Skip to content

Instantly share code, notes, and snippets.

@coldtobi
Created November 12, 2014 19:59
Show Gist options
  • Save coldtobi/7f26ea288f88b8d48e5d to your computer and use it in GitHub Desktop.
Save coldtobi/7f26ea288f88b8d48e5d to your computer and use it in GitHub Desktop.
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: no, waiting for other patches to be applied first.
Last-Update: 2014-10-19
---
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
@@ -187,32 +187,6 @@
#if SDL_VERSION_ATLEAST(2, 0, 0)
-#ifdef __APPLE__
- r_useOpenGL32.SetInteger( 2 ); // only core profile is supported on OS X
-#endif
-
- // 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 )
@@ -234,23 +208,50 @@
* "do fullscreen, but I don't care on what monitor", at least on my box it's the monitor with
* the mouse cursor.
*/
-
-
+
window = SDL_CreateWindow( GAME_NAME,
windowPos,
windowPos,
parms.width, parms.height, flags );
// DG end
-
+
+ if( !window )
+ {
+ common->DPrintf( "Couldn't set GL mode %d/%d/%d: %s",
+ channelcolorbits, tdepthbits, tstencilbits, SDL_GetError() );
+ continue;
+ }
+
context = SDL_GL_CreateContext( window );
-
- if( !window )
- {
- common->DPrintf( "Couldn't set GL mode %d/%d/%d: %s",
- channelcolorbits, tdepthbits, tstencilbits, SDL_GetError() );
- continue;
- }
-
+ SDL_GL_MakeCurrent(window, context);
+
+#ifdef __APPLE__
+ r_useOpenGL32.SetInteger( 2 ); // only core profile is supported on OS X
+#endif
+
+ // 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 );
+ }
+ }
+ // Is a else required here for OPENGL 2.0?
+
+
+ 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" );
QA Timing INIT: 000878ms
RBDOOM 3 BFG 1.0.2.1401 linux-x86_86 Nov 12 2014 20:19:35
found interface lo - loopback
found interface eth0 - 10.243.48.20/255.255.255.0
no 'base' directory in exe path /home/tobi/workspace/debian-building/maybe/doom3-engine/bfg/upstream/coldtobi/RBDOOM-3-BFG/obj-x86_64-linux-gnu, skipping
WARNING: using hardcoded default base path /usr/share/games/doom3bfg
------ Initializing File System ------
Loaded resource file _common.resources
Loaded resource file _ordered.resources
Loaded resource file _sound_pc.resources
Loaded resource file _sound_pc_en.resources
Loaded resource file maps/admin.resources
Loaded resource file maps/alphalabs1.resources
Loaded resource file maps/alphalabs2.resources
Loaded resource file maps/alphalabs3.resources
Loaded resource file maps/alphalabs4.resources
Loaded resource file maps/caverns1.resources
Loaded resource file maps/caverns2.resources
Loaded resource file maps/comm1.resources
Loaded resource file maps/commoutside.resources
Loaded resource file maps/cpu.resources
Loaded resource file maps/cpuboss.resources
Loaded resource file maps/d3ctf1.resources
Loaded resource file maps/d3ctf2.resources
Loaded resource file maps/d3ctf3.resources
Loaded resource file maps/d3ctf4.resources
Loaded resource file maps/d3dm1.resources
Loaded resource file maps/d3dm2.resources
Loaded resource file maps/d3dm3.resources
Loaded resource file maps/d3dm4.resources
Loaded resource file maps/d3dm5.resources
Loaded resource file maps/d3xpdm1.resources
Loaded resource file maps/d3xpdm2.resources
Loaded resource file maps/d3xpdm3.resources
Loaded resource file maps/d3xpdm4.resources
Loaded resource file maps/delta1.resources
Loaded resource file maps/delta2a.resources
Loaded resource file maps/delta2b.resources
Loaded resource file maps/delta3.resources
Loaded resource file maps/delta4.resources
Loaded resource file maps/delta5.resources
Loaded resource file maps/deltax.resources
Loaded resource file maps/enpro.resources
Loaded resource file maps/erebus1.resources
Loaded resource file maps/erebus2.resources
Loaded resource file maps/erebus3.resources
Loaded resource file maps/erebus4.resources
Loaded resource file maps/erebus5.resources
Loaded resource file maps/erebus6.resources
Loaded resource file maps/hell.resources
Loaded resource file maps/hell1.resources
Loaded resource file maps/hellhole.resources
Loaded resource file maps/le_enpro1.resources
Loaded resource file maps/le_enpro2.resources
Loaded resource file maps/le_exis1.resources
Loaded resource file maps/le_exis2.resources
Loaded resource file maps/le_hell.resources
Loaded resource file maps/le_hell_post.resources
Loaded resource file maps/le_underground.resources
Loaded resource file maps/le_underground2.resources
Loaded resource file maps/mars_city1.resources
Loaded resource file maps/mars_city2.resources
Loaded resource file maps/mc_underground.resources
Loaded resource file maps/monorail.resources
Loaded resource file maps/phobos1.resources
Loaded resource file maps/phobos2.resources
Loaded resource file maps/phobos3.resources
Loaded resource file maps/phobos4.resources
Loaded resource file maps/recycling1.resources
Loaded resource file maps/recycling2.resources
Loaded resource file maps/site3.resources
Current search path:
/home/tobi/.rbdoom3bfg/base
/usr/share/games/doom3bfg/base
_common.resources
_ordered.resources
_sound_pc.resources
_sound_pc_en.resources
maps/admin.resources
maps/alphalabs1.resources
maps/alphalabs2.resources
maps/alphalabs3.resources
maps/alphalabs4.resources
maps/caverns1.resources
maps/caverns2.resources
maps/comm1.resources
maps/commoutside.resources
maps/cpu.resources
maps/cpuboss.resources
maps/d3ctf1.resources
maps/d3ctf2.resources
maps/d3ctf3.resources
maps/d3ctf4.resources
maps/d3dm1.resources
maps/d3dm2.resources
maps/d3dm3.resources
maps/d3dm4.resources
maps/d3dm5.resources
maps/d3xpdm1.resources
maps/d3xpdm2.resources
maps/d3xpdm3.resources
maps/d3xpdm4.resources
maps/delta1.resources
maps/delta2a.resources
maps/delta2b.resources
maps/delta3.resources
maps/delta4.resources
maps/delta5.resources
maps/deltax.resources
maps/enpro.resources
maps/erebus1.resources
maps/erebus2.resources
maps/erebus3.resources
maps/erebus4.resources
maps/erebus5.resources
maps/erebus6.resources
maps/hell.resources
maps/hell1.resources
maps/hellhole.resources
maps/le_enpro1.resources
maps/le_enpro2.resources
maps/le_exis1.resources
maps/le_exis2.resources
maps/le_hell.resources
maps/le_hell_post.resources
maps/le_underground.resources
maps/le_underground2.resources
maps/mars_city1.resources
maps/mars_city2.resources
maps/mc_underground.resources
maps/monorail.resources
maps/phobos1.resources
maps/phobos2.resources
maps/phobos3.resources
maps/phobos4.resources
maps/recycling1.resources
maps/recycling2.resources
maps/site3.resources
file system initialized.
--------------------------------------
WARNING: Unable to open resource file maps/_startup.resources
----- Initializing Decls -----
------------------------------
Couldn't open journal files
/proc/cpuinfo CPU processors: 3
/proc/cpuinfo CPU logical cores: 3
execing default.cfg
execing D3BFGConfig.cfg
couldn't exec autoexec.cfg
----- R_InitOpenGL -----
Initializing OpenGL subsystem
Using 8 color bits, 24 depth, 8 stencil display
Using GLEW 1.11.0
OpenGL Version : 4.4
OpenGL Vendor : NVIDIA Corporation
OpenGL Renderer : GeForce GTX 470/PCIe/SSE2
OpenGL GLSL : 4.4
maxTextureAnisotropy: 16.000000
...using GL_EXT_texture_lod_bias
X..GL_GREMEDY_string_marker not found
...using GL_EXT_framebuffer_object
...using GL_EXT_framebuffer_blit
----- Initializing Render Shaders -----
----- Initializing Sound System ------
Setup OpenAL device and context... Done.
OpenAL vendor: OpenAL Community
OpenAL renderer: OpenAL Soft
OpenAL version: 1.1 ALSOFT 1.15.1
OpenAL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
sound system initialized.
--------------------------------------
------- Initializing renderSystem --------
Updating texture filter parameters.
renderSystem initialized.
--------------------------------------
Skipping Intro Videos!
Reading strings/english.lang as UTF-8
9104 strings read
--------- Initializing Game ----------
gamename: baseDOOM-1
gamedate: Nov 12 2014
Initializing event system
...535 event definitions
Initializing class hierarchy
...158 classes, 992960 bytes for event callbacks
Initializing scripts
/proc/cpuinfo CPU frequency: 800 MHz
Compiled '/usr/share/games/doom3bfg/base/script/doom_main.script': 2704.4 ms
---------- Compile stats ----------
Memory usage:
Strings: 120, 15840 bytes
Statements: 95386, 3815440 bytes
Functions: 3070, 496728 bytes
Variables: 239712 bytes
Mem used: 6284512 bytes
Static data: 6266520 bytes
Allocated: 8567312 bytes
Thread size: 14064 bytes
...6 aas types
game initialized.
--------------------------------------
Loaded FFMPEG file: 'video/intro/introloop.bik', looping=1512x512, 30.000000 FPS, 12.000000 sec
Loaded FFMPEG file: 'video/mars1.bik', looping=0512x512, 30.000000 FPS, 32.166668 sec
Loaded FFMPEG file: 'video/mars_rotation.bik', looping=11567x406, 30.000000 FPS, 100.000000 sec
----- idRenderModelManagerLocal::EndLevelLoad -----
0 models purged from previous level, 3 models kept.
---------------------------------------------------
----- idImageManager::EndLevelLoad -----
30 images loaded in 0.0 seconds
----------------------------------------
----- idSoundSystemLocal::EndLevelLoad -----
7 sounds loaded in 0.1 seconds
----------------------------------------
------------- Warnings ---------------
during DOOM 3: BFG Edition initialization...
WARNING: Unable to open resource file maps/_startup.resources
1 warnings
Preloading images...
00362 images preloaded ( or were already loaded ) in 0.2 seconds
----------------------------------------
00259 sounds preloaded in 0.2 seconds
----------------------------------------
WARNING: Couldn't load image: _doomclassic : _doomclassic#__0200
--- Common Initialization Complete ---
QA Timing IIS: 006579ms
terminal support enabled ( use +set in_tty 0 to disabled )
pid: 29133
session->GetSaveGameManager().CancelToTerminate();
soundSystem->StopAllSounds();
Stop();
--------- Game Map Shutdown ----------
--------------------------------------
CleanupShell();
delete loadGUI;
delete renderWorld;
delete soundWorld;
delete menuSoundWorld;
session->ShutdownSoundRelatedSystems();
session->Shutdown();
game->Leaderboards_Shutdown();
uiManager->Shutdown();
soundSystem->Shutdown();
usercmdGen->Shutdown();
eventLoop->Shutdown();
declManager->Shutdown();
renderSystem->Shutdown();
idRenderSystem::Shutdown()
Shutting down OpenGL subsystem
commonDialog.Shutdown();
UnloadGameDLL();
------------ Game Shutdown -----------
--------- Game Map Shutdown ----------
--------------------------------------
Shutdown event system
--------------------------------------
saveFile.Clear( true );
stringsFile.Clear( true );
CloseLogFile();
fileSystem->Shutdown( false );
Sys_Shutdown();
console->Shutdown();
idKeyInput::Shutdown();
cvarSystem->Shutdown();
cmdSystem->Shutdown();
ClearWarnings( GAME_NAME " shutdown" );
warningCaption.Clear();
errorList.Clear();
idLib::ShutDown();
shutdown terminal support
QA Timing INIT: 000824ms
RBDOOM 3 BFG 1.0.2.1401 linux-x86_86 Nov 12 2014 20:33:00
found interface lo - loopback
found interface eth0 - 10.243.48.20/255.255.255.0
no 'base' directory in exe path /home/tobi/workspace/debian-building/maybe/doom3-engine/bfg/upstream/coldtobi/RBDOOM-3-BFG/obj-x86_64-linux-gnu, skipping
WARNING: using hardcoded default base path /usr/share/games/doom3bfg
------ Initializing File System ------
Loaded resource file _common.resources
Loaded resource file _ordered.resources
Loaded resource file _sound_pc.resources
Loaded resource file _sound_pc_en.resources
Loaded resource file maps/admin.resources
Loaded resource file maps/alphalabs1.resources
Loaded resource file maps/alphalabs2.resources
Loaded resource file maps/alphalabs3.resources
Loaded resource file maps/alphalabs4.resources
Loaded resource file maps/caverns1.resources
Loaded resource file maps/caverns2.resources
Loaded resource file maps/comm1.resources
Loaded resource file maps/commoutside.resources
Loaded resource file maps/cpu.resources
Loaded resource file maps/cpuboss.resources
Loaded resource file maps/d3ctf1.resources
Loaded resource file maps/d3ctf2.resources
Loaded resource file maps/d3ctf3.resources
Loaded resource file maps/d3ctf4.resources
Loaded resource file maps/d3dm1.resources
Loaded resource file maps/d3dm2.resources
Loaded resource file maps/d3dm3.resources
Loaded resource file maps/d3dm4.resources
Loaded resource file maps/d3dm5.resources
Loaded resource file maps/d3xpdm1.resources
Loaded resource file maps/d3xpdm2.resources
Loaded resource file maps/d3xpdm3.resources
Loaded resource file maps/d3xpdm4.resources
Loaded resource file maps/delta1.resources
Loaded resource file maps/delta2a.resources
Loaded resource file maps/delta2b.resources
Loaded resource file maps/delta3.resources
Loaded resource file maps/delta4.resources
Loaded resource file maps/delta5.resources
Loaded resource file maps/deltax.resources
Loaded resource file maps/enpro.resources
Loaded resource file maps/erebus1.resources
Loaded resource file maps/erebus2.resources
Loaded resource file maps/erebus3.resources
Loaded resource file maps/erebus4.resources
Loaded resource file maps/erebus5.resources
Loaded resource file maps/erebus6.resources
Loaded resource file maps/hell.resources
Loaded resource file maps/hell1.resources
Loaded resource file maps/hellhole.resources
Loaded resource file maps/le_enpro1.resources
Loaded resource file maps/le_enpro2.resources
Loaded resource file maps/le_exis1.resources
Loaded resource file maps/le_exis2.resources
Loaded resource file maps/le_hell.resources
Loaded resource file maps/le_hell_post.resources
Loaded resource file maps/le_underground.resources
Loaded resource file maps/le_underground2.resources
Loaded resource file maps/mars_city1.resources
Loaded resource file maps/mars_city2.resources
Loaded resource file maps/mc_underground.resources
Loaded resource file maps/monorail.resources
Loaded resource file maps/phobos1.resources
Loaded resource file maps/phobos2.resources
Loaded resource file maps/phobos3.resources
Loaded resource file maps/phobos4.resources
Loaded resource file maps/recycling1.resources
Loaded resource file maps/recycling2.resources
Loaded resource file maps/site3.resources
Current search path:
/home/tobi/.rbdoom3bfg/base
/usr/share/games/doom3bfg/base
_common.resources
_ordered.resources
_sound_pc.resources
_sound_pc_en.resources
maps/admin.resources
maps/alphalabs1.resources
maps/alphalabs2.resources
maps/alphalabs3.resources
maps/alphalabs4.resources
maps/caverns1.resources
maps/caverns2.resources
maps/comm1.resources
maps/commoutside.resources
maps/cpu.resources
maps/cpuboss.resources
maps/d3ctf1.resources
maps/d3ctf2.resources
maps/d3ctf3.resources
maps/d3ctf4.resources
maps/d3dm1.resources
maps/d3dm2.resources
maps/d3dm3.resources
maps/d3dm4.resources
maps/d3dm5.resources
maps/d3xpdm1.resources
maps/d3xpdm2.resources
maps/d3xpdm3.resources
maps/d3xpdm4.resources
maps/delta1.resources
maps/delta2a.resources
maps/delta2b.resources
maps/delta3.resources
maps/delta4.resources
maps/delta5.resources
maps/deltax.resources
maps/enpro.resources
maps/erebus1.resources
maps/erebus2.resources
maps/erebus3.resources
maps/erebus4.resources
maps/erebus5.resources
maps/erebus6.resources
maps/hell.resources
maps/hell1.resources
maps/hellhole.resources
maps/le_enpro1.resources
maps/le_enpro2.resources
maps/le_exis1.resources
maps/le_exis2.resources
maps/le_hell.resources
maps/le_hell_post.resources
maps/le_underground.resources
maps/le_underground2.resources
maps/mars_city1.resources
maps/mars_city2.resources
maps/mc_underground.resources
maps/monorail.resources
maps/phobos1.resources
maps/phobos2.resources
maps/phobos3.resources
maps/phobos4.resources
maps/recycling1.resources
maps/recycling2.resources
maps/site3.resources
file system initialized.
--------------------------------------
WARNING: Unable to open resource file maps/_startup.resources
----- Initializing Decls -----
------------------------------
Couldn't open journal files
/proc/cpuinfo CPU processors: 3
/proc/cpuinfo CPU logical cores: 3
execing default.cfg
execing D3BFGConfig.cfg
couldn't exec autoexec.cfg
----- R_InitOpenGL -----
Initializing OpenGL subsystem
Using 8 color bits, 24 depth, 8 stencil display
Using GLEW 1.11.0
OpenGL Version : 3.2
OpenGL Vendor : NVIDIA Corporation
OpenGL Renderer : GeForce GTX 470/PCIe/SSE2
OpenGL GLSL : 1.5
...using GL_EXT_texture_lod_bias
X..GL_GREMEDY_string_marker not found
X..GL_EXT_framebuffer_object not found
X..GL_EXT_framebuffer_object not found
TODO: Sys_SetClipboardData
--------- Game Map Shutdown ----------
--------------------------------------
Setup OpenAL device and context... Done.
OpenAL vendor: OpenAL Community
OpenAL renderer: OpenAL Soft
OpenAL version: 1.1 ALSOFT 1.15.1
OpenAL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
********************
ERROR: GL_ARB_texture_compression or GL_EXT_texture_compression_s3tc not available
********************
Sys_Error: Error during initialization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment