FAQ for Programming Assignment 2

General Questions

  1. What is the resolution of the monitors in the labs?

    Sun's: 1280 X 1024 generally...to check for sure type xdpyinfo and scroll through the results.

  2. Is it possible to print out the image we generated?

    Yes. Use xv& to display, crop and print the image as a postscript file.

  3. How do I create an appropriate makefile for this programming assignment?

    Look in /usr/local/pub/ncs/graphics/OpenGL/ExamplesLab2. In each subdirectories there is a file called Makefile that you can download (DO NOT cut and paste as some of the white space NEEDS to be TABS!!!) that file to your directory. As long as your source is in a single file, this makefile will work for you, simply type

    make PROG=lab2

    (assuming you've followed directions and named your file lab2.c!). If you have more than one source file, you'll need to add those file names into the makefile saying that they need to be compiled. For example, you might add a line that says:

    EXTRAS = filename1.c filename2.c

    And then change the last line in Makefile to say:

    $(CC) $(INCLUDE) $(CFLAGS) $(PROG).c $(EXTRAS) $(LDFLAGS) $(LDLIBS) -o $(PROG)

    NOTE: The line above starts with a TAB!

  4. Will makemake work?

    Apparently not, from the questions I've received. I don't think it knows where to find all the includes and libraries you need. I've personally never used this program so I don't know what is supposed to be able to do and not supposed to be able to do.

  5. How do I download that Makefile you mentioned?

    There are two ways you can do this.

    1. If you are working on a Unix machine at RIT, simply use the cp (copy) command to pull the files you want from the /usr/local/pub/ncs/graphics/OpenGL/ExamplesLab2 directory. (A cp -r will do a recursive copy.)

    2. From your browser:

      • go to the course page URL: http://www.cs.rit.edu/~ncs/Courses/570.shtml

      • Under Resources, go to my public directory for the course

      • Go down the directory structure to the files you want

      • Hold down the shift-key while pressing the left mouse button. This will download the file.

  6. I get the following error:

    In file included from multiViewports.c:8:
    /usr/local/glut/include/GL/glut.h:58: GL/gl.h: No such file or directory
    /usr/local/glut/include/GL/glut.h:59: GL/glu.h: No such file or directory
    *** Error code 1 make: Fatal error: Command failed for target `executable'

    Do you know how to fix this?

    I have seen this problem arise under two circumstances:

    1. If you type make multiViewports instead of make PROG=multiViewports
    2. OpenGL SHOULD be mounted on every machine in the department. Occasionally we'll come across one that was missed. The result is error messages of this type. Report the machine name to me where this occurs and try another machine!

  7. How do I use C++ to access OpenGL?

    Well, you've stumped me here as I haven't had a chance, and won't anytime soon, to approach this issue. Some students have reported being able to use the C++ compiler simply by modifying the Makefile to use the C++ compiler and changing the extensions on my files to .C instead of .c. BUT, these files are still written in C, not C++.

    I'll answer this question as soon as I can!

OpenGL Questions

  1. Do I have to use all of the primitives?

    Yes, if you want all of the points. Check out the grade sheet.

  2. How can change the background color in OpenGL?

    Use the glClearColor procedure. This must occure BEFORE any calls to glClear(GL_COLOR_BUFFER_BIT).

  3. How do I find out about the individual procedures and functions avaiable in OpenGL?

    Please see the documentation section on the course page http://www.cs.rit.edu/~ncs/Courses/570.shtml. There are links there to both the "OpenGL Programming Guide" and the "OpenGL Reference Manual", as well as the GLUT manual. You can find out more than you'll ever want to know ( :-) ) about the OpenGL commands in the Reference Manual.

  4. Is there anyway for me to see the colors before I select them?

    Try the applet at http://www1.mmu.edu.my/~mukund/cogr/RGB.html. You can see the numbers for the red, green and blue values for the color that is displayed out of 255.

    You might also want to look at /usr/openwin/lib/rgb.txt. This will provide a list of color names and the values to use for red, green and blue. (These values range from 0 to 255 for each color - Red, Green, Blue.)

  5. How can I clear the screen in OpenGL?

    glClear(GL_COLOR_BUFFER_BIT) does the trick.

  6. I'm trying to use view_windows and viewports, but my images keep getting smaller and smaller. What am I doing wrong?

    It is likely that you've forgotten to precede your call to glOrtho or gluOrth2d with these lines:

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    We'll be looking at all of these transformations in the coming weeks and what's happening here will be clearer then. What is happening is the matrix representing your window is being multiplied in over and over again.

  7. In the specifications for programming assignment 2, I don't understand what you mean by: "You are expected to use the window-to-viewport transformations to construct an original image composed of a variety of pieces." I know it's related to the drawWorld() example you did in class.

    There is an example of drawWorld() in MultipleViewports in

    http://www.cs.rit.edu/usr/local/pub/ncs/graphics/OpenGL/ExamplesLab2/

    In this case, all the drawWorld() does is draw a red or white square. (drawWorld() is display()) Your drawWorld() (and you could name it that) could contain the commands to draw ALL of the things in your world. Then, using

    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    gluOrtho2D(...); (OR glOrtho(...);)
    each time BEFORE calling drawWorld(), you can choose which of all the things you are drawing to actually display on the screen! (The rest are clipped away.)

    glViewport is used to select WHERE to place what you've chosen from your world.

  8. My program currently doesn't have multiple "screens." It has a single environment that changes according to how you move the mouse, click the mouse, and there are a few keyboard keys that you can use to manipulate. My question is, do we have to have the multiple frames or is an interactive environment sufficient?

    Yes, that is sufficient. The specifications indicate what I'd minimally like to see. The point of the multiple screens was to have you implement some mouse functionality.

  9. My vertices do not seem to be showing up where I have specified. How could that happen?

    There are a couple of things I can think of at this point to check:

    1. Make sure you have specified the viewWindow (using gluOrtho2d or glOrtho) correctly as well as your viewport (using glViewport).
    2. Make sure all of your glEnd's are written as glEnd() NOT glEnd. For some reason the compiler doesn't catch this and the results are MOST peculiar!

  10. Where is the OpenGL library located on our systems?

    The Makefile in any of the directories in my public area actually contain this information, the INCLUDE line tells us where all the include files are located and the LDFLAGS line tells us about the location of the libraries. In particular, glut.h is located in /usr/local/glut/include/GL and gl.h and glu.h are located in /usr/openwin/include/GL. The glut library is available in /usr/local/glut/lib/glut and the OpenGL libraries are in /usr/openwin/lib -L/. The X stuff is needed by GLUT.


Nan C. Schaller
Rochester Institute of Technology
Computer Science Department
102 Lomb Memorial Dr.
Rochester, NY 14623-5608
telephone: +1.585.475.2139
fax: +1.585.475.7100
e-mail: ncs@cs.rit.edu
April 11, 2002
http://www.cs.rit.edu/~ncs/Courses/570/faq2.html