Fix several OpenGL version checking comparisons and add glGetTexImage.

Thanks @devsh for the patch.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6071 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2020-02-10 14:08:59 +00:00
parent 5451a2a8a0
commit 7beeb3d3f8
3 changed files with 69 additions and 19 deletions

View File

@ -2750,7 +2750,7 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
statesCache.IsCached = false;
#ifdef GL_VERSION_2_1
if (Version >= 210)
if (Version >= 201)
{
if (!statesCache.IsCached || material.TextureLayer[i].LODBias != statesCache.LODBias)
{

View File

@ -84,11 +84,11 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
pGlBlendFuncIndexedAMD(0), pGlBlendFunciARB(0), pGlBlendFuncSeparateIndexedAMD(0), pGlBlendFuncSeparateiARB(0),
pGlBlendEquationIndexedAMD(0), pGlBlendEquationiARB(0), pGlBlendEquationSeparateIndexedAMD(0), pGlBlendEquationSeparateiARB(0),
// DSA
pGlTextureStorage2D(0), pGlTextureStorage3D(0), pGlTextureSubImage2D(0), pGlNamedFramebufferTexture(0),
pGlTextureStorage2D(0), pGlTextureStorage3D(0), pGlTextureSubImage2D(0), pGlGetTextureImage(0), pGlNamedFramebufferTexture(0),
pGlTextureParameteri(0), pGlCreateTextures(0), pGlCreateFramebuffers(0), pGlBindTextures(0), pGlGenerateTextureMipmap(0),
// DSA with EXT or functions to simulate it
pGlTextureSubImage2DEXT(0), pGlTextureStorage2DEXT(0), pGlTexStorage2D(0), pGlTextureStorage3DEXT(0),
pGlTexStorage3D(0), pGlNamedFramebufferTextureEXT(0), pGlFramebufferTexture(0), pGlGenerateTextureMipmapEXT(0)
pGlTextureStorage2DEXT(0), pGlTexStorage2D(0), pGlTextureStorage3DEXT(0), pGlTexStorage3D(0), pGlTextureSubImage2DEXT(0), pGlGetTextureImageEXT(0),
pGlNamedFramebufferTextureEXT(0), pGlFramebufferTexture(0), pGlGenerateTextureMipmapEXT(0)
#if defined(GLX_SGI_swap_control)
,pGlxSwapIntervalSGI(0)
#endif
@ -567,9 +567,10 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
pGlBlendEquationSeparateIndexedAMD = (PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) IRR_OGL_LOAD_EXTENSION("glBlendEquationSeparateIndexedAMD");
pGlBlendEquationSeparateiARB = (PFNGLBLENDEQUATIONSEPARATEIPROC) IRR_OGL_LOAD_EXTENSION("glBlendEquationSeparateiARB");
pGlTextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glTextureSubImage2D");
pGlTextureStorage2D = (PFNGLTEXTURESTORAGE2DPROC) IRR_OGL_LOAD_EXTENSION("glTextureStorage2D");
pGlTextureStorage3D = (PFNGLTEXTURESTORAGE3DPROC) IRR_OGL_LOAD_EXTENSION("glTextureStorage3D");
pGlTextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glTextureSubImage2D");
pGlGetTextureImage = (PFNGLGETTEXTUREIMAGEPROC)IRR_OGL_LOAD_EXTENSION("glGetTextureImage");
pGlNamedFramebufferTexture = (PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) IRR_OGL_LOAD_EXTENSION("glNamedFramebufferTexture");
pGlTextureParameteri = (PFNGLTEXTUREPARAMETERIPROC) IRR_OGL_LOAD_EXTENSION("glTextureParameteri");
pGlCreateTextures = (PFNGLCREATETEXTURESPROC) IRR_OGL_LOAD_EXTENSION("glCreateTextures");
@ -577,11 +578,12 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
pGlBindTextures = (PFNGLBINDTEXTURESPROC) IRR_OGL_LOAD_EXTENSION("glBindTextures");
pGlGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC) IRR_OGL_LOAD_EXTENSION("glGenerateTextureMipmap");
//==============================
pGlTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)IRR_OGL_LOAD_EXTENSION("glTextureSubImage2DEXT");
pGlTextureStorage2DEXT = (PFNGLTEXTURESTORAGE2DEXTPROC)IRR_OGL_LOAD_EXTENSION("glTextureStorage2DEXT");
pGlTexStorage2D = (PFNGLTEXSTORAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glTexStorage2D");
pGlTextureStorage3DEXT = (PFNGLTEXTURESTORAGE3DEXTPROC)IRR_OGL_LOAD_EXTENSION("glTextureStorage3DEXT");
pGlTexStorage3D = (PFNGLTEXSTORAGE3DPROC)IRR_OGL_LOAD_EXTENSION("glTexStorage3D");
pGlTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)IRR_OGL_LOAD_EXTENSION("glTextureSubImage2DEXT");
pGlGetTextureImageEXT = (PFNGLGETTEXTUREIMAGEEXTPROC)IRR_OGL_LOAD_EXTENSION("glGetTextureImageEXT");
pGlNamedFramebufferTextureEXT = (PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC)IRR_OGL_LOAD_EXTENSION("glNamedFramebufferTextureEXT");
pGlFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferTexture");
pGlActiveTexture = (PFNGLACTIVETEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glActiveTexture");
@ -751,7 +753,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
#endif
OcclusionQuerySupport=false;
Feature.BlendOperation = (Version >= 140) ||
Feature.BlendOperation = (Version >= 104) ||
FeatureAvailable[IRR_EXT_blend_minmax] ||
FeatureAvailable[IRR_EXT_blend_subtract] ||
FeatureAvailable[IRR_EXT_blend_logic_op];
@ -850,17 +852,17 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
return FeatureAvailable[IRR_ARB_occlusion_query] && OcclusionQuerySupport;
case EVDF_POLYGON_OFFSET:
// both features supported with OpenGL 1.1
return Version>=110;
return Version>=101;
case EVDF_BLEND_OPERATIONS:
return Feature.BlendOperation;
case EVDF_BLEND_SEPARATE:
return (Version>=140) || FeatureAvailable[IRR_EXT_blend_func_separate];
return (Version>=104) || FeatureAvailable[IRR_EXT_blend_func_separate];
case EVDF_TEXTURE_MATRIX:
return true;
case EVDF_TEXTURE_COMPRESSED_DXT:
return FeatureAvailable[IRR_EXT_texture_compression_s3tc];
case EVDF_TEXTURE_CUBEMAP:
return (Version >= 130) || FeatureAvailable[IRR_ARB_texture_cube_map] || FeatureAvailable[IRR_EXT_texture_cube_map];
return (Version >= 103) || FeatureAvailable[IRR_ARB_texture_cube_map] || FeatureAvailable[IRR_EXT_texture_cube_map];
case EVDF_TEXTURE_CUBEMAP_SEAMLESS:
return FeatureAvailable[IRR_ARB_seamless_cube_map];
case EVDF_DEPTH_CLAMP:

View File

@ -86,6 +86,7 @@ static const char* const OpenGLFeatureStrings[] = {
"GL_ARB_depth_buffer_float",
"GL_ARB_depth_clamp",
"GL_ARB_depth_texture",
"GL_ARB_direct_state_access",
"GL_ARB_draw_buffers",
"GL_ARB_draw_buffers_blend",
"GL_ARB_draw_elements_base_vertex",
@ -572,6 +573,7 @@ class COpenGLExtensionHandler
IRR_ARB_depth_buffer_float,
IRR_ARB_depth_clamp,
IRR_ARB_depth_texture,
IRR_ARB_direct_state_access,
IRR_ARB_draw_buffers,
IRR_ARB_draw_buffers_blend,
IRR_ARB_draw_elements_base_vertex,
@ -1188,6 +1190,7 @@ class COpenGLExtensionHandler
void extGlTextureSubImage2D(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
void extGlTextureStorage2D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
void extGlTextureStorage3D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
void extGlGetTextureImage(GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void* pixels);
void extGlNamedFramebufferTexture(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
void extGlTextureParameteri(GLuint texture, GLenum pname, GLint param);
void extGlCreateTextures(GLenum target, GLsizei n, GLuint* textures);
@ -1347,6 +1350,7 @@ class COpenGLExtensionHandler
PFNGLTEXTURESTORAGE2DPROC pGlTextureStorage2D;
PFNGLTEXTURESTORAGE3DPROC pGlTextureStorage3D;
PFNGLTEXTURESUBIMAGE2DPROC pGlTextureSubImage2D;
PFNGLGETTEXTUREIMAGEPROC pGlGetTextureImage;
PFNGLNAMEDFRAMEBUFFERTEXTUREPROC pGlNamedFramebufferTexture;
PFNGLTEXTUREPARAMETERIPROC pGlTextureParameteri;
PFNGLCREATETEXTURESPROC pGlCreateTextures;
@ -1354,11 +1358,12 @@ class COpenGLExtensionHandler
PFNGLBINDTEXTURESPROC pGlBindTextures;
PFNGLGENERATETEXTUREMIPMAPPROC pGlGenerateTextureMipmap;
// DSA with EXT or functions to simulate it
PFNGLTEXTURESUBIMAGE2DEXTPROC pGlTextureSubImage2DEXT;
PFNGLTEXTURESTORAGE2DEXTPROC pGlTextureStorage2DEXT;
PFNGLTEXSTORAGE2DPROC pGlTexStorage2D;
PFNGLTEXTURESTORAGE3DEXTPROC pGlTextureStorage3DEXT;
PFNGLTEXSTORAGE3DPROC pGlTexStorage3D;
PFNGLTEXTURESUBIMAGE2DEXTPROC pGlTextureSubImage2DEXT;
PFNGLGETTEXTUREIMAGEEXTPROC pGlGetTextureImageEXT;
PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC pGlNamedFramebufferTextureEXT;
PFNGLFRAMEBUFFERTEXTUREPROC pGlFramebufferTexture;
PFNGLGENERATETEXTUREMIPMAPEXTPROC pGlGenerateTextureMipmapEXT;
@ -2730,7 +2735,7 @@ inline void COpenGLExtensionHandler::irrGlBlendEquationSeparateIndexed(GLuint bu
inline void COpenGLExtensionHandler::extGlTextureSubImage2D(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
{
if (Version>=450)
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
{
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (pGlTextureSubImage2D)
@ -2784,7 +2789,7 @@ inline void COpenGLExtensionHandler::extGlTextureSubImage2D(GLuint texture, GLen
inline void COpenGLExtensionHandler::extGlTextureStorage2D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
{
if (Version>=450)
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
{
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (pGlTextureStorage2D)
@ -2838,7 +2843,7 @@ inline void COpenGLExtensionHandler::extGlTextureStorage2D(GLuint texture, GLenu
inline void COpenGLExtensionHandler::extGlTextureStorage3D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
{
if (Version>=450)
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
{
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (pGlTextureStorage3D)
@ -2887,11 +2892,54 @@ inline void COpenGLExtensionHandler::extGlTextureStorage3D(GLuint texture, GLenu
}
}
inline void COpenGLExtensionHandler::extGlGetTextureImage(GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void* pixels)
{
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
{
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (pGlGetTextureImage)
pGlGetTextureImage(texture,level,format,type,bufSize,pixels);
#else
glGetTextureImage(texture,level,format,type,bufSize,pixels);
#endif // _IRR_OPENGL_USE_EXTPOINTER_
}
else if (FeatureAvailable[IRR_EXT_direct_state_access])
{
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (pGlGetTextureImageEXT)
pGlGetTextureImageEXT(texture,target,level,format,type,pixels);
#else
glGetTextureImageEXT(texture,target,level,format,type,pixels);
#endif // _IRR_OPENGL_USE_EXTPOINTER_
}
else
{
GLint bound;
switch (target)
{
case GL_TEXTURE_2D_ARRAY:
glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY, &bound);
break;
case GL_TEXTURE_3D:
glGetIntegerv(GL_TEXTURE_BINDING_3D, &bound);
break;
case GL_TEXTURE_CUBE_MAP_ARRAY:
glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &bound);
break;
default:
return;
}
glBindTexture(target, texture);
glGetTexImage(target,level,format,type,pixels);
glBindTexture(target, bound);
}
}
inline void COpenGLExtensionHandler::extGlNamedFramebufferTexture(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level)
{
if (!needsDSAFramebufferHack)
{
if (Version>=450)
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
{
pGlNamedFramebufferTexture(framebuffer, attachment, texture, level);
return;
@ -2925,7 +2973,7 @@ inline void COpenGLExtensionHandler::extGlTextureParameteri(GLuint texture, GLen
inline void COpenGLExtensionHandler::extGlCreateTextures(GLenum target, GLsizei n, GLuint* textures)
{
if (Version>=450)
if (Version>=405)
{
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (pGlCreateTextures)
@ -2946,7 +2994,7 @@ inline void COpenGLExtensionHandler::extGlCreateFramebuffers(GLsizei n, GLuint*
{
if (!needsDSAFramebufferHack)
{
if (Version>=450)
if (Version>=405)
{
pGlCreateFramebuffers(n, framebuffers);
return;
@ -2963,7 +3011,7 @@ inline void COpenGLExtensionHandler::extGlBindTextures(GLuint first, GLsizei cou
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
if (Version>=440||FeatureAvailable[IRR_ARB_multi_bind])
if (Version>=404||FeatureAvailable[IRR_ARB_multi_bind])
{
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (pGlBindTextures)
@ -2999,7 +3047,7 @@ inline void COpenGLExtensionHandler::extGlBindTextures(GLuint first, GLsizei cou
inline void COpenGLExtensionHandler::extGlGenerateTextureMipmap(GLuint texture, GLenum target)
{
if (Version>=450)
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
{
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (pGlGenerateTextureMipmap)