Archive for the ‘cpsc465’ Category

Announcements

Saturday, April 8th, 2006

Assignment 6 is available.

Note the updated office hours shown to the left: I’ve been able to rearrange my work schedule in order to be available before class. Be sure to drop by and visit.

GLIntercept

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:

glClearColor(0.000000,0.000000,0.000000,0.000000)
wglGetCurrentContext()=0x10000
wglGetCurrentDC()=0xb70114f8
wglGetCurrentContext()=0x10000
wglGetCurrentDC()=0xb70114f8
glViewport(0,0,600,300)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(0.000000,2.000000,0.000000,1.000000,-1.000000,1.000000)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(1.000000,1.000000,0.000000)
glBegin(GL_LINES)
glVertex3f(1.000000,0.000000,0.000000)
glVertex3f(1.000000,1.000000,0.000000)
glEnd()
glViewport(300,0,300,300)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glFrustum(-1.500000,1.500000,-1.500000,1.500000,2.000000,8.000000)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glMultMatrixf([1.000000,0.000000,0.000000,0.000000,
             0.000000,1.000000,0.000000,0.000000,
             0.000000,0.000000,1.000000,0.000000,
             0.000000,0.000000,0.000000,1.000000])
glTranslated(0.000000,0.000000,-6.500000)
glPushMatrix()
glPushMatrix()
glColor3f(1.000000,0.000000,0.000000)
glBegin(GL_LINE_LOOP)
glNormal3fv([0.000000,0.000000,-1.000000])
glVertex3fv([0.500000,0.500000,-0.500000])
glVertex3fv([0.500000,-0.500000,-0.500000])
glVertex3fv([-0.500000,-0.500000,-0.500000])
glVertex3fv([-0.500000,0.500000,-0.500000])
glEnd()

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.

Why Microsoft is not my favorite software company

Saturday, March 18th, 2006

The grade sheet that I posted a few minutes ago is rather hard to read in Internet Explorer. It looks like the bottom few pixels of each row are cut off.

The HTML file was generated by setting a print area and choosing Save As Web Page from the File menu in Excel 2004 for Mac.

I understand cross-browser differences. I even understand cross-platform differences. But if I can’t save a web page from the latest version of one Microsoft product and have it readable from the latest version of another Microsoft product, well…

You should all be using Mozilla Firefox anyway. It looks fine there.

Assignment 5

Saturday, March 11th, 2006

Assignment 5 is available. Note that this is the last assignment due before the Midterm Exam on March 24.

Another schedule update

Monday, March 6th, 2006

Please note that I’ve updated the Course Outline again.

For those of you wondering why I’ve been making changes to the schedule, I’ve taught the course two different ways in the past:

  1. As a lab course with weekly assignments
  2. As a lecture course with 4 or 5 larger programming assignments

In courses of type (1), we cover the basic techniques of 3D graphics and you get a lot of experience implementing them. In courses of type (2) we talk about a broader range of topics, but for most of them you never get a chance to see the code.

I’d originally planned to teach this semester as a lecture course, but when it was scheduled for a single class meeting on Friday nights a couple of things became clear:

  1. The building would be nearly empty, and we could have our pick of labs
  2. In a lecture course, everyone would be asleep by 8:45

So I’m adjusting the outline as we go along. I think we’re on track for the rest of the semester, but don’t be surprised if there’s at least one more change before the end.

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.
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-2.0, 2.0, -2.0, 2.0, 0.0, 10.0);
  3. Set your viewing parameters.
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    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);
    glClear(GL_COLOR_BUFFER_BIT);
    
    glColor(0.0, 0.0, 1.0);
    glutWireSphere(1.0, 10, 10);

Don’t cross the streams

Friday, March 3rd, 2006

If you’re still working on Assignment 3, note that the coordinate axes (the lines in gray) should not be moving when you transform the cube. The axes should remain at the center of the world, not at the center of your model.

By the way, Assignment 4 is available.

Assignment 3

Saturday, February 25th, 2006

Assignment 3 is available.

Demo version of Assignment 2

Monday, February 20th, 2006

A compiled executable version of Assignment 2 is now available. Download assignment2.exe to see how your program should work.

My version needed 14 new lines of code: a function to implement the vector cross product operation and some changes to the function move_point().