OpenGL Introduction

CS 320

Feb. 4, 2011

You'll be using OpenGL with C under Eclipse for these two small projects.

  1. Create a new C project in Eclipse and then create a new source file within the project. Copy the contents of the file pentagon.c from the class home page into the source file you just created.

  2. Open the Project menu and choose Properties. Expand the C/C++ Build node and select Settings. In the panel to the right, select Libraries (under MinGW C Linker) and add these three libraries:
    1. opengl32
    2. glu32
    3. glut32
    (Make sure you enter these under Libraries and not Library Search Path.)

    You'll need to perform this step of adding these three libraries for each OpenGL project you create.

  3. Observe the header file declarations in pentagon.c:
    #include<GL/glut.h>
    
    This should be included in all your projects.

  4. Compile pentagon.c and fix all warnings and/or errors. (Hint: There is no random() function, but there is a rand() function defined in stdlib.h.)

  5. Build the program, fixing any unresolved references.

  6. Run the program. Nice pentagon, right? What happens when you minimize and restore the window? Can you hypothesize why that happens?

  7. Looking through the program code, find out how to interact with the program and then use this functionality.

  8. Repeat for quadric.c. You should only get one warning, regarding errorCallback(), which you can safely ignore.

    Look at the functions init() and display(). Can you see any correlation between the code and the images? The man pages for all the OpenGL, GLU, and GLUT functions are installed on phoenix for your perusal.

  9. Remove the three library files files that you added earlier. Try to build the program and note the error messages you receive. This what will happen any time you forget to include the library files in the compiler's link phase.



Thomas P. Kelliher 2011-02-04
Tom Kelliher