The lab for this week is to take a program that uses glBegin/glEnd and to convert it to use glDrawArrays or glDrawElements instead. (You have your choice; there is no extra credit or penalty for using one rather than the other.) For extra credit, your program can use vertex buffer objects when the OpenGL version is 1.5 or higher.
The starting point for your work is the package graph3d, which is a self-contained Jogl program. You can find the graph3d folder in the directory /classes/s10/cs424. Add it to an OpenGL project in Eclipse. The program is the file Grapher.java. When you run the program, you can use it to graph a function z = f(x,y), which you can type in. The default function looks like a ripple. The definition of the function can include parameters a and b, and the values of these parameters can be controlled using sliders at the bottom of the window. The program is not meant to be full-featured. There is no way to control the xy-values for which the function is graphed; they always go from -5 to 5. The range of possible values for a and b is -2 to 2, and there is no way to change it.
The methods drawSurface and drawLinesOnSurface are where the surface and the grid lines are drawn. You should remove all use of glBegin/glEnd from these methods. You will want to write separate code for creating the surface data, and possibly put it in a method such as createSurfaceData. You should not create the data every time the surface is drawn; it only has to be created when the function or the parameter values (of a and b) change. A good way to manage this is to use "lazy" data creation. Use a flag to tell whether the data is valid. Set the flag to false when the function or parameter values change. In the drawing methods, test the flag to see whether the data needs to be created.
There are several ways to organize the data; we will talk a little about the possibilities in class on Monday. The sample programs VertexArrayDemo.java and IcosphereIFS.java might be helpful. The material in Section 3.4 is essential for this lab.
The program uses a class Expr2 to represent expressions. You don't have to understand this class, except how to use it to evaluate the expressions. The program also uses the TrackBall and Camera classes, but I have moved them into the graph3d package for convenience in this program.
Note: Your program can continue to use glBegin/glEnd to draw the axes.
Here is an applet version of the program (still using glBegin/glEnd). You might find it rather sluggish (except on a very fast machine):