Merge branch 'mipmapstuff' into 'next'

Replace gluBuild2DMipmaps with GL_GENERATE_MIPMAPS

See merge request STJr/SRB2!2287
This commit is contained in:
Alam Ed Arias 2025-01-10 03:20:16 +00:00
commit be3d4c9eee
6 changed files with 17 additions and 72 deletions

View file

@ -117,7 +117,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module
#define pwglDeleteContext wglDeleteContext;
#define pwglMakeCurrent wglMakeCurrent;
#else
static HMODULE OGL32, GLU32;
static HMODULE OGL32;
typedef void *(WINAPI *PFNwglGetProcAddress) (const char *);
static PFNwglGetProcAddress pwglGetProcAddress;
typedef HGLRC (WINAPI *PFNwglCreateContext) (HDC hdc);
@ -132,13 +132,6 @@ static PFNwglMakeCurrent pwglMakeCurrent;
void *GetGLFunc(const char *proc)
{
void *func = NULL;
if (strncmp(proc, "glu", 3) == 0)
{
if (GLU32)
func = GetProcAddress(GLU32, proc);
else
return NULL;
}
if (pwglGetProcAddress)
func = pwglGetProcAddress(proc);
if (!func)
@ -155,8 +148,6 @@ boolean LoadGL(void)
if (!OGL32)
return 0;
GLU32 = LoadLibrary("GLU32.DLL");
pwglGetProcAddress = GetGLFunc("wglGetProcAddress");
pwglCreateContext = GetGLFunc("wglCreateContext");
pwglDeleteContext = GetGLFunc("wglDeleteContext");
@ -528,7 +519,6 @@ EXPORT void HWRAPI(Shutdown) (void)
ReleaseDC(hWnd, hDC);
hDC = NULL;
}
FreeLibrary(GLU32);
FreeLibrary(OGL32);
GL_DBG_Printf ("HWRAPI Shutdown(DONE)\n");
}

View file

