Merge branch 'raysan5:master' into embedded-optimizations-pico
This commit is contained in:
commit
2e4436edda
18 changed files with 2897 additions and 2603 deletions
|
|
@ -103,7 +103,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
|||
| [Raylib.lean](https://github.com/KislyjKisel/Raylib.lean) | **5.5-dev** | [Lean4](https://lean-lang.org) | BSD-3-Clause |
|
||||
| [raylib-cobol](https://codeberg.org/glowiak/raylib-cobol) | **auto** | [COBOL](https://gnucobol.sourceforge.io) | Public domain |
|
||||
| [raylib-apl](https://github.com/Brian-ED/raylib-apl) | **5.0** | [Dyalog APL](https://www.dyalog.com/) | MIT |
|
||||
| [raylib-jai](https://github.com/ahmedqarmout2/raylib-jai) | **5.5** | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | MIT |
|
||||
| [raylib-jai](https://github.com/ahmedqarmout2/raylib-jai) | **6.0** | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | MIT |
|
||||
| [fnl-raylib](https://github.com/0riginaln0/fnl-raylib) | **5.5** | [Fennel](https://fennel-lang.org/) | MIT |
|
||||
| [Rayua](https://github.com/uiua-lang/rayua) | **5.5** | [Uiua](https://www.uiua.org/) | **???** |
|
||||
| [Target](https://github.com/FinnDemonCat/Target/tree/main/libs/raylib) | **5.5** | [Dart](https://dart.dev/) | Apache-2.0 license |
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.22)
|
||||
#this change avoid the warning that appear when we include raylib using Cmake fatch content
|
||||
project(raylib)
|
||||
|
||||
# Avoid excessive expansion of variables in conditionals. In particular, if
|
||||
|
|
|
|||
4242
src/external/RGFW/RGFW.h
vendored
4242
src/external/RGFW/RGFW.h
vendored
File diff suppressed because it is too large
Load diff
|
|
@ -1078,7 +1078,7 @@ Image GetClipboardImage(void)
|
|||
XID window = glfwGetX11Window(platform.handle);
|
||||
|
||||
// Lazy-load X11 atoms
|
||||
if(clipboard == 0)
|
||||
if (clipboard == 0)
|
||||
{
|
||||
clipboard = XInternAtom(display, "CLIPBOARD", False);
|
||||
targetType = XInternAtom(display, "image/png", False);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
void ShowCursor(void);
|
||||
void CloseWindow(void);
|
||||
double get_time_seconds(void);
|
||||
double GetTimeSeconds(void);
|
||||
|
||||
#if defined(__unix__) || defined(__linux__)
|
||||
#define _XTYPEDEF_FONT
|
||||
|
|
@ -310,113 +310,113 @@ static PlatformData platform = { 0 }; // Platform specific
|
|||
|
||||
static const unsigned short RGFW_keyConvertTable[] = {
|
||||
[RGFW_keyNULL] = KEY_NULL,
|
||||
[RGFW_apostrophe] = KEY_APOSTROPHE,
|
||||
[RGFW_comma] = KEY_COMMA,
|
||||
[RGFW_minus] = KEY_MINUS,
|
||||
[RGFW_period] = KEY_PERIOD,
|
||||
[RGFW_slash] = KEY_SLASH,
|
||||
[RGFW_0] = KEY_ZERO,
|
||||
[RGFW_1] = KEY_ONE,
|
||||
[RGFW_2] = KEY_TWO,
|
||||
[RGFW_3] = KEY_THREE,
|
||||
[RGFW_4] = KEY_FOUR,
|
||||
[RGFW_5] = KEY_FIVE,
|
||||
[RGFW_6] = KEY_SIX,
|
||||
[RGFW_7] = KEY_SEVEN,
|
||||
[RGFW_8] = KEY_EIGHT,
|
||||
[RGFW_9] = KEY_NINE,
|
||||
[RGFW_semicolon] = KEY_SEMICOLON,
|
||||
[RGFW_equals] = KEY_EQUAL,
|
||||
[RGFW_a] = KEY_A,
|
||||
[RGFW_b] = KEY_B,
|
||||
[RGFW_c] = KEY_C,
|
||||
[RGFW_d] = KEY_D,
|
||||
[RGFW_e] = KEY_E,
|
||||
[RGFW_f] = KEY_F,
|
||||
[RGFW_g] = KEY_G,
|
||||
[RGFW_h] = KEY_H,
|
||||
[RGFW_i] = KEY_I,
|
||||
[RGFW_j] = KEY_J,
|
||||
[RGFW_k] = KEY_K,
|
||||
[RGFW_l] = KEY_L,
|
||||
[RGFW_m] = KEY_M,
|
||||
[RGFW_n] = KEY_N,
|
||||
[RGFW_o] = KEY_O,
|
||||
[RGFW_p] = KEY_P,
|
||||
[RGFW_q] = KEY_Q,
|
||||
[RGFW_r] = KEY_R,
|
||||
[RGFW_s] = KEY_S,
|
||||
[RGFW_t] = KEY_T,
|
||||
[RGFW_u] = KEY_U,
|
||||
[RGFW_v] = KEY_V,
|
||||
[RGFW_w] = KEY_W,
|
||||
[RGFW_x] = KEY_X,
|
||||
[RGFW_y] = KEY_Y,
|
||||
[RGFW_z] = KEY_Z,
|
||||
[RGFW_bracket] = KEY_LEFT_BRACKET,
|
||||
[RGFW_backSlash] = KEY_BACKSLASH,
|
||||
[RGFW_closeBracket] = KEY_RIGHT_BRACKET,
|
||||
[RGFW_backtick] = KEY_GRAVE,
|
||||
[RGFW_space] = KEY_SPACE,
|
||||
[RGFW_escape] = KEY_ESCAPE,
|
||||
[RGFW_return] = KEY_ENTER,
|
||||
[RGFW_tab] = KEY_TAB,
|
||||
[RGFW_backSpace] = KEY_BACKSPACE,
|
||||
[RGFW_insert] = KEY_INSERT,
|
||||
[RGFW_delete] = KEY_DELETE,
|
||||
[RGFW_right] = KEY_RIGHT,
|
||||
[RGFW_left] = KEY_LEFT,
|
||||
[RGFW_down] = KEY_DOWN,
|
||||
[RGFW_up] = KEY_UP,
|
||||
[RGFW_pageUp] = KEY_PAGE_UP,
|
||||
[RGFW_pageDown] = KEY_PAGE_DOWN,
|
||||
[RGFW_home] = KEY_HOME,
|
||||
[RGFW_end] = KEY_END,
|
||||
[RGFW_capsLock] = KEY_CAPS_LOCK,
|
||||
[RGFW_scrollLock] = KEY_SCROLL_LOCK,
|
||||
[RGFW_numLock] = KEY_NUM_LOCK,
|
||||
[RGFW_printScreen] = KEY_PRINT_SCREEN,
|
||||
[RGFW_pause] = KEY_PAUSE,
|
||||
[RGFW_F1] = KEY_F1,
|
||||
[RGFW_F2] = KEY_F2,
|
||||
[RGFW_F3] = KEY_F3,
|
||||
[RGFW_F4] = KEY_F4,
|
||||
[RGFW_F5] = KEY_F5,
|
||||
[RGFW_F6] = KEY_F6,
|
||||
[RGFW_F7] = KEY_F7,
|
||||
[RGFW_F8] = KEY_F8,
|
||||
[RGFW_F9] = KEY_F9,
|
||||
[RGFW_F10] = KEY_F10,
|
||||
[RGFW_F11] = KEY_F11,
|
||||
[RGFW_F12] = KEY_F12,
|
||||
[RGFW_shiftL] = KEY_LEFT_SHIFT,
|
||||
[RGFW_controlL] = KEY_LEFT_CONTROL,
|
||||
[RGFW_altL] = KEY_LEFT_ALT,
|
||||
[RGFW_superL] = KEY_LEFT_SUPER,
|
||||
[RGFW_keyApostrophe] = KEY_APOSTROPHE,
|
||||
[RGFW_keyComma] = KEY_COMMA,
|
||||
[RGFW_keyMinus] = KEY_MINUS,
|
||||
[RGFW_keyPeriod] = KEY_PERIOD,
|
||||
[RGFW_keySlash] = KEY_SLASH,
|
||||
[RGFW_key0] = KEY_ZERO,
|
||||
[RGFW_key1] = KEY_ONE,
|
||||
[RGFW_key2] = KEY_TWO,
|
||||
[RGFW_key3] = KEY_THREE,
|
||||
[RGFW_key4] = KEY_FOUR,
|
||||
[RGFW_key5] = KEY_FIVE,
|
||||
[RGFW_key6] = KEY_SIX,
|
||||
[RGFW_key7] = KEY_SEVEN,
|
||||
[RGFW_key8] = KEY_EIGHT,
|
||||
[RGFW_key9] = KEY_NINE,
|
||||
[RGFW_keySemicolon] = KEY_SEMICOLON,
|
||||
[RGFW_keyEquals] = KEY_EQUAL,
|
||||
[RGFW_keyA] = KEY_A,
|
||||
[RGFW_keyB] = KEY_B,
|
||||
[RGFW_keyC] = KEY_C,
|
||||
[RGFW_keyD] = KEY_D,
|
||||
[RGFW_keyE] = KEY_E,
|
||||
[RGFW_keyF] = KEY_F,
|
||||
[RGFW_keyG] = KEY_G,
|
||||
[RGFW_keyH] = KEY_H,
|
||||
[RGFW_keyI] = KEY_I,
|
||||
[RGFW_keyJ] = KEY_J,
|
||||
[RGFW_keyK] = KEY_K,
|
||||
[RGFW_keyL] = KEY_L,
|
||||
[RGFW_keyM] = KEY_M,
|
||||
[RGFW_keyN] = KEY_N,
|
||||
[RGFW_keyO] = KEY_O,
|
||||
[RGFW_keyP] = KEY_P,
|
||||
[RGFW_keyQ] = KEY_Q,
|
||||
[RGFW_keyR] = KEY_R,
|
||||
[RGFW_keyS] = KEY_S,
|
||||
[RGFW_keyT] = KEY_T,
|
||||
[RGFW_keyU] = KEY_U,
|
||||
[RGFW_keyV] = KEY_V,
|
||||
[RGFW_keyW] = KEY_W,
|
||||
[RGFW_keyX] = KEY_X,
|
||||
[RGFW_keyY] = KEY_Y,
|
||||
[RGFW_keyZ] = KEY_Z,
|
||||
[RGFW_keyBracket] = KEY_LEFT_BRACKET,
|
||||
[RGFW_keyBackSlash] = KEY_BACKSLASH,
|
||||
[RGFW_keyCloseBracket] = KEY_RIGHT_BRACKET,
|
||||
[RGFW_keyBacktick] = KEY_GRAVE,
|
||||
[RGFW_keySpace] = KEY_SPACE,
|
||||
[RGFW_keyEscape] = KEY_ESCAPE,
|
||||
[RGFW_keyReturn] = KEY_ENTER,
|
||||
[RGFW_keyTab] = KEY_TAB,
|
||||
[RGFW_keyBackSpace] = KEY_BACKSPACE,
|
||||
[RGFW_keyInsert] = KEY_INSERT,
|
||||
[RGFW_keyDelete] = KEY_DELETE,
|
||||
[RGFW_keyRight] = KEY_RIGHT,
|
||||
[RGFW_keyLeft] = KEY_LEFT,
|
||||
[RGFW_keyDown] = KEY_DOWN,
|
||||
[RGFW_keyUp] = KEY_UP,
|
||||
[RGFW_keyPageUp] = KEY_PAGE_UP,
|
||||
[RGFW_keyPageDown] = KEY_PAGE_DOWN,
|
||||
[RGFW_keyHome] = KEY_HOME,
|
||||
[RGFW_keyEnd] = KEY_END,
|
||||
[RGFW_keyCapsLock] = KEY_CAPS_LOCK,
|
||||
[RGFW_keyScrollLock] = KEY_SCROLL_LOCK,
|
||||
[RGFW_keyNumLock] = KEY_NUM_LOCK,
|
||||
[RGFW_keyPrintScreen] = KEY_PRINT_SCREEN,
|
||||
[RGFW_keyPause] = KEY_PAUSE,
|
||||
[RGFW_keyF1] = KEY_F1,
|
||||
[RGFW_keyF2] = KEY_F2,
|
||||
[RGFW_keyF3] = KEY_F3,
|
||||
[RGFW_keyF4] = KEY_F4,
|
||||
[RGFW_keyF5] = KEY_F5,
|
||||
[RGFW_keyF6] = KEY_F6,
|
||||
[RGFW_keyF7] = KEY_F7,
|
||||
[RGFW_keyF8] = KEY_F8,
|
||||
[RGFW_keyF9] = KEY_F9,
|
||||
[RGFW_keyF10] = KEY_F10,
|
||||
[RGFW_keyF11] = KEY_F11,
|
||||
[RGFW_keyF12] = KEY_F12,
|
||||
[RGFW_keyShiftL] = KEY_LEFT_SHIFT,
|
||||
[RGFW_keyControlL] = KEY_LEFT_CONTROL,
|
||||
[RGFW_keyAltL] = KEY_LEFT_ALT,
|
||||
[RGFW_keySuperL] = KEY_LEFT_SUPER,
|
||||
// #ifndef RGFW_MACOS
|
||||
[RGFW_shiftR] = KEY_RIGHT_SHIFT,
|
||||
[RGFW_controlR] = KEY_RIGHT_CONTROL,
|
||||
[RGFW_altR] = KEY_RIGHT_ALT,
|
||||
[RGFW_superR] = KEY_RIGHT_SUPER,
|
||||
[RGFW_keyShiftR] = KEY_RIGHT_SHIFT,
|
||||
[RGFW_keyControlR] = KEY_RIGHT_CONTROL,
|
||||
[RGFW_keyAltR] = KEY_RIGHT_ALT,
|
||||
[RGFW_keySuperR] = KEY_RIGHT_SUPER,
|
||||
// #endif
|
||||
[RGFW_menu] = KEY_KB_MENU,
|
||||
[RGFW_kp0] = KEY_KP_0,
|
||||
[RGFW_kp1] = KEY_KP_1,
|
||||
[RGFW_kp2] = KEY_KP_2,
|
||||
[RGFW_kp3] = KEY_KP_3,
|
||||
[RGFW_kp4] = KEY_KP_4,
|
||||
[RGFW_kp5] = KEY_KP_5,
|
||||
[RGFW_kp6] = KEY_KP_6,
|
||||
[RGFW_kp7] = KEY_KP_7,
|
||||
[RGFW_kp8] = KEY_KP_8,
|
||||
[RGFW_kp9] = KEY_KP_9,
|
||||
[RGFW_kpPeriod] = KEY_KP_DECIMAL,
|
||||
[RGFW_kpSlash] = KEY_KP_DIVIDE,
|
||||
[RGFW_kpMultiply] = KEY_KP_MULTIPLY,
|
||||
[RGFW_kpMinus] = KEY_KP_SUBTRACT,
|
||||
[RGFW_kpPlus] = KEY_KP_ADD,
|
||||
[RGFW_kpReturn] = KEY_KP_ENTER,
|
||||
[RGFW_kpEqual] = KEY_KP_EQUAL,
|
||||
[RGFW_keyMenu] = KEY_KB_MENU,
|
||||
[RGFW_keyPad0] = KEY_KP_0,
|
||||
[RGFW_keyPad1] = KEY_KP_1,
|
||||
[RGFW_keyPad2] = KEY_KP_2,
|
||||
[RGFW_keyPad3] = KEY_KP_3,
|
||||
[RGFW_keyPad4] = KEY_KP_4,
|
||||
[RGFW_keyPad5] = KEY_KP_5,
|
||||
[RGFW_keyPad6] = KEY_KP_6,
|
||||
[RGFW_keyPad7] = KEY_KP_7,
|
||||
[RGFW_keyPad8] = KEY_KP_8,
|
||||
[RGFW_keyPad9] = KEY_KP_9,
|
||||
[RGFW_keyPadPeriod] = KEY_KP_DECIMAL,
|
||||
[RGFW_keyPadSlash] = KEY_KP_DIVIDE,
|
||||
[RGFW_keyPadMultiply] = KEY_KP_MULTIPLY,
|
||||
[RGFW_keyPadMinus] = KEY_KP_SUBTRACT,
|
||||
[RGFW_keyPadPlus] = KEY_KP_ADD,
|
||||
[RGFW_keyPadReturn] = KEY_KP_ENTER,
|
||||
[RGFW_keyPadEqual] = KEY_KP_EQUAL,
|
||||
};
|
||||
|
||||
static int mg_buttonConvertTable[] = {
|
||||
|
|
@ -456,14 +456,299 @@ static int mg_axisConvertTable[] = {
|
|||
[MG_AXIS_HAT_DPAD_DOWN] = -1,
|
||||
};
|
||||
|
||||
static KeyboardKey ConvertScancodeToKey(u32 keycode);
|
||||
void RemapMouseToTouch(int touchAction);
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// RGFW Callbacks (instead of the older polling)
|
||||
// ---------------------------------------------------------------------------------
|
||||
static void RGFW_cb_mousenotifyfunc(const RGFW_event *e)
|
||||
{
|
||||
if (e->common.win != platform.window) return;
|
||||
|
||||
CORE.Input.Mouse.cursorOnScreen = e->mouse.inWindow;
|
||||
}
|
||||
/*
|
||||
static void RGFW_cb_windowclosefunc(const RGFW_event *e)
|
||||
{
|
||||
if (e->common.win != platform.window) return;
|
||||
|
||||
// Don't want to close here, raylib handles it
|
||||
//RGFW_window_setShouldClose(platform.window, true);
|
||||
}
|
||||
*/
|
||||
static void RGFW_cb_dropfunc(const RGFW_event *e)
|
||||
{
|
||||
if (e->common.win != platform.window) return;
|
||||
|
||||
if (CORE.Window.dropFileCount == 0)
|
||||
{
|
||||
CORE.Window.dropFilepaths = (char **)RL_CALLOC(1024, sizeof(char *));
|
||||
|
||||
CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
|
||||
strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], e->drop.value->data);
|
||||
|
||||
CORE.Window.dropFileCount++;
|
||||
}
|
||||
else if (CORE.Window.dropFileCount < 1024)
|
||||
{
|
||||
CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
|
||||
strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], e->drop.value->data);
|
||||
|
||||
CORE.Window.dropFileCount++;
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "FILE: Maximum drag and drop files at once is limited to 1024 files!");
|
||||
}
|
||||
static void RGFW_cb_windowresizefunc(const RGFW_event *e)
|
||||
{
|
||||
if (e->common.win != platform.window) return;
|
||||
|
||||
CORE.Window.resizedLastFrame = true;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||
{
|
||||
RGFW_monitor *currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
SetupViewport(platform.window->w*currentMonitor->pixelRatio, platform.window->h*currentMonitor->pixelRatio);
|
||||
CORE.Window.screenScale = MatrixScale(currentMonitor->pixelRatio, currentMonitor->pixelRatio, 1.0f);
|
||||
|
||||
CORE.Window.screen.width = platform.window->w;
|
||||
CORE.Window.screen.height = platform.window->h;
|
||||
CORE.Window.render.width = CORE.Window.screen.width*currentMonitor->pixelRatio;
|
||||
CORE.Window.render.height = CORE.Window.screen.height*currentMonitor->pixelRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetupViewport(platform.window->w, platform.window->h);
|
||||
CORE.Window.screen.width = platform.window->w;
|
||||
CORE.Window.screen.height = platform.window->h;
|
||||
CORE.Window.render.width = CORE.Window.screen.width;
|
||||
CORE.Window.render.height = CORE.Window.screen.height;
|
||||
}
|
||||
|
||||
CORE.Window.currentFbo.width = CORE.Window.render.width;
|
||||
CORE.Window.currentFbo.height = CORE.Window.render.height;
|
||||
#elif defined(PLATFORM_WEB_RGFW)
|
||||
// do nothing but prevent other behavior
|
||||
#else
|
||||
SetupViewport(platform.window->w, platform.window->h);
|
||||
|
||||
// Consider content scaling if required
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||
{
|
||||
Vector2 scaleDpi = GetWindowScaleDPI();
|
||||
CORE.Window.screen.width = (int)(platform.window->w/scaleDpi.x);
|
||||
CORE.Window.screen.height = (int)(platform.window->h/scaleDpi.y);
|
||||
CORE.Window.screenScale = MatrixScale(scaleDpi.x, scaleDpi.y, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
CORE.Window.screen.width = platform.window->w;
|
||||
CORE.Window.screen.height = platform.window->h;
|
||||
}
|
||||
|
||||
CORE.Window.currentFbo.width = CORE.Window.screen.width;
|
||||
CORE.Window.currentFbo.height = CORE.Window.screen.height;
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
#if defined(__APPLE__)
|
||||
RGFW_monitor *currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
CORE.Window.screenScale = MatrixScale(currentMonitor->pixelRatio, currentMonitor->pixelRatio, 1.0f);
|
||||
SetupViewport(platform.window->w*currentMonitor->pixelRatio, platform.window->h*currentMonitor->pixelRatio);
|
||||
|
||||
CORE.Window.render.width = CORE.Window.screen.width*currentMonitor->pixelRatio;
|
||||
CORE.Window.render.height = CORE.Window.screen.height*currentMonitor->pixelRatio;
|
||||
CORE.Window.currentFbo.width = CORE.Window.render.width;
|
||||
CORE.Window.currentFbo.height = CORE.Window.render.height;
|
||||
#endif
|
||||
platform.surfaceWidth = CORE.Window.currentFbo.width;
|
||||
platform.surfaceHeight = CORE.Window.currentFbo.height;
|
||||
|
||||
// in software mode we dont have the viewport so we need to reverse the highdpi changes
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||
{
|
||||
Vector2 scaleDpi = GetWindowScaleDPI();
|
||||
platform.surfaceWidth *= scaleDpi.x;
|
||||
platform.surfaceHeight *= scaleDpi.y;
|
||||
}
|
||||
|
||||
if (platform.surfacePixels != NULL)
|
||||
{
|
||||
RL_FREE(platform.surfacePixels);
|
||||
platform.surfacePixels = RL_MALLOC(platform.surfaceWidth*platform.surfaceHeight*4);
|
||||
}
|
||||
|
||||
if (platform.surface != NULL)
|
||||
{
|
||||
RGFW_surface_free(platform.surface);
|
||||
platform.surface = RGFW_window_createSurface(platform.window, platform.surfacePixels, platform.surfaceWidth, platform.surfaceHeight, RGFW_formatBGRA8);
|
||||
swResize(platform.surfaceWidth, platform.surfaceHeight);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
static void RGFW_cb_windowmaximizefunc(const RGFW_event *e)
|
||||
{
|
||||
if (e->common.win != platform.window) return;
|
||||
|
||||
FLAG_SET(CORE.Window.flags, FLAG_WINDOW_MAXIMIZED); // The window was maximized
|
||||
}
|
||||
static void RGFW_cb_windowminimizefunc(const RGFW_event *e)
|
||||
{
|
||||
if (e->common.win != platform.window) return;
|
||||
|
||||
FLAG_SET(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // The window was iconified
|
||||
}
|
||||
static void RGFW_cb_windowrestorefunc(const RGFW_event *e)
|
||||
{
|
||||
if (e->common.win != platform.window) return;
|
||||
|
||||
if (RGFW_window_isMaximized(platform.window))
|
||||
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_MAXIMIZED); // The window was restored
|
||||
if (RGFW_window_isMinimized(platform.window))
|
||||
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // The window was restored
|
||||
}
|
||||
static void RGFW_cb_windowmovefunc(const RGFW_event *e)
|
||||
{
|
||||
if (e->common.win != platform.window) return;
|
||||
|
||||
CORE.Window.position.x = platform.window->x;
|
||||
CORE.Window.position.y = platform.window->x;
|
||||
}
|
||||
static void RGFW_cb_keycharfunc(const RGFW_event *e)
|
||||
{
|
||||
if (e->common.win != platform.window) return;
|
||||
|
||||
// NOTE: event.text.text data comes an UTF-8 text sequence but registering codepoints (int)
|
||||
// Check if there is space available in the queue
|
||||
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
|
||||
{
|
||||
// Add character (codepoint) to the queue
|
||||
CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = e->keyChar.value;
|
||||
CORE.Input.Keyboard.charPressedQueueCount++;
|
||||
}
|
||||
}
|
||||
static void RGFW_cb_scrollfunc(const RGFW_event *e)
|
||||
{
|
||||
if (e->common.win != platform.window) return;
|
||||
|
||||
CORE.Input.Mouse.currentWheelMove.x += e->delta.x;
|
||||
CORE.Input.Mouse.currentWheelMove.y += e->delta.y;
|
||||
}
|
||||
static void RGFW_cb_mousebuttonfunc(const RGFW_event *e)
|
||||
{
|
||||
if (e->common.win != platform.window) return;
|
||||
|
||||
int btn = e->button.value;
|
||||
if (btn == RGFW_mouseLeft) btn = 1;
|
||||
else if (btn == RGFW_mouseRight) btn = 2;
|
||||
else if (btn == RGFW_mouseMiddle) btn = 3;
|
||||
|
||||
// pressed or released
|
||||
if (e->button.state){
|
||||
CORE.Input.Mouse.currentButtonState[btn - 1] = 1;
|
||||
CORE.Input.Touch.currentTouchState[btn - 1] = 1;
|
||||
|
||||
// simulate touch with the mouse
|
||||
RemapMouseToTouch(1);
|
||||
} else
|
||||
{
|
||||
CORE.Input.Mouse.currentButtonState[btn - 1] = 0;
|
||||
CORE.Input.Touch.currentTouchState[btn - 1] = 0;
|
||||
|
||||
// simulate touch with the mouse
|
||||
RemapMouseToTouch(0);
|
||||
}
|
||||
}
|
||||
static void RGFW_cb_mouserawmotionfunc(const RGFW_event *e)
|
||||
{
|
||||
if (!RGFW_window_isRawMouseMode(platform.window))
|
||||
{
|
||||
// if not raw, use non-raw motion. this prevents the doubled events
|
||||
return;
|
||||
}
|
||||
|
||||
float mouseX = 0.0f;
|
||||
float mouseY = 0.0f;
|
||||
mouseX = e->delta.x;
|
||||
mouseY = e->delta.y;
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
double canvasWidth = 0.0;
|
||||
double canvasHeight = 0.0;
|
||||
emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);
|
||||
mouseX *= ((float)GetScreenWidth()/(float)canvasWidth);
|
||||
mouseY *= ((float)GetScreenHeight()/(float)canvasHeight);
|
||||
#endif
|
||||
|
||||
CORE.Input.Mouse.currentPosition.x += mouseX;
|
||||
CORE.Input.Mouse.currentPosition.y += mouseY;
|
||||
|
||||
// simulate touch with the mouse
|
||||
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
|
||||
RemapMouseToTouch(2);
|
||||
}
|
||||
static void RGFW_cb_mousemotionfunc(const RGFW_event *e)
|
||||
{
|
||||
if (RGFW_window_isRawMouseMode(platform.window))
|
||||
{
|
||||
// if raw, use raw motion. this prevents the doubled events
|
||||
return;
|
||||
}
|
||||
|
||||
float mouseX = 0.0f;
|
||||
float mouseY = 0.0f;
|
||||
mouseX = e->mouse.x;
|
||||
mouseY = e->mouse.y;
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
double canvasWidth = 0.0;
|
||||
double canvasHeight = 0.0;
|
||||
emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);
|
||||
mouseX *= ((float)GetScreenWidth()/(float)canvasWidth);
|
||||
mouseY *= ((float)GetScreenHeight()/(float)canvasHeight);
|
||||
#endif
|
||||
|
||||
CORE.Input.Mouse.currentPosition.x = mouseX;
|
||||
CORE.Input.Mouse.currentPosition.y = mouseY;
|
||||
|
||||
// simulate touch with the mouse
|
||||
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
|
||||
RemapMouseToTouch(2);
|
||||
}
|
||||
static void RGFW_cb_keyfunc(const RGFW_keyEvent* e)
|
||||
{
|
||||
if (e->win != platform.window) return;
|
||||
|
||||
KeyboardKey key = ConvertScancodeToKey(e->value);
|
||||
if (key == KEY_NULL) return;
|
||||
|
||||
// pressed or released
|
||||
if (e->state)
|
||||
{
|
||||
// If key was up, add it to the key pressed queue
|
||||
if ((CORE.Input.Keyboard.currentKeyState[key] == 0) && (CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE))
|
||||
{
|
||||
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key;
|
||||
CORE.Input.Keyboard.keyPressedQueueCount++;
|
||||
}
|
||||
|
||||
CORE.Input.Keyboard.currentKeyState[key] = 1;
|
||||
|
||||
if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey]) RGFW_window_setShouldClose(platform.window, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CORE.Input.Keyboard.currentKeyState[key] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
int InitPlatform(void); // Initialize platform (graphics, inputs and more)
|
||||
bool InitGraphicsDevice(void); // Initialize graphics device
|
||||
|
||||
static KeyboardKey ConvertScancodeToKey(u32 keycode);
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
@ -476,10 +761,9 @@ static KeyboardKey ConvertScancodeToKey(u32 keycode);
|
|||
// Check if application should close
|
||||
bool WindowShouldClose(void)
|
||||
{
|
||||
if (CORE.Window.shouldClose == false)
|
||||
CORE.Window.shouldClose = RGFW_window_shouldClose(platform.window);
|
||||
if (CORE.Window.shouldClose == false) CORE.Window.shouldClose = RGFW_window_shouldClose(platform.window);
|
||||
if (CORE.Window.ready) return CORE.Window.shouldClose;
|
||||
else return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Toggle fullscreen mode
|
||||
|
|
@ -494,7 +778,7 @@ void ToggleFullscreen(void)
|
|||
CORE.Window.previousPosition.y = currentPosition.y;
|
||||
CORE.Window.previousScreen = CORE.Window.screen;
|
||||
|
||||
RGFW_monitor* currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
RGFW_monitor *currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
RGFW_monitor_scaleToWindow(currentMonitor, platform.window);
|
||||
RGFW_window_setFullscreen(platform.window, 1);
|
||||
}
|
||||
|
|
@ -639,7 +923,7 @@ void SetWindowState(unsigned int flags)
|
|||
}
|
||||
if (FLAG_IS_SET(flags, FLAG_MSAA_4X_HINT))
|
||||
{
|
||||
RGFW_glHints* hints = RGFW_getGlobalHints_OpenGL();
|
||||
RGFW_glHints *hints = RGFW_getGlobalHints_OpenGL();
|
||||
hints->samples = 4;
|
||||
RGFW_setGlobalHints_OpenGL(hints);
|
||||
}
|
||||
|
|
@ -715,7 +999,7 @@ void ClearWindowState(unsigned int flags)
|
|||
}
|
||||
if (FLAG_IS_SET(flags, FLAG_MSAA_4X_HINT))
|
||||
{
|
||||
RGFW_glHints* hints = RGFW_getGlobalHints_OpenGL();
|
||||
RGFW_glHints *hints = RGFW_getGlobalHints_OpenGL();
|
||||
hints->samples = 0;
|
||||
RGFW_setGlobalHints_OpenGL(hints);
|
||||
}
|
||||
|
|
@ -810,7 +1094,7 @@ void SetWindowSize(int width, int height)
|
|||
Vector2 scaleDpi = GetWindowScaleDPI();
|
||||
|
||||
#if defined(__APPLE__)
|
||||
RGFW_monitor* currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
RGFW_monitor *currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
CORE.Window.screenScale = MatrixScale(currentMonitor->pixelRatio, currentMonitor->pixelRatio, 1.0f);
|
||||
|
||||
CORE.Window.render.width = CORE.Window.screen.width*currentMonitor->pixelRatio;
|
||||
|
|
@ -1181,7 +1465,7 @@ double GetTime(void)
|
|||
{
|
||||
// CORE.Time.base is nanoseconds as integer
|
||||
double baseTime = (double)CORE.Time.base*1e-9;
|
||||
double time = get_time_seconds() - baseTime;
|
||||
double time = GetTimeSeconds() - baseTime;
|
||||
|
||||
return time;
|
||||
}
|
||||
|
|
@ -1288,9 +1572,6 @@ void PollInputEvents(void)
|
|||
// Map touch position to mouse position for convenience
|
||||
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
|
||||
|
||||
int touchAction = -1; // 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE
|
||||
bool realTouch = false; // Flag to differentiate real touch gestures from mouse ones
|
||||
|
||||
// Register previous keys states
|
||||
// NOTE: Android supports up to 260 keys
|
||||
for (int i = 0; i < MAX_KEYBOARD_KEYS; i++)
|
||||
|
|
@ -1322,291 +1603,9 @@ void PollInputEvents(void)
|
|||
CORE.Time.previous = GetTime();
|
||||
}
|
||||
|
||||
RGFW_event rgfw_event;
|
||||
while (RGFW_window_checkEvent(platform.window, &rgfw_event))
|
||||
{
|
||||
// All input events can be processed after polling
|
||||
switch (rgfw_event.type)
|
||||
{
|
||||
case RGFW_mouseEnter: CORE.Input.Mouse.cursorOnScreen = true; break;
|
||||
case RGFW_mouseLeave: CORE.Input.Mouse.cursorOnScreen = false; break;
|
||||
case RGFW_quit:
|
||||
RGFW_window_setShouldClose(platform.window, true);
|
||||
return;
|
||||
case RGFW_dataDrop: // Dropped file
|
||||
{
|
||||
for (int i = 0; i < rgfw_event.drop.count; i++)
|
||||
{
|
||||
if (CORE.Window.dropFileCount == 0)
|
||||
{
|
||||
// When a new file is dropped, reserve a fixed number of slots for all possible dropped files
|
||||
// at the moment limiting the number of drops at once to 1024 files but this behaviour should probably be reviewed
|
||||
// TODO: Pointers should probably be reallocated for any new file added...
|
||||
CORE.Window.dropFilepaths = (char **)RL_CALLOC(1024, sizeof(char *));
|
||||
|
||||
CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
|
||||
strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], rgfw_event.drop.files[i]);
|
||||
|
||||
CORE.Window.dropFileCount++;
|
||||
}
|
||||
else if (CORE.Window.dropFileCount < 1024)
|
||||
{
|
||||
CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
|
||||
strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], rgfw_event.drop.files[i]);
|
||||
|
||||
CORE.Window.dropFileCount++;
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "FILE: Maximum drag and drop files at once is limited to 1024 files!");
|
||||
}
|
||||
} break;
|
||||
|
||||
// Window events are also polled (Minimized, maximized, close...)
|
||||
case RGFW_windowResized:
|
||||
{
|
||||
// set flag that the window was resized
|
||||
CORE.Window.resizedLastFrame = true;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||
{
|
||||
RGFW_monitor* currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
SetupViewport(platform.window->w*currentMonitor->pixelRatio, platform.window->h*currentMonitor->pixelRatio);
|
||||
CORE.Window.screenScale = MatrixScale(currentMonitor->pixelRatio, currentMonitor->pixelRatio, 1.0f);
|
||||
|
||||
CORE.Window.screen.width = platform.window->w;
|
||||
CORE.Window.screen.height = platform.window->h;
|
||||
CORE.Window.render.width = CORE.Window.screen.width*currentMonitor->pixelRatio;
|
||||
CORE.Window.render.height = CORE.Window.screen.height*currentMonitor->pixelRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetupViewport(platform.window->w, platform.window->h);
|
||||
CORE.Window.screen.width = platform.window->w;
|
||||
CORE.Window.screen.height = platform.window->h;
|
||||
CORE.Window.render.width = CORE.Window.screen.width;
|
||||
CORE.Window.render.height = CORE.Window.screen.height;
|
||||
}
|
||||
|
||||
CORE.Window.currentFbo.width = CORE.Window.render.width;
|
||||
CORE.Window.currentFbo.height = CORE.Window.render.height;
|
||||
#elif defined(PLATFORM_WEB_RGFW)
|
||||
// do nothing but prevent other behavior
|
||||
#else
|
||||
SetupViewport(platform.window->w, platform.window->h);
|
||||
|
||||
// Consider content scaling if required
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||
{
|
||||
Vector2 scaleDpi = GetWindowScaleDPI();
|
||||
CORE.Window.screen.width = (int)(platform.window->w/scaleDpi.x);
|
||||
CORE.Window.screen.height = (int)(platform.window->h/scaleDpi.y);
|
||||
CORE.Window.screenScale = MatrixScale(scaleDpi.x, scaleDpi.y, 1.0f);
|
||||
|
||||
// Mouse scale does not seem to be needed
|
||||
//SetMouseScale(1.0f/scaleDpi.x, 1.0f/scaleDpi.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
CORE.Window.screen.width = platform.window->w;
|
||||
CORE.Window.screen.height = platform.window->h;
|
||||
}
|
||||
|
||||
CORE.Window.currentFbo.width = CORE.Window.screen.width;
|
||||
CORE.Window.currentFbo.height = CORE.Window.screen.height;
|
||||
#endif
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
#if defined(__APPLE__)
|
||||
RGFW_monitor* currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
CORE.Window.screenScale = MatrixScale(currentMonitor->pixelRatio, currentMonitor->pixelRatio, 1.0f);
|
||||
SetupViewport(platform.window->w*currentMonitor->pixelRatio, platform.window->h*currentMonitor->pixelRatio);
|
||||
|
||||
CORE.Window.render.width = CORE.Window.screen.width*currentMonitor->pixelRatio;
|
||||
CORE.Window.render.height = CORE.Window.screen.height*currentMonitor->pixelRatio;
|
||||
CORE.Window.currentFbo.width = CORE.Window.render.width;
|
||||
CORE.Window.currentFbo.height = CORE.Window.render.height;
|
||||
#endif
|
||||
platform.surfaceWidth = CORE.Window.currentFbo.width;
|
||||
platform.surfaceHeight = CORE.Window.currentFbo.height;
|
||||
|
||||
// in software mode we dont have the viewport so we need to reverse the highdpi changes
|
||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||
{
|
||||
Vector2 scaleDpi = GetWindowScaleDPI();
|
||||
platform.surfaceWidth *= scaleDpi.x;
|
||||
platform.surfaceHeight *= scaleDpi.y;
|
||||
}
|
||||
|
||||
if (platform.surfacePixels != NULL)
|
||||
{
|
||||
RL_FREE(platform.surfacePixels);
|
||||
platform.surfacePixels = RL_MALLOC(platform.surfaceWidth*platform.surfaceHeight*4);
|
||||
}
|
||||
|
||||
if (platform.surface != NULL)
|
||||
{
|
||||
RGFW_surface_free(platform.surface);
|
||||
platform.surface = RGFW_window_createSurface(platform.window, platform.surfacePixels, platform.surfaceWidth, platform.surfaceHeight, RGFW_formatBGRA8);
|
||||
swResize(platform.surfaceWidth, platform.surfaceHeight);
|
||||
}
|
||||
#endif
|
||||
} break;
|
||||
case RGFW_windowMaximized:
|
||||
{
|
||||
FLAG_SET(CORE.Window.flags, FLAG_WINDOW_MAXIMIZED); // The window was maximized
|
||||
} break;
|
||||
case RGFW_windowMinimized:
|
||||
{
|
||||
FLAG_SET(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // The window was iconified
|
||||
} break;
|
||||
case RGFW_windowRestored:
|
||||
{
|
||||
if (RGFW_window_isMaximized(platform.window))
|
||||
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_MAXIMIZED); // The window was restored
|
||||
if (RGFW_window_isMinimized(platform.window))
|
||||
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // The window was restored
|
||||
} break;
|
||||
case RGFW_windowMoved:
|
||||
{
|
||||
CORE.Window.position.x = platform.window->x;
|
||||
CORE.Window.position.y = platform.window->x;
|
||||
} break;
|
||||
|
||||
// Keyboard events
|
||||
case RGFW_keyPressed:
|
||||
{
|
||||
KeyboardKey key = ConvertScancodeToKey(rgfw_event.key.value);
|
||||
if (key != KEY_NULL)
|
||||
{
|
||||
// If key was up, add it to the key pressed queue
|
||||
if ((CORE.Input.Keyboard.currentKeyState[key] == 0) && (CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE))
|
||||
{
|
||||
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key;
|
||||
CORE.Input.Keyboard.keyPressedQueueCount++;
|
||||
}
|
||||
|
||||
CORE.Input.Keyboard.currentKeyState[key] = 1;
|
||||
|
||||
if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey]) RGFW_window_setShouldClose(platform.window, true);
|
||||
}
|
||||
} break;
|
||||
case RGFW_keyReleased:
|
||||
{
|
||||
KeyboardKey key = ConvertScancodeToKey(rgfw_event.key.value);
|
||||
if (key != KEY_NULL) CORE.Input.Keyboard.currentKeyState[key] = 0;
|
||||
} break;
|
||||
|
||||
case RGFW_keyChar:
|
||||
{
|
||||
// NOTE: event.text.text data comes an UTF-8 text sequence but registering codepoints (int)
|
||||
// Check if there is space available in the queue
|
||||
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
|
||||
{
|
||||
// Add character (codepoint) to the queue
|
||||
CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = rgfw_event.keyChar.value;
|
||||
CORE.Input.Keyboard.charPressedQueueCount++;
|
||||
}
|
||||
} break;
|
||||
|
||||
// Check mouse events
|
||||
case RGFW_mouseScroll:
|
||||
{
|
||||
CORE.Input.Mouse.currentWheelMove.x += rgfw_event.scroll.x;
|
||||
CORE.Input.Mouse.currentWheelMove.y += rgfw_event.scroll.y;
|
||||
} break;
|
||||
case RGFW_mouseButtonPressed:
|
||||
{
|
||||
int btn = rgfw_event.button.value;
|
||||
if (btn == RGFW_mouseLeft) btn = 1;
|
||||
else if (btn == RGFW_mouseRight) btn = 2;
|
||||
else if (btn == RGFW_mouseMiddle) btn = 3;
|
||||
|
||||
CORE.Input.Mouse.currentButtonState[btn - 1] = 1;
|
||||
CORE.Input.Touch.currentTouchState[btn - 1] = 1;
|
||||
|
||||
touchAction = 1;
|
||||
} break;
|
||||
case RGFW_mouseButtonReleased:
|
||||
{
|
||||
int btn = rgfw_event.button.value;
|
||||
if (btn == RGFW_mouseLeft) btn = 1;
|
||||
else if (btn == RGFW_mouseRight) btn = 2;
|
||||
else if (btn == RGFW_mouseMiddle) btn = 3;
|
||||
|
||||
CORE.Input.Mouse.currentButtonState[btn - 1] = 0;
|
||||
CORE.Input.Touch.currentTouchState[btn - 1] = 0;
|
||||
|
||||
touchAction = 0;
|
||||
} break;
|
||||
case RGFW_mousePosChanged:
|
||||
{
|
||||
float mouseX = 0.0f;
|
||||
float mouseY = 0.0f;
|
||||
if (RGFW_window_isCaptured(platform.window))
|
||||
{
|
||||
mouseX = (float)rgfw_event.mouse.vecX;
|
||||
mouseY = (float)rgfw_event.mouse.vecY;
|
||||
}
|
||||
else
|
||||
{
|
||||
mouseX = (float)rgfw_event.mouse.x;
|
||||
mouseY = (float)rgfw_event.mouse.y;
|
||||
}
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
double canvasWidth = 0.0;
|
||||
double canvasHeight = 0.0;
|
||||
emscripten_get_element_css_size("#canvas", &canvasWidth, &canvasHeight);
|
||||
mouseX *= ((float)GetScreenWidth()/(float)canvasWidth);
|
||||
mouseY *= ((float)GetScreenHeight()/(float)canvasHeight);
|
||||
#endif
|
||||
if (RGFW_window_isCaptured(platform.window))
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition.x += mouseX;
|
||||
CORE.Input.Mouse.currentPosition.y += mouseY;
|
||||
}
|
||||
else
|
||||
{
|
||||
CORE.Input.Mouse.currentPosition.x = mouseX;
|
||||
CORE.Input.Mouse.currentPosition.y = mouseY;
|
||||
}
|
||||
|
||||
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
|
||||
touchAction = 2;
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
if (touchAction > -1)
|
||||
{
|
||||
// Process mouse events as touches to be able to use mouse-gestures
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
|
||||
// Register touch actions
|
||||
gestureEvent.touchAction = touchAction;
|
||||
|
||||
// Assign a pointer ID
|
||||
gestureEvent.pointId[0] = 0;
|
||||
|
||||
// Register touch points count
|
||||
gestureEvent.pointCount = 1;
|
||||
|
||||
// Register touch points position, only one point registered
|
||||
if (touchAction == 2 || realTouch) gestureEvent.position[0] = CORE.Input.Touch.position[0];
|
||||
else gestureEvent.position[0] = GetMousePosition();
|
||||
|
||||
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
|
||||
gestureEvent.position[0].x /= (float)GetScreenWidth();
|
||||
gestureEvent.position[0].y /= (float)GetScreenHeight();
|
||||
|
||||
// Gesture data is sent to gestures-system for processing
|
||||
ProcessGestureEvent(gestureEvent);
|
||||
|
||||
touchAction = -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// using RGFW callbacks instead of polling
|
||||
RGFW_pollEvents();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
mg_event gamepad_event;
|
||||
|
|
@ -1646,7 +1645,7 @@ void PollInputEvents(void)
|
|||
case GAMEPAD_AXIS_RIGHT_TRIGGER:
|
||||
CORE.Input.Gamepad.axisState[gamepadIndex][axis] = platform.minigamepad.gamepads[gamepadIndex].axes[gamepad_event.axis].value;
|
||||
|
||||
/* trigger button press when axis is all the way */
|
||||
// Trigger button press when axis is all the way
|
||||
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER) ? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
|
||||
int pressed = (platform.minigamepad.gamepads[gamepadIndex].axes[gamepad_event.axis].value >= 1.0f);
|
||||
|
||||
|
|
@ -1663,9 +1662,12 @@ void PollInputEvents(void)
|
|||
|
||||
int axisCount = 0;
|
||||
for (int i = 0; i < MG_AXIS_COUNT; i += 1) {
|
||||
if (platform.minigamepad.gamepads[gamepadIndex].axes[i].supported) {
|
||||
if (platform.minigamepad.gamepads[gamepadIndex].axes[i].supported)
|
||||
{
|
||||
axisCount += 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1763,7 +1765,7 @@ int InitPlatform(void)
|
|||
|
||||
// NOTE: Some OpenGL context attributes must be set before window creation
|
||||
// Check selection OpenGL version
|
||||
RGFW_glHints* hints = RGFW_getGlobalHints_OpenGL();
|
||||
RGFW_glHints *hints = RGFW_getGlobalHints_OpenGL();
|
||||
if (rlGetVersion() == RL_OPENGL_21)
|
||||
{
|
||||
hints->major = 2;
|
||||
|
|
@ -1838,7 +1840,7 @@ int InitPlatform(void)
|
|||
Vector2 scaleDpi = GetWindowScaleDPI();
|
||||
|
||||
#if defined(__APPLE__)
|
||||
RGFW_monitor* currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
RGFW_monitor *currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
CORE.Window.screenScale = MatrixScale(currentMonitor->pixelRatio, currentMonitor->pixelRatio, 1.0f);
|
||||
|
||||
CORE.Window.render.width = CORE.Window.screen.width*currentMonitor->pixelRatio;
|
||||
|
|
@ -1856,7 +1858,7 @@ int InitPlatform(void)
|
|||
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
|
||||
// apple always scales for retina
|
||||
#if defined(__APPLE__)
|
||||
RGFW_monitor* currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
RGFW_monitor *currentMonitor = RGFW_window_getMonitor(platform.window);
|
||||
CORE.Window.screenScale = MatrixScale(currentMonitor->pixelRatio, currentMonitor->pixelRatio, 1.0f);
|
||||
|
||||
CORE.Window.render.width = CORE.Window.screen.width*currentMonitor->pixelRatio;
|
||||
|
|
@ -1886,6 +1888,25 @@ int InitPlatform(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
// Set callbacks
|
||||
RGFW_setEventCallback(RGFW_mouseEnter, RGFW_cb_mousenotifyfunc);
|
||||
RGFW_setEventCallback(RGFW_mouseLeave, RGFW_cb_mousenotifyfunc);
|
||||
// RGFW_setEventCallback(RGFW_windowClose, RGFW_cb_windowclosefunc); // do not close here. let raylib handle it
|
||||
RGFW_setEventCallback(RGFW_dataDrop, RGFW_cb_dropfunc);
|
||||
RGFW_setEventCallback(RGFW_windowResized, RGFW_cb_windowresizefunc);
|
||||
RGFW_setEventCallback(RGFW_windowMaximized, RGFW_cb_windowmaximizefunc);
|
||||
RGFW_setEventCallback(RGFW_windowMinimized, RGFW_cb_windowminimizefunc);
|
||||
RGFW_setEventCallback(RGFW_windowRestored, RGFW_cb_windowrestorefunc);
|
||||
RGFW_setEventCallback(RGFW_windowMoved, RGFW_cb_windowmovefunc);
|
||||
RGFW_setEventCallback(RGFW_keyChar, RGFW_cb_keycharfunc);
|
||||
RGFW_setEventCallback(RGFW_mouseScroll, RGFW_cb_scrollfunc);
|
||||
RGFW_setEventCallback(RGFW_mouseButtonPressed, RGFW_cb_mousebuttonfunc);
|
||||
RGFW_setEventCallback(RGFW_mouseButtonReleased, RGFW_cb_mousebuttonfunc);
|
||||
RGFW_setEventCallback(RGFW_mouseRawMotion, RGFW_cb_mouserawmotionfunc);
|
||||
RGFW_setEventCallback(RGFW_mouseMotion, RGFW_cb_mousemotionfunc);
|
||||
RGFW_setEventCallback(RGFW_keyPressed, (RGFW_genericFunc)RGFW_cb_keyfunc);
|
||||
RGFW_setEventCallback(RGFW_keyReleased, (RGFW_genericFunc)RGFW_cb_keyfunc);
|
||||
|
||||
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully %s",
|
||||
FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI)? "(HighDPI)" : "");
|
||||
TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
|
||||
|
|
@ -2007,8 +2028,39 @@ static KeyboardKey ConvertScancodeToKey(u32 keycode)
|
|||
return (KeyboardKey)RGFW_keyConvertTable[keycode];
|
||||
}
|
||||
|
||||
// assign mouse to touches
|
||||
// 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE
|
||||
void RemapMouseToTouch(int touchAction)
|
||||
{
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
if (touchAction < 0) return;
|
||||
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
|
||||
// Register touch actions
|
||||
gestureEvent.touchAction = touchAction;
|
||||
|
||||
// Assign a pointer ID
|
||||
gestureEvent.pointId[0] = 0;
|
||||
|
||||
// Register touch points count
|
||||
gestureEvent.pointCount = 1;
|
||||
|
||||
// Register touch points position, only one point registered
|
||||
if (touchAction == 2 /*|| realTouch*/) gestureEvent.position[0] = CORE.Input.Touch.position[0];
|
||||
else gestureEvent.position[0] = GetMousePosition();
|
||||
|
||||
// Normalize gestureEvent.position[0] for CORE.Window.screen.width and CORE.Window.screen.height
|
||||
gestureEvent.position[0].x /= (float)GetScreenWidth();
|
||||
gestureEvent.position[0].y /= (float)GetScreenHeight();
|
||||
|
||||
// Gesture data is sent to gestures-system for processing
|
||||
ProcessGestureEvent(gestureEvent);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Helper functions for Time
|
||||
double get_time_seconds(void)
|
||||
double GetTimeSeconds(void)
|
||||
{
|
||||
double currentTime = 0.0;
|
||||
|
||||
|
|
|
|||
|
|
@ -566,100 +566,100 @@ static KeyboardKey GetKeyFromWparam(WPARAM wparam)
|
|||
case 'X': return KEY_X;
|
||||
case 'Y': return KEY_Y;
|
||||
case 'Z': return KEY_Z;
|
||||
/* case VK_LWIN: return KEY_; */
|
||||
/* case VK_RWIN: return KEY_; */
|
||||
/* case VK_APPS: return KEY_; */
|
||||
/* case VK_SLEEP: return KEY_; */
|
||||
/* case VK_NUMPAD0: return KEY_; */
|
||||
/* case VK_NUMPAD1: return KEY_; */
|
||||
/* case VK_NUMPAD2: return KEY_; */
|
||||
/* case VK_NUMPAD3: return KEY_; */
|
||||
/* case VK_NUMPAD4: return KEY_; */
|
||||
/* case VK_NUMPAD5: return KEY_; */
|
||||
/* case VK_NUMPAD6: return KEY_; */
|
||||
/* case VK_NUMPAD7: return KEY_; */
|
||||
/* case VK_NUMPAD8: return KEY_; */
|
||||
/* case VK_NUMPAD9: return KEY_; */
|
||||
/* case VK_MULTIPLY: return KEY_; */
|
||||
/* case VK_ADD: return KEY_; */
|
||||
/* case VK_SEPARATOR: return KEY_; */
|
||||
/* case VK_SUBTRACT: return KEY_; */
|
||||
/* case VK_DECIMAL: return KEY_; */
|
||||
/* case VK_DIVIDE: return KEY_; */
|
||||
/* case VK_F1: return KEY_; */
|
||||
/* case VK_F2: return KEY_; */
|
||||
/* case VK_F3: return KEY_; */
|
||||
/* case VK_F4: return KEY_; */
|
||||
/* case VK_F5: return KEY_; */
|
||||
/* case VK_F6: return KEY_; */
|
||||
/* case VK_F7: return KEY_; */
|
||||
/* case VK_F8: return KEY_; */
|
||||
/* case VK_F9: return KEY_; */
|
||||
/* case VK_F10: return KEY_; */
|
||||
/* case VK_F11: return KEY_; */
|
||||
/* case VK_F12: return KEY_; */
|
||||
/* case VK_F13: return KEY_; */
|
||||
/* case VK_F14: return KEY_; */
|
||||
/* case VK_F15: return KEY_; */
|
||||
/* case VK_F16: return KEY_; */
|
||||
/* case VK_F17: return KEY_; */
|
||||
/* case VK_F18: return KEY_; */
|
||||
/* case VK_F19: return KEY_; */
|
||||
/* case VK_F20: return KEY_; */
|
||||
/* case VK_F21: return KEY_; */
|
||||
/* case VK_F22: return KEY_; */
|
||||
/* case VK_F23: return KEY_; */
|
||||
/* case VK_F24: return KEY_; */
|
||||
/* case VK_NUMLOCK: return KEY_; */
|
||||
/* case VK_SCROLL: return KEY_; */
|
||||
/* case VK_LSHIFT: return KEY_; */
|
||||
/* case VK_RSHIFT: return KEY_; */
|
||||
/* case VK_LCONTROL: return KEY_; */
|
||||
/* case VK_RCONTROL: return KEY_; */
|
||||
/* case VK_LMENU: return KEY_; */
|
||||
/* case VK_RMENU: return KEY_; */
|
||||
/* case VK_BROWSER_BACK: return KEY_; */
|
||||
/* case VK_BROWSER_FORWARD: return KEY_; */
|
||||
/* case VK_BROWSER_REFRESH: return KEY_; */
|
||||
/* case VK_BROWSER_STOP: return KEY_; */
|
||||
/* case VK_BROWSER_SEARCH: return KEY_; */
|
||||
/* case VK_BROWSER_FAVORITES: return KEY_; */
|
||||
/* case VK_BROWSER_HOME: return KEY_; */
|
||||
/* case VK_VOLUME_MUTE: return KEY_; */
|
||||
/* case VK_VOLUME_DOWN: return KEY_; */
|
||||
/* case VK_VOLUME_UP: return KEY_; */
|
||||
/* case VK_MEDIA_NEXT_TRACK: return KEY_; */
|
||||
/* case VK_MEDIA_PREV_TRACK: return KEY_; */
|
||||
/* case VK_MEDIA_STOP: return KEY_; */
|
||||
/* case VK_MEDIA_PLAY_PAUSE: return KEY_; */
|
||||
/* case VK_LAUNCH_MAIL: return KEY_; */
|
||||
/* case VK_LAUNCH_MEDIA_SELECT: return KEY_; */
|
||||
/* case VK_LAUNCH_APP1: return KEY_; */
|
||||
/* case VK_LAUNCH_APP2: return KEY_; */
|
||||
/* case VK_OEM_1: return KEY_; */
|
||||
/* case VK_OEM_PLUS: return KEY_; */
|
||||
/* case VK_OEM_COMMA: return KEY_; */
|
||||
/* case VK_OEM_MINUS: return KEY_; */
|
||||
/* case VK_OEM_PERIOD: return KEY_; */
|
||||
/* case VK_OEM_2: return KEY_; */
|
||||
/* case VK_OEM_3: return KEY_; */
|
||||
/* case VK_OEM_4: return KEY_; */
|
||||
/* case VK_OEM_5: return KEY_; */
|
||||
/* case VK_OEM_6: return KEY_; */
|
||||
/* case VK_OEM_7: return KEY_; */
|
||||
/* case VK_OEM_8: return KEY_; */
|
||||
/* case VK_OEM_102: return KEY_; */
|
||||
/* case VK_PROCESSKEY: return KEY_; */
|
||||
/* case VK_PACKET: return KEY_; */
|
||||
/* case VK_ATTN: return KEY_; */
|
||||
/* case VK_CRSEL: return KEY_; */
|
||||
/* case VK_EXSEL: return KEY_; */
|
||||
/* case VK_EREOF: return KEY_; */
|
||||
/* case VK_PLAY: return KEY_; */
|
||||
/* case VK_ZOOM: return KEY_; */
|
||||
/* case VK_NONAME: return KEY_; */
|
||||
/* case VK_PA1: return KEY_; */
|
||||
/* case VK_OEM_CLEAR: return KEY_; */
|
||||
//case VK_LWIN: return KEY_;
|
||||
//case VK_RWIN: return KEY_;
|
||||
//case VK_APPS: return KEY_;
|
||||
//case VK_SLEEP: return KEY_;
|
||||
//case VK_NUMPAD0: return KEY_;
|
||||
//case VK_NUMPAD1: return KEY_;
|
||||
//case VK_NUMPAD2: return KEY_;
|
||||
//case VK_NUMPAD3: return KEY_;
|
||||
//case VK_NUMPAD4: return KEY_;
|
||||
//case VK_NUMPAD5: return KEY_;
|
||||
//case VK_NUMPAD6: return KEY_;
|
||||
//case VK_NUMPAD7: return KEY_;
|
||||
//case VK_NUMPAD8: return KEY_;
|
||||
//case VK_NUMPAD9: return KEY_;
|
||||
//case VK_MULTIPLY: return KEY_;
|
||||
//case VK_ADD: return KEY_;
|
||||
//case VK_SEPARATOR: return KEY_;
|
||||
//case VK_SUBTRACT: return KEY_;
|
||||
//case VK_DECIMAL: return KEY_;
|
||||
//case VK_DIVIDE: return KEY_;
|
||||
//case VK_F1: return KEY_;
|
||||
//case VK_F2: return KEY_;
|
||||
//case VK_F3: return KEY_;
|
||||
//case VK_F4: return KEY_;
|
||||
//case VK_F5: return KEY_;
|
||||
//case VK_F6: return KEY_;
|
||||
//case VK_F7: return KEY_;
|
||||
//case VK_F8: return KEY_;
|
||||
//case VK_F9: return KEY_;
|
||||
//case VK_F10: return KEY_;
|
||||
//case VK_F11: return KEY_;
|
||||
//case VK_F12: return KEY_;
|
||||
//case VK_F13: return KEY_;
|
||||
//case VK_F14: return KEY_;
|
||||
//case VK_F15: return KEY_;
|
||||
//case VK_F16: return KEY_;
|
||||
//case VK_F17: return KEY_;
|
||||
//case VK_F18: return KEY_;
|
||||
//case VK_F19: return KEY_;
|
||||
//case VK_F20: return KEY_;
|
||||
//case VK_F21: return KEY_;
|
||||
//case VK_F22: return KEY_;
|
||||
//case VK_F23: return KEY_;
|
||||
//case VK_F24: return KEY_;
|
||||
//case VK_NUMLOCK: return KEY_;
|
||||
//case VK_SCROLL: return KEY_;
|
||||
//case VK_LSHIFT: return KEY_;
|
||||
//case VK_RSHIFT: return KEY_;
|
||||
//case VK_LCONTROL: return KEY_;
|
||||
//case VK_RCONTROL: return KEY_;
|
||||
//case VK_LMENU: return KEY_;
|
||||
//case VK_RMENU: return KEY_;
|
||||
//case VK_BROWSER_BACK: return KEY_;
|
||||
//case VK_BROWSER_FORWARD: return KEY_;
|
||||
//case VK_BROWSER_REFRESH: return KEY_;
|
||||
//case VK_BROWSER_STOP: return KEY_;
|
||||
//case VK_BROWSER_SEARCH: return KEY_;
|
||||
//case VK_BROWSER_FAVORITES: return KEY_;
|
||||
//case VK_BROWSER_HOME: return KEY_;
|
||||
//case VK_VOLUME_MUTE: return KEY_;
|
||||
//case VK_VOLUME_DOWN: return KEY_;
|
||||
//case VK_VOLUME_UP: return KEY_;
|
||||
//case VK_MEDIA_NEXT_TRACK: return KEY_;
|
||||
//case VK_MEDIA_PREV_TRACK: return KEY_;
|
||||
//case VK_MEDIA_STOP: return KEY_;
|
||||
//case VK_MEDIA_PLAY_PAUSE: return KEY_;
|
||||
//case VK_LAUNCH_MAIL: return KEY_;
|
||||
//case VK_LAUNCH_MEDIA_SELECT: return KEY_;
|
||||
//case VK_LAUNCH_APP1: return KEY_;
|
||||
//case VK_LAUNCH_APP2: return KEY_;
|
||||
//case VK_OEM_1: return KEY_;
|
||||
//case VK_OEM_PLUS: return KEY_;
|
||||
//case VK_OEM_COMMA: return KEY_;
|
||||
//case VK_OEM_MINUS: return KEY_;
|
||||
//case VK_OEM_PERIOD: return KEY_;
|
||||
//case VK_OEM_2: return KEY_;
|
||||
//case VK_OEM_3: return KEY_;
|
||||
//case VK_OEM_4: return KEY_;
|
||||
//case VK_OEM_5: return KEY_;
|
||||
//case VK_OEM_6: return KEY_;
|
||||
//case VK_OEM_7: return KEY_;
|
||||
//case VK_OEM_8: return KEY_;
|
||||
//case VK_OEM_102: return KEY_;
|
||||
//case VK_PROCESSKEY: return KEY_;
|
||||
//case VK_PACKET: return KEY_;
|
||||
//case VK_ATTN: return KEY_;
|
||||
//case VK_CRSEL: return KEY_;
|
||||
//case VK_EXSEL: return KEY_;
|
||||
//case VK_EREOF: return KEY_;
|
||||
//case VK_PLAY: return KEY_;
|
||||
//case VK_ZOOM: return KEY_;
|
||||
//case VK_NONAME: return KEY_;
|
||||
//case VK_PA1: return KEY_;
|
||||
//case VK_OEM_CLEAR: return KEY_;
|
||||
default: return KEY_NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ void SetWindowSize(int width, int height)
|
|||
// When resizing the canvas, several elements must be considered:
|
||||
// - CSS canvas size: Web layout size, logical pixels
|
||||
// - Canvas contained framebuffer resolution
|
||||
// * Browser monitor, device pixel ratio (HighDPI)
|
||||
// - Browser monitor, device pixel ratio (HighDPI)
|
||||
|
||||
double canvasCssWidth = 0.0;
|
||||
double canvasCssHeight = 0.0;
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ typedef enum {
|
|||
// Audio buffer struct
|
||||
struct rAudioBuffer {
|
||||
ma_data_converter converter; // Audio data converter
|
||||
unsigned char* converterResidual; // Cached residual input frames for use by the converter
|
||||
unsigned char *converterResidual; // Cached residual input frames for use by the converter
|
||||
unsigned int converterResidualCount; // The number of valid frames sitting in converterResidual
|
||||
|
||||
AudioCallback callback; // Audio buffer callback for buffer filling on audio threads
|
||||
|
|
|
|||
|
|
@ -2714,13 +2714,13 @@ RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotatio
|
|||
stabilizer = fmaxf(stabilizer, fabsf(matColumns[i].y));
|
||||
stabilizer = fmaxf(stabilizer, fabsf(matColumns[i].z));
|
||||
}
|
||||
matColumns[0] = Vector3Scale(matColumns[0], 1.0f / stabilizer);
|
||||
matColumns[1] = Vector3Scale(matColumns[1], 1.0f / stabilizer);
|
||||
matColumns[2] = Vector3Scale(matColumns[2], 1.0f / stabilizer);
|
||||
matColumns[0] = Vector3Scale(matColumns[0], 1.0f/stabilizer);
|
||||
matColumns[1] = Vector3Scale(matColumns[1], 1.0f/stabilizer);
|
||||
matColumns[2] = Vector3Scale(matColumns[2], 1.0f/stabilizer);
|
||||
|
||||
// X Scale
|
||||
scl.x = Vector3Length(matColumns[0]);
|
||||
if (scl.x > eps) matColumns[0] = Vector3Scale(matColumns[0], 1.0f / scl.x);
|
||||
if (scl.x > eps) matColumns[0] = Vector3Scale(matColumns[0], 1.0f/scl.x);
|
||||
|
||||
// Compute XY shear and make col2 orthogonal
|
||||
shear[0] = Vector3DotProduct(matColumns[0], matColumns[1]);
|
||||
|
|
@ -2730,7 +2730,7 @@ RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotatio
|
|||
scl.y = Vector3Length(matColumns[1]);
|
||||
if (scl.y > eps)
|
||||
{
|
||||
matColumns[1] = Vector3Scale(matColumns[1], 1.0f / scl.y);
|
||||
matColumns[1] = Vector3Scale(matColumns[1], 1.0f/scl.y);
|
||||
shear[0] /= scl.y; // Correct XY shear
|
||||
}
|
||||
|
||||
|
|
@ -2744,7 +2744,7 @@ RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotatio
|
|||
scl.z = Vector3Length(matColumns[2]);
|
||||
if (scl.z > eps)
|
||||
{
|
||||
matColumns[2] = Vector3Scale(matColumns[2], 1.0f / scl.z);
|
||||
matColumns[2] = Vector3Scale(matColumns[2], 1.0f/scl.z);
|
||||
shear[1] /= scl.z; // Correct XZ shear
|
||||
shear[2] /= scl.z; // Correct YZ shear
|
||||
}
|
||||
|
|
|
|||
18
src/rcore.c
18
src/rcore.c
|
|
@ -2246,10 +2246,10 @@ int FileCopy(const char *srcPath, const char *dstPath)
|
|||
unsigned char *srcFileData = LoadFileData(srcPath, &srcDataSize);
|
||||
|
||||
// Create required paths if they do not exist
|
||||
if (!DirectoryExists(GetDirectoryPath(dstPath)))
|
||||
result = MakeDirectory(GetDirectoryPath(dstPath));
|
||||
if (DirectoryExists(GetDirectoryPath(dstPath))) result = 0; // Already exists
|
||||
else result = MakeDirectory(GetDirectoryPath(dstPath));
|
||||
|
||||
if (result == 0) // Directory created successfully (or already exists)
|
||||
if (result == 0) // Directory created successfully or already exists
|
||||
{
|
||||
if ((srcFileData != NULL) && (srcDataSize > 0))
|
||||
{
|
||||
|
|
@ -3943,7 +3943,11 @@ bool IsGamepadAvailable(int gamepad)
|
|||
// Get gamepad internal name id
|
||||
const char *GetGamepadName(int gamepad)
|
||||
{
|
||||
return CORE.Input.Gamepad.name[gamepad];
|
||||
const char *name = NULL;
|
||||
|
||||
if ((gamepad >= 0) && (gamepad < MAX_GAMEPADS)) name = CORE.Input.Gamepad.name[gamepad];
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
// Check if gamepad button has been pressed once
|
||||
|
|
@ -4008,7 +4012,11 @@ int GetGamepadButtonPressed(void)
|
|||
// Get gamepad axis count
|
||||
int GetGamepadAxisCount(int gamepad)
|
||||
{
|
||||
return CORE.Input.Gamepad.axisCount[gamepad];
|
||||
int result = 0;
|
||||
|
||||
if ((gamepad >= 0) && (gamepad < MAX_GAMEPADS)) result = CORE.Input.Gamepad.axisCount[gamepad];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Get axis movement vector for a gamepad
|
||||
|
|
|
|||
14
src/rlgl.h
14
src/rlgl.h
|
|
@ -1237,7 +1237,11 @@ void rlMatrixMode(int mode)
|
|||
// Push the current matrix into RLGL.State.stack
|
||||
void rlPushMatrix(void)
|
||||
{
|
||||
if (RLGL.State.stackCounter >= RL_MAX_MATRIX_STACK_SIZE) TRACELOG(RL_LOG_ERROR, "RLGL: Matrix stack overflow (RL_MAX_MATRIX_STACK_SIZE)");
|
||||
if (RLGL.State.stackCounter >= RL_MAX_MATRIX_STACK_SIZE)
|
||||
{
|
||||
TRACELOG(RL_LOG_ERROR, "RLGL: Matrix stack overflow (RL_MAX_MATRIX_STACK_SIZE)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (RLGL.State.currentMatrixMode == RL_MODELVIEW)
|
||||
{
|
||||
|
|
@ -3777,9 +3781,17 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format)
|
|||
// Attach our texture to FBO
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, id, 0);
|
||||
|
||||
#if defined(FBO_READ_TEXTURE_AS_RGBA)
|
||||
// Reading data as RGBA because FBO texture is configured as RGBA, despite binding another texture format
|
||||
pixels = RL_CALLOC(rlGetPixelDataSize(width, height, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8), 1);
|
||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
#else
|
||||
// Reading data as original texture format, in some platforms (RPI, Wasm) it works
|
||||
pixels = (unsigned char *)RL_MALLOC(GetPixelDataSize(width, height, format));
|
||||
unsigned int glInternalFormat = 0, glFormat = 0, glType = 0;
|
||||
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType);
|
||||
glReadPixels(0, 0, width, height, glFormat, glType, pixels);
|
||||
#endif
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -3142,6 +3142,8 @@ Mesh GenMeshCone(float radius, float height, int slices)
|
|||
}
|
||||
|
||||
// Generate torus mesh
|
||||
// NOTE: The distance between the center of the hole and the center of the
|
||||
// tube is half size of the radius of the tube (radius*size/2)
|
||||
Mesh GenMeshTorus(float radius, float size, int radSeg, int sides)
|
||||
{
|
||||
Mesh mesh = { 0 };
|
||||
|
|
@ -7212,7 +7214,7 @@ static Model LoadM3D(const char *fileName)
|
|||
return model;
|
||||
}
|
||||
|
||||
#define M3D_ANIMDELAY 17 // Animation frames delay, (~1000 ms/60 FPS = 16.666666* ms)
|
||||
#define M3D_ANIMDELAY 17 // Animation frames delay, (~1000 ms/60 FPS = 16.666666 ms)
|
||||
|
||||
// Load M3D animation data
|
||||
static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, int *animCount)
|
||||
|
|
|
|||
|
|
@ -947,8 +947,8 @@ Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyp
|
|||
// Security fix: check both lower and upper bounds
|
||||
if (destX >= 0 && destX < atlas.width && destY >= 0 && destY < atlas.height)
|
||||
{
|
||||
((unsigned char *)atlas.data)[destY * atlas.width + destX] =
|
||||
((unsigned char *)glyphs[i].image.data)[y * glyphs[i].image.width + x];
|
||||
((unsigned char *)atlas.data)[destY*atlas.width + destX] =
|
||||
((unsigned char *)glyphs[i].image.data)[y*glyphs[i].image.width + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1919,10 +1919,14 @@ char *TextReplaceBetween(const char *text, const char *begin, const char *end, c
|
|||
int replaceLen = (replacement == NULL)? 0 : TextLength(replacement);
|
||||
//int toreplaceLen = endIndex - beginIndex - beginLen;
|
||||
|
||||
if ((beginIndex + beginLen + replaceLen + (textLen - endIndex)) < (MAX_TEXT_BUFFER_LENGTH - 1))
|
||||
{
|
||||
strncpy(buffer, text, beginIndex + beginLen); // Copy first text part
|
||||
if (replacement != NULL) strncpy(buffer + beginIndex + beginLen, replacement, replaceLen); // Copy replacement (if provided)
|
||||
strncpy(buffer + beginIndex + beginLen + replaceLen, text + endIndex, textLen - endIndex); // Copy end text part
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "TEXT: Text with replaced string is longer than internal buffer (MAX_TEXT_BUFFER_LENGTH)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -562,15 +562,18 @@ Image LoadImageFromTexture(Texture2D texture)
|
|||
{
|
||||
image.width = texture.width;
|
||||
image.height = texture.height;
|
||||
#if defined(FBO_READ_TEXTURE_AS_RGBA)
|
||||
// WARNING: On OpenGL ES 2.0/WebGL 1.0, there is no glGetTexImage() so,
|
||||
// texture data is retrieved by creating an RGBA fbo, binding the texture
|
||||
// to the fbo color attachment, and reading it as RGBA data with glReadPixels()
|
||||
// Returned data *should* be RGBA but it seems on some platforms (RPI, WASM)
|
||||
// original texture format is retrieved, so adding a define for this patch
|
||||
image.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
|
||||
#else
|
||||
image.format = texture.format;
|
||||
#endif
|
||||
image.mipmaps = 1;
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
// NOTE: Data retrieved on OpenGL ES 2.0 should be RGBA,
|
||||
// coming from FBO color buffer attachment, but it seems
|
||||
// original texture format is retrieved on RPI...
|
||||
image.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
|
||||
#endif
|
||||
TRACELOG(LOG_INFO, "TEXTURE: [ID %i] Pixel data retrieved successfully", texture.id);
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "TEXTURE: [ID %i] Failed to retrieve pixel data", texture.id);
|
||||
|
|
|
|||
|
|
@ -1886,9 +1886,11 @@ int main(int argc, char *argv[])
|
|||
printf(" test <example_name> : Build and Test example for Desktop and Web platforms\n");
|
||||
printf(" validate : Validate examples collection, generates report\n");
|
||||
printf(" update : Validate and update examples collection, generates report\n\n");
|
||||
|
||||
printf("OPTIONS:\n\n");
|
||||
printf(" -h, --help : Show tool version and command line usage help\n");
|
||||
printf(" -v, --verbose : Verbose mode, show additional logs on processes\n");
|
||||
|
||||
printf("\nEXAMPLES:\n\n");
|
||||
printf(" > rexm add shapes_custom_stars\n");
|
||||
printf(" Add and updates new example provided <shapes_custom_stars>\n\n");
|
||||
|
|
|
|||
Loading…
Reference in a new issue