Archive for the ‘graphics’ Category

Compiling Fl-Inventor on Windows

Thursday, June 15th, 2006

Another option for Open Inventor programming on Windows is the Fl-Inventor library. Here’s how I got it to build:

  1. Download the latest version of FLTK 1.1 from At the time of this writing, the latest is
  2. Unzip somewhere convenient, say C:\fltk-1.1.7
  3. Open visualc\fltkdll.dsw with Visual Studio. (I’m using 6.0. If you’re using a later version, your mileage may vary.)
  4. Choose Build, Set Active Configuration… and choose fltkdll - Win32 Release


  1. Choose Build, Build fltkdll.dll.
  2. Download and install an older version of CMake from (The latest version won’t work without change, and the last thing I need to learn is a new build tool.) I used CMSetup14.exe.
  3. Download fliv-1.0.1.tar.gz and oiv_linux_w32-4.tar.gz from Unzip them both into the same place.
  4. Change to C:\fl-inventor and type “cmake .
  5. Back in Visual Studio, open FLINV_ALL.dsw
  6. Set the Active Project Configuration to “ALL_BUILD - Win32 Release”.


  1. Choose Project, Settings…. Settings For: should be set to “Win32 Release”, and all sub-projects should be selected.
  2. Holding down the Ctrl key, de-select ALL_BUILD. Some more tabs should appear to the right. Select the C++ tab, and change Category: to “Preprocessor”. Under Additional include directories:, add C:\fltk-1.1.7.


  1. Holding down the Ctrl key again, de-select FL, FreeType2, and Jpeg. A Link tab should appear to the right. Select it and Change the Category: to “Input”. Under Additional library path:, add C:\fltk-1.1.7\test. Click Ok


  1. Choose Build, Build. The build will take several minutes.
  2. Exit Visual Studio. You should be able to run the example programs from C:\fl-inventor\install\bin

Open Inventor on Windows

Wednesday, June 14th, 2006

The Open Source version of SGI Open Inventor is Linux-specific, and while it probably ports easily enough to other UNIX platforms, it doesn’t look like a very attractive option for Windows.

If you want to do Open Inventor programming on Windows, the options seem to be:

  1. TGS Open Inventor, a commercial product
  2. Coin3D, a GPL clone of Open Inventor
  3. a Win32 port of the Open Source SGI Open Inventor that requires the SoQt library from Coin3D

Coin3D is probably the best choice, but it seems to include only the OI libraries, not the OI command-line tools like ivview and ivnorm.

Alternatively, the Win32 port of Open Inventor does incldue pre-compiled DLLs of Inventor, but not of the SoQt library or command-line tools.

I’m honestly not sure what the best solution is. I’ll post some instructions when I come up with something.

Pixar’s On-line Library

Saturday, May 13th, 2006

I happened across this the other day: Pixar has made available an On-line library of technical papers. Many of them are probably a bit advanced, but worth a look if you’re considering further study.

Material Colors

Wednesday, May 10th, 2006

Here’s a function to set the current drawing color, whether or not lighting is enabled:

