Sign in to follow this  

gluLookAt()

This topic is 3861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is my code:
void drawbox(float x, float y,float length,float height)
{
     GLfloat white[]={1.0f,1.0f,1.0f,1.0f};
     glTranslatef(x,y,0.0f);
     glScalef(length,height,0.0f);
     glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,white);
     glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,128);
     glBegin(GL_QUADS);
     glVertex3f(0.0f,0.0f,0.0f);
     glVertex3f(0.075f,0.0f,0.0f);
     glVertex3f(0.075f,0.1f,0.0f);
     glVertex3f(0.0f,0.1f,0.0f);
     glEnd();
     glScalef(-length,-height,0.0f);
     glTranslatef(-x,-y,0.0f);
}
void render()
{
 
 gluLookAt(0.0f, 0.0f,1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
 glEnable(GL_DEPTH_TEST);
 GLfloat ambientLight[] = { 1.0f, 1.0f, 1.0f, 1.0f };
 GLfloat diffuseLight[] = { 0.0f, 0.0f, 0.8, 1.0f };
 GLfloat specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
 GLfloat position[] = { 0.0f, 2.0f,0.0f, 1.0f };
 GLfloat direction[]={0.0,-1.0,0.0};
 drawbox(0.0f,0.0f,2.0f,2.0f);
}
Now i see mi square but if 1 want it to look from a greater distance like this: gluLookAt(0.0f, 0.0f,2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); My object dissapears but howe come?

Share this post


Link to post
Share on other sites
It's obviously passes the far plane. Use glFrustum/gluFrustum to set the clipping planes. And you haven't set the projection what I can see in your code. Use glOrtho to set a orthographic projection or use gluPerspective to set a perspective projection.

Share this post


Link to post
Share on other sites
Sign in to follow this