Move MaximizeWindow, MinimizeWindow and RestoreWindow out of rcore

This commit is contained in:
michaelfiber 2023-09-14 13:51:44 -04:00
parent f6d30b5fbd
commit 67d04b96e4
5 changed files with 361 additions and 263 deletions

View File

@ -513,41 +513,6 @@ void ToggleBorderlessWindowed(void)
#endif #endif
} }
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
void MaximizeWindow(void)
{
#if defined(PLATFORM_DESKTOP)
if (glfwGetWindowAttrib(CORE.Window.handle, GLFW_RESIZABLE) == GLFW_TRUE)
{
glfwMaximizeWindow(CORE.Window.handle);
CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED;
}
#endif
}
// Set window state: minimized (only PLATFORM_DESKTOP)
void MinimizeWindow(void)
{
#if defined(PLATFORM_DESKTOP)
// NOTE: Following function launches callback that sets appropriate flag!
glfwIconifyWindow(CORE.Window.handle);
#endif
}
// Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
void RestoreWindow(void)
{
#if defined(PLATFORM_DESKTOP)
if (glfwGetWindowAttrib(CORE.Window.handle, GLFW_RESIZABLE) == GLFW_TRUE)
{
// Restores the specified window if it was previously iconified (minimized) or maximized
glfwRestoreWindow(CORE.Window.handle);
CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED;
CORE.Window.flags &= ~FLAG_WINDOW_MAXIMIZED;
}
#endif
}
// Set window configuration state using flags // Set window configuration state using flags
void SetWindowState(unsigned int flags) void SetWindowState(unsigned int flags)
{ {

View File

@ -1331,3 +1331,23 @@ void ToggleFullscreen(void)
{ {
TRACELOG(LOG_WARNING, "SYSTEM: Failed to toggle to windowed mode"); TRACELOG(LOG_WARNING, "SYSTEM: Failed to toggle to windowed mode");
} }
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
void MaximizeWindow(void)
{
TRACELOG(LOG_WARNING, "MaximizeWindow not implemented in rcore_android.c");
}
// Set window state: minimized (only PLATFORM_DESKTOP)
void MinimizeWindow(void)
{
TRACELOG(LOG_WARNING, "MinimizeWindow not implemented in rcore_android.c");
}
// Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
void RestoreWindow(void)
{
TRACELOG(LOG_WARNING, "RestoreWindow not implemented in rcore_android.c");
}

View File

@ -584,6 +584,7 @@ void ToggleFullscreen(void)
glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
} }
} }
else else
{ {
@ -597,3 +598,34 @@ void ToggleFullscreen(void)
// NOTE: V-Sync can be enabled by graphic driver configuration // NOTE: V-Sync can be enabled by graphic driver configuration
if (CORE.Window.flags & FLAG_VSYNC_HINT) glfwSwapInterval(1); if (CORE.Window.flags & FLAG_VSYNC_HINT) glfwSwapInterval(1);
} }
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
void MaximizeWindow(void)
{
if (glfwGetWindowAttrib(CORE.Window.handle, GLFW_RESIZABLE) == GLFW_TRUE)
{
glfwMaximizeWindow(CORE.Window.handle);
CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED;
}
}
// Set window state: minimized (only PLATFORM_DESKTOP)
void MinimizeWindow(void)
{
// NOTE: Following function launches callback that sets appropriate flag!
glfwIconifyWindow(CORE.Window.handle);
}
// Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
void RestoreWindow(void)
{
if (glfwGetWindowAttrib(CORE.Window.handle, GLFW_RESIZABLE) == GLFW_TRUE)
{
// Restores the specified window if it was previously iconified (minimized) or maximized
glfwRestoreWindow(CORE.Window.handle);
CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED;
CORE.Window.flags &= ~FLAG_WINDOW_MAXIMIZED;
}
}

View File

@ -1049,3 +1049,23 @@ void ToggleFullscreen(void)
{ {
TRACELOG(LOG_WARNING, "SYSTEM: Failed to toggle to windowed mode"); TRACELOG(LOG_WARNING, "SYSTEM: Failed to toggle to windowed mode");
} }
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
void MaximizeWindow(void)
{
TRACELOG(LOG_WARNING, "MaximizeWindow not implemented in rcore_drm.c");
}
// Set window state: minimized (only PLATFORM_DESKTOP)
void MinimizeWindow(void)
{
TRACELOG(LOG_WARNING, "MinimizeWindow not implemented in rcore_drm.c");
}
// Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
void RestoreWindow(void)
{
TRACELOG(LOG_WARNING, "RestoreWindow not implemented in rcore_drm.c");
}

View File

