Jump to content
  • Advertisement
Sign in to follow this  
cippyboy

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.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I couldn`t believe, this, after some tests I made (I mainly work with arrays but for some rectangles I`m 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 don`t get it)


The thing is that I first thought "hey,maybe I make stupid calls the way there and let`s 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 this post


Link to post
Share on other sites
Advertisement
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 there`s 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 (It`s not the first time I`m 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 this post


Link to post
Share on other sites
Ok...that's not the "Most stupid error ever". ...I think I have the stupidest error ever. I've been trying to teach myself OpenGL for about 4 months now (been kinda an off and on hobby kinda thing) and when I first started out, I could get my Win32 code to work (It would create my window and everything) but when I added OpenGL code in it to draw a triangle to the screen, I would compile and it would give me an "Exited with native code 0" kind of error. I was working out of the "Beginning OpenGL Game Programming" book and I would load the sample code and it would run fine. ...went back to my code to check the header includes...yup all there....checked linker settings...yup all there. Still would never display... anyway...This really, really, REALLY frustrated me and I kinda stepped away from it for a while. I came back to my code over the summer, looked at the linker settings and immediately was like "Wait a minute...the libraries aren't gl.lib, glu.lib and glaux.lib" ...I had linked the HEADER files with a LIB extension instead of the actual LIB files for some reason. ...changed them to gl32.lib and opengl32.lib and the program ran fine....I'm now to the point where I've got a terrain loader up and running and I'm getting ready to move on to handling vertex arrays and stuff.

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 this post


Link to post
Share on other sites
Quote:
Original post by Dave Hunt
Is 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 it`s working but posts an error, I`m too tired to re-test now...

Oh one more error, if i`m still here: enablevertexarrayattrib(2) doesn`t enable normals for me.
Actually I enabled 0 (for vertices) and enabled every one else (1-15) and set it`s 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 this post


Link to post
Share on other sites
Quote:
Original post by Alaric
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)


I`m 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 I`m curently working at,that`s more than frustrating, oh and the warning lines telling me my code is "deprecated" are really hilarious, what`s next ? suggesting me not to code anymore or get to the next version of C ? oh wait that`s C#(and it sucks,I know!)

Well, I hope everyone feels the same...

Share this post


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

RTFM:
Quote:

(from glGetError) GL_INVALID_OPERATION
The 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_OPERATION
A 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 i`m still here: enablevertexarrayattrib(2) doesn`t enable normals for me.
Actually I enabled 0 (for vertices) and enabled every one else (1-15) and set it`s 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...

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:

I`m curently working at,that`s 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 this post


Link to post
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, it`s so funny...

And you said that I must use vp for the attribs i`m 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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!