summaryrefslogtreecommitdiff
path: root/src/render/OpenGL.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2023-12-04 03:52:54 +0000
committerVaxry <vaxry@vaxry.net>2023-12-04 03:52:54 +0000
commit68783d904d850df65887adb1bab7eff59943c1ac (patch)
tree8c79712bf5213c1236b3a20f5874854459303f08 /src/render/OpenGL.cpp
parent5d100bdcbbd87bac74935eae6b7d7aed25620323 (diff)
screencopy: use buffer format for glReadPixels
fixes #4029
Diffstat (limited to 'src/render/OpenGL.cpp')
-rw-r--r--src/render/OpenGL.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index 061cc2b5..2c9151e5 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -2067,14 +2067,6 @@ void CHyprOpenGLImpl::setMonitorTransformEnabled(bool enabled) {
m_bEndFrame = !enabled;
}
-struct SGLPixelFormat {
- uint32_t drmFormat = DRM_FORMAT_INVALID;
- GLint glInternalFormat = 0;
- GLint glFormat = 0;
- GLint glType = 0;
- bool withAlpha = false;
-};
-
inline const SGLPixelFormat GLES2_FORMATS[] = {
{
.drmFormat = DRM_FORMAT_ARGB8888,
@@ -2179,9 +2171,6 @@ inline const SGLPixelFormat GLES2_FORMATS[] = {
};
uint32_t CHyprOpenGLImpl::getPreferredReadFormat(CMonitor* pMonitor) {
- if (g_pHyprRenderer->isNvidia())
- return DRM_FORMAT_XBGR8888;
-
GLint glf = -1, glt = -1, as = -1;
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &glf);
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &glt);
@@ -2202,3 +2191,12 @@ uint32_t CHyprOpenGLImpl::getPreferredReadFormat(CMonitor* pMonitor) {
return DRM_FORMAT_XBGR8888;
}
+
+const SGLPixelFormat* CHyprOpenGLImpl::getPixelFormatFromDRM(uint32_t drmFormat) {
+ for (auto& fmt : GLES2_FORMATS) {
+ if (fmt.drmFormat == drmFormat)
+ return &fmt;
+ }
+
+ return nullptr;
+} \ No newline at end of file