View Full Version : glGenTextures problem in MFC app

01-21-2002, 02:31 AM
I am doing a very elementary OpenGL application under Windows, and am using MFC. I know, it's a performance pig, but I'm just trying to get my head around the big picture of OpenGL.

However, whenever I call glGenTextures in the application, no texture number is generated. glGetError returns GL_INVALID_OPERATION. According to the documentation, this only can happen if glGenTextures is called between glBegin and glEnd.

I have checked exhaustively, including adding code at the earliest possible place in my code, and am certain that I am not calling glBegin before the glGenTextures call.

I've built some GLUT demos on my machine that use texture objects and traced through them, and they all perform as expected. Has anyone seen anything like this, or can anyone help a flustered newbie with this?

Thanks in advance for any suggestions!

- Steve

01-21-2002, 06:56 AM
Does your code look something like this:

glGenTextures (1, &textureID[0]); // Generate space for Texture Objects

01-21-2002, 08:02 AM
I have a class I am using for maintaining individual textures, so it's more along the lines of:

GLuint m_nTextureID; // this is declared in the header file

glGenTextures (1, &m_nTextureID); // this is called when I load a texture

I'm hoping that there is something really obvious I'm doing here, and I've just being staring at the code too long to see it.

- Steve

01-21-2002, 12:25 PM
Dunno... I was hoping for summit obvious 2.

Can you post a pointer to the code?

01-21-2002, 05:16 PM
When you call glGenTextures have you created a resource context and set it up as the current context? I am fairly sure that no GL functions will work till you have done that

01-21-2002, 06:35 PM
Yeah, Make sure you call glGenTex after you make the context current. Otherwise you would get the INVALID_OPERATION error that you noted....


01-22-2002, 07:45 AM
Well, I feel sheepish. Yes, I was trying to call the function outside of a valid render context. Things are working much better now http://www.opengl.org/discussion_boards/ubb/wink.gif the performance gain is pretty staggering too.

Thanks to all who replied!

- Steve