mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-22 02:42:20 +00:00
Only initialise OpenGL if you actually intend to use it.
This commit is contained in:
parent
6c5db5f462
commit
07afd7520f
3 changed files with 19 additions and 12 deletions
|
@ -37,8 +37,9 @@ typedef enum
|
|||
extern rendermode_t rendermode;
|
||||
|
||||
/** \brief hardware renderer loaded
|
||||
0 = never loaded, 1 = loaded successfully, -1 = failed loading
|
||||
*/
|
||||
extern boolean hwrenderloaded;
|
||||
extern INT32 hwrenderloaded;
|
||||
|
||||
/** \brief use highcolor modes if true
|
||||
*/
|
||||
|
|
|
@ -104,7 +104,7 @@ static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff
|
|||
static consvar_t cv_alwaysgrabmouse = {"alwaysgrabmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
UINT8 graphics_started = 0; // Is used in console.c and screen.c
|
||||
boolean hwrenderloaded = false;
|
||||
INT32 hwrenderloaded = 0;
|
||||
|
||||
// To disable fullscreen at startup; is set in VID_PrepareModeList
|
||||
boolean allow_fullscreen = false;
|
||||
|
@ -1473,7 +1473,7 @@ static SDL_bool Impl_CreateContext(void)
|
|||
#ifdef HWRENDER
|
||||
static void VID_CheckGLLoaded(rendermode_t oldrender)
|
||||
{
|
||||
if (!hwrenderloaded) // Well, it didn't work the first time anyway.
|
||||
if (hwrenderloaded == -1) // Well, it didn't work the first time anyway.
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "OpenGL never loaded\n");
|
||||
rendermode = oldrender;
|
||||
|
@ -1505,8 +1505,13 @@ void VID_CheckRenderer(void)
|
|||
{
|
||||
rendermode = setrenderneeded;
|
||||
#ifdef HWRENDER
|
||||
if (setrenderneeded == render_opengl)
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
VID_CheckGLLoaded(oldrenderer);
|
||||
// Initialise OpenGL before calling SDLSetMode!!!
|
||||
if (hwrenderloaded != 1)
|
||||
I_StartupHardwareGraphics();
|
||||
}
|
||||
#endif
|
||||
Impl_CreateContext();
|
||||
}
|
||||
|
@ -1522,14 +1527,14 @@ void VID_CheckRenderer(void)
|
|||
bufSurface = NULL;
|
||||
}
|
||||
#ifdef HWRENDER
|
||||
HWR_FreeTextureCache();
|
||||
if (hwrenderloaded == 1) // Only if OpenGL ever loaded!
|
||||
HWR_FreeTextureCache();
|
||||
#endif
|
||||
SCR_SetDrawFuncs();
|
||||
}
|
||||
#ifdef HWRENDER
|
||||
else if (rendermode == render_opengl)
|
||||
{
|
||||
I_StartupHardwareGraphics();
|
||||
// Needs to check if switching failed somehow, too.
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
|
@ -1714,7 +1719,8 @@ void I_StartupGraphics(void)
|
|||
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY>>1,SDL_DEFAULT_REPEAT_INTERVAL<<2);
|
||||
VID_Command_ModeList_f();
|
||||
#ifdef HWRENDER
|
||||
I_StartupHardwareGraphics();
|
||||
if (chosenrendermode == render_opengl)
|
||||
I_StartupHardwareGraphics();
|
||||
#endif
|
||||
|
||||
// Fury: we do window initialization after GL setup to allow
|
||||
|
@ -1807,12 +1813,12 @@ void I_StartupHardwareGraphics(void)
|
|||
if (HWD.pfnGetRenderVersion() != VERSION)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, M_GetText("The version of the renderer doesn't match the version of the executable\nBe sure you have installed SRB2 properly.\n"));
|
||||
hwrenderloaded = false;
|
||||
hwrenderloaded = -1;
|
||||
}
|
||||
else
|
||||
hwrenderloaded = HWD.pfnInit(I_Error); // let load the OpenGL library
|
||||
hwrenderloaded = HWD.pfnInit(I_Error) ? 1 : -1; // let load the OpenGL library
|
||||
|
||||
if (!hwrenderloaded)
|
||||
if (hwrenderloaded == -1)
|
||||
{
|
||||
rendermode = render_soft;
|
||||
setrenderneeded = 0;
|
||||
|
|
|
@ -95,10 +95,10 @@ boolean LoadGL(void)
|
|||
|
||||
if (SDL_GL_LoadLibrary(OGLLibname) != 0)
|
||||
{
|
||||
I_OutputMsg("Could not load OpenGL Library: %s\n"
|
||||
CONS_Alert(CONS_ERROR, "Could not load OpenGL Library: %s\n"
|
||||
"Falling back to Software mode.\n", SDL_GetError());
|
||||
if (!M_CheckParm ("-OGLlib"))
|
||||
I_OutputMsg("If you know what is the OpenGL library's name, use -OGLlib\n");
|
||||
CONS_Alert(CONS_ERROR, "If you know what is the OpenGL library's name, use -OGLlib\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue