Crash due to glBindTexture
I''m not entirely certain what causes the crash, but I do know where it happens.
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, mTextureId);
glColor4f(mRed, mGreen, mBlue, mAlpha);
int endX = mX + mWidth;
int endY = mY + mHeight;
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2d(mX, endY);
glTexCoord2f(1.0f, 0.0f);
glVertex2d(endX, endY);
glTexCoord2f(1.0f, 1.0f);
glVertex2d(endX, mY);
glTexCoord2f(0.0f, 1.0f);
glVertex2d(mX, mY);
glEnd();
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
The crash occurs somewhere in this code. Now the code works. What I''m trying to accomplish, though, is to generate a texture once, and then have multiple calls using it. The code above is contained in a class. If someone needs the class code to answer I can post it. The program runs fine as long as only one instance is using a texture, but the moment two are and I try to close the program there''s an unhandled exception at NVOGLNT!
Can someone help me with this?
Additional:
If I set the texture id of the second instance to 0 after it draws, the crashes stop. It appears that OpenGL doesn''t like having the same texture bound twice. Which is crazy, but I''m sure it makes sense in some way.
Is there a way to "unbind" a texture without deleting it or binding to some constant?
If I set the texture id of the second instance to 0 after it draws, the crashes stop. It appears that OpenGL doesn''t like having the same texture bound twice. Which is crazy, but I''m sure it makes sense in some way.
Is there a way to "unbind" a texture without deleting it or binding to some constant?
Is mTextureId a static member of your class ? If it is not, different instances of the class won''t share the same texture.
Please post the class code, and the relevant calls to the class members. (between [ source ] and [ /source ] (wihtout the spaces) tags so that it looks good).
Please post the class code, and the relevant calls to the class members. (between [ source ] and [ /source ] (wihtout the spaces) tags so that it looks good).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement