building functions work now

main
Brett 2023-12-17 20:13:28 -05:00
parent e04f4b555d
commit cd5f25e923
4 changed files with 38 additions and 36 deletions

View File

@ -78,7 +78,7 @@ if (${BUILD_GRAPHICS_TESTS})
target_link_libraries(BLT_GRAPHICS_TESTS BLT_WITH_GRAPHICS) 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_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) if (${ENABLE_ADDRSAN} MATCHES ON)
target_compile_options(BLT_GRAPHICS_TESTS PRIVATE -fsanitize=address) target_compile_options(BLT_GRAPHICS_TESTS PRIVATE -fsanitize=address)
@ -114,6 +114,6 @@ if (EMSCRIPTEN)
else () else ()
target_link_libraries(BLT_WITH_GRAPHICS PUBLIC glfw) target_link_libraries(BLT_WITH_GRAPHICS PUBLIC glfw)
target_compile_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) target_link_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing -Wno-unused-function)
endif () endif ()

View File

@ -2876,12 +2876,12 @@ static float stbir__filter_mitchell(float x, float s, void * user_data)
return (0.0f); return (0.0f);
} }
static float stbir__support_zero(float s, void * user_data) //static float stbir__support_zero(float s, void * user_data)
{ //{
STBIR__UNUSED(s); // STBIR__UNUSED(s);
STBIR__UNUSED(user_data); // STBIR__UNUSED(user_data);
return 0; // return 0;
} //}
static float stbir__support_zeropoint5(float s, void * user_data) static float stbir__support_zeropoint5(float s, void * user_data)
{ {

View File

@ -20,7 +20,6 @@
#define BLT_TEXTURE_H #define BLT_TEXTURE_H
#include <blt/gfx/gl_includes.h> #include <blt/gfx/gl_includes.h>
#include <blt/gfx/stb/stb_image.h>
#include <blt/std/logging.h> #include <blt/std/logging.h>
#include <string> #include <string>
#include <vector> #include <vector>
@ -48,27 +47,27 @@ namespace blt::gfx
texture_data() = default; texture_data() = default;
unsigned char* data() inline unsigned char* data()
{ {
return m_data; return m_data;
} }
[[nodiscard]] unsigned char* data() const [[nodiscard]] inline unsigned char* data() const
{ {
return m_data; return m_data;
} }
[[nodiscard]] int width() const [[nodiscard]] inline int width() const
{ {
return m_width; return m_width;
} }
[[nodiscard]] int height() const [[nodiscard]] inline int height() const
{ {
return m_height; return m_height;
} }
[[nodiscard]] int channels() const [[nodiscard]] inline int channels() const
{ {
return m_channels; return m_channels;
} }
@ -94,27 +93,27 @@ namespace blt::gfx
texture_file& resize(int target_width, int target_height); texture_file& resize(int target_width, int target_height);
texture_data& texture() const inline texture_data& texture() const
{ {
return m_texture; return m_texture;
} }
[[nodiscard]] int channels() const [[nodiscard]] inline int channels() const
{ {
return m_texture.m_channels; return m_texture.m_channels;
} }
[[nodiscard]] int width() const [[nodiscard]] inline int width() const
{ {
return m_texture.m_width; return m_texture.m_width;
} }
[[nodiscard]] int height() const [[nodiscard]] inline int height() const
{ {
return m_texture.m_height; return m_texture.m_height;
} }
[[nodiscard]] const std::string& getName() const [[nodiscard]] inline const std::string& getName() const
{ {
return m_name; return m_name;
} }
@ -149,22 +148,7 @@ namespace blt::gfx
glBindTexture(textureBindType, 0); glBindTexture(textureBindType, 0);
} }
void setDefaults() const 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();
}
inline void generateMipmaps() const inline void generateMipmaps() const
{ {

View File

@ -22,6 +22,7 @@
#include <blt/gfx/stb/stb_image_write.h> #include <blt/gfx/stb/stb_image_write.h>
#include <blt/gfx/stb/stb_image_resize2.h> #include <blt/gfx/stb/stb_image_resize2.h>
#include <blt/gfx/stb/stb_image.h>
#include <blt/gfx/stb/stb_perlin.h> #include <blt/gfx/stb/stb_perlin.h>
#include <blt/gfx/texture.h> #include <blt/gfx/texture.h>
@ -66,3 +67,20 @@ blt::gfx::texture_file& blt::gfx::texture_file::resize(int target_width, int tar
return *this; 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();
}