PDA

View Full Version : glerror invalid operation



David Doria
11-23-2008, 08:56 AM
I am very confused with this error.

I call a display function once and then check the "result" with

cout << gluErrorString(glGetError()) << endl;

Then I enter selection mode with
glRenderMode(GL_SELECT);

then call the same display function and again check the result.

The first time I see "no error", but the second time I see "invalid operation". I've been told you can't use glGetError() inside glBegin() glEnd() pairs, so I can't really check anything else in between. How can I tell why this error is being generated?

Thanks,

Dave

David Doria
11-23-2008, 09:01 AM
Of course I realize what's wrong right after I post...

GL_INVALID_OPERATION is generated if glLoadName is executed
between the execution of glBegin and the corresponding
execution of glEnd.

I wanted to name each triangle in a mesh so I can "pick" a triangle after the mesh is drawn.

So I was doing

for each triangle
glLoadName(i);
glBegin(GL_TRIANGLES);
//draw triangle
glEnd();
end

but everyone told me that would be super slow, so I should draw all of the triangles inside the same begin() end() block.

so I changed to

glBegin(GL_TRIANGLES);
for each triangle
glLoadName(i);
//draw triangle
end
glEnd();

But now this has broken the naming. Is there anyway to get the best of both worlds?

Thanks,
Dave

dletozeun
11-23-2008, 09:22 AM
use a color instead of a name and display list, vertex array or vbo to make it faster.