problems with text and viewport

I posted a message similar to this one a couple of days ago. I have a program where a color cube rotates about the x, y, and z axis, depending on which quadrant you click on, and the fourth quadrant pauses and restarts the rotation. I got a reply on how to keep the text from rotating with the cube by pushing and popping the matrix, but glortho readjusts the window to keep the cube in the middle, and the viewport clips off everything after about -2, 2 on the x and y axis, but it depends on the width and height of the window, but it is always around that. When you extend the window width, the text I have put in the upper left corner moves toward the center with the cube, and down when the height is exteded. How can I keep the text at the corner of the window without the viewport clipping it? Thanks
Snakepit

Have you used a reshape callback? Sounds (or reads) like you don’t. The reshape callback is usually implemented like this (I am assuming you are using glut; if you’re using windows put the code on a WM_SIZE message)

void reshape(int w, int h)
{
//w,h = current window width and height
glViewport(0, 0, w, h) // for a viewport that covers the entire window.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(…ortho coordinates…);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

Try this and post back if your not satisfied.

I am using a reshape function, this is it:

void myReshape(int w, int h)
{
glViewport(0,0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho(-2.0, 2.0, -2.0 * (GLfloat) h / (GLfloat) w,
2.0 * (GLfloat) h / (GLfloat) w, -10.0, 10.0);
else
glOrtho(-2.0 * (GLfloat) w / (GLfloat) h,
2.0 * (GLfloat) w / (GLfloat) h, -2.0, 2.0, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
}

I added this code to it to keep track of where I need to place the text:

if(w <= h)
{
www=2;
whh=2.0 * ((GLfloat) h / (GLfloat) w);
}
else
{
www= 2.0 * (GLfloat) w / (GLfloat) h;
whh=2;

}

I start the text at (www, whh). Initially it doesnt even show up on the window, I have to increase the height a little to see it, but if I subtract as little as .1 from whh, it shows up in the middle of the window, so I am baffled as to what is going on. Thanks
Snakepit

[This message has been edited by snakepit (edited 11-22-2003).]