COEN 290 Laboratory Information


Lab Introduction

Brad Grantham, grantham@plunk.org, (650)224-5545

(Dave Shreiner, shreiner@plunk.org teaches the "COEN290" lecture portion on Wednesdays.)

Brad is the Coen290 Lab Instructor. He will be available to help you with lab assignments during most scheduled lab sessions, and through the coen290 email alias, coen290@plunk.org. He also manages policy on Lab submissions and grade lab assignments.

Labs are assigned during the lecture on Wednesday. Usually the labs are due one or two weeks later, at 7 PM on Wednesday night, before the lecture lab.

The lab portion of COEN290 does not usually have a lecture. Normally Brad just uses the time to allow you to ask detailed questions and get help before the program is due. You may or may not show up depending on whether you think you need help.

Table of Contents


Lab Assignments and Due Dates

Click on the lab name to see the assignment and the instructions.
Project NameDue Date
Lab 1Wednesday, January 17th, by 7 PM
Lab 2Wednesday, February 7th, by 7 PM
Lab 3Wednesday, February 21st, by 7 PM
Final ProjectProposal due Wednesday, March 7th, by 7 PM
Final project due by March 25th.
Project ReportSchedule Presentation time


Programming Language and Library

Assignments will be completed in the C or C++ programming language, use OpenGL as the graphics library, and GLUT as the windowing interface.

For information about OpenGL, see the OpenGL Webpage, or the comp.graphics.opengl newsgroup.


Development Machines

We recommend using Windows 2000 with Visual C++ 6.0. This is the configuration used on the Design Center PC's. Windows 98 (with Visual C++ 6.0) will probably operate very similarly and so we'll accept questions about it as well.

You may use another compiler, such as CygWin or Borland C++, or even Linux or UNIX, but you will be mostly on your own. We will attempt to help but can only commit to supporting one compiler and operating system. If you try to compile the lab projects at home, you will need OpenGL. For Windows, we recommend downloading and running "GLSetup", which is available from www.glsetup.com. It will automatically detect what video card you have and will install the correct OpenGL driver.

If you have a PC running Linux or OS/2, or a Unix system, Amiga, Machintosh, BeOS, or Next machine you can use Mesa, a free library compatible with OpenGL.

Even if you develop your program on Linux or UNIX, you will be required to provide your source code and a runnable program on the SCU lab machines, specifically under NT. If you are unable to comply because of schedules or travel times (we have day jobs, too) then please talk with us about it.


OpenGL, Mesa, and GLUT

OpenGL and Mesa

Windows NT and 98 have native implementations of OpenGL. Use GLUT (a public domain window system interface) for the window system interactions.

GLUT

GLUT is a window-system independent window-interface layer for OpenGL. To be portable, OpenGL has no notion of a window system. A separate library has to be used to create a window, create an OpenGL context, attach the two, and start OpenGL. While OpenGL is running, this library is used, along with the window system itself, to handle window events, such as mouse or keyboard input.

There are a number of major window systems in use right now: X11 (for Unix) Windows from Microsoft, OS/2 from IBM, MAC OS, etc. (some don't make a clear distinction between the Operating and Window systems). There are corresponding OpenGL interface libraries for each window system:

These systems are very powerful; allowing you to determine what graphics features the OpenGL window should have, allowing buttons, sliders, and other input items in the window, and handling window interaction events such as mouse and keyboard input. It is often not trivial to program with these interfaces.

Enter GLUT.

GLUT is library that is layered on these window-system dependent systems, and provides a single interface for simple OpenGL programs. It's more or less designed to make it easy to start programming with OpenGL, and to provide some portability across systems. If you write an OpenGL program, and use GLUT to handle the windowing issues, you will have a fairly portable piece of source code (binary compatibility is a whole other issue).

GLUT has its limitations, but it is simple to program with, and is supported on PCs, Unix Machines, and Macintoshs.

If you want information about GLUT on NT, including where to download it, try this link. It also includes some really cool images!

To get you started, here is my list of frequently used GLUT functions.


Getting Started with Mesa and GLUT

Sample Programs

To download these programs, hold down the shift key, and click on the the highlighted text. A dialog box should pop up, allowing you to choose where you want to download the file.


Lab Time Slot

Mondays in Room 618 (in the Design Center in the Mechanical Engineering building), 7:10 PM until 9 PM

This means that we have priority in this room on the day and hours listed. This protects us from marauding seniors. It doesn't mean that you have to do your work in room 618 only on Wednesday nights.


Honor Code Adherence

The SCU School of Engineering Honor Code prohibits students from giving or receiving aid for course work for the purpose of grading except as permitted by the instructor. That means I expect you to turn in lab programs that are your work; you you write the code in your programs. The exceptions to that rule are the following: Inclusion of code other than your own in your lab submission must be clearly documented, including the purpose of the code, where you got it, and how it adds to your program.

Just to go over this once again, the instructors will be sorely upset if they find out that two people shared code, and violations will be reported to the office of the Dean.


Loading JPEG images

We have provided a JPEG loader for you. This function reads a JPEG file and returns an array of RGB unsigned char that you can use as a texture. You will need to download these two files into the directory with your source files: Then you will need to add the following line to your source code, before your function which calls it:
    void jpegRead(char *jpegName, int *width, int *height, unsigned char **pixels);
Call this JPEG loader function with code that looks something like this:
    int imageWidth;
    int imageHeight;
    unsigned char *imagePixels;

    /* The & means to pass a pointer to the thing. */
    jpegRead("bricks.jpg", &imageWidth, &imageHeight, &imagePixels);

    /* Then use imageWidth, imageHeight, and imagePixels for a texture. */
    /* Since you can't know that the dimensions are a power of two, I
       suggest using the GLU mipmap function gluBuild2DMipmaps. */

    /* Let go of the pixel memory */
    free(imagePixels);
Please feel free to take the libjpeg loader with you for future programs. When you are finished with the pixels in your program, free the pixel memory with something like free(imagePixels).

(If you want to see the code I wrote to load the JPEG, it's called loadjpeg.c, but you also need the JPEG library to compile it.)


Brad Grantham (grantham@plunk.org)
Original document by Tom McReynolds

Last modified: Tue Mar 6 14:13:11 EST 2001