REVIEWED: Formating to follow raylib conventions
This commit is contained in:
parent
bd8e59f18d
commit
7f8bf2233c
1 changed files with 83 additions and 81 deletions
|
@ -128,7 +128,7 @@ typedef struct {
|
|||
//----------------------------------------------------------------------------------
|
||||
extern CoreData CORE; // Global CORE state context
|
||||
|
||||
static PlatformData platform = { NULL }; // Platform specific
|
||||
static PlatformData platform = { 0 }; // Platform specific
|
||||
|
||||
static bool RGFW_disableCursor = false;
|
||||
|
||||
|
@ -315,7 +315,9 @@ void ToggleBorderlessWindowed(void)
|
|||
|
||||
RGFW_monitor mon = RGFW_window_getMonitor(platform.window);
|
||||
RGFW_window_resize(platform.window, mon.mode.area);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
RGFW_window_setBorder(platform.window, 1);
|
||||
|
||||
CORE.Window.position = CORE.Window.previousPosition;
|
||||
|
@ -340,8 +342,7 @@ void MinimizeWindow(void)
|
|||
// Set window state: not minimized/maximized
|
||||
void RestoreWindow(void)
|
||||
{
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED))
|
||||
RGFW_window_focus(platform.window);
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
|
||||
RGFW_window_restore(platform.window);
|
||||
}
|
||||
|
@ -357,8 +358,7 @@ void SetWindowState(unsigned int flags)
|
|||
}
|
||||
if (flags & FLAG_FULLSCREEN_MODE)
|
||||
{
|
||||
if (!CORE.Window.fullscreen)
|
||||
ToggleFullscreen();
|
||||
if (!CORE.Window.fullscreen) ToggleFullscreen();
|
||||
}
|
||||
if (flags & FLAG_WINDOW_RESIZABLE)
|
||||
{
|
||||
|
@ -432,8 +432,7 @@ void ClearWindowState(unsigned int flags)
|
|||
}
|
||||
if (flags & FLAG_FULLSCREEN_MODE)
|
||||
{
|
||||
if (CORE.Window.fullscreen)
|
||||
ToggleFullscreen();
|
||||
if (CORE.Window.fullscreen) ToggleFullscreen();
|
||||
}
|
||||
if (flags & FLAG_WINDOW_RESIZABLE)
|
||||
{
|
||||
|
@ -446,21 +445,20 @@ void ClearWindowState(unsigned int flags)
|
|||
}
|
||||
if (flags & FLAG_WINDOW_HIDDEN)
|
||||
{
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED))
|
||||
RGFW_window_focus(platform.window);
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
|
||||
RGFW_window_show(platform.window);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_MINIMIZED)
|
||||
{
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED))
|
||||
RGFW_window_focus(platform.window);
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
|
||||
RGFW_window_restore(platform.window);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_MAXIMIZED)
|
||||
{
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED))
|
||||
RGFW_window_focus(platform.window);
|
||||
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);
|
||||
|
||||
RGFW_window_restore(platform.window);
|
||||
}
|
||||
if (flags & FLAG_WINDOW_UNFOCUSED)
|
||||
|
@ -490,8 +488,7 @@ void ClearWindowState(unsigned int flags)
|
|||
}
|
||||
if (flags & FLAG_BORDERLESS_WINDOWED_MODE)
|
||||
{
|
||||
if (CORE.Window.fullscreen)
|
||||
ToggleBorderlessWindowed();
|
||||
if (CORE.Window.fullscreen) ToggleBorderlessWindowed();
|
||||
}
|
||||
if (flags & FLAG_MSAA_4X_HINT)
|
||||
{
|
||||
|
@ -505,7 +502,8 @@ void ClearWindowState(unsigned int flags)
|
|||
|
||||
int RGFW_formatToChannels(int format)
|
||||
{
|
||||
switch (format) {
|
||||
switch (format)
|
||||
{
|
||||
case PIXELFORMAT_UNCOMPRESSED_GRAYSCALE:
|
||||
case PIXELFORMAT_UNCOMPRESSED_R16: // 16 bpp (1 channel - half float)
|
||||
case PIXELFORMAT_UNCOMPRESSED_R32: // 32 bpp (1 channel - float)
|
||||
|
@ -547,32 +545,29 @@ void SetWindowIcon(Image image)
|
|||
// Set icon for window
|
||||
void SetWindowIcons(Image *images, int count)
|
||||
{
|
||||
|
||||
if ((images == NULL) || (count <= 0))
|
||||
{
|
||||
RGFW_window_setIcon(platform.window, NULL, RGFW_AREA(0, 0), 0);
|
||||
} {
|
||||
Image* bigIcon = NULL;
|
||||
Image* smallIcon = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
Image *bigIcon = NULL;
|
||||
Image *smallIcon = NULL;
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
if (bigIcon == NULL || (images[i].width > bigIcon->width && images[i].height > bigIcon->height))
|
||||
bigIcon = &images[i];
|
||||
if (smallIcon == NULL || (images[i].width < smallIcon->width && images[i].height > smallIcon->height))
|
||||
smallIcon = &images[i];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if ((bigIcon == NULL) || ((images[i].width > bigIcon->width) && (images[i].height > bigIcon->height))) bigIcon = &images[i];
|
||||
if ((smallIcon == NULL) || ((images[i].width < smallIcon->width) && (images[i].height > smallIcon->height))) smallIcon = &images[i];
|
||||
}
|
||||
|
||||
if (smallIcon != NULL)
|
||||
RGFW_window_setIconEx(platform.window, smallIcon->data, RGFW_AREA(smallIcon->width, smallIcon->height), RGFW_formatToChannels(smallIcon->format), RGFW_iconWindow);
|
||||
if (bigIcon != NULL)
|
||||
RGFW_window_setIconEx(platform.window, bigIcon->data, RGFW_AREA(bigIcon->width, bigIcon->height), RGFW_formatToChannels(bigIcon->format), RGFW_iconTaskbar);
|
||||
if (smallIcon != NULL) RGFW_window_setIconEx(platform.window, smallIcon->data, RGFW_AREA(smallIcon->width, smallIcon->height), RGFW_formatToChannels(smallIcon->format), RGFW_iconWindow);
|
||||
if (bigIcon != NULL) RGFW_window_setIconEx(platform.window, bigIcon->data, RGFW_AREA(bigIcon->width, bigIcon->height), RGFW_formatToChannels(bigIcon->format), RGFW_iconTaskbar);
|
||||
}
|
||||
}
|
||||
|
||||
// Set title for window
|
||||
void SetWindowTitle(const char *title)
|
||||
{
|
||||
|
||||
RGFW_window_setName(platform.window, (char *)title);
|
||||
CORE.Window.title = title;
|
||||
}
|
||||
|
@ -661,9 +656,10 @@ int GetMonitorCount(void)
|
|||
int GetCurrentMonitor(void)
|
||||
{
|
||||
RGFW_monitor *mons = RGFW_getMonitors();
|
||||
RGFW_monitor mon;
|
||||
RGFW_monitor mon = { 0 };
|
||||
|
||||
if (platform.window) mon = RGFW_window_getMonitor(platform.window);
|
||||
else mon = RGFW_getPrimaryMonitor();
|
||||
else mon = RGFW_getPrimaryMonitor();
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
|
@ -739,11 +735,12 @@ Vector2 GetWindowPosition(void)
|
|||
// Get window scale DPI factor for current monitor
|
||||
Vector2 GetWindowScaleDPI(void)
|
||||
{
|
||||
RGFW_monitor monitor;
|
||||
if (platform.window) monitor = RGFW_window_getMonitor(platform.window);
|
||||
else monitor = RGFW_getPrimaryMonitor();
|
||||
RGFW_monitor monitor = { 0 };
|
||||
|
||||
return (Vector2){monitor.scaleX, monitor.scaleX};
|
||||
if (platform.window) monitor = RGFW_window_getMonitor(platform.window);
|
||||
else monitor = RGFW_getPrimaryMonitor();
|
||||
|
||||
return (Vector2){ monitor.scaleX, monitor.scaleX };
|
||||
}
|
||||
|
||||
// Set clipboard text content
|
||||
|
@ -759,7 +756,6 @@ const char *GetClipboardText(void)
|
|||
return RGFW_readClipboard(NULL);
|
||||
}
|
||||
|
||||
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_CLIPBOARD_IMPLEMENTATION
|
||||
|
@ -893,6 +889,7 @@ void SetMouseCursor(int cursor)
|
|||
const char *GetKeyName(int key)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetKeyName() unsupported on target platform");
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -1043,17 +1040,20 @@ void PollInputEvents(void)
|
|||
CORE.Window.resizedLastFrame = true;
|
||||
} break;
|
||||
case RGFW_windowMaximized:
|
||||
{
|
||||
CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED; // The window was maximized
|
||||
break;
|
||||
} break;
|
||||
case RGFW_windowMinimized:
|
||||
{
|
||||
CORE.Window.flags |= FLAG_WINDOW_MINIMIZED; // The window was iconified
|
||||
break;
|
||||
} break;
|
||||
case RGFW_windowRestored:
|
||||
{
|
||||
if (RGFW_window_isMaximized(platform.window))
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_MAXIMIZED; // The window was restored
|
||||
if (RGFW_window_isMinimized(platform.window))
|
||||
CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; // The window was restored
|
||||
break;
|
||||
} break;
|
||||
case RGFW_windowMoved:
|
||||
{
|
||||
CORE.Window.position.x = platform.window->r.x;
|
||||
|
@ -1104,7 +1104,8 @@ void PollInputEvents(void)
|
|||
{
|
||||
CORE.Input.Mouse.currentWheelMove.y = event->scroll;
|
||||
break;
|
||||
} else CORE.Input.Mouse.currentWheelMove.y = 0;
|
||||
}
|
||||
else CORE.Input.Mouse.currentWheelMove.y = 0;
|
||||
|
||||
int btn = event->button;
|
||||
if (btn == RGFW_mouseLeft) btn = 1;
|
||||
|
@ -1122,7 +1123,8 @@ void PollInputEvents(void)
|
|||
{
|
||||
CORE.Input.Mouse.currentWheelMove.y = event->scroll;
|
||||
break;
|
||||
} else CORE.Input.Mouse.currentWheelMove.y = 0;
|
||||
}
|
||||
else CORE.Input.Mouse.currentWheelMove.y = 0;
|
||||
|
||||
int btn = event->button;
|
||||
if (btn == RGFW_mouseLeft) btn = 1;
|
||||
|
@ -1152,16 +1154,18 @@ void PollInputEvents(void)
|
|||
touchAction = 2;
|
||||
} break;
|
||||
case RGFW_gamepadConnected:
|
||||
{
|
||||
CORE.Input.Gamepad.ready[platform.window->event.gamepad] = true;
|
||||
CORE.Input.Gamepad.axisCount[platform.window->event.gamepad] = platform.window->event.axisesCount;
|
||||
CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
|
||||
CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
|
||||
|
||||
strcpy(CORE.Input.Gamepad.name[platform.window->event.gamepad], RGFW_getGamepadName(platform.window, platform.window->event.gamepad));
|
||||
break;
|
||||
} break;
|
||||
case RGFW_gamepadDisconnected:
|
||||
{
|
||||
CORE.Input.Gamepad.ready[platform.window->event.gamepad] = false;
|
||||
break;
|
||||
} break;
|
||||
case RGFW_gamepadButtonPressed:
|
||||
{
|
||||
int button = RGFW_gpConvTable[event->button];
|
||||
|
@ -1182,8 +1186,8 @@ void PollInputEvents(void)
|
|||
case RGFW_gamepadAxisMove:
|
||||
{
|
||||
int axis = -1;
|
||||
|
||||
float value = 0;
|
||||
|
||||
switch(event->whichAxis)
|
||||
{
|
||||
case 0:
|
||||
|
@ -1200,6 +1204,7 @@ void PollInputEvents(void)
|
|||
case 3:
|
||||
{
|
||||
if (axis == -1) axis = GAMEPAD_AXIS_RIGHT_TRIGGER;
|
||||
|
||||
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
|
||||
int pressed = (value > 0.1f);
|
||||
CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = pressed;
|
||||
|
@ -1276,7 +1281,6 @@ int InitPlatform(void)
|
|||
if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) flags |= RGFW_windowHide;
|
||||
if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0) flags |= RGFW_windowMaximize;
|
||||
|
||||
|
||||
// NOTE: Some OpenGL context attributes must be set before window creation
|
||||
// Check selection OpenGL version
|
||||
if (rlGetVersion() == RL_OPENGL_21)
|
||||
|
@ -1365,10 +1369,8 @@ int InitPlatform(void)
|
|||
//----------------------------------------------------------------------------
|
||||
|
||||
#if defined(RGFW_WAYLAND)
|
||||
if (RGFW_useWaylandBool)
|
||||
TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (RGFW - Wayland): Initialized successfully");
|
||||
else
|
||||
TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (RGFW - X11 (fallback)): Initialized successfully");
|
||||
if (RGFW_useWaylandBool) TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (RGFW - Wayland): Initialized successfully");
|
||||
else TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (RGFW - X11 (fallback)): Initialized successfully");
|
||||
#elif defined(RGFW_X11)
|
||||
#if defined(__APPLE__)
|
||||
TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (RGFW - X11 (MacOS)): Initialized successfully");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue