Commit 3e71d976 authored by hybrid's avatar hybrid

Make use of new mipmap extension in case the card supports it. Patch also by Nadro.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4050 dfc29bdd-3216-0410-991c-e03cc46cb475
parent b601dede
...@@ -728,8 +728,8 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const ...@@ -728,8 +728,8 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
case EVDF_VERTEX_SHADER_1_1: case EVDF_VERTEX_SHADER_1_1:
case EVDF_ARB_VERTEX_PROGRAM_1: case EVDF_ARB_VERTEX_PROGRAM_1:
return FeatureAvailable[IRR_ARB_vertex_program] || FeatureAvailable[IRR_NV_vertex_program1_1]; return FeatureAvailable[IRR_ARB_vertex_program] || FeatureAvailable[IRR_NV_vertex_program1_1];
case EVDF_PIXEL_SHADER_1_1: case EVDF_PIXEL_SHADER_1_1:
case EVDF_PIXEL_SHADER_1_2: case EVDF_PIXEL_SHADER_1_2:
case EVDF_ARB_FRAGMENT_PROGRAM_1: case EVDF_ARB_FRAGMENT_PROGRAM_1:
return FeatureAvailable[IRR_ARB_fragment_program] || FeatureAvailable[IRR_NV_fragment_program]; return FeatureAvailable[IRR_ARB_fragment_program] || FeatureAvailable[IRR_NV_fragment_program];
case EVDF_PIXEL_SHADER_2_0: case EVDF_PIXEL_SHADER_2_0:
......
...@@ -2264,7 +2264,6 @@ inline void COpenGLExtensionHandler::extGlEnableIndexed(GLenum target, GLuint in ...@@ -2264,7 +2264,6 @@ inline void COpenGLExtensionHandler::extGlEnableIndexed(GLenum target, GLuint in
#endif #endif
} }
inline void COpenGLExtensionHandler::extGlDisableIndexed(GLenum target, GLuint index) inline void COpenGLExtensionHandler::extGlDisableIndexed(GLenum target, GLuint index)
{ {
#ifdef _IRR_OPENGL_USE_EXTPOINTER_ #ifdef _IRR_OPENGL_USE_EXTPOINTER_
...@@ -2277,7 +2276,6 @@ inline void COpenGLExtensionHandler::extGlDisableIndexed(GLenum target, GLuint i ...@@ -2277,7 +2276,6 @@ inline void COpenGLExtensionHandler::extGlDisableIndexed(GLenum target, GLuint i
#endif #endif
} }
inline void COpenGLExtensionHandler::extGlBlendFuncIndexed(GLuint buf, GLenum src, GLenum dst) inline void COpenGLExtensionHandler::extGlBlendFuncIndexed(GLuint buf, GLenum src, GLenum dst)
{ {
#ifdef _IRR_OPENGL_USE_EXTPOINTER_ #ifdef _IRR_OPENGL_USE_EXTPOINTER_
...@@ -2294,7 +2292,6 @@ inline void COpenGLExtensionHandler::extGlBlendFuncIndexed(GLuint buf, GLenum sr ...@@ -2294,7 +2292,6 @@ inline void COpenGLExtensionHandler::extGlBlendFuncIndexed(GLuint buf, GLenum sr
#endif #endif
} }
inline void COpenGLExtensionHandler::extGlBlendEquationIndexed(GLuint buf, GLenum mode) inline void COpenGLExtensionHandler::extGlBlendEquationIndexed(GLuint buf, GLenum mode)
{ {
#ifdef _IRR_OPENGL_USE_EXTPOINTER_ #ifdef _IRR_OPENGL_USE_EXTPOINTER_
...@@ -2311,7 +2308,6 @@ inline void COpenGLExtensionHandler::extGlBlendEquationIndexed(GLuint buf, GLenu ...@@ -2311,7 +2308,6 @@ inline void COpenGLExtensionHandler::extGlBlendEquationIndexed(GLuint buf, GLenu
#endif #endif
} }
inline void COpenGLExtensionHandler::extGlProgramParameteri(GLhandleARB program, GLenum pname, GLint value) inline void COpenGLExtensionHandler::extGlProgramParameteri(GLhandleARB program, GLenum pname, GLint value)
{ {
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
...@@ -2333,7 +2329,6 @@ inline void COpenGLExtensionHandler::extGlProgramParameteri(GLhandleARB program, ...@@ -2333,7 +2329,6 @@ inline void COpenGLExtensionHandler::extGlProgramParameteri(GLhandleARB program,
#endif #endif
} }
inline void COpenGLExtensionHandler::extGlGenQueries(GLsizei n, GLuint *ids) inline void COpenGLExtensionHandler::extGlGenQueries(GLsizei n, GLuint *ids)
{ {
#ifdef _IRR_OPENGL_USE_EXTPOINTER_ #ifdef _IRR_OPENGL_USE_EXTPOINTER_
...@@ -2349,7 +2344,6 @@ inline void COpenGLExtensionHandler::extGlGenQueries(GLsizei n, GLuint *ids) ...@@ -2349,7 +2344,6 @@ inline void COpenGLExtensionHandler::extGlGenQueries(GLsizei n, GLuint *ids)
os::Printer::log("glGenQueries not supported", ELL_ERROR); os::Printer::log("glGenQueries not supported", ELL_ERROR);
#endif #endif
} }
inline void COpenGLExtensionHandler::extGlDeleteQueries(GLsizei n, const GLuint *ids) inline void COpenGLExtensionHandler::extGlDeleteQueries(GLsizei n, const GLuint *ids)
{ {
...@@ -2382,7 +2376,7 @@ inline GLboolean COpenGLExtensionHandler::extGlIsQuery(GLuint id) ...@@ -2382,7 +2376,7 @@ inline GLboolean COpenGLExtensionHandler::extGlIsQuery(GLuint id)
return false; return false;
#endif #endif
} }
inline void COpenGLExtensionHandler::extGlBeginQuery(GLenum target, GLuint id) inline void COpenGLExtensionHandler::extGlBeginQuery(GLenum target, GLuint id)
{ {
#ifdef _IRR_OPENGL_USE_EXTPOINTER_ #ifdef _IRR_OPENGL_USE_EXTPOINTER_
...@@ -2398,7 +2392,7 @@ inline void COpenGLExtensionHandler::extGlBeginQuery(GLenum target, GLuint id) ...@@ -2398,7 +2392,7 @@ inline void COpenGLExtensionHandler::extGlBeginQuery(GLenum target, GLuint id)
os::Printer::log("glBeginQuery not supported", ELL_ERROR); os::Printer::log("glBeginQuery not supported", ELL_ERROR);
#endif #endif
} }
inline void COpenGLExtensionHandler::extGlEndQuery(GLenum target) inline void COpenGLExtensionHandler::extGlEndQuery(GLenum target)
{ {
#ifdef _IRR_OPENGL_USE_EXTPOINTER_ #ifdef _IRR_OPENGL_USE_EXTPOINTER_
...@@ -2414,7 +2408,7 @@ inline void COpenGLExtensionHandler::extGlEndQuery(GLenum target) ...@@ -2414,7 +2408,7 @@ inline void COpenGLExtensionHandler::extGlEndQuery(GLenum target)
os::Printer::log("glEndQuery not supported", ELL_ERROR); os::Printer::log("glEndQuery not supported", ELL_ERROR);
#endif #endif
} }
inline void COpenGLExtensionHandler::extGlGetQueryiv(GLenum target, GLenum pname, GLint *params) inline void COpenGLExtensionHandler::extGlGetQueryiv(GLenum target, GLenum pname, GLint *params)
{ {
#ifdef _IRR_OPENGL_USE_EXTPOINTER_ #ifdef _IRR_OPENGL_USE_EXTPOINTER_
......
...@@ -314,6 +314,8 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level) ...@@ -314,6 +314,8 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
if (Driver->testGLError()) if (Driver->testGLError())
os::Printer::log("Could not bind Texture", ELL_ERROR); os::Printer::log("Could not bind Texture", ELL_ERROR);
bool mipmapLegacyMode = true;
// mipmap handling for main texture // mipmap handling for main texture
if (!level && newTexture) if (!level && newTexture)
{ {
...@@ -322,15 +324,20 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level) ...@@ -322,15 +324,20 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
// auto generate if possible and no mipmap data is given // auto generate if possible and no mipmap data is given
if (HasMipMaps && !mipmapData && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE)) if (HasMipMaps && !mipmapData && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE))
{ {
if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED)) if(!Driver->queryFeature(EVDF_FRAMEBUFFER_OBJECT))
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST); {
else if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY)) if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST); glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST);
else if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY))
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
else
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_DONT_CARE);
// automatically generate and update mipmaps
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
AutomaticMipmapUpdate=true;
}
else else
glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_DONT_CARE); mipmapLegacyMode = false;
// automatically generate and update mipmaps
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
AutomaticMipmapUpdate=true;
} }
else else
#endif #endif
...@@ -368,6 +375,17 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level) ...@@ -368,6 +375,17 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
image->getDimension().Height, PixelFormat, PixelType, source); image->getDimension().Height, PixelFormat, PixelType, source);
image->unlock(); image->unlock();
if (!mipmapLegacyMode)
{
glEnable(GL_TEXTURE_2D);
Driver->extGlGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
AutomaticMipmapUpdate=true;
}
if (Driver->testGLError()) if (Driver->testGLError())
os::Printer::log("Could not glTexImage2D", ELL_ERROR); os::Printer::log("Could not glTexImage2D", ELL_ERROR);
} }
...@@ -606,13 +624,13 @@ void COpenGLTexture::regenerateMipMapLevels(void* mipmapData) ...@@ -606,13 +624,13 @@ void COpenGLTexture::regenerateMipMapLevels(void* mipmapData)
bool COpenGLTexture::isRenderTarget() const bool COpenGLTexture::isRenderTarget() const
{ {
return IsRenderTarget; return IsRenderTarget;
} }
void COpenGLTexture::setIsRenderTarget(bool isTarget) void COpenGLTexture::setIsRenderTarget(bool isTarget)
{ {
IsRenderTarget = isTarget; IsRenderTarget = isTarget;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment