From 988653e01ebbc59ad182cbca622a5a027a6eec49 Mon Sep 17 00:00:00 2001 From: Jacob Coby Date: Sun, 28 Apr 2024 10:14:26 -0400 Subject: [PATCH] Grab mouse after SDL_SetVideoMode Fixes mouse cursor not being grabbed on macOS. Also sets the `ddio_mouseGrabbed` flag correctly so it can be detected later on. Fixes #201 --- renderer/HardwareOpenGL.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/renderer/HardwareOpenGL.cpp b/renderer/HardwareOpenGL.cpp index 55e333c8..11f5c091 100644 --- a/renderer/HardwareOpenGL.cpp +++ b/renderer/HardwareOpenGL.cpp @@ -1,5 +1,5 @@ /* -* Descent 3 +* Descent 3 * Copyright (C) 2024 Parallax Software * * This program is free software: you can redistribute it and/or modify @@ -693,18 +693,20 @@ int opengl_Setup(oeApplication *app, int *width, int *height) { flags |= SDL_FULLSCREEN; } + // Should we shoot for 32-bpp if available? !!! + SDL_Surface *surface = SDL_SetVideoMode(*width, *height, 32, flags); + mprintf((0, "OpenGL: SDL GL surface is %sNULL.", (surface == NULL) ? "" : "NOT ")); + if (!FindArg("-nomousecap")) { // ShowCursor(0) and input grabbing need to be done before setting // the video mode, or the Voodoo 3 gets a hardware cursor stuck // on the screen. + // On modern systems this is not necessary and must be done after to take effect. SDL_ShowCursor(0); SDL_WM_GrabInput(SDL_GRAB_ON); + ddio_mouseGrabbed = true; } - // Should we shoot for 32-bpp if available? !!! - SDL_Surface *surface = SDL_SetVideoMode(*width, *height, 32, flags); - mprintf((0, "OpenGL: SDL GL surface is %sNULL.", (surface == NULL) ? "" : "NOT ")); - if (ddio_mouseGrabbed == false) { SDL_WM_GrabInput(SDL_GRAB_OFF); }