@ -4,7 +4,7 @@
#include "rcore.h" #include "rcore.h"
#define GLFW_INCLUDE_ES2 // GLFW3: Enable OpenGL ES 2.0 (translated to WebGL) #define GLFW_INCLUDE_ES2 // GLFW3: Enable OpenGL ES 2.0 (translated to WebGL)
//#define GLFW_INCLUDE_ES3 // GLFW3: Enable OpenGL ES 3.0 (transalted to WebGL2?) // #define GLFW_INCLUDE_ES3 // GLFW3: Enable OpenGL ES 3.0 (transalted to WebGL2?)
#include "GLFW/glfw3.h" // GLFW3: Windows, OpenGL context and Input management #include "GLFW/glfw3.h" // GLFW3: Windows, OpenGL context and Input management
#include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX #include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX
@ -24,7 +24,7 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE
static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error
// Window callbacks events // Window callbacks events
static void WindowSizeCallback(GLFWwindow *window, int width, int height); // GLFW3 WindowSize Callback, runs when window is resized static void WindowSizeCallback(GLFWwindow *window, int width, int height); // GLFW3 WindowSize Callback, runs when window is resized
static void WindowMaximizeCallback(GLFWwindow* window, int maximized); // GLFW3 Window Maximize Callback, runs when window is maximized static void WindowMaximizeCallback(GLFWwindow *window, int maximized); // GLFW3 Window Maximize Callback, runs when window is maximized
static void WindowIconifyCallback(GLFWwindow *window, int iconified); // GLFW3 WindowIconify Callback, runs when window is minimized/restored static void WindowIconifyCallback(GLFWwindow *window, int iconified); // GLFW3 WindowIconify Callback, runs when window is minimized/restored
static void WindowFocusCallback(GLFWwindow *window, int focused); // GLFW3 WindowFocus Callback, runs when window get/lose focus static void WindowFocusCallback(GLFWwindow *window, int focused); // GLFW3 WindowFocus Callback, runs when window get/lose focus
static void WindowDropCallback(GLFWwindow *window, int count, const char **paths); // GLFW3 Window Drop Callback, runs when drop files into window static void WindowDropCallback(GLFWwindow *window, int count, const char **paths); // GLFW3 Window Drop Callback, runs when drop files into window
@ -71,12 +71,13 @@ void InitWindow(int width, int height, const char *title)
TRACELOG(LOG_INFO, " > raudio:.... not loaded (optional)"); TRACELOG(LOG_INFO, " > raudio:.... not loaded (optional)");
#endif #endif
if ((title != NULL) && (title[0] != 0)) CORE.Window.title = title; if ((title != NULL) && (title[0] != 0))
CORE.Window.title = title;
// Initialize global input state // Initialize global input state
memset(&CORE.Input, 0, sizeof(CORE.Input)); memset(&CORE.Input, 0, sizeof(CORE.Input));
CORE.Input.Keyboard.exitKey = KEY_ESCAPE; CORE.Input.Keyboard.exitKey = KEY_ESCAPE;
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f }; CORE.Input.Mouse.scale = (Vector2){1.0f, 1.0f};
CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW; CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW;
CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
#if defined(SUPPORT_EVENTS_WAITING) #if defined(SUPPORT_EVENTS_WAITING)
@ -92,7 +93,8 @@ void InitWindow(int width, int height, const char *title)
TRACELOG(LOG_FATAL, "Failed to initialize Graphic Device"); TRACELOG(LOG_FATAL, "Failed to initialize Graphic Device");
return; return;
} }
else SetWindowPosition(GetMonitorWidth(GetCurrentMonitor())/2 - CORE.Window.screen.width/2, GetMonitorHeight(GetCurrentMonitor())/2 - CORE.Window.screen.height/2); else
SetWindowPosition(GetMonitorWidth(GetCurrentMonitor()) / 2 - CORE.Window.screen.width / 2, GetMonitorHeight(GetCurrentMonitor()) / 2 - CORE.Window.screen.height / 2);
// Initialize hi-res timer // Initialize hi-res timer
InitTimer(); InitTimer();
@ -107,28 +109,28 @@ void InitWindow(int width, int height, const char *title)
// Load default font // Load default font
// WARNING: External function: Module required: rtext // WARNING: External function: Module required: rtext
LoadFontDefault(); LoadFontDefault();
#if defined(SUPPORT_MODULE_RSHAPES) #if defined(SUPPORT_MODULE_RSHAPES)
// Set font white rectangle for shapes drawing, so shapes and text can be batched together // Set font white rectangle for shapes drawing, so shapes and text can be batched together
// WARNING: rshapes module is required, if not available, default internal white rectangle is used // WARNING: rshapes module is required, if not available, default internal white rectangle is used
Rectangle rec = GetFontDefault().recs[95]; Rectangle rec = GetFontDefault().recs[95];
if (CORE.Window.flags & FLAG_MSAA_4X_HINT) if (CORE.Window.flags & FLAG_MSAA_4X_HINT)
{ {
// NOTE: We try to maxime rec padding to avoid pixel bleeding on MSAA filtering // NOTE: We try to maxime rec padding to avoid pixel bleeding on MSAA filtering
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 2, rec.y + 2, 1, 1 }); SetShapesTexture(GetFontDefault().texture, (Rectangle){rec.x + 2, rec.y + 2, 1, 1});
} }
else else
{ {
// NOTE: We set up a 1px padding on char rectangle to avoid pixel bleeding // NOTE: We set 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 }); SetShapesTexture(GetFontDefault().texture, (Rectangle){rec.x + 1, rec.y + 1, rec.width - 2, rec.height - 2});
} }
#endif #endif
#else #else
#if defined(SUPPORT_MODULE_RSHAPES) #if defined(SUPPORT_MODULE_RSHAPES)
// Set default texture and rectangle to be used for shapes drawing // Set default texture and rectangle to be used for shapes drawing
// NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8 // NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8
Texture2D texture = { rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; Texture2D texture = {rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8};
SetShapesTexture(texture, (Rectangle){ 0.0f, 0.0f, 1.0f, 1.0f }); // WARNING: Module required: rshapes SetShapesTexture(texture, (Rectangle){0.0f, 0.0f, 1.0f, 1.0f}); // WARNING: Module required: rshapes
#endif #endif
#endif #endif
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) #if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
if ((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0) if ((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0)
@ -145,15 +147,15 @@ void InitWindow(int width, int height, const char *title)
// WARNING: Below resize code was breaking fullscreen mode for sample games and examples, it needs review // WARNING: Below resize code was breaking fullscreen mode for sample games and examples, it needs review
// Check fullscreen change events(note this is done on the window since most browsers don't support this on #canvas) // Check fullscreen change events(note this is done on the window since most browsers don't support this on #canvas)
//emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback); // emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback);
// Check Resize event (note this is done on the window since most browsers don't support this on #canvas) // Check Resize event (note this is done on the window since most browsers don't support this on #canvas)
//emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback); // emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback);
// Trigger this once to get initial window sizing // Trigger this once to get initial window sizing
//EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL); // EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL);
// Support keyboard events -> Not used, GLFW.JS takes care of that // Support keyboard events -> Not used, GLFW.JS takes care of that
//emscripten_set_keypress_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback); // emscripten_set_keypress_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback);
//emscripten_set_keydown_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback); // emscripten_set_keydown_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback);
// Support mouse events // Support mouse events
emscripten_set_click_callback("#canvas", NULL, 1, EmscriptenMouseCallback); emscripten_set_click_callback("#canvas", NULL, 1, EmscriptenMouseCallback);
@ -197,13 +199,14 @@ EM_JS(int, GetCanvasHeight, (), { return canvas.clientHeight; });
static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *event, void *userData) static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *event, void *userData)
{ {
// Don't resize non-resizeable windows // Don't resize non-resizeable windows
if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) == 0) return 1; if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) == 0)
return 1;
// This event is called whenever the window changes sizes, // This event is called whenever the window changes sizes,
// so the size of the canvas object is explicitly retrieved below // so the size of the canvas object is explicitly retrieved below
int width = GetCanvasWidth(); int width = GetCanvasWidth();
int height = GetCanvasHeight(); int height = GetCanvasHeight();
emscripten_set_canvas_element_size("#canvas",width,height); emscripten_set_canvas_element_size("#canvas", width, height);
SetupViewport(width, height); // Reset viewport and projection matrix for new size SetupViewport(width, height); // Reset viewport and projection matrix for new size
@ -211,7 +214,8 @@ static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *
CORE.Window.currentFbo.height = height; CORE.Window.currentFbo.height = height;
CORE.Window.resizedLastFrame = true; CORE.Window.resizedLastFrame = true;
if (IsWindowFullscreen()) return 1; if (IsWindowFullscreen())
return 1;
// Set current screen size // Set current screen size
CORE.Window.screen.width = width; CORE.Window.screen.width = width;
@ -245,9 +249,10 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE
if ((gamepadEvent->connected) && (gamepadEvent->index < MAX_GAMEPADS)) if ((gamepadEvent->connected) && (gamepadEvent->index < MAX_GAMEPADS))
{ {
CORE.Input.Gamepad.ready[gamepadEvent->index] = true; CORE.Input.Gamepad.ready[gamepadEvent->index] = true;
sprintf(CORE.Input.Gamepad.name[gamepadEvent->index],"%s",gamepadEvent->id); sprintf(CORE.Input.Gamepad.name[gamepadEvent->index], "%s", gamepadEvent->id);
} }
else CORE.Input.Gamepad.ready[gamepadEvent->index] = false; else
CORE.Input.Gamepad.ready[gamepadEvent->index] = false;
return 1; // The event was consumed by the callback handler return 1; // The event was consumed by the callback handler
} }
@ -262,7 +267,7 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
double canvasHeight = 0.0; double canvasHeight = 0.0;
// NOTE: emscripten_get_canvas_element_size() returns canvas.width and canvas.height but // 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 // we are looking for actual CSS size: canvas.style.width and canvas.style.height
//EMSCRIPTEN_RESULT res = emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight); // EMSCRIPTEN_RESULT res = emscripten_get_canvas_element_size("#canvas", &canvasWidth, &canvasHeight);
emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight); emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);
for (int i = 0; (i < CORE.Input.Touch.pointCount) && (i < MAX_TOUCH_POINTS); i++) for (int i = 0; (i < CORE.Input.Touch.pointCount) && (i < MAX_TOUCH_POINTS); i++)
@ -271,26 +276,32 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
CORE.Input.Touch.pointId[i] = touchEvent->touches[i].identifier; CORE.Input.Touch.pointId[i] = touchEvent->touches[i].identifier;
// Register touch points position // Register touch points position
CORE.Input.Touch.position[i] = (Vector2){ touchEvent->touches[i].targetX, touchEvent->touches[i].targetY }; CORE.Input.Touch.position[i] = (Vector2){touchEvent->touches[i].targetX, touchEvent->touches[i].targetY};
// Normalize gestureEvent.position[x] for CORE.Window.screen.width and CORE.Window.screen.height // Normalize gestureEvent.position[x] for CORE.Window.screen.width and CORE.Window.screen.height
CORE.Input.Touch.position[i].x *= ((float)GetScreenWidth()/(float)canvasWidth); CORE.Input.Touch.position[i].x *= ((float)GetScreenWidth() / (float)canvasWidth);
CORE.Input.Touch.position[i].y *= ((float)GetScreenHeight()/(float)canvasHeight); CORE.Input.Touch.position[i].y *= ((float)GetScreenHeight() / (float)canvasHeight);
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) CORE.Input.Touch.currentTouchState[i] = 1; if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART)
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) CORE.Input.Touch.currentTouchState[i] = 0; CORE.Input.Touch.currentTouchState[i] = 1;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND)
CORE.Input.Touch.currentTouchState[i] = 0;
} }
#if defined(SUPPORT_GESTURES_SYSTEM) // PLATFORM_WEB #if defined(SUPPORT_GESTURES_SYSTEM) // PLATFORM_WEB
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = {0};
gestureEvent.pointCount = CORE.Input.Touch.pointCount; gestureEvent.pointCount = CORE.Input.Touch.pointCount;
// Register touch actions // Register touch actions
if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) gestureEvent.touchAction = TOUCH_ACTION_DOWN; if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART)
else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) gestureEvent.touchAction = TOUCH_ACTION_UP; gestureEvent.touchAction = TOUCH_ACTION_DOWN;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) gestureEvent.touchAction = TOUCH_ACTION_MOVE; else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND)
else if (eventType == EMSCRIPTEN_EVENT_TOUCHCANCEL) gestureEvent.touchAction = TOUCH_ACTION_CANCEL; gestureEvent.touchAction = TOUCH_ACTION_UP;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE)
gestureEvent.touchAction = TOUCH_ACTION_MOVE;
else if (eventType == EMSCRIPTEN_EVENT_TOUCHCANCEL)
gestureEvent.touchAction = TOUCH_ACTION_CANCEL;
for (int i = 0; (i < gestureEvent.pointCount) && (i < MAX_TOUCH_POINTS); i++) for (int i = 0; (i < gestureEvent.pointCount) && (i < MAX_TOUCH_POINTS); i++)
{ {
@ -306,13 +317,13 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
ProcessGestureEvent(gestureEvent); ProcessGestureEvent(gestureEvent);
// Reset the pointCount for web, if it was the last Touch End event // Reset the pointCount for web, if it was the last Touch End event
if (eventType == EMSCRIPTEN_EVENT_TOUCHEND && CORE.Input.Touch.pointCount == 1) CORE.Input.Touch.pointCount = 0; if (eventType == EMSCRIPTEN_EVENT_TOUCHEND && CORE.Input.Touch.pointCount == 1)
CORE.Input.Touch.pointCount = 0;
#endif #endif
return 1; // The event was consumed by the callback handler return 1; // The event was consumed by the callback handler
} }
// Initialize display device and framebuffer // Initialize display device and framebuffer
// NOTE: width and height represent the screen (framebuffer) desired size, not actual display size // NOTE: width and height represent the screen (framebuffer) desired size, not actual display size
// If width or height are 0, default display size will be used for framebuffer size // If width or height are 0, default display size will be used for framebuffer size
@ -356,43 +367,58 @@ static bool InitGraphicsDevice(int width, int height)
} }
glfwDefaultWindowHints(); // Set default windows hints glfwDefaultWindowHints(); // Set default windows hints
//glfwWindowHint(GLFW_RED_BITS, 8); // Framebuffer red color component bits // glfwWindowHint(GLFW_RED_BITS, 8); // Framebuffer red color component bits
//glfwWindowHint(GLFW_GREEN_BITS, 8); // Framebuffer green color component bits // glfwWindowHint(GLFW_GREEN_BITS, 8); // Framebuffer green color component bits
//glfwWindowHint(GLFW_BLUE_BITS, 8); // Framebuffer blue color component bits // glfwWindowHint(GLFW_BLUE_BITS, 8); // Framebuffer blue color component bits
//glfwWindowHint(GLFW_ALPHA_BITS, 8); // Framebuffer alpha color component bits // glfwWindowHint(GLFW_ALPHA_BITS, 8); // Framebuffer alpha color component bits
//glfwWindowHint(GLFW_DEPTH_BITS, 24); // Depthbuffer bits // glfwWindowHint(GLFW_DEPTH_BITS, 24); // Depthbuffer bits
//glfwWindowHint(GLFW_REFRESH_RATE, 0); // Refresh rate for fullscreen window // glfwWindowHint(GLFW_REFRESH_RATE, 0); // Refresh rate for fullscreen window
//glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); // OpenGL API to use. Alternative: GLFW_OPENGL_ES_API // glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); // OpenGL API to use. Alternative: GLFW_OPENGL_ES_API
//glfwWindowHint(GLFW_AUX_BUFFERS, 0); // Number of auxiliar buffers // glfwWindowHint(GLFW_AUX_BUFFERS, 0); // Number of auxiliar buffers
// Check window creation flags // Check window creation flags
if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) CORE.Window.fullscreen = true; if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0)
CORE.Window.fullscreen = true;
if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // Visible window if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0)
else glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE); // Window initially hidden glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // Visible window
else
glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE); // Window initially hidden
if ((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) > 0) glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); // Border and buttons on Window if ((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) > 0)
else glfwWindowHint(GLFW_DECORATED, GLFW_TRUE); // Decorated window glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); // Border and buttons on Window
else
glfwWindowHint(GLFW_DECORATED, GLFW_TRUE); // Decorated window
if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) > 0) glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // Resizable window if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) > 0)
else glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); // Avoid window being resizable glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // Resizable window
else
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); // Avoid window being resizable
// Disable FLAG_WINDOW_MINIMIZED, not supported on initialization // Disable FLAG_WINDOW_MINIMIZED, not supported on initialization
if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0)
CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED;
// Disable FLAG_WINDOW_MAXIMIZED, not supported on initialization // Disable FLAG_WINDOW_MAXIMIZED, not supported on initialization
if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0) CORE.Window.flags &= ~FLAG_WINDOW_MAXIMIZED; if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0)
CORE.Window.flags &= ~FLAG_WINDOW_MAXIMIZED;
if ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) > 0) glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE); if ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) > 0)
else glfwWindowHint(GLFW_FOCUSED, GLFW_TRUE); glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE);
else
glfwWindowHint(GLFW_FOCUSED, GLFW_TRUE);
if ((CORE.Window.flags & FLAG_WINDOW_TOPMOST) > 0) glfwWindowHint(GLFW_FLOATING, GLFW_TRUE); if ((CORE.Window.flags & FLAG_WINDOW_TOPMOST) > 0)
else glfwWindowHint(GLFW_FLOATING, GLFW_FALSE); glfwWindowHint(GLFW_FLOATING, GLFW_TRUE);
else
glfwWindowHint(GLFW_FLOATING, GLFW_FALSE);
// NOTE: Some GLFW flags are not supported on HTML5 // NOTE: Some GLFW flags are not supported on HTML5
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
if ((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) > 0) glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); // Transparent framebuffer if ((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) > 0)
else glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_FALSE); // Opaque framebuffer glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); // Transparent framebuffer
else
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_FALSE); // Opaque framebuffer
if ((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0) if ((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0)
{ {
@ -400,15 +426,18 @@ static bool InitGraphicsDevice(int width, int height)
// NOTE: This hint only has an effect on platforms where screen coordinates and pixels always map 1:1 such as Windows and X11. // NOTE: This hint only has an effect on platforms where screen coordinates and pixels always map 1:1 such as Windows and X11.
// On platforms like macOS the resolution of the framebuffer is changed independently of the window size. // On platforms like macOS the resolution of the framebuffer is changed independently of the window size.
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); // Scale content area based on the monitor content scale where window is placed on glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); // Scale content area based on the monitor content scale where window is placed on
#if defined(__APPLE__) #if defined(__APPLE__)
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE); glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE);
#endif #endif
} }
else glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE); else
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE);
// Mouse passthrough // Mouse passthrough
if ((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE); if ((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0)
else glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE); glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE);
else
glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE);
#endif #endif
if (CORE.Window.flags & FLAG_MSAA_4X_HINT) if (CORE.Window.flags & FLAG_MSAA_4X_HINT)
@ -439,7 +468,7 @@ static bool InitGraphicsDevice(int width, int height)
#else #else
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE); // Forward Compatibility Hint: Only 3.3 and above! glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE); // Forward Compatibility Hint: Only 3.3 and above!
#endif #endif
//glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Request OpenGL DEBUG context // glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Request OpenGL DEBUG context
} }
else if (rlGetVersion() == RL_OPENGL_43) else if (rlGetVersion() == RL_OPENGL_43)
{ {
@ -479,7 +508,8 @@ static bool InitGraphicsDevice(int width, int height)
// Forcing this initialization here avoids doing it on PollInputEvents() called by EndDrawing() after first frame has been just drawn. // Forcing this initialization here avoids doing it on PollInputEvents() called by EndDrawing() after first frame has been just drawn.
// The initialization will still happen and possible delays still occur, but before the window is shown, which is a nicer experience. // The initialization will still happen and possible delays still occur, but before the window is shown, which is a nicer experience.
// REF: https://github.com/raysan5/raylib/issues/1554 // REF: https://github.com/raysan5/raylib/issues/1554
if (MAX_GAMEPADS > 0) glfwSetJoystickCallback(NULL); if (MAX_GAMEPADS > 0)
glfwSetJoystickCallback(NULL);
#endif #endif
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
@ -497,8 +527,10 @@ static bool InitGraphicsDevice(int width, int height)
CORE.Window.display.height = mode->height; CORE.Window.display.height = mode->height;
// Set screen width/height to the display width/height if they are 0 // Set screen width/height to the display width/height if they are 0
if (CORE.Window.screen.width == 0) CORE.Window.screen.width = CORE.Window.display.width; if (CORE.Window.screen.width == 0)
if (CORE.Window.screen.height == 0) CORE.Window.screen.height = CORE.Window.display.height; CORE.Window.screen.width = CORE.Window.display.width;
if (CORE.Window.screen.height == 0)
CORE.Window.screen.height = CORE.Window.display.height;
#endif // PLATFORM_DESKTOP #endif // PLATFORM_DESKTOP
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
@ -514,17 +546,19 @@ static bool InitGraphicsDevice(int width, int height)
{ {
// If screen width/height equal to the display, we can't calculate the window pos for toggling full-screened/windowed. // 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. // 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.x = CORE.Window.display.width / 4;
CORE.Window.position.y = CORE.Window.display.height/4; CORE.Window.position.y = CORE.Window.display.height / 4;
} }
else else
{ {
CORE.Window.position.x = CORE.Window.display.width/2 - CORE.Window.screen.width/2; CORE.Window.position.x = CORE.Window.display.width / 2 - CORE.Window.screen.width / 2;
CORE.Window.position.y = CORE.Window.display.height/2 - CORE.Window.screen.height/2; CORE.Window.position.y = CORE.Window.display.height / 2 - CORE.Window.screen.height / 2;
} }
if (CORE.Window.position.x < 0) CORE.Window.position.x = 0; if (CORE.Window.position.x < 0)
if (CORE.Window.position.y < 0) CORE.Window.position.y = 0; CORE.Window.position.x = 0;
if (CORE.Window.position.y < 0)
CORE.Window.position.y = 0;
// Obtain recommended CORE.Window.display.width/CORE.Window.display.height from a valid videomode for the monitor // Obtain recommended CORE.Window.display.width/CORE.Window.display.height from a valid videomode for the monitor
int count = 0; int count = 0;
@ -557,10 +591,10 @@ static bool InitGraphicsDevice(int width, int height)
// HighDPI monitors are properly considered in a following similar function: SetupViewport() // HighDPI monitors are properly considered in a following similar function: SetupViewport()
SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height); SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height);
CORE.Window.handle = glfwCreateWindow(CORE.Window.display.width, CORE.Window.display.height, (CORE.Window.title != 0)? CORE.Window.title : " ", glfwGetPrimaryMonitor(), NULL); CORE.Window.handle = glfwCreateWindow(CORE.Window.display.width, CORE.Window.display.height, (CORE.Window.title != 0) ? CORE.Window.title : " ", glfwGetPrimaryMonitor(), NULL);
// NOTE: Full-screen change, not working properly... // NOTE: Full-screen change, not working properly...
//glfwSetWindowMonitor(CORE.Window.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); // glfwSetWindowMonitor(CORE.Window.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
} }
else else
{ {
@ -572,7 +606,7 @@ static bool InitGraphicsDevice(int width, int height)
} }
#endif #endif
// No-fullscreen window creation // No-fullscreen window creation
CORE.Window.handle = glfwCreateWindow(CORE.Window.screen.width, CORE.Window.screen.height, (CORE.Window.title != 0)? CORE.Window.title : " ", NULL, NULL); CORE.Window.handle = glfwCreateWindow(CORE.Window.screen.width, CORE.Window.screen.height, (CORE.Window.title != 0) ? CORE.Window.title : " ", NULL, NULL);
if (CORE.Window.handle) if (CORE.Window.handle)
{ {
@ -590,7 +624,7 @@ static bool InitGraphicsDevice(int width, int height)
// glfwCreateWindow title doesn't work with emscripten. // glfwCreateWindow title doesn't work with emscripten.
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_set_window_title((CORE.Window.title != 0)? CORE.Window.title : " "); emscripten_set_window_title((CORE.Window.title != 0) ? CORE.Window.title : " ");
#endif #endif
// Set window callback events // Set window callback events
@ -638,15 +672,15 @@ static bool InitGraphicsDevice(int width, int height)
{ {
// NOTE: On APPLE platforms system should manage window/input scaling and also framebuffer scaling. // NOTE: On APPLE platforms system should manage window/input scaling and also framebuffer scaling.
// Framebuffer scaling should be activated with: glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE); // Framebuffer scaling should be activated with: glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE);
#if !defined(__APPLE__) #if !defined(__APPLE__)
glfwGetFramebufferSize(CORE.Window.handle, &fbWidth, &fbHeight); glfwGetFramebufferSize(CORE.Window.handle, &fbWidth, &fbHeight);
// Screen scaling matrix is required in case desired screen area is different from display area // Screen scaling matrix is required in case desired screen area is different from display area
CORE.Window.screenScale = MatrixScale((float)fbWidth/CORE.Window.screen.width, (float)fbHeight/CORE.Window.screen.height, 1.0f); CORE.Window.screenScale = MatrixScale((float)fbWidth / CORE.Window.screen.width, (float)fbHeight / CORE.Window.screen.height, 1.0f);
// Mouse input scaling for the new screen size // Mouse input scaling for the new screen size
SetMouseScale((float)CORE.Window.screen.width/fbWidth, (float)CORE.Window.screen.height/fbHeight); SetMouseScale((float)CORE.Window.screen.width / fbWidth, (float)CORE.Window.screen.height / fbHeight);
#endif #endif
} }
#endif #endif
@ -771,19 +805,22 @@ static bool InitGraphicsDevice(int width, int height)
} }
const bool allowInterlaced = CORE.Window.flags & FLAG_INTERLACED_HINT; const bool allowInterlaced = 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 // Try to find an exact matching mode
CORE.Window.modeIndex = FindExactConnectorMode(CORE.Window.connector, CORE.Window.screen.width, CORE.Window.screen.height, fps, allowInterlaced); CORE.Window.modeIndex = FindExactConnectorMode(CORE.Window.connector, CORE.Window.screen.width, CORE.Window.screen.height, fps, allowInterlaced);
// If nothing found, try to find a nearly matching mode // If nothing found, try to find a nearly matching mode
if (CORE.Window.modeIndex < 0) CORE.Window.modeIndex = FindNearestConnectorMode(CORE.Window.connector, CORE.Window.screen.width, CORE.Window.screen.height, fps, allowInterlaced); if (CORE.Window.modeIndex < 0)
CORE.Window.modeIndex = FindNearestConnectorMode(CORE.Window.connector, CORE.Window.screen.width, CORE.Window.screen.height, fps, allowInterlaced);
// If nothing found, try to find an exactly matching mode including interlaced // If nothing found, try to find an exactly matching mode including interlaced
if (CORE.Window.modeIndex < 0) CORE.Window.modeIndex = FindExactConnectorMode(CORE.Window.connector, CORE.Window.screen.width, CORE.Window.screen.height, fps, true); if (CORE.Window.modeIndex < 0)
CORE.Window.modeIndex = FindExactConnectorMode(CORE.Window.connector, CORE.Window.screen.width, CORE.Window.screen.height, fps, true);
// If nothing found, try to find a nearly matching mode including interlaced // If nothing found, try to find a nearly matching mode including interlaced
if (CORE.Window.modeIndex < 0) CORE.Window.modeIndex = FindNearestConnectorMode(CORE.Window.connector, CORE.Window.screen.width, CORE.Window.screen.height, fps, true); if (CORE.Window.modeIndex < 0)
CORE.Window.modeIndex = FindNearestConnectorMode(CORE.Window.connector, CORE.Window.screen.width, CORE.Window.screen.height, fps, true);
// If nothing found, there is no suitable mode // If nothing found, there is no suitable mode
if (CORE.Window.modeIndex < 0) if (CORE.Window.modeIndex < 0)
@ -839,29 +876,37 @@ static bool InitGraphicsDevice(int width, int height)
const EGLint framebufferAttribs[] = const EGLint framebufferAttribs[] =
{ {
EGL_RENDERABLE_TYPE, (rlGetVersion() == RL_OPENGL_ES_30)? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, // Type of context support EGL_RENDERABLE_TYPE,
(rlGetVersion() == RL_OPENGL_ES_30) ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, // Type of context support
#if defined(PLATFORM_DRM) #if defined(PLATFORM_DRM)
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, // Don't use it on Android! EGL_SURFACE_TYPE,
EGL_WINDOW_BIT, // Don't use it on Android!
#endif #endif
EGL_RED_SIZE, 8, // RED color bit depth (alternative: 5) EGL_RED_SIZE,
EGL_GREEN_SIZE, 8, // GREEN color bit depth (alternative: 6) 8, // RED color bit depth (alternative: 5)
EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5) EGL_GREEN_SIZE,
8, // GREEN color bit depth (alternative: 6)
EGL_BLUE_SIZE,
8, // BLUE color bit depth (alternative: 5)
#if defined(PLATFORM_DRM) #if defined(PLATFORM_DRM)
EGL_ALPHA_SIZE, 8, // ALPHA bit depth (required for transparent framebuffer) EGL_ALPHA_SIZE,
8, // ALPHA bit depth (required for transparent framebuffer)
#endif #endif
//EGL_TRANSPARENT_TYPE, EGL_NONE, // Request transparent framebuffer (EGL_TRANSPARENT_RGB does not work on RPI) // EGL_TRANSPARENT_TYPE, EGL_NONE, // Request transparent framebuffer (EGL_TRANSPARENT_RGB does not work on RPI)
EGL_DEPTH_SIZE, 16, // Depth buffer size (Required to use Depth testing!) EGL_DEPTH_SIZE,
//EGL_STENCIL_SIZE, 8, // Stencil buffer size 16, // Depth buffer size (Required to use Depth testing!)
EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA // EGL_STENCIL_SIZE, 8, // Stencil buffer size
EGL_SAMPLES, samples, // 4x Antialiasing if activated (Free on MALI GPUs) EGL_SAMPLE_BUFFERS,
sampleBuffer, // Activate MSAA
EGL_SAMPLES,
samples, // 4x Antialiasing if activated (Free on MALI GPUs)
EGL_NONE EGL_NONE
}; };
const EGLint contextAttribs[] = const EGLint contextAttribs[] =
{ {
EGL_CONTEXT_CLIENT_VERSION, 2, EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE EGL_NONE};
};
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_DRM) #if defined(PLATFORM_ANDROID) || defined(PLATFORM_DRM)
EGLint numConfigs = 0; EGLint numConfigs = 0;
@ -973,7 +1018,7 @@ static bool InitGraphicsDevice(int width, int height)
SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height); SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height);
ANativeWindow_setBuffersGeometry(CORE.Android.app->window, CORE.Window.render.width, CORE.Window.render.height, displayFormat); ANativeWindow_setBuffersGeometry(CORE.Android.app->window, CORE.Window.render.width, CORE.Window.render.height, displayFormat);
//ANativeWindow_setBuffersGeometry(CORE.Android.app->window, 0, 0, displayFormat); // Force use of native display size // ANativeWindow_setBuffersGeometry(CORE.Android.app->window, 0, 0, displayFormat); // Force use of native display size
CORE.Window.surface = eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, CORE.Android.app->window, NULL); CORE.Window.surface = eglCreateWindowSurface(CORE.Window.device, CORE.Window.config, CORE.Android.app->window, NULL);
#endif // PLATFORM_ANDROID #endif // PLATFORM_ANDROID
@ -995,7 +1040,7 @@ static bool InitGraphicsDevice(int width, int height)
#endif // PLATFORM_DRM #endif // PLATFORM_DRM
// There must be at least one frame displayed before the buffers are swapped // There must be at least one frame displayed before the buffers are swapped
//eglSwapInterval(CORE.Window.device, 1); // eglSwapInterval(CORE.Window.device, 1);
if (eglMakeCurrent(CORE.Window.device, CORE.Window.surface, CORE.Window.surface, CORE.Window.context) == EGL_FALSE) if (eglMakeCurrent(CORE.Window.device, CORE.Window.surface, CORE.Window.surface, CORE.Window.context) == EGL_FALSE)
{ {
@ -1037,7 +1082,8 @@ static bool InitGraphicsDevice(int width, int height)
CORE.Window.ready = true; CORE.Window.ready = true;
#endif #endif
if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) MinimizeWindow(); if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0)
MinimizeWindow();
return true; return true;
} }
@ -1075,8 +1121,6 @@ void CloseWindow(void)
TRACELOG(LOG_INFO, "Window closed successfully"); TRACELOG(LOG_INFO, "Window closed successfully");
} }
// Check if KEY_ESCAPE pressed or Close icon pressed // Check if KEY_ESCAPE pressed or Close icon pressed
bool WindowShouldClose(void) bool WindowShouldClose(void)
{ {
@ -1119,11 +1163,10 @@ bool IsWindowResized(void)
return CORE.Window.resizedLastFrame; return CORE.Window.resizedLastFrame;
} }
// Toggle fullscreen mode (only PLATFORM_DESKTOP) // Toggle fullscreen mode (only PLATFORM_DESKTOP)
void ToggleFullscreen(void) void ToggleFullscreen(void)
{ {
/* /*
EM_ASM EM_ASM
( (
// This strategy works well while using raylib minimal web shell for emscripten, // This strategy works well while using raylib minimal web shell for emscripten,
@ -1133,9 +1176,9 @@ void ToggleFullscreen(void)
if (document.fullscreenElement) document.exitFullscreen(); if (document.fullscreenElement) document.exitFullscreen();
else Module.requestFullscreen(true, true); //false, true); else Module.requestFullscreen(true, true); //false, true);
); );
*/ */
//EM_ASM(Module.requestFullscreen(false, false);); // EM_ASM(Module.requestFullscreen(false, false););
/* /*
if (!CORE.Window.fullscreen) if (!CORE.Window.fullscreen)
{ {
// Option 1: Request fullscreen for the canvas element // Option 1: Request fullscreen for the canvas element
@ -1186,7 +1229,25 @@ void ToggleFullscreen(void)
CORE.Window.fullscreen = false; // Toggle fullscreen flag CORE.Window.fullscreen = false; // Toggle fullscreen flag
CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE; CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE;
} }
*/ */
CORE.Window.fullscreen = !CORE.Window.fullscreen; // Toggle fullscreen flag CORE.Window.fullscreen = !CORE.Window.fullscreen; // Toggle fullscreen flag
} }
// Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
void MaximizeWindow(void)
{
TRACELOG(LOG_WARNING, "MaximizeWindow not implemented in rcore_web.c");
}
// Set window state: minimized (only PLATFORM_DESKTOP)
void MinimizeWindow(void)
{
TRACELOG(LOG_WARNING, "MinimizeWindow not implemented in rcore_web.c");
}
// Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
void RestoreWindow(void)
{
TRACELOG(LOG_WARNING, "RestoreWindow not implemented in rcore_web.c");
}