void color(double r, double g, double b)
    float color[4] = { r, g, b, 1.0 };

    if (glIsEnabled(GL_LIGHTING)) {
        glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
    } else {
        glColor3f(r, g, b);

Note that although the color can be set for GL_AMBIENT and GL_DIFFUSE separately, you’ll usually want them to be the same.

Alternatively, you could try reading about GL_COLOR_MATERIAL.


Saturday, April 1st, 2006

Here’s a cool debugging tool for OpenGL on Windows: GLIntercept. You can use it to track every OpenGL function call along with its parameters. (For those of you familiar with UNIX, this is like truss(1) or strace(1), only for OpenGL calls instead of system calls.)

Here’s a 30-second walkthrough:

  1. Download and run the Windows installer. You’ll end up with a new directory, C:\Program Files\GLIntercept0_5.
  2. Copy OpenGL32.dll and gliConfig_FullDebug.ini to the same directory as your program. Rename gliConfig_FullDebug.ini to gliConfig.ini
  3. Run your program. A new file will be created in the same directory called gliInterceptLog.txt, containing every OpenGL call your program makes. (You may also find that your program is a little slower).

Here’s some of the output from running assignment5.c:


Running with gliConfig_FullDebug.ini also makes sure that every call to an OpenGL function is checked with glGetError(), which will catch things like passing bad values to functions or trying to pop the matrix stack more times that it’s been pushed.

To make the best use of a tool like this, you’ll probably want a utility to tail the log as your program is running. (I’m told there are also GUI versions).

Note that you don’t need access to the source code — if you have a game at home that uses OpenGL, you can watch what it’s doing, too. (Just don’t steal their code, and don’t tell them I’m the one who told you how.)

GLIntercept has a few more tricks up its sleeve, but I’ll leave it up to you to read about them. For Linux people, there’s a similar program called BuGLe, but I haven’t tried it. And, of course, we smug OS X weenies have the OpenGL Profiler.

For those of you using Igloo, I’ve put together a new debug package that includes GLIntercept and Windows port of GNU tail. I’m not entirely sure about the legality of all this — GLIntercept and GNU tail are available under the GNU General Public license, but EiC is still MIA.

Vector Math Tutorial for 3D Computer Graphics

Monday, March 6th, 2006

If you need to brush up on your math before the midterm, the Vector Math for 3D Computer Graphics from the Computer Science department at Central Connecticut State University is a pretty good review.

A correction

Monday, March 6th, 2006

If you were paying attention over the weekend, you noticed that I updated the screenshot for Assignment 4.If you compare it with the original screenshot, you’ll notice that the original wasn’t really a parallel projection.

The problem is that (as you should recall from your reading) OpenGL is a state machine. When you make a function call like gluPerspective() to update the current projection matrix, that change stays in effect until you reset the matrix (e.g., with glLoadIdentity().

My mistake was to draw the parallel projections (calling glOrtho()) without remembering to reset the projection matrix, which had already been set with gluPerspective. The result was that we took a cube in perspective, then drew a parallel projection of the perspective rendering. Oops. I didn’t notice because it looks “sort of” right — there was, in fact, a parallel projection happening.

To avoid making silly mistakes like me, do the following whenever you go to render a model (e.g., in your display callback):

  1. Set the viewport.
    glViewport(0, 0, width, height);
  2. Set up the projection.
    glOrtho(-2.0, 2.0, -2.0, 2.0, 0.0, 10.0);
  3. Set your viewing parameters.
    gluLookAt(0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
  4. Draw the scene.
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glColor(0.0, 0.0, 1.0);
    glutWireSphere(1.0, 10, 10);

An easy way to run OpenGL programs

Thursday, February 16th, 2006

Now that I’ve put you through the pain of setting up your own
programming environment
, I’ll show you the easy way to run gears.c.

Grab a copy of and unzip it somewhere convenient. Run the program by typing

C:igloo> igloo gears.c

Cool. No compilation step, no moving headers and library files around, just type and go. And in less than 230 Kb.

Igloo is a version of the EIC C Interpreter, an Open Source project that seems to have gone missing in action.

Luckily, I saved a copy, just for you. I wish I’d saved a copy of the source code, too, but at least there are lots of other C interpreters.

So what’s the catch?

  1. The error messages generated by the interpreter aren’t perfect. But then again, neither are the error messages generated by Visual Studio.
  2. I’m not sure how exact it is about implementing the ANSI C Standard, and can’t find out because the web site is gone. There may be constructs that won’t work. But gears.c is pretty complicated, and it works just fine.
  3. It’s a C interpreter, not C++. Feel free to Google for one of those, and e-mail me if you find a good one.

Hints for Assignment 1

Saturday, February 11th, 2006
  1. If you’re writing your program in C++, note that <GL/glut.h> needs to be #included after <iostream> or you’ll get

    error C2381: ‘exit’ : redefinition; __declspec(noreturn) differs

  2. In order to toggle double-buffering on and off, you’ll need to destroy and re-create the window. See the API Reference for details.

Setting up OpenGL in CS-300

Saturday, February 11th, 2006

If you’re working in the lab, instead of messing around with placing the GLUT header and import library files in the right directories, just download and unzip it into C:\.