glEnd error

Started by
2 comments, last by Firestryke31 13 years, 3 months ago
I'm not afraid to admit I don't know OpenGL very well. However, it seemed simplest to use in my project without adding 600 dependencies and what not.

I've been poking around tutorials and the documentation, and have been able to get stuff on the screen. Then I decided to try to clean up my code.

Right now I'm at the bare minimum "draw a quad on the screen" stage. For some reason I keep getting glEnd to error (as reported by glGetError()). I'm hoping a fresh pair (or more) of eyes will help me figure out the error.


My check code:

void check()
{
GLenum error = glGetError();
if(error != GL_NO_ERROR)
{
MessageBox(NULL, L"There was a failure!", L"Assert fail!", MB_OK);
__asm int 3;
// ^^ allows me to break into the program to see error without a
// bunch of support code. I simply use the variable view in my IDE
}
}


Here's my GL state setup code:

glShadeModel(GL_SMOOTH);
glClearColor(0, 0, 0, 0);
glClearDepth(1);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


"Loading" the texture:

glGenTextures(NUM_TEXTURES, texture);
check();

// Font Texture
GLuint *fontTextureData = new GLuint[128 * 128];

// ...
// Unpack font bmp. I know this works
// ...

glBindTexture(GL_TEXTURE_2D, fontTexture);
check();

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, fontTextureData);
check();

delete[] fontTextureData;


My rendering "function:"

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glBindTexture(GL_TEXTURE_2D, fontTexture);
check();
glBegin(GL_QUADS);
check();
glVertex3f(-1.0, -1.0, -1.0);
glVertex3f(-1.0, 1.0, -1.0);
glVertex3f(1.0, 1.0, -1.0);
glVertex3f(1.0, -1.0, -1.0);
glEnd();
check();
SwapBuffers(hDC);
Sleep(0); // Sleep(0) just says "I'm done for now"
Advertisement
What error code does glGetError() return?
0xa0000000
It's not legal to call glGetError between a glBegin/glEnd pair. That's whats causing your error, your check() right after glBegin.

This restriction is listed in the documentation for glGetError, under "Errors"

http://www.opengl.org/sdk/docs/man/xhtml/glGetError.xml
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game

It's not legal to call glGetError between a glBegin/glEnd pair. That's whats causing your error, your check() right after glBegin.

This restriction is listed in the documentation for glGetError, under "Errors"

http://www.opengl.org/sdk/docs/man/xhtml/glGetError.xml


OMFG so my checking for errors was causing an error?!

tacticalfacepalm.jpg

Now to figure out why my texture isn't working (after putting the texcoord calls back in of course)...

This topic is closed to new replies.

Advertisement