ref: get rid of vidState, add GL_SwapBuffers to engine exports

This commit is contained in:
mittorn 2019-03-16 11:58:44 +07:00
parent 31ab710485
commit 57320c0c25
6 changed files with 28 additions and 28 deletions

View File

@ -3,6 +3,7 @@
#include "library.h"
#include "cl_tent.h"
#include "platform/platform.h"
#include "vid_common.h"
struct ref_state_s ref;
ref_globals_t refState;
@ -352,6 +353,7 @@ static ref_api_t gEngfuncs =
GL_SetAttribute,
GL_GetAttribute,
GL_GetProcAddress,
GL_SwapBuffers,
BuildGammaTable,
LightToTexGamma,

View File

@ -27,7 +27,6 @@ convar_t *vid_brightness;
convar_t *vid_gamma;
convar_t *vid_highdpi;
vidstate_t vidState;
glwstate_t glw_state;
convar_t *window_xpos;
@ -54,8 +53,8 @@ void VID_InitDefaultResolution( void )
{
// we need to have something valid here
// until video subsystem initialized
vidState.width = 640;
vidState.height = 480;
refState.width = 640;
refState.height = 480;
}
/*
@ -65,8 +64,8 @@ R_SaveVideoMode
*/
void R_SaveVideoMode( int w, int h )
{
vidState.width = w;
vidState.height = h;
refState.width = w;
refState.height = h;
host.window_center_x = w / 2;
host.window_center_y = h / 2;
@ -76,8 +75,8 @@ void R_SaveVideoMode( int w, int h )
// check for 4:3 or 5:4
if( w * 3 != h * 4 && w * 4 != h * 5 )
vidState.wideScreen = true;
else vidState.wideScreen = false;
refState.wideScreen = true;
else refState.wideScreen = false;
}
/*

View File

@ -28,15 +28,6 @@ typedef struct
} glwstate_t;
typedef struct vidstate_s
{
int width, height;
int prev_width, prev_height;
qboolean fullScreen;
qboolean wideScreen;
} vidstate_t;
extern vidstate_t vidState;
extern glwstate_t glw_state;
#define VID_MIN_HEIGHT 200
@ -50,5 +41,6 @@ void R_SaveVideoMode( int w, int h );
void VID_CheckChanges( void );
const char *VID_GetModeString( int vid_mode );
void VID_StartupGamma( void );
void GL_SwapBuffers();
#endif // VID_COMMON

View File

@ -24,6 +24,10 @@ GNU General Public License for more details.
static vidmode_t *vidmodes = NULL;
static int num_vidmodes = 0;
static void GL_SetupAttributes( void );
struct
{
int prev_width, prev_height;
} sdlState;
int R_MaxVideoModes( void )
{
@ -470,9 +474,9 @@ void VID_DestroyWindow( void )
host.hWnd = NULL;
}
if( vidState.fullScreen )
if( refState.fullScreen )
{
vidState.fullScreen = false;
refState.fullScreen = false;
}
}
@ -488,6 +492,13 @@ static void GL_SetupAttributes( void )
ref.dllFuncs.GL_SetupAttributes( glw_state.safe );
}
void GL_SwapBuffers()
{
SDL_GL_SwapWindow( host.hWnd );
}
int GL_SetAttribute( int attr, int val )
{
return SDL_GL_SetAttribute( (SDL_GLattr)attr, val );
@ -568,7 +579,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
glw_state.desktopWidth = displayMode.w;
glw_state.desktopHeight = displayMode.h;
vidState.fullScreen = fullscreen;
refState.fullScreen = fullscreen;
if( !host.hWnd )
{
@ -640,8 +651,8 @@ qboolean VID_SetMode( void )
if(( err = R_ChangeDisplaySettings( iScreenWidth, iScreenHeight, fullscreen )) == rserr_ok )
{
vidState.prev_width = iScreenWidth;
vidState.prev_height = iScreenHeight;
sdlState.prev_width = iScreenWidth;
sdlState.prev_height = iScreenHeight;
}
else
{
@ -660,7 +671,7 @@ qboolean VID_SetMode( void )
}
// try setting it back to something safe
if(( err = R_ChangeDisplaySettings( vidState.prev_width, vidState.prev_height, false )) != rserr_ok )
if(( err = R_ChangeDisplaySettings( sdlState.prev_width, sdlState.prev_height, false )) != rserr_ok )
{
Con_Reportf( S_ERROR "VID_SetMode: could not revert to safe mode\n" );
Sys_Warn("could not revert to safe mode!");

View File

@ -383,6 +383,7 @@ typedef struct ref_api_s
int (*GL_SetAttribute)( int attr, int value );
int (*GL_GetAttribute)( int attr, int *value );
void *(*GL_GetProcAddress)( const char *name );
void (*GL_SwapBuffers)();
// gamma
void (*BuildGammaTable)( float lightgamma, float brightness );

View File

@ -1138,12 +1138,7 @@ void R_EndFrame( void )
{
// flush any remaining 2D bits
R_Set2DMode( false );
#ifdef XASH_SDL
SDL_GL_SwapWindow( host.hWnd );
#elif defined __ANDROID__ // For direct android backend
Android_SwapBuffers();
#endif
gEngfuncs.GL_SwapBuffers();
}
/*