Lab(6) - Graphics

The program for this lab is prepared by Steven McKinney CS senior student


    To learn the basics of texture mapping
    To create a box with 6 images on each side

This lab is to illustrate how you can bring images into your drawings using texture mapping.  Before we start the lab, you need the following.  


Step 1: Preparing Images
Create a directory lab6, then directory Data inside of it for the images.  You need six images for the six sides of the cube.  Of course, they all can be the same, but if you decide to have them different, you need six images.  These images must be of size 256-by-256 in .bmp format.  You can use other size image, but for now, let's make that a standard.  You can use the PaintShop Pro, Adobe PhotoShop, or Unix-based xv software to change the size of the images you have or save them in the correct format.

Here is the list of the images that I have copied in jpg format from the ASU server. 

Ian     Dan     Spencer  
josh     Mike_Drumm     Chris
Hai     Brian     Steve

Caleb    Trung     DSmith
SSmith     Mike     Marlen
James     Yang

As you may have noticed these images are not 256x256 size.  You can use one of the software packages mentioned above to resize them.  For testing of the code that is giving below, I have saved a 256x256 image with 6 different names.  Image 1: crate, Image 2: face, Image 3: hacker, Image 4: shell, Image 5: sniper, Image 6: whirl.  All images must be stored in the directory Data under lab6 for the program to work correctly.

Step 2:  VC++ Preparations
Make sure you are under the lab6 directory.  We will use a program to create the box with 6 images on its sides. Then we will rotate the box to see all sides.  In order to correctly do this, you need to follow these steps very closely:
    1) Open VC++
    2) Under File--> New, select win32 applications, and give a name to your program, text_cube, and follow the next few screens and keep the defaults.  
    3) Then again under File--> New ... C++ Source, give the same name as above for the file name, text_cube, then ok.  In the blank screen copy and paste the    following code text_cube.cpp.  NOTE: Please do NOT save the file as it is, cut and paste the content of the file into the blank screen in VC++ instead.  
    4) Compile the program, you shouldn't have any error. If you do, wait and we will fix it before we go further.
    5) Under setting and the to the link:  glu32.lib  opengl32.lib and glaux.lib.
    6) With this your program should run.

Now you can modify the images that you wish to include and also automate the process so that is rotates and/or bounces in a random fashion.  Then create an executable file that can be used as an screen saver.

Few Tips:
The box rotates in different directions using the up-down and left-right arrows.

In the program there are two places that you are setting the screen resolution and the number of bits for the color.  These two lines look like this:
          if(!CreateGLWindow("Return_Null's SniperGL RotateWork", 1024, 768, 32, fullscreen))

If you change the screen resolutions and number of bits to smaller values, such as; 640, 480, 16, then your display will become much faster.  

Also, if you increase the value of rotation step, that makes the box to rotate faster.  Here is one of the places you will make a change, there should be four places.
                    if(keys[VK_UP])                            // Has up arrow been pressed?
                        xspeed -= 0.01f;                        // Decrease xspeed
 That change should be made in xspeed.