summarylogtreecommitdiffstats
path: root/30-init-sdl2.patch
diff options
context:
space:
mode:
Diffstat (limited to '30-init-sdl2.patch')
-rw-r--r--30-init-sdl2.patch98
1 files changed, 98 insertions, 0 deletions
diff --git a/30-init-sdl2.patch b/30-init-sdl2.patch
new file mode 100644
index 000000000000..df6cd657f7cd
--- /dev/null
+++ b/30-init-sdl2.patch
@@ -0,0 +1,98 @@
+Description: Fix SDL2 initialistion
+ SDL_GL_* should only be called after the window created.
+ Also, SDL_GL_MakeCurrent seems necessary.
+Author: Tobias Frost <tobi@debian.org>
+Forwarded: https://github.com/RobertBeckeba06/RBDOOM-3-BFG/issues/205
+Forwarded: https://github.com/RobertBeckebans/RBDOOM-3-BFG/pull/251
+Last-Update: 2014-12-06
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/neo/sys/sdl/sdl_glimp.cpp
++++ b/neo/sys/sdl/sdl_glimp.cpp
+@@ -49,15 +49,7 @@
+ idCVar r_waylandcompat( "r_waylandcompat", "0", CVAR_SYSTEM | CVAR_NOCHEAT | CVAR_ARCHIVE, "wayland compatible framebuffer" );
+
+ // RB: only relevant if using SDL 2.0
+-#if defined(__APPLE__)
+-// only core profile is supported on OS X
+-idCVar r_useOpenGL32( "r_useOpenGL32", "2", CVAR_INTEGER, "0 = OpenGL 3.x, 1 = OpenGL 3.2 compatibility profile, 2 = OpenGL 3.2 core profile", 0, 2 );
+-#elif defined(__linux__)
+-// Linux open source drivers suck
+-idCVar r_useOpenGL32( "r_useOpenGL32", "0", CVAR_INTEGER, "0 = OpenGL 3.x, 1 = OpenGL 3.2 compatibility profile, 2 = OpenGL 3.2 core profile", 0, 2 );
+-#else
+-idCVar r_useOpenGL32( "r_useOpenGL32", "1", CVAR_INTEGER, "0 = OpenGL 3.x, 1 = OpenGL 3.2 compatibility profile, 2 = OpenGL 3.2 core profile", 0, 2 );
+-#endif
++idCVar r_useOpenGL32( "r_useOpenGL32", "1", CVAR_INTEGER, "0 = OpenGL 2.0, 1 = OpenGL 3.2 compatibility profile, 2 = OpenGL 3.2 core profile", 0, 2 );
+ // RB end
+
+ static bool grabbed = false;
+@@ -195,28 +187,6 @@
+
+ #if SDL_VERSION_ATLEAST(2, 0, 0)
+
+- // RB begin
+- if( r_useOpenGL32.GetInteger() > 0 )
+- {
+- glConfig.driverType = GLDRV_OPENGL32_COMPATIBILITY_PROFILE;
+-
+- SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
+- SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 2 );
+-
+- if( r_debugContext.GetBool() )
+- {
+- SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG );
+- }
+- }
+-
+- if( r_useOpenGL32.GetInteger() > 1 )
+- {
+- glConfig.driverType = GLDRV_OPENGL32_CORE_PROFILE;
+-
+- SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
+- }
+- // RB end
+-
+ // DG: set display num for fullscreen
+ int windowPos = SDL_WINDOWPOS_UNDEFINED;
+ if( parms.fullScreen > 0 )
+@@ -246,8 +216,6 @@
+ parms.width, parms.height, flags );
+ // DG end
+
+- context = SDL_GL_CreateContext( window );
+-
+ if( !window )
+ {
+ common->DPrintf( "Couldn't set GL mode %d/%d/%d: %s",
+@@ -255,6 +223,31 @@
+ continue;
+ }
+
++ context = SDL_GL_CreateContext( window );
++ SDL_GL_MakeCurrent(window, context);
++
++ // RB begin
++ if( r_useOpenGL32.GetInteger() > 0 )
++ {
++ glConfig.driverType = GLDRV_OPENGL32_COMPATIBILITY_PROFILE;
++
++ SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
++ SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 2 );
++
++ if( r_debugContext.GetBool() )
++ {
++ SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG );
++ }
++ }
++
++ if( r_useOpenGL32.GetInteger() > 1 )
++ {
++ glConfig.driverType = GLDRV_OPENGL32_CORE_PROFILE;
++
++ SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
++ }
++ // RB end
++
+ if( SDL_GL_SetSwapInterval( r_swapInterval.GetInteger() ) < 0 )
+ common->Warning( "SDL_GL_SWAP_CONTROL not supported" );
+