Archive for the ‘assignments’ Category

Assignment 2

Saturday, February 18th, 2006

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

Stop trying so hard!

Friday, February 17th, 2006

For those of you still scrambling to finish Assignment 1, note that the Course Outline says “Chapter 1 and Chapter 2,” and 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.)

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.

Assignment 1

Friday, February 10th, 2006

Assignment 1 is available. There are a few questions to answer and a program to write.

Assignment 0

Saturday, February 4th, 2006

Assignment 0 is available.

If you are using Visual Studio, you may run into a problem compiling Example 1-2 from the OpenGL Programming Guide. If you run into a large number of errors complaining about undefined constants like WINGDIAPI, then problem is the two header files in the listing:

#include <GL/gl.h> #include <GL/glut.h>

The problem is that the Win32 OpenGL implementation is done in terms of the Win32 API, and uses Win32 API constants to declare functions. You can fix this by #includeing windows.h first, by swapping glut.h and gl.h, or by just #includeing glut.h by itself, because the GLUT header #includes gl.h.

Incidentally, take a look at the hoops you have to jump through in the first 100 lines or so of the Win32 version of glut.h just to get the headers straight to see why I stopped writing code for Windows in 1999 and haven’t looked back.

PLY Format

Monday, May 9th, 2005

If you haven’t started writing the code to read object files, I recommend PLY format. I hadn’t noticed it, but the page I linked to already includes code to read PLY files. The PLY page at Georgia Tech also has code to convert OBJ files to PLY format.

Parser Test Programs

Saturday, May 7th, 2005

The programs I used to test Assignment 2 have been posted here.

Software Milestone Exercise

Monday, May 2nd, 2005

Click here for today’s Lab Exercise.

3AC Interpreter

Monday, May 2nd, 2005

I’ve posted a virtual machine written in Python that will execute the 3AC for Assignment 3. You can download a copy fo the 3AC factorial program here. Make sure that you have Python installed, then type

$ python 3vm.py factorial.3ac

You’ll see a trace of memory accesses and the output of the program.

(Note: now that I’ve actually been able to run the program, I’ve updated the original factorial program and its corresponding 3AC code, and added a HLT instruction to the 3AC definition.)

Example Parser and another Lexical Analyzer

Sunday, May 1st, 2005

If you had trouble finishing Assignment 2, you can download example.zip to start work on Assignment 3.

The parser was generated with the Coco/R compiler generator. To add semantic actions, you can either read the documentation, edit example.atg and re-generate the compiler, or you can modify the C code directly.

I chose Coco/R instead of YACC or Bison because it generates Recursive-Descent parsers instead of LALR(1) parsers. You are, of course, limited to LL(1) languges, but the resulting code is significantly easier to read and debug.