From 6d4dec4054a9cd8ff8d259b4b40e8fa22f10d5bf Mon Sep 17 00:00:00 2001 From: cutealien Date: Sat, 20 Jun 2020 12:50:38 +0000 Subject: [PATCH] Compile fixed for COpenGLExtensionHandler compiled on older GL versions without extensions Thanks @Maksym Hamarnyk for report and patch proposal. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6126 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/COpenGLExtensionHandler.h | 115 ++++++++++++++++++++-- 1 file changed, 105 insertions(+), 10 deletions(-) diff --git a/source/Irrlicht/COpenGLExtensionHandler.h b/source/Irrlicht/COpenGLExtensionHandler.h index 9edd733e..5f567e72 100644 --- a/source/Irrlicht/COpenGLExtensionHandler.h +++ b/source/Irrlicht/COpenGLExtensionHandler.h @@ -2876,7 +2876,7 @@ inline void COpenGLExtensionHandler::extGlTextureSubImage2D(GLuint texture, GLen #ifdef _IRR_OPENGL_USE_EXTPOINTER_ if (pGlTextureSubImage2DEXT) pGlTextureSubImage2DEXT(texture, target, level, xoffset, yoffset,width, height,format, type, pixels); -#else +#elif defined(GL_EXT_direct_state_access) glTextureSubImage2DEXT(texture, target, level, xoffset, yoffset,width, height,format, type, pixels); #endif // _IRR_OPENGL_USE_EXTPOINTER_ } @@ -2885,15 +2885,23 @@ inline void COpenGLExtensionHandler::extGlTextureSubImage2D(GLuint texture, GLen GLint bound; switch (target) { +#ifdef GL_VERSION_3_0 case GL_TEXTURE_1D_ARRAY: glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY, &bound); break; +#elif GL_EXT_texture_array + case GL_TEXTURE_1D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY_EXT, &bound); + break; +#endif case GL_TEXTURE_2D: glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound); break; +#ifdef GL_VERSION_3_2 case GL_TEXTURE_2D_MULTISAMPLE: glGetIntegerv(GL_TEXTURE_BINDING_2D_MULTISAMPLE, &bound); break; +#endif case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: @@ -2930,7 +2938,7 @@ inline void COpenGLExtensionHandler::extGlTextureStorage2D(GLuint texture, GLenu #ifdef _IRR_OPENGL_USE_EXTPOINTER_ if (pGlTextureStorage2DEXT) pGlTextureStorage2DEXT(texture,target,levels,internalformat,width,height); -#else +#elif defined(GL_EXT_direct_state_access) glTextureStorage2DEXT(texture,target,levels,internalformat,width,height); #endif // _IRR_OPENGL_USE_EXTPOINTER_ } @@ -2944,9 +2952,15 @@ inline void COpenGLExtensionHandler::extGlTextureStorage2D(GLuint texture, GLenu GLint bound; switch (target) { +#ifdef GL_VERSION_3_0 case GL_TEXTURE_1D_ARRAY: glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY, &bound); break; +#elif GL_EXT_texture_array + case GL_TEXTURE_1D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY_EXT, &bound); + break; +#endif case GL_TEXTURE_2D: glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound); break; @@ -2986,7 +3000,7 @@ inline void COpenGLExtensionHandler::extGlTextureStorage3D(GLuint texture, GLenu #ifdef _IRR_OPENGL_USE_EXTPOINTER_ if (pGlTextureStorage3DEXT) pGlTextureStorage3DEXT(texture,target,levels,internalformat,width,height,depth); -#else +#elif defined(GL_EXT_direct_state_access) glTextureStorage3DEXT(texture,target,levels,internalformat,width,height,depth); #endif // _IRR_OPENGL_USE_EXTPOINTER_ } @@ -2999,15 +3013,27 @@ inline void COpenGLExtensionHandler::extGlTextureStorage3D(GLuint texture, GLenu GLint bound; switch (target) { +#ifdef GL_VERSION_3_0 case GL_TEXTURE_2D_ARRAY: glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY, &bound); break; +#elif GL_EXT_texture_array + case GL_TEXTURE_2D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY_EXT, &bound); + break; +#endif case GL_TEXTURE_3D: glGetIntegerv(GL_TEXTURE_BINDING_3D, &bound); break; +#ifdef GL_VERSION_4_0 case GL_TEXTURE_CUBE_MAP_ARRAY: glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &bound); break; +#elif defined(GL_ARB_texture_cube_map_array) + case GL_TEXTURE_CUBE_MAP_ARRAY_ARB: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB, &bound); + break; +#endif default: return; } @@ -3029,7 +3055,7 @@ inline void COpenGLExtensionHandler::extGlGetTextureImage(GLuint texture, GLenum #ifdef _IRR_OPENGL_USE_EXTPOINTER_ if (pGlGetTextureImage) pGlGetTextureImage(texture,level,format,type,bufSize,pixels); -#else +#elif defined(GL_VERSION_4_5) glGetTextureImage(texture,level,format,type,bufSize,pixels); #endif // _IRR_OPENGL_USE_EXTPOINTER_ } @@ -3038,7 +3064,7 @@ inline void COpenGLExtensionHandler::extGlGetTextureImage(GLuint texture, GLenum #ifdef _IRR_OPENGL_USE_EXTPOINTER_ if (pGlGetTextureImageEXT) pGlGetTextureImageEXT(texture,target,level,format,type,pixels); -#else +#elif defined(GL_EXT_direct_state_access) glGetTextureImageEXT(texture,target,level,format,type,pixels); #endif // _IRR_OPENGL_USE_EXTPOINTER_ } @@ -3047,15 +3073,27 @@ inline void COpenGLExtensionHandler::extGlGetTextureImage(GLuint texture, GLenum GLint bound; switch (target) { +#ifdef GL_VERSION_3_0 case GL_TEXTURE_2D_ARRAY: glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY, &bound); break; +#elif GL_EXT_texture_array + case GL_TEXTURE_2D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY_EXT, &bound); + break; +#endif case GL_TEXTURE_3D: glGetIntegerv(GL_TEXTURE_BINDING_3D, &bound); break; +#ifdef GL_VERSION_4_0 case GL_TEXTURE_CUBE_MAP_ARRAY: glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &bound); break; +#elif defined(GL_ARB_texture_cube_map_array) + case GL_TEXTURE_CUBE_MAP_ARRAY_ARB: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB, &bound); + break; +#endif default: return; } @@ -3162,10 +3200,37 @@ inline void COpenGLExtensionHandler::extGlCreateFramebuffers(GLsizei n, GLuint* inline void COpenGLExtensionHandler::extGlBindTextures(GLuint first, GLsizei count, const GLuint *textures, const GLenum* targets) { - const GLenum supportedTargets[] = { GL_TEXTURE_1D,GL_TEXTURE_2D, // GL 1.x - GL_TEXTURE_3D,GL_TEXTURE_RECTANGLE,GL_TEXTURE_CUBE_MAP, // GL 2.x - GL_TEXTURE_1D_ARRAY,GL_TEXTURE_2D_ARRAY,GL_TEXTURE_BUFFER, // GL 3.x - GL_TEXTURE_CUBE_MAP_ARRAY,GL_TEXTURE_2D_MULTISAMPLE,GL_TEXTURE_2D_MULTISAMPLE_ARRAY}; // GL 4.x + const GLenum supportedTargets[] = { GL_TEXTURE_1D, GL_TEXTURE_2D // GL 1.x + ,GL_TEXTURE_3D // GL 2.x +#ifdef GL_VERSION_3_1 + ,GL_TEXTURE_RECTANGLE +#elif defined(GL_ARB_texture_rectangle) + ,GL_TEXTURE_RECTANGLE_ARB +#elif defined(GL_NV_texture_rectangle) + ,GL_TEXTURE_RECTANGLE_NV +#endif + ,GL_TEXTURE_CUBE_MAP +#ifdef GL_VERSION_3_0 + ,GL_TEXTURE_1D_ARRAY,GL_TEXTURE_2D_ARRAY // GL 3.x +#elif GL_EXT_texture_array + ,GL_TEXTURE_1D_ARRAY_EXT,GL_TEXTURE_2D_ARRAY_EXT +#endif +#ifdef GL_VERSION_3_1 + ,GL_TEXTURE_BUFFER +#elif defined(GL_ARB_texture_buffer_object) + ,GL_TEXTURE_BUFFER_ARB +#elif defined(GL_EXT_texture_buffer_object) + ,GL_TEXTURE_BUFFER_EXT +#endif +#ifdef GL_VERSION_4_0 + ,GL_TEXTURE_CUBE_MAP_ARRAY // GL 4.x +#elif defined(GL_ARB_texture_cube_map_array) + ,GL_TEXTURE_CUBE_MAP_ARRAY_ARB +#endif +#ifdef GL_VERSION_3_2 + ,GL_TEXTURE_2D_MULTISAMPLE,GL_TEXTURE_2D_MULTISAMPLE_ARRAY +#endif + }; if (Version>=404||FeatureAvailable[IRR_ARB_multi_bind]) { @@ -3217,7 +3282,7 @@ inline void COpenGLExtensionHandler::extGlGenerateTextureMipmap(GLuint texture, #ifdef _IRR_OPENGL_USE_EXTPOINTER_ if (pGlGenerateTextureMipmapEXT) pGlGenerateTextureMipmapEXT(texture,target); -#else +#elif defined(GL_EXT_direct_state_access) glGenerateTextureMipmapEXT(texture,target); #endif // _IRR_OPENGL_USE_EXTPOINTER_ } @@ -3233,33 +3298,63 @@ inline void COpenGLExtensionHandler::extGlGenerateTextureMipmap(GLuint texture, case GL_TEXTURE_1D: glGetIntegerv(GL_TEXTURE_BINDING_1D, &bound); break; +#ifdef GL_VERSION_3_0 case GL_TEXTURE_1D_ARRAY: glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY, &bound); break; +#elif GL_EXT_texture_array + case GL_TEXTURE_1D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY_EXT, &bound); + break; +#endif case GL_TEXTURE_2D: glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound); break; +#ifdef GL_VERSION_3_0 case GL_TEXTURE_2D_ARRAY: glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY, &bound); break; +#elif GL_EXT_texture_array + case GL_TEXTURE_2D_ARRAY_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY_EXT, &bound); + break; +#endif +#ifdef GL_VERSION_3_2 case GL_TEXTURE_2D_MULTISAMPLE: glGetIntegerv(GL_TEXTURE_BINDING_2D_MULTISAMPLE, &bound); break; case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: glGetIntegerv(GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY, &bound); break; +#endif case GL_TEXTURE_3D: glGetIntegerv(GL_TEXTURE_BINDING_3D, &bound); break; +#ifdef GL_VERSION_3_1 case GL_TEXTURE_BUFFER: glGetIntegerv(GL_TEXTURE_BINDING_BUFFER, &bound); break; +#elif defined(GL_ARB_texture_buffer_object) + case GL_TEXTURE_BUFFER_ARB: + glGetIntegerv(GL_TEXTURE_BINDING_BUFFER_ARB, &bound); + break; +#elif defined(GL_EXT_texture_buffer_object) + case GL_TEXTURE_BUFFER_EXT: + glGetIntegerv(GL_TEXTURE_BINDING_BUFFER_EXT, &bound); + break; +#endif case GL_TEXTURE_CUBE_MAP: glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &bound); break; +#ifdef GL_VERSION_4_0 case GL_TEXTURE_CUBE_MAP_ARRAY: glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &bound); break; +#elif defined(GL_ARB_texture_cube_map_array) + case GL_TEXTURE_CUBE_MAP_ARRAY_ARB: + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB, &bound); + break; +#endif case GL_TEXTURE_RECTANGLE: glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE, &bound); break;