Lab 2: Introduction to OpenGL/JOGL
CS 445: Computer Graphics, Fall 2008


[previous lab][schedule][next lab]

Reading

Goals


Part 1 (week 1) Getting Started with OpenGL


SimpleJOGL

Netbeans makes it possible for you to automatically generate a number of JOGL examples. In this part of the lab, you are to generate the Simple JOGL Application as follows. In Netbeans, go to the menu File; New Project. Under "Categories" choose OpenGL. Under "Projects" choose Simple JOGL Application. Click the "Next" button and continue as usual to create a new project. Run the program and look through the code. Your job is to try to understand what each part of the code is doing.

We will go over it in class as well.


Animation about y-axis

glutWireTeapot

To explore what the code is doing, try experimenting by making small changes. For example:

  • Run the code and resize the window. What happens? The resize behavior is controlled by the code in the reshape method. Do you understand the code? For example, what happens when
    h = (float) width / (float) height;
    is replaced with h=1;

    Try changing other things such as parameters in the lines

    • gl.glViewport(0, 0, width, height); or
    • glu.gluPerspective(45.0f, h, 1.0, 20.0);
  • Move the camera in the display method (do you see how?)
  • Transform the objects in the display method (e.g. rotate, scale, translate)
  • Animation is actually turned on but nothing moves because you don't ever change what is drawn. Try changing what is drawn, for example, by adding the following lines in the display method (where you put these lines is important!):
    angle += 1;
    gl.glRotated(angle, 0, 1, 0);
  • Add glut objects (e.g. teapots, spheres, boxes, etc).

Part 1 Deliverables: By classtime on Oct 2, Place a number of sample images of what you generated in the lab2/part1/your_name folder. You do not need to turn in the code. Also place a jar file of at least one animation you created. Be prepared to discuss how you generated the images.


Part 2 (Week 2) Simple Modeling


Wave


Chess (wire on solid)
click to enlarge.

  • Project 1: Download and run WaveJOGL.zip. It shows how one can plot a function of 2 variables. This program loops over an (x,y) grid to calculate the height z = f(x,y) and then plots (x,y,z) (actually, at each iteration, 4 points forming a square are calculated). Your job is to 1) understand the code and 2) replace the function with a different one of your choice (make it interesting!). For 2), you may need to change the range and the viewing angle.

  • Project 2: Model your own scene e.g. a chess set, a car on a road, or crude "human" figure standing or sitting on something. Use a combination of glu objects, glut objects and objects that you make by entering vertices. You may want to use only wireframe or wireframe objects on top of solid since solid objects alone are hard to see without lighting. Later on in the course, after we have talked about lighting and shading, you can go back and fill in the shapes. If it isn't already there, you will probably need to add

    gl.glEnable(GL.GL_DEPTH_TEST);
    to the init method.

Part 2 Deliverables: By classtime on Oct 9, place your jar files for both projects on enfuzion in the lab2/part2 folder. Make sure they run properly. Email the entire project to gorr (please first delete all of the dist folders in your project!). You will be evaluated based on the readability of your code and the complexity of your scene.


Part 3 (Weeks 3) Scene Graphs


A high-strung robotic arm.

In class we saw how to create and implement the scene graph for a simple solar system and a robotic arm. In this part of the lab, you are to model an object of your choice. It should be built of multiple components and have only a few moveable parts. It's movement should be hierarchical. For example, the top of the robot arm automatically moves when the middle part or the arm moves. The object you create might be a simple humanoid with moving legs, a car with moving wheels and a door that opens, or a helicoptor that can move forward/backwards and has moving rotors. Once you decide on your object, do the following:

  • Draw a rough picture of the object, labeling the size and location of all components as well as all angles or directions where movement will take place. Make sure the hierarchy is clear.
  • Using your picture as a reference, draw a scene graph being careful to include all shapes and transformations.
  • Based on the scene graph, implement the object in OpenGL. User controls may be implemented either through buttons or key presses. It is important to keep your code clean. Use the robotic arm code as an example of how to organize your code. Include enough comments in your code so that someone reading it can understand what it is doing.

Part 3 Deliverables: By classtime on Oct 16, Place your jar file on enfuzion in the lab2/part3 folder. Email the entire project to gorr (please delete all of the dist folders!). You will be evaluated based on the organization of your scene graph and the complexity of what you create.


Evaluation


[top]  [Schedule]  [Home]