From 4a4c3d5e3b9aba656a0956fcdbcce3b12c2f9d56 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 24 Apr 2020 03:21:44 +1000 Subject: [PATCH] GL/Texture: Add internal format as parameter --- src/common/gl/texture.cpp | 5 +++-- src/common/gl/texture.h | 2 +- src/core/gpu_hw_opengl.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/common/gl/texture.cpp b/src/common/gl/texture.cpp index 76108a519..8fb60333d 100644 --- a/src/common/gl/texture.cpp +++ b/src/common/gl/texture.cpp @@ -21,14 +21,15 @@ Texture::~Texture() Destroy(); } -bool Texture::Create(u32 width, u32 height, GLenum format, GLenum type, const void* data, bool linear_filter) +bool Texture::Create(u32 width, u32 height, GLenum internal_format, GLenum format, GLenum type, const void* data, + bool linear_filter) { glGetError(); GLuint id; glGenTextures(1, &id); glBindTexture(GL_TEXTURE_2D, id); - glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, type, data); + glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, type, data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, linear_filter ? GL_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, linear_filter ? GL_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); diff --git a/src/common/gl/texture.h b/src/common/gl/texture.h index c86e720f6..08bc9ea5a 100644 --- a/src/common/gl/texture.h +++ b/src/common/gl/texture.h @@ -10,7 +10,7 @@ public: Texture(Texture&& moved); ~Texture(); - bool Create(u32 width, u32 height, GLenum format, GLenum type, const void* data = nullptr, + bool Create(u32 width, u32 height, GLenum internal_format, GLenum format, GLenum type, const void* data = nullptr, bool linear_filter = false); bool CreateFramebuffer(); diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index 44c3de98a..e5bc6c60e 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -211,7 +211,7 @@ bool GPU_HW_OpenGL::CreateFramebuffer() const u32 texture_width = VRAM_WIDTH * m_resolution_scale; const u32 texture_height = VRAM_HEIGHT * m_resolution_scale; - if (!m_vram_texture.Create(texture_width, texture_height, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false) || + if (!m_vram_texture.Create(texture_width, texture_height, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false) || !m_vram_texture.CreateFramebuffer()) { return false; @@ -233,11 +233,11 @@ bool GPU_HW_OpenGL::CreateFramebuffer() old_vram_texture.Destroy(); } - if (!m_vram_read_texture.Create(texture_width, texture_height, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false) || + if (!m_vram_read_texture.Create(texture_width, texture_height, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false) || !m_vram_read_texture.CreateFramebuffer() || - !m_vram_encoding_texture.Create(VRAM_WIDTH, VRAM_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false) || + !m_vram_encoding_texture.Create(VRAM_WIDTH, VRAM_HEIGHT, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false) || !m_vram_encoding_texture.CreateFramebuffer() || - !m_display_texture.Create(texture_width, texture_height, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false) || + !m_display_texture.Create(texture_width, texture_height, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false) || !m_display_texture.CreateFramebuffer()) { return false;