summaryrefslogtreecommitdiff
path: root/src/render/Framebuffer.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2023-10-30 15:56:02 +0000
committerVaxry <vaxry@vaxry.net>2023-10-30 15:56:16 +0000
commit4b592d0819e2f4563d59e6cbb2c3c236ec8f23af (patch)
tree0224cb3f7e1ff4c72c2030d103af35500bc9aed4 /src/render/Framebuffer.cpp
parenta1924ae4356657a06e43e740f1cf2e1634fa958d (diff)
renderer: properly pass 10-bit formats to opengl
Diffstat (limited to 'src/render/Framebuffer.cpp')
-rw-r--r--src/render/Framebuffer.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/render/Framebuffer.cpp b/src/render/Framebuffer.cpp
index a62ea18a..e1f815ce 100644
--- a/src/render/Framebuffer.cpp
+++ b/src/render/Framebuffer.cpp
@@ -1,10 +1,13 @@
#include "Framebuffer.hpp"
#include "OpenGL.hpp"
-bool CFramebuffer::alloc(int w, int h) {
+bool CFramebuffer::alloc(int w, int h, uint32_t drmFormat) {
bool firstAlloc = false;
RASSERT((w > 1 && h > 1), "cannot alloc a FB with negative / zero size! (attempted {}x{})", w, h);
+ uint32_t glFormat = drmFormatToGL(drmFormat);
+ uint32_t glType = glFormat != GL_RGBA ? GL_UNSIGNED_INT_2_10_10_10_REV : GL_UNSIGNED_BYTE;
+
if (m_iFb == (uint32_t)-1) {
firstAlloc = true;
glGenFramebuffers(1, &m_iFb);
@@ -22,7 +25,7 @@ bool CFramebuffer::alloc(int w, int h) {
if (firstAlloc || m_vSize != Vector2D(w, h)) {
glBindTexture(GL_TEXTURE_2D, m_cTex.m_iTexID);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+ glTexImage2D(GL_TEXTURE_2D, 0, glFormat, w, h, 0, GL_RGBA, glType, 0);
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex.m_iTexID, 0);