PDA

View Full Version : glOrtho 's problems



powervr
10-31-2004, 08:01 AM
Hi, I have the following codes:
-------------------------------

void Render()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glColor3f(1.0f, 0.0f, 0.0f);

glPushMatrix();

glTranslated(100,100,0);
glRotatef ( xrot, 1.0, 0.0, 0.0 );
glRotatef ( yrot, 0.0, 1.0, 0.0 );

//draw a object
glutSolidTeapot (30);

// Restore the matrix state
glPopMatrix();// Modelview matrix

glutSwapBuffers();
}

void Resized(int w, int h) //execute when windows is reshaped
{
//prevent divide by zero
if(h == 0)
{ h = 1; }

WindowWidth = w;
WindowHeight = h;

ratio = 1.0f * w / h;

glViewport(0,0, w, h);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrtho(0.0f,w,0.0f,h,-1.0f,200.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

//--------------------------------------------

Why the teapot is showing, but some parts (in z-direction) are clipped ?

Thanks :)