Moved some platforms functions to generic rcore #3313

Reviewed `InitWindow()` to clearly note platform specific code
This commit is contained in:
Ray 2023-10-13 14:14:16 +02:00
parent 876e6b3a0d
commit 2e65bc675c
6 changed files with 142 additions and 236 deletions

View File

@ -322,18 +322,15 @@ const char *TextFormat(const char *text, ...); // Formatting of text with
//void InitWindow(int width, int height, const char *title) //void InitWindow(int width, int height, const char *title)
//void CloseWindow(void) //void CloseWindow(void)
//bool WindowShouldClose(void) //bool WindowShouldClose(void)
//bool IsWindowHidden(void)
//bool IsWindowMinimized(void)
//bool IsWindowMaximized(void)
//bool IsWindowFocused(void)
//bool IsWindowResized(void)
//void ToggleFullscreen(void) //void ToggleFullscreen(void)
//void ToggleBorderlessWindowed(void)
//void MaximizeWindow(void) //void MaximizeWindow(void)
//void MinimizeWindow(void) //void MinimizeWindow(void)
//void RestoreWindow(void) //void RestoreWindow(void)
//void ToggleBorderlessWindowed(void)
//void SetWindowState(unsigned int flags) //void SetWindowState(unsigned int flags)
//void ClearWindowState(unsigned int flags) //void ClearWindowState(unsigned int flags)
//void SetWindowIcon(Image image) //void SetWindowIcon(Image image)
//void SetWindowIcons(Image *images, int count) //void SetWindowIcons(Image *images, int count)
//void SetWindowTitle(const char *title) //void SetWindowTitle(const char *title)
@ -345,25 +342,27 @@ const char *TextFormat(const char *text, ...); // Formatting of text with
//void SetWindowOpacity(float opacity) //void SetWindowOpacity(float opacity)
//void SetWindowFocused(void) //void SetWindowFocused(void)
//void *GetWindowHandle(void) //void *GetWindowHandle(void)
//Vector2 GetWindowPosition(void)
//Vector2 GetWindowScaleDPI(void)
//int GetMonitorCount(void) //int GetMonitorCount(void)
//int GetCurrentMonitor(void) //int GetCurrentMonitor(void)
//Vector2 GetMonitorPosition(int monitor)
//int GetMonitorWidth(int monitor) //int GetMonitorWidth(int monitor)
//int GetMonitorHeight(int monitor) //int GetMonitorHeight(int monitor)
//int GetMonitorPhysicalWidth(int monitor) //int GetMonitorPhysicalWidth(int monitor)
//int GetMonitorPhysicalHeight(int monitor) //int GetMonitorPhysicalHeight(int monitor)
//int GetMonitorRefreshRate(int monitor) //int GetMonitorRefreshRate(int monitor)
//Vector2 GetMonitorPosition(int monitor)
//const char *GetMonitorName(int monitor) //const char *GetMonitorName(int monitor)
//Vector2 GetWindowPosition(void)
//Vector2 GetWindowScaleDPI(void)
//void SetClipboardText(const char *text) //void SetClipboardText(const char *text)
//const char *GetClipboardText(void) //const char *GetClipboardText(void)
//void ShowCursor(void) //void ShowCursor(void)
//void HideCursor(void) //void HideCursor(void)
//void EnableCursor(void) //void EnableCursor(void)
//void DisableCursor(void) //void DisableCursor(void)
// Check if window has been initialized successfully // Check if window has been initialized successfully
bool IsWindowReady(void) bool IsWindowReady(void)
{ {
@ -376,6 +375,36 @@ bool IsWindowFullscreen(void)
return CORE.Window.fullscreen; return CORE.Window.fullscreen;
} }
// Check if window is currently hidden
bool IsWindowHidden(void)
{
return ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0);
}
// Check if window has been minimized
bool IsWindowMinimized(void)
{
return ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0);
}
// Check if window has been maximized
bool IsWindowMaximized(void)
{
return ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0);
}
// Check if window has the focus
bool IsWindowFocused(void)
{
return ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) == 0);
}
// Check if window has been resizedLastFrame
bool IsWindowResized(void)
{
return CORE.Window.resizedLastFrame;
}
// Check if one specific window flag is enabled // Check if one specific window flag is enabled
bool IsWindowState(unsigned int flag) bool IsWindowState(unsigned int flag)
{ {
@ -394,13 +423,13 @@ int GetScreenHeight(void)
return CORE.Window.screen.height; return CORE.Window.screen.height;
} }
// Get current render width which is equal to screen width * dpi scale // Get current render width which is equal to screen width*dpi scale
int GetRenderWidth(void) int GetRenderWidth(void)
{ {
return CORE.Window.render.width; return CORE.Window.render.width;
} }
// Get current screen height which is equal to screen height * dpi scale // Get current screen height which is equal to screen height*dpi scale
int GetRenderHeight(void) int GetRenderHeight(void)
{ {
return CORE.Window.render.height; return CORE.Window.render.height;

View File

@ -183,13 +183,14 @@ void InitWindow(int width, int height, const char *title)
CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
CORE.Window.eventWaiting = false; CORE.Window.eventWaiting = false;
// Platform specific init window
//--------------------------------------------------------------
CORE.Window.screen.width = width; CORE.Window.screen.width = width;
CORE.Window.screen.height = height; CORE.Window.screen.height = height;
CORE.Window.currentFbo.width = width; CORE.Window.currentFbo.width = width;
CORE.Window.currentFbo.height = height; CORE.Window.currentFbo.height = height;
// Platform specific init window
//--------------------------------------------------------------
// Set desired windows flags before initializing anything // Set desired windows flags before initializing anything
ANativeActivity_setWindowFlags(platform.app->activity, AWINDOW_FLAG_FULLSCREEN, 0); //AWINDOW_FLAG_SCALED, AWINDOW_FLAG_DITHER ANativeActivity_setWindowFlags(platform.app->activity, AWINDOW_FLAG_FULLSCREEN, 0); //AWINDOW_FLAG_SCALED, AWINDOW_FLAG_DITHER
@ -227,6 +228,12 @@ void InitWindow(int width, int height, const char *title)
// Initialize base path for storage // Initialize base path for storage
CORE.Storage.basePath = platform.app->activity->internalDataPath; CORE.Storage.basePath = platform.app->activity->internalDataPath;
// Set some default window flags
CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN; // false
CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED); // false
CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED); // true
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED); // false
TRACELOG(LOG_INFO, "PLATFORM: ANDROID: Application initialized successfully"); TRACELOG(LOG_INFO, "PLATFORM: ANDROID: Application initialized successfully");
@ -311,36 +318,6 @@ bool WindowShouldClose(void)
else return true; else return true;
} }
// Check if window is currently hidden
bool IsWindowHidden(void)
{
return false;
}
// Check if window has been minimized
bool IsWindowMinimized(void)
{
return false;
}
// Check if window has been maximized
bool IsWindowMaximized(void)
{
return false;
}
// Check if window has the focus
bool IsWindowFocused(void)
{
return platform.appEnabled;
}
// Check if window has been resizedLastFrame
bool IsWindowResized(void)
{
return false;
}
// Toggle fullscreen mode // Toggle fullscreen mode
void ToggleFullscreen(void) void ToggleFullscreen(void)
{ {
@ -936,12 +913,14 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
case APP_CMD_GAINED_FOCUS: case APP_CMD_GAINED_FOCUS:
{ {
platform.appEnabled = true; platform.appEnabled = true;
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED;
//ResumeMusicStream(); //ResumeMusicStream();
} break; } break;
case APP_CMD_PAUSE: break; case APP_CMD_PAUSE: break;
case APP_CMD_LOST_FOCUS: case APP_CMD_LOST_FOCUS:
{ {
platform.appEnabled = false; platform.appEnabled = false;
CORE.Window.flags |= FLAG_WINDOW_UNFOCUSED;
//PauseMusicStream(); //PauseMusicStream();
} break; } break;
case APP_CMD_TERM_WINDOW: case APP_CMD_TERM_WINDOW:

View File

@ -2,7 +2,7 @@
* *
* rcore_desktop - Functions to manage window, graphics device and inputs * rcore_desktop - Functions to manage window, graphics device and inputs
* *
* PLATFORM: DESKTOP * PLATFORM: DESKTOP: GLFW
* - Windows (Win32, Win64) * - Windows (Win32, Win64)
* - Linux (X11/Wayland desktop mode) * - Linux (X11/Wayland desktop mode)
* - FreeBSD, OpenBSD, NetBSD, DragonFly (X11 desktop) * - FreeBSD, OpenBSD, NetBSD, DragonFly (X11 desktop)
@ -187,8 +187,26 @@ void InitWindow(int width, int height, const char *title)
CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
CORE.Window.eventWaiting = false; CORE.Window.eventWaiting = false;
// Platform specific init window
//--------------------------------------------------------------
glfwSetErrorCallback(ErrorCallback);
/*
// TODO: Setup GLFW custom allocators to match raylib ones
const GLFWallocator allocator = {
.allocate = MemAlloc,
.deallocate = MemFree,
.reallocate = MemRealloc,
.user = NULL
};
glfwInitAllocator(&allocator);
*/
// Initialize graphics device // Initialize graphics device
// NOTE: returns true if window and graphic device has been initialized successfully // NOTE: returns true if window and graphic device has been initialized successfully
// WARNING: Actually, all window initialization and input callbacks initialization is
// done inside InitGraphicsDevice(), this functionality should be changed!
CORE.Window.ready = InitGraphicsDevice(width, height); CORE.Window.ready = InitGraphicsDevice(width, height);
// If graphic device is no properly initialized, we end program // If graphic device is no properly initialized, we end program
@ -197,13 +215,15 @@ void InitWindow(int width, int height, const char *title)
// Initialize hi-res timer // Initialize hi-res timer
InitTimer(); InitTimer();
// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();
//--------------------------------------------------------------
// Initialize random seed // Initialize random seed
SetRandomSeed((unsigned int)time(NULL)); SetRandomSeed((unsigned int)time(NULL));
// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) #if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
// Load default font // Load default font
// WARNING: External function: Module required: rtext // WARNING: External function: Module required: rtext
@ -304,36 +324,6 @@ bool WindowShouldClose(void)
else return true; else return true;
} }
// Check if window is currently hidden
bool IsWindowHidden(void)
{
return ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0);
}
// Check if window has been minimized
bool IsWindowMinimized(void)
{
return ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0);
}
// Check if window has been maximized
bool IsWindowMaximized(void)
{
return ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0);
}
// Check if window has the focus
bool IsWindowFocused(void)
{
return ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) == 0);
}
// Check if window has been resizedLastFrame
bool IsWindowResized(void)
{
return CORE.Window.resizedLastFrame;
}
// Toggle fullscreen mode // Toggle fullscreen mode
void ToggleFullscreen(void) void ToggleFullscreen(void)
{ {
@ -1408,18 +1398,6 @@ static bool InitGraphicsDevice(int width, int height)
// NOTE: Framebuffer (render area - CORE.Window.render.width, CORE.Window.render.height) could include black bars... // NOTE: Framebuffer (render area - CORE.Window.render.width, CORE.Window.render.height) could include black bars...
// ...in top-down or left-right to match display aspect ratio (no weird scaling) // ...in top-down or left-right to match display aspect ratio (no weird scaling)
glfwSetErrorCallback(ErrorCallback);
/*
// TODO: Setup GLFW custom allocators to match raylib ones
const GLFWallocator allocator = {
.allocate = MemAlloc,
.deallocate = MemFree,
.reallocate = MemRealloc,
.user = NULL
};
glfwInitAllocator(&allocator);
*/
#if defined(__APPLE__) #if defined(__APPLE__)
glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, GLFW_FALSE); glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, GLFW_FALSE);
#endif #endif

View File

@ -215,6 +215,9 @@ void InitWindow(int width, int height, const char *title)
CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
CORE.Window.eventWaiting = false; CORE.Window.eventWaiting = false;
// Platform specific init window
//--------------------------------------------------------------
// Initialize graphics device (display device and OpenGL context) // Initialize graphics device (display device and OpenGL context)
// NOTE: returns true if window and graphic device has been initialized successfully // NOTE: returns true if window and graphic device has been initialized successfully
CORE.Window.ready = InitGraphicsDevice(width, height); CORE.Window.ready = InitGraphicsDevice(width, height);
@ -223,15 +226,28 @@ void InitWindow(int width, int height, const char *title)
if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); return; } if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphic device"); 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);
// Set some default window flags
CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN; // false
CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED); // false
CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED); // true
CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED); // false
// Initialize hi-res timer // Initialize hi-res timer
InitTimer(); InitTimer();
// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();
// Initialize raw input system
InitEvdevInput(); // Evdev inputs initialization
InitGamepad(); // Gamepad init
InitKeyboard(); // Keyboard init (stdin)
//--------------------------------------------------------------
// Initialize random seed // Initialize random seed
SetRandomSeed((unsigned int)time(NULL)); SetRandomSeed((unsigned int)time(NULL));
// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) #if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
// Load default font // Load default font
// WARNING: External function: Module required: rtext // WARNING: External function: Module required: rtext
@ -274,14 +290,6 @@ void InitWindow(int width, int height, const char *title)
CORE.Time.frameCounter = 0; CORE.Time.frameCounter = 0;
#endif #endif
// Platform specific init window
//--------------------------------------------------------------
// Initialize raw input system
InitEvdevInput(); // Evdev inputs initialization
InitGamepad(); // Gamepad init
InitKeyboard(); // Keyboard init (stdin)
//--------------------------------------------------------------
TRACELOG(LOG_INFO, "PLATFORM: DRM: Application initialized successfully"); TRACELOG(LOG_INFO, "PLATFORM: DRM: Application initialized successfully");
} }
@ -412,36 +420,6 @@ bool WindowShouldClose(void)
else return true; else return true;
} }
// Check if window is currently hidden
bool IsWindowHidden(void)
{
return false;
}
// Check if window has been minimized
bool IsWindowMinimized(void)
{
return false;
}
// Check if window has been maximized
bool IsWindowMaximized(void)
{
return false;
}
// Check if window has the focus
bool IsWindowFocused(void)
{
return true;
}
// Check if window has been resizedLastFrame
bool IsWindowResized(void)
{
return false;
}
// Toggle fullscreen mode // Toggle fullscreen mode
void ToggleFullscreen(void) void ToggleFullscreen(void)
{ {

View File

@ -128,8 +128,11 @@ void InitWindow(int width, int height, const char *title)
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
CORE.Window.eventWaiting = false; CORE.Window.eventWaiting = false;
// TODO: Platform specific init window
//--------------------------------------------------------------
CORE.Window.screen.width = width; CORE.Window.screen.width = width;
CORE.Window.screen.height = height; CORE.Window.screen.height = height;
CORE.Window.currentFbo.width = width; CORE.Window.currentFbo.width = width;
@ -144,13 +147,15 @@ void InitWindow(int width, int height, const char *title)
// Initialize hi-res timer // Initialize hi-res timer
InitTimer(); InitTimer();
// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();
//--------------------------------------------------------------
// Initialize random seed // Initialize random seed
SetRandomSeed((unsigned int)time(NULL)); SetRandomSeed((unsigned int)time(NULL));
// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) #if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
// Load default font // Load default font
// WARNING: External function: Module required: rtext // WARNING: External function: Module required: rtext
@ -193,11 +198,6 @@ void InitWindow(int width, int height, const char *title)
CORE.Time.frameCounter = 0; CORE.Time.frameCounter = 0;
#endif #endif
// TODO: Platform specific init window
//--------------------------------------------------------------
// ...
//--------------------------------------------------------------
TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Application initialized successfully"); TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Application initialized successfully");
} }
@ -239,36 +239,6 @@ bool WindowShouldClose(void)
else return true; else return true;
} }
// Check if window is currently hidden
bool IsWindowHidden(void)
{
return false;
}
// Check if window has been minimized
bool IsWindowMinimized(void)
{
return false;
}
// Check if window has been maximized
bool IsWindowMaximized(void)
{
return false;
}
// Check if window has the focus
bool IsWindowFocused(void)
{
return platform.appEnabled;
}
// Check if window has been resizedLastFrame
bool IsWindowResized(void)
{
return false;
}
// Toggle fullscreen mode // Toggle fullscreen mode
void ToggleFullscreen(void) void ToggleFullscreen(void)
{ {

View File

@ -171,6 +171,9 @@ void InitWindow(int width, int height, const char *title)
CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
CORE.Window.eventWaiting = false; CORE.Window.eventWaiting = false;
// Platform specific init window
//--------------------------------------------------------------
// Initialize graphics device (display device and OpenGL context) // Initialize graphics device (display device and OpenGL context)
// NOTE: returns true if window and graphic device has been initialized successfully // NOTE: returns true if window and graphic device has been initialized successfully
CORE.Window.ready = InitGraphicsDevice(width, height); CORE.Window.ready = InitGraphicsDevice(width, height);
@ -181,13 +184,44 @@ void InitWindow(int width, int height, const char *title)
// Initialize hi-res timer // Initialize hi-res timer
InitTimer(); InitTimer();
// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();
// Setup callback functions for the DOM events
emscripten_set_fullscreenchange_callback("#canvas", NULL, 1, EmscriptenFullscreenChangeCallback);
// 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)
// 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)
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback);
// Trigger this once to get initial window sizing
EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL);
// Support keyboard events -> Not used, GLFW.JS takes care of that
// emscripten_set_keypress_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback);
// emscripten_set_keydown_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback);
// Support mouse events
emscripten_set_click_callback("#canvas", NULL, 1, EmscriptenMouseCallback);
// Support touch events
emscripten_set_touchstart_callback("#canvas", NULL, 1, EmscriptenTouchCallback);
emscripten_set_touchend_callback("#canvas", NULL, 1, EmscriptenTouchCallback);
emscripten_set_touchmove_callback("#canvas", NULL, 1, EmscriptenTouchCallback);
emscripten_set_touchcancel_callback("#canvas", NULL, 1, EmscriptenTouchCallback);
// Support gamepad events (not provided by GLFW3 on emscripten)
emscripten_set_gamepadconnected_callback(NULL, 1, EmscriptenGamepadCallback);
emscripten_set_gamepaddisconnected_callback(NULL, 1, EmscriptenGamepadCallback);
//--------------------------------------------------------------
// Initialize random seed // Initialize random seed
SetRandomSeed((unsigned int)time(NULL)); SetRandomSeed((unsigned int)time(NULL));
// Initialize base path for storage
CORE.Storage.basePath = GetWorkingDirectory();
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) #if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
// Load default font // Load default font
// WARNING: External function: Module required: rtext // WARNING: External function: Module required: rtext
@ -230,38 +264,6 @@ void InitWindow(int width, int height, const char *title)
CORE.Time.frameCounter = 0; CORE.Time.frameCounter = 0;
#endif #endif
// Platform specific init window
//--------------------------------------------------------------
// Setup callback functions for the DOM events
emscripten_set_fullscreenchange_callback("#canvas", NULL, 1, EmscriptenFullscreenChangeCallback);
// 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)
// 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)
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback);
// Trigger this once to get initial window sizing
EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL);
// Support keyboard events -> Not used, GLFW.JS takes care of that
// emscripten_set_keypress_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback);
// emscripten_set_keydown_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback);
// Support mouse events
emscripten_set_click_callback("#canvas", NULL, 1, EmscriptenMouseCallback);
// Support touch events
emscripten_set_touchstart_callback("#canvas", NULL, 1, EmscriptenTouchCallback);
emscripten_set_touchend_callback("#canvas", NULL, 1, EmscriptenTouchCallback);
emscripten_set_touchmove_callback("#canvas", NULL, 1, EmscriptenTouchCallback);
emscripten_set_touchcancel_callback("#canvas", NULL, 1, EmscriptenTouchCallback);
// Support gamepad events (not provided by GLFW3 on emscripten)
emscripten_set_gamepadconnected_callback(NULL, 1, EmscriptenGamepadCallback);
emscripten_set_gamepaddisconnected_callback(NULL, 1, EmscriptenGamepadCallback);
//--------------------------------------------------------------
TRACELOG(LOG_INFO, "PLATFORM: WEB: Application initialized successfully"); TRACELOG(LOG_INFO, "PLATFORM: WEB: Application initialized successfully");
} }
@ -309,36 +311,6 @@ bool WindowShouldClose(void)
return false; return false;
} }
// Check if window is currently hidden
bool IsWindowHidden(void)
{
return false;
}
// Check if window has been minimized
bool IsWindowMinimized(void)
{
return false;
}
// Check if window has been maximized
bool IsWindowMaximized(void)
{
return false;
}
// Check if window has the focus
bool IsWindowFocused(void)
{
return ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) == 0);
}
// Check if window has been resizedLastFrame
bool IsWindowResized(void)
{
return CORE.Window.resizedLastFrame;
}
// Toggle fullscreen mode // Toggle fullscreen mode
void ToggleFullscreen(void) void ToggleFullscreen(void)
{ {