mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-15 10:19:18 -05:00
REVIEWED: Some comments (Code Gardening)
This commit is contained in:
@ -1189,7 +1189,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||
if (FLAG_IS_SET(source, AINPUT_SOURCE_JOYSTICK) ||
|
||||
FLAG_IS_SET(source, AINPUT_SOURCE_GAMEPAD))
|
||||
{
|
||||
// For now we'll assume a single gamepad which we "detect" on its input event
|
||||
// Assuming a single gamepad, "detected" on its input event
|
||||
CORE.Input.Gamepad.ready[0] = true;
|
||||
|
||||
CORE.Input.Gamepad.axisState[0][GAMEPAD_AXIS_LEFT_X] = AMotionEvent_getAxisValue(
|
||||
@ -1256,7 +1256,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||
FLAG_IS_SET(source, AINPUT_SOURCE_GAMEPAD)) &&
|
||||
!FLAG_IS_SET(source, AINPUT_SOURCE_KEYBOARD))
|
||||
{
|
||||
// For now we'll assume a single gamepad which we "detect" on its input event
|
||||
// Assuming a single gamepad, "detected" on its input event
|
||||
CORE.Input.Gamepad.ready[0] = true;
|
||||
|
||||
GamepadButton button = AndroidTranslateGamepadButton(keycode);
|
||||
|
||||
@ -602,7 +602,7 @@ void SetWindowIcon(Image image)
|
||||
icon[0].height = image.height;
|
||||
icon[0].pixels = (unsigned char *)image.data;
|
||||
|
||||
// NOTE 1: We only support one image icon
|
||||
// NOTE 1: Only one image icon supported
|
||||
// NOTE 2: The specified image data is copied before this function returns
|
||||
glfwSetWindowIcon(platform.handle, 1, icon);
|
||||
}
|
||||
@ -833,7 +833,7 @@ int GetCurrentMonitor(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
// In case the window is between two monitors, we use below logic
|
||||
// In case the window is between two monitors, below logic is used
|
||||
// to try to detect the "current monitor" for that window, note that
|
||||
// this is probably an overengineered solution for a very side case
|
||||
// trying to match SDL behaviour
|
||||
@ -1186,7 +1186,7 @@ void SetMouseCursor(int cursor)
|
||||
if (cursor == MOUSE_CURSOR_DEFAULT) glfwSetCursor(platform.handle, NULL);
|
||||
else
|
||||
{
|
||||
// NOTE: We are relating internal GLFW enum values to our MouseCursor enum values
|
||||
// NOTE: Mapping internal GLFW enum values to MouseCursor enum values
|
||||
glfwSetCursor(platform.handle, glfwCreateStandardCursor(0x00036000 + cursor));
|
||||
}
|
||||
}
|
||||
@ -1247,7 +1247,7 @@ void PollInputEvents(void)
|
||||
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
|
||||
|
||||
// Check if gamepads are ready
|
||||
// NOTE: We do it here in case of disconnection
|
||||
// NOTE: Doing it here in case of disconnection
|
||||
for (int i = 0; i < MAX_GAMEPADS; i++)
|
||||
{
|
||||
if (glfwJoystickPresent(i)) CORE.Input.Gamepad.ready[i] = true;
|
||||
@ -1263,7 +1263,7 @@ void PollInputEvents(void)
|
||||
for (int k = 0; k < MAX_GAMEPAD_BUTTONS; k++) CORE.Input.Gamepad.previousButtonState[i][k] = CORE.Input.Gamepad.currentButtonState[i][k];
|
||||
|
||||
// Get current gamepad state
|
||||
// NOTE: There is no callback available, so we get it manually
|
||||
// NOTE: There is no callback available, getting it manually
|
||||
GLFWgamepadstate state = { 0 };
|
||||
int result = glfwGetGamepadState(i, &state); // This remaps all gamepads so they have their buttons mapped like an xbox controller
|
||||
if (result == GLFW_FALSE) // No joystick is connected, no gamepad mapping or an error occurred
|
||||
@ -1359,8 +1359,8 @@ void PollInputEvents(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
// Function wrappers around RL_*alloc macros, used by glfwInitAllocator() inside of InitPlatform()
|
||||
// We need to provide these because GLFWallocator expects function pointers with specific signatures
|
||||
// Function wrappers around RL_*ALLOC macros, used by glfwInitAllocator() inside of InitPlatform()
|
||||
// GLFWallocator expects function pointers with specific signatures to be provided
|
||||
// REF: https://www.glfw.org/docs/latest/intro_guide.html#init_allocator
|
||||
static void *AllocateWrapper(size_t size, void *user)
|
||||
{
|
||||
@ -1742,7 +1742,7 @@ int InitPlatform(void)
|
||||
for (int i = 0; i < MAX_GAMEPADS; i++)
|
||||
{
|
||||
// WARNING: If glfwGetJoystickName() is longer than MAX_GAMEPAD_NAME_LENGTH,
|
||||
// we can get a not-NULL terminated string, so, we only copy up to (MAX_GAMEPAD_NAME_LENGTH - 1)
|
||||
// only copying up to (MAX_GAMEPAD_NAME_LENGTH - 1)
|
||||
if (glfwJoystickPresent(i))
|
||||
{
|
||||
CORE.Input.Gamepad.ready[i] = true;
|
||||
@ -1819,8 +1819,8 @@ static void FramebufferSizeCallback(GLFWwindow *window, int width, int height)
|
||||
{
|
||||
//TRACELOG(LOG_INFO, "GLFW3: Window framebuffer size callback called [%i,%i]", width, height);
|
||||
|
||||
// WARNING: On window minimization, callback is called,
|
||||
// but we don't want to change internal screen values, it breaks things
|
||||
// WARNING: On window minimization, callback is called with 0 values,
|
||||
// but internal screen values should not be changed, it breaks things
|
||||
if ((width == 0) || (height == 0)) return;
|
||||
|
||||
// Reset viewport and projection matrix for new size
|
||||
@ -1926,7 +1926,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]);
|
||||
@ -1937,7 +1937,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, keeping an internal copy
|
||||
CORE.Window.dropFileCount = count;
|
||||
CORE.Window.dropFilepaths = (char **)RL_CALLOC(CORE.Window.dropFileCount, sizeof(char *));
|
||||
|
||||
@ -1954,7 +1954,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;
|
||||
@ -2079,7 +2079,7 @@ static void JoystickCallback(int jid, int event)
|
||||
if (event == GLFW_CONNECTED)
|
||||
{
|
||||
// WARNING: If glfwGetJoystickName() is longer than MAX_GAMEPAD_NAME_LENGTH,
|
||||
// we can get a not-NULL terminated string, so, we clean destination and only copy up to -1
|
||||
// only copy up to (MAX_GAMEPAD_NAME_LENGTH -1) to destination string
|
||||
memset(CORE.Input.Gamepad.name[jid], 0, MAX_GAMEPAD_NAME_LENGTH);
|
||||
strncpy(CORE.Input.Gamepad.name[jid], glfwGetJoystickName(jid), MAX_GAMEPAD_NAME_LENGTH - 1);
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
#define USING_SDL3_PROJECT
|
||||
#endif
|
||||
#ifndef SDL_ENABLE_OLD_NAMES
|
||||
#define SDL_ENABLE_OLD_NAMES // Just in case we're on SDL3, we need some in-between compatibily
|
||||
#define SDL_ENABLE_OLD_NAMES // Just in case on SDL3, some in-between compatibily is needed
|
||||
#endif
|
||||
// SDL base library (window/rendered, input, timing... functionality)
|
||||
#ifdef USING_SDL3_PROJECT
|
||||
@ -254,10 +254,10 @@ static const int CursorsLUT[] = {
|
||||
#if defined(USING_VERSION_SDL3)
|
||||
|
||||
// SDL3 Migration:
|
||||
// SDL_WINDOW_FULLSCREEN_DESKTOP has been removed,
|
||||
// and you can call SDL_GetWindowFullscreenMode()
|
||||
// to see whether an exclusive fullscreen mode will be used
|
||||
// or the borderless fullscreen desktop mode will be used
|
||||
// SDL_WINDOW_FULLSCREEN_DESKTOP has been removed,
|
||||
// and you can call SDL_GetWindowFullscreenMode()
|
||||
// to see whether an exclusive fullscreen mode will be used
|
||||
// or the borderless fullscreen desktop mode will be used
|
||||
#define SDL_WINDOW_FULLSCREEN_DESKTOP SDL_WINDOW_FULLSCREEN
|
||||
|
||||
#define SDL_IGNORE false
|
||||
@ -340,9 +340,8 @@ SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth
|
||||
}
|
||||
|
||||
// SDL3 Migration:
|
||||
// SDL_GetDisplayDPI() -
|
||||
// not reliable across platforms, approximately replaced by multiplying
|
||||
// SDL_GetWindowDisplayScale() times 160 on iPhone and Android, and 96 on other platforms
|
||||
// SDL_GetDisplayDPI() not reliable across platforms, approximately replaced by multiplying
|
||||
// SDL_GetWindowDisplayScale() times 160 on iPhone and Android, and 96 on other platforms
|
||||
// returns 0 on success or a negative error code on failure
|
||||
int SDL_GetDisplayDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi)
|
||||
{
|
||||
@ -413,7 +412,7 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID)
|
||||
return count;
|
||||
}
|
||||
|
||||
#else // We're on SDL2
|
||||
#else // SDL2 fallback
|
||||
|
||||
// Since SDL2 doesn't have this function we leave a stub
|
||||
// SDL_GetClipboardData function is available since SDL 3.1.3. (e.g. SDL3)
|
||||
@ -833,10 +832,9 @@ void SetWindowMonitor(int monitor)
|
||||
if ((monitor >= 0) && (monitor < monitorCount))
|
||||
#endif
|
||||
{
|
||||
// NOTE:
|
||||
// 1. SDL started supporting moving exclusive fullscreen windows between displays on SDL3,
|
||||
// see commit https://github.com/libsdl-org/SDL/commit/3f5ef7dd422057edbcf3e736107e34be4b75d9ba
|
||||
// 2. A workaround for SDL2 is leaving fullscreen, moving the window, then entering full screen again
|
||||
// NOTE 1: SDL started supporting moving exclusive fullscreen windows between displays on SDL3,
|
||||
// see commit https://github.com/libsdl-org/SDL/commit/3f5ef7dd422057edbcf3e736107e34be4b75d9ba
|
||||
// NOTE 2: A workaround for SDL2 is leaving fullscreen, moving the window, then entering full screen again
|
||||
const bool wasFullscreen = (FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))? true : false;
|
||||
|
||||
const int screenWidth = CORE.Window.screen.width;
|
||||
@ -854,14 +852,13 @@ void SetWindowMonitor(int monitor)
|
||||
// If the screen size is larger than the monitor usable area, anchor it on the top left corner, otherwise, center it
|
||||
if ((screenWidth >= usableBounds.w) || (screenHeight >= usableBounds.h))
|
||||
{
|
||||
// NOTE:
|
||||
// 1. There's a known issue where if the window larger than the target display bounds,
|
||||
// when moving the windows to that display, the window could be clipped back
|
||||
// ending up positioned partly outside the target display
|
||||
// 2. The workaround for that is, previously to moving the window,
|
||||
// setting the window size to the target display size, so they match
|
||||
// 3. It wasn't done here because we can't assume changing the window size automatically
|
||||
// is acceptable behavior by the user
|
||||
// NOTE 1: There's a known issue where if the window larger than the target display bounds,
|
||||
// when moving the windows to that display, the window could be clipped back
|
||||
// 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
|
||||
SDL_SetWindowPosition(platform.window, usableBounds.x, usableBounds.y);
|
||||
CORE.Window.position.x = usableBounds.x;
|
||||
CORE.Window.position.y = usableBounds.y;
|
||||
@ -1250,7 +1247,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: We use 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);
|
||||
@ -1617,7 +1614,7 @@ void PollInputEvents(void)
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
{
|
||||
// NOTE: SDL2 mouse button order is LEFT, MIDDLE, RIGHT, but raylib uses LEFT, RIGHT, MIDDLE like GLFW
|
||||
// The following conditions align SDL with raylib.h MouseButton enum order
|
||||
// The following conditions align SDL with raylib.h MouseButton enum order
|
||||
int btn = event.button.button - 1;
|
||||
if (btn == 2) btn = 1;
|
||||
else if (btn == 1) btn = 2;
|
||||
@ -1630,7 +1627,7 @@ void PollInputEvents(void)
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
// NOTE: SDL2 mouse button order is LEFT, MIDDLE, RIGHT, but raylib uses LEFT, RIGHT, MIDDLE like GLFW
|
||||
// The following conditions align SDL with raylib.h MouseButton enum order
|
||||
// The following conditions align SDL with raylib.h MouseButton enum order
|
||||
int btn = event.button.button - 1;
|
||||
if (btn == 2) btn = 1;
|
||||
else if (btn == 1) btn = 2;
|
||||
|
||||
@ -433,7 +433,7 @@ static bool UpdateWindowSize(int mode, HWND hwnd, int width, int height, unsigne
|
||||
return true;
|
||||
}
|
||||
|
||||
// Verify if we are running in Windows 10 version 1703 (Creators Update)
|
||||
// Check if running in Windows 10 version 1703 (Creators Update)
|
||||
static BOOL IsWindows10Version1703OrGreaterWin32(void)
|
||||
{
|
||||
HMODULE ntdll = LoadLibraryW(L"ntdll.dll");
|
||||
@ -1138,7 +1138,7 @@ void ShowCursor(void)
|
||||
// Hides mouse cursor
|
||||
void HideCursor(void)
|
||||
{
|
||||
// NOTE: We use SetCursor() instead of ShowCursor() because
|
||||
// NOTE: Using SetCursor() instead of ShowCursor() because
|
||||
// it makes it easy to only hide the cursor while it's inside the client area
|
||||
SetCursor(NULL);
|
||||
CORE.Input.Mouse.cursorHidden = true;
|
||||
@ -1345,7 +1345,7 @@ void PollInputEvents(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Initialize modern OpenGL context
|
||||
// NOTE: We need to create a dummy context first to query required extensions
|
||||
// NOTE: Creating a dummy context first to query required extensions
|
||||
HGLRC InitOpenGL(HWND hwnd, HDC hdc)
|
||||
{
|
||||
// First, create a dummy context to get WGL extensions
|
||||
@ -1460,7 +1460,7 @@ HGLRC InitOpenGL(HWND hwnd, HDC hdc)
|
||||
0 // Terminator
|
||||
};
|
||||
|
||||
// NOTE: We are not sharing context resources so, second parameters is NULL
|
||||
// NOTE: Not sharing context resources so, second parameters is NULL
|
||||
realContext = wglCreateContextAttribsARB(hdc, NULL, contextAttribs);
|
||||
|
||||
// Check for error context creation errors
|
||||
@ -1476,8 +1476,8 @@ HGLRC InitOpenGL(HWND hwnd, HDC hdc)
|
||||
// Activate real context
|
||||
if (realContext) wglMakeCurrent(hdc, realContext);
|
||||
|
||||
// Once we got a real modern OpenGL context,
|
||||
// we can load required extensions (function pointers)
|
||||
// Once a real modern OpenGL context is created,
|
||||
// required extensions can be loaded (function pointers)
|
||||
rlLoadExtensions(WglGetProcAddress);
|
||||
|
||||
return realContext;
|
||||
@ -1521,7 +1521,7 @@ int InitPlatform(void)
|
||||
.lpfnWndProc = WndProc, // Custom procedure assigned
|
||||
.cbWndExtra = sizeof(LONG_PTR), // extra space for the Tuple object ptr
|
||||
.hInstance = hInstance,
|
||||
.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW), // TODO: Audit if we want to set this since we're implementing WM_SETCURSOR
|
||||
.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW), // TODO: Check if this is really required, since WM_SETCURSOR event is processed
|
||||
.lpszClassName = CLASS_NAME // Class name: L"raylibWindow"
|
||||
};
|
||||
|
||||
@ -1854,8 +1854,8 @@ 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 any of these other cases, we might want to post a window
|
||||
// resize event after the dpi changes?
|
||||
// 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;
|
||||
if (CORE.Window.flags & FLAG_BORDERLESS_WINDOWED_MODE) return TRUE;
|
||||
@ -2025,8 +2025,8 @@ static void HandleRawInput(LPARAM lparam)
|
||||
|
||||
if (input.data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) TRACELOG(LOG_ERROR, "TODO: handle virtual desktop mouse inputs!");
|
||||
|
||||
// Trick to keep the mouse position at 0,0 and instead move
|
||||
// the previous position so we can still get a proper mouse delta
|
||||
// Trick to keep the mouse position at (0,0) and instead move
|
||||
// the previous position so a proper mouse delta can still be retrieved
|
||||
//CORE.Input.Mouse.previousPosition.x -= input.data.mouse.lLastX;
|
||||
//CORE.Input.Mouse.previousPosition.y -= input.data.mouse.lLastY;
|
||||
//if (CORE.Input.Mouse.currentPosition.x != 0) abort();
|
||||
@ -2138,12 +2138,12 @@ static unsigned SanitizeFlags(int mode, unsigned flags)
|
||||
// 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 we'd need to
|
||||
// update the window style, but updating the style would mean the window size would change
|
||||
// causing the window to lose its Maximized state which would mean we'd need to update the
|
||||
// window size and then update the window style a second time to restore that maximized
|
||||
// if you have 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
|
||||
// state. This implementation is able to handle any/all of these special situations with a
|
||||
// retry loop that continues until we either reach the desired state or the state stops changing
|
||||
// retry loop that continues until either the desired state is reached or the state stops changing
|
||||
static void UpdateFlags(HWND hwnd, unsigned desiredFlags, int width, int height)
|
||||
{
|
||||
// Flags that just apply immediately without needing any operations
|
||||
|
||||
@ -499,7 +499,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;
|
||||
|
||||
@ -953,8 +953,8 @@ void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float d
|
||||
if (duration > MAX_GAMEPAD_VIBRATION_TIME) duration = MAX_GAMEPAD_VIBRATION_TIME;
|
||||
duration *= 1000.0f; // Convert duration to ms
|
||||
|
||||
// Note: At the moment (2024.10.21) Chrome, Edge, Opera, Safari, Android Chrome, Android Webview only support the vibrationActuator API,
|
||||
// and Firefox only supports the hapticActuators API
|
||||
// NOTE: At the moment (2024.10.21) Chrome, Edge, Opera, Safari, Android Chrome, Android Webview only support the vibrationActuator API,
|
||||
// and Firefox only supports the hapticActuators API
|
||||
EM_ASM({
|
||||
try
|
||||
{
|
||||
@ -1798,8 +1798,8 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
|
||||
// Emscripten: Called on fullscreen change events
|
||||
static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const EmscriptenFullscreenChangeEvent *event, void *userData)
|
||||
{
|
||||
// NOTE: 1. Reset the fullscreen flags if the user left fullscreen manually by pressing the Escape key
|
||||
// 2. Which is a necessary safeguard because that case will bypass the toggles CORE.Window.flags resets
|
||||
// NOTE 1: Reset the fullscreen flags if the user left fullscreen manually by pressing the Escape key
|
||||
// NOTE 2: Which is a necessary safeguard because that case will bypass the toggles CORE.Window.flags resets
|
||||
if (platform.ourFullscreen) platform.ourFullscreen = false;
|
||||
else
|
||||
{
|
||||
|
||||
@ -137,7 +137,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,
|
||||
// NOTE: Optionally, time can be managed, giving control back-to-browser as required,
|
||||
// but it seems below line could generate stuttering on some browsers
|
||||
emscripten_sleep(12);
|
||||
|
||||
@ -1358,7 +1358,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]);
|
||||
@ -1369,7 +1369,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 should be kept
|
||||
CORE.Window.dropFileCount = count;
|
||||
CORE.Window.dropFilepaths = (char **)RL_CALLOC(CORE.Window.dropFileCount, sizeof(char *));
|
||||
|
||||
@ -1610,7 +1610,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
|
||||
// looking for actual CSS size: 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);
|
||||
|
||||
@ -1630,7 +1630,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 if a single touch is detected
|
||||
if (CORE.Input.Touch.pointCount == 1)
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition.x = CORE.Input.Touch.position[0].x;
|
||||
|
||||
Reference in New Issue
Block a user