/** * Manage shapes for my Toy JOGL programs. * Deals with shape menu and rendering the shapes. */ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.media.opengl.*; import javax.media.opengl.glu.*; import com.sun.opengl.util.*; public class ShapeManager { String[] shapeNames = {"Teapot","Torus","Cube","Cone","Dodecahedron","Xwing","Sphere", "Tree","Function","Terrain","Bezier Patch","Revolution","CSE Logo"}; String curShape = shapeNames[0]; JMenu shape; public ShapeManager(){ shape = new JMenu("Shape"); for (int i = 0; i < shapeNames.length; i++){ JMenuItem mi = new JMenuItem(shapeNames[i]); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { curShape = e.getActionCommand(); } }); shape.add(mi); } } public JMenu getMenu() { return shape; } public void display(GL gl, int level, boolean useWireframe){ GLU glu = new GLU(); GLUquadric qobj = glu.gluNewQuadric(); glu.gluQuadricDrawStyle(qobj, GLU.GLU_FILL); glu.gluQuadricTexture(qobj, true); GLUT glut = new GLUT(); //# of slices for spheres and the like based on level int slices = 4* (1<