PDA

View Full Version : glLoadName trouble



04-04-2002, 03:52 AM
i have 4 objects and i am trying to glLoadName each one with a different name. However the first three objects all get called '2' and the last one gets called '1' instead of 1,2,3 and 4 like i think should happen. whats wrong? thanks

object_count=4;
m=0;

static void display (void)
{
//Init names of objects
glInitNames();
glPushName(m);

draw();
. . . .
. . . .
. . . .
}

void draw()
{
int obj; // object counter

//////////////////////////////
// draw all the objects
for (obj = 0; obj < object_count; obj++) {

glPushMatrix();

glLoadName(m+1);
drawPolygon();
m++;
glPopMatrix();
}
}

zeckensack
04-04-2002, 05:13 AM
The only OpenGL functions you have here are glPushMatrix and glPopMatrix. I simply don't know what the rest is, but I know they don't belong to OpenGL. It's bad practice to prefix your own stuff with gl, it only confuses people.

Furrage
04-04-2002, 05:52 AM
Huh? Duh? All the calls posted that start with gl are valid calls. They are a part of the standard code used for picking. Check your OpenGL docs again.
Originally posted by zeckensack:
The only OpenGL functions you have here are glPushMatrix and glPopMatrix. I simply don't know what the rest is, but I know they don't belong to OpenGL. It's bad practice to prefix your own stuff with gl, it only confuses people.

04-04-2002, 05:59 AM
well anyway...anyone have any thoughts about my picking dilema?

Furrage
04-04-2002, 05:59 AM
That's a weird one. Your code seems flawless. Are you sure your are not calling glLoadName somewhere in your drawPolygon() function?

Originally posted by gussy:
i have 4 objects and i am trying to glLoadName each one with a different name. However the first three objects all get called '2' and the last one gets called '1' instead of 1,2,3 and 4 like i think should happen. whats wrong? thanks

[Edit] Note that you only init m once. Thus after the first display m = 4. However since it isn't reinitialised your next display should end up with names starting from 5 and ending with eight 8; and keep incrementing each display.


[This message has been edited by Furrage (edited 04-04-2002).]

[Edit] Post your code to process your hits as well. The problem could be there.

[This message has been edited by Furrage (edited 04-04-2002).]

zeckensack
04-04-2002, 08:11 AM
Oops, sorry. I guess you never stop learning http://www.opengl.org/discussion_boards/ubb/biggrin.gif