Thursday, November 22, 2007

PRACTICAL 4


#include "glut.h"
void MyDisplay()
{
glClear(GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT);
glColor3ub(255,255,255);
glVertex3f(0.0f, 0.0f, 100.0);
glVertex3f(0.0f, 0.0f, -10.0);
glVertex3f(100.0f, 0.0f, 0.0);
glVertex3f(-10.0f, 0.0f, 0.0);
glVertex3f(0.0f, 100.0f, 0.0);
glVertex3f(0.0f, -10.0f, 0.0);
glEnd();

glColor3f(0, 1, 0);
glBegin(GL_QUADS);
glVertex3f(-35,-30,11);
glVertex3f(-35,30,11);
glVertex3f(-30,30,11);
glVertex3f(-30,-30,11);
glEnd( );

glColor3f(1, 0, 0);
glBegin(GL_QUADS);
glVertex3f(-40,-20,10);
glVertex3f(-40,-10,10);
glVertex3f(40,-10,14);
glVertex3f(40,-20,14);
glEnd( );

glColor3f(0, 0, 1);
glBegin(GL_QUADS);
glVertex3f(-40,20,12);
glVertex3f(-40,25,12);
glVertex3f(40,25,12);
glVertex3f(40,20,12);
glEnd( );

glColor3f(1, 1, 0);
glBegin(GL_QUADS);
glVertex3f(30,-30,13);
glVertex3f(30,30,13);
glVertex3f(35,30,13);
glVertex3f(35,-30,13);
glEnd( );

glutSwapBuffers();
} // Called by GLUT library when the window has changed sizevoid Rescale

(GLsizei w, GLsizei h)
{
glViewport(0,0,w,h);
}

void SetupRC()
{
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0,0,0,1);
glOrtho(-64,64,48,-48,1,50);
gluLookAt(0,0,20,0,2,0,0,2,0);
glEnable(GL_DEPTH_TEST);
}

void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE GLUT_RGB GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutCreateWindow("My Practical 4");
glutDisplayFunc(MyDisplay);
glutReshapeFunc(Rescale);
SetupRC();
glutMainLoop();
}

No comments: