GL_GENERATE_MIPMAP is enough
also made MajorGL and MinorGL extern, so can be used in other parts if needed to check for it
This commit is contained in:
1 parent
b487df7771
commit
2fc6a26e77
3 files changed
+27
-64
No files matched your search
@@ -103,12 +103,16 @@ static GLboolean MipMap = GL_FALSE;
|
||||
static GLint min_filter = GL_LINEAR;
|
||||
static GLint mag_filter = GL_LINEAR;
|
||||
static GLint anisotropic_filter = 0;
|
||||
boolean supportMipMap = false;
|
||||
static FTransform md2_transform;
|
||||
|
||||
const GLubyte *gl_version = NULL;
|
||||
const GLubyte *gl_renderer = NULL;
|
||||
const GLubyte *gl_extensions = NULL;
|
||||
|
||||
// Loaded OpenGL version
|
||||
int majorGL = 0, minorGL = 0;
|
||||
|
||||
//Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-)
|
||||
static GLfloat modelMatrix[16];
|
||||
GLfloat projMatrix[16];
|
||||
@@ -157,9 +161,6 @@ 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,
|
||||
// : else do nothing
|
||||
@@ -427,11 +428,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
|
||||
|
||||
/* 3.0 functions */
|
||||
#ifdef GL_VERSION_3_0
|
||||
typedef void (APIENTRY * PFNglGenerateMipmap) (GLenum target);
|
||||
static PFNglGenerateMipmap pglGenerateMipmap;
|
||||
#endif
|
||||
|
||||
/* 1.2 functions for 3D textures */
|
||||
@@ -716,10 +712,6 @@ void SetupGLFunc4(void)
|
||||
pglUniform2fv = GetGLFunc("glUniform2fv");
|
||||
pglUniform3fv = GetGLFunc("glUniform3fv");
|
||||
pglGetUniformLocation = GetGLFunc("glGetUniformLocation");
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
pglGenerateMipmap = GetGLFunc("glGenerateMipmap");
|
||||
#endif
|
||||
}
|
||||
|
||||
EXPORT boolean HWRAPI(InitShaders) (void)
|
||||
@@ -935,7 +927,7 @@ void SetStates(void)
|
||||
|
||||
pglEnable(GL_STENCIL_TEST);
|
||||
pglEnable(GL_DEPTH_TEST); // check the depth buffer
|
||||
pglDepthMask(GL_TRUE); // enable writing to depth buffer
|
||||
pglDepthMask(GL_TRUE); // enable writing to depth buffer
|
||||
pglClearDepth(1.0f);
|
||||
pglDepthRange(0.0f, 1.0f);
|
||||
pglDepthFunc(GL_LEQUAL);
|
||||
@@ -1458,23 +1450,14 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
|
||||
//pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
|
||||
if (MipMap)
|
||||
{
|
||||
if ((majorGL == 1 && minorGL >= 4) || (majorGL == 2))
|
||||
{
|
||||
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);
|
||||
}
|
||||
#ifdef GL_VERSION_3_0
|
||||
else if (majorGL >= 3)
|
||||
{
|
||||
pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
|
||||
pglGenerateMipmap(GL_TEXTURE_2D);
|
||||
}
|
||||
#endif
|
||||
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
|
||||
else
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 16);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4);
|
||||
//pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_LINEAR_MIPMAP_LINEAR);
|
||||
}
|
||||
else
|
||||
@@ -1490,23 +1473,14 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
|
||||
//pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
|
||||
if (MipMap)
|
||||
{
|
||||
if ((majorGL == 1 && minorGL >= 4) || (majorGL == 2))
|
||||
{
|
||||
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);
|
||||
}
|
||||
#ifdef GL_VERSION_3_0
|
||||
else if (majorGL >= 3)
|
||||
{
|
||||
pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
|
||||
pglGenerateMipmap(GL_TEXTURE_2D);
|
||||
}
|
||||
#endif
|
||||
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
|
||||
else
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 16);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4);
|
||||
//pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_LINEAR_MIPMAP_LINEAR);
|
||||
}
|
||||
else
|
||||
@@ -1521,24 +1495,15 @@ EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *pTexInfo)
|
||||
{
|
||||
if (MipMap)
|
||||
{
|
||||
if ((majorGL == 1 && minorGL >= 4) || (majorGL == 2))
|
||||
{
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
|
||||
pglTexImage2D(GL_TEXTURE_2D, 0, textureformatGL, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
|
||||
}
|
||||
#ifdef GL_VERSION_3_0
|
||||
else if (majorGL >= 3)
|
||||
{
|
||||
pglTexImage2D(GL_TEXTURE_2D, 0, textureformatGL, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
|
||||
pglGenerateMipmap(GL_TEXTURE_2D);
|
||||
}
|
||||
#endif
|
||||
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)
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff
|
||||
else
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 16);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2176,22 +2141,12 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
|
||||
mag_filter = GL_LINEAR;
|
||||
min_filter = GL_NEAREST;
|
||||
}
|
||||
if (majorGL == 1 && minorGL <= 3)
|
||||
if (!supportMipMap)
|
||||
{
|
||||
MipMap = GL_FALSE;
|
||||
min_filter = GL_LINEAR;
|
||||
}
|
||||
#ifdef GL_VERSION_3_0
|
||||
else
|
||||
{
|
||||
if (!pglGenerateMipmap)
|
||||
{
|
||||
MipMap = GL_FALSE;
|
||||
min_filter = GL_LINEAR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Flush(); //??? if we want to change filter mode by texture, remove this
|
||||
break;
|
||||
|
||||
|
||||
@@ -112,11 +112,14 @@ extern const GLubyte *gl_version;
|
||||
extern const GLubyte *gl_renderer;
|
||||
extern const GLubyte *gl_extensions;
|
||||
|
||||
extern int majorGL, minorGL;
|
||||
|
||||
extern RGBA_t myPaletteData[];
|
||||
extern GLint screen_width;
|
||||
extern GLint screen_height;
|
||||
extern GLbyte screen_depth;
|
||||
extern GLint maximumAnisotropy;
|
||||
extern boolean supportMipMap;
|
||||
|
||||
/** \brief OpenGL flags for video driver
|
||||
*/
|
||||
|
||||
@@ -161,6 +161,11 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||
|
||||
SetupGLFunc4();
|
||||
|
||||
if (majorGL == 1 && minorGL <= 3) // GL_GENERATE_MIPMAP is unavailible for OGL 1.3 and below
|
||||
supportMipMap = false;
|
||||
else
|
||||
supportMipMap = true;
|
||||
|
||||
granisotropicmode_cons_t[1].value = maximumAnisotropy;
|
||||
|
||||
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
|
||||
|
||||
Reference in new issue
Block a user