|
5 | 5 | #include "Util/Logger.hpp" |
6 | 6 |
|
7 | 7 | namespace Core { |
8 | | -Texture::Texture(GLint format, int width, int height, const void *data) { |
| 8 | +Texture::Texture(GLint format, int width, int height, const void *data, |
| 9 | + bool useAA) { |
9 | 10 | glGenTextures(1, &m_TextureId); |
| 11 | + UseAntiAliasing(useAA); |
10 | 12 | UpdateData(format, width, height, data); |
11 | 13 | } |
12 | 14 |
|
@@ -56,7 +58,23 @@ void Texture::UpdateData(GLint format, int width, int height, |
56 | 58 | glTexImage2D(GL_TEXTURE_2D, 0, GlFormatToGlInternalFormat(format), width, |
57 | 59 | height, 0, format, GL_UNSIGNED_BYTE, data); |
58 | 60 |
|
59 | | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
60 | | - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 61 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, m_MinFilter); |
| 62 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, m_MagFilter); |
| 63 | + glGenerateMipmap(GL_TEXTURE_2D); |
| 64 | +} |
| 65 | + |
| 66 | +void Texture::UseAntiAliasing(bool useAA) { |
| 67 | + /** |
| 68 | + * additional docs |
| 69 | + * https://www.khronos.org/opengl/wiki/Texture |
| 70 | + * https://www.khronos.org/opengl/wiki/Sampler_Object#Sampling_parameters |
| 71 | + */ |
| 72 | + if (useAA) { |
| 73 | + m_MinFilter = GL_LINEAR_MIPMAP_LINEAR; |
| 74 | + m_MagFilter = GL_LINEAR; |
| 75 | + } else { |
| 76 | + m_MinFilter = GL_NEAREST_MIPMAP_NEAREST; |
| 77 | + m_MagFilter = GL_NEAREST; |
| 78 | + } |
61 | 79 | } |
62 | 80 | } // namespace Core |
0 commit comments