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?
gluLookAt()
This is my code:
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement