Formating review, using imperative mode in comments

This commit is contained in:
Ray
2026-03-03 22:40:34 +01:00
parent bf830c3f7b
commit b4746469d4
18 changed files with 164 additions and 161 deletions

View File

@ -1522,7 +1522,7 @@ int InitPlatform(void)
glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_FALSE);
#endif
#if defined(_GLFW_WAYLAND) && !defined(_GLFW_X11)
// GLFW 3.4+ defaults GLFW_SCALE_FRAMEBUFFER to TRUE,
// GLFW 3.4+ defaults GLFW_SCALE_FRAMEBUFFER to TRUE,
// causing framebuffer/window size mismatch on Wayland with display scaling
glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_FALSE);
#endif
@ -1727,12 +1727,12 @@ int InitPlatform(void)
#if !defined(__APPLE__)
if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND)
{
// On Wayland, GLFW_SCALE_FRAMEBUFFER handles scaling; read actual framebuffer size
// On Wayland, GLFW_SCALE_FRAMEBUFFER handles scaling; read actual framebuffer size
// instead of resizing the window (which would double-scale)
int fbWidth = 0;
int fbHeight = 0;
glfwGetFramebufferSize(platform.handle, &fbWidth, &fbHeight);
CORE.Window.render.width = fbWidth;
CORE.Window.render.height = fbHeight;
}
@ -1751,7 +1751,7 @@ int InitPlatform(void)
// Current active framebuffer size is main framebuffer size
CORE.Window.currentFbo = CORE.Window.render;
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully %s",
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully %s",
FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI)? "(HighDPI)" : "");
TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
@ -1935,14 +1935,14 @@ static void FramebufferSizeCallback(GLFWwindow *window, int width, int height)
int winWidth = 0;
int winHeight = 0;
glfwGetWindowSize(platform.handle, &winWidth, &winHeight);
if ((winWidth != width) || (winHeight != height))
{
CORE.Window.screen.width = winWidth;
CORE.Window.screen.height = winHeight;
float scaleX = (float)width/winWidth;
float scaleY = (float)height/winHeight;
CORE.Window.screenScale = MatrixScale(scaleX, scaleY, 1.0f);
}
}

View File

