Skip to content

Commit

Permalink
PlatformCore: Conditionally set texture format
Browse files Browse the repository at this point in the history
sRGB texture format is needed for the output to look right with
sRGB framebuffer enabled and no color correction shader applied.
  • Loading branch information
GranMinigun committed Oct 6, 2023
1 parent e626a89 commit 7421221
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/platform/core/src/device/ogl_video_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ void OGLVideoDevice::UpdateTextures() {
constexpr GLsizei gba_screen_width = 240;
constexpr GLsizei gba_screen_height = 160;

const auto texture_format =
config->video.color == Video::Color::No ? GL_SRGB8_ALPHA8 : GL_RGBA8;

for(auto& texture_ref : texture) {
glBindTexture(GL_TEXTURE_2D, texture_ref);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, gba_screen_width, gba_screen_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, nullptr);
glTexImage2D(GL_TEXTURE_2D, 0, texture_format, gba_screen_width,
gba_screen_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, nullptr);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture_filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texture_filter);
Expand Down

0 comments on commit 7421221

Please sign in to comment.