mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Some TODOs and format reviews
This commit is contained in:
@ -623,10 +623,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.
|
||||
// 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
|
||||
// NOTE: This function is only safe to use if you control the URL given
|
||||
// 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
|
||||
void OpenURL(const char *url)
|
||||
{
|
||||
// Security check to (partially) avoid malicious code
|
||||
@ -687,7 +686,7 @@ void SetMouseCursor(int cursor)
|
||||
TRACELOG(LOG_WARNING, "SetMouseCursor() not implemented on target platform");
|
||||
}
|
||||
|
||||
// Get physical key name.
|
||||
// Get physical key name
|
||||
const char *GetKeyName(int key)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetKeyName() not implemented on target platform");
|
||||
@ -748,9 +747,9 @@ void PollInputEvents(void)
|
||||
// Process this event
|
||||
if (platform.source != NULL) platform.source->process(platform.app, platform.source);
|
||||
|
||||
// NOTE: Allow closing the window in case a configuration change happened.
|
||||
// NOTE: Allow closing the window in case a configuration change happened
|
||||
// The android_main function should be allowed to return to its caller in order for the
|
||||
// Android OS to relaunch the activity.
|
||||
// Android OS to relaunch the activity
|
||||
if (platform.app->destroyRequested != 0)
|
||||
{
|
||||
CORE.Window.shouldClose = true;
|
||||
@ -829,13 +828,13 @@ 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 we reach TIMEOUT, which indicates no more events queued
|
||||
while ((pollResult = ALooper_pollOnce(0, NULL, &pollEvents, ((void **)&platform.source)) > ALOOPER_POLL_TIMEOUT))
|
||||
{
|
||||
// Process this event
|
||||
if (platform.source != NULL) platform.source->process(platform.app, platform.source);
|
||||
|
||||
// NOTE: It's highly likely destroyRequested will never be non-zero at the start of the activity lifecycle.
|
||||
// NOTE: It's highly likely destroyRequested will never be non-zero at the start of the activity lifecycle
|
||||
//if (platform.app->destroyRequested != 0) CORE.Window.shouldClose = true;
|
||||
}
|
||||
}
|
||||
@ -869,8 +868,9 @@ void ClosePlatform(void)
|
||||
platform.device = EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
// NOTE: Reset global state in case the activity is being relaunched.
|
||||
if (platform.app->destroyRequested != 0) {
|
||||
// NOTE: Reset global state in case the activity is being relaunched
|
||||
if (platform.app->destroyRequested != 0)
|
||||
{
|
||||
CORE = (CoreData){0};
|
||||
platform = (PlatformData){0};
|
||||
}
|
||||
@ -925,7 +925,7 @@ static int InitGraphicsDevice(void)
|
||||
// Initialize the EGL device connection
|
||||
if (eglInitialize(platform.device, NULL, NULL) == EGL_FALSE)
|
||||
{
|
||||
// If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred.
|
||||
// If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred
|
||||
TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device");
|
||||
return -1;
|
||||
}
|
||||
@ -1081,21 +1081,6 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
|
||||
|
||||
// Initialize random seed
|
||||
SetRandomSeed((unsigned int)time(NULL));
|
||||
|
||||
// TODO: GPU assets reload in case of lost focus (lost context)
|
||||
// NOTE: This problem has been solved just unbinding and rebinding context from display
|
||||
/*
|
||||
if (assetsReloadRequired)
|
||||
{
|
||||
for (int i = 0; i < assetCount; i++)
|
||||
{
|
||||
// TODO: Unload old asset if required
|
||||
|
||||
// Load texture again to pointed texture
|
||||
(*textureAsset + i) = LoadTexture(assetPath[i]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
} break;
|
||||
@ -1115,7 +1100,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
|
||||
case APP_CMD_TERM_WINDOW:
|
||||
{
|
||||
// Detach OpenGL context and destroy display surface
|
||||
// NOTE 1: This case is used when the user exits the app without closing it. We detach the context to ensure everything is recoverable upon resuming.
|
||||
// NOTE 1: This case is used when the user exits the app without closing it, context is detached to ensure everything is recoverable upon resuming
|
||||
// NOTE 2: Detaching context before destroying display surface avoids losing our resources (textures, shaders, VBOs...)
|
||||
// NOTE 3: In some cases (too many context loaded), OS could unload context automatically... :(
|
||||
if (platform.device != EGL_NO_DISPLAY)
|
||||
@ -1179,8 +1164,8 @@ static GamepadButton AndroidTranslateGamepadButton(int button)
|
||||
static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||
{
|
||||
// If additional inputs are required check:
|
||||
// https://developer.android.com/ndk/reference/group/input
|
||||
// https://developer.android.com/training/game-controllers/controller-input
|
||||
// Ref: https://developer.android.com/ndk/reference/group/input
|
||||
// Ref: https://developer.android.com/training/game-controllers/controller-input
|
||||
|
||||
int type = AInputEvent_getType(event);
|
||||
int source = AInputEvent_getSource(event);
|
||||
@ -1290,7 +1275,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||
{
|
||||
// Let the OS handle input to avoid app stuck. Behaviour: CMD_PAUSE -> CMD_SAVE_STATE -> CMD_STOP -> CMD_CONFIG_CHANGED -> CMD_LOST_FOCUS
|
||||
// Resuming Behaviour: CMD_START -> CMD_RESUME -> CMD_CONFIG_CHANGED -> CMD_CONFIG_CHANGED -> CMD_GAINED_FOCUS
|
||||
// It seems like locking mobile, screen size (CMD_CONFIG_CHANGED) is affected.
|
||||
// It seems like locking mobile, screen size (CMD_CONFIG_CHANGED) is affected
|
||||
// NOTE: AndroidManifest.xml must have <activity android:configChanges="orientation|keyboardHidden|screenSize" >
|
||||
// Before that change, activity was calling CMD_TERM_WINDOW and CMD_DESTROY when locking mobile, so that was not a normal behaviour
|
||||
return 0;
|
||||
@ -1419,15 +1404,9 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||
if (CORE.Input.Touch.pointCount > 0) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 1;
|
||||
else CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0;
|
||||
|
||||
// Stores the previous position of touch[0] only while it's active to calculate the delta.
|
||||
if (flags == AMOTION_EVENT_ACTION_MOVE)
|
||||
{
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
CORE.Input.Mouse.previousPosition = CORE.Input.Touch.position[0];
|
||||
}
|
||||
// Stores the previous position of touch[0] only while it's active to calculate the delta
|
||||
if (flags == AMOTION_EVENT_ACTION_MOVE) CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
|
||||
else CORE.Input.Mouse.previousPosition = CORE.Input.Touch.position[0];
|
||||
|
||||
// Map touch[0] as mouse input for convenience
|
||||
CORE.Input.Mouse.currentPosition = CORE.Input.Touch.position[0];
|
||||
|
||||
@ -1220,9 +1220,9 @@ void PollInputEvents(void)
|
||||
|
||||
// Map touch position to mouse position for convenience
|
||||
// WARNING: If the target desktop device supports touch screen, this behaviour should be reviewed!
|
||||
// TODO: GLFW does not support multi-touch input just yet
|
||||
// https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch
|
||||
// https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages
|
||||
// TODO: GLFW does not support multi-touch input yet
|
||||
// Ref: https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch
|
||||
// Ref: https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages
|
||||
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
|
||||
|
||||
// Check if gamepads are ready
|
||||
@ -1334,7 +1334,7 @@ void PollInputEvents(void)
|
||||
// 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
|
||||
// Similar wrappers exist in utils.c but we cannot reuse them here due to declaration mismatch
|
||||
// https://www.glfw.org/docs/latest/intro_guide.html#init_allocator
|
||||
// Ref: https://www.glfw.org/docs/latest/intro_guide.html#init_allocator
|
||||
static void *AllocateWrapper(size_t size, void *user)
|
||||
{
|
||||
(void)user;
|
||||
@ -1592,8 +1592,8 @@ int InitPlatform(void)
|
||||
bool requestWindowedFullscreen = (CORE.Window.screen.height == 0) && (CORE.Window.screen.width == 0);
|
||||
|
||||
// Default to at least one pixel in size, as creation with a zero dimension is not allowed
|
||||
int creationWidth = CORE.Window.screen.width != 0 ? CORE.Window.screen.width : 1;
|
||||
int creationHeight = CORE.Window.screen.height != 0 ? CORE.Window.screen.height : 1;
|
||||
int creationWidth = (CORE.Window.screen.width != 0)? CORE.Window.screen.width : 1;
|
||||
int creationHeight = (CORE.Window.screen.height != 0)? CORE.Window.screen.height : 1;
|
||||
|
||||
platform.handle = glfwCreateWindow(creationWidth, creationHeight, (CORE.Window.title != 0)? CORE.Window.title : " ", NULL, NULL);
|
||||
if (!platform.handle)
|
||||
|
||||
@ -870,17 +870,27 @@ 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.
|
||||
// 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
|
||||
// NOTE: This function is only safe to use if you control the URL given
|
||||
// A user could craft a malicious string performing another action
|
||||
void OpenURL(const char *url)
|
||||
{
|
||||
// Security check to (partially) avoid malicious code on target platform
|
||||
if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character");
|
||||
else
|
||||
{
|
||||
// TODO: Open URL implementation
|
||||
char *cmd = (char *)RL_CALLOC(strlen(url) + 32, sizeof(char));
|
||||
#if defined(_WIN32)
|
||||
sprintf(cmd, "explorer \"%s\"", url);
|
||||
#endif
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
sprintf(cmd, "open '%s'", url);
|
||||
#endif
|
||||
int result = system(cmd);
|
||||
if (result == -1) TRACELOG(LOG_WARNING, "OpenURL() child process could not be created");
|
||||
RL_FREE(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -915,7 +925,7 @@ void SetMouseCursor(int cursor)
|
||||
RGFW_window_setMouseStandard(platform.window, cursor);
|
||||
}
|
||||
|
||||
// Get physical key name.
|
||||
// Get physical key name
|
||||
const char *GetKeyName(int key)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetKeyName() unsupported on target platform");
|
||||
@ -1095,11 +1105,7 @@ void PollInputEvents(void)
|
||||
CORE.Input.Keyboard.currentKeyState[key] = 1;
|
||||
}
|
||||
|
||||
// TODO: Put exitKey verification outside the switch?
|
||||
if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey])
|
||||
{
|
||||
CORE.Window.shouldClose = true;
|
||||
}
|
||||
if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey]) CORE.Window.shouldClose = true;
|
||||
|
||||
// NOTE: event.text.text data comes an UTF-8 text sequence but we register codepoints (int)
|
||||
// Check if there is space available in the queue
|
||||
|
||||
@ -1129,7 +1129,7 @@ Vector2 GetWindowScaleDPI(void)
|
||||
|
||||
#ifndef USING_VERSION_SDL3
|
||||
// NOTE: SDL_GetWindowDisplayScale was only added on SDL3
|
||||
// see https://wiki.libsdl.org/SDL3/SDL_GetWindowDisplayScale
|
||||
// Ref: https://wiki.libsdl.org/SDL3/SDL_GetWindowDisplayScale
|
||||
// TODO: Implement the window scale factor calculation manually
|
||||
TRACELOG(LOG_WARNING, "GetWindowScaleDPI() not implemented on target platform");
|
||||
#else
|
||||
@ -1425,8 +1425,10 @@ void PollInputEvents(void)
|
||||
CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
|
||||
|
||||
#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.
|
||||
// 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
|
||||
strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.data);
|
||||
#else
|
||||
strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.file);
|
||||
@ -1458,7 +1460,7 @@ void PollInputEvents(void)
|
||||
// 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. 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
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
switch (event.window.event)
|
||||
@ -1582,11 +1584,9 @@ void PollInputEvents(void)
|
||||
|
||||
if (event.key.repeat) CORE.Input.Keyboard.keyRepeatInFrame[key] = 1;
|
||||
|
||||
// TODO: Put exitKey verification outside the switch?
|
||||
if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey])
|
||||
{
|
||||
CORE.Window.shouldClose = true;
|
||||
}
|
||||
// Check for registered exit key to request exit game loop on next iteration
|
||||
if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey]) CORE.Window.shouldClose = true;
|
||||
|
||||
} break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
@ -2080,7 +2080,7 @@ int InitPlatform(void)
|
||||
|
||||
// Disable mouse events being interpreted as touch events
|
||||
// NOTE: This is wanted because there are SDL_FINGER* events available which provide unique data
|
||||
// Due to the way PollInputEvents() and rgestures.h are currently implemented, setting this won't break SUPPORT_MOUSE_GESTURES
|
||||
// Due to the way PollInputEvents() and rgestures.h are currently implemented, setting this won't break SUPPORT_MOUSE_GESTURES
|
||||
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
|
||||
|
||||
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
||||
|
||||
@ -939,7 +939,7 @@ void SetWindowIcon(Image image)
|
||||
// Set icon for window
|
||||
void SetWindowIcons(Image *images, int count)
|
||||
{
|
||||
// TODO.
|
||||
// TODO: Implement SetWindowIcons()
|
||||
}
|
||||
|
||||
void SetWindowTitle(const char *title)
|
||||
@ -1246,7 +1246,11 @@ void OpenURL(const char *url)
|
||||
if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character");
|
||||
else
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "OpenURL not implemented");
|
||||
char *cmd = (char *)RL_CALLOC(strlen(url) + 32, sizeof(char));
|
||||
sprintf(cmd, "explorer \"%s\"", url);
|
||||
int result = system(cmd);
|
||||
if (result == -1) TRACELOG(LOG_WARNING, "OpenURL() child process could not be created");
|
||||
RL_FREE(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -220,7 +220,7 @@ static const short linuxToRaylibMap[KEYMAP_SIZE] = {
|
||||
248, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
// Gamepads are mapped according to:
|
||||
// https://www.kernel.org/doc/html/next/input/gamepad.html
|
||||
// Ref: https://www.kernel.org/doc/html/next/input/gamepad.html
|
||||
// Those mappings are standardized, but that doesn't mean people follow
|
||||
// the standards, so this is more of an approximation
|
||||
[BTN_DPAD_UP] = GAMEPAD_BUTTON_LEFT_FACE_UP,
|
||||
@ -637,7 +637,7 @@ static uint32_t GetOrCreateFbForBo(struct gbm_bo *bo)
|
||||
}
|
||||
|
||||
// Renders a blank frame to allocate initial buffers
|
||||
// TODO: WARNING: Platform layers do not include OpenGL code!
|
||||
// TODO: WARNING: Platform backend should not include OpenGL code
|
||||
void RenderBlankFrame()
|
||||
{
|
||||
glClearColor(0, 0, 0, 1);
|
||||
@ -1213,9 +1213,9 @@ int InitPlatform(void)
|
||||
|
||||
TRACELOG(LOG_TRACE, "DISPLAY: Connector %i modes detected: %i", i, con->count_modes);
|
||||
TRACELOG(LOG_TRACE, "DISPLAY: Connector %i status: %s", i,
|
||||
(con->connection == DRM_MODE_CONNECTED) ? "CONNECTED" :
|
||||
(con->connection == DRM_MODE_DISCONNECTED) ? "DISCONNECTED" :
|
||||
(con->connection == DRM_MODE_UNKNOWNCONNECTION) ? "UNKNOWN" : "OTHER");
|
||||
(con->connection == DRM_MODE_CONNECTED)? "CONNECTED" :
|
||||
(con->connection == DRM_MODE_DISCONNECTED)? "DISCONNECTED" :
|
||||
(con->connection == DRM_MODE_UNKNOWNCONNECTION)? "UNKNOWN" : "OTHER");
|
||||
|
||||
// In certain cases the status of the conneciton is reported as UKNOWN, but it is still connected
|
||||
// This might be a hardware or software limitation like on Raspberry Pi Zero with composite output
|
||||
@ -1298,7 +1298,7 @@ int InitPlatform(void)
|
||||
}
|
||||
|
||||
const bool allowInterlaced = FLAG_IS_SET(CORE.Window.flags, FLAG_INTERLACED_HINT);
|
||||
const int fps = (CORE.Time.target > 0) ? (1.0/CORE.Time.target) : 60;
|
||||
const int fps = (CORE.Time.target > 0)? (1.0/CORE.Time.target) : 60;
|
||||
|
||||
// Try to find an exact matching mode
|
||||
platform.modeIndex = FindExactConnectorMode(platform.connector, CORE.Window.screen.width, CORE.Window.screen.height, fps, allowInterlaced);
|
||||
@ -1345,7 +1345,7 @@ int InitPlatform(void)
|
||||
platform.connector->modes[0].name,
|
||||
platform.connector->modes[0].hdisplay,
|
||||
platform.connector->modes[0].vdisplay,
|
||||
(platform.connector->modes[0].flags & DRM_MODE_FLAG_INTERLACE) ? 'i' : 'p',
|
||||
(platform.connector->modes[0].flags & DRM_MODE_FLAG_INTERLACE)? 'i' : 'p',
|
||||
platform.connector->modes[0].vrefresh);
|
||||
}
|
||||
else
|
||||
@ -1740,10 +1740,10 @@ static void InitKeyboard(void)
|
||||
else
|
||||
{
|
||||
// Reconfigure keyboard mode to get:
|
||||
// - scancodes (K_RAW)
|
||||
// - keycodes (K_MEDIUMRAW)
|
||||
// - ASCII chars (K_XLATE)
|
||||
// - UNICODE chars (K_UNICODE)
|
||||
// - scancodes (K_RAW)
|
||||
// - keycodes (K_MEDIUMRAW)
|
||||
// - ASCII chars (K_XLATE)
|
||||
// - UNICODE chars (K_UNICODE)
|
||||
ioctl(STDIN_FILENO, KDSKBMODE, K_XLATE); // ASCII chars
|
||||
}
|
||||
|
||||
|
||||
@ -159,7 +159,7 @@ static const char *GetCanvasId(void);
|
||||
bool WindowShouldClose(void)
|
||||
{
|
||||
// Emscripten Asyncify is required to run synchronous code in asynchronous JS
|
||||
// REF: https://emscripten.org/docs/porting/asyncify.html
|
||||
// Ref: https://emscripten.org/docs/porting/asyncify.html
|
||||
|
||||
// WindowShouldClose() is not called on a web-ready raylib application if using emscripten_set_main_loop()
|
||||
// and encapsulating one frame execution on a UpdateDrawFrame() function,
|
||||
@ -309,8 +309,8 @@ void ToggleBorderlessWindowed(void)
|
||||
|
||||
if (enterBorderless)
|
||||
{
|
||||
// NOTE: 1. The setTimeouts handle the browser mode change delay
|
||||
// 2. The style unset handles the possibility of a width="value%" like on the default shell.html file
|
||||
// 1. The setTimeouts handle the browser mode change delay
|
||||
// 2. The style unset handles the possibility of a width="value%" like on the default shell.html file
|
||||
EM_ASM
|
||||
(
|
||||
setTimeout(function()
|
||||
@ -866,7 +866,6 @@ void EnableCursor(void)
|
||||
// Disables cursor (lock cursor)
|
||||
void DisableCursor(void)
|
||||
{
|
||||
// TODO: figure out how not to hard code the canvas ID here.
|
||||
emscripten_request_pointerlock(GetCanvasId(), 1);
|
||||
|
||||
// Set cursor position in the middle
|
||||
@ -893,10 +892,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.
|
||||
// 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
|
||||
// NOTE: This function is only safe to use if you control the URL given
|
||||
// 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
|
||||
void OpenURL(const char *url)
|
||||
{
|
||||
// Security check to (partially) avoid malicious code on target platform
|
||||
@ -1090,10 +1088,6 @@ void PollInputEvents(void)
|
||||
}
|
||||
|
||||
CORE.Window.resizedLastFrame = false;
|
||||
|
||||
// TODO: This code does not seem to do anything??
|
||||
//if (CORE.Window.eventWaiting) glfwWaitEvents(); // Wait for in input events before continue (drawing is paused)
|
||||
//else glfwPollEvents(); // Poll input events: keyboard/mouse/window events (callbacks) --> WARNING: Where is key input reset?
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -1161,8 +1155,8 @@ int InitPlatform(void)
|
||||
}
|
||||
|
||||
// NOTE: When asking for an OpenGL context version, most drivers provide the highest supported version
|
||||
// with backward compatibility to older OpenGL versions.
|
||||
// For example, if using OpenGL 1.1, driver can provide a 4.3 backwards compatible context.
|
||||
// with backward compatibility to older OpenGL versions
|
||||
// For example, if using OpenGL 1.1, driver can provide a 4.3 backwards compatible context
|
||||
|
||||
// Check selection OpenGL version
|
||||
if (rlGetVersion() == RL_OPENGL_21)
|
||||
@ -1172,10 +1166,12 @@ int InitPlatform(void)
|
||||
}
|
||||
else if (rlGetVersion() == RL_OPENGL_33)
|
||||
{
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // Choose OpenGL major version (just hint)
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // Profiles Hint: Only 3.3 and above!
|
||||
// Values: GLFW_OPENGL_CORE_PROFILE, GLFW_OPENGL_ANY_PROFILE, GLFW_OPENGL_COMPAT_PROFILE
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // Choose OpenGL major version (just hint)
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
|
||||
// Profiles Hint, only OpenGL 3.3 and above
|
||||
// Possible values: GLFW_OPENGL_CORE_PROFILE, GLFW_OPENGL_ANY_PROFILE, GLFW_OPENGL_COMPAT_PROFILE
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE); // Forward Compatibility Hint: Only 3.3 and above!
|
||||
// glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Request OpenGL DEBUG context
|
||||
}
|
||||
@ -1198,7 +1194,6 @@ int InitPlatform(void)
|
||||
}
|
||||
else if (rlGetVersion() == RL_OPENGL_ES_30) // Request OpenGL ES 3.0 context
|
||||
{
|
||||
// TODO: It seems WebGL 2.0 context is not set despite being requested
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||
@ -1217,8 +1212,8 @@ 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, 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, 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
|
||||
CORE.Window.position.x = CORE.Window.display.width/4;
|
||||
CORE.Window.position.y = CORE.Window.display.height/4;
|
||||
}
|
||||
@ -1714,7 +1709,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 we detect a single touch
|
||||
if (CORE.Input.Touch.pointCount == 1)
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition.x = CORE.Input.Touch.position[0].x;
|
||||
|
||||
Reference in New Issue
Block a user