CS 3744, Assignment 1 - Due February 2, 2010

The goal of this assignment is to verify that Netbeans and JOGL are properly installed and working and to create a simple OpenGL application with a reshape callback.

Assignment

Consider the program on the class web page that draws a white rectangle on a blue background. This code specifies that the rectangle dimensions are half the dimensions of the initial graphics window. Run this program in Netbeans through the following steps: Notice that when this program is run, the size of the white rectangle changes when the screen window is resized. This is because the default reshape callback sets the viewport to the size of the entire screen window whenever it is resized. Write a simple reshape callback so that when the screen window size is changed, the rectangle remains exactly the same size and stays in the same position relative to the bottom left of the window. Make sure that when the screen window is partially or completely covered, the rectangle is redrawn correctly when the window is again uncovered.

Next change your program to draw a duplicate white rectangle to the right of and slightly higher than the first white rectangle. Of course, you will not see the second rectangle entirely when your program starts, but if your program is correct at this point, you will see both rectangles when the screen window is sufficiently enlarged.

The next modification involves adding a mouseMoved handler to return the mouse coordinates whenever the mouse is moved and to write the x, y mouse coordinates in red in the center of the lower left white box using the OpenGL GLUT functions. The easiest way to do that is to add a global string variable to the main class and to let the mouseMoved function write the coordinates to that variable. Then calls to glColor, gl.RasterPos, and glutBitmapString are all that is needed in the display handler. Be sure to call glColor BEFORE the call to gl.RasterPos. Note that the mouse coordinates are in device coordinates with (0, 0) at the upper left.

The final task is to write the x, y mouse coordinates in green in the center of the upper right white rectangle using Swing methods. The code is provided in the template, and you need only figure out the correct coordinates for placing the text.

Instructions