Browse Source

3.2 core by default

Nicolas Cannasse 8 years ago
parent
commit
70c3a070e1
2 changed files with 13 additions and 8 deletions
  1. 9 6
      libs/sdl/sdl.c
  2. 4 2
      libs/sdl/sdl/Window.hx

+ 9 - 6
libs/sdl/sdl.c

@@ -75,14 +75,10 @@ HL_PRIM bool HL_NAME(init_once)() {
 	// Set the internal windows timer period to 1ms (will give accurate sleep for vsync)
 	timeBeginPeriod(1);
 #	endif
-
+	// default GL parameters
 	SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
 	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
-	#ifdef HL_MAC
 	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
-	#else
-	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
-	#endif
 	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
 	SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
 	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
@@ -96,7 +92,14 @@ HL_PRIM void HL_NAME(gl_options)( int major, int minor, int depth, int stencil,
 	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depth);
 	SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencil);
 	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, (flags&1));
-	SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, (flags&2) ? SDL_GL_CONTEXT_PROFILE_CORE : (flags&4) ? SDL_GL_CONTEXT_PROFILE_ES : SDL_GL_CONTEXT_PROFILE_COMPATIBILITY );
+	if( flags&2 )
+		SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
+	else if( flags&4 )
+		SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
+	else if( flags&8 )
+		SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
+	else
+		SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0); // auto
 }
 
 HL_PRIM bool HL_NAME(event_loop)( event_data *event ) {

+ 4 - 2
libs/sdl/sdl/Window.hx

@@ -30,8 +30,10 @@ class Window {
 		win = winCreate(@:privateAccess title.toUtf8(), width, height);
 		if( win == null ) throw "Failed to create window";
 		glctx = winGetGLContext(win);
-		if( glctx == null ) throw "Failed to init GL Context (OpenGL 2.1 required)";
-		if( !GL.init() ) throw "Failed to init GL API";
+		if( glctx == null )
+			throw "Failed to init GL Context (OpenGL 3.2+ required)";
+		if( !GL.init() )
+			throw "Failed to init GL API";
 		windows.push(this);
 		vsync = true;
 	}