picking and redraw question

Hi, I have a picking problem by using selection mechanism. There are 2 objects (say, A and B) rendered on the screen. When I click/pick object A, it works fine to make a selection hit, and then I translate some distance it by pressing a key. After that, when I try to click object B, the object A is drawn back to the original place.
This run the same situation when I click on the area out of these 2 objects (i.e. no selection hit and both 2 objects go back original place)…

It seems that we can only redraw that object when it make a selection hit. How can I redraw the whole scene once a selection hit is made? or What’s wrong with that?

Thanks for any input.

Could you post some code?

From what you are saying, I would look at how you draw your objects in the first place, do you translate them after a selection, if so are you recalculating the object using the original coordinates?

Here is my code, most from red book…Thx.

void render(GLenum mode)
{

glPushMatrix();
	glTranslated(0.0, 0.0, (GLdouble) translate);
	glPushMatrix();
		if (mode == GL_SELECT)
			glLoadName(1);
		if (selected == 1)
			glRotated((GLdouble) rot_angle1, 1.0, 0.0, 0.0);
		glCallList(CHAIR01);
	glPopMatrix();
	
	glTranslated(100.0 , 0.0, 0.0);
	
	glPushMatrix();
		if (mode == GL_SELECT)
			glLoadName(2);
		if (selected == 2)
			glRotated((GLdouble) rot_angle2, 1.0, 0.0, 0.0);
		glCallList(TABLE01);
	glPopMatrix();
glPopMatrix();
glutSwapBuffers();

}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
render(GL_RENDER);
glFlush();
}

void proces****s (GLint hits, GLuint buffer[])
{
unsigned int i, j;
GLuint ii, jj, names, *ptr;

printf ("hits = %d
", hits);
if (hits == 0)
selected = 0;

ptr = (GLuint ) buffer;
for (i = 0; i < hits; i++) { /
for each hit */
names = *ptr;
printf (" number of names for this hit = %d
“, names);
ptr++;
printf(” z1 is %g;", (float) *ptr/0x7fffffff); ptr++;
printf(" z2 is %g
“, (float) ptr/0x7fffffff); ptr++;
printf (" names are ");
for (j = 0; j < names; j++) { /
for each name */
printf (”%d “, *ptr);
selected = *ptr;
ptr++;
}
printf (”
");
}
}

void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case ‘m’:
if (selected == 1)
translate1 = (translate1 + 10) % 360;
if (selected == 2)
translate2 = (translate2 + 10) % 360;
glutPostRedisplay();
break;
default:
break;
}
}

void mouse(int button, int state, int x, int y)
{
GLuint selectBuf[512];
GLint hits;
GLint viewport[4];

if (button != GLUT_LEFT_BUTTON | | state != GLUT_DOWN)
	return;

glGetIntegerv(GL_VIEWPORT, viewport);
glSelectBuffer(512, selectBuf);
glRenderMode(GL_SELECT);

glInitNames();
glPushName(0);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();

gluPickMatrix((GLdouble) x, (GLdouble) viewport[3] - y, 5.0, 5.0, viewport);
gluPerspective(90.0, (GLfloat) 500/ (GLfloat) 500, 10.0, 1500.0);

render(GL_SELECT);

glPopMatrix();

hits = glRenderMode (GL_RENDER);
proces****s (hits, selectBuf);

glFlush();
glutPostRedisplay();

}

oh…I have just found out the problem…totally my stupid coding…
“if (selected == 1)” and "if (selected == 2) shouldn’t be added in void render(GLenum mode)…
Anyway, thx for ur hint.