mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-18 02:50:33 +00:00
ref: get rid of vidState, add GL_SwapBuffers to engine exports
This commit is contained in:
parent
31ab710485
commit
57320c0c25
@ -3,6 +3,7 @@
|
|||||||
#include "library.h"
|
#include "library.h"
|
||||||
#include "cl_tent.h"
|
#include "cl_tent.h"
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
|
#include "vid_common.h"
|
||||||
|
|
||||||
struct ref_state_s ref;
|
struct ref_state_s ref;
|
||||||
ref_globals_t refState;
|
ref_globals_t refState;
|
||||||
@ -352,6 +353,7 @@ static ref_api_t gEngfuncs =
|
|||||||
GL_SetAttribute,
|
GL_SetAttribute,
|
||||||
GL_GetAttribute,
|
GL_GetAttribute,
|
||||||
GL_GetProcAddress,
|
GL_GetProcAddress,
|
||||||
|
GL_SwapBuffers,
|
||||||
|
|
||||||
BuildGammaTable,
|
BuildGammaTable,
|
||||||
LightToTexGamma,
|
LightToTexGamma,
|
||||||
|
@ -27,7 +27,6 @@ convar_t *vid_brightness;
|
|||||||
convar_t *vid_gamma;
|
convar_t *vid_gamma;
|
||||||
convar_t *vid_highdpi;
|
convar_t *vid_highdpi;
|
||||||
|
|
||||||
vidstate_t vidState;
|
|
||||||
glwstate_t glw_state;
|
glwstate_t glw_state;
|
||||||
|
|
||||||
convar_t *window_xpos;
|
convar_t *window_xpos;
|
||||||
@ -54,8 +53,8 @@ void VID_InitDefaultResolution( void )
|
|||||||
{
|
{
|
||||||
// we need to have something valid here
|
// we need to have something valid here
|
||||||
// until video subsystem initialized
|
// until video subsystem initialized
|
||||||
vidState.width = 640;
|
refState.width = 640;
|
||||||
vidState.height = 480;
|
refState.height = 480;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -65,8 +64,8 @@ R_SaveVideoMode
|
|||||||
*/
|
*/
|
||||||
void R_SaveVideoMode( int w, int h )
|
void R_SaveVideoMode( int w, int h )
|
||||||
{
|
{
|
||||||
vidState.width = w;
|
refState.width = w;
|
||||||
vidState.height = h;
|
refState.height = h;
|
||||||
|
|
||||||
host.window_center_x = w / 2;
|
host.window_center_x = w / 2;
|
||||||
host.window_center_y = h / 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
|
// check for 4:3 or 5:4
|
||||||
if( w * 3 != h * 4 && w * 4 != h * 5 )
|
if( w * 3 != h * 4 && w * 4 != h * 5 )
|
||||||
vidState.wideScreen = true;
|
refState.wideScreen = true;
|
||||||
else vidState.wideScreen = false;
|
else refState.wideScreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -28,15 +28,6 @@ typedef struct
|
|||||||
|
|
||||||
} glwstate_t;
|
} 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;
|
extern glwstate_t glw_state;
|
||||||
|
|
||||||
#define VID_MIN_HEIGHT 200
|
#define VID_MIN_HEIGHT 200
|
||||||
@ -50,5 +41,6 @@ void R_SaveVideoMode( int w, int h );
|
|||||||
void VID_CheckChanges( void );
|
void VID_CheckChanges( void );
|
||||||
const char *VID_GetModeString( int vid_mode );
|
const char *VID_GetModeString( int vid_mode );
|
||||||
void VID_StartupGamma( void );
|
void VID_StartupGamma( void );
|
||||||
|
void GL_SwapBuffers();
|
||||||
|
|
||||||
#endif // VID_COMMON
|
#endif // VID_COMMON
|
||||||
|
@ -24,6 +24,10 @@ GNU General Public License for more details.
|
|||||||
static vidmode_t *vidmodes = NULL;
|
static vidmode_t *vidmodes = NULL;
|
||||||
static int num_vidmodes = 0;
|
static int num_vidmodes = 0;
|
||||||
static void GL_SetupAttributes( void );
|
static void GL_SetupAttributes( void );
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
int prev_width, prev_height;
|
||||||
|
} sdlState;
|
||||||
|
|
||||||
int R_MaxVideoModes( void )
|
int R_MaxVideoModes( void )
|
||||||
{
|
{
|
||||||
@ -470,9 +474,9 @@ void VID_DestroyWindow( void )
|
|||||||
host.hWnd = NULL;
|
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 );
|
ref.dllFuncs.GL_SetupAttributes( glw_state.safe );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GL_SwapBuffers()
|
||||||
|
{
|
||||||
|
SDL_GL_SwapWindow( host.hWnd );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int GL_SetAttribute( int attr, int val )
|
int GL_SetAttribute( int attr, int val )
|
||||||
{
|
{
|
||||||
return SDL_GL_SetAttribute( (SDL_GLattr)attr, 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.desktopWidth = displayMode.w;
|
||||||
glw_state.desktopHeight = displayMode.h;
|
glw_state.desktopHeight = displayMode.h;
|
||||||
|
|
||||||
vidState.fullScreen = fullscreen;
|
refState.fullScreen = fullscreen;
|
||||||
|
|
||||||
if( !host.hWnd )
|
if( !host.hWnd )
|
||||||
{
|
{
|
||||||
@ -640,8 +651,8 @@ qboolean VID_SetMode( void )
|
|||||||
|
|
||||||
if(( err = R_ChangeDisplaySettings( iScreenWidth, iScreenHeight, fullscreen )) == rserr_ok )
|
if(( err = R_ChangeDisplaySettings( iScreenWidth, iScreenHeight, fullscreen )) == rserr_ok )
|
||||||
{
|
{
|
||||||
vidState.prev_width = iScreenWidth;
|
sdlState.prev_width = iScreenWidth;
|
||||||
vidState.prev_height = iScreenHeight;
|
sdlState.prev_height = iScreenHeight;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -660,7 +671,7 @@ qboolean VID_SetMode( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try setting it back to something safe
|
// 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" );
|
Con_Reportf( S_ERROR "VID_SetMode: could not revert to safe mode\n" );
|
||||||
Sys_Warn("could not revert to safe mode!");
|
Sys_Warn("could not revert to safe mode!");
|
||||||
|
@ -383,6 +383,7 @@ typedef struct ref_api_s
|
|||||||
int (*GL_SetAttribute)( int attr, int value );
|
int (*GL_SetAttribute)( int attr, int value );
|
||||||
int (*GL_GetAttribute)( int attr, int *value );
|
int (*GL_GetAttribute)( int attr, int *value );
|
||||||
void *(*GL_GetProcAddress)( const char *name );
|
void *(*GL_GetProcAddress)( const char *name );
|
||||||
|
void (*GL_SwapBuffers)();
|
||||||
|
|
||||||
// gamma
|
// gamma
|
||||||
void (*BuildGammaTable)( float lightgamma, float brightness );
|
void (*BuildGammaTable)( float lightgamma, float brightness );
|
||||||
|
@ -1138,12 +1138,7 @@ void R_EndFrame( void )
|
|||||||
{
|
{
|
||||||
// flush any remaining 2D bits
|
// flush any remaining 2D bits
|
||||||
R_Set2DMode( false );
|
R_Set2DMode( false );
|
||||||
|
gEngfuncs.GL_SwapBuffers();
|
||||||
#ifdef XASH_SDL
|
|
||||||
SDL_GL_SwapWindow( host.hWnd );
|
|
||||||
#elif defined __ANDROID__ // For direct android backend
|
|
||||||
Android_SwapBuffers();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user