WPI Computer Science Department

Computer Science Department
------------------------------------------

CS 4731, B Term 2011 Homework 1, Due Thursday, November 10, 2011, 11:59PM


Homework 1 (Part A): Not to be submitted (in class discussion next week)

This project guides you through steps you can take to test a given CCC machine (or your hardware) to see if your machine (or any machine) is capable of running OpenGL shaders written in the GL Shading Language (GLSL). You will also get used to compiling OpenGL/GLSL code in Visual Studio. Some tools and code will be provided to help you out.

Note: The instructions below have been tested and will work on machines in 6 computer labs on the WPI campus. If you would like to work on your own machine, much of these instructions will also work for you. But it will be your responsibility to get things to work on your home machine. The TA/SA can help you if you would like to do that. Even if you work on your home machine, the final submission must work on machines in one of these 6 labs. You must port your code yourself and indicate in your documentation which on-campus lab you tested your final submission on.

The following WPI CCC Machines have adequate hardware for this class.

Homework 1 (Part A) Specifics

Step 1: Finding out what version of OpenGL your graphics card support: The very first thing you need to do is determine if your video card can support GPU programming. Specifically, you are looking to see if your graphic card supports OpenGL version 3.1 or later. To determine your card's capabilities for you, try the Glinfo application located here: (GLinfo2.exe). This application will give what OpenGL version your card supports and a list of extensions your card supports. Run the GLinfo2 application, make sure you have OpenGL 3.1 or later.

Step 2: Running a working Shader application : If your machine supports shaders, try downloading the following full blown application that uses shaders and playing with it. The rendering application to test your machine's shader abilities is located here GLSLDemo.zip. Unzip the application to a computer with a programmable GPU. GLSLDemo is a Win32-only application. The executable file is located in the "bin" directory of the demo application. Double-click on the executable to open the application. Try playing with it by changing the shape rendered, the textures used and other rendering modes.

Step 3: Compiling Shader application : Download and unzip the following zip file [ Here ] . Visual Studio 10 is already installed on the CCC machines. Double-click on the Visual Studio file to open it Press Ctrl-F5 to compile and run the program. It should draw a triangle to the screen. If the triangle is drawn, you are all set! You can now compile OpenGL and shader programs. Note: In class I described and installation procedure for GLEW and GLUT which requires access to the Windows\system directory and also to your Visual studio include\ and lib\ directories. Since you don't have access to these directories on the CCC machines, the required files have been placed in sub-folders of this project and the Visual Studio solution is set up to point to these files. The good thing is that this file should also work for you on your home machine. But again, we will help you on WPI CCC machines. It's your responsibility to get things working on your home machine. The TAs will help you.

Homework 1 (Part B): To be submitted by due date

Step 4. Render the sierpinski Gasket: Modify the starter program given to you to draw the Sierpinski Gasket as explained in class. The code for the Sierpinski gasket is actually in your text.

Step 5. Modify the program so that it can read in and draw the following polyline files: The polyline files below are in the GRS format, a homegrown format:

dragon.dat
usa.dat
vinci.dat

The structure of GRS files is:

Step 6. Render the Hilbert Curve: Modify the starter program given to you to draw the Hilbert Curve as explained in class. Recursion is your friend for this part of your assignment. See the Hilbert Curve page at Mathworld for more information. Also see the wikipedia, it has a better explanation. This tutorial also has some useful information and may give you some ideas about how to apply different shapes and colors. Try to be creative.

Remember that what you are really doing, is replacing the "cup", the three-line segment, with four cups that are connected together with short lines. The new cups are one rotated counter clockwise, two in the same direction, then one rotated clockwise, all with lines connecting the end of one cup with the beginning of the next. Connectors are never changed, except that they will get smaller in length. It is the cups that get replaced with four new cups.

By default you should draw the Hilbert Curve iterated 3 times.

Summary of Your program behavior

After the practice, now re-organize your program to have the following behavior. When program starts as default, the Hilbert Curve (3 iterations) is drawn. Your program should then respond to the following key strokes Notes: No OpenGL fixed function commands (glBegin, glVertex, etc) or immediate mode drawing commands should be used in your program. All drawing should be done using shaders, retained mode, Vertex Buffer Objects, and glDrawArrays similar to the code in your textbook (and in the starter code)

Aspect ratio: You should maintain aspect ratio in all your drawings. This should be done initially whenever you draw a polyline for the first time. Also, implement a reshape function that recalculates the correct dimensions of the drawing whenever the user changes the current drawing Window dimensions.

Keyboard control: In order for your program to respond to keyboard strokes, you will need to write and register a keyboard callback function.

Submitting Your Work

Your final submission must be configured to work and fully tested in one of the 6 labs listed above. Please indicate in your documentation which lab you finally tested your submission. The TA will go there to grade your project. Points will be docked for submissions that do not compile or require ANY modifications to compile. The starter Visual Studio package is configured to work in these 6 labs. It is strongly advised that you use the starter package to avoid porting problems at the end. Porting OpenGL code is non-trivial due to platform differences. Make sure to double-check that everything works before submitting. Submit all your executable and source files. Put all your work files (Visual Studio solution, OpenGL program, shaders, executable and input files into a folder and zip it. Essentially, after your project is complete, just zip the project directory created by Visual Studio. If the filesize is less than 10MB, you can email the file to cs4731-staff@cs.wpi.edu. If the final zip file is larger than 10MB, put it in a webspace and email us its URL.

Create documentation for your program and submit it along with the project inside the zip file. Your documentation can be either a pure ASCII text or Microsoft Word file. The documentation does not have to be long. Briefly describe the structure of your program, what each file turned in contains. Explain briefly what each module does and tie in your filenames. Most importantly, give clear instructions on how to compile and run your program. MAKE SURE IT RUNSbefore submission. Name your zip file according to the convention FirstName_lastName_hw1.zip


[Feedback] [Search Our Web] [Help & Index]

[Return to the WPI Homepage] [Return to CS Homepage]

mailto:emmanuel@cs.wpi.edu