Homework 8
22C:151 Introduction to Computer Graphics
Due Tuesday, Dec. 2, 2008
20 points
1. Implement and submit a program corresponding to Exercise 9.1 of the textbook.
Note: your score will depend slightly on how interesting your program is. That is,
if it seems to me that you put very little effort into creating the program, essentially
making trivial modifications to examples from the book or web, then you will
likely lose some points.
Notes on compiling and running programs with shaders:
- Shader programming requires a machine that has OpenGL 2.0 (or newer) installed.
- If you want to find out what OpenGL version is installed on your machine, compile
and run this program, glversion.c. The first number displayed
is the version number (the rest of the info gives more detail about exactly which OpenGL
implementation is being used - e.g. version associated nVidia graphics card drivers or
Mesa, a open-source implementation of OpenGL often used on
machines without good graphics cards)
- The CS linux machines in 301 MLH all have OpenGL 2.0 (or 2.1). However, to compile
shader programs on these machine, you do need two small changes from earlier homeworks
in this class. You need to:
- include an additional header file, glext.h
#include <GL/glext.h>
- add another "compiler flag" in the Makefile you use to compile things. Thus, in the simple good-for-one-file makefile I provided for the class, you need
GCC_OPTIONS=-Wall -pedantic -DGL_GLEXT_PROTOTYPES
instead of the original line. If you don't use a makefile you can just add the -DGL_GLEXT_PROTOTYPES part to your gcc/g++ line.
- You will not be able to successfully run OpenGL 2.0 programs using the "NoMachine" client to remotely access CS department linux machines. The machine that you connect to via "NoMachine" does
not have OpenGL 2.0. Thus, to use CS Linux machines for this assignment you must physically go
to the lab.
- On Macs (newish ones, at least), you do not need the glext.h and extra compiler flag.
(I believe, actually, that you *shouldn't* need them on the CS Linux machines either, but ...)
- Many MS Windows machines only have OpenGL 1.1 (or other pre-2.0 version) installed.
You can get OpenGL 2.0 by installing new drivers either from your graphics card manufacturer
or downloading and installing a recent version of Mesa.
NOTE ON ALTERNATIVE ACCEPTABLE HOMEWORK: as discussed in 11/21/08 email message to class, working
with reflection and normal mapping starting from the files in this folder is also
acceptable for homework 8. You can compile cubetex.c using the given Makefile, and run it to
see the results of simple reflection mapping and normal mapping using cube maps (see textbook for
background on reflection/normal/cube/environment mapping). Your HW8 job would be to achieve
the same results using shaders. Shaders to start with (actually, they fully handle one of the two
cases - reflection or normal mapping - you just have to figure out which) with are provided. To use them and
see their effect, modify cubetex.c, adding shader handling code. (Also, to be CERTAIN that
your shaders are having the intended effect, rather
than the texture code in the application, it's
worth commenting out, or removing, the three glEnable(GL_TEXTURE_GEN_...) and three glTexGeni(...) lines.)