texture mipmap fix

main
Brett 2024-01-25 11:03:17 -05:00
parent 709db71827
commit 129f6e3fb9
3 changed files with 15 additions and 4 deletions

View File

@ -173,7 +173,9 @@ namespace blt::gfx
void upload(void* data, GLint dataColorMode = GL_RGBA, int level = 0, int x_offset = 0, int y_offset = 0, int sub_width = -1, void upload(void* data, GLint dataColorMode = GL_RGBA, int level = 0, int x_offset = 0, int y_offset = 0, int sub_width = -1,
int sub_height = -1, GLint dataMode = GL_UNSIGNED_BYTE) const; int sub_height = -1, GLint dataMode = GL_UNSIGNED_BYTE) const;
void upload(const texture_file& tex_file) const; void upload(void* data, int width, int height, GLint dataColorMode = GL_RGBA, GLint dataMode = GL_UNSIGNED_BYTE);
void upload(const texture_data& file_data) const;
/** /**
* Resizes the internal memory for the texture but does NOT resize the texture image stored * Resizes the internal memory for the texture but does NOT resize the texture image stored

@ -1 +1 @@
Subproject commit 0fbe3bf2281aaa091173d7acd1cc017b3d60bf7b Subproject commit a0b92ddfa756ddf80e280e1af37a057dd0d41cf9

View File

@ -104,12 +104,13 @@ void blt::gfx::texture_gl2D::upload(void* data, GLint dataColorMode, int level,
sub_height = m_height; sub_height = m_height;
bind(); bind();
glTexSubImage2D(textureBindType, level, x_offset, y_offset, sub_width, sub_height, dataColorMode, dataMode, data); glTexSubImage2D(textureBindType, level, x_offset, y_offset, sub_width, sub_height, dataColorMode, dataMode, data);
generateMipmaps();
unbind(); unbind();
} }
void blt::gfx::texture_gl2D::upload(const blt::gfx::texture_file& tex_file) const void blt::gfx::texture_gl2D::upload(const blt::gfx::texture_data& file_data) const
{ {
upload(tex_file.texture().data(), tex_file.channels() == 4 ? GL_RGBA : GL_RGB, 0, 0, 0, tex_file.width(), tex_file.height()); upload((void*)file_data.data(), file_data.channels() == 4 ? GL_RGBA : GL_RGB, 0, 0, 0, file_data.width(), file_data.height());
} }
void blt::gfx::texture_gl2D::resize(int width, int height) void blt::gfx::texture_gl2D::resize(int width, int height)
@ -142,6 +143,14 @@ blt::gfx::texture_gl2D::texture_gl2D(const blt::gfx::texture_data& data): textur
unbind(); unbind();
} }
void blt::gfx::texture_gl2D::upload(void* data, int width, int height, GLint dataColorMode, GLint dataMode)
{
bind();
glTexImage2D(textureBindType, 0, textureColorMode, width, height, 0, dataColorMode, dataMode, data);
generateMipmaps();
unbind();
}
void blt::gfx::gl_texture2D_array::upload(void* data, int index, GLint dataColorMode, int level, int x_offset, int y_offset, int sub_width, void blt::gfx::gl_texture2D_array::upload(void* data, int index, GLint dataColorMode, int level, int x_offset, int y_offset, int sub_width,
int sub_height) const int sub_height) const
{ {