defaults and mipmap
parent
cd5f25e923
commit
68fd994119
|
@ -137,6 +137,13 @@ namespace blt::gfx
|
||||||
glGenTextures(1, &textureID);
|
glGenTextures(1, &textureID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setDefaults() const;
|
||||||
|
|
||||||
|
inline void generateMipmaps() const
|
||||||
|
{
|
||||||
|
glGenerateMipmap(textureBindType);
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
inline void bind() const
|
inline void bind() const
|
||||||
{
|
{
|
||||||
|
@ -148,16 +155,6 @@ namespace blt::gfx
|
||||||
glBindTexture(textureBindType, 0);
|
glBindTexture(textureBindType, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDefaults() const;
|
|
||||||
|
|
||||||
inline void generateMipmaps() const
|
|
||||||
{
|
|
||||||
// it's a little inefficient binding and unbinding for these small calls, they really should be done in the constructor or data upload
|
|
||||||
bind();
|
|
||||||
glGenerateMipmap(textureBindType);
|
|
||||||
unbind();
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] inline unsigned int getTextureID() const
|
[[nodiscard]] inline unsigned int getTextureID() const
|
||||||
{
|
{
|
||||||
return textureID;
|
return textureID;
|
||||||
|
@ -176,6 +173,7 @@ namespace blt::gfx
|
||||||
texture_gl(width, height, GL_TEXTURE_2D, colorMode)
|
texture_gl(width, height, GL_TEXTURE_2D, colorMode)
|
||||||
{
|
{
|
||||||
bind();
|
bind();
|
||||||
|
setDefaults();
|
||||||
// TODO:
|
// TODO:
|
||||||
const int MIPMAP_LEVELS = 4;
|
const int MIPMAP_LEVELS = 4;
|
||||||
glTexStorage2D(
|
glTexStorage2D(
|
||||||
|
@ -196,6 +194,7 @@ namespace blt::gfx
|
||||||
textureBindType, level, x_offset, y_offset, sub_width, sub_height,
|
textureBindType, level, x_offset, y_offset, sub_width, sub_height,
|
||||||
dataColorMode, GL_UNSIGNED_BYTE, data
|
dataColorMode, GL_UNSIGNED_BYTE, data
|
||||||
);
|
);
|
||||||
|
generateMipmaps();
|
||||||
unbind();
|
unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +225,7 @@ namespace blt::gfx
|
||||||
texture_gl(width, height, GL_TEXTURE_2D_ARRAY, colorMode), m_layers(layers)
|
texture_gl(width, height, GL_TEXTURE_2D_ARRAY, colorMode), m_layers(layers)
|
||||||
{
|
{
|
||||||
bind();
|
bind();
|
||||||
|
setDefaults();
|
||||||
// 6+ mipmaps is about where I stop noticing any difference (size is 4x4 pixels, so that makes sense)
|
// 6+ mipmaps is about where I stop noticing any difference (size is 4x4 pixels, so that makes sense)
|
||||||
glTexStorage3D(textureBindType, 6, colorMode, width, height, layers);
|
glTexStorage3D(textureBindType, 6, colorMode, width, height, layers);
|
||||||
BLT_DEBUG("Creating 2D Texture Array with ID: %d", textureID);
|
BLT_DEBUG("Creating 2D Texture Array with ID: %d", textureID);
|
||||||
|
@ -243,6 +243,7 @@ namespace blt::gfx
|
||||||
textureBindType, level, x_offset, y_offset, index, sub_width, sub_height, 1,
|
textureBindType, level, x_offset, y_offset, index, sub_width, sub_height, 1,
|
||||||
dataColorMode, GL_UNSIGNED_BYTE, data
|
dataColorMode, GL_UNSIGNED_BYTE, data
|
||||||
);
|
);
|
||||||
|
generateMipmaps();
|
||||||
unbind();
|
unbind();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -70,7 +70,6 @@ blt::gfx::texture_file& blt::gfx::texture_file::resize(int target_width, int tar
|
||||||
|
|
||||||
void blt::gfx::texture_gl::setDefaults() const
|
void blt::gfx::texture_gl::setDefaults() const
|
||||||
{
|
{
|
||||||
bind();
|
|
||||||
glTexParameteri(textureBindType, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(textureBindType, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
glTexParameteri(textureBindType, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(textureBindType, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
// nearest preserves the pixely look
|
// nearest preserves the pixely look
|
||||||
|
@ -82,5 +81,4 @@ void blt::gfx::texture_gl::setDefaults() const
|
||||||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &a);
|
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &a);
|
||||||
glTexParameterf(textureBindType, GL_TEXTURE_MAX_ANISOTROPY_EXT, a);
|
glTexParameterf(textureBindType, GL_TEXTURE_MAX_ANISOTROPY_EXT, a);
|
||||||
#endif
|
#endif
|
||||||
unbind();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue