Add mipmap support from FBO extension, patch by Nadro.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4049 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2012-01-20 18:27:53 +00:00
parent 1fda9980df
commit b601dede10
2 changed files with 26 additions and 4 deletions

View File

@ -54,12 +54,12 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
pGlBindFramebuffer(0), pGlDeleteFramebuffers(0), pGlGenFramebuffers(0),
pGlCheckFramebufferStatus(0), pGlFramebufferTexture2D(0),
pGlBindRenderbuffer(0), pGlDeleteRenderbuffers(0), pGlGenRenderbuffers(0),
pGlRenderbufferStorage(0), pGlFramebufferRenderbuffer(0),
pGlRenderbufferStorage(0), pGlFramebufferRenderbuffer(0), pGlGenerateMipmap(0),
// EXT framebuffer object
pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0),
pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0),
pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0),
pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0),
pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0), pGlGenerateMipmapEXT(0),
// MRTs
pGlDrawBuffersARB(0), pGlDrawBuffersATI(0),
pGlGenBuffersARB(0), pGlBindBufferARB(0), pGlBufferDataARB(0), pGlDeleteBuffersARB(0),
@ -481,6 +481,8 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
pGlGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) IRR_OGL_LOAD_EXTENSION("glGenRenderbuffers");
pGlRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) IRR_OGL_LOAD_EXTENSION("glRenderbufferStorage");
pGlFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) IRR_OGL_LOAD_EXTENSION("glFramebufferRenderbuffer");
pGlGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) IRR_OGL_LOAD_EXTENSION("glGenerateMipmap");
// EXT FrameBufferObjects
pGlBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) IRR_OGL_LOAD_EXTENSION("glBindFramebufferEXT");
pGlDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) IRR_OGL_LOAD_EXTENSION("glDeleteFramebuffersEXT");
@ -492,6 +494,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
pGlGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) IRR_OGL_LOAD_EXTENSION("glGenRenderbuffersEXT");
pGlRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) IRR_OGL_LOAD_EXTENSION("glRenderbufferStorageEXT");
pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) IRR_OGL_LOAD_EXTENSION("glFramebufferRenderbufferEXT");
pGlGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) IRR_OGL_LOAD_EXTENSION("glGenerateMipmapEXT");
pGlDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC) IRR_OGL_LOAD_EXTENSION("glDrawBuffersARB");
pGlDrawBuffersATI = (PFNGLDRAWBUFFERSATIPROC) IRR_OGL_LOAD_EXTENSION("glDrawBuffersATI");
@ -719,7 +722,7 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
case EVDF_MIP_MAP:
return true;
case EVDF_MIP_MAP_AUTO_UPDATE:
return FeatureAvailable[IRR_SGIS_generate_mipmap];
return FeatureAvailable[IRR_SGIS_generate_mipmap] || FeatureAvailable[IRR_EXT_framebuffer_object] || FeatureAvailable[IRR_ARB_framebuffer_object];
case EVDF_STENCIL_BUFFER:
return StencilBuffer;
case EVDF_VERTEX_SHADER_1_1:
@ -742,7 +745,7 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
// return (FeatureAvailable[IRR_ARB_texture_non_power_of_two]||Version>=200);
return (FeatureAvailable[IRR_ARB_texture_non_power_of_two]);
case EVDF_FRAMEBUFFER_OBJECT:
return FeatureAvailable[IRR_EXT_framebuffer_object];
return FeatureAvailable[IRR_EXT_framebuffer_object] || FeatureAvailable[IRR_ARB_framebuffer_object];
case EVDF_VERTEX_BUFFER_OBJECT:
return FeatureAvailable[IRR_ARB_vertex_buffer_object];
case EVDF_COLOR_MASK:

View File

@ -1059,6 +1059,7 @@ class COpenGLExtensionHandler
void extGlGenRenderbuffers(GLsizei n, GLuint *renderbuffers);
void extGlRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void extGlFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
void extGlGenerateMipmap(GLenum target);
void extGlActiveStencilFace(GLenum face);
void extGlDrawBuffers(GLsizei n, const GLenum *bufs);
@ -1169,6 +1170,7 @@ class COpenGLExtensionHandler
PFNGLGENRENDERBUFFERSPROC pGlGenRenderbuffers;
PFNGLRENDERBUFFERSTORAGEPROC pGlRenderbufferStorage;
PFNGLFRAMEBUFFERRENDERBUFFERPROC pGlFramebufferRenderbuffer;
PFNGLGENERATEMIPMAPPROC pGlGenerateMipmap;
// EXT framebuffer object
PFNGLBINDFRAMEBUFFEREXTPROC pGlBindFramebufferEXT;
PFNGLDELETEFRAMEBUFFERSEXTPROC pGlDeleteFramebuffersEXT;
@ -1180,6 +1182,7 @@ class COpenGLExtensionHandler
PFNGLGENRENDERBUFFERSEXTPROC pGlGenRenderbuffersEXT;
PFNGLRENDERBUFFERSTORAGEEXTPROC pGlRenderbufferStorageEXT;
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC pGlFramebufferRenderbufferEXT;
PFNGLGENERATEMIPMAPEXTPROC pGlGenerateMipmapEXT;
PFNGLACTIVESTENCILFACEEXTPROC pGlActiveStencilFaceEXT;
PFNGLDRAWBUFFERSARBPROC pGlDrawBuffersARB;
PFNGLDRAWBUFFERSATIPROC pGlDrawBuffersATI;
@ -2035,6 +2038,22 @@ inline void COpenGLExtensionHandler::extGlFramebufferRenderbuffer(GLenum target,
#endif
}
inline void COpenGLExtensionHandler::extGlGenerateMipmap(GLenum target)
{
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (pGlGenerateMipmap)
pGlGenerateMipmap(target);
else if (pGlGenerateMipmapEXT)
pGlGenerateMipmapEXT(target);
#elif defined(GL_ARB_framebuffer_object)
glGenerateMipmapARB(target);
#elif defined(GL_EXT_framebuffer_object)
glGenerateMipmapEXT(target);
#else
os::Printer::log("glGenerateMipmap not supported", ELL_ERROR);
#endif
}
inline void COpenGLExtensionHandler::extGlActiveStencilFace(GLenum face)
{
#ifdef _IRR_OPENGL_USE_EXTPOINTER_