Explorar el Código

Check for Vulkan or Metal request and don't force OpenGL (#666)

Ryan Cleven hace 1 año
padre
commit
1d54fc5734
Se han modificado 2 ficheros con 12 adiciones y 2 borrados
  1. 11 2
      libs/sdl/sdl.c
  2. 1 0
      libs/sdl/sdl/Window.hx

+ 11 - 2
libs/sdl/sdl.c

@@ -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>
@@ -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

+ 1 - 0
libs/sdl/sdl/Window.hx

@@ -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;