CPSC310A
Video Game Development

Assignment 2

Texture Mapping

Details

Add a window class and add texture maps to the Model class. The classs should have the following methods:

Model

Model()

Creates a new empty Model object. If an empty model's draw function is called, nothing will be drawn.

void load(string objFileName)

Loads the specified Wavefront obj file as a OpenGL vertex buffer object. If this model has already loaded an obj file, the old model is cleared before the new model is loaded. This method only reads the following obj file lines:

1. v [x coordinate] [y coordinate] [z coordinate]
2. vn [x direction] [y direction] [z direction]
3. vt [u coordinate] [v coordinate]
4. f [vertex] [vertex] [vertex]
5. f [vertex]//[normal] [vertex]//[normal] [vertex]//[normal]
6. f [vertex]/[texture]/[normal] [vertex]/[texture]/[normal] [vertex]/[texture]/[normal]
7. mtllib [.mtl file name]
8. usemtl [material name]

This method only reads the following mtl file lines:

1. newmtl [material name]
2. Ka [red] [green] [blue]
3. Kd [red] [green] [blue]
4. Ks [red] [green] [blue]
5. Ns [coefficient]
7. map_Kd [.ppm file name]

This method assumes that an OpenGL context and window have been created. Each image file is only stored on the graphics card once.

void draw()

Draw this model using OpenGL and glDrawArrays. Triangles are rendered with the materials and texture maps specified in the obj and mtl files. This method assumes that an OpenGL context and window have been created.

void clear()

De-allocates the vertex buffer objects and texture images and sets the model state back to an empty model object.

Window

Window()

Creates new OpenGl window by initializing GLFW, an OpenGL context, and a shader program.

close()

Deletes the shader program and terminates GLFW.

Submission

Your program will be evaluated for both style and functionality. Submit your code and test data as a tar file on cseval before class on Wednesday February 19th.