From cd5f25e923d19249430ddd53583990e7c34c3603 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Sun, 17 Dec 2023 20:13:28 -0500 Subject: [PATCH] building functions work now --- CMakeLists.txt | 6 ++-- include/blt/gfx/stb/stb_image_resize2.h | 12 ++++---- include/blt/gfx/texture.h | 38 +++++++------------------ src/blt/gfx/texture.cpp | 18 ++++++++++++ 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b23358..1fdd20d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,7 @@ if (${BUILD_GRAPHICS_TESTS}) target_link_libraries(BLT_GRAPHICS_TESTS BLT_WITH_GRAPHICS) target_compile_options(BLT_GRAPHICS_TESTS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing) - target_link_options(BLT_GRAPHICS_TESTS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing) + target_link_options(BLT_GRAPHICS_TESTS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing -Wno-unused-function) if (${ENABLE_ADDRSAN} MATCHES ON) target_compile_options(BLT_GRAPHICS_TESTS PRIVATE -fsanitize=address) @@ -114,6 +114,6 @@ if (EMSCRIPTEN) else () target_link_libraries(BLT_WITH_GRAPHICS PUBLIC glfw) - target_compile_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing) - target_link_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing) + target_compile_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing -Wno-unused-function) + target_link_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing -Wno-unused-function) endif () \ No newline at end of file diff --git a/include/blt/gfx/stb/stb_image_resize2.h b/include/blt/gfx/stb/stb_image_resize2.h index faf1b08..ec1aee3 100644 --- a/include/blt/gfx/stb/stb_image_resize2.h +++ b/include/blt/gfx/stb/stb_image_resize2.h @@ -2876,12 +2876,12 @@ static float stbir__filter_mitchell(float x, float s, void * user_data) return (0.0f); } -static float stbir__support_zero(float s, void * user_data) -{ - STBIR__UNUSED(s); - STBIR__UNUSED(user_data); - return 0; -} +//static float stbir__support_zero(float s, void * user_data) +//{ +// STBIR__UNUSED(s); +// STBIR__UNUSED(user_data); +// return 0; +//} static float stbir__support_zeropoint5(float s, void * user_data) { diff --git a/include/blt/gfx/texture.h b/include/blt/gfx/texture.h index aca607d..376b1b8 100644 --- a/include/blt/gfx/texture.h +++ b/include/blt/gfx/texture.h @@ -20,7 +20,6 @@ #define BLT_TEXTURE_H #include -#include #include #include #include @@ -48,27 +47,27 @@ namespace blt::gfx texture_data() = default; - unsigned char* data() + inline unsigned char* data() { return m_data; } - [[nodiscard]] unsigned char* data() const + [[nodiscard]] inline unsigned char* data() const { return m_data; } - [[nodiscard]] int width() const + [[nodiscard]] inline int width() const { return m_width; } - [[nodiscard]] int height() const + [[nodiscard]] inline int height() const { return m_height; } - [[nodiscard]] int channels() const + [[nodiscard]] inline int channels() const { return m_channels; } @@ -94,27 +93,27 @@ namespace blt::gfx texture_file& resize(int target_width, int target_height); - texture_data& texture() const + inline texture_data& texture() const { return m_texture; } - [[nodiscard]] int channels() const + [[nodiscard]] inline int channels() const { return m_texture.m_channels; } - [[nodiscard]] int width() const + [[nodiscard]] inline int width() const { return m_texture.m_width; } - [[nodiscard]] int height() const + [[nodiscard]] inline int height() const { return m_texture.m_height; } - [[nodiscard]] const std::string& getName() const + [[nodiscard]] inline const std::string& getName() const { return m_name; } @@ -149,22 +148,7 @@ namespace blt::gfx glBindTexture(textureBindType, 0); } - void setDefaults() const - { - bind(); - glTexParameteri(textureBindType, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(textureBindType, GL_TEXTURE_WRAP_T, GL_REPEAT); - // nearest preserves the pixely look - glTexParameteri(textureBindType, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); - glTexParameteri(textureBindType, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_LINEAR); -#ifdef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT - // Anisotropy helps preserve textures at oblique angles - float a = 0; - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &a); - glTexParameterf(textureBindType, GL_TEXTURE_MAX_ANISOTROPY_EXT, a); -#endif - unbind(); - } + void setDefaults() const; inline void generateMipmaps() const { diff --git a/src/blt/gfx/texture.cpp b/src/blt/gfx/texture.cpp index ebf3aef..6d40526 100644 --- a/src/blt/gfx/texture.cpp +++ b/src/blt/gfx/texture.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -66,3 +67,20 @@ blt::gfx::texture_file& blt::gfx::texture_file::resize(int target_width, int tar return *this; } + +void blt::gfx::texture_gl::setDefaults() const +{ + bind(); + glTexParameteri(textureBindType, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(textureBindType, GL_TEXTURE_WRAP_T, GL_REPEAT); + // nearest preserves the pixely look + glTexParameteri(textureBindType, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); + glTexParameteri(textureBindType, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_LINEAR); +#ifdef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT + // Anisotropy helps preserve textures at oblique angles + float a = 0; + glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &a); + glTexParameterf(textureBindType, GL_TEXTURE_MAX_ANISOTROPY_EXT, a); +#endif + unbind(); +}