# OpenGL The most Stupid error ever

This topic is 4809 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I couldnt believe, this, after some tests I made (I mainly work with arrays but for some rectangles Im going for immediate mode) and found out that... after I call
*hrc=wglCreateContext(*hdc);
wglMakeCurrent(*hdc,*hrc);
//
glBegin(GL_POINTS);
glVertex3f(0,0,0);
glEnd();//it gives an Invalid operation right here and I dont get it)


The thing is that I first thought "hey,maybe I make stupid calls the way there and lets try to call it right after OpenGL is initiated" and, you might think that it does that because perspective is not configured, well it does that even afterwards and... after each and every one glEnd() call, and the more weird thins is that the respective vertices are rendered in the end... wacked !

##### Share on other sites
you'll be wanting to use glError() all over the place to track down the error then..

##### Share on other sites
Well... I use this to figure it out

char *GetGLError(){	int e=glGetError();	if (e) {		const unsigned char *estr = gluErrorString(e);		char *p=(char*)estr;		return p;	}	else return NULL;}

And I just put that in my debugger and press F10 to make the next step, so I know if theres any error between the last call and the current call, this way I can even track in which one of my subfunctions the error occured :D (Its not the first time Im having errors in OpenGL)

And to make things even more wacked, I use line loops to draw bounding boxes and after the glEnd() comes an invalid operation and still... the bounding box gets rendered,weird !

##### Share on other sites
Is it possible that you have a spurious glBegin somewhere without an opposing glEnd? (Or perhaps the other way around?)

##### Share on other sites

The thing that still really confuses me is why .NET didn't give me linker errors whenever I was trying to link to bad lib files instead of just a "Exited with Native code 0"????? (by the way...I've been programming for a while. This whole things was quite embarrassing lol)

##### Share on other sites
Quote:
 Original post by Dave HuntIs it possible that you have a spurious glBegin somewhere without an opposing glEnd? (Or perhaps the other way around?)

That was the first thing I thought of, but in only 2 places I was doing that, so I already checked it... eh... anyway its working but posts an error, Im too tired to re-test now...

Oh one more error, if im still here: enablevertexarrayattrib(2) doesnt enable normals for me.
Actually I enabled 0 (for vertices) and enabled every one else (1-15) and set its pointer to my normal array and... crap nothing! then I enabled GL_NORMAL_ARRAY, set the glNormalPointer and everything works... very weird
I was wondering if I must use vertex programs if I use the attrib arrays and stuff...

I think I once read that arrays differs on ATI(as indices 0-15 I guess) than on NVIDIA, and I got an Radeon 9550...

##### Share on other sites
Quote:
 Original post by AlaricThe thing that still really confuses me is why .NET didn't give me linker errors whenever I was trying to link to bad lib files instead of just a "Exited with Native code 0"????? (by the way...I've been programming for a while. This whole things was quite embarrassing lol)

Im not using .NET because I have 5 projects all at once in VC6 and in .NET it makes a "Sollution",What the heck is he suppoed to mean by that ? I WANT MY PROJECTS BACK ONE BY ONE ! actually they are still there :D but when I hit F7 it compiles each and every single one instead of compiling only the one Im curently working at,thats more than frustrating, oh and the warning lines telling me my code is "deprecated" are really hilarious, whats next ? suggesting me not to code anymore or get to the next version of C ? oh wait thats C#(and it sucks,I know!)

Well, I hope everyone feels the same...

##### Share on other sites
Quote:
 Original post by cippyboy*** Source Snippet Removed ***

RTFM:
Quote:
 (from glGetError) GL_INVALID_OPERATIONThe specified operation is not allowed in the current state. The offending function is ignored, having no side effect other than to set the error flag.

Quote:
 (from glBegin) GL_INVALID_OPERATIONA function other than glVertex, glColor, glIndex, glNormal, glTexCoord, glEvalCoord, glEvalPoint, glMaterial, glEdgeFlag, glCallList, or glCallLists was called between glBegin and the corresponding glEnd. The function glEnd was called before the corresponding glBegin was called, or glBegin was called within a glBegin/glEnd sequence.

To state the obvious, only a small subset of functions can be called between a begin/end pair, and you're almost certainly calling one of them. Note that glGetError is also not allowed here, so you don't want to be testing it after *every* function call. Also, as specified, invalid calls are ignored which is why your rendering appears unaffected. If you're sure everything between begin/end is correct, then check for errors beforehand which you're only picking up late.

Quote:
 Oh one more error, if im still here: enablevertexarrayattrib(2) doesnt enable normals for me.Actually I enabled 0 (for vertices) and enabled every one else (1-15) and set its pointer to my normal array and... crap nothing! then I enabled GL_NORMAL_ARRAY, set the glNormalPointer and everything works... very weirdI was wondering if I must use vertex programs if I use the attrib arrays and stuff...

Vertex attribs are only for use with vertex programs. How else would GL know which of the magic attrib slots you'd actually used for normals? The actual bindings of generic attribs to usable data is done when you create your vertex program. You need to use glNormalPointer for fixed function normals.

Quote:
 Im curently working at,thats more than frustrating, oh and the warning lines telling me my code is "deprecated" are really hilarious

Deprecated library methods shouldn't be called by any of your own code, so of course they will show up as warnings. Your code is broken, so you should fix it. Again, RTFM as deprecated methods almost always suggest a new, correct way of acheiving the same behaviour.

##### Share on other sites
Ok, I got it doctor :D

So the debugger was calling geterror and finally posted an error because I wanted to know where are the errors, its so funny...

And you said that I must use vp for the attribs im using... well... why does the first vertexattrib work without enabling vertex program ? that was the odd thing, If I enable Array(0), I get to see the vertices drawn, enabling normals is not the same. I first thought that if that was true I wasn`t suppose to see anything but a black background but... anyway, topic closed.

1. 1
Rutin
35
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633343
• Total Posts
3011431
• ### Who's Online (See full list)

There are no registered users currently online

×