Browse Source

sdl: vid: fix washed out screen on Windows and probably other platforms(#50)

pull/2/head
Alibek Omarov 6 years ago
parent
commit
eb22ff53c4
  1. 62
      engine/platform/sdl/vid_sdl.c
  2. 14
      engine/ref_api.h

62
engine/platform/sdl/vid_sdl.c

@ -712,27 +712,73 @@ void GL_SwapBuffers()
SDL_GL_SwapWindow( host.hWnd ); SDL_GL_SwapWindow( host.hWnd );
} }
int GL_SetAttribute( int attr, int val ) int GL_SetAttribute( int attr, int val )
{ {
switch( attr ) switch( attr )
{ {
#define MAP_REF_API_ATTRIBUTE_TO_SDL( name ) case REF_##name: return SDL_GL_SetAttribute( SDL_##name, val );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_RED_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_GREEN_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_BLUE_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_ALPHA_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_DOUBLEBUFFER );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_DEPTH_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_STENCIL_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLEBUFFERS );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLESAMPLES );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_ACCELERATED_VISUAL );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MAJOR_VERSION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MINOR_VERSION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_EGL );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_FLAGS );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_SHARE_WITH_CURRENT_CONTEXT );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_FRAMEBUFFER_SRGB_CAPABLE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RELEASE_BEHAVIOR );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RESET_NOTIFICATION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_NO_ERROR );
case REF_GL_CONTEXT_PROFILE_MASK: case REF_GL_CONTEXT_PROFILE_MASK:
#ifdef SDL_HINT_OPENGL_ES_DRIVER #ifdef SDL_HINT_OPENGL_ES_DRIVER
if( val == REF_GL_CONTEXT_PROFILE_ES ) if (val == REF_GL_CONTEXT_PROFILE_ES)
SDL_SetHint( SDL_HINT_OPENGL_ES_DRIVER, "1" ); SDL_SetHint(SDL_HINT_OPENGL_ES_DRIVER, "1");
#endif // SDL_HINT_OPENGL_ES_DRIVER #endif // SDL_HINT_OPENGL_ES_DRIVER
break; return SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, val );
default: #undef MAP_REF_API_ATTRIBUTE_TO_SDL
break;
} }
return SDL_GL_SetAttribute( (SDL_GLattr)attr, val ); ASSERT( 0 );
return -1;
} }
int GL_GetAttribute( int attr, int *val ) int GL_GetAttribute( int attr, int *val )
{ {
return SDL_GL_GetAttribute( (SDL_GLattr)attr, val ); switch( attr )
{
#define MAP_REF_API_ATTRIBUTE_TO_SDL( name ) case REF_##name: return SDL_GL_GetAttribute( SDL_##name, val );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_RED_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_GREEN_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_BLUE_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_ALPHA_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_DOUBLEBUFFER );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_DEPTH_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_STENCIL_SIZE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLEBUFFERS );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLESAMPLES );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_ACCELERATED_VISUAL );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MAJOR_VERSION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MINOR_VERSION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_EGL );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_FLAGS );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_SHARE_WITH_CURRENT_CONTEXT );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_FRAMEBUFFER_SRGB_CAPABLE );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RELEASE_BEHAVIOR );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RESET_NOTIFICATION );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_NO_ERROR );
MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_PROFILE_MASK );
#undef MAP_REF_API_ATTRIBUTE_TO_SDL
}
ASSERT( 0 );
return 0;
} }
#ifndef EGL_LIB #ifndef EGL_LIB

14
engine/ref_api.h

@ -169,27 +169,19 @@ typedef enum
SAFE_DONTCARE // ignore everything, let SDL/EGL decide SAFE_DONTCARE // ignore everything, let SDL/EGL decide
} ref_safegl_context_t; } ref_safegl_context_t;
// binary compatible with SDL2
enum // OpenGL configuration attributes enum // OpenGL configuration attributes
{ {
REF_GL_RED_SIZE, REF_GL_RED_SIZE,
REF_GL_GREEN_SIZE, REF_GL_GREEN_SIZE,
REF_GL_BLUE_SIZE, REF_GL_BLUE_SIZE,
REF_GL_ALPHA_SIZE, REF_GL_ALPHA_SIZE,
// UNUSED_REF_GL_BUFFER_SIZE, REF_GL_DOUBLEBUFFER,
REF_GL_DOUBLEBUFFER = REF_GL_ALPHA_SIZE + 1,
REF_GL_DEPTH_SIZE, REF_GL_DEPTH_SIZE,
REF_GL_STENCIL_SIZE, REF_GL_STENCIL_SIZE,
// UNUSED_REF_GL_ACCUM_RED_SIZE, REF_GL_MULTISAMPLEBUFFERS,
// UNUSED_REF_GL_ACCUM_GREEN_SIZE,
// UNUSED_REF_GL_ACCUM_BLUE_SIZE,
// UNUSED_REF_GL_ACCUM_ALPHA_SIZE,
// UNUSED_REF_GL_STEREO,
REF_GL_MULTISAMPLEBUFFERS = REF_GL_STENCIL_SIZE + 5,
REF_GL_MULTISAMPLESAMPLES, REF_GL_MULTISAMPLESAMPLES,
REF_GL_ACCELERATED_VISUAL, REF_GL_ACCELERATED_VISUAL,
// UNUSED_REF_GL_RETAINED_BACKING, REF_GL_CONTEXT_MAJOR_VERSION,
REF_GL_CONTEXT_MAJOR_VERSION = REF_GL_ACCELERATED_VISUAL + 1,
REF_GL_CONTEXT_MINOR_VERSION, REF_GL_CONTEXT_MINOR_VERSION,
REF_GL_CONTEXT_EGL, REF_GL_CONTEXT_EGL,
REF_GL_CONTEXT_FLAGS, REF_GL_CONTEXT_FLAGS,

Loading…
Cancel
Save