Text
Objectives: In this lab, you will learn:
-OpenGL texture mapping
-OpenGL picking
-Rendering transparent objects
-Output frame buffer content
1. (4 pts) Add OpenGL textures to your scene:
a Choose appropriate images to decorate your scene objects
c. Use key stroke 'x' to turn on/off the textures
2. (3 pt) Allow OpenGL picking, where the user will use mouse to click on any of the objects in the scene. Whatever object gets picked will be displayed in a unique color of your choice that can be easily distinguished from its surroundings.
3.(2 pts) Create a picture-in-picture effect. Put an additional camera in the scene and render the scene using that camera into a small window at the upper left corner of your display window. Use key ‘p’ to toggle this effect.
4.(2 pts) Render your OBJ model(s) using vertex buffer objects (VBO).
5. (2 pts) Add a semi-transparent object to the scene. To do this you need to use OpenGL's alpha blending feature. In essence, you need to enable OpenGL blending by calling the function glEnable(GL_BLEND), and set up the blending function using glBlendFunc(). The parameter in this function should be GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALHPA. Also, you need to use glColor4f() with the last parameter as the opacity (range: [0-1]; 1: opaque; 0: transparent) This semi-transparent object should be the last object to draw in your display function. Read the description in the red book.
6. (2 pts) Finally, allow the program to output the image to a file by pressing the key stroke 'o'. To do this, you need to read the frame buffer back to memory by using the function glReadPixels(). For instance, calling glReadPixels(0, 0, ScreenWidth, ScreenHeight, GL_RGB, GL_UNSIGNED_BYTE, Image) will dump the frame buffer (RGB pixels) to an array named 'Image' in your memory which is declared by you and has dimensions ScreenWidth*ScreenHeight*3 with the type as unsigned character. Output the memory content to a ppm file. Below is a pseudo code of writing out ppm files.
FILE *fp;
fp = fopen("out.ppm","w");
int height = ScreenHeight; // you need to know this from somewhere else
int width = ScreenWidth; // same here.
int max_ccv = 255; // Write the 'header' information
fprintf(fp,"P3 %d %d %d\n", width, height, max_ccv);
for each row, for each pixel, write out an integer value from 0 to255 for each of the R, G, B color components
fclose(fp);
Extra credits:
(1 point) Map textures to your OBJ models using the principles we discussed in class such as mapping vertices to spherical or cylindrical coordiates.
(1 point) Use OpenGL’s curves and surfaces to create objects (Chapter 12 in the text book)
Submitting Files
What to submit?
Your program source files
The Visual Studio solution and project files you use to compile your program.
A simple readme file if you have any instructions about how to compile and use your program.
Do not submit any executable or object files.
In order to submit files for cse581 lab4, use the following command:
submit c581aa lab4 < names of all your files>
Important Note about the 'submit' program
The 'submit' program submits all of the files at once, not one at a time, previous submissions for a given lab are completely removed. Or put another way; each time the submit command is issued for a given lab, ALL of the previously submitted files are clobbered.
That means that
submit c581aa lab4 lab4.c
submit c581aa lab4 readme
will result in ONLY 'readme' remaining in the lab1 submission
You should do the following:
submit c581aa lab4 lab4.c readme
or
submit c581aa lab4 lab4_dir
Where 'lab4_dir' is a directory containing all of the lab1 files to be submitted, or best of all (for both student and grader) is:
cd lab4_dir
submit c581aa lab4
Submit will immediately print submission information to the submitter. Use 'man submit' if you have any other questions.
Late Penalty
You should submit your lab on time. We are on a quarter schedule, which is pretty tight. Being late for one lab could affect the time left for you to complete subsequent labs. All labs are due at 11:59pm of the specified due data, and there is a 10% penalty each day for up to 50%. After that, you get zero.
Grading Criteria
Grading of the labs will be based on the following:
•90%: Correctness and adherence to assignment specification.
•10%: Readability, structure of code, use of comments, adherence to lab procedures (submitting, naming conventions, etc.)
The grader will grade the labs. If you have problems with the grade you received on your lab, see the grader first. If you can't resolve the dispute with the grader, then see me. However, in order to maintain consistent grading for everyone in the class, I am not very inclined to alter grades that are assigned by the grader.
Don't copy labs. Discussion of lab assignments is allowed and encouraged. However, you need to complete the lab all by yourself. Labs which are too similar will be handed over to the Committee on Academic Misconduct and handled by them.
CSE 581 Lab 4
Due: 3/11/2011 11:59 pm