FAQ for Programming Assignment 1
Under Construction

General Questions

  1. Is there a way I can view my graphics projects on my PC at home?

    Well, yes and no. You can construct your projects on your home computer but you will need to have OpenGL, GLUT, and a C/C++ compiler to do so. BUT, be WARNED, if you do so, you will need to allow yourself enough time to try it out on the RIT Sun workstations and submit it from there. Also, I found that I have to set my laptop screen to 256 (:-() colors to get stuff to actually show up. Some graphics boards are better than others at supporting openGL.

    What you CANNOT do is execute your program on a Sun and display it at home on a PC or Mac. GLUT is too device dependent to allow the graphics to be seen. (Well, I understand you might be able to if you use Cygwin...)

    BUT, it has been reported that if you are using Linux (with Mesa, an OpenGL look alike, and GLX - which is likely the critical piece) or Mac OS X with Xfree86 installed you can view it like you view any other Unix application. I.e., when you ssh into the cs box, X server output gets forwarded automatically. (If there is a GLUT version for Windows that calls glx, we might be able to do this from windows as well.)

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

    Look in /usr/local/pub/ncs/graphics/OpenGL/Lab1. 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=paint

    (assuming you've followed directions and named your file paint.c!).

  3. 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.

  4. 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/Lab1 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.

    NOTE: Do NOT cut and paste the contents of this file as there are critical TABs in it.

  5. I get the following error:

    In file included from paint.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 if OpenGL is not mounted on the machine that you are using. 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!

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

    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++.

  7. I cannot figure out how to use structs. Can you help?

    You could create a data structure using parallel arrays instead, or you could consult a C book. BUT ... here's how you define a struct in C:

    struct edge {
       int ymax;
       float xAtYmin;
       float inverseSlope;
       struct edge *next;
    };

    And, here's how you then declare a variable to be of this type.

    struct edge edge1;
    struct edge *AET;

    To reference a particular field, say "ymax", the field may be accessed as "edge1.ymax" or "AET->ymax", respectively.

  8. I'm getting an arithmetic exception that I can't find, mostly because I can't isolate it. I've been trying to use "printf" to find were exactly the error is being generated, but that is not printing anything to the screen. Can you tell me of a function that will display text to standard out?

    "printf" is the function you want, but to force output, you may find that you need to do an "fflush( stdout )" after each printf. Output is buffered and only printed when the buffer is full; "fflush" forces it to be printed immediately.

Line Drawing Questions

  1. Only some of my lines get drawn when I run lineTest with my drawLine routine; what's happening?

    You don't really expect me to be able to answer this with no further info, do you? My approach would be to make a copy of the lineTest.c program and comment out all of the line drawing except one. Get that debugged and add others in one at a time.

  2. Should I have to use the absolute value function for the four special cases?

    Not in general as it will undermine your efficiency; the only place where you MIGHT use it is to decide whether it's a steep or shallow slope.

Polygon Filling Questions

  1. Only some of the polygons get drawn when I run polygonTest with my drawPolygon routine; what's happening?

    You don't really expect me to be able to answer this with no further info, do you? My approach would be to make a copy of the polygonTest.c program and comment out all of the polygon drawing except one. Get that debugged and add others in one at a time.

  2. I remember mention about truncation or rounding of the x intersection values for filling, but what exactly did you say?

    Remember the rule about not drawing top or right edges? Well, that comes into play here. What you do is "err" on the side of getting inside the polygon, so if

    Be sure NOT to save the altered value in your data structure, rather keep the whole X value as a float!

  3. How can we find out how high the window is to create the ET?

    The window size by default is 300 X 300, but it can be altered by using GLUTInitWindowSize and it can be reset by resizing the window. In the latter case, the user has access to the new window size if they have registered the Reshape callback function. This suggests that a dynamically allocated ET would be in order to be robust.

    However, paint assumes a 500 X 500 window initially, but (I just noticed) creates the default size one. Rather than get too fancy (unless you want to), just use 500 as the height or come up with a different datastructure (see below). I will (EVENTUALLY) modify paint to open a 500 X 500 window or to set the initial window size to 300 X 300 for consistency.

  4. The data structure discussed in class seems like it's overkill; may I design another datastructure?

    Yes, feel free. Just be sure the essence of the algorithm is in tact. For example, since at most you will have three edges, you COULD put everything into the AET sorted by minimum Y, and use only the first two entries for filling at any one time. Be sure to sort these two by their current X values before filling and be sure to keep the X and the inverse slopes as floats.

  5. I cannot figure out how to use structs. Can you help? (Note: this question is a repeat of one under General Questions)

    You could create a data structure using parallel arrays instead, or you could consult a C book. BUT ... here's how you define a struct in C:

    struct edge {
       int ymax;
       float xAtYmin;
       float inverseSlope;
       struct edge *next;
    }

    And, here's how you then declare a variable to be of this type.

    struct edge edge1;
    struct edge *AET;

    To reference a particular field, say "ymax", the field may be accessed as "edge1.ymax" or "AET->ymax", respectively.

  6. Is it all right to use my drawLine routine in my drawPolygon routine?

    Well, it is certainly possible to do so, BUT as it is not efficient to repeatedly call functions, I will take off if you do so.

  7. Some of my triangles are not drawing properly. How can I find out what's going wrong?

    The key to debugging is simplification. Make a copy of the drawPolygon.c file and eliminate all but one of the triangles that is not drawing properly and then add a lot of printf's and fflush's to your filling algorithm so that you can trace it.

OpenGL Questions

  1. 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.

  2. 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.

  3. Are there any news groups for OpenGL?

    Yes, there are several. One is http://groups.yahoo.com/group/opengl-newbie. You may need to join the group to read it. They also have a plain opengl group. Other are comp.graphics.opengl and comp.graphics.api.opengl. You can subscribe to it though netscape's mailer.


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
December 19, 2002
http://www.cs.rit.edu/~ncs/Courses/570/faq1.html