mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-15 10:19:18 -05:00
REVIEWED: Comments to impersonal format
This commit is contained in:
@ -290,8 +290,8 @@ FILE *funopen(const void *cookie, int (*readfn)(void *, char *, int), int (*writ
|
||||
// Module Functions Definition: Application
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// To allow easier porting to android, we allow the user to define a
|
||||
// main function which we call from android_main, defined by ourselves
|
||||
// To allow easier porting to android, allow the user to define a
|
||||
// custom main function which is called from android_main
|
||||
extern int main(int argc, char *argv[]);
|
||||
|
||||
// Android main function
|
||||
@ -313,7 +313,7 @@ void android_main(struct android_app *app)
|
||||
// Waiting for application events before complete finishing
|
||||
while (!app->destroyRequested)
|
||||
{
|
||||
// Poll all events until we reach return value TIMEOUT, meaning no events left to process
|
||||
// Poll all events until return value TIMEOUT is reached, meaning no events left to process
|
||||
while ((pollResult = ALooper_pollOnce(0, NULL, &pollEvents, (void **)&platform.source)) > ALOOPER_POLL_TIMEOUT)
|
||||
{
|
||||
if (platform.source != NULL) platform.source->process(app, platform.source);
|
||||
@ -640,9 +640,9 @@ double GetTime(void)
|
||||
}
|
||||
|
||||
// Open URL with default system browser (if available)
|
||||
// NOTE: This function is only safe to use if you control the URL given
|
||||
// NOTE: This function is only safe to use if the provided URL is safe
|
||||
// A user could craft a malicious string performing another action
|
||||
// Only call this function yourself not with user input or make sure to check the string yourself
|
||||
// Avoid calling this function with user input non-validated strings
|
||||
void OpenURL(const char *url)
|
||||
{
|
||||
// Security check to (partially) avoid malicious code
|
||||
@ -757,7 +757,7 @@ void PollInputEvents(void)
|
||||
int pollResult = 0;
|
||||
int pollEvents = 0;
|
||||
|
||||
// Poll Events (registered events) until we reach TIMEOUT which indicates there are no events left to poll
|
||||
// Poll Events (registered events) until TIMEOUT is reached which indicates there are no events left to poll
|
||||
// NOTE: Activity is paused if not enabled (platform.appEnabled) and always run flag is not set (FLAG_WINDOW_ALWAYS_RUN)
|
||||
while ((pollResult = ALooper_pollOnce((platform.appEnabled || FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_ALWAYS_RUN))? 0 : -1, NULL, &pollEvents, ((void **)&platform.source)) > ALOOPER_POLL_TIMEOUT))
|
||||
{
|
||||
@ -843,7 +843,7 @@ int InitPlatform(void)
|
||||
// Wait for window to be initialized (display and context)
|
||||
while (!CORE.Window.ready)
|
||||
{
|
||||
// Process events until we reach TIMEOUT, which indicates no more events queued
|
||||
// Process events until TIMEOUT is reached, which indicates no more events queued
|
||||
while ((pollResult = ALooper_pollOnce(0, NULL, &pollEvents, ((void **)&platform.source)) > ALOOPER_POLL_TIMEOUT))
|
||||
{
|
||||
// Process this event
|
||||
@ -964,10 +964,10 @@ static int InitGraphicsDevice(void)
|
||||
EGLint displayFormat = 0;
|
||||
|
||||
// EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is guaranteed to be accepted by ANativeWindow_setBuffersGeometry()
|
||||
// As soon as we picked a EGLConfig, we can safely reconfigure the ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID
|
||||
// As soon as an EGLConfig is picked, it's safe to reconfigure the ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID
|
||||
eglGetConfigAttrib(platform.device, platform.config, EGL_NATIVE_VISUAL_ID, &displayFormat);
|
||||
|
||||
// At this point we need to manage render size vs screen size
|
||||
// At this point render size vs screen size needs to be managed
|
||||
// NOTE: This function use and modify global module variables:
|
||||
// -> CORE.Window.screen.width/CORE.Window.screen.height
|
||||
// -> CORE.Window.render.width/CORE.Window.render.height
|
||||
@ -1075,12 +1075,12 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
|
||||
Rectangle rec = GetFontDefault().recs[95];
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
|
||||
{
|
||||
// NOTE: We try to maxime rec padding to avoid pixel bleeding on MSAA filtering
|
||||
// NOTE: Trying to maxime rec padding to avoid pixel bleeding on MSAA filtering
|
||||
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 2, rec.y + 2, 1, 1 });
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE: We set up a 1px padding on char rectangle to avoid pixel bleeding
|
||||
// NOTE: Setting up a 1px padding on char rectangle to avoid pixel bleeding
|
||||
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 1, rec.y + 1, rec.width - 2, rec.height - 2 });
|
||||
}
|
||||
#endif
|
||||
@ -1450,7 +1450,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||
// NOTE: Global variables CORE.Window.render.width/CORE.Window.render.height and CORE.Window.renderOffset.x/CORE.Window.renderOffset.y can be modified
|
||||
static void SetupFramebuffer(int width, int height)
|
||||
{
|
||||
// Calculate CORE.Window.render.width and CORE.Window.render.height, we have the display size (input params) and the desired screen size (global var)
|
||||
// Calculate CORE.Window.render.width and CORE.Window.render.height, having the display size (input params) and the desired screen size (global var)
|
||||
if ((CORE.Window.screen.width > CORE.Window.display.width) || (CORE.Window.screen.height > CORE.Window.display.height))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "DISPLAY: Downscaling required: Screen size (%ix%i) is bigger than display size (%ix%i)", CORE.Window.screen.width, CORE.Window.screen.height, CORE.Window.display.width, CORE.Window.display.height);
|
||||
@ -1478,8 +1478,8 @@ static void SetupFramebuffer(int width, int height)
|
||||
float scaleRatio = (float)CORE.Window.render.width/(float)CORE.Window.screen.width;
|
||||
CORE.Window.screenScale = MatrixScale(scaleRatio, scaleRatio, 1.0f);
|
||||
|
||||
// NOTE: We render to full display resolution!
|
||||
// We just need to calculate above parameters for downscale matrix and offsets
|
||||
// NOTE: Rendering to full display resolution
|
||||
// Above parameters need to be calculate for downscale matrix and offsets
|
||||
CORE.Window.render.width = CORE.Window.display.width;
|
||||
CORE.Window.render.height = CORE.Window.display.height;
|
||||
|
||||
@ -1533,8 +1533,8 @@ FILE *android_fopen(const char *fileName, const char *mode)
|
||||
if (mode[0] == 'w')
|
||||
{
|
||||
// NOTE: fopen() is mapped to android_fopen() that only grants read access to
|
||||
// assets directory through AAssetManager but we want to also be able to
|
||||
// write data when required using the standard stdio FILE access functions
|
||||
// assets directory through AAssetManager but it could be required to write data
|
||||
// using the standard stdio FILE access functions
|
||||
// REF: https://stackoverflow.com/questions/11294487/android-writing-saving-files-from-native-code-only
|
||||
#undef fopen
|
||||
file = fopen(TextFormat("%s/%s", platform.app->activity->internalDataPath, fileName), mode);
|
||||
|
||||
@ -255,9 +255,9 @@ static const int CursorsLUT[] = {
|
||||
|
||||
// SDL3 Migration:
|
||||
// SDL_WINDOW_FULLSCREEN_DESKTOP has been removed,
|
||||
// and you can call SDL_GetWindowFullscreenMode()
|
||||
// SDL_GetWindowFullscreenMode() can be called
|
||||
// to see whether an exclusive fullscreen mode will be used
|
||||
// or the borderless fullscreen desktop mode will be used
|
||||
// or the borderless fullscreen desktop mode
|
||||
#define SDL_WINDOW_FULLSCREEN_DESKTOP SDL_WINDOW_FULLSCREEN
|
||||
|
||||
#define SDL_IGNORE false
|
||||
@ -1269,9 +1269,9 @@ double GetTime(void)
|
||||
}
|
||||
|
||||
// Open URL with default system browser (if available)
|
||||
// NOTE: This function is only safe to use if you control the URL given
|
||||
// NOTE: This function is only safe to use if the provided URL is safe
|
||||
// A user could craft a malicious string performing another action
|
||||
// Only call this function yourself not with user input or make sure to check the string yourself
|
||||
// Avoid calling this function with user input non-validated strings
|
||||
// REF: https://github.com/raysan5/raylib/issues/686
|
||||
void OpenURL(const char *url)
|
||||
{
|
||||
@ -1437,9 +1437,9 @@ void PollInputEvents(void)
|
||||
|
||||
#if defined(USING_VERSION_SDL3)
|
||||
// const char *data; // The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events
|
||||
// Event memory is now managed by SDL, so you should not free the data in SDL_EVENT_DROP_FILE,
|
||||
// and if you want to hold onto the text in SDL_EVENT_TEXT_EDITING and SDL_EVENT_TEXT_INPUT events,
|
||||
// you should make a copy of it. SDL_TEXTINPUTEVENT_TEXT_SIZE is no longer necessary and has been removed
|
||||
// Event memory is now managed by SDL, so it should not be freed in SDL_EVENT_DROP_FILE,
|
||||
// in case data needs to be hold onto the text in SDL_EVENT_TEXT_EDITING and SDL_EVENT_TEXT_INPUT events,
|
||||
// a copy is required, SDL_TEXTINPUTEVENT_TEXT_SIZE is no longer necessary and has been removed
|
||||
strncpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.data, MAX_FILEPATH_LENGTH - 1);
|
||||
#else
|
||||
strncpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.file, MAX_FILEPATH_LENGTH - 1);
|
||||
@ -1468,10 +1468,10 @@ void PollInputEvents(void)
|
||||
// Window events are also polled (minimized, maximized, close...)
|
||||
|
||||
#ifndef USING_VERSION_SDL3
|
||||
// SDL3 states:
|
||||
// The SDL_WINDOWEVENT_* events have been moved to top level events, and SDL_WINDOWEVENT has been removed
|
||||
// In general, handling this change just means checking for the individual events instead of first checking for SDL_WINDOWEVENT
|
||||
// and then checking for window events. You can compare the event >= SDL_EVENT_WINDOW_FIRST and <= SDL_EVENT_WINDOW_LAST if you need to see whether it's a window event
|
||||
// and then checking for window events; Events >= SDL_EVENT_WINDOW_FIRST and <= SDL_EVENT_WINDOW_LAST can be compared
|
||||
// to see whether it's a window event
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
switch (event.window.event)
|
||||
|
||||
@ -1244,9 +1244,9 @@ double GetTime(void)
|
||||
}
|
||||
|
||||
// Open URL with default system browser (if available)
|
||||
// NOTE: This function is only safe to use if you control the URL given
|
||||
// NOTE: This function is only safe to use if the provided URL is safe
|
||||
// A user could craft a malicious string performing another action
|
||||
// Only call this function yourself not with user input or make sure to check the string yourself
|
||||
// Avoid calling this function with user input non-validated strings
|
||||
// REF: https://github.com/raysan5/raylib/issues/686
|
||||
void OpenURL(const char *url)
|
||||
{
|
||||
@ -1864,9 +1864,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
|
||||
} break;
|
||||
case WM_SIZE:
|
||||
{
|
||||
// WARNING: Don't trust the docs, they say you won't get this message if you don't call DefWindowProc
|
||||
// in response to WM_WINDOWPOSCHANGED but looks like when a window is created you'll get this
|
||||
// message without getting WM_WINDOWPOSCHANGED
|
||||
// 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,
|
||||
// this message can be obtained without getting WM_WINDOWPOSCHANGED
|
||||
HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
|
||||
} break;
|
||||
//case WM_MOVE
|
||||
@ -2187,10 +2187,10 @@ static unsigned SanitizeFlags(int mode, unsigned flags)
|
||||
// window. This function will continue to perform these update operations so long as
|
||||
// the state continues to change
|
||||
//
|
||||
// This design takes care of many odd corner cases. For example, if you want to restore
|
||||
// a window that was previously maximized AND minimized and you want to remove both these
|
||||
// flags, you actually need to call ShowWindow with SW_RESTORE twice. Another example is
|
||||
// if you have a maximized window, if the undecorated flag is modified then the window style
|
||||
// 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,
|
||||
// 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
|
||||
// causing the window to lose its Maximized state which would mean the window size
|
||||
// needs to be updated, followed by the update of window style, a second time, to restore that maximized
|
||||
|
||||
@ -1017,10 +1017,9 @@ double GetTime(void)
|
||||
}
|
||||
|
||||
// Open URL with default system browser (if available)
|
||||
// NOTE: This function is only safe to use if you control the URL given
|
||||
// NOTE: This function is only safe to use if the provided URL is safe
|
||||
// A user could craft a malicious string performing another action
|
||||
// Only call this function yourself not with user input or make sure to check the string yourself
|
||||
// REF: https://github.com/raysan5/raylib/issues/686
|
||||
// Avoid calling this function with user input non-validated strings
|
||||
void OpenURL(const char *url)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "OpenURL() not implemented on target platform");
|
||||
@ -2149,14 +2148,11 @@ static void ConfigureEvdevDevice(char *device)
|
||||
|
||||
if (absAxisCount > 0)
|
||||
{
|
||||
// TODO / NOTE
|
||||
// TODO: Review GamepadAxis enum matching
|
||||
// So gamepad axes (as in the actual linux joydev.c) are just simply enumerated
|
||||
// and (at least for some input drivers like xpat) it's convention to use
|
||||
// ABS_X, ABX_Y for one joystick ABS_RX, ABS_RY for the other and the Z axes for the
|
||||
// shoulder buttons
|
||||
// If these are now enumerated you get LJOY_X, LJOY_Y, LEFT_SHOULDERB, RJOY_X, ...
|
||||
// That means they don't match the GamepadAxis enum
|
||||
// This could be fixed
|
||||
// ABS_X, ABX_Y for one joystick ABS_RX, ABS_RY for the other and the Z axes for the shoulder buttons
|
||||
// If these are now enumerated, it results to LJOY_X, LJOY_Y, LEFT_SHOULDERB, RJOY_X, ...
|
||||
int axisIndex = 0;
|
||||
for (int axis = ABS_X; axis < ABS_PRESSURE; axis++)
|
||||
{
|
||||
|
||||
@ -173,7 +173,7 @@ bool WindowShouldClose(void)
|
||||
// and encapsulating one frame execution on a UpdateDrawFrame() function,
|
||||
// allowing the browser to manage execution asynchronously
|
||||
|
||||
// Optionally we can manage the time we give-control-back-to-browser if required,
|
||||
// Optionally, time to give-control-back-to-browser can be managed here,
|
||||
// but it seems below line could generate stuttering on some browsers
|
||||
emscripten_sleep(12);
|
||||
|
||||
@ -921,9 +921,9 @@ double GetTime(void)
|
||||
}
|
||||
|
||||
// Open URL with default system browser (if available)
|
||||
// NOTE: This function is only safe to use if you control the URL given
|
||||
// NOTE: This function is only safe to use if the provided URL is safe
|
||||
// A user could craft a malicious string performing another action
|
||||
// Only call this function yourself not with user input or make sure to check the string yourself
|
||||
// Avoid calling this function with user input non-validated strings
|
||||
void OpenURL(const char *url)
|
||||
{
|
||||
// Security check to (partially) avoid malicious code on target platform
|
||||
@ -1252,11 +1252,11 @@ int InitPlatform(void)
|
||||
#else
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
|
||||
{
|
||||
// remember center for switchinging from fullscreen to window
|
||||
// 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, we can't calculate the window pos for toggling full-screened/windowed
|
||||
// Toggling full-screened/windowed with pos(0, 0) can cause problems in some platforms, such as X11
|
||||
// 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;
|
||||
}
|
||||
@ -1367,7 +1367,7 @@ int InitPlatform(void)
|
||||
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_MINIMIZED)) MinimizeWindow();
|
||||
|
||||
// If graphic device is no properly initialized, we end program
|
||||
// If graphic device is no properly initialized, end program
|
||||
if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); return -1; }
|
||||
|
||||
// Load OpenGL extensions
|
||||
@ -1491,7 +1491,7 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
// In case previous dropped filepaths have not been freed, we free them
|
||||
// In case previous dropped filepaths have not been freed, free them
|
||||
if (CORE.Window.dropFileCount > 0)
|
||||
{
|
||||
for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilepaths[i]);
|
||||
@ -1502,7 +1502,7 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths
|
||||
CORE.Window.dropFilepaths = NULL;
|
||||
}
|
||||
|
||||
// WARNING: Paths are freed by GLFW when the callback returns, we must keep an internal copy
|
||||
// WARNING: Paths are freed by GLFW when the callback returns, an internal copy must freed
|
||||
CORE.Window.dropFileCount = count;
|
||||
CORE.Window.dropFilepaths = (char **)RL_CALLOC(CORE.Window.dropFileCount, sizeof(char *));
|
||||
|
||||
@ -1519,7 +1519,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
||||
{
|
||||
if (key < 0) return; // Security check, macOS fn key generates -1
|
||||
|
||||
// WARNING: GLFW could return GLFW_REPEAT, we need to consider it as 1
|
||||
// WARNING: GLFW could return GLFW_REPEAT, it needs to be considered as 1
|
||||
// to work properly with our implementation (IsKeyDown/IsKeyUp checks)
|
||||
if (action == GLFW_RELEASE) CORE.Input.Keyboard.currentKeyState[key] = 0;
|
||||
else if (action == GLFW_PRESS) CORE.Input.Keyboard.currentKeyState[key] = 1;
|
||||
@ -1721,7 +1721,7 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
|
||||
double canvasWidth = 0.0;
|
||||
double canvasHeight = 0.0;
|
||||
// NOTE: emscripten_get_canvas_element_size() returns canvas.width and canvas.height but
|
||||
// we are looking for actual CSS size: canvas.style.width and canvas.style.height
|
||||
// actual CSS size needs to be considered: canvas.style.width and canvas.style.height
|
||||
// EMSCRIPTEN_RESULT res = emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight);
|
||||
emscripten_get_element_css_size(platform.canvasId, &canvasWidth, &canvasHeight);
|
||||
|
||||
@ -1741,7 +1741,7 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
|
||||
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) CORE.Input.Touch.currentTouchState[i] = 0;
|
||||
}
|
||||
|
||||
// Update mouse position if we detect a single touch
|
||||
// Update mouse position when single touch detected
|
||||
if (CORE.Input.Touch.pointCount == 1)
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition.x = CORE.Input.Touch.position[0].x;
|
||||
|
||||
@ -908,9 +908,9 @@ double GetTime(void)
|
||||
}
|
||||
|
||||
// Open URL with default system browser (if available)
|
||||
// NOTE: This function is only safe to use if you control the URL given
|
||||
// NOTE: This function is only safe to use if the provided URL is safe
|
||||
// A user could craft a malicious string performing another action
|
||||
// Only call this function yourself not with user input or make sure to check the string yourself
|
||||
// Avoid calling this function with user input non-validated strings
|
||||
void OpenURL(const char *url)
|
||||
{
|
||||
// Security check to (partially) avoid malicious code on target platform
|
||||
|
||||
Reference in New Issue
Block a user