diff --git a/include/blt/gfx/texture.h b/include/blt/gfx/texture.h index 68b1be3..82f02b5 100644 --- a/include/blt/gfx/texture.h +++ b/include/blt/gfx/texture.h @@ -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, 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 diff --git a/libraries/BLT b/libraries/BLT index 0fbe3bf..a0b92dd 160000 --- a/libraries/BLT +++ b/libraries/BLT @@ -1 +1 @@ -Subproject commit 0fbe3bf2281aaa091173d7acd1cc017b3d60bf7b +Subproject commit a0b92ddfa756ddf80e280e1af37a057dd0d41cf9 diff --git a/src/blt/gfx/texture.cpp b/src/blt/gfx/texture.cpp index 2f7504d..22a1782 100644 --- a/src/blt/gfx/texture.cpp +++ b/src/blt/gfx/texture.cpp @@ -104,12 +104,13 @@ void blt::gfx::texture_gl2D::upload(void* data, GLint dataColorMode, int level, sub_height = m_height; bind(); glTexSubImage2D(textureBindType, level, x_offset, y_offset, sub_width, sub_height, dataColorMode, dataMode, data); + generateMipmaps(); 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) @@ -142,6 +143,14 @@ blt::gfx::texture_gl2D::texture_gl2D(const blt::gfx::texture_data& data): textur 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, int sub_height) const {