Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL/gl.h>
- #include <GL/glut.h>
- void display(void)
- {
- /* clear all pixels */
- glClear (GL_COLOR_BUFFER_BIT);
- /* draw white polygon (rectangle) with corners at
- * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
- */
- glColor3f(0.0f, 0.5f, 1.0f);//baby Blue Sky
- glBegin(GL_POLYGON);
- glVertex3f (00, 50, 0.0);
- glVertex3f (100, 50, 0.0);
- glVertex3f (100, 100, 0.0);
- glVertex3f (00, 100, 0.0);
- glEnd();
- glColor3f(0.0f, 0.5f, 0.5f);//Blue-Green Ground
- glBegin(GL_POLYGON);
- glVertex3f (00, 00, 0.0);
- glVertex3f (100, 00, 0.0);
- glVertex3f (100, 50, 0.0);
- glVertex3f (00, 50, 0.0);
- glEnd();
- glColor3f(0.5f, 0.5f, 0.5f);//Violet(House)
- glBegin(GL_POLYGON);
- glVertex3f (15, 20, 0.0);
- glVertex3f (50, 20, 0.0);
- glVertex3f (50, 50, 0.0);
- glVertex3f (15, 50, 0.0);
- glEnd();
- glColor3f(0.1f, 0.1f, 0.1f);//Dark grey(House Ground)
- glBegin(GL_POLYGON);
- glVertex3f (13, 18, 0.0);
- glVertex3f (52, 18, 0.0);
- glVertex3f (52, 20, 0.0);
- glVertex3f (13, 20, 0.0);
- glEnd();
- glColor3f(0.1f, 0.1f, 0.0f);//Bronze(Tree)
- glBegin(GL_POLYGON);
- glVertex3f (75, 20, 0.0);
- glVertex3f (77, 20, 0.0);
- glVertex3f (77, 50, 0.0);
- glVertex3f (75, 50, 0.0);
- glEnd();
- glBegin(GL_POLYGON);
- glVertex3f (85, 20, 0.0);
- glVertex3f (87, 20, 0.0);
- glVertex3f (87, 43, 0.0);
- glVertex3f (85, 43, 0.0);
- glEnd();
- glColor3f(0.1f, 0.0f, 0.0f);//Brown Door
- glBegin(GL_POLYGON);
- glVertex3f (29, 20, 0.0);
- glVertex3f (36, 20, 0.0);
- glVertex3f (36, 35, 0.0);
- glVertex3f (29, 35, 0.0);
- glEnd();
- glColor4f(1.0f, 0.5f, 0.0f, 0.0f);//orange/brown Door Line
- glBegin(GL_POLYGON);
- glVertex3f (32.30f, 20, 0.0);
- glVertex3f (32.70f, 20, 0.0);
- glVertex3f (32.70f, 35, 0.0);
- glVertex3f (32.30f, 35, 0.0);
- glEnd();
- glColor3f(0.1f, 0.0f, 0.0f);//Brown Window
- glBegin(GL_POLYGON);
- glVertex3f (40, 33, 0.0);
- glVertex3f (46, 33, 0.0);
- glVertex3f (46, 40, 0.0);
- glVertex3f (40, 40, 0.0);
- glEnd();
- glColor3f(0.1f, 0.0f, 0.0f);//Brown Window
- glBegin(GL_POLYGON);
- glVertex3f (25, 33, 0.0);
- glVertex3f (19, 33, 0.0);
- glVertex3f (19, 40, 0.0);
- glVertex3f (25, 40, 0.0);
- glEnd();
- glColor3f(0.0f, 0.1f, 0.0f);//Forest Green Roof
- glBegin(GL_TRIANGLES);
- //Triangle
- glVertex3f(13, 50, 0.0f);
- glVertex3f(52, 50, 0.0f);
- glVertex3f(32.5f, 65, 0.0f);
- glColor3f(0.0f, 1.0f, 0.0f);//Green
- glVertex3f(69, 49, 0.0f);
- glVertex3f(83, 49, 0.0f);
- glVertex3f(76, 55, 0.0f);
- glVertex3f(69, 53, 0.0f);
- glVertex3f(83, 53, 0.0f);
- glVertex3f(76, 60, 0.0f);
- glVertex3f(69, 57, 0.0f);
- glVertex3f(83, 57, 0.0f);
- glVertex3f(76, 67, 0.0f);
- glVertex3f(79, 42, 0.0f);
- glVertex3f(93, 42, 0.0f);
- glVertex3f(86, 50, 0.0f);
- glVertex3f(79, 46, 0.0f);
- glVertex3f(93, 46, 0.0f);
- glVertex3f(86, 55, 0.0f);
- glVertex3f(79, 50, 0.0f);
- glVertex3f(93, 50, 0.0f);
- glVertex3f(86, 60, 0.0f);
- glEnd();
- /* don't wait!
- * start processing buffered OpenGL routines
- */
- glFlush ();
- }
- void init (void)
- {
- /* select clearing (background) color */
- glClearColor (0.0, 0.0, 0.0, 0.0);
- /* initialize viewing values */
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0.0, 100, 0.0, 100, -1.0, 1.0);
- }
- /*
- * Declare initial window size, position, and display mode
- * (single buffer and RGBA). Open window with "hello"
- * in its title bar. Call initialization routines.
- * Register callback function to display graphics.
- * Enter main loop and process events.
- */
- int main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize (600, 500);
- glutInitWindowPosition (75,75);
- glutCreateWindow ("Fist Lab Task");
- init ();
- glutDisplayFunc(display);
- glutMainLoop();
- return 0; /* ISO C requires main to return int. */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement