/var/spool/weblog
   


Prof Avery's weblog
industrial waste of time

<spool@kenytt.net>

CSU Fullerton Perl Powered Python vi Hacker

Geek News

del.icio.us bookmarks

RSS


       
Fri, May 19, 2006

Minimal Ray Tracer
Some code to accompany tonight's lecture: a version of Paul Heckbert's Minimal Ray Tracer from Graphics Gems IV.

I've updated the code to do the following:

  • compile with GNU C
  • output plain PPM
  • generate a 1024 by 1024 image instead of the tiny 32-pixel original
I've also included a JPEG version of the image, generated with ppmtojpeg,

If you want to experiment with changing the scene defined in ray.h, you'll probably want to download NetPbm for Windows.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Sat, May 13, 2006

Assignment 10
If you didn't finish Assignment 10, you can download assignment10.c as a starting point for Assignment 11.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Fri, May 12, 2006

Demos for tonight's lecture
There are two demonstration program for tonight's lecture:

You will need the texture mapping technique for Assignment 11.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Pixar's On-line Library
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.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Wed, May 10, 2006

Is this normal behavior?
Have you noticed that the lighting calculations don't seem to be affecting your windshield the same way they affect the rest of the car?

I wonder which part of the illumination equation isn't being evaluated normally.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Material Colors
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.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Fri, May 05, 2006

Chapter mismatch between HTML and PDF versions of the Red Book
HTML and PDF versions of the Red Book -- they're different editions, with different Chapter divisions. The Chapter 12 you want is "Selection and Feedback", not "Evaluators and NURBS." The next chapter, "Lighting", has the same problem.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Fri, Apr 28, 2006

Assignment 9
Assignment 9 is available. Trust me -- the assignment will be easier if you attend class and implement the version of the algorithm that we discuss.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Fri, Apr 14, 2006

Slides for tonight's lecture
For the second half of tonight's lecture, we'll be looking at the Aliasing and Antialiasing slides in the ACM SIGGRAPH 1993 Education Slide Set. There are some visual effects here that I couldn't draw on a whiteboard to save my life.

/var/spool/courses/csuf/2006/spring/cpsc465 #

A note on doing the work yourself
I realize that in Assignment 6 and Assignment 7 where we deal with well-known algorithms, it will be especially tempting to use someone else's implementation -- they are, after all, readily available on teh interwebs.

Note, however, the following:

  1. Turning in code you didn't write yourself is Academic Dishonesty.
  2. Using someone else's pseudocode is fine, as long as you credit the source.
  3. If you do use someone else's pseudocode, make sure you understand what it does.
  4. There will be at least one question on each algorithm on the Final Exam.
  5. If you take the time to implement the algorithm yourself, you will be more likely to remember it well enough to earn full credit on the exam.
Remember also that if you are struggling with an algorithm, you are allowed to work on homework assignments with a partner.

Hint: pick a partner who's smarter than you are.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Fri, Apr 07, 2006

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

/var/spool/courses/csuf/2006/spring/cpsc465 #

Fri, Mar 31, 2006

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

/var/spool/courses/csuf/2006/spring/cpsc465 #

Sat, Mar 18, 2006

Why Microsoft is not my favorite software company
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.

/var/spool/courses/csuf/2006/spring/cpsc465/misc #

Homework Grades
I've posted grades as of 10:41pm Friday 3/17.

If you turned in an assignment that isn't recorded, or if you didn't get as high a score on an assignment as you think you should have, please e-mail me.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Fri, Mar 10, 2006

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

/var/spool/courses/csuf/2006/spring/cpsc465 #

Mon, Mar 06, 2006

Another schedule update
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.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Vector Math Tutorial for 3D Computer Graphics
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.

/var/spool/courses/csuf/2006/spring/cpsc465 #

A correction
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);

/var/spool/courses/csuf/2006/spring/cpsc465 #

Thu, Mar 02, 2006

Don't cross the streams
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.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Fri, Feb 24, 2006

Assignment 3
Assignment 3 is available.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Mon, Feb 20, 2006

Demo version of Assignment 2
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().

/var/spool/courses/csuf/2006/spring/cpsc465 #

Sun, Feb 19, 2006

Assignment 2 update
Some compilers may have trouble with Assignment 2 because their standard library's <math.h> header files define y0() and y1() to compute the Bessel function.

To fix the issue, replace y0 and y1 with y_0 and y_1 or download the updated version of assignment2.c

Line 194 may cause some compilers to issue warnings:

	glutPostRedisplay;
should be
	glutPostRedisplay();

/var/spool/courses/csuf/2006/spring/cpsc465 #

Sat, Feb 18, 2006

Assignment 2
Assignment 2 is available. Check back mid-week to download a compiled executable of a working solution.

/var/spool/courses/csuf/2006/spring/cpsc465 #

Fri, Feb 17, 2006

Stop trying so hard!
For those of you still scrambling to finish Course Outline says "Chapter 1 and Chapter 2," that's exactly what it means. You shouldn't be reading Chapter 5 or Chapter 12. You don't need glTranslate() or gluPickMatrix() or any other OpenGL function that you haven't run into in Chapters 1 and 2. (Don't worry, we'll cover those functions later on, when we get to them.)

In the meantime, here are the GL functions I called in my solution for Assignment 1:

  • glBegin
  • glClear
  • glClearColor
  • glColor3f
  • glEnd
  • glFlush
  • glLoadIdentity
  • glMatrixMode
  • glOrtho
  • glVertex3f
  • glViewport
And technically, I didn't even need to bother with glViewport().

If your list looks significantly different from mine, and especially if you're trying to translate the square to move it around the window or use a pick list to figure out whether the user clicked it, you've gone down the wrong path. We're not even going to talk about translation until next week. (Well, ok, possibly this week; but if so, only at the end.)

/var/spool/courses/csuf/2006/spring/cpsc465 #

Wed, Feb 15, 2006

An easy way to run OpenGL programs
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 igloo.zip 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.

/var/spool/courses/csuf/2006/spring/cpsc465/misc #


       

 

December 2017
Sun Mon Tue Wed Thu Fri Sat
         
           

RSS

Topics


Archives



Advanced Search
Search:
Entire Site This Topic Only
Match:
Any All
Partial Whole Words only