@ -479,7 +479,7 @@ void ToggleFullscreen(void)
if (!FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
{
FLAG_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
// Store previous window position (in case we exit fullscreen)
// Store previous window position (in case of exiting fullscreen)
Vector2 currentPosition = GetWindowPosition();
CORE.Window.previousPosition.x = currentPosition.x;
CORE.Window.previousPosition.y = currentPosition.y;
@ -493,7 +493,7 @@ void ToggleFullscreen(void)
{
FLAG_CLEAR(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
// we update the window position right away
// Update the window position right away
CORE.Window.position = CORE.Window.previousPosition;
RGFW_window_setFullscreen(platform.window, 0);
RGFW_window_move(platform.window, CORE.Window.position.x, CORE.Window.position.y);
@ -534,7 +534,7 @@ void ToggleBorderlessWindowed(void)
{
FLAG_CLEAR(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE);
RGFW_window_setBorder(platform.window, 1);
CORE.Window.position = CORE.Window.previousPosition;
RGFW_window_resize(platform.window, CORE.Window.previousScreen.width, CORE.Window.previousScreen.height);
@ -821,7 +821,7 @@ void SetWindowSize(int width, int height)
CORE.Window.screen.width = width;
CORE.Window.screen.height = height;
}
RGFW_window_resize(platform.window, CORE.Window.screen.width, CORE.Window.screen.height);
}
@ -957,17 +957,17 @@ Vector2 GetWindowScaleDPI(void)
else monitor = RGFW_getPrimaryMonitor();
#if defined(__APPLE__)
// apple does < 1.0f scaling, example: 0.66f, 0.5f
// we want to convert this to be consistent
return (Vector2){ 1.0f / monitor->scaleX, 1.0f / monitor->scaleX };
// Apple does < 1.0f scaling, example: 0.66f, 0.5f
// it needs to be convert to be consistent
return (Vector2){ 1.0f/monitor->scaleX, 1.0f/monitor->scaleX };
#else
// linux and windows do >= 1.0f scaling, example: 1.0f, 1.25f, 2.0f
// Linux and Windows do >= 1.0f scaling, example: 1.0f, 1.25f, 2.0f
return (Vector2){ monitor->scaleX, monitor->scaleX };
#endif
}
// Not part of raylib. Mac has a different pixel ratio for retina displays
// and we want to be able to handle it
// Get monitor pixel ratio
// WARNING: Function not used, neither exposed by raylib
float GetMonitorPixelRatio(void)
{
RGFW_monitor *monitor = NULL;
@ -1009,7 +1009,7 @@ const char *GetClipboardText(void)
Image GetClipboardImage(void)
{
Image image = { 0 };
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES
#if defined(_WIN32)
@ -1283,8 +1283,8 @@ void PollInputEvents(void)
{
if (CORE.Window.dropFileCount == 0)
{
// When a new file is dropped, we reserve a fixed number of slots for all possible dropped files
// at the moment we limit the number of drops at once to 1024 files but this behaviour should probably be reviewed
// When a new file is dropped, reserve a fixed number of slots for all possible dropped files
// at the moment limiting the number of drops at once to 1024 files but this behaviour should probably be reviewed
// TODO: Pointers should probably be reallocated for any new file added...
CORE.Window.dropFilepaths = (char **)RL_CALLOC(1024, sizeof(char *));
@ -1331,19 +1331,20 @@ void PollInputEvents(void)
CORE.Window.currentFbo.width = CORE.Window.render.width;
CORE.Window.currentFbo.height = CORE.Window.render.height;
#elif defined(PLATFORM_WEB_RGFW)
// do nothing for web
return;
#else
SetupViewport(platform.window->w, platform.window->h);
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
// Consider content scaling if required
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
{
Vector2 scaleDpi = GetWindowScaleDPI();
CORE.Window.screen.width = (int)(platform.window->w/scaleDpi.x);
CORE.Window.screen.height = (int)(platform.window->h/scaleDpi.y);
CORE.Window.screenScale = MatrixScale(scaleDpi.x, scaleDpi.y, 1.0f);
// mouse scale doesnt seem needed
// SetMouseScale(1.0f/scaleDpi.x, 1.0f/scaleDpi.y);
// Mouse scale does not seem to be needed
//SetMouseScale(1.0f/scaleDpi.x, 1.0f/scaleDpi.y);
}
else
{
@ -1403,7 +1404,7 @@ void PollInputEvents(void)
case RGFW_keyChar:
{
// NOTE: event.text.text data comes an UTF-8 text sequence but we register codepoints (int)
// NOTE: event.text.text data comes an UTF-8 text sequence but registering codepoints (int)
// Check if there is space available in the queue
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
{
@ -1664,7 +1665,7 @@ int InitPlatform(void)
//----------------------------------------------------------------------------
// If everything work as expected, we can continue
// If everything work as expected, continue
CORE.Window.position.x = platform.window->x;
CORE.Window.position.y = platform.window->y;
CORE.Window.render.width = CORE.Window.screen.width;

View File

@ -250,10 +250,10 @@ static const int CursorsLUT[] = {
//SDL_SYSTEM_CURSOR_WAITARROW, // No equivalent implemented on MouseCursor enum on raylib.h
};
// SDL3 Migration Layer made to avoid 'ifdefs' inside functions when we can
// SDL3 migration layer made to avoid 'ifdefs' inside functions
#if defined(USING_VERSION_SDL3)
// SDL3 Migration:
// SDL3 migration:
// SDL_WINDOW_FULLSCREEN_DESKTOP has been removed,
// SDL_GetWindowFullscreenMode() can be called
// to see whether an exclusive fullscreen mode will be used
@ -265,10 +265,10 @@ static const int CursorsLUT[] = {
#define SDL_ENABLE true
// SDL3 Migration: SDL_INIT_TIMER - no longer needed before calling SDL_AddTimer()
#define SDL_INIT_TIMER 0x0 // It's a flag, so no problem in setting it to zero if we use in a bitor (|)
#define SDL_INIT_TIMER 0x0 // It's a flag, so no problem in setting it to zero to be used in a bitor (|)
// SDL3 Migration: The SDL_WINDOW_SHOWN flag has been removed. Windows are shown by default and can be created hidden by using the SDL_WINDOW_HIDDEN flag
#define SDL_WINDOW_SHOWN 0x0 // It's a flag, so no problem in setting it to zero if we use in a bitor (|)
#define SDL_WINDOW_SHOWN 0x0 // It's a flag, so no problem in setting it to zero to be used in a bitor (|)
// SDL3 Migration: Renamed
// IMPORTANT: Might need to call SDL_CleanupEvent somewhere see :https://github.com/libsdl-org/SDL/issues/3540#issuecomment-1793449852
@ -414,13 +414,14 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID)
#else // SDL2 fallback
// Since SDL2 doesn't have this function we leave a stub
// Since SDL2 doesn't have this function, leaving a stub
// SDL_GetClipboardData function is available since SDL 3.1.3. (e.g. SDL3)
void *SDL_GetClipboardData(const char *mime_type, size_t *size)
{
TRACELOG(LOG_WARNING, "SDL: Getting clipboard data that is not text not available in SDL2");
// We could possibly implement it ourselves in this case for some easier platforms
// TODO: Implement getting clipboard data
return NULL;
}
#endif // USING_VERSION_SDL3
@ -573,8 +574,6 @@ void SetWindowState(unsigned int flags)
}
if (FLAG_IS_SET(flags, FLAG_WINDOW_UNFOCUSED))
{
// NOTE: To be able to implement this part it seems that we should
// do it ourselves, via 'windows.h', 'X11/Xlib.h' or even 'Cocoa.h'
TRACELOG(LOG_WARNING, "SetWindowState() - FLAG_WINDOW_UNFOCUSED is not supported on PLATFORM_DESKTOP_SDL");
}
if (FLAG_IS_SET(flags, FLAG_WINDOW_TOPMOST))
@ -856,8 +855,8 @@ void SetWindowMonitor(int monitor)
// ending up positioned partly outside the target display
// NOTE 2: The workaround for that is, previously to moving the window,
// setting the window size to the target display size, so they match
// NOTE 3: It wasn't done here because we can't assume changing the window size automatically
// is acceptable behavior by the user
// NOTE 3: It wasn't done here because it can not bee assumed that changing
// the window size automatically is acceptable behavior by the user
SDL_SetWindowPosition(platform.window, usableBounds.x, usableBounds.y);
CORE.Window.position.x = usableBounds.x;
CORE.Window.position.y = usableBounds.y;
@ -1261,7 +1260,7 @@ void DisableCursor(void)
void SwapScreenBuffer(void)
{
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
// NOTE: We use a preprocessor condition here because rlCopyFramebuffer() is only declared for software rendering
// NOTE: Using a preprocessor condition here because rlCopyFramebuffer() is only declared for software rendering
SDL_Surface *surface = SDL_GetWindowSurface(platform.window);
rlCopyFramebuffer(0, 0, CORE.Window.render.width, CORE.Window.render.height, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, surface->pixels);
SDL_UpdateWindowSurface(platform.window);
@ -1442,8 +1441,8 @@ void PollInputEvents(void)
{
if (CORE.Window.dropFileCount == 0)
{
// When a new file is dropped, we reserve a fixed number of slots for all possible dropped files
// at the moment we limit the number of drops at once to 1024 files but this behaviour should probably be reviewed
// When a new file is dropped, reserve a fixed number of slots for all possible dropped files
// at the moment limit the number of drops at once to 1024 files but this behaviour should probably be reviewed
// TODO: Pointers should probably be reallocated for any new file added...
CORE.Window.dropFilepaths = (char **)RL_CALLOC(1024, sizeof(char *));
@ -1497,7 +1496,8 @@ void PollInputEvents(void)
const int width = event.window.data1;
const int height = event.window.data2;
SetupViewport(width, height);
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
// Consider content scaling if required
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
{
CORE.Window.screen.width = (int)(width/GetWindowScaleDPI().x);
@ -1622,7 +1622,7 @@ void PollInputEvents(void)
case SDL_TEXTINPUT:
{
// NOTE: event.text.text data comes an UTF-8 text sequence but we register codepoints (int)
// NOTE: event.text.text data comes an UTF-8 text sequence but register codepoints (int)
// Check if there is space available in the queue
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
@ -1885,7 +1885,7 @@ void PollInputEvents(void)
{
if (platform.gamepadId[i] == event.jaxis.which)
{
// SDL axis value range is -32768 to 32767, we normalize it to raylib's -1.0 to 1.0f range
// SDL axis value range is -32768 to 32767, normalizing it to raylib's -1.0 to 1.0f range
float value = event.jaxis.value/(float)32767;
CORE.Input.Gamepad.axisState[i][axis] = value;
@ -2032,7 +2032,7 @@ int InitPlatform(void)
platform.window = SDL_CreateWindow(CORE.Window.title, CORE.Window.screen.width, CORE.Window.screen.height, flags);
// NOTE: SDL3 no longer enables text input by default,
// NOTE: SDL3 no longer enables text input by default,
// it is needed to be enabled manually to keep GetCharPressed() working
// REF: https://github.com/libsdl-org/SDL/commit/72fc6f86e5d605a3787222bc7dc18c5379047f4a
const char *enableOSK = SDL_GetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD);

View File

@ -995,7 +995,7 @@ void SetWindowMaxSize(int width, int height)
CORE.Window.screenMax.width = width;
CORE.Window.screenMax.height = height;
SetWindowSize(platform.appScreenWidth, platform.appScreenHeight);
}
@ -1771,7 +1771,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
SIZE maxWindowSize = CalcWindowSize(96, maxClientSize, style);
SIZE minClientSize = { CORE.Window.screenMin.width, CORE.Window.screenMin.height };
SIZE minWindowSize = CalcWindowSize(96, minClientSize, style);
LPMINMAXINFO lpmmi = (LPMINMAXINFO) lparam;
lpmmi->ptMaxSize.x = maxWindowSize.cx;
lpmmi->ptMaxSize.y = maxWindowSize.cy;
@ -1865,7 +1865,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
case WM_SIZE:
{
// WARNING: Don't trust the docs, they say this message can not be obtained if not calling DefWindowProc()
// in response to WM_WINDOWPOSCHANGED but looks like when a window is created,
// in response to WM_WINDOWPOSCHANGED but looks like when a window is created,
// this message can be obtained without getting WM_WINDOWPOSCHANGED
HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
} break;
@ -1880,7 +1880,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
SIZE *inoutSize = (SIZE *)lparam;
UINT newDpi = (UINT)wparam; // TODO: WARNING: Converting from WPARAM = UINT_PTR
// For the following flag changes, a window resize event should be posted,
// For the following flag changes, a window resize event should be posted,
// TODO: Should it be done after dpi changes?
if (CORE.Window.flags & FLAG_WINDOW_MINIMIZED) return TRUE;
if (CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) return TRUE;
@ -2188,7 +2188,7 @@ static unsigned SanitizeFlags(int mode, unsigned flags)
// the state continues to change
//
// This design takes care of many odd corner cases. For example, in case of restoring
// a window that was previously maximized AND minimized and those two flags need to be removed,
// a window that was previously maximized AND minimized and those two flags need to be removed,
// ShowWindow with SW_RESTORE twice need to bee actually calleed. Another example is
// wheen having a maximized window, if the undecorated flag is modified then the window style
// needs to be updated, but updating the style would mean the window size would change

View File

@ -58,7 +58,7 @@
#include <linux/joystick.h> // Linux: Joystick support library
// WARNING: Both 'linux/input.h' and 'raylib.h' define KEY_F12
// To avoid conflict with the capturing code in rcore.c we undefine the macro KEY_F12,
// To avoid conflict with the capturing code in rcore.c, undefine the macro KEY_F12,
// so the enum KEY_F12 from raylib is used
#undef KEY_F12
@ -97,7 +97,7 @@
#define DEFAULT_EVDEV_PATH "/dev/input/" // Path to the linux input events
// Actually biggest key is KEY_CNT but we only really map the keys up to KEY_ALS_TOGGLE
// Actually biggest key is KEY_CNT but only mapping keys up to KEY_ALS_TOGGLE
#define KEYMAP_SIZE KEY_ALS_TOGGLE
//----------------------------------------------------------------------------------
@ -1428,7 +1428,7 @@ int InitPlatform(void)
if ((eglClientExtensions != NULL) && (strstr(eglClientExtensions, "EGL_EXT_platform_base") != NULL))
{
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
if (eglGetPlatformDisplayEXT != NULL) platform.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, platform.gbmDevice, NULL);
}

View File

@ -341,7 +341,7 @@ void SwapScreenBuffer(void)
double GetTime(void)
{
double time = 0.0;
struct timespec ts = { 0 };
clock_gettime(CLOCK_MONOTONIC, &ts);
unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
@ -459,7 +459,7 @@ int InitPlatform(void)
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
{
// TODO: Enable MSAA
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4");
}
@ -489,7 +489,7 @@ int InitPlatform(void)
}
//----------------------------------------------------------------------------
// If everything work as expected, we can continue
// If everything worked as expected, continue
CORE.Window.render.width = CORE.Window.screen.width;
CORE.Window.render.height = CORE.Window.screen.height;
CORE.Window.currentFbo.width = CORE.Window.render.width;

View File

@ -1255,7 +1255,7 @@ int InitPlatform(void)
// Remember center for switchinging from fullscreen to window
if ((CORE.Window.screen.height == CORE.Window.display.height) && (CORE.Window.screen.width == CORE.Window.display.width))
{
// If screen width/height equal to the display, it's not possible to
// If screen width/height equal to the display, it's not possible to
// calculate the window position for toggling full-screened/windowed
CORE.Window.position.x = CORE.Window.display.width/4;
CORE.Window.position.y = CORE.Window.display.height/4;