From 8f92315207484acd9858d64ae25aab6cbc5aa690 Mon Sep 17 00:00:00 2001 From: flyinghead Date: Sat, 21 Mar 2020 15:25:02 +0100 Subject: [PATCH] Use sdl on windows --- core/windows/winmain.cpp | 2 ++ core/wsi/sdl.cpp | 24 +++++++++++++++++++----- shell/linux/Makefile | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 6fb26ec03..85068c66f 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -370,6 +370,7 @@ static HWND hWnd; static bool windowClassRegistered; static int window_x, window_y; +#if !defined(USE_SDL) void CreateMainWindow() { if (hWnd != NULL) @@ -411,6 +412,7 @@ void CreateMainWindow() theGLContext.SetWindow(hWnd); theGLContext.SetDeviceContext(GetDC(hWnd)); } +#endif void os_CreateWindow() { diff --git a/core/wsi/sdl.cpp b/core/wsi/sdl.cpp index c8a478df6..efdbe3527 100644 --- a/core/wsi/sdl.cpp +++ b/core/wsi/sdl.cpp @@ -51,10 +51,21 @@ bool SDLGLGraphicsContext::Init() glcontext = SDL_GL_CreateContext(window); if (!glcontext) { - ERROR_LOG(RENDERER, "Error creating SDL GL context"); - SDL_DestroyWindow(window); - window = nullptr; - return false; +#ifndef GLES + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + glcontext = SDL_GL_CreateContext(window); + if (!glcontext) + { +#endif + ERROR_LOG(RENDERER, "Error creating SDL GL context"); + SDL_DestroyWindow(window); + window = nullptr; + return false; +#ifndef GLES + } +#endif } SDL_GL_MakeCurrent(window, NULL); @@ -69,8 +80,11 @@ bool SDLGLGraphicsContext::Init() SDL_GL_MakeCurrent(window, glcontext); #ifndef GLES - if (gl3wInit() == -1 || !gl3wIsSupported(3, 1)) + if (gl3wInit() == -1 || !gl3wIsSupported(3, 0)) + { + ERROR_LOG(RENDERER, "gl3wInit failed or GL 3.0 not supported"); return false; + } #endif PostInit(); diff --git a/shell/linux/Makefile b/shell/linux/Makefile index eeb507e66..da7eef524 100644 --- a/shell/linux/Makefile +++ b/shell/linux/Makefile @@ -268,6 +268,7 @@ else ifneq (,$(findstring win32,$(platform))) PLATFORM_EXT := exe CC = gcc CXX = g++ + USE_SDL = 1 ifeq ($(WITH_DYNAREC), x86) X86_REC := 1 LDFLAGS += -m32