chore: fix glReadPixels for older opengl versions

This commit is contained in:
Almamu 2025-04-01 21:57:51 +02:00
parent 35969a7a0a
commit 1e18f760d7
2 changed files with 17 additions and 4 deletions

View File

@ -246,8 +246,15 @@ void CWallpaperApplication::takeScreenshot (const std::filesystem::path& filenam
// read the viewport data into the pixel buffer
glPixelStorei (GL_PACK_ALIGNMENT, 1);
glReadnPixels (viewport->viewport.x, viewport->viewport.y, viewport->viewport.z, viewport->viewport.w, GL_RGB,
GL_UNSIGNED_BYTE, bufferSize, buffer);
// 4.5 supports glReadnPixels, anything older doesn't...
if (GLEW_VERSION_4_5) {
glReadnPixels (viewport->viewport.x, viewport->viewport.y, viewport->viewport.z, viewport->viewport.w,
GL_RGB, GL_UNSIGNED_BYTE, bufferSize, buffer);
} else {
// fallback to old version
glReadPixels (viewport->viewport.x, viewport->viewport.y, viewport->viewport.z, viewport->viewport.w,
GL_RGB, GL_UNSIGNED_BYTE, buffer);
}
GLenum error = glGetError();

View File

@ -133,8 +133,14 @@ void CGLFWOpenGLDriver::dispatchEventQueue () {
// read the full texture into the image
if (this->m_output->haveImageBuffer ()) {
glReadnPixels (0, 0, this->m_output->getFullWidth (), this->m_output->getFullHeight (), GL_BGRA,
GL_UNSIGNED_BYTE, this->m_output->getImageBufferSize(), this->m_output->getImageBuffer ());
// 4.5 supports glReadnPixels, anything older doesn't...
if (GLEW_VERSION_4_5) {
glReadnPixels (0, 0, this->m_output->getFullWidth (), this->m_output->getFullHeight (), GL_BGRA,
GL_UNSIGNED_BYTE, this->m_output->getImageBufferSize (), this->m_output->getImageBuffer ());
} else {
// fallback to old version
glReadPixels (0, 0, this->m_output->getFullWidth (), this->m_output->getFullHeight (), GL_BGRA, GL_UNSIGNED_BYTE, this->m_output->getImageBuffer ());
}
GLenum error = glGetError();