CS312 Lab 1:  Basic OpenGL and Event Handling


  1. Use the debugger -- gdb/lldb commands:
    1. Compile with -g flag
    2. Start gdb with "gdb <name of executable>"
    3. "list" or "l" -- lists code with line numbers
    4. "break #" or "b #" -- sets a break point at line number #
    5. "run" -- start program execution (if you have arguments, type them in after run)
    6. "print <varname>" or "p <varname>" -- print the value of named variable
  2. Copy the demo program shapes from ~dxu/handouts/cs312/gldemo to your own directory (note that there are two subdirectories mac and linux. Choose the correct binary for your current machine architecture). Run.
    1. Make sure you try out the menus attached under right-click (control-click on macs)
    2. Also try toggling the following key commands:
      1. 'B'
      2. 'C'
      3. 'O' (only visible under TRIANGLE_FAN, TRIANGLE_STRIP and QUAD_STRIP)
      4. escape
  3. Copy the programs simple.c hello_gl.c from ~dxu/handouts/cs312/glcode to your own directory
  4. Copy Makefile from ~dxu/handouts/cs312/glcode to your own directory
  5. Compile each with "make <name without .c>" and run.
  6. Write a program that opens an OpenGL window and draws a blue triangle in it.
  7. Copy the program events.c from ~dxu/handouts/cs312/glcode to your own directory. Compile and run.
  8. Write a program that draws a small circle/square at every mouse-click.