Unify texture configuration.

This commit is contained in:
2018-02-27 16:04:38 +01:00
parent 7fdce48259
commit 0b8c05ded9
4 changed files with 18 additions and 22 deletions

View File

@@ -34,3 +34,18 @@ void Texture::bind(GLenum target) const
{
glBindTexture(target, id);
}
void Texture::configure(GLenum target) const
{
bind(target);
const float color[] = {1, 0, 1}; // Background color for textures.
// Set up (lack of) repetition
glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, color);
// Set up texture scaling
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); // Use mipmapping for scaling down
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Use nearest pixel when scaling up.
}