mirror of
https://github.com/raysan5/raylib.git
synced 2026-11-25 09:01:47 -05:00
Compare commits
8 Commits
9b1b4d47c9
...
c99d3e8b49
| Author | SHA1 | Date | |
|---|---|---|---|
| c99d3e8b49 | |||
| fa62b272ce | |||
| 1cf6fd9933 | |||
| 69a8cbf596 | |||
| f9c97eef37 | |||
| 6c4893ed3a | |||
| 7d30b4fc6e | |||
| 2f1ace31e5 |
@ -172,6 +172,14 @@ foreach (example_source ${example_sources})
|
||||
target_link_libraries(${example_name} m)
|
||||
endif()
|
||||
|
||||
# This example calls system OpenGL stencil functions directly.
|
||||
if ("${example_name}" STREQUAL "gl_scissor_shapes")
|
||||
if ("${PLATFORM}" MATCHES "Desktop" OR "${PLATFORM}" MATCHES "RGFW")
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(${example_name} OpenGL::GL)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
|
||||
string(APPEND resources_dir "resources")
|
||||
|
||||
|
||||
@ -120,6 +120,126 @@ static PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = NULL;
|
||||
static PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL;
|
||||
static PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = NULL;
|
||||
|
||||
// Maps scancodes to Raylib keys
|
||||
static const unsigned short keyboardKeyFromScancode[] = {
|
||||
[0x01] = KEY_ESCAPE,
|
||||
[0x02] = KEY_ONE,
|
||||
[0x03] = KEY_TWO,
|
||||
[0x04] = KEY_THREE,
|
||||
[0x05] = KEY_FOUR,
|
||||
[0x06] = KEY_FIVE,
|
||||
[0x07] = KEY_SIX,
|
||||
[0x08] = KEY_SEVEN,
|
||||
[0x09] = KEY_EIGHT,
|
||||
[0x0A] = KEY_NINE,
|
||||
[0x0B] = KEY_ZERO,
|
||||
[0x0C] = KEY_MINUS,
|
||||
[0x0D] = KEY_EQUAL,
|
||||
[0x0E] = KEY_BACKSPACE,
|
||||
[0x0F] = KEY_TAB,
|
||||
[0x10] = KEY_Q,
|
||||
[0x11] = KEY_W,
|
||||
[0x12] = KEY_E,
|
||||
[0x13] = KEY_R,
|
||||
[0x14] = KEY_T,
|
||||
[0x15] = KEY_Y,
|
||||
[0x16] = KEY_U,
|
||||
[0x17] = KEY_I,
|
||||
[0x18] = KEY_O,
|
||||
[0x19] = KEY_P,
|
||||
[0x1A] = KEY_LEFT_BRACKET,
|
||||
[0x1B] = KEY_RIGHT_BRACKET,
|
||||
[0x1C] = KEY_ENTER,
|
||||
[0x1D] = KEY_LEFT_CONTROL,
|
||||
[0x1E] = KEY_A,
|
||||
[0x1F] = KEY_S,
|
||||
[0x20] = KEY_D,
|
||||
[0x21] = KEY_F,
|
||||
[0x22] = KEY_G,
|
||||
[0x23] = KEY_H,
|
||||
[0x24] = KEY_J,
|
||||
[0x25] = KEY_K,
|
||||
[0x26] = KEY_L,
|
||||
[0x27] = KEY_SEMICOLON,
|
||||
[0x28] = KEY_APOSTROPHE,
|
||||
[0x29] = KEY_GRAVE,
|
||||
[0x2A] = KEY_LEFT_SHIFT,
|
||||
[0x2B] = KEY_BACKSLASH,
|
||||
[0x2C] = KEY_Z,
|
||||
[0x2D] = KEY_X,
|
||||
[0x2E] = KEY_C,
|
||||
[0x2F] = KEY_V,
|
||||
[0x30] = KEY_B,
|
||||
[0x31] = KEY_N,
|
||||
[0x32] = KEY_M,
|
||||
[0x33] = KEY_COMMA,
|
||||
[0x34] = KEY_PERIOD,
|
||||
[0x35] = KEY_SLASH,
|
||||
[0x36] = KEY_RIGHT_SHIFT,
|
||||
[0x37] = KEY_KP_MULTIPLY,
|
||||
[0x38] = KEY_LEFT_ALT,
|
||||
[0x39] = KEY_SPACE,
|
||||
[0x3A] = KEY_CAPS_LOCK,
|
||||
[0x3B] = KEY_F1,
|
||||
[0x3C] = KEY_F2,
|
||||
[0x3D] = KEY_F3,
|
||||
[0x3E] = KEY_F4,
|
||||
[0x3F] = KEY_F5,
|
||||
[0x40] = KEY_F6,
|
||||
[0x41] = KEY_F7,
|
||||
[0x42] = KEY_F8,
|
||||
[0x43] = KEY_F9,
|
||||
[0x44] = KEY_F10,
|
||||
[0x45] = KEY_PAUSE,
|
||||
[0x46] = KEY_SCROLL_LOCK,
|
||||
[0x47] = KEY_KP_7,
|
||||
[0x48] = KEY_KP_8,
|
||||
[0x49] = KEY_KP_9,
|
||||
[0x4A] = KEY_KP_SUBTRACT,
|
||||
[0x4B] = KEY_KP_4,
|
||||
[0x4C] = KEY_KP_5,
|
||||
[0x4D] = KEY_KP_6,
|
||||
[0x4E] = KEY_KP_ADD,
|
||||
[0x4F] = KEY_KP_1,
|
||||
[0x50] = KEY_KP_2,
|
||||
[0x51] = KEY_KP_3,
|
||||
[0x52] = KEY_KP_0,
|
||||
[0x53] = KEY_KP_DECIMAL,
|
||||
[0x57] = KEY_F11,
|
||||
[0x58] = KEY_F12,
|
||||
[0x59] = KEY_KP_EQUAL,
|
||||
|
||||
// Duplicate scancodes
|
||||
[0x54] = KEY_PRINT_SCREEN, // Alt+PrtSc sends the SysRq scancode
|
||||
};
|
||||
|
||||
// Maps scancodes with extended-flag set to Raylib keys; lowest key is 0x1C
|
||||
static const unsigned short keyboardKeyFromExtendedScancode[] = {
|
||||
[0x1C - EXTENDED_KEY_OFFSET] = KEY_KP_ENTER,
|
||||
[0x1D - EXTENDED_KEY_OFFSET] = KEY_RIGHT_CONTROL,
|
||||
[0x35 - EXTENDED_KEY_OFFSET] = KEY_KP_DIVIDE,
|
||||
[0x37 - EXTENDED_KEY_OFFSET] = KEY_PRINT_SCREEN,
|
||||
[0x38 - EXTENDED_KEY_OFFSET] = KEY_RIGHT_ALT,
|
||||
[0x45 - EXTENDED_KEY_OFFSET] = KEY_NUM_LOCK,
|
||||
[0x47 - EXTENDED_KEY_OFFSET] = KEY_HOME,
|
||||
[0x48 - EXTENDED_KEY_OFFSET] = KEY_UP,
|
||||
[0x49 - EXTENDED_KEY_OFFSET] = KEY_PAGE_UP,
|
||||
[0x4B - EXTENDED_KEY_OFFSET] = KEY_LEFT,
|
||||
[0x4D - EXTENDED_KEY_OFFSET] = KEY_RIGHT,
|
||||
[0x4F - EXTENDED_KEY_OFFSET] = KEY_END,
|
||||
[0x50 - EXTENDED_KEY_OFFSET] = KEY_DOWN,
|
||||
[0x51 - EXTENDED_KEY_OFFSET] = KEY_PAGE_DOWN,
|
||||
[0x52 - EXTENDED_KEY_OFFSET] = KEY_INSERT,
|
||||
[0x53 - EXTENDED_KEY_OFFSET] = KEY_DELETE,
|
||||
[0x5B - EXTENDED_KEY_OFFSET] = KEY_LEFT_SUPER,
|
||||
[0x5C - EXTENDED_KEY_OFFSET] = KEY_RIGHT_SUPER,
|
||||
[0x5D - EXTENDED_KEY_OFFSET] = KEY_KB_MENU,
|
||||
|
||||
// Duplicate scancodes
|
||||
[0x46 - EXTENDED_KEY_OFFSET] = KEY_PAUSE, // Ctrl+Pause sends the Break scancode
|
||||
[0x36 - EXTENDED_KEY_OFFSET] = KEY_RIGHT_SHIFT, // Some keyboards set the extended bit on Right Shift
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// This part of the file contains pure functions that never access global state
|
||||
// This distinction helps keep the backend maintainable as the inputs and outputs
|
||||
@ -254,7 +374,10 @@ static bool DecoratedFromStyle(DWORD style)
|
||||
}
|
||||
|
||||
DWORD masked = (style & STYLE_FLAGS_UNDECORATED_OFF);
|
||||
if (STYLE_FLAGS_UNDECORATED_OFF != masked) TRACELOG(LOG_ERROR, "WIN32: FLAGS: Style 0x%x is missing flags 0x%x", masked, masked ^ STYLE_FLAGS_UNDECORATED_OFF);
|
||||
if (STYLE_FLAGS_UNDECORATED_OFF != masked)
|
||||
{
|
||||
TRACELOG(LOG_ERROR, "WIN32: FLAGS: Style 0x%x is missing flags 0x%x", masked, masked ^ STYLE_FLAGS_UNDECORATED_OFF);
|
||||
}
|
||||
|
||||
return true; // Decorated
|
||||
}
|
||||
@ -751,7 +874,7 @@ void SetWindowIcon(Image image)
|
||||
}
|
||||
}
|
||||
|
||||
// Set icon for window
|
||||
// Set icon for window (multiple sizes)
|
||||
void SetWindowIcons(Image *images, int count)
|
||||
{
|
||||
// TODO: Implement SetWindowIcons()
|
||||
@ -1310,22 +1433,10 @@ void PollInputEvents(void)
|
||||
}
|
||||
|
||||
// Windows will miss key up events for specific keys; check them manually
|
||||
if ((GetKeyState(VK_LSHIFT) & 0x8000) == 0)
|
||||
{
|
||||
CORE.Input.Keyboard.currentKeyState[KEY_LEFT_SHIFT] = 0;
|
||||
}
|
||||
if ((GetKeyState(VK_RSHIFT) & 0x8000) == 0)
|
||||
{
|
||||
CORE.Input.Keyboard.currentKeyState[KEY_RIGHT_SHIFT] = 0;
|
||||
}
|
||||
if ((GetKeyState(VK_LWIN) & 0x8000) == 0)
|
||||
{
|
||||
CORE.Input.Keyboard.currentKeyState[KEY_LEFT_SUPER] = 0;
|
||||
}
|
||||
if ((GetKeyState(VK_RWIN) & 0x8000) == 0)
|
||||
{
|
||||
CORE.Input.Keyboard.currentKeyState[KEY_RIGHT_SUPER] = 0;
|
||||
}
|
||||
if ((GetKeyState(VK_LSHIFT) & 0x8000) == 0) CORE.Input.Keyboard.currentKeyState[KEY_LEFT_SHIFT] = 0;
|
||||
if ((GetKeyState(VK_RSHIFT) & 0x8000) == 0) CORE.Input.Keyboard.currentKeyState[KEY_RIGHT_SHIFT] = 0;
|
||||
if ((GetKeyState(VK_LWIN) & 0x8000) == 0) CORE.Input.Keyboard.currentKeyState[KEY_LEFT_SUPER] = 0;
|
||||
if ((GetKeyState(VK_RWIN) & 0x8000) == 0) CORE.Input.Keyboard.currentKeyState[KEY_RIGHT_SUPER] = 0;
|
||||
|
||||
// Windows won't send a WM_KEYDOWN event for print screen; check it manually
|
||||
bool isPrintScreenDown = ((GetAsyncKeyState(VK_SNAPSHOT) & 0x8000) != 0) && (GetForegroundWindow() == platform.hwnd);
|
||||
@ -1336,7 +1447,6 @@ void PollInputEvents(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Initialize modern OpenGL context
|
||||
// NOTE: Creating a dummy context first to query required extensions
|
||||
HGLRC InitOpenGL(HWND hwnd, HDC hdc)
|
||||
@ -1427,14 +1537,8 @@ HGLRC InitOpenGL(HWND hwnd, HDC hdc)
|
||||
int pixelFormat = ChoosePixelFormat(hdc, &pixelFormatDesc);
|
||||
setPixelFormatSucceeded = SetPixelFormat(hdc, pixelFormat, &pixelFormatDesc);
|
||||
|
||||
if (setPixelFormatSucceeded)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "WGL: Using legacy pixel format, MSAA not available");
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACELOG(LOG_ERROR, "WGL: Unable to find a suitable pixel format with this graphics driver");
|
||||
}
|
||||
if (setPixelFormatSucceeded) TRACELOG(LOG_WARNING, "WGL: Using legacy pixel format, MSAA not available");
|
||||
else TRACELOG(LOG_ERROR, "WGL: Unable to find a suitable pixel format with this graphics driver");
|
||||
}
|
||||
|
||||
// Create real modern OpenGL context (3.3 core)
|
||||
@ -2068,7 +2172,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
|
||||
{
|
||||
case XBUTTON1: HandleMouseButton(MOUSE_BUTTON_SIDE, 1); break;
|
||||
case XBUTTON2: HandleMouseButton(MOUSE_BUTTON_EXTRA, 1); break;
|
||||
default: TRACELOG(LOG_WARNING, "TODO: handle ex mouse button DOWN wparam=%u", HIWORD(wparam)); break;
|
||||
default: TRACELOG(LOG_WARNING, "TODO: Handle ex mouse button DOWN [wparam=%u]", HIWORD(wparam)); break;
|
||||
}
|
||||
} break;
|
||||
case WM_XBUTTONUP:
|
||||
@ -2077,7 +2181,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
|
||||
{
|
||||
case XBUTTON1: HandleMouseButton(MOUSE_BUTTON_SIDE, 0); break;
|
||||
case XBUTTON2: HandleMouseButton(MOUSE_BUTTON_EXTRA, 0); break;
|
||||
default: TRACELOG(LOG_WARNING, "TODO: handle ex mouse button UP wparam=%u", HIWORD(wparam)); break;
|
||||
default: TRACELOG(LOG_WARNING, "TODO: Handle ex mouse button UP [wparam=%u]", HIWORD(wparam)); break;
|
||||
}
|
||||
} break;
|
||||
case WM_MOUSEWHEEL: CORE.Input.Mouse.currentWheelMove.y = ((float)GET_WHEEL_DELTA_WPARAM(wparam))/WHEEL_DELTA; break;
|
||||
@ -2101,129 +2205,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
|
||||
return result;
|
||||
}
|
||||
|
||||
// Maps scancodes to Raylib keys
|
||||
static const unsigned short keyboardKeyFromScancode[] =
|
||||
{
|
||||
[0x01] = KEY_ESCAPE,
|
||||
[0x02] = KEY_ONE,
|
||||
[0x03] = KEY_TWO,
|
||||
[0x04] = KEY_THREE,
|
||||
[0x05] = KEY_FOUR,
|
||||
[0x06] = KEY_FIVE,
|
||||
[0x07] = KEY_SIX,
|
||||
[0x08] = KEY_SEVEN,
|
||||
[0x09] = KEY_EIGHT,
|
||||
[0x0A] = KEY_NINE,
|
||||
[0x0B] = KEY_ZERO,
|
||||
[0x0C] = KEY_MINUS,
|
||||
[0x0D] = KEY_EQUAL,
|
||||
[0x0E] = KEY_BACKSPACE,
|
||||
[0x0F] = KEY_TAB,
|
||||
[0x10] = KEY_Q,
|
||||
[0x11] = KEY_W,
|
||||
[0x12] = KEY_E,
|
||||
[0x13] = KEY_R,
|
||||
[0x14] = KEY_T,
|
||||
[0x15] = KEY_Y,
|
||||
[0x16] = KEY_U,
|
||||
[0x17] = KEY_I,
|
||||
[0x18] = KEY_O,
|
||||
[0x19] = KEY_P,
|
||||
[0x1A] = KEY_LEFT_BRACKET,
|
||||
[0x1B] = KEY_RIGHT_BRACKET,
|
||||
[0x1C] = KEY_ENTER,
|
||||
[0x1D] = KEY_LEFT_CONTROL,
|
||||
[0x1E] = KEY_A,
|
||||
[0x1F] = KEY_S,
|
||||
[0x20] = KEY_D,
|
||||
[0x21] = KEY_F,
|
||||
[0x22] = KEY_G,
|
||||
[0x23] = KEY_H,
|
||||
[0x24] = KEY_J,
|
||||
[0x25] = KEY_K,
|
||||
[0x26] = KEY_L,
|
||||
[0x27] = KEY_SEMICOLON,
|
||||
[0x28] = KEY_APOSTROPHE,
|
||||
[0x29] = KEY_GRAVE,
|
||||
[0x2A] = KEY_LEFT_SHIFT,
|
||||
[0x2B] = KEY_BACKSLASH,
|
||||
[0x2C] = KEY_Z,
|
||||
[0x2D] = KEY_X,
|
||||
[0x2E] = KEY_C,
|
||||
[0x2F] = KEY_V,
|
||||
[0x30] = KEY_B,
|
||||
[0x31] = KEY_N,
|
||||
[0x32] = KEY_M,
|
||||
[0x33] = KEY_COMMA,
|
||||
[0x34] = KEY_PERIOD,
|
||||
[0x35] = KEY_SLASH,
|
||||
[0x36] = KEY_RIGHT_SHIFT,
|
||||
[0x37] = KEY_KP_MULTIPLY,
|
||||
[0x38] = KEY_LEFT_ALT,
|
||||
[0x39] = KEY_SPACE,
|
||||
[0x3A] = KEY_CAPS_LOCK,
|
||||
[0x3B] = KEY_F1,
|
||||
[0x3C] = KEY_F2,
|
||||
[0x3D] = KEY_F3,
|
||||
[0x3E] = KEY_F4,
|
||||
[0x3F] = KEY_F5,
|
||||
[0x40] = KEY_F6,
|
||||
[0x41] = KEY_F7,
|
||||
[0x42] = KEY_F8,
|
||||
[0x43] = KEY_F9,
|
||||
[0x44] = KEY_F10,
|
||||
[0x45] = KEY_PAUSE,
|
||||
[0x46] = KEY_SCROLL_LOCK,
|
||||
[0x47] = KEY_KP_7,
|
||||
[0x48] = KEY_KP_8,
|
||||
[0x49] = KEY_KP_9,
|
||||
[0x4A] = KEY_KP_SUBTRACT,
|
||||
[0x4B] = KEY_KP_4,
|
||||
[0x4C] = KEY_KP_5,
|
||||
[0x4D] = KEY_KP_6,
|
||||
[0x4E] = KEY_KP_ADD,
|
||||
[0x4F] = KEY_KP_1,
|
||||
[0x50] = KEY_KP_2,
|
||||
[0x51] = KEY_KP_3,
|
||||
[0x52] = KEY_KP_0,
|
||||
[0x53] = KEY_KP_DECIMAL,
|
||||
[0x57] = KEY_F11,
|
||||
[0x58] = KEY_F12,
|
||||
[0x59] = KEY_KP_EQUAL,
|
||||
|
||||
// Duplicate scancodes
|
||||
[0x54] = KEY_PRINT_SCREEN, // Alt+PrtSc sends the SysRq scancode
|
||||
};
|
||||
|
||||
// Maps scancodes with extended-flag set to Raylib keys; lowest key is 0x1C
|
||||
static const unsigned short keyboardKeyFromExtendedScancode[] =
|
||||
{
|
||||
[0x1C - EXTENDED_KEY_OFFSET] = KEY_KP_ENTER,
|
||||
[0x1D - EXTENDED_KEY_OFFSET] = KEY_RIGHT_CONTROL,
|
||||
[0x35 - EXTENDED_KEY_OFFSET] = KEY_KP_DIVIDE,
|
||||
[0x37 - EXTENDED_KEY_OFFSET] = KEY_PRINT_SCREEN,
|
||||
[0x38 - EXTENDED_KEY_OFFSET] = KEY_RIGHT_ALT,
|
||||
[0x45 - EXTENDED_KEY_OFFSET] = KEY_NUM_LOCK,
|
||||
[0x47 - EXTENDED_KEY_OFFSET] = KEY_HOME,
|
||||
[0x48 - EXTENDED_KEY_OFFSET] = KEY_UP,
|
||||
[0x49 - EXTENDED_KEY_OFFSET] = KEY_PAGE_UP,
|
||||
[0x4B - EXTENDED_KEY_OFFSET] = KEY_LEFT,
|
||||
[0x4D - EXTENDED_KEY_OFFSET] = KEY_RIGHT,
|
||||
[0x4F - EXTENDED_KEY_OFFSET] = KEY_END,
|
||||
[0x50 - EXTENDED_KEY_OFFSET] = KEY_DOWN,
|
||||
[0x51 - EXTENDED_KEY_OFFSET] = KEY_PAGE_DOWN,
|
||||
[0x52 - EXTENDED_KEY_OFFSET] = KEY_INSERT,
|
||||
[0x53 - EXTENDED_KEY_OFFSET] = KEY_DELETE,
|
||||
[0x5B - EXTENDED_KEY_OFFSET] = KEY_LEFT_SUPER,
|
||||
[0x5C - EXTENDED_KEY_OFFSET] = KEY_RIGHT_SUPER,
|
||||
[0x5D - EXTENDED_KEY_OFFSET] = KEY_KB_MENU,
|
||||
|
||||
// Duplicate scancodes
|
||||
[0x46 - EXTENDED_KEY_OFFSET] = KEY_PAUSE, // Ctrl+Pause sends the Break scancode
|
||||
[0x36 - EXTENDED_KEY_OFFSET] = KEY_RIGHT_SHIFT, // Some keyboards set the extended bit on Right Shift
|
||||
};
|
||||
|
||||
|
||||
// Handle keyboard input event
|
||||
static void HandleKey(WPARAM wparam, LPARAM lparam, char state)
|
||||
{
|
||||
@ -2241,18 +2222,12 @@ static void HandleKey(WPARAM wparam, LPARAM lparam, char state)
|
||||
{
|
||||
unsigned int index = scancode - EXTENDED_KEY_OFFSET;
|
||||
unsigned int arrayLength = sizeof(keyboardKeyFromExtendedScancode)/sizeof(keyboardKeyFromExtendedScancode[0]);
|
||||
if (index < arrayLength)
|
||||
{
|
||||
key = keyboardKeyFromExtendedScancode[index];
|
||||
}
|
||||
if (index < arrayLength) key = keyboardKeyFromExtendedScancode[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int arrayLength = sizeof(keyboardKeyFromScancode)/sizeof(keyboardKeyFromScancode[0]);
|
||||
if (scancode < arrayLength)
|
||||
{
|
||||
key = keyboardKeyFromScancode[scancode];
|
||||
}
|
||||
if (scancode < arrayLength) key = keyboardKeyFromScancode[scancode];
|
||||
}
|
||||
|
||||
bool ignoreKey = false;
|
||||
@ -2270,10 +2245,8 @@ static void HandleKey(WPARAM wparam, LPARAM lparam, char state)
|
||||
bool isNextExtendedKey = ((HIWORD(next.lParam) & KF_EXTENDED) != 0);
|
||||
if ((next.wParam == VK_MENU) && ((LONG)next.time == time) && isNextExtendedKey)
|
||||
{
|
||||
if ((next.message == WM_KEYDOWN) || (next.message == WM_SYSKEYDOWN) || (next.message == WM_KEYUP) || (next.message == WM_SYSKEYUP))
|
||||
{
|
||||
ignoreKey = true;
|
||||
}
|
||||
if ((next.message == WM_KEYDOWN) || (next.message == WM_SYSKEYDOWN) ||
|
||||
(next.message == WM_KEYUP) || (next.message == WM_SYSKEYUP)) ignoreKey = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2308,10 +2281,8 @@ static void HandleMouseButton(int button, char state)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allMouseButtonsReleased)
|
||||
{
|
||||
SetCapture(platform.hwnd);
|
||||
}
|
||||
|
||||
if (allMouseButtonsReleased) SetCapture(platform.hwnd);
|
||||
}
|
||||
|
||||
// Register current mouse button state
|
||||
@ -2330,10 +2301,8 @@ static void HandleMouseButton(int button, char state)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allMouseButtonsReleased)
|
||||
{
|
||||
ReleaseCapture();
|
||||
}
|
||||
|
||||
if (allMouseButtonsReleased) ReleaseCapture();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2352,9 +2321,9 @@ static void HandleRawInput(LPARAM lparam)
|
||||
|
||||
if (input.header.dwType != RIM_TYPEMOUSE) TRACELOG(LOG_ERROR, "WIN32: Unexpected WM_INPUT type %lu", input.header.dwType);
|
||||
|
||||
if (input.data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE) TRACELOG(LOG_ERROR, "TODO: handle absolute mouse inputs!");
|
||||
if (input.data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE) TRACELOG(LOG_ERROR, "TODO: Handle absolute mouse inputs");
|
||||
|
||||
if (input.data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) TRACELOG(LOG_ERROR, "TODO: handle virtual desktop mouse inputs!");
|
||||
if (input.data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) TRACELOG(LOG_ERROR, "TODO: Handle virtual desktop mouse inputs");
|
||||
|
||||
// Trick to keep the mouse position at (0,0) and instead move
|
||||
// the previous position so a proper mouse delta can still be retrieved
|
||||
@ -2521,7 +2490,7 @@ static void UpdateFlags(HWND hwnd, unsigned desiredFlags, int width, int height)
|
||||
else CORE.Window.flags &= ~FLAG_VSYNC_HINT;
|
||||
}
|
||||
|
||||
// TODO: Review all this code...
|
||||
// TODO: Review flags update code
|
||||
DWORD previousStyle = 0;
|
||||
for (unsigned attempt = 1; ; attempt++)
|
||||
{
|
||||
@ -2534,7 +2503,6 @@ static void UpdateFlags(HWND hwnd, unsigned desiredFlags, int width, int height)
|
||||
if ((FLAG_MASK_REQUIRED & desiredFlags) == (FLAG_MASK_REQUIRED & CORE.Window.flags)) break;
|
||||
}
|
||||
|
||||
|
||||
if ((attempt > 1) && (previousStyle == MakeWindowStyle(CORE.Window.flags)) && !windowSizeUpdated)
|
||||
{
|
||||
TRACELOG(LOG_ERROR, "WIN32: WINDOW: UpdateFlags() failed after %u attempt(s) wanted 0x%x but is 0x%x (diff=0x%x)",
|
||||
|
||||
@ -1430,24 +1430,28 @@ int InitPlatform(void)
|
||||
const char *eglClientExtensions = NULL;
|
||||
|
||||
// Get an EGL device connection
|
||||
// NOTE: eglGetPlatformDisplay() is preferred over eglGetDisplay() legacy call
|
||||
platform.device = EGL_NO_DISPLAY;
|
||||
#if defined(EGL_VERSION_1_5)
|
||||
|
||||
#if !defined(EGL_NO_GETPLATFORMDISPLAY_AVAILABLE)
|
||||
// WARNING: eglGetPlatformDisplay() is preferred over eglGetDisplay() legacy call but
|
||||
// on some devices (Mali GPUs: Mali-G31) symbol could not be available despite defining EGL_VERSION_1_5
|
||||
#if defined(EGL_VERSION_1_5)
|
||||
platform.device = eglGetPlatformDisplay(EGL_PLATFORM_GBM_KHR, platform.gbmDevice, NULL);
|
||||
#else
|
||||
#else
|
||||
// Check if extension is available for eglGetPlatformDisplayEXT()
|
||||
// NOTE: Better compatibility with some drivers (e.g. Mali Midgard)
|
||||
eglClientExtensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
|
||||
if ((eglClientExtensions != NULL) && (strstr(eglClientExtensions, "EGL_EXT_platform_base") != NULL))
|
||||
{
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||
|
||||
if (eglGetPlatformDisplayEXT != NULL) platform.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, platform.gbmDevice, NULL);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// In case extension not found or display could not be retrieved, try using legacy version
|
||||
if (platform.device == EGL_NO_DISPLAY) platform.device = eglGetDisplay((EGLNativeDisplayType)platform.gbmDevice);
|
||||
#endif
|
||||
|
||||
if (platform.device == EGL_NO_DISPLAY)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device");
|
||||
|
||||
@ -1111,7 +1111,7 @@ RLAPI void UnloadRandomSequence(int *sequence); // Unload random values
|
||||
|
||||
// Misc. functions
|
||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format)
|
||||
RLAPI void SetConfigFlags(unsigned int flags); // Set up init configuration flags (view FLAGS)
|
||||
RLAPI void SetConfigFlags(unsigned int flags); // Set init configuration flags (view FLAGS)
|
||||
RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)
|
||||
|
||||
// Logging system
|
||||
|
||||
@ -1590,6 +1590,7 @@ int GetFPS(void)
|
||||
#define FPS_STEP (FPS_AVERAGE_TIME_SECONDS/FPS_CAPTURE_FRAMES_COUNT)
|
||||
|
||||
static int index = 0;
|
||||
static unsigned int captureFramesCounted = 0;
|
||||
static float history[FPS_CAPTURE_FRAMES_COUNT] = { 0 };
|
||||
static float average = 0, last = 0;
|
||||
float fpsFrame = GetFrameTime();
|
||||
@ -1600,6 +1601,7 @@ int GetFPS(void)
|
||||
average = 0;
|
||||
last = 0;
|
||||
index = 0;
|
||||
captureFramesCounted = 0;
|
||||
|
||||
for (int i = 0; i < FPS_CAPTURE_FRAMES_COUNT; i++) history[i] = 0;
|
||||
}
|
||||
@ -1613,9 +1615,11 @@ int GetFPS(void)
|
||||
average -= history[index];
|
||||
history[index] = fpsFrame/FPS_CAPTURE_FRAMES_COUNT;
|
||||
average += history[index];
|
||||
|
||||
if (captureFramesCounted < FPS_CAPTURE_FRAMES_COUNT) captureFramesCounted += 1;
|
||||
}
|
||||
|
||||
fps = (int)roundf(1.0f/average);
|
||||
if (captureFramesCounted > 0) fps = (int)roundf(captureFramesCounted/(average*FPS_CAPTURE_FRAMES_COUNT));
|
||||
}
|
||||
else fps = 0;
|
||||
#endif
|
||||
|
||||
16
src/rlgl.h
16
src/rlgl.h
@ -5013,7 +5013,7 @@ static void rlLoadShaderDefault(void)
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_ES3)
|
||||
"#version 300 es \n"
|
||||
"precision mediump float; \n" // Precision required for OpenGL ES3 (WebGL 2) (on some browsers)
|
||||
"precision highp float; \n" // Precision highp is mandatory in vertex shaders, mediump may run as fp16 and misplace vertices
|
||||
"in vec3 vertexPosition; \n"
|
||||
"in vec2 vertexTexCoord; \n"
|
||||
"in vec4 vertexColor; \n"
|
||||
@ -5021,7 +5021,7 @@ static void rlLoadShaderDefault(void)
|
||||
"out vec4 fragColor; \n"
|
||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
||||
"#version 100 \n"
|
||||
"precision mediump float; \n" // Precision required for OpenGL ES2 (WebGL) (on some browsers)
|
||||
"precision highp float; \n" // Precision highp is mandatory in vertex shaders, mediump may run as fp16 and misplace vertices
|
||||
"attribute vec3 vertexPosition; \n"
|
||||
"attribute vec2 vertexTexCoord; \n"
|
||||
"attribute vec4 vertexColor; \n"
|
||||
@ -5066,7 +5066,11 @@ static void rlLoadShaderDefault(void)
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_ES3)
|
||||
"#version 300 es \n"
|
||||
"precision mediump float; \n" // Precision required for OpenGL ES3 (WebGL 2)
|
||||
"#ifdef GL_FRAGMENT_PRECISION_HIGH \n"
|
||||
"precision highp float; \n"
|
||||
"#else \n"
|
||||
"precision mediump float; \n"
|
||||
"#endif \n"
|
||||
"in vec2 fragTexCoord; \n"
|
||||
"in vec4 fragColor; \n"
|
||||
"out vec4 finalColor; \n"
|
||||
@ -5079,7 +5083,11 @@ static void rlLoadShaderDefault(void)
|
||||
"} \n";
|
||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
||||
"#version 100 \n"
|
||||
"precision mediump float; \n" // Precision required for OpenGL ES2 (WebGL)
|
||||
"#ifdef GL_FRAGMENT_PRECISION_HIGH \n"
|
||||
"precision highp float; \n"
|
||||
"#else \n"
|
||||
"precision mediump float; \n"
|
||||
"#endif \n"
|
||||
"varying vec2 fragTexCoord; \n"
|
||||
"varying vec4 fragColor; \n"
|
||||
"uniform sampler2D texture0; \n"
|
||||
|
||||
@ -4176,7 +4176,7 @@
|
||||
},
|
||||
{
|
||||
"name": "SetConfigFlags",
|
||||
"description": "Set up init configuration flags (view FLAGS)",
|
||||
"description": "Set init configuration flags (view FLAGS)",
|
||||
"returnType": "void",
|
||||
"params": [
|
||||
{
|
||||
|
||||
@ -3855,7 +3855,7 @@ return {
|
||||
},
|
||||
{
|
||||
name = "SetConfigFlags",
|
||||
description = "Set up init configuration flags (view FLAGS)",
|
||||
description = "Set init configuration flags (view FLAGS)",
|
||||
returnType = "void",
|
||||
params = {
|
||||
{type = "unsigned int", name = "flags"}
|
||||
|
||||
@ -2787,7 +2787,7 @@
|
||||
((type "const char *") (name "fileName"))))
|
||||
|
||||
((name "SetConfigFlags")
|
||||
(description "Set up init configuration flags (view FLAGS)")
|
||||
(description "Set init configuration flags (view FLAGS)")
|
||||
(return-type "void")
|
||||
(params
|
||||
((type "unsigned int") (name "flags"))))
|
||||
|
||||
@ -1558,7 +1558,7 @@ Function 104: TakeScreenshot() (1 input parameters)
|
||||
Function 105: SetConfigFlags() (1 input parameters)
|
||||
Name: SetConfigFlags
|
||||
Return type: void
|
||||
Description: Set up init configuration flags (view FLAGS)
|
||||
Description: Set init configuration flags (view FLAGS)
|
||||
Param[1]: flags (type: unsigned int)
|
||||
Function 106: OpenURL() (1 input parameters)
|
||||
Name: OpenURL
|
||||
|
||||
@ -984,7 +984,7 @@
|
||||
<Function name="TakeScreenshot" retType="void" paramCount="1" desc="Takes a screenshot of current screen (filename extension defines format)">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
</Function>
|
||||
<Function name="SetConfigFlags" retType="void" paramCount="1" desc="Set up init configuration flags (view FLAGS)">
|
||||
<Function name="SetConfigFlags" retType="void" paramCount="1" desc="Set init configuration flags (view FLAGS)">
|
||||
<Param type="unsigned int" name="flags" desc="" />
|
||||
</Function>
|
||||
<Function name="OpenURL" retType="void" paramCount="1" desc="Open URL with default system browser (if available)">
|
||||
|
||||
Reference in New Issue
Block a user