mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-29 20:50:58 +00:00
Merge branch 'fix-ogllib' into 'master'
Fix -OGLlib See merge request STJr/SRB2!794
This commit is contained in:
commit
7d14796954
6 changed files with 145 additions and 32 deletions
|
@ -1276,11 +1276,18 @@ void D_SRB2Main(void)
|
|||
// Lactozilla: Does the render mode need to change?
|
||||
if ((setrenderneeded != 0) && (setrenderneeded != rendermode))
|
||||
{
|
||||
CONS_Printf("Switching the renderer...\n");
|
||||
CONS_Printf(M_GetText("Switching the renderer...\n"));
|
||||
Z_PreparePatchFlush();
|
||||
|
||||
// set needpatchflush / needpatchrecache true for D_CheckRendererState
|
||||
needpatchflush = true;
|
||||
needpatchrecache = true;
|
||||
|
||||
// Set cv_renderer to the new render mode
|
||||
VID_CheckRenderer();
|
||||
SCR_ChangeRendererCVars(setrenderneeded);
|
||||
|
||||
// check the renderer's state, and then clear setrenderneeded
|
||||
D_CheckRendererState();
|
||||
setrenderneeded = 0;
|
||||
}
|
||||
|
|
|
@ -32,10 +32,14 @@ typedef enum
|
|||
render_none = 3 // for dedicated server
|
||||
} rendermode_t;
|
||||
|
||||
/** \brief currect render mode
|
||||
/** \brief current render mode
|
||||
*/
|
||||
extern rendermode_t rendermode;
|
||||
|
||||
/** \brief hardware renderer loaded
|
||||
0 = never loaded, 1 = loaded successfully, -1 = failed loading
|
||||
*/
|
||||
extern INT32 hwrenderloaded;
|
||||
|
||||
/** \brief use highcolor modes if true
|
||||
*/
|
||||
|
@ -44,6 +48,9 @@ extern boolean highcolor;
|
|||
/** \brief setup video mode
|
||||
*/
|
||||
void I_StartupGraphics(void);
|
||||
|
||||
/** \brief setup hardware mode
|
||||
*/
|
||||
void I_StartupHardwareGraphics(void);
|
||||
|
||||
/** \brief restore old video mode
|
||||
|
@ -82,9 +89,12 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h);
|
|||
|
||||
\param modenum video mode to set to
|
||||
|
||||
\return currect video mode
|
||||
\return current video mode
|
||||
*/
|
||||
INT32 VID_SetMode(INT32 modenum);
|
||||
|
||||
/** \brief Checks the render state
|
||||
*/
|
||||
void VID_CheckRenderer(void);
|
||||
|
||||
/** \brief The VID_GetModeName function
|
||||
|
|
28
src/m_menu.c
28
src/m_menu.c
|
@ -312,6 +312,7 @@ static void M_AssignJoystick(INT32 choice);
|
|||
static void M_ChangeControl(INT32 choice);
|
||||
|
||||
// Video & Sound
|
||||
static void M_VideoOptions(INT32 choice);
|
||||
menu_t OP_VideoOptionsDef, OP_VideoModeDef, OP_ColorOptionsDef;
|
||||
#ifdef HWRENDER
|
||||
static void M_OpenGLOptionsMenu(void);
|
||||
|
@ -1034,7 +1035,7 @@ static menuitem_t OP_MainMenu[] =
|
|||
{IT_SUBMENU | IT_STRING, NULL, "Player 2 Controls...", &OP_P2ControlsDef, 20},
|
||||
{IT_CVAR | IT_STRING, NULL, "Controls per key", &cv_controlperkey, 30},
|
||||
|
||||
{IT_SUBMENU | IT_STRING, NULL, "Video Options...", &OP_VideoOptionsDef, 50},
|
||||
{IT_CALL | IT_STRING, NULL, "Video Options...", M_VideoOptions, 50},
|
||||
{IT_SUBMENU | IT_STRING, NULL, "Sound Options...", &OP_SoundOptionsDef, 60},
|
||||
|
||||
{IT_CALL | IT_STRING, NULL, "Server Options...", M_ServerOptions, 80},
|
||||
|
@ -1285,6 +1286,16 @@ static menuitem_t OP_Camera2ExtendedOptionsMenu[] =
|
|||
{IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 126},
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
op_video_resolution = 1,
|
||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
op_video_fullscreen,
|
||||
#endif
|
||||
op_video_vsync,
|
||||
op_video_renderer,
|
||||
};
|
||||
|
||||
static menuitem_t OP_VideoOptionsMenu[] =
|
||||
{
|
||||
{IT_HEADER, NULL, "Screen", NULL, 0},
|
||||
|
@ -2083,6 +2094,20 @@ menu_t OP_PlaystyleDef = {
|
|||
0, 0, 0, NULL
|
||||
};
|
||||
|
||||
static void M_VideoOptions(INT32 choice)
|
||||
{
|
||||
(void)choice;
|
||||
#ifdef HWRENDER
|
||||
if (hwrenderloaded == -1)
|
||||
{
|
||||
OP_VideoOptionsMenu[op_video_renderer].status = (IT_TRANSTEXT | IT_PAIR);
|
||||
OP_VideoOptionsMenu[op_video_renderer].patch = "Renderer";
|
||||
OP_VideoOptionsMenu[op_video_renderer].text = "Software";
|
||||
}
|
||||
|
||||
#endif
|
||||
M_SetupNextMenu(&OP_VideoOptionsDef);
|
||||
}
|
||||
|
||||
menu_t OP_VideoOptionsDef =
|
||||
{
|
||||
|
@ -12114,7 +12139,6 @@ static void M_VideoModeMenu(INT32 choice)
|
|||
|
||||
static void M_DrawMainVideoMenu(void)
|
||||
{
|
||||
|
||||
M_DrawGenericScrollMenu();
|
||||
if (itemOn < 8) // where it starts to go offscreen; change this number if you change the layout of the video menu
|
||||
{
|
||||
|
|
16
src/screen.c
16
src/screen.c
|
@ -450,6 +450,20 @@ static int target_renderer = 0;
|
|||
void SCR_ActuallyChangeRenderer(void)
|
||||
{
|
||||
setrenderneeded = target_renderer;
|
||||
|
||||
#ifdef HWRENDER
|
||||
// Well, it didn't even load anyway.
|
||||
if ((hwrenderloaded == -1) && (setrenderneeded == render_opengl))
|
||||
{
|
||||
if (M_CheckParm("-nogl"))
|
||||
CONS_Alert(CONS_ERROR, "OpenGL rendering was disabled!\n");
|
||||
else
|
||||
CONS_Alert(CONS_ERROR, "OpenGL never loaded\n");
|
||||
setrenderneeded = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// setting the same renderer twice WILL crash your game, so let's not, please
|
||||
if (rendermode == setrenderneeded)
|
||||
setrenderneeded = 0;
|
||||
|
@ -464,7 +478,7 @@ void SCR_ChangeRenderer(void)
|
|||
{
|
||||
target_renderer = cv_renderer.value;
|
||||
#ifdef HWRENDER
|
||||
if (M_CheckParm("-opengl"))
|
||||
if (M_CheckParm("-opengl") && (hwrenderloaded == 1))
|
||||
target_renderer = rendermode = render_opengl;
|
||||
else
|
||||
#endif
|
||||
|
|
|
@ -93,7 +93,8 @@ static INT32 numVidModes = -1;
|
|||
*/
|
||||
static char vidModeName[33][32]; // allow 33 different modes
|
||||
|
||||
rendermode_t rendermode=render_soft;
|
||||
rendermode_t rendermode = render_soft;
|
||||
static rendermode_t chosenrendermode = render_soft; // set by command line arguments
|
||||
|
||||
boolean highcolor = false;
|
||||
|
||||
|
@ -103,6 +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
|
||||
INT32 hwrenderloaded = 0;
|
||||
|
||||
// To disable fullscreen at startup; is set in VID_PrepareModeList
|
||||
boolean allow_fullscreen = false;
|
||||
|
@ -174,7 +176,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
|
|||
//static void Impl_SetWindowName(const char *title);
|
||||
static void Impl_SetWindowIcon(void);
|
||||
|
||||
static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||
static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool reposition)
|
||||
{
|
||||
static SDL_bool wasfullscreen = SDL_FALSE;
|
||||
Uint32 rmask;
|
||||
|
@ -203,10 +205,13 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
|||
}
|
||||
// Reposition window only in windowed mode
|
||||
SDL_SetWindowSize(window, width, height);
|
||||
SDL_SetWindowPosition(window,
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)),
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window))
|
||||
);
|
||||
if (reposition)
|
||||
{
|
||||
SDL_SetWindowPosition(window,
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)),
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1435,7 +1440,7 @@ static SDL_bool Impl_CreateContext(void)
|
|||
{
|
||||
// Renderer-specific stuff
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
if ((rendermode == render_opengl) && (hwrenderloaded != -1))
|
||||
{
|
||||
if (!sdlglcontext)
|
||||
sdlglcontext = SDL_GL_CreateContext(window);
|
||||
|
@ -1468,18 +1473,58 @@ static SDL_bool Impl_CreateContext(void)
|
|||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
static void VID_CheckGLLoaded(rendermode_t oldrender)
|
||||
{
|
||||
if (hwrenderloaded == -1) // Well, it didn't work the first time anyway.
|
||||
{
|
||||
rendermode = oldrender;
|
||||
if (chosenrendermode == render_opengl) // fallback to software
|
||||
rendermode = render_soft;
|
||||
if (setrenderneeded)
|
||||
{
|
||||
CV_StealthSetValue(&cv_renderer, oldrender);
|
||||
CV_StealthSetValue(&cv_newrenderer, oldrender);
|
||||
setrenderneeded = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void VID_CheckRenderer(void)
|
||||
{
|
||||
SDL_bool rendererchanged = SDL_FALSE;
|
||||
rendermode_t oldrenderer = rendermode;
|
||||
|
||||
if (dedicated)
|
||||
return;
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (!graphics_started)
|
||||
VID_CheckGLLoaded(oldrenderer);
|
||||
#endif
|
||||
|
||||
if (setrenderneeded)
|
||||
{
|
||||
rendermode = setrenderneeded;
|
||||
rendererchanged = SDL_TRUE;
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
VID_CheckGLLoaded(oldrenderer);
|
||||
// Initialise OpenGL before calling SDLSetMode!!!
|
||||
if (hwrenderloaded != 1)
|
||||
I_StartupHardwareGraphics();
|
||||
else if (hwrenderloaded == -1)
|
||||
rendererchanged = SDL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
Impl_CreateContext();
|
||||
}
|
||||
|
||||
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
|
||||
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN, (rendererchanged ? SDL_FALSE : SDL_TRUE));
|
||||
Impl_VideoSetupBuffer();
|
||||
|
||||
if (rendermode == render_soft)
|
||||
|
@ -1490,16 +1535,16 @@ 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();
|
||||
R_InitHardwareMode();
|
||||
}
|
||||
#else
|
||||
(void)oldrenderer;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1541,7 +1586,8 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
|
|||
flags |= SDL_WINDOW_BORDERLESS;
|
||||
|
||||
#ifdef HWRENDER
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
if (hwrenderloaded != -1)
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
#endif
|
||||
|
||||
// Create a window
|
||||
|
@ -1664,10 +1710,10 @@ void I_StartupGraphics(void)
|
|||
|
||||
#ifdef HWRENDER
|
||||
if (M_CheckParm("-opengl"))
|
||||
rendermode = render_opengl;
|
||||
chosenrendermode = rendermode = render_opengl;
|
||||
else if (M_CheckParm("-software"))
|
||||
#endif
|
||||
rendermode = render_soft;
|
||||
chosenrendermode = rendermode = render_soft;
|
||||
|
||||
usesdl2soft = M_CheckParm("-softblit");
|
||||
borderlesswindow = M_CheckParm("-borderless");
|
||||
|
@ -1675,7 +1721,10 @@ 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 (M_CheckParm("-nogl"))
|
||||
hwrenderloaded = -1; // Don't call SDL_GL_LoadLibrary
|
||||
else
|
||||
I_StartupHardwareGraphics();
|
||||
#endif
|
||||
|
||||
// Fury: we do window initialization after GL setup to allow
|
||||
|
@ -1763,13 +1812,22 @@ void I_StartupHardwareGraphics(void)
|
|||
HWD.pfnMakeScreenTexture= hwSym("MakeScreenTexture",NULL);
|
||||
HWD.pfnMakeScreenFinalTexture=hwSym("MakeScreenFinalTexture",NULL);
|
||||
HWD.pfnDrawScreenFinalTexture=hwSym("DrawScreenFinalTexture",NULL);
|
||||
|
||||
// check gl renderer lib
|
||||
if (HWD.pfnGetRenderVersion() != VERSION)
|
||||
I_Error("%s", M_GetText("The version of the renderer doesn't match the version of the executable\nBe sure you have installed SRB2 properly.\n"));
|
||||
if (!HWD.pfnInit(I_Error)) // let load the OpenGL library
|
||||
rendermode = render_soft;
|
||||
{
|
||||
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 = -1;
|
||||
}
|
||||
else
|
||||
glstartup = true;
|
||||
hwrenderloaded = HWD.pfnInit(I_Error) ? 1 : -1; // let load the OpenGL library
|
||||
|
||||
if (hwrenderloaded == -1)
|
||||
{
|
||||
rendermode = render_soft;
|
||||
setrenderneeded = 0;
|
||||
}
|
||||
glstartup = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -128,15 +128,15 @@ boolean LoadGL(void)
|
|||
return SetupGLfunc();
|
||||
else
|
||||
{
|
||||
I_OutputMsg("Could not load GLU Library: %s\n", GLULibname);
|
||||
CONS_Alert(CONS_ERROR, "Could not load GLU Library: %s\n", GLULibname);
|
||||
if (!M_CheckParm ("-GLUlib"))
|
||||
I_OutputMsg("If you know what is the GLU library's name, use -GLUlib\n");
|
||||
CONS_Alert(CONS_ERROR, "If you know what is the GLU library's name, use -GLUlib\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
I_OutputMsg("Could not load GLU Library\n");
|
||||
I_OutputMsg("If you know what is the GLU library's name, use -GLUlib\n");
|
||||
CONS_Alert(CONS_ERROR, "Could not load GLU Library\n");
|
||||
CONS_Alert(CONS_ERROR, "If you know what is the GLU library's name, use -GLUlib\n");
|
||||
}
|
||||
#endif
|
||||
return SetupGLfunc();
|
||||
|
|
Loading…
Reference in a new issue