Skip to content

Commit

Permalink
Check for Vulkan or Metal request and don't force OpenGL (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
onehundredfeet authored Apr 6, 2024
1 parent f7fafd1 commit 1d54fc5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions libs/sdl/sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#if defined(_WIN32) || defined(__ANDROID__) || defined(HL_IOS) || defined(HL_TVOS)
# include <SDL.h>
# include <SDL_vulkan.h>
# include <SDL_syswm.h>
#else
# include <SDL2/SDL.h>
Expand Down Expand Up @@ -515,12 +516,20 @@ DEFINE_PRIM(_BOOL, hint_value, _BYTES _BYTES);

HL_PRIM SDL_Window *HL_NAME(win_create_ex)(int x, int y, int width, int height, int sdlFlags) {
// force window to match device resolution on mobile
if (sdlFlags & (
#ifdef HL_MAC
SDL_WINDOW_METAL |
#endif
SDL_WINDOW_VULKAN ) == 0) {
sdlFlags |= SDL_WINDOW_OPENGL;
}

#ifdef HL_MOBILE
SDL_DisplayMode displayMode;
SDL_GetDesktopDisplayMode(0, &displayMode);
SDL_Window* win = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | sdlFlags);
SDL_Window* win = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_BORDERLESS | sdlFlags);
#else
SDL_Window* win = SDL_CreateWindow("", x, y, width, height, SDL_WINDOW_OPENGL | sdlFlags);
SDL_Window* win = SDL_CreateWindow("", x, y, width, height, sdlFlags);
#endif
# ifdef HL_WIN
// force window to show even if the debugger force process windows to be hidden
Expand Down
1 change: 1 addition & 0 deletions libs/sdl/sdl/Window.hx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Window {
public static inline var SDL_WINDOW_TOOLTIP = 0x00040000;
public static inline var SDL_WINDOW_POPUP_MENU = 0x00080000;
public static inline var SDL_WINDOW_VULKAN = 0x10000000;
public static inline var SDL_WINDOW_METAL = 0x20000000;

var win : WinPtr;
var glctx : GLContext;
Expand Down

0 comments on commit 1d54fc5

Please sign in to comment.