CSE581 Lab0

Due: Wednesday, April 8, 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 has an OpenGL programming environment set up so they can do the lab assignments.

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

Notes:

  • Complete the header information with your name and email address
  • Use the submit command to submit the source code, e.g.: submit c581aa lab0 lab0.c
  • 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.
  • You get no credit for completing this lab. However, if you don't successfully submit source code that can be compiled and run (as submitted) by the due date for Lab 0 or alert me of the problems you are having and you have problems with getting Lab 1 (or any other lab) working on time for reasons that should have been resolved by this exercise, then you will automatically lose 20 points off of the lab in addition to any late penalties or other grading deductions it incurs.


//////////////////////////////////////////////////////// 
// CSE 581 - Spring '09
// Lab 0
// <your name here>
// <your email address here>
//////////////////////////////////////////////////////// 

#include <glut.h> 

void myDisplay();

// =================================================
// MAIN
int main(int argc, char** argv) 
{ 
  glutInit(&argc, argv);        // initialize OpenGL
  glutCreateWindow("Lab 0");    // create a window
  glutDisplayFunc(myDisplay);     // display callback function is 'myDisplay'
  glutMainLoop();              // go into the main idle loop: wait for an event
} 

// =================================================
// MY DISPLAY
void myDisplay() 
{ 

  glColor3f(1,0,0);       // set the color to red
  glClear(GL_COLOR_BUFFER_BIT);   // clear the buffer

  glColor3f(1,0,1);            // set the color to cyan
  glBegin(GL_LINES);           // draw individual lines
    glVertex2f(-0.75, -0.75); 
    glVertex2f(0.75,  0.75); 
    glVertex2f(-0.75, 0.75); 
    glVertex2f(0.75, -0.75); 
  glEnd(); 

  glColor3f(1,1,1);             // set the color to white
  glBegin(GL_LINE_STRIP);       // draw connected lines
    glVertex2f(-1.0, -1.0); 
    glVertex2f(2.0,  1.0); 
    glVertex2f(0.5, -1.0); 
    glVertex2f(2.0, 0.5); 
  glEnd(); 

  glColor4f(1,1,0,1);            // set the color to yellow
  glBegin(GL_POLYGON);           // draw a polygon
    glVertex2f(-0.5, -0.5); 
    glVertex2f(-0.5,  0.5); 
    glVertex2f(0.5, 0.5); 
    glVertex2f(0.5, -0.5); 
  glEnd(); 
  
  glColor3f(0,1,0);              // set the color to green
  glBegin(GL_TRIANGLES);         // draw a 2D triangle
    glVertex2f(-0.25, -0.5); 
    glVertex2f(-0.5,  0.5); 
    glVertex2f(0.5, 0.5); 
  glEnd(); 

  
  glFlush();              // this 'flushes' the command buffer

} 


last updated 4/2/09
Class web site