add support for high res brush textures, implement mipmaps on brush
This commit is contained in:
@@ -5,12 +5,15 @@
|
||||
|
||||
std::map<uint16_t, Texture2D> TextureManager::m_textures;
|
||||
|
||||
bool TextureManager::load(const char* path)
|
||||
bool TextureManager::load(const char* path, bool generate_mipmaps)
|
||||
{
|
||||
uint16_t id = const_hash(path);
|
||||
if (m_textures.count(id) == 0 || !m_textures[id].ready())
|
||||
{
|
||||
return m_textures[id].load(path);
|
||||
if (!m_textures[id].load(path))
|
||||
return false;
|
||||
if (generate_mipmaps)
|
||||
m_textures[id].create_mipmaps();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -54,6 +57,13 @@ bool Texture2D::create(const ui::Image& img)
|
||||
return create(img.width, img.height, iformats[img.comp - 1], formats[img.comp - 1], img.data());
|
||||
}
|
||||
|
||||
void Texture2D::create_mipmaps()
|
||||
{
|
||||
bind();
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
unbind();
|
||||
}
|
||||
|
||||
void Texture2D::assign(GLuint tex, int w/* = -1*/, int h/* = -1*/, GLuint internal_format/* = GL_RGBA8*/, GLuint format/* = GL_RGBA*/)
|
||||
{
|
||||
m_tex = tex;
|
||||
@@ -102,6 +112,13 @@ void Sampler::set(GLint filter /*= GL_LINEAR*/, GLint wrap /*= GL_CLAMP_TO_EDGE*
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, filter);
|
||||
#endif // USE_SAMPLER
|
||||
}
|
||||
void Sampler::set_filter(GLint filter_min, GLint filter_mag)
|
||||
{
|
||||
#if USE_SAMPLER
|
||||
glSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, filter_min);
|
||||
glSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, filter_mag);
|
||||
#endif // USE_SAMPLER
|
||||
}
|
||||
void Sampler::bind(int unit)
|
||||
{
|
||||
current_unit = unit;
|
||||
|
||||
Reference in New Issue
Block a user