Hi,
I’m trying to draw a rectangle in a perspective projection to show the area selected by the user when he wants to select the objects inside the rectangle drawn but the rectangle is not shown.
Here’s the code.
public void DrawRectangleSelection(Point point1, Point point2)
{
// Store the projection matrix
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPushMatrix();
Gl.glLoadIdentity();
// Change the projection to orthographic
Gl.glOrtho(-20, 20, -20, 20, -50, 50);
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPushMatrix();
Gl.glLoadIdentity();
// Draw the rectangle
Vector3d wp1 = UnProject(point1.X, point1.Y, 0);
Vector3d wp2 = UnProject(point2.X, point2.Y, 0);
Gl.glVertex3d(wp1.X, wp1.Y, 0);
Gl.glVertex3d(wp1.X, wp2.Y, 0);
Gl.glVertex3d(wp2.X, wp2.Y, 0);
Gl.glVertex3d(wp2.X, wp1.Y, 0);
// Restore the Projection matrix
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glPopMatrix();
// Restore the ModelView matrix
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glPopMatrix();
}
There’s some extra code before the method is called that calls the glBegin(), and so on.
The custom method UnProject() works well.
Do I’ve some error in my code? I suspect I’ve an error changing the projection matrix.
Thanks
PD: I’m using TAO Framework.