Browse Source

vid_sdl: fix GL_UpdateContext, fix window created outside screen if positions were negative

pull/2/head
Alibek Omarov 6 years ago
parent
commit
844b3a39a7
  1. 20
      engine/platform/sdl/vid_sdl.c

20
engine/platform/sdl/vid_sdl.c

@ -461,9 +461,9 @@ GL_UpdateContext
*/ */
qboolean GL_UpdateContext( void ) qboolean GL_UpdateContext( void )
{ {
if( !SDL_GL_MakeCurrent( host.hWnd, glw_state.context )) if( SDL_GL_MakeCurrent( host.hWnd, glw_state.context ))
{ {
MsgDev(D_ERROR, "GL_UpdateContext: %s", SDL_GetError()); MsgDev(D_ERROR, "GL_UpdateContext: %s\n", SDL_GetError());
return GL_DeleteContext(); return GL_DeleteContext();
} }
@ -566,6 +566,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
rgbdata_t *icon = NULL; rgbdata_t *icon = NULL;
qboolean iconLoaded = false; qboolean iconLoaded = false;
char iconpath[MAX_STRING]; char iconpath[MAX_STRING];
int xpos, ypos;
if( vid_highdpi->value ) wndFlags |= SDL_WINDOW_ALLOW_HIGHDPI; if( vid_highdpi->value ) wndFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
Q_strncpy( wndname, GI->title, sizeof( wndname )); Q_strncpy( wndname, GI->title, sizeof( wndname ));
@ -573,17 +574,16 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
if( !fullscreen ) if( !fullscreen )
{ {
wndFlags |= SDL_WINDOW_RESIZABLE; wndFlags |= SDL_WINDOW_RESIZABLE;
host.hWnd = SDL_CreateWindow( wndname, xpos = max( 0, Cvar_VariableInteger( "_window_xpos" ) );
Cvar_VariableInteger( "_window_xpos" ), ypos = max( 0, Cvar_VariableInteger( "_window_ypos" ) );
Cvar_VariableInteger( "_window_ypos" ),
width, height, wndFlags );
} }
else else
{ {
wndFlags |= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_GRABBED; wndFlags |= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_GRABBED;
host.hWnd = SDL_CreateWindow( wndname, 0, 0, width, height, wndFlags ); xpos = ypos = 0;
} }
host.hWnd = SDL_CreateWindow( wndname, xpos, ypos, width, height, wndFlags );
if( !host.hWnd ) if( !host.hWnd )
{ {
@ -669,17 +669,13 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
if( !glw_state.initialized ) if( !glw_state.initialized )
{ {
if( !GL_CreateContext( )) if( !GL_CreateContext( ))
{
return false; return false;
}
VID_StartupGamma(); VID_StartupGamma();
} }
else
{
if( !GL_UpdateContext( )) if( !GL_UpdateContext( ))
return false; return false;
}
SDL_GL_GetDrawableSize( host.hWnd, &width, &height ); SDL_GL_GetDrawableSize( host.hWnd, &width, &height );
R_ChangeDisplaySettingsFast( width, height ); R_ChangeDisplaySettingsFast( width, height );

Loading…
Cancel
Save