Hello,
Can we add in the ability to generate mipmapping.
Using
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
We can use the glGenerateMipmap() if everyone is on board for that vs. the above code...
I am thinking of something like this?
bool Image::CreateTexture()
{
// Create the OpenGL texture
if (!myTexture)
{
GLint PreviousTexture;
GLCheck(glGetIntegerv(GL_TEXTURE_BINDING_2D, &PreviousTexture));
GLuint Texture = 0;
GLCheck(glGenTextures(1, &Texture));
GLCheck(glBindTexture(GL_TEXTURE_2D, Texture));
GLCheck(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, myTextureWidth, myTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
if(myIsMipmapped)
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myIsSmooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST));
else
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE));
myTexture = static_cast<unsigned int>(Texture);
GLCheck(glBindTexture(GL_TEXTURE_2D, PreviousTexture));
}
}
Mipmapping would be on by default and you would need to add bool IsMipmapped() and SetMipmap(bool)
Please advise!
Thanks,
Dave