From 8c01f7fafff2385275eb3b94f2cf7afa75319468 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 30 Aug 2021 14:02:41 +0200 Subject: [PATCH] gles2gsg: Implement support for GL_EXT_clear_texture in OpenGL ES 2+ --- panda/src/gles2gsg/panda_esgl2ext.h | 10 ++++++++++ panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 12 ++++++++++++ panda/src/glstuff/glGraphicsStateGuardian_src.h | 6 +++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/panda/src/gles2gsg/panda_esgl2ext.h b/panda/src/gles2gsg/panda_esgl2ext.h index 888e8e2553..a95d9b001b 100644 --- a/panda/src/gles2gsg/panda_esgl2ext.h +++ b/panda/src/gles2gsg/panda_esgl2ext.h @@ -1050,6 +1050,16 @@ GL_APICALL void GL_APIENTRY glBufferStorageEXT (GLenum target, GLsizeiptr size, #endif #endif /* GL_EXT_buffer_storage */ +#ifndef GL_EXT_clear_texture +#define GL_EXT_clear_texture 1 +typedef void (GL_APIENTRYP PFNGLCLEARTEXIMAGEEXTPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (GL_APIENTRYP PFNGLCLEARTEXSUBIMAGEEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glClearTexImageEXT (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GL_APICALL void GL_APIENTRY glClearTexSubImageEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +#endif +#endif /* GL_EXT_clear_texture */ + #ifndef GL_EXT_clip_control #define GL_EXT_clip_control 1 #define GL_LOWER_LEFT_EXT 0x8CA1 diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 2bbeff7665..8aba915666 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -1080,6 +1080,18 @@ reset() { _supports_clear_texture = true; } } +#elif !defined(OPENGLES_1) + if (has_extension("GL_EXT_clear_texture")) { + _glClearTexImage = (PFNGLCLEARTEXIMAGEEXTPROC) + get_extension_func("glClearTexImageEXT"); + + if (_glClearTexImage == nullptr) { + GLCAT.warning() + << "GL_EXT_clear_texture advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; + } else { + _supports_clear_texture = true; + } + } #endif _supports_clear_buffer = false; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index c889545fc9..6457cc920c 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -229,10 +229,10 @@ typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFo typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -#endif // OPENGLES_1 -#ifndef OPENGLES typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +#endif // OPENGLES_1 +#ifndef OPENGLES typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); @@ -804,7 +804,7 @@ public: #endif bool _supports_clear_texture; -#ifndef OPENGLES +#ifndef OPENGLES_1 PFNGLCLEARTEXIMAGEPROC _glClearTexImage; #endif