Retreive OpenGL version only once at startup

This commit is contained in:
indev committed 2023-12-13 00:31:49 +03:00
1 parent 58147117be
commit 14f0e70a9b
5 files changed
+20 -8

No files matched your search

+3 -1
View File
@@ -28,6 +28,7 @@
// ==========================================================================
EXPORT boolean HWRAPI(Init) (void);
EXPORT void HWRAPI(SetupGLInfo) (void);
#if defined (PURESDL) || defined (macintosh)
EXPORT void HWRAPI(SetPalette) (INT32 *, RGBA_t *gamma);
#else
@@ -95,6 +96,7 @@ EXPORT void HWRAPI(ClearLightTableCache) (void);
struct hwdriver_s
{
Init pfnInit;
SetupGLInfo pfnSetupGLInfo;
SetPalette pfnSetPalette;
FinishUpdate pfnFinishUpdate;
Draw2DLine pfnDraw2DLine;
@@ -146,4 +148,4 @@ extern struct hwdriver_s hwdriver;
#endif //not defined _CREATE_DLL_
#endif //__HWR_DRV_H__
#endif //__HWR_DRV_H__
+2
View File
@@ -6599,6 +6599,8 @@ void HWR_Startup(void)
CONS_Printf("HWR_Startup()...\n");
HWR_InitTextureCache();
HWR_InitMD2();
HWD.pfnSetupGLInfo();
}
if (rendermode == render_opengl)
+13 -7
View File
@@ -166,6 +166,8 @@ static const GLfloat byte2float[256] = {
0.972549f, 0.976471f, 0.980392f, 0.984314f, 0.988235f, 0.992157f, 0.996078f, 1.000000f
};
// Loaded OpenGL version
static int majorGL = 0, minorGL = 0;
// -----------------+
// GL_DBG_Printf : Output debug messages to debug log if DEBUG_TO_FILE is defined,
@@ -1589,6 +1591,17 @@ EXPORT boolean HWRAPI(Init) (void)
}
// -----------------+
// SetupGLInfo : Retreive and store currently loaded OpenGL version
// -----------------+
EXPORT void HWRAPI(SetupGLInfo) (void)
{
const GLubyte *versionGL = pglGetString(GL_VERSION);
CONS_Printf("Loaded OpenGL version %s\n", (const char*)versionGL);
sscanf((const char*)versionGL, "%d.%d", &majorGL, &minorGL);
}
// -----------------+
// ClearMipMapCache : Flush OpenGL textures from memory
// -----------------+
@@ -1970,9 +1983,6 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
INT32 w, h;
GLuint texnum = 0;
const GLubyte *versionGL = pglGetString(GL_VERSION);
int majorGL, minorGL;
sscanf(versionGL, "%d.%d", &majorGL, &minorGL);
if (!pTexInfo->downloaded)
{
@@ -3244,10 +3254,6 @@ EXPORT void HWRAPI(RenderSkyDome) (INT32 tex, INT32 texture_width, INT32 texture
// ==========================================================================
EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
{
const GLubyte *versionGL = pglGetString(GL_VERSION);
int majorGL, minorGL;
sscanf(versionGL, "%d.%d", &majorGL, &minorGL);
switch (IdState)
{
case HWD_SET_SHADERS:
+1
View File
@@ -78,6 +78,7 @@ void *hwSym(const char *funcName,void *handle)
funcPointer = &OglSdlSetPalette;
GETFUNC(Init);
GETFUNC(SetupGLInfo);
GETFUNC(Draw2DLine);
GETFUNC(DrawPolygon);
GETFUNC(SetBlend);
+1
View File
@@ -2109,6 +2109,7 @@ void I_StartupGraphics(void)
if (rendermode == render_opengl)
{
HWD.pfnInit = hwSym("Init",NULL);
HWD.pfnSetupGLInfo = hwSym("SetupGLInfo",NULL);
HWD.pfnFinishUpdate = NULL;
HWD.pfnDraw2DLine = hwSym("Draw2DLine",NULL);
HWD.pfnDrawPolygon = hwSym("DrawPolygon",NULL);