Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does GL_LINEAR_MIPMAP_LINEAR give an INVALID_ENUM error?

Tags:

ios

opengl-es

Using XCode 4.4.1 I have the following OpenGL code:

//set the tex params
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);

I check the OpenGL error using this snippet:

GLenum err = glGetError();//THIS IS LIKE THIS BECAUSE OF AN EARLIER ERROR

if (err != GL_NO_ERROR)
{
    NSLog(@"glError: 0x%04X", i, err);
}

The OpenGL code produces an error (0x500) - I'm targetting iOS 5.0 with OpenGL ES2.0.

Why is this an invalid enum??

like image 267
user1654794 Avatar asked Sep 07 '12 13:09

user1654794


1 Answers

The magnifaction filter GL_TEXTURE_MAG_FILTER doesn't support mip-mapping, as this just has no meaning for texture magnification. It only supports GL_NEAREST and GL_LINEAR. So just change this line to

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
like image 181
Christian Rau Avatar answered Sep 28 '22 05:09

Christian Rau