mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-04 15:31:21 +00:00
Replace glBuild2DMipmaps with GL_GENERATE_MIPMAPS
Quote "gluBuild2DMipmaps. Never use this." gluBuild2DMipmaps was causing massive stutters on many maps on windows this replaces it with GL_GENERATE_MIPMAP and removes glBuild2DMipmaps completely https://www.khronos.org/opengl/wiki/Common_Mistakes
This commit is contained in:
parent
bae687a1b9
commit
7ff1d5877d
3 changed files with 14 additions and 10 deletions
|
@ -77,6 +77,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;
|
||||
|
@ -397,9 +398,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.3 functions for multitexturing */
|
||||
typedef void (APIENTRY *PFNglActiveTexture) (GLenum);
|
||||
|
@ -907,9 +905,6 @@ void SetupGLFunc4(void)
|
|||
pglUniform3fv = GetGLFunc("glUniform3fv");
|
||||
pglGetUniformLocation = GetGLFunc("glGetUniformLocation");
|
||||
#endif
|
||||
|
||||
// GLU
|
||||
pgluBuild2DMipmaps = GetGLFunc("gluBuild2DMipmaps");
|
||||
}
|
||||
|
||||
EXPORT boolean HWRAPI(CompileShaders) (void)
|
||||
|
@ -1887,7 +1882,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
|
||||
|
@ -1908,7 +1904,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
|
||||
|
@ -1928,7 +1925,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)
|
||||
|
@ -2463,7 +2461,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;
|
||||
|
|
|
@ -126,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
|
||||
*/
|
||||
|
|
|
@ -189,6 +189,11 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
|||
else
|
||||
maximumAnisotropy = 1;
|
||||
|
||||
if (atof((const char*)gl_version) >= 1.4)
|
||||
supportMipMap = true;
|
||||
else
|
||||
supportMipMap = false;
|
||||
|
||||
SetupGLFunc4();
|
||||
|
||||
glanisotropicmode_cons_t[1].value = maximumAnisotropy;
|
||||
|
|
Loading…
Reference in a new issue