mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
chore: fix glReadPixels for older opengl versions
This commit is contained in:
parent
35969a7a0a
commit
1e18f760d7
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user