PDA

View Full Version : Another proble with object's id



jirkamelich
12-09-2002, 12:07 PM
i have this source code :


glInitNames();
glPushName(0);
glBindTexture(GL_TEXTURE_2D,Textures[0]);

glLoadName(LEVAZED);

glBegin(GL_QUADS);
glColor3f(Zed1.Red,Zed1.Green,Zed1.Blue);
glTexCoord2f(0,1); glVertex3f(-0.1,0.1,0);
glTexCoord2f(1,1); glVertex3f(0.1,0.1,0);
glTexCoord2f(1,0); glVertex3f(0.1,0,0);
glTexCoord2f(0,0); glVertex3f(-0.1,0,0);
glColor3f(1,1,1);
glEnd();

glLoadName(PRAVAZED);

glBegin(GL_QUADS);
glColor3f(Zed2.Red,Zed2.Green,Zed2.Blue);
glTexCoord2f(0,1); glVertex3f(0.2,0.1,0);
glTexCoord2f(1,1); glVertex3f(0.4,0.1,0);
glTexCoord2f(1,0); glVertex3f(0.4,0,0);
glTexCoord2f(0,0); glVertex3f(0.2,0,0);
glColor3f(1,1,1);
glEnd();

glLoadName(11);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,100,0,500,-100,100);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
//--
glBegin(GL_QUADS);
glColor3f(1,1,0);
glVertex3f(0,100,1);
glVertex3f(100,100,1);
glVertex3f(100,0,1);
glVertex3f(0,0,1);
glEnd();
//--
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

but all objects have the same name - 11 , but when i don't draw the last object it works correctly.

nexusone
12-09-2002, 12:38 PM
I see you call glPushName, but never make a glPopname call.

I not sure what you are trying to do, but the last two glMatrixMode calls I don't see why you have them there and some that are stuck in diffrent places.

I am guessing that is part of your problems.


Originally posted by jirkamelich:
i have this source code :


glInitNames();
glPushName(0);
glBindTexture(GL_TEXTURE_2D,Textures[0]);

glLoadName(LEVAZED);

glBegin(GL_QUADS);
glColor3f(Zed1.Red,Zed1.Green,Zed1.Blue);
glTexCoord2f(0,1); glVertex3f(-0.1,0.1,0);
glTexCoord2f(1,1); glVertex3f(0.1,0.1,0);
glTexCoord2f(1,0); glVertex3f(0.1,0,0);
glTexCoord2f(0,0); glVertex3f(-0.1,0,0);
glColor3f(1,1,1);
glEnd();

glLoadName(PRAVAZED);

glBegin(GL_QUADS);
glColor3f(Zed2.Red,Zed2.Green,Zed2.Blue);
glTexCoord2f(0,1); glVertex3f(0.2,0.1,0);
glTexCoord2f(1,1); glVertex3f(0.4,0.1,0);
glTexCoord2f(1,0); glVertex3f(0.4,0,0);
glTexCoord2f(0,0); glVertex3f(0.2,0,0);
glColor3f(1,1,1);
glEnd();

glLoadName(11);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,100,0,500,-100,100);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
//--
glBegin(GL_QUADS);
glColor3f(1,1,0);
glVertex3f(0,100,1);
glVertex3f(100,100,1);
glVertex3f(100,0,1);
glVertex3f(0,0,1);
glEnd();
//--
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

but all objects have the same name - 11 , but when i don't draw the last object it works correctly.