Will this cause an GL_INVALID_OPERATION??

Hi Gang,
I am trying to debug some code that seems like it’s giving me some problems. I am getting an GL_INVALID_OPERATION error when I stress out the system, and I can see it is happening around this block of code:

glBegin(GL_LINE_STRIP);

for (azListIter = arcVector_[index].listA_begin();, azListIter != arcVector_[index].listA_.end(); ++azListIter)
{
// create the XYZ point from the Az, El,
// and range from the azListIter
GlobeXYZ pt;
createArcPoint(azListIter->az_,
azListIter->el_,
arcVector_[index].range_,
pt);
double vec[3];
pt.xyzVector(vec);
glVertex3dv(vec);
}

glEnd();

Now, I have heard that nothing should go between a glBegin and a glEnd except for glVertex, glColor, glIndex, glNormal, glTexCoord, etc commands. Is this really true? Can I call regular C++ functions in between a glBegin and glEnd?

Thanks for your help. I am a novice at this stuff.

Roach

Yes, you can (and usually do) use any non-OpenGL code you want between a glBegin/glEnd. The only thing you can’t use are certain gl commands.

Ok, Thanks!

I am still getting an GL_INVALID_OPERATION error at times though. What else (besides having an invalid call between a glBegin and a glEnd) cause an Invalid Operation error

Like I said, I only get an Invalid Operation error when I am stressing the system (causing mutiple re-draws in a short period of time). Could this be causing the invalid operation (I.e could I be making calls to draw before the last redraw is done and could this be causing problems?)

Thanks
Roach

  1. Are you using multi-threading?

  2. Are you sure this is the bit of code causing the GL_INVALID_OPERATION? Do you get GL_NO_ERROR before this code executes, and GL_INVALID_OPERATION afterwards?

  3. Is there any chance that the code gets called at any time before the gl context is setup?

Originally posted by Roach:

[quote]

glBegin(GL_LINE_STRIP);

for (azListIter = arcVector_[index].listA_begin();, azListIter != arcVector_[index].listA_.end(); ++azListIter)
{
// create the XYZ point from the Az, El,
// and range from the azListIter
GlobeXYZ pt;
createArcPoint(azListIter->az_,
azListIter->el_,
arcVector_[index].range_,
pt);
double vec[3];
pt.xyzVector(vec);
glVertex3dv(vec);
}
glEnd();

You generate temporary objects within the for-loop and pass those pointers to glVertex4DV().

The pointers will be invalid after the for-loop is complete.
[/b][/QUOTE]

Hope that helps.

Nothing: That should not be a problem. It would be a problem if the pointer was used in GLU’s tesselators, but not with standard GL commands.