CS312 Lab 4: Shader-based OpenGL

 

  1. Copy the directory ex1/ from ~dxu/handouts/cs312/glcode to your own directory. Compile and run. This is a simple program that draws the 2D Sierpinski Gasket with points. Please study carefully. Things to note:
    1. initshader.c implements the helper functions that read in, compile and link the shaders.
    2. example1_*.glsl are the vertex and fragment shaders
  2. Install necessary libraries to get OpenGL 3.2 or above running on your own platform (or use our labs!)
  3. Write the following programs to start familiarizing yourself with the shader-based OpenGL
    1. Write a program to display a colored triangle (still in 2D with default projection)
    2. Modify the program to display a 3D triangle with all three vertices having different colors. Note that you will need a separate color buffer (or interleave your vertex buffer). Stay with default ortho projection. Add more triangles to your scene. Add an object to give some depth cue (if your triangle is parallel to x-y, then an intersecting triangle parallel to z, for example).

    3. Modify the program further to add keyboard controls to translate, rotate and scale the objects (you will need to write your own equivalent glTranslate, glRotate and glScale).
    4. If you get this far, then you are ready to convert your hw2 to the new OpenGL. Do.
    5. Now convert your lab3 (solid cube intersecting tetrahedron) to VAOs and VBOs
    6. Now add your own camera movement functions. Most people simply implement their own gluLookAt, however, if you always hated gluLookAt and wanted a different way to handle the camera, now it's your chance. Remember that all of this still only affects the modelview matrix, if you are staying with the legacy OpenGL separation of matrices.
    7. Continue with supplying a projection matrix and get perspective projection to work.
    8. Now you are ready to convert hw3.