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
m_glGetGraphicsResetStatus = (glGetGraphicsResetStatus_func)resolveFunction("glGetGraphicsResetStatusARB");
m_glReadnPixels = (glReadnPixels_func)resolveFunction("glReadnPixelsARB");
m_glGetnTexImage = (glGetnTexImage_func)resolveFunction("glGetnTexImageARB");
m_glGetnUniformfv = (glGetnUniformfv_func)resolveFunction("glGetnUniformfvARB");
} else if (robustContext && haveExtRobustness) {
// 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)
{
if (m_glGetnUniformfv) {

View file

@ -31,6 +31,8 @@ class GLPlatform;
using glGetGraphicsResetStatus_func = GLenum (*)();
using glReadnPixels_func = void (*)(GLint x, GLint y, GLsizei width, GLsizei height,
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);
class KWIN_EXPORT OpenGlContext
@ -79,6 +81,7 @@ public:
GLenum checkGraphicsResetStatus();
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 pushFramebuffer(GLFramebuffer *fbo);
@ -124,6 +127,7 @@ protected:
const std::unique_ptr<GLPlatform> m_glPlatform;
glGetGraphicsResetStatus_func m_glGetGraphicsResetStatus = nullptr;
glReadnPixels_func m_glReadnPixels = nullptr;
glGetnTexImage_func m_glGetnTexImage = nullptr;
glGetnUniformfv_func m_glGetnUniformfv = nullptr;
ShaderManager *m_shaderManager = 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());
GLFramebuffer::popFramebuffer();
} else {
if (context->openglVersion() >= Version(4, 5)) {
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());
}
context->glGetnTexImage(texture->target(), 0, closestGLType(target->format()), GL_UNSIGNED_BYTE, target->sizeInBytes(), target->bits());
}
if (invertNeededAndSupported) {