CSE581 Lab1

Due: Friday, Oct. 30, by 11:59pm

OBJECTIVE:
This lab is just to get you to type in an OpenGl program and get it to run. Basically, it is intended to make sure everyone can submit a lab assignment that compiles and runs on the official class environment.

Type in the code below, compile it, and run it.

Notes:

  • Complete the header information with your name and email address
  • Your lab should compile and run on the PC environment found in CL112D. Of course you can develop it on any platform you choose, but then you should port it over to CL112D and make sure it runs there.
  • Depending on the enivronment you are developing on, you may have to change the path to the gl.h and glut.h files or you may not have to explicitly include gl.h at all. You may also have to include some other headers.


//////////////////////////////////////////////////////// 
// CSE 581 - Autumn 2011
// Lab 1
// <your name here>
// <your email address here>
//////////////////////////////////////////////////////// 


#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>
#include <GL/gl.h>


void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);          // the color will be cleared
   
    glBegin(GL_QUADS);                     // draw a quadrilateral
    glVertex2f(-0.75f, -0.75f);
    glVertex2f( 0.75f, -0.75f);
    glVertex2f( 0.75f,  0.75f);
    glVertex2f(-0.75f,  0.75f);
    glEnd();
   
    glFlush();                             // force exec of all OpenGl commands
}


int _tmain(int argc, char** argv)
{
    glutInit(&argc, argv);              // initialize glut
    glutCreateWindow("581 Lab1");       // create a windo
    glutDisplayFunc(display);           // say what the 'display' func is
   
    glClearColor(1.0,0.5,0.0,0.5);      // set the clear color
    glColor3f(0.0,1.0,0.0);             // set the drawing color
   
    glutMainLoop();
    return EXIT_SUCCESS;
}