Selection Buffer problem ... Please help

I understand that
glGEtIntegerv(GL_VIEWPORT,viewport) will
return the current viewport cordinates.
Question: What will happen if I mention more than one viewports while drawing.
say,
Setviewport ( left half)
draw object 1
Setviewport ( Right half)
draw object 2

Now, if I want to select objects in right half screen, Shouldn’t I get the Viewport of right half.

How to get it?

Thanks in advance

The four parameters you retrieve with glGetIntegerv are exactly the ones you gave to glViewport to set up your viewport.

If you simply keep those four numbers in some variables in your program, you will be able to use them directly without using glGetIntegerv (it is usually advised not to use any glGetxxxx command for fast rendering).

GLint leftx,lefty,rightx,righty;
GLsizei leftw,lefth,rightw,righth;

glViewport(leftx,lefty,leftw,lefth);
RenderObjectsOnTheLeft();
glViewport(rightx,righty,rightw,righth);
RenderObjectsOnTheRight();

Now, when you have a mouse event in your window, you can check wether it hits the left or right part. Then:

int iPartHit; // 0 for left, 1 for right //
GLint x,y;
GLsizei w,h;
iPartHit=FindWhereTheHellTheUserClicked();
switch (iPartHit)
{
case 0:
x=leftx;
y=lefty;
w=leftw;
h=lefth;
break;
case 1:
x=rightx;
y=righty;
w=rightw;
h=righth;
break;
}
// Now you know which numbers to use for the selection without using glGetIntegerv: they are x,y,w,h //

Hope this helps.

Regards.

Eric

[This message has been edited by Eric (edited 04-19-2001).]