@ -96,6 +96,7 @@ static GLint min_filter = GL_LINEAR;
static GLint mag_filter = GL_LINEAR;
static GLint anisotropic_filter = 0;
static boolean model_lighting = false;
boolean supportMipMap = false;
const GLubyte *gl_version = NULL;
const GLubyte *gl_renderer = NULL;
@ -417,9 +418,6 @@ static PFNglCopyTexImage2D pglCopyTexImage2D;
typedef void (APIENTRY * PFNglCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
static PFNglCopyTexSubImage2D pglCopyTexSubImage2D;
#endif
/* GLU functions */
typedef GLint (APIENTRY * PFNgluBuild2DMipmaps) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data);
static PFNgluBuild2DMipmaps pgluBuild2DMipmaps;
/* 1.2 functions for 3D textures */
typedef void (APIENTRY * PFNglTexImage3D) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
@ -708,9 +706,6 @@ void SetupGLFunc4(void)
pglUniform3fv = GetGLFunc("glUniform3fv");
pglGetUniformLocation = GetGLFunc("glGetUniformLocation");
#endif
// GLU
pgluBuild2DMipmaps = GetGLFunc("gluBuild2DMipmaps");
}
EXPORT boolean HWRAPI(InitShaders) (void)
@ -1617,7 +1612,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
//pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
if (MipMap)
{
pgluBuild2DMipmaps(GL_TEXTURE_2D, GL_LUMINANCE_ALPHA, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0);
if (pTexInfo->flags & TF_TRANSPARENT)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff
@ -1638,7 +1634,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
//pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
if (MipMap)
{
pgluBuild2DMipmaps(GL_TEXTURE_2D, GL_ALPHA, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0);
if (pTexInfo->flags & TF_TRANSPARENT)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff
@ -1658,7 +1655,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
{
if (MipMap)
{
pgluBuild2DMipmaps(GL_TEXTURE_2D, textureformatGL, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
pglTexImage2D(GL_TEXTURE_2D, 0, textureformatGL, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
// Control the mipmap level of detail
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); // the lower the number, the higer the detail
if (pTexInfo->flags & TF_TRANSPARENT)
@ -2241,7 +2239,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
mag_filter = GL_LINEAR;
min_filter = GL_NEAREST;
}
if (!pgluBuild2DMipmaps)
if (!supportMipMap)
{
MipMap = GL_FALSE;
min_filter = GL_LINEAR;

View file

@ -35,7 +35,6 @@
#else
#include <GL/gl.h>
#include <GL/glu.h>
#ifdef STATIC_OPENGL // Because of the 1.3 functions, you'll need GLext to compile it if static
#define GL_GLEXT_PROTOTYPES
@ -127,6 +126,7 @@ extern GLint screen_width;
extern GLint screen_height;
extern GLbyte screen_depth;
extern GLint maximumAnisotropy;
extern boolean supportMipMap;
/** \brief OpenGL flags for video driver
*/

View file

@ -1949,8 +1949,6 @@ void I_ShutdownGraphics(void)
I_OutputMsg("shut down\n");
#ifdef HWRENDER
if (GLUhandle)
hwClose(GLUhandle);
if (sdlglcontext)
{
SDL_GL_DeleteContext(sdlglcontext);

View file

@ -70,18 +70,10 @@ PFNglGetString pglGetString;
/** \brief SDL video display surface
*/
INT32 oglflags = 0;
void *GLUhandle = NULL;
SDL_GLContext sdlglcontext = 0;
void *GetGLFunc(const char *proc)
{
if (strncmp(proc, "glu", 3) == 0)
{
if (GLUhandle)
return hwSym(proc, GLUhandle);
else
return NULL;
}
return SDL_GL_GetProcAddress(proc);
}
@ -89,7 +81,6 @@ boolean LoadGL(void)
{
#ifndef STATIC_OPENGL
const char *OGLLibname = NULL;
const char *GLULibname = NULL;
if (M_CheckParm("-OGLlib") && M_IsNextParm())
OGLLibname = M_GetNextParm();
@ -102,43 +93,6 @@ boolean LoadGL(void)
CONS_Printf("If you know what is the OpenGL library's name, use -OGLlib\n");
return 0;
}
#if 0
GLULibname = "/proc/self/exe";
#elif defined (_WIN32)
GLULibname = "GLU32.DLL";
#elif defined (__MACH__)
GLULibname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib";
#elif defined (macintos)
GLULibname = "OpenGLLibrary";
#elif defined (__unix__)
GLULibname = "libGLU.so.1";
#elif defined (__HAIKU__)
GLULibname = "libGLU.so";
#else
GLULibname = NULL;
#endif
if (M_CheckParm("-GLUlib") && M_IsNextParm())
GLULibname = M_GetNextParm();
if (GLULibname)
{
GLUhandle = hwOpen(GLULibname);
if (GLUhandle)
return SetupGLfunc();
else
{
CONS_Alert(CONS_ERROR, "Could not load GLU Library: %s\n", GLULibname);
if (!M_CheckParm ("-GLUlib"))
CONS_Alert(CONS_ERROR, "If you know what is the GLU library's name, use -GLUlib\n");
}
}
else
{
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();
}
@ -155,6 +109,7 @@ boolean OglSdlSurface(INT32 w, INT32 h)
{
INT32 cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value;
static boolean first_init = false;
static int majorGL = 0, minorGL = 0;
oglflags = 0;
@ -189,6 +144,12 @@ boolean OglSdlSurface(INT32 w, INT32 h)
else
maximumAnisotropy = 1;
if (sscanf((const char*)gl_version, "%d.%d", &majorGL, &minorGL)
&& (!(majorGL == 1 && minorGL <= 3)))
supportMipMap = true;
else
supportMipMap = false;
SetupGLFunc4();
glanisotropicmode_cons_t[1].value = maximumAnisotropy;

View file

@ -19,8 +19,6 @@
#include "../v_video.h"
extern void *GLUhandle;
boolean OglSdlSurface(INT32 w, INT32 h);
void OglSdlFinishUpdate(boolean vidwait);