Browse Source

Update RGFW (#4176)

* update RGFW

* fix bug with GetCurrentMonitor

* update RGFW

* update RGFW

* clean up merge
pull/4178/head
Colleague Riley 5 months ago
committed by GitHub
parent
commit
f1f08861a1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
2 changed files with 2189 additions and 1229 deletions
  1. +2160
    -1209
      src/external/RGFW.h
  2. +29
    -20
      src/platforms/rcore_desktop_rgfw.c

+ 2160
- 1209
src/external/RGFW.h
File diff suppressed because it is too large
View File


+ 29
- 20
src/platforms/rcore_desktop_rgfw.c View File

@ -46,7 +46,7 @@
*
**********************************************************************************************/
#ifdef GRAPHICS_API_OPENGL_ES2
#if defined(GRAPHICS_API_OPENGL_ES2)
#define RGFW_OPENGL_ES2
#endif
@ -182,7 +182,7 @@ static const unsigned short keyMappingRGFW[] = {
[RGFW_u] = KEY_U,
[RGFW_v] = KEY_V,
[RGFW_w] = KEY_W,
[RGFW_x] KEY_X,
[RGFW_x] o">= KEY_X,
[RGFW_y] = KEY_Y,
[RGFW_z] = KEY_Z,
[RGFW_Bracket] = KEY_LEFT_BRACKET,
@ -483,14 +483,14 @@ void SetWindowIcons(Image *images, int count)
// Set title for window
void SetWindowTitle(const char *title)
{
RGFW_window_setName(platform.window, title);
RGFW_window_setName(platform.window, p">(char*)title);
CORE.Window.title = title;
}
// Set window position on screen (windowed mode)
void SetWindowPosition(int x, int y)
{
RGFW_window_move(platform.window, RGFW_VECTOR(x, y));
RGFW_window_move(platform.window, RGFW_POINT(x, y));
}
// Set monitor for the current window
@ -536,7 +536,9 @@ void SetWindowFocused(void)
// Get native window handle
void *GetWindowHandle(void)
{
#ifndef RGFW_WINDOWS
#ifdef RGFW_WEBASM
return (void*)platform.window->src.ctx;
#elif !defined(RGFW_WINDOWS)
return (void *)platform.window->src.window;
#else
return platform.window->src.hwnd;
@ -643,7 +645,7 @@ Vector2 GetWindowScaleDPI(void)
{
RGFW_monitor monitor = RGFW_window_getMonitor(platform.window);
return (Vector2){p">((u32)monitor.scaleX)*platform.window->r.w, p">((u32) monitor.scaleX)*platform.window->r.h};
return (Vector2){monitor.scaleX, monitor.scaleX};
}
// Set clipboard text content
@ -689,9 +691,8 @@ void EnableCursor(void)
void DisableCursor(void)
{
RGFW_disableCursor = true;
// Set cursor position in the middle
SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
RGFW_window_mouseHold(platform.window, RGFW_AREA(CORE.Window.screen.width / 2, CORE.Window.screen.height / 2));
HideCursor();
}
@ -745,7 +746,7 @@ int SetGamepadMappings(const char *mappings)
// Set mouse position XY
void SetMousePosition(int x, int y)
{
RGFW_window_moveMouse(platform.window, RGFW_VECTOR(x, y));
RGFW_window_moveMouse(platform.window, RGFW_POINT(x, y));
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
}
@ -875,10 +876,10 @@ void PollInputEvents(void)
//-----------------------------------------------------------------------------
CORE.Window.resizedLastFrame = false;
#define RGFW_HOLD_MOUSE (1L<<2)
#if defined(RGFW_X11) //|| defined(RGFW_MACOS)
if (platform.window->src.winArgs & RGFW_HOLD_MOUSE)
#define RGFW_HOLD_MOUSE (1L<<2)
#if defined(RGFW_X11) //|| defined(RGFW_MACOS)
if (platform.window->_winArgs & RGFW_HOLD_MOUSE)
{
CORE.Input.Mouse.previousPosition = (Vector2){ 0.0f, 0.0f };
CORE.Input.Mouse.currentPosition = (Vector2){ 0.0f, 0.0f };
@ -1031,17 +1032,17 @@ void PollInputEvents(void)
} break;
case RGFW_mousePosChanged:
{
if (platform.window->src.winArgs & RGFW_HOLD_MOUSE)
if (platform.window->_winArgs & RGFW_HOLD_MOUSE)
{
CORE.Input.Mouse.previousPosition = (Vector2){ 0.0f, 0.0f };
if (p">(event->point.x - (platform.window->r.w/2))*2)
if (event->point.x)
CORE.Input.Mouse.previousPosition.x = CORE.Input.Mouse.currentPosition.x;
if (p">(event->point.y - (platform.window->r.h/2))*2)
if (event->point.y)
CORE.Input.Mouse.previousPosition.y = CORE.Input.Mouse.currentPosition.y;
CORE.Input.Mouse.currentPosition.x = (event->point.x - (platform.window->r.w/2))*2;
CORE.Input.Mouse.currentPosition.y = (event->point.y - (platform.window->r.h/2))*2;
CORE.Input.Mouse.currentPosition.x = (kt">float)event->point.x;
CORE.Input.Mouse.currentPosition.y = (kt">float)event->point.y;
}
else
{
@ -1205,8 +1206,6 @@ void PollInputEvents(void)
}
#endif
}
if (RGFW_disableCursor && platform.window->event.inFocus) RGFW_window_mouseHold(platform.window, RGFW_AREA(0, 0));
//-----------------------------------------------------------------------------
}
@ -1258,6 +1257,16 @@ int InitPlatform(void)
platform.window = RGFW_createWindow(CORE.Window.title, RGFW_RECT(0, 0, CORE.Window.screen.width, CORE.Window.screen.height), flags);
RGFW_area screenSize = RGFW_getScreenSize();
CORE.Window.display.width = screenSize.w;
CORE.Window.display.height = screenSize.h;
/*
I think this is needed by Raylib now ?
If so, rcore_destkop_sdl should be updated too
*/
SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height);
if (CORE.Window.flags & FLAG_VSYNC_HINT) RGFW_window_swapInterval(platform.window, 1);
RGFW_window_makeCurrent(platform.window);

Loading…
Cancel
Save