PDA

View Full Version : Getting "GL_INVALID_ENUM" when calling glEnable(GL_TEXTURE_2D)



tmason
10-28-2014, 08:01 PM
Hello,

Title says it all, really. I am initializing my OpenGL context and in the middle of setting up stuff like glPolygonMode(GL_FRONT_AND_BACK, GL_FILL), glEnable(GL_DEPTH_TEST), etc. when I make a call to glEnable(GL_TEXTURE_2D) I get the following ENUM error: "GL_INVALID_ENUM"

I looked up the function: https://www.opengl.org/sdk/docs/man2/xhtml/glEnable.xml

And no fragment shader is active when I call it on my open OpenGL context.

Any ideas?

Thank you.

GClements
10-28-2014, 08:23 PM
It sounds as if you have an OpenGL 3+ core profile context, where GL_TEXTURE_2D is indeed not a valid argument to glEnable() (it's only meaningful for the fixed-function pipeline, and OpenGL 3+ core profile doesn't support the fixed-function pipeline).

tmason
10-28-2014, 08:32 PM
It sounds as if you have an OpenGL 3+ core profile context, where GL_TEXTURE_2D is indeed not a valid argument to glEnable() (it's only meaningful for the fixed-function pipeline, and OpenGL 3+ core profile doesn't support the fixed-function pipeline).

I see, makes sense.

I don't plan on coding in the fixed-function pipeline at all; is it safe to take out and still use textures? I assume yes but I want to check.

Thank you.

GClements
10-28-2014, 08:54 PM
is it safe to take out and still use textures?
Yes.

glEnable(GL_TEXTURE_2D) instructs the fixed-function pipeline's equivalent of the fragment shader to use textures to determine the fragment colour, in accordance with the glTexEnv() settings. If disabled, the fragment colour is based upon vertex colours or the current colour, without involving textures.

It doesn't affect anything else, so when a fragment shader is being used it doesn't affect anything.

tmason
10-29-2014, 02:57 AM
Yes.

glEnable(GL_TEXTURE_2D) instructs the fixed-function pipeline's equivalent of the fragment shader to use textures to determine the fragment colour, in accordance with the glTexEnv() settings. If disabled, the fragment colour is based upon vertex colours or the current colour, without involving textures.

It doesn't affect anything else, so when a fragment shader is being used it doesn't affect anything.

Thanks! Removing this line was indeed OK. I have another issue but that'll be in a separate post.

Thanks again.