opengl: Add OpenGlContext::glGetnTexImage()

Add glGetnTexImage() to be consistent with other robustness stuff.
This commit is contained in:
Vlad Zahorodnii 2024-07-04 14:14:58 +03:00
parent 74d7c33a97
commit 9ce095dad3
3 changed files with 15 additions and 5 deletions

View file

@ -334,6 +334,7 @@ void OpenGlContext::glResolveFunctions(const std::function<resolveFuncPtr(const
// See https://www.opengl.org/registry/specs/ARB/robustness.txt // See https://www.opengl.org/registry/specs/ARB/robustness.txt
m_glGetGraphicsResetStatus = (glGetGraphicsResetStatus_func)resolveFunction("glGetGraphicsResetStatusARB"); m_glGetGraphicsResetStatus = (glGetGraphicsResetStatus_func)resolveFunction("glGetGraphicsResetStatusARB");
m_glReadnPixels = (glReadnPixels_func)resolveFunction("glReadnPixelsARB"); m_glReadnPixels = (glReadnPixels_func)resolveFunction("glReadnPixelsARB");
m_glGetnTexImage = (glGetnTexImage_func)resolveFunction("glGetnTexImageARB");
m_glGetnUniformfv = (glGetnUniformfv_func)resolveFunction("glGetnUniformfvARB"); m_glGetnUniformfv = (glGetnUniformfv_func)resolveFunction("glGetnUniformfvARB");
} else if (robustContext && haveExtRobustness) { } else if (robustContext && haveExtRobustness) {
// See https://www.khronos.org/registry/gles/extensions/EXT/EXT_robustness.txt // See https://www.khronos.org/registry/gles/extensions/EXT/EXT_robustness.txt
@ -434,6 +435,15 @@ void OpenGlContext::glReadnPixels(GLint x, GLint y, GLsizei width, GLsizei heigh
} }
} }
void OpenGlContext::glGetnTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels)
{
if (m_glGetnTexImage) {
m_glGetnTexImage(target, level, format, type, bufSize, pixels);
} else {
glGetTexImage(target, level, format, type, pixels);
}
}
void OpenGlContext::glGetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params) void OpenGlContext::glGetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params)
{ {
if (m_glGetnUniformfv) { if (m_glGetnUniformfv) {

View file

@ -31,6 +31,8 @@ class GLPlatform;
using glGetGraphicsResetStatus_func = GLenum (*)(); using glGetGraphicsResetStatus_func = GLenum (*)();
using glReadnPixels_func = void (*)(GLint x, GLint y, GLsizei width, GLsizei height, using glReadnPixels_func = void (*)(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); GLenum format, GLenum type, GLsizei bufSize, GLvoid *data);
using glGetnTexImage_func = void (*)(GLenum target, GLint level, GLenum format, GLenum type,
GLsizei bufSize, void *pixels);
using glGetnUniformfv_func = void (*)(GLuint program, GLint location, GLsizei bufSize, GLfloat *params); using glGetnUniformfv_func = void (*)(GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
class KWIN_EXPORT OpenGlContext class KWIN_EXPORT OpenGlContext
@ -79,6 +81,7 @@ public:
GLenum checkGraphicsResetStatus(); GLenum checkGraphicsResetStatus();
void glReadnPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); void glReadnPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data);
void glGetnTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels);
void glGetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params); void glGetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
void pushFramebuffer(GLFramebuffer *fbo); void pushFramebuffer(GLFramebuffer *fbo);
@ -124,6 +127,7 @@ protected:
const std::unique_ptr<GLPlatform> m_glPlatform; const std::unique_ptr<GLPlatform> m_glPlatform;
glGetGraphicsResetStatus_func m_glGetGraphicsResetStatus = nullptr; glGetGraphicsResetStatus_func m_glGetGraphicsResetStatus = nullptr;
glReadnPixels_func m_glReadnPixels = nullptr; glReadnPixels_func m_glReadnPixels = nullptr;
glGetnTexImage_func m_glGetnTexImage = nullptr;
glGetnUniformfv_func m_glGetnUniformfv = nullptr; glGetnUniformfv_func m_glGetnUniformfv = nullptr;
ShaderManager *m_shaderManager = nullptr; ShaderManager *m_shaderManager = nullptr;
GLVertexBuffer *m_streamingBuffer = nullptr; GLVertexBuffer *m_streamingBuffer = nullptr;

View file

@ -60,11 +60,7 @@ static void doGrabTexture(GLTexture *texture, QImage *target)
context->glReadnPixels(0, 0, size.width(), size.height(), closestGLType(target->format()), GL_UNSIGNED_BYTE, target->sizeInBytes(), target->bits()); context->glReadnPixels(0, 0, size.width(), size.height(), closestGLType(target->format()), GL_UNSIGNED_BYTE, target->sizeInBytes(), target->bits());
GLFramebuffer::popFramebuffer(); GLFramebuffer::popFramebuffer();
} else { } else {
if (context->openglVersion() >= Version(4, 5)) { context->glGetnTexImage(texture->target(), 0, closestGLType(target->format()), GL_UNSIGNED_BYTE, target->sizeInBytes(), target->bits());
glGetnTexImage(texture->target(), 0, closestGLType(target->format()), GL_UNSIGNED_BYTE, target->sizeInBytes(), target->bits());
} else {
glGetTexImage(texture->target(), 0, closestGLType(target->format()), GL_UNSIGNED_BYTE, target->bits());
}
} }
if (invertNeededAndSupported) { if (invertNeededAndSupported) {