diff options
63 files changed, 2238 insertions, 1748 deletions
diff --git a/src/demos/applets/GearsApplet.java b/src/demos/applets/GearsApplet.java index 15ea9c7..bc65d74 100755 --- a/src/demos/applets/GearsApplet.java +++ b/src/demos/applets/GearsApplet.java @@ -2,11 +2,10 @@ package demos.applets; import java.applet.*; import java.awt.*; -import java.io.*; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; import demos.gears.Gears; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.Animator; +import javax.media.opengl.util.FPSAnimator; /** Shows how to deploy an applet using JOGL. This demo must be referenced from a web page via an <applet> tag. */ diff --git a/src/demos/applets/GearsJOALApplet.java b/src/demos/applets/GearsJOALApplet.java index e33733a..9a1db8a 100755 --- a/src/demos/applets/GearsJOALApplet.java +++ b/src/demos/applets/GearsJOALApplet.java @@ -1,15 +1,15 @@ package demos.applets; -import java.applet.*; -import java.awt.*; -import java.io.*; -import javax.swing.*; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; import demos.gears.Gears; -import demos.devmaster.lesson1.*; -import net.java.games.joal.util.*; +import java.applet.Applet; +import java.awt.EventQueue; +import java.awt.GridLayout; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.Animator; +import javax.media.opengl.util.FPSAnimator; +import javax.swing.JPanel; + + /** Shows how to deploy an applet using both JOGL and JOAL. This demo must be referenced from a web page via an <applet> tag. */ diff --git a/src/demos/cg/runtime_ogl/cgGL_vertex_example.java b/src/demos/cg/runtime_ogl/cgGL_vertex_example.java index f85e26c..2324e0e 100644 --- a/src/demos/cg/runtime_ogl/cgGL_vertex_example.java +++ b/src/demos/cg/runtime_ogl/cgGL_vertex_example.java @@ -284,6 +284,6 @@ public class cgGL_vertex_example implements GLEventListener }).start(); } }); - frame.show(); + frame.setVisible(true); } } diff --git a/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java b/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java index afafd6f..da23072 100644 --- a/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java +++ b/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java @@ -88,7 +88,7 @@ public class runtime_ogl_vertex_fragment implements GLEventListener }).start(); } }); - frame.show(); + frame.setVisible(true); animator.start(); // and all the rest happens in the display function... diff --git a/src/demos/context/DualContext.java b/src/demos/context/DualContext.java index ae7865f..8e23f1b 100755 --- a/src/demos/context/DualContext.java +++ b/src/demos/context/DualContext.java @@ -39,13 +39,24 @@ package demos.context; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; +import com.sun.opengl.util.glut.gl2.GLUTgl2; +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.Graphics; +import java.awt.GraphicsConfiguration; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.awt.AWTGraphicsConfiguration; +import javax.media.opengl.glu.GLU; +import javax.swing.JButton; +import javax.swing.JFrame; + -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; /** This demo illustrates the use of the GLDrawable and GLContext APIs to create two OpenGL contexts for the same Canvas. The red and @@ -58,7 +69,7 @@ public class DualContext extends Canvas { private GLContext context1; private GLContext context2; private GLU glu; - private GLUT glut; + private GLUTgl2 glut; private int repaintNum; public DualContext(GLCapabilities capabilities) { diff --git a/src/demos/cubefbo/Main.java b/src/demos/cubefbo/Main.java index bb2d479..b1db392 100755 --- a/src/demos/cubefbo/Main.java +++ b/src/demos/cubefbo/Main.java @@ -33,12 +33,14 @@ package demos.cubefbo; -import javax.media.opengl.*; -import com.sun.opengl.util.*; -import java.nio.*; -import java.awt.*; -import java.awt.event.*; -import java.applet.*; +import java.awt.Frame; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.Animator; +import javax.media.opengl.util.FPSAnimator; + public class Main { @@ -87,7 +89,7 @@ public class Main } }); - frame.show(); + frame.setVisible(true); animator.start(); } } diff --git a/src/demos/fullscreen/GearsFullscreen.java b/src/demos/fullscreen/GearsFullscreen.java index f71dd77..5e574be 100755 --- a/src/demos/fullscreen/GearsFullscreen.java +++ b/src/demos/fullscreen/GearsFullscreen.java @@ -3,10 +3,10 @@ package demos.fullscreen; import java.awt.*; import java.awt.event.*; -import javax.media.opengl.*; -import com.sun.opengl.util.*; import demos.gears.Gears; import demos.util.*; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.Animator; /** * GearsFullscreen.java <BR> diff --git a/src/demos/fullscreen/GearsFullscreen2.java b/src/demos/fullscreen/GearsFullscreen2.java index eea7869..9b08cba 100755 --- a/src/demos/fullscreen/GearsFullscreen2.java +++ b/src/demos/fullscreen/GearsFullscreen2.java @@ -1,13 +1,21 @@ package demos.fullscreen; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; import demos.gears.Gears; -import demos.util.*; +import demos.util.ScreenResSelector; +import java.awt.BorderLayout; +import java.awt.DisplayMode; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.Animator; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.ToolTipManager; + /** * GearsFullscreen2.java <BR> diff --git a/src/demos/fullscreen/JGearsFullscreen.java b/src/demos/fullscreen/JGearsFullscreen.java index 465c566..d9d1134 100755 --- a/src/demos/fullscreen/JGearsFullscreen.java +++ b/src/demos/fullscreen/JGearsFullscreen.java @@ -1,13 +1,21 @@ package demos.fullscreen; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; import demos.jgears.JGears; -import demos.util.*; +import demos.util.ScreenResSelector; +import java.awt.BorderLayout; +import java.awt.DisplayMode; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.awt.gl2.GL2JPanel; +import javax.media.opengl.util.Animator; +import javax.swing.JButton; +import javax.swing.JFrame; + + /** * JGearsFullscreen.java <BR> @@ -53,7 +61,7 @@ public class JGearsFullscreen { if (newMode != null) { frame.setUndecorated(true); } - GLJPanel drawable = new JGears(); + JGears drawable = new JGears(); drawable.addGLEventListener(new FullscreenWorkaround(initWidth, initHeight)); frame.getContentPane().setLayout(new BorderLayout()); diff --git a/src/demos/gamma/TestGamma.java b/src/demos/gamma/TestGamma.java index 17fb365..74a63a1 100755 --- a/src/demos/gamma/TestGamma.java +++ b/src/demos/gamma/TestGamma.java @@ -39,13 +39,15 @@ package demos.gamma; -import java.awt.*; -import java.awt.event.*; +import demos.gears.Gears; +import java.awt.Frame; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.Animator; +import javax.media.opengl.util.Gamma; -import javax.media.opengl.*; -import com.sun.opengl.util.*; -import demos.gears.*; public class TestGamma { private static void usage() { @@ -89,7 +91,7 @@ public class TestGamma { }).start(); } }); - frame.show(); + frame.setVisible(true); animator.start(); if (!Gamma.setDisplayGamma(gamma, brightness, contrast)) { diff --git a/src/demos/gears/Gears.java b/src/demos/gears/Gears.java index 4ae780e..c20d183 100644 --- a/src/demos/gears/Gears.java +++ b/src/demos/gears/Gears.java @@ -1,10 +1,19 @@ package demos.gears; -import java.awt.*; -import java.awt.event.*; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.awt.gl2.GL2JPanel; +import javax.media.opengl.util.Animator; /** * Gears.java <BR> @@ -18,7 +27,11 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene Frame frame = new Frame("Gear Demo"); GLCanvas canvas = new GLCanvas(); - canvas.addGLEventListener(new Gears()); + final Gears gears = new Gears(); + canvas.addMouseListener(gears); + canvas.addMouseMotionListener(gears); + canvas.addGLEventListener(gears); + frame.add(canvas); frame.setSize(300, 300); final Animator animator = new Animator(canvas); @@ -35,7 +48,7 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene }).start(); } }); - frame.show(); + frame.setVisible(true); animator.start(); } @@ -50,7 +63,7 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene // Use debug pipeline // drawable.setGL(new DebugGL(drawable.getGL())); - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); System.err.println("INIT GL IS: " + gl.getClass().getName()); @@ -63,50 +76,48 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene float green[] = { 0.0f, 0.8f, 0.2f, 1.0f }; float blue[] = { 0.2f, 0.2f, 1.0f, 1.0f }; - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, pos, 0); - gl.glEnable(GL.GL_CULL_FACE); - gl.glEnable(GL.GL_LIGHTING); - gl.glEnable(GL.GL_LIGHT0); - gl.glEnable(GL.GL_DEPTH_TEST); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0); + gl.glEnable(GL2.GL_CULL_FACE); + gl.glEnable(GL2.GL_LIGHTING); + gl.glEnable(GL2.GL_LIGHT0); + gl.glEnable(GL2.GL_DEPTH_TEST); /* make the gears */ gear1 = gl.glGenLists(1); - gl.glNewList(gear1, GL.GL_COMPILE); - gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, red, 0); + gl.glNewList(gear1, GL2.GL_COMPILE); + gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT_AND_DIFFUSE, red, 0); gear(gl, 1.0f, 4.0f, 1.0f, 20, 0.7f); gl.glEndList(); gear2 = gl.glGenLists(1); - gl.glNewList(gear2, GL.GL_COMPILE); - gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, green, 0); + gl.glNewList(gear2, GL2.GL_COMPILE); + gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT_AND_DIFFUSE, green, 0); gear(gl, 0.5f, 2.0f, 2.0f, 10, 0.7f); gl.glEndList(); gear3 = gl.glGenLists(1); - gl.glNewList(gear3, GL.GL_COMPILE); - gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, blue, 0); + gl.glNewList(gear3, GL2.GL_COMPILE); + gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT_AND_DIFFUSE, blue, 0); gear(gl, 1.3f, 2.0f, 0.5f, 10, 0.7f); gl.glEndList(); - gl.glEnable(GL.GL_NORMALIZE); + gl.glEnable(GL2.GL_NORMALIZE); - drawable.addMouseListener(this); - drawable.addMouseMotionListener(this); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); float h = (float)height / (float)width; - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); - System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); - System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); - System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println("GL_VENDOR: " + gl.glGetString(GL2.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL2.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL2.GL_VERSION)); gl.glLoadIdentity(); gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f, 0.0f, -40.0f); } @@ -116,16 +127,16 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene angle += 2.0f; // Get the GL corresponding to the drawable we are animating - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); // Special handling for the case where the GLJPanel is translucent // and wants to be composited with other Java 2D content - if ((drawable instanceof GLJPanel) && - !((GLJPanel) drawable).isOpaque() && - ((GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { - gl.glClear(GL.GL_DEPTH_BUFFER_BIT); + if ((drawable instanceof GL2JPanel) && + !((GL2JPanel) drawable).isOpaque() && + ((GL2JPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { + gl.glClear(GL2.GL_DEPTH_BUFFER_BIT); } else { - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); } // Rotate the entire assembly of gears based on how the user @@ -163,7 +174,7 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} - public static void gear(GL gl, + public static void gear(GL2 gl, float inner_radius, float outer_radius, float width, @@ -181,12 +192,12 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene da = 2.0f * (float) Math.PI / teeth / 4.0f; - gl.glShadeModel(GL.GL_FLAT); + gl.glShadeModel(GL2.GL_FLAT); gl.glNormal3f(0.0f, 0.0f, 1.0f); /* draw front face */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -201,7 +212,7 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene gl.glEnd(); /* draw front sides of teeth */ - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -213,7 +224,7 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene gl.glEnd(); /* draw back face */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -225,7 +236,7 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene gl.glEnd(); /* draw back sides of teeth */ - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -237,7 +248,7 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene gl.glEnd(); /* draw outward faces of teeth */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -265,10 +276,10 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), -width * 0.5f); gl.glEnd(); - gl.glShadeModel(GL.GL_SMOOTH); + gl.glShadeModel(GL2.GL_SMOOTH); /* draw inside radius cylinder */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; diff --git a/src/demos/hdr/HDR.java b/src/demos/hdr/HDR.java index 5bf64dd..4c6efc6 100755 --- a/src/demos/hdr/HDR.java +++ b/src/demos/hdr/HDR.java @@ -1,19 +1,45 @@ package demos.hdr; -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.nio.*; -import java.util.*; -import javax.swing.*; - -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import demos.common.*; -import demos.util.*; -import gleem.*; -import gleem.linalg.*; +import com.sun.opengl.util.glut.gl2.GLUTgl2; +import demos.common.Demo; +import demos.common.DemoListener; +import demos.util.DurationTimer; +import demos.util.ObjReader; +import demos.util.SystemTime; +import demos.util.Time; +import gleem.BSphere; +import gleem.BSphereProvider; +import gleem.CameraParameters; +import gleem.ExaminerViewer; +import gleem.ManipManager; +import gleem.MouseButtonHelper; +import gleem.linalg.Mat4f; +import gleem.linalg.Rotf; +import gleem.linalg.Vec3f; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import java.io.InputStream; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLPbuffer; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.media.opengl.util.Animator; +import javax.swing.JOptionPane; + /** HDR demo by NVidia Corporation - Simon Green, [email protected] <P> @@ -38,7 +64,7 @@ public class HDR extends Demo { private ObjReader model; private Pipeline pipeline; - private GLUT glut = new GLUT(); + private GLUTgl2 glut = new GLUTgl2(); private boolean[] b = new boolean[256]; @@ -124,7 +150,7 @@ public class HDR extends Demo { frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); canvas.requestFocus(); frame.addWindowListener(new WindowAdapter() { @@ -405,16 +431,16 @@ public class HDR extends Demo { tonemap_pbuffer.display(); // display in window - gl.glEnable(GL.GL_TEXTURE_RECTANGLE_NV); - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glBindTexture(GL.GL_TEXTURE_RECTANGLE_NV, tonemap_pbuffer_tex); + gl.glEnable(GL2.GL_TEXTURE_RECTANGLE); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, tonemap_pbuffer_tex); if (b['n']) { - gl.glTexParameteri( GL.GL_TEXTURE_RECTANGLE_NV, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); + gl.glTexParameteri( GL2.GL_TEXTURE_RECTANGLE, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); } else { - gl.glTexParameteri( GL.GL_TEXTURE_RECTANGLE_NV, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); + gl.glTexParameteri( GL2.GL_TEXTURE_RECTANGLE, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); } drawQuadRect4(gl, win_w, win_h, pbuffer_w, pbuffer_h); - gl.glDisable(GL.GL_TEXTURE_RECTANGLE_NV); + gl.glDisable(GL2.GL_TEXTURE_RECTANGLE); // Try to avoid swamping the CPU on Linux Thread.yield(); @@ -498,13 +524,13 @@ public class HDR extends Demo { gl.glGenTextures(1, tmp, 0); int texid = tmp[0]; - int target = GL.GL_TEXTURE_1D; + int target = GL2.GL_TEXTURE_1D; gl.glBindTexture(target, texid); - gl.glTexParameteri(target, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); - gl.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); - gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE); + gl.glTexParameteri(target, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); + gl.glTexParameteri(target, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); + gl.glTexParameteri(target, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP_TO_EDGE); - gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); + gl.glPixelStorei(GL2.GL_UNPACK_ALIGNMENT, 1); float[] img = new float [size]; @@ -513,7 +539,7 @@ public class HDR extends Demo { img[i] = (float) Math.pow(x, gamma); } - gl.glTexImage1D(target, 0, GL.GL_LUMINANCE, size, 0, GL.GL_LUMINANCE, GL.GL_FLOAT, FloatBuffer.wrap(img)); + gl.glTexImage1D(target, 0, GL2.GL_LUMINANCE, size, 0, GL2.GL_LUMINANCE, GL2.GL_FLOAT, FloatBuffer.wrap(img)); return texid; } @@ -525,13 +551,13 @@ public class HDR extends Demo { gl.glGenTextures(1, tmp, 0); int texid = tmp[0]; - gl.glBindTexture(GL.GL_TEXTURE_RECTANGLE_NV, texid); - gl.glTexParameteri(GL.GL_TEXTURE_RECTANGLE_NV, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); - gl.glTexParameteri(GL.GL_TEXTURE_RECTANGLE_NV, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); - gl.glTexParameteri(GL.GL_TEXTURE_RECTANGLE_NV, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE); - gl.glTexParameteri(GL.GL_TEXTURE_RECTANGLE_NV, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE); + gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE_NV, texid); + gl.glTexParameteri(GL2.GL_TEXTURE_RECTANGLE_NV, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); + gl.glTexParameteri(GL2.GL_TEXTURE_RECTANGLE_NV, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); + gl.glTexParameteri(GL2.GL_TEXTURE_RECTANGLE_NV, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP_TO_EDGE); + gl.glTexParameteri(GL2.GL_TEXTURE_RECTANGLE_NV, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP_TO_EDGE); - gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); + gl.glPixelStorei(GL2.GL_UNPACK_ALIGNMENT, 1); float[] img = new float [xsiz*ysiz]; @@ -553,7 +579,7 @@ public class HDR extends Demo { } } - gl.glTexImage2D(GL.GL_TEXTURE_RECTANGLE_NV, 0, GL.GL_LUMINANCE, xsiz, ysiz, 0, GL.GL_LUMINANCE, GL.GL_FLOAT, FloatBuffer.wrap(img)); + gl.glTexImage2D(GL2.GL_TEXTURE_RECTANGLE_NV, 0, GL2.GL_LUMINANCE, xsiz, ysiz, 0, GL2.GL_LUMINANCE, GL2.GL_FLOAT, FloatBuffer.wrap(img)); return texid; } @@ -569,7 +595,7 @@ public class HDR extends Demo { // drawable.setGL(new DebugGL(drawable.getGL())); GL gl = drawable.getGL(); - gl.glEnable(GL.GL_DEPTH_TEST); + gl.glEnable(GL2.GL_DEPTH_TEST); // FIXME: what about the ExaminerViewer? setPerspectiveProjection(gl, pbuffer_w, pbuffer_h); @@ -582,18 +608,18 @@ public class HDR extends Demo { System.err.println("Creating HILO cubemap"); hdr_tex = hdr.createCubemapHILO(gl, true); hdr_tex2 = hdr.createCubemapHILO(gl, false); - texmode = GL.GL_FLOAT_RGBA16_NV; + texmode = GL2.GL_FLOAT_RGBA16_NV; hilo = true; break; case GLPbuffer.APPLE_FLOAT: System.err.println("Creating FLOAT16_APPLE cubemap"); - hdr_tex = hdr.createCubemap(gl, GL.GL_RGB_FLOAT16_APPLE); - texmode = GL.GL_RGBA_FLOAT16_APPLE; + hdr_tex = hdr.createCubemap(gl, GL2.GL_RGB_FLOAT16_APPLE); + texmode = GL2.GL_RGBA_FLOAT16_APPLE; break; case GLPbuffer.ATI_FLOAT: System.err.println("Creating FLOAT16_ATI cubemap"); - hdr_tex = hdr.createCubemap(gl, GL.GL_RGB_FLOAT16_ATI); - texmode = GL.GL_RGBA_FLOAT16_ATI; + hdr_tex = hdr.createCubemap(gl, GL2.GL_RGB_FLOAT16_ATI); + texmode = GL2.GL_RGBA_FLOAT16_ATI; break; default: throw new RuntimeException("Unexpected floating-point mode " + fpmode); @@ -630,42 +656,42 @@ public class HDR extends Demo { // render scene to float pbuffer private void renderScene(GL gl) { - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); if (doViewAll) { viewer.viewAll(gl); } if (b['w']) - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE); + gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE); else - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL); + gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL); if (b['m']) { - gl.glEnable(GL.GL_MULTISAMPLE); - gl.glHint(GL.GL_MULTISAMPLE_FILTER_HINT_NV, GL.GL_NICEST); + gl.glEnable(GL2.GL_MULTISAMPLE); + gl.glHint(GL2.GL_MULTISAMPLE_FILTER_HINT_NV, GL2.GL_NICEST); } else { - gl.glDisable(GL.GL_MULTISAMPLE); + gl.glDisable(GL2.GL_MULTISAMPLE); } if (!b['e']) { // draw background pipeline.enableFragmentProgram(gl, skybox_fprog); - gl.glDisable(GL.GL_DEPTH_TEST); + gl.glDisable(GL2.GL_DEPTH_TEST); drawSkyBox(gl); - gl.glEnable(GL.GL_DEPTH_TEST); + gl.glEnable(GL2.GL_DEPTH_TEST); } // draw object pipeline.enableVertexProgram(gl, object_vprog); pipeline.enableFragmentProgram(gl, object_fprog); - gl.glMatrixMode(GL.GL_TEXTURE); + gl.glMatrixMode(GL2.GL_TEXTURE); gl.glLoadIdentity(); viewer.update(); viewer.updateInverseRotation(gl); - gl.glMatrixMode( GL.GL_MODELVIEW ); + gl.glMatrixMode( GL2.GL_MODELVIEW ); gl.glLoadIdentity(); CameraParameters params = viewer.getCameraParameters(); Mat4f view = params.getModelviewMatrix(); @@ -684,36 +710,36 @@ public class HDR extends Demo { view.xformPt(eyePos_eye, eyePos_model); pipeline.setVertexProgramParameter3f(gl, eyePos_param, eyePos_model.x(), eyePos_model.y(), eyePos_model.z()); - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glBindTexture(GL.GL_TEXTURE_CUBE_MAP, hdr_tex); - gl.glEnable(GL.GL_TEXTURE_CUBE_MAP); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_CUBE_MAP, hdr_tex); + gl.glEnable(GL2.GL_TEXTURE_CUBE_MAP); boolean linear = b['l']; if (linear) { - gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_LINEAR); - gl.glTexParameteri( GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); + gl.glTexParameteri(GL2.GL_TEXTURE_CUBE_MAP, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR); + gl.glTexParameteri( GL2.GL_TEXTURE_CUBE_MAP, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); } else { - // glTexParameteri( GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST_MIPMAP_NEAREST); - gl.glTexParameteri( GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); - gl.glTexParameteri( GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); + // glTexParameteri( GL2.GL_TEXTURE_CUBE_MAP, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST_MIPMAP_NEAREST); + gl.glTexParameteri( GL2.GL_TEXTURE_CUBE_MAP, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); + gl.glTexParameteri( GL2.GL_TEXTURE_CUBE_MAP, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); } if (hilo) { - gl.glActiveTexture(GL.GL_TEXTURE1); - gl.glBindTexture(GL.GL_TEXTURE_CUBE_MAP, hdr_tex2); - gl.glEnable(GL.GL_TEXTURE_CUBE_MAP); + gl.glActiveTexture(GL2.GL_TEXTURE1); + gl.glBindTexture(GL2.GL_TEXTURE_CUBE_MAP, hdr_tex2); + gl.glEnable(GL2.GL_TEXTURE_CUBE_MAP); if (linear) { - gl.glTexParameteri( GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_LINEAR); - gl.glTexParameteri( GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); + gl.glTexParameteri( GL2.GL_TEXTURE_CUBE_MAP, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR); + gl.glTexParameteri( GL2.GL_TEXTURE_CUBE_MAP, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); } else { - // glTexParameteri( GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST_MIPMAP_NEAREST); - gl.glTexParameteri( GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); - gl.glTexParameteri( GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); + // glTexParameteri( GL2.GL_TEXTURE_CUBE_MAP, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST_MIPMAP_NEAREST); + gl.glTexParameteri( GL2.GL_TEXTURE_CUBE_MAP, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); + gl.glTexParameteri( GL2.GL_TEXTURE_CUBE_MAP, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); } } - gl.glEnable(GL.GL_CULL_FACE); + gl.glEnable(GL2.GL_CULL_FACE); switch(modelno) { case 0: @@ -733,21 +759,21 @@ public class HDR extends Demo { // glut.glutSolidTeapot(gl, 1.0f); break; case 5: - gl.glEnableClientState(GL.GL_VERTEX_ARRAY); - gl.glEnableClientState(GL.GL_NORMAL_ARRAY); - gl.glVertexPointer(3, GL.GL_FLOAT, 0, model.getVertices()); - gl.glNormalPointer(GL.GL_FLOAT, 0, model.getVertexNormals()); + gl.glEnableClientState(GL2.GL_VERTEX_ARRAY); + gl.glEnableClientState(GL2.GL_NORMAL_ARRAY); + gl.glVertexPointer(3, GL2.GL_FLOAT, 0, model.getVertices()); + gl.glNormalPointer(GL2.GL_FLOAT, 0, model.getVertexNormals()); int[] indices = model.getFaceIndices(); - gl.glDrawElements(GL.GL_TRIANGLES, indices.length, GL.GL_UNSIGNED_INT, IntBuffer.wrap(indices)); - gl.glDisableClientState(GL.GL_VERTEX_ARRAY); - gl.glDisableClientState(GL.GL_NORMAL_ARRAY); + gl.glDrawElements(GL2.GL_TRIANGLES, indices.length, GL2.GL_UNSIGNED_INT, IntBuffer.wrap(indices)); + gl.glDisableClientState(GL2.GL_VERTEX_ARRAY); + gl.glDisableClientState(GL2.GL_NORMAL_ARRAY); break; } - gl.glDisable(GL.GL_CULL_FACE); + gl.glDisable(GL2.GL_CULL_FACE); pipeline.disableVertexProgram(gl); pipeline.disableFragmentProgram(gl); - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL); + gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL); } } @@ -771,8 +797,8 @@ public class HDR extends Demo { GL gl = drawable.getGL(); // horizontal blur - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, blurh_fprog); - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glBindProgramARB(GL2.GL_FRAGMENT_PROGRAM_ARB, blurh_fprog); + gl.glActiveTexture(GL2.GL_TEXTURE0); pipeline.bindTexture(gl, blur2_pbuffer_tex); glowPass(gl); @@ -803,20 +829,20 @@ public class HDR extends Demo { GL gl = drawable.getGL(); if (blur2Pass == BLUR2_SHRINK_PASS) { - gl.glClear(GL.GL_COLOR_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT); pipeline.enableFragmentProgram(gl, shrink_fprog); setOrthoProjection(gl, 0, 0, blur_w, blur_h); - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glBindTexture(GL.GL_TEXTURE_RECTANGLE_NV, pbuffer_tex); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE_NV, pbuffer_tex); drawQuadRect2(gl, blur_w, blur_h, pbuffer_w, pbuffer_h); pipeline.disableFragmentProgram(gl); } else if (blur2Pass == BLUR2_VERT_BLUR_PASS) { // vertical blur - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, blurv_fprog); - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glBindProgramARB(GL2.GL_FRAGMENT_PROGRAM_ARB, blurv_fprog); + gl.glActiveTexture(GL2.GL_TEXTURE0); pipeline.bindTexture(gl, blur_pbuffer_tex); glowPass(gl); @@ -859,48 +885,48 @@ public class HDR extends Demo { // private void setOrthoProjection(GL gl, int x, int y, int w, int h) { - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0, w, 0, h, -1.0, 1.0); - gl.glMatrixMode(GL.GL_TEXTURE); + gl.glMatrixMode(GL2.GL_TEXTURE); gl.glLoadIdentity(); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glViewport(x, y, w, h); } private void setPerspectiveProjection(GL gl, int w, int h) { // FIXME: what about ExaminerViewer? - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(60.0, (float) w / (float) h, 0.1, 10.0); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glViewport(0, 0, w, h); } // blur floating point image private void glowPass(GL gl) { - gl.glDisable(GL.GL_DEPTH_TEST); - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glDisable(GL2.GL_DEPTH_TEST); + gl.glEnable(GL2.GL_FRAGMENT_PROGRAM_ARB); setOrthoProjection(gl, 0, 0, blur_w, blur_h); drawQuadRect(gl, blur_w, blur_h); - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glDisable(GL2.GL_FRAGMENT_PROGRAM_ARB); } private void drawQuadRect(GL gl, int w, int h) { - gl.glBegin(GL.GL_QUADS); - gl.glTexCoord2f(0, h); gl.glMultiTexCoord2f(GL.GL_TEXTURE1, 0, h / blur_scale); gl.glVertex3f(0, h, 0); - gl.glTexCoord2f(w, h); gl.glMultiTexCoord2f(GL.GL_TEXTURE1, w / blur_scale, h / blur_scale); gl.glVertex3f(w, h, 0); - gl.glTexCoord2f(w, 0); gl.glMultiTexCoord2f(GL.GL_TEXTURE1, w / blur_scale, 0); gl.glVertex3f(w, 0, 0); - gl.glTexCoord2f(0, 0); gl.glMultiTexCoord2f(GL.GL_TEXTURE1, 0, 0); gl.glVertex3f(0, 0, 0); + gl.glBegin(GL2.GL_QUADS); + gl.glTexCoord2f(0, h); gl.glMultiTexCoord2f(GL2.GL_TEXTURE1, 0, h / blur_scale); gl.glVertex3f(0, h, 0); + gl.glTexCoord2f(w, h); gl.glMultiTexCoord2f(GL2.GL_TEXTURE1, w / blur_scale, h / blur_scale); gl.glVertex3f(w, h, 0); + gl.glTexCoord2f(w, 0); gl.glMultiTexCoord2f(GL2.GL_TEXTURE1, w / blur_scale, 0); gl.glVertex3f(w, 0, 0); + gl.glTexCoord2f(0, 0); gl.glMultiTexCoord2f(GL2.GL_TEXTURE1, 0, 0); gl.glVertex3f(0, 0, 0); gl.glEnd(); } private void drawQuadRect2(GL gl, int w, int h, int tw, int th) { - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); gl.glTexCoord2f(0, th); gl.glVertex3f(0, h, 0); gl.glTexCoord2f(tw, th); gl.glVertex3f(w, h, 0); gl.glTexCoord2f(tw, 0); gl.glVertex3f(w, 0, 0); @@ -910,7 +936,7 @@ public class HDR extends Demo { private void drawQuadRect4(GL gl, int w, int h, int tw, int th) { float offset = 0.5f; - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); gl.glTexCoord2f(offset, th - offset); gl.glVertex3f(0, h, 0); gl.glTexCoord2f(tw - offset, th - offset); gl.glVertex3f(w, h, 0); gl.glTexCoord2f(tw - offset, offset); gl.glVertex3f(w, 0, 0); @@ -919,65 +945,65 @@ public class HDR extends Demo { } private void disableTexGen(GL gl) { - gl.glDisable(GL.GL_TEXTURE_GEN_S); - gl.glDisable(GL.GL_TEXTURE_GEN_T); - gl.glDisable(GL.GL_TEXTURE_GEN_R); + gl.glDisable(GL2.GL_TEXTURE_GEN_S); + gl.glDisable(GL2.GL_TEXTURE_GEN_T); + gl.glDisable(GL2.GL_TEXTURE_GEN_R); } private void enableTexGen(GL gl) { - gl.glEnable(GL.GL_TEXTURE_GEN_S); - gl.glEnable(GL.GL_TEXTURE_GEN_T); - gl.glEnable(GL.GL_TEXTURE_GEN_R); + gl.glEnable(GL2.GL_TEXTURE_GEN_S); + gl.glEnable(GL2.GL_TEXTURE_GEN_T); + gl.glEnable(GL2.GL_TEXTURE_GEN_R); } // draw cubemap background private void drawSkyBox(GL gl) { - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glBindTexture(GL.GL_TEXTURE_CUBE_MAP, hdr_tex); - gl.glEnable(GL.GL_TEXTURE_CUBE_MAP); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_CUBE_MAP, hdr_tex); + gl.glEnable(GL2.GL_TEXTURE_CUBE_MAP); if (hilo) { - gl.glActiveTexture(GL.GL_TEXTURE1); - gl.glBindTexture(GL.GL_TEXTURE_CUBE_MAP, hdr_tex2); - gl.glEnable(GL.GL_TEXTURE_CUBE_MAP); + gl.glActiveTexture(GL2.GL_TEXTURE1); + gl.glBindTexture(GL2.GL_TEXTURE_CUBE_MAP, hdr_tex2); + gl.glEnable(GL2.GL_TEXTURE_CUBE_MAP); } // initialize object linear texgen - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); float[] s_plane = { 1.0f, 0.0f, 0.0f, 0.0f }; float[] t_plane = { 0.0f, 1.0f, 0.0f, 0.0f }; float[] r_plane = { 0.0f, 0.0f, 1.0f, 0.0f }; - gl.glTexGenfv(GL.GL_S, GL.GL_OBJECT_PLANE, s_plane, 0); - gl.glTexGenfv(GL.GL_T, GL.GL_OBJECT_PLANE, t_plane, 0); - gl.glTexGenfv(GL.GL_R, GL.GL_OBJECT_PLANE, r_plane, 0); + gl.glTexGenfv(GL2.GL_S, GL2.GL_OBJECT_PLANE, s_plane, 0); + gl.glTexGenfv(GL2.GL_T, GL2.GL_OBJECT_PLANE, t_plane, 0); + gl.glTexGenfv(GL2.GL_R, GL2.GL_OBJECT_PLANE, r_plane, 0); gl.glPopMatrix(); - gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_OBJECT_LINEAR); - gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_OBJECT_LINEAR); - gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_OBJECT_LINEAR); + gl.glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + gl.glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + gl.glTexGeni(GL2.GL_R, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); enableTexGen(gl); - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); - gl.glMatrixMode(GL.GL_TEXTURE); + gl.glMatrixMode(GL2.GL_TEXTURE); gl.glPushMatrix(); gl.glLoadIdentity(); viewer.updateInverseRotation(gl); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glScalef(10.0f, 10.0f, 10.0f); glut.glutSolidCube(1.0f); gl.glPopMatrix(); - gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); + gl.glDisable(GL2.GL_TEXTURE_CUBE_MAP); - gl.glMatrixMode(GL.GL_TEXTURE); + gl.glMatrixMode(GL2.GL_TEXTURE); gl.glPopMatrix(); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); disableTexGen(gl); } @@ -986,18 +1012,18 @@ public class HDR extends Demo { private void toneMappingPass(GL gl) { gl.glFinish(); - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glBindTexture(GL.GL_TEXTURE_RECTANGLE_NV, pbuffer_tex); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE_NV, pbuffer_tex); - gl.glActiveTexture(GL.GL_TEXTURE1); + gl.glActiveTexture(GL2.GL_TEXTURE1); if (blur2_pbuffer != null) { - gl.glBindTexture(GL.GL_TEXTURE_RECTANGLE_NV, blur2_pbuffer_tex); + gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE_NV, blur2_pbuffer_tex); } - gl.glActiveTexture(GL.GL_TEXTURE2); - gl.glBindTexture(GL.GL_TEXTURE_1D, gamma_tex); + gl.glActiveTexture(GL2.GL_TEXTURE2); + gl.glBindTexture(GL2.GL_TEXTURE_1D, gamma_tex); - gl.glActiveTexture(GL.GL_TEXTURE3); + gl.glActiveTexture(GL2.GL_TEXTURE3); pipeline.bindTexture(gl, vignette_tex); pipeline.enableFragmentProgram(gl, tonemap_fprog); @@ -1087,11 +1113,11 @@ public class HDR extends Demo { private void initBlurCode(GL gl, int blurWidth) { // generate blur code String blurCode = generateBlurCodeFP2(blurWidth, false); - blurh_fprog = loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, blurCode); + blurh_fprog = loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM_ARB, blurCode); // printf("%s\n", blurCode); blurCode = generateBlurCodeFP2(blurWidth, true); - blurv_fprog = loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, blurCode); + blurv_fprog = loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM_ARB, blurCode); // printf("%s\n", blurCode); } @@ -1102,18 +1128,18 @@ public class HDR extends Demo { prog_id = tmp[0]; gl.glBindProgramARB(target, prog_id); int size = code.length(); - gl.glProgramStringARB(target, GL.GL_PROGRAM_FORMAT_ASCII_ARB, code.length(), code); + gl.glProgramStringARB(target, GL2.GL_PROGRAM_FORMAT_ASCII_ARB, code.length(), code); int[] errPos = new int[1]; - gl.glGetIntegerv(GL.GL_PROGRAM_ERROR_POSITION_ARB, errPos, 0); + gl.glGetIntegerv(GL2.GL_PROGRAM_ERROR_POSITION_ARB, errPos, 0); if (errPos[0] >= 0) { String kind = "Program"; - if (target == GL.GL_VERTEX_PROGRAM_ARB) { + if (target == GL2.GL_VERTEX_PROGRAM_ARB) { kind = "Vertex program"; - } else if (target == GL.GL_FRAGMENT_PROGRAM_ARB) { + } else if (target == GL2.GL_FRAGMENT_PROGRAM_ARB) { kind = "Fragment program"; } System.out.println(kind + " failed to load:"); - String errMsg = gl.glGetString(GL.GL_PROGRAM_ERROR_STRING_ARB); + String errMsg = gl.glGetString(GL2.GL_PROGRAM_ERROR_STRING_ARB); if (errMsg == null) { System.out.println("[No error message available]"); } else { @@ -1127,10 +1153,10 @@ public class HDR extends Demo { System.out.println(code.substring(errPos[0], endPos)); throw new GLException("Error loading " + kind); } else { - if (target == GL.GL_FRAGMENT_PROGRAM_ARB) { + if (target == GL2.GL_FRAGMENT_PROGRAM_ARB) { int[] isNative = new int[1]; - gl.glGetProgramivARB(GL.GL_FRAGMENT_PROGRAM_ARB, - GL.GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, + gl.glGetProgramivARB(GL2.GL_FRAGMENT_PROGRAM_ARB, + GL2.GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, isNative, 0); if (isNative[0] != 1) { System.out.println("WARNING: fragment program is over native resource limits"); diff --git a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java index 50ff3e4..fddef16 100644 --- a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java +++ b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java @@ -33,23 +33,41 @@ package demos.hwShadowmapsSimple; -import java.awt.*; -import java.awt.event.*; -import java.awt.image.*; -import java.io.*; -import java.nio.*; -import java.util.*; -import javax.imageio.*; -import javax.swing.*; - -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.texture.*; -import demos.common.*; -import demos.util.*; -import gleem.*; -import gleem.linalg.*; +import com.sun.opengl.util.glut.gl2.GLUTgl2; +import com.sun.opengl.util.texture.Texture; +import com.sun.opengl.util.texture.TextureIO; +import demos.common.Demo; +import demos.common.DemoListener; +import gleem.BSphere; +import gleem.BSphereProvider; +import gleem.CameraParameters; +import gleem.ExaminerViewer; +import gleem.HandleBoxManip; +import gleem.ManipManager; +import gleem.MouseButtonHelper; +import gleem.linalg.Mat4f; +import gleem.linalg.Rotf; +import gleem.linalg.Vec3f; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import java.util.ArrayList; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLPbuffer; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.swing.JOptionPane; + /** This demo is a simple illustration of ARB_shadow and ARB_depth_texture. <P> Cass Everitt <BR> @@ -63,9 +81,16 @@ import gleem.linalg.*; public class HWShadowmapsSimple extends Demo { public static void main(String[] args) { final GLCanvas canvas = new GLCanvas(); - HWShadowmapsSimple demo = new HWShadowmapsSimple(); + final HWShadowmapsSimple demo = new HWShadowmapsSimple(); canvas.addGLEventListener(demo); + canvas.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + demo.dispatchKey(e.getKeyChar()); + demo.demoListener.repaint(); + } + }); + demo.setDemoListener(new DemoListener() { public void shutdownDemo() { runExit(); @@ -80,7 +105,7 @@ public class HWShadowmapsSimple extends Demo { canvas.setSize(512, 512); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); canvas.requestFocus(); frame.addWindowListener(new WindowAdapter() { @@ -103,7 +128,7 @@ public class HWShadowmapsSimple extends Demo { private GLPbuffer pbuffer; private GLU glu; - private GLUT glut; + private GLUTgl2 glut; private float[] light_ambient = { 0, 0, 0, 0 }; private float[] light_intensity = { 1, 1, 1, 1 }; @@ -178,9 +203,9 @@ public class HWShadowmapsSimple extends Demo { // Use debug pipeline // drawable.setGL(new DebugGL(drawable.getGL())); - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); glu = new GLU(); - glut = new GLUT(); + glut = new GLUTgl2(); try { checkExtension(gl, "GL_VERSION_1_3"); // For multitexture @@ -199,8 +224,8 @@ public class HWShadowmapsSimple extends Demo { decal = TextureIO.newTexture(getClass().getClassLoader().getResourceAsStream("demos/data/images/decal_image.png"), true, TextureIO.PNG); - decal.setTexParameteri(GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); - decal.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); + decal.setTexParameteri(GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT); + decal.setTexParameteri(GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT); light_image = TextureIO.newTexture(getClass().getClassLoader().getResourceAsStream("demos/data/images/nvlogo_spot.png"), true, TextureIO.PNG); @@ -209,11 +234,11 @@ public class HWShadowmapsSimple extends Demo { } quad = gl.glGenLists(1); - gl.glNewList(quad, GL.GL_COMPILE); + gl.glNewList(quad, GL2.GL_COMPILE); gl.glPushMatrix(); gl.glRotatef(-90, 1, 0, 0); gl.glScalef(4,4,4); - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); gl.glNormal3f(0, 0, 1); gl.glVertex2f(-1, -1); gl.glVertex2f(-1, 1); @@ -224,23 +249,23 @@ public class HWShadowmapsSimple extends Demo { gl.glEndList(); wirecube = gl.glGenLists(1); - gl.glNewList(wirecube, GL.GL_COMPILE); + gl.glNewList(wirecube, GL2.GL_COMPILE); glut.glutWireCube(2); gl.glEndList(); geometry = gl.glGenLists(1); - gl.glNewList(geometry, GL.GL_COMPILE); + gl.glNewList(geometry, GL2.GL_COMPILE); gl.glPushMatrix(); glut.glutSolidTeapot(0.8f); gl.glPopMatrix(); gl.glEndList(); - gl.glEnable(GL.GL_LIGHT0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, light_ambient, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, light_intensity, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, light_intensity, 0); + gl.glEnable(GL2.GL_LIGHT0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, light_ambient, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, light_intensity, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, light_intensity, 0); - gl.glEnable(GL.GL_DEPTH_TEST); + gl.glEnable(GL2.GL_DEPTH_TEST); // init pbuffer GLCapabilities caps = new GLCapabilities(); @@ -293,12 +318,6 @@ public class HWShadowmapsSimple extends Demo { tweaks.add(new Tweak("polygon offset scale", 2.5f, 0.5f)); tweaks.add(new Tweak("polygon offset bias", 10.0f, 1.0f)); - drawable.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - dispatchKey(e.getKeyChar()); - demoListener.repaint(); - } - }); } public void display(GLAutoDrawable drawable) { @@ -330,17 +349,17 @@ public class HWShadowmapsSimple extends Demo { return; } - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); if (doViewAll) { viewer.viewAll(gl); doViewAll = false; // Immediately zap effects - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); // Schedule repaint to clean up first bogus frame demoListener.repaint(); @@ -402,42 +421,42 @@ public class HWShadowmapsSimple extends Demo { // Use debug pipeline // drawable.setGL(new DebugGL(drawable.getGL())); - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); - gl.glEnable(GL.GL_DEPTH_TEST); + gl.glEnable(GL2.GL_DEPTH_TEST); int[] depth_bits = new int[1]; - gl.glGetIntegerv(GL.GL_DEPTH_BITS, depth_bits, 0); + gl.glGetIntegerv(GL2.GL_DEPTH_BITS, depth_bits, 0); - if (depth_bits[0] == 16) depth_format = GL.GL_DEPTH_COMPONENT16_ARB; - else depth_format = GL.GL_DEPTH_COMPONENT24_ARB; + if (depth_bits[0] == 16) depth_format = GL2.GL_DEPTH_COMPONENT16_ARB; + else depth_format = GL2.GL_DEPTH_COMPONENT24_ARB; light_view_depth = genTexture(gl); - gl.glBindTexture(GL.GL_TEXTURE_2D, light_view_depth); - gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, depth_format, TEX_SIZE, TEX_SIZE, 0, - GL.GL_DEPTH_COMPONENT, GL.GL_UNSIGNED_INT, null); + gl.glBindTexture(GL2.GL_TEXTURE_2D, light_view_depth); + gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, depth_format, TEX_SIZE, TEX_SIZE, 0, + GL2.GL_DEPTH_COMPONENT, GL2.GL_UNSIGNED_INT, null); set_light_view_texture_parameters(gl); fullyInitialized = true; } public void display(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glPolygonOffset(((Tweak) tweaks.get(POLYGON_OFFSET_SCALE)).val, ((Tweak) tweaks.get(POLYGON_OFFSET_BIAS)).val); - gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); + gl.glEnable(GL2.GL_POLYGON_OFFSET_FILL); render_scene_from_light_view(gl, drawable, 0, 0); - gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); + gl.glDisable(GL2.GL_POLYGON_OFFSET_FILL); - gl.glBindTexture(GL.GL_TEXTURE_2D, light_view_depth); + gl.glBindTexture(GL2.GL_TEXTURE_2D, light_view_depth); // trying different ways of getting the depth info over - gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, 0, 0, TEX_SIZE, TEX_SIZE); + gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, TEX_SIZE, TEX_SIZE); } // Unused routines @@ -446,13 +465,13 @@ public class HWShadowmapsSimple extends Demo { } private void set_light_view_texture_parameters(GL gl) { - gl.glBindTexture(GL.GL_TEXTURE_2D, light_view_depth); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_COMPARE_MODE_ARB, GL.GL_COMPARE_R_TO_TEXTURE_ARB); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_COMPARE_FUNC_ARB, GL.GL_LEQUAL); + gl.glBindTexture(GL2.GL_TEXTURE_2D, light_view_depth); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP_TO_EDGE); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP_TO_EDGE); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_COMPARE_MODE, GL2.GL_COMPARE_R_TO_TEXTURE); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_COMPARE_FUNC, GL2.GL_LEQUAL); } private int genTexture(GL gl) { @@ -461,30 +480,30 @@ public class HWShadowmapsSimple extends Demo { return tmp[0]; } - private void eye_linear_texgen(GL gl) { + private void eye_linear_texgen(GL2 gl) { Mat4f m = new Mat4f(); m.makeIdent(); - set_texgen_planes(gl, GL.GL_EYE_PLANE, m); - gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_EYE_LINEAR); - gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_EYE_LINEAR); - gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_EYE_LINEAR); - gl.glTexGeni(GL.GL_Q, GL.GL_TEXTURE_GEN_MODE, GL.GL_EYE_LINEAR); + set_texgen_planes(gl, GL2.GL_EYE_PLANE, m); + gl.glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); + gl.glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); + gl.glTexGeni(GL2.GL_R, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); + gl.glTexGeni(GL2.GL_Q, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_EYE_LINEAR); } - private void obj_linear_texgen(GL gl) { + private void obj_linear_texgen(GL2 gl) { Mat4f m = new Mat4f(); m.makeIdent(); - set_texgen_planes(gl, GL.GL_OBJECT_PLANE, m); - gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_OBJECT_LINEAR); - gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_OBJECT_LINEAR); - gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_OBJECT_LINEAR); - gl.glTexGeni(GL.GL_Q, GL.GL_TEXTURE_GEN_MODE, GL.GL_OBJECT_LINEAR); + set_texgen_planes(gl, GL2.GL_OBJECT_PLANE, m); + gl.glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + gl.glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + gl.glTexGeni(GL2.GL_R, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); + gl.glTexGeni(GL2.GL_Q, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR); } - private void set_texgen_planes(GL gl, int plane_type, Mat4f m) { - int[] coord = {GL.GL_S, GL.GL_T, GL.GL_R, GL.GL_Q}; + private void set_texgen_planes(GL2 gl, int plane_type, Mat4f m) { + int[] coord = {GL2.GL_S, GL2.GL_T, GL2.GL_R, GL2.GL_Q}; float[] row = new float[4]; for(int i = 0; i < 4; i++) { getRow(m, i, row); @@ -494,54 +513,54 @@ public class HWShadowmapsSimple extends Demo { private void texgen(GL gl, boolean enable) { if(enable) { - gl.glEnable(GL.GL_TEXTURE_GEN_S); - gl.glEnable(GL.GL_TEXTURE_GEN_T); - gl.glEnable(GL.GL_TEXTURE_GEN_R); - gl.glEnable(GL.GL_TEXTURE_GEN_Q); + gl.glEnable(GL2.GL_TEXTURE_GEN_S); + gl.glEnable(GL2.GL_TEXTURE_GEN_T); + gl.glEnable(GL2.GL_TEXTURE_GEN_R); + gl.glEnable(GL2.GL_TEXTURE_GEN_Q); } else { - gl.glDisable(GL.GL_TEXTURE_GEN_S); - gl.glDisable(GL.GL_TEXTURE_GEN_T); - gl.glDisable(GL.GL_TEXTURE_GEN_R); - gl.glDisable(GL.GL_TEXTURE_GEN_Q); + gl.glDisable(GL2.GL_TEXTURE_GEN_S); + gl.glDisable(GL2.GL_TEXTURE_GEN_T); + gl.glDisable(GL2.GL_TEXTURE_GEN_R); + gl.glDisable(GL2.GL_TEXTURE_GEN_Q); } } - private void render_light_frustum(GL gl) { + private void render_light_frustum(GL2 gl) { gl.glPushMatrix(); applyTransform(gl, cameraInverseTransform); applyTransform(gl, spotlightTransform); applyTransform(gl, perspectiveInverse(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar)); - gl.glDisable(GL.GL_LIGHTING); + gl.glDisable(GL2.GL_LIGHTING); gl.glColor3f(1,1,0); gl.glCallList(wirecube); gl.glColor3f(1,1,1); - gl.glEnable(GL.GL_LIGHTING); + gl.glEnable(GL2.GL_LIGHTING); gl.glPopMatrix(); } - private void render_quad(GL gl) { - gl.glActiveTexture(GL.GL_TEXTURE0); + private void render_quad(GL2 gl) { + gl.glActiveTexture(GL2.GL_TEXTURE0); obj_linear_texgen(gl); texgen(gl, true); - gl.glMatrixMode(GL.GL_TEXTURE); + gl.glMatrixMode(GL2.GL_TEXTURE); gl.glLoadIdentity(); gl.glScalef(4,4,1); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); - gl.glDisable(GL.GL_LIGHTING); + gl.glDisable(GL2.GL_LIGHTING); decal.bind(); decal.enable(); gl.glCallList(quad); decal.disable(); - gl.glEnable(GL.GL_LIGHTING); + gl.glEnable(GL2.GL_LIGHTING); texgen(gl, false); - gl.glMatrixMode(GL.GL_TEXTURE); + gl.glMatrixMode(GL2.GL_TEXTURE); gl.glLoadIdentity(); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); } - private void render_scene(GL gl, Mat4f view, GLAutoDrawable drawable, CameraParameters params) { + private void render_scene(GL2 gl, Mat4f view, GLAutoDrawable drawable, CameraParameters params) { gl.glColor3f(1,1,1); gl.glPushMatrix(); Mat4f inverseView = new Mat4f(view); @@ -553,16 +572,16 @@ public class HWShadowmapsSimple extends Demo { applyTransform(gl, objectTransform); - gl.glEnable(GL.GL_LIGHTING); + gl.glEnable(GL2.GL_LIGHTING); gl.glCallList(geometry); - gl.glDisable(GL.GL_LIGHTING); + gl.glDisable(GL2.GL_LIGHTING); gl.glPopMatrix(); gl.glPopMatrix(); } - private void render_manipulators(GL gl, Mat4f view, GLAutoDrawable drawable, CameraParameters params) { + private void render_manipulators(GL2 gl, Mat4f view, GLAutoDrawable drawable, CameraParameters params) { gl.glColor3f(1,1,1); gl.glPushMatrix(); Mat4f inverseView = new Mat4f(view); @@ -577,17 +596,17 @@ public class HWShadowmapsSimple extends Demo { gl.glPopMatrix(); } - private void render_scene_from_camera_view(GL gl, GLAutoDrawable drawable, CameraParameters params) { + private void render_scene_from_camera_view(GL2 gl, GLAutoDrawable drawable, CameraParameters params) { // place light gl.glPushMatrix(); gl.glLoadIdentity(); applyTransform(gl, cameraInverseTransform); applyTransform(gl, spotlightTransform); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, light_pos, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, light_pos, 0); gl.glPopMatrix(); // spot image - gl.glActiveTexture(GL.GL_TEXTURE1); + gl.glActiveTexture(GL2.GL_TEXTURE1); gl.glPushMatrix(); applyTransform(gl, cameraInverseTransform); @@ -595,46 +614,46 @@ public class HWShadowmapsSimple extends Demo { texgen(gl, true); gl.glPopMatrix(); - gl.glMatrixMode(GL.GL_TEXTURE); + gl.glMatrixMode(GL2.GL_TEXTURE); gl.glLoadIdentity(); gl.glTranslatef(.5f, .5f, .5f); gl.glScalef(.5f, -.5f, .5f); glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); applyTransform(gl, spotlightInverseTransform); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); light_image.bind(); light_image.enable(); - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glViewport(viewportX, viewportY, drawable.getWidth(), drawable.getHeight()); applyTransform(gl, cameraPerspective); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); render_scene(gl, cameraTransform, drawable, params); - gl.glActiveTexture(GL.GL_TEXTURE1); + gl.glActiveTexture(GL2.GL_TEXTURE1); light_image.disable(); - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); render_manipulators(gl, cameraTransform, drawable, params); render_light_frustum(gl); } - private void render_scene_from_camera_view_shadowed(GL gl, GLAutoDrawable drawable, CameraParameters params) { + private void render_scene_from_camera_view_shadowed(GL2 gl, GLAutoDrawable drawable, CameraParameters params) { // place light gl.glPushMatrix(); gl.glLoadIdentity(); applyTransform(gl, cameraInverseTransform); applyTransform(gl, spotlightTransform); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, light_pos, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, light_pos, 0); gl.glPopMatrix(); // spot image - gl.glActiveTexture(GL.GL_TEXTURE1); + gl.glActiveTexture(GL2.GL_TEXTURE1); gl.glPushMatrix(); applyTransform(gl, cameraInverseTransform); @@ -642,20 +661,20 @@ public class HWShadowmapsSimple extends Demo { texgen(gl, true); gl.glPopMatrix(); - gl.glMatrixMode(GL.GL_TEXTURE); + gl.glMatrixMode(GL2.GL_TEXTURE); gl.glLoadIdentity(); gl.glTranslatef(.5f, .5f, .5f); gl.glScalef(.5f, -.5f, .5f); glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); applyTransform(gl, spotlightInverseTransform); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); light_image.bind(); light_image.enable(); - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); // depth compare - gl.glActiveTexture(GL.GL_TEXTURE2); + gl.glActiveTexture(GL2.GL_TEXTURE2); gl.glPushMatrix(); applyTransform(gl, cameraInverseTransform); @@ -663,32 +682,32 @@ public class HWShadowmapsSimple extends Demo { texgen(gl, true); gl.glPopMatrix(); - gl.glMatrixMode(GL.GL_TEXTURE); + gl.glMatrixMode(GL2.GL_TEXTURE); gl.glLoadIdentity(); gl.glTranslatef(.5f, .5f, ((Tweak) tweaks.get(R_COORDINATE_SCALE)).val); gl.glScalef(.5f, .5f, ((Tweak) tweaks.get(R_COORDINATE_BIAS)).val); glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); applyTransform(gl, spotlightInverseTransform); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); - gl.glBindTexture(GL.GL_TEXTURE_2D, light_view_depth); - gl.glEnable(GL.GL_TEXTURE_2D); - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE); + gl.glBindTexture(GL2.GL_TEXTURE_2D, light_view_depth); + gl.glEnable(GL2.GL_TEXTURE_2D); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glViewport(viewportX, viewportY, drawable.getWidth(), drawable.getHeight()); applyTransform(gl, cameraPerspective); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); render_scene(gl, cameraTransform, drawable, params); - gl.glActiveTexture(GL.GL_TEXTURE1); + gl.glActiveTexture(GL2.GL_TEXTURE1); light_image.disable(); - gl.glActiveTexture(GL.GL_TEXTURE2); - gl.glDisable(GL.GL_TEXTURE_2D); - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE2); + gl.glDisable(GL2.GL_TEXTURE_2D); + gl.glActiveTexture(GL2.GL_TEXTURE0); render_manipulators(gl, cameraTransform, drawable, params); @@ -703,46 +722,46 @@ public class HWShadowmapsSimple extends Demo { gl.glViewport(viewportX, viewportY, size, size); } - private void render_scene_from_light_view(GL gl, GLAutoDrawable drawable, int viewportX, int viewportY) { + private void render_scene_from_light_view(GL2 gl, GLAutoDrawable drawable, int viewportX, int viewportY) { // place light gl.glPushMatrix(); gl.glLoadIdentity(); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, light_pos, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, light_pos, 0); gl.glPopMatrix(); // spot image - gl.glActiveTexture(GL.GL_TEXTURE1); + gl.glActiveTexture(GL2.GL_TEXTURE1); gl.glPushMatrix(); eye_linear_texgen(gl); texgen(gl, true); gl.glPopMatrix(); - gl.glMatrixMode(GL.GL_TEXTURE); + gl.glMatrixMode(GL2.GL_TEXTURE); gl.glLoadIdentity(); gl.glTranslatef(.5f, .5f, .5f); gl.glScalef(.5f, .5f, .5f); glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); light_image.bind(); light_image.enable(); - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); gl.glViewport(0, 0, TEX_SIZE, TEX_SIZE); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); if (displayMode == RENDER_SCENE_FROM_LIGHT_VIEW) largest_square_power_of_two_viewport(gl, drawable, viewportX, viewportY); render_scene(gl, spotlightTransform, null, null); - gl.glActiveTexture(GL.GL_TEXTURE1); + gl.glActiveTexture(GL2.GL_TEXTURE1); light_image.disable(); - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); } private static void getRow(Mat4f m, int row, float[] out) { diff --git a/src/demos/infiniteShadowVolumes/InfiniteShadowVolumes.java b/src/demos/infiniteShadowVolumes/InfiniteShadowVolumes.java index 364fc0e..4bcef94 100644 --- a/src/demos/infiniteShadowVolumes/InfiniteShadowVolumes.java +++ b/src/demos/infiniteShadowVolumes/InfiniteShadowVolumes.java @@ -33,22 +33,37 @@ package demos.infiniteShadowVolumes; -import java.awt.*; -import java.awt.event.*; -import java.awt.image.*; -import java.io.*; -import java.nio.*; -import java.util.*; -import javax.imageio.*; -import javax.imageio.stream.*; - -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import demos.common.*; -import demos.util.*; -import gleem.*; -import gleem.linalg.*; +import com.sun.opengl.util.glut.gl2.GLUTgl2; +import demos.common.Demo; +import demos.common.DemoListener; +import demos.util.MD2; +import gleem.BSphere; +import gleem.BSphereProvider; +import gleem.CameraParameters; +import gleem.ExaminerViewer; +import gleem.HandleBoxManip; +import gleem.ManipManager; +import gleem.MouseButtonHelper; +import gleem.linalg.Mat4f; +import gleem.linalg.Rotf; +import gleem.linalg.Vec3f; +import gleem.linalg.Vec4f; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import java.nio.FloatBuffer; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; + + /** Infinite shadow volumes are described in the paper @@ -89,7 +104,7 @@ public class InfiniteShadowVolumes extends Demo { canvas.setSize(512, 512); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); canvas.requestFocus(); frame.addWindowListener(new WindowAdapter() { @@ -148,7 +163,7 @@ public class InfiniteShadowVolumes extends Demo { private int curr_view = CAMERA_VIEW; private GLU glu = new GLU(); - private GLUT glut = new GLUT(); + private GLUTgl2 glut = new GLUTgl2(); private GLAutoDrawable drawable; private ExaminerViewer viewer; @@ -177,28 +192,28 @@ public class InfiniteShadowVolumes extends Demo { private boolean toggleWireframe; public void init(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); gl.glClearStencil(128); - //glEnable(GL.GL_DEPTH_CLAMP_NV); - gl.glEnable(GL.GL_DEPTH_TEST); - gl.glDepthFunc(GL.GL_LESS); - gl.glEnable(GL.GL_NORMALIZE); - gl.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_FALSE); + //glEnable(GL2.GL_DEPTH_CLAMP_NV); + gl.glEnable(GL2.GL_DEPTH_TEST); + gl.glDepthFunc(GL2.GL_LESS); + gl.glEnable(GL2.GL_NORMALIZE); + gl.glLightModeli(GL2.GL_LIGHT_MODEL_TWO_SIDE, GL2.GL_FALSE); float[] ambient = new float[] {0.3f, 0.3f, 0.3f, 1}; - gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambient, 0); faceDisplayList = gl.glGenLists(1); - gl.glNewList(faceDisplayList, GL.GL_COMPILE); + gl.glNewList(faceDisplayList, GL2.GL_COMPILE); drawMesh(gl, 20, 40); gl.glEndList(); int[] tmp = new int[1]; gl.glGenTextures(1, tmp, 0); wallTexObject = tmp[0]; - gl.glBindTexture(GL.GL_TEXTURE_2D, wallTexObject); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_GENERATE_MIPMAP_SGIS, GL.GL_TRUE); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_LINEAR); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); + gl.glBindTexture(GL2.GL_TEXTURE_2D, wallTexObject); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_GENERATE_MIPMAP, GL2.GL_TRUE); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); float[] tex = new float[32*32]; for(int i=0; i < 32; i++) { @@ -209,7 +224,7 @@ public class InfiniteShadowVolumes extends Demo { tex[i+j*32] = .9f; } } - gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, 32, 32, 0, GL.GL_LUMINANCE, GL.GL_FLOAT, FloatBuffer.wrap(tex)); + gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_RGBA, 32, 32, 0, GL2.GL_LUMINANCE, GL2.GL_FLOAT, FloatBuffer.wrap(tex)); initModel(); @@ -220,12 +235,13 @@ public class InfiniteShadowVolumes extends Demo { doViewAll = true; - drawable.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { - dispatchKey(e.getKeyChar()); - demoListener.repaint(); - } - }); + //TODO drawable has no addKeyListener +// drawable.addKeyListener(new KeyAdapter() { +// public void keyTyped(KeyEvent e) { +// dispatchKey(e.getKeyChar()); +// demoListener.repaint(); +// } +// }); // Register the window with the ManipManager ManipManager manager = ManipManager.getManipManager(); @@ -300,9 +316,9 @@ public class InfiniteShadowVolumes extends Demo { } public void display(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); if (doViewAll) { @@ -313,14 +329,15 @@ public class InfiniteShadowVolumes extends Demo { objectManipXform = objectManip.getTransform(); lightManipXform = lightManip.getTransform(); - if (toggleDepthClampNV) { - if (enableDepthClampNV) { - gl.glEnable(GL.GL_DEPTH_CLAMP_NV); - } else { - gl.glDisable(GL.GL_DEPTH_CLAMP_NV); - } - toggleDepthClampNV = false; - } + // TODO GL_DEPTH_CLAMP_NV not available +// if (toggleDepthClampNV) { +// if (enableDepthClampNV) { +// gl.glEnable(GL2.GL_DEPTH_CLAMP_NV); +// } else { +// gl.glDisable(GL2.GL_DEPTH_CLAMP_NV); +// } +// toggleDepthClampNV = false; +// } if (b[' ']) { animateForward = true; @@ -345,7 +362,7 @@ public class InfiniteShadowVolumes extends Demo { } if (hideCurrentModel) { - gl.glNewList(faceDisplayList, GL.GL_COMPILE); + gl.glNewList(faceDisplayList, GL2.GL_COMPILE); drawMesh(gl, 20, 40); gl.glEndList(); hideCurrentModel = false; @@ -353,9 +370,9 @@ public class InfiniteShadowVolumes extends Demo { if (toggleWireframe) { if(b['w']) - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE); + gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE); else - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL); + gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL); } if(b['I']) { @@ -364,7 +381,7 @@ public class InfiniteShadowVolumes extends Demo { case CAMERA_VIEW: viewer.update(gl); // Undo perspective effects of ExaminerViewer - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); applyInfinitePerspective(gl, viewer); break; @@ -412,7 +429,7 @@ public class InfiniteShadowVolumes extends Demo { } } - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); // FIXME if (b['X']) { @@ -430,18 +447,18 @@ public class InfiniteShadowVolumes extends Demo { double[] neg_y = new double[] { 0, 1, 0, 1}; double[] pos_z = new double[] { 0, 0,-1, 1}; double[] neg_z = new double[] { 0, 0, 1, 1}; - gl.glClipPlane(GL.GL_CLIP_PLANE0, pos_x, 0); - gl.glClipPlane(GL.GL_CLIP_PLANE1, neg_x, 0); - gl.glClipPlane(GL.GL_CLIP_PLANE2, pos_y, 0); - gl.glClipPlane(GL.GL_CLIP_PLANE3, neg_y, 0); - gl.glClipPlane(GL.GL_CLIP_PLANE4, pos_z, 0); - gl.glClipPlane(GL.GL_CLIP_PLANE5, neg_z, 0); - gl.glEnable(GL.GL_CLIP_PLANE0); - gl.glEnable(GL.GL_CLIP_PLANE1); - gl.glEnable(GL.GL_CLIP_PLANE2); - gl.glEnable(GL.GL_CLIP_PLANE3); - gl.glEnable(GL.GL_CLIP_PLANE4); - gl.glEnable(GL.GL_CLIP_PLANE5); + gl.glClipPlane(GL2.GL_CLIP_PLANE0, pos_x, 0); + gl.glClipPlane(GL2.GL_CLIP_PLANE1, neg_x, 0); + gl.glClipPlane(GL2.GL_CLIP_PLANE2, pos_y, 0); + gl.glClipPlane(GL2.GL_CLIP_PLANE3, neg_y, 0); + gl.glClipPlane(GL2.GL_CLIP_PLANE4, pos_z, 0); + gl.glClipPlane(GL2.GL_CLIP_PLANE5, neg_z, 0); + gl.glEnable(GL2.GL_CLIP_PLANE0); + gl.glEnable(GL2.GL_CLIP_PLANE1); + gl.glEnable(GL2.GL_CLIP_PLANE2); + gl.glEnable(GL2.GL_CLIP_PLANE3); + gl.glEnable(GL2.GL_CLIP_PLANE4); + gl.glEnable(GL2.GL_CLIP_PLANE5); gl.glLoadIdentity(); } @@ -450,16 +467,16 @@ public class InfiniteShadowVolumes extends Demo { // camera.apply_inverse_transform(); // light.apply_transform(); gl.glMultMatrixf(getData(lightManipXform), 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, getData(light_position), 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, getData(light_position), 0); gl.glPopMatrix(); - gl.glEnable(GL.GL_LIGHT0); + gl.glEnable(GL2.GL_LIGHT0); // FIXME gl.glPushMatrix(); // gl.glLoadIdentity(); // camera.apply_inverse_transform(); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT | GL2.GL_STENCIL_BUFFER_BIT); ManipManager.getManipManager().updateCameraParameters(drawable, viewer.getCameraParameters()); ManipManager.getManipManager().render(drawable, gl); @@ -475,12 +492,12 @@ public class InfiniteShadowVolumes extends Demo { } if (b['X']) { - gl.glDisable(GL.GL_CLIP_PLANE0); - gl.glDisable(GL.GL_CLIP_PLANE1); - gl.glDisable(GL.GL_CLIP_PLANE2); - gl.glDisable(GL.GL_CLIP_PLANE3); - gl.glDisable(GL.GL_CLIP_PLANE4); - gl.glDisable(GL.GL_CLIP_PLANE5); + gl.glDisable(GL2.GL_CLIP_PLANE0); + gl.glDisable(GL2.GL_CLIP_PLANE1); + gl.glDisable(GL2.GL_CLIP_PLANE2); + gl.glDisable(GL2.GL_CLIP_PLANE3); + gl.glDisable(GL2.GL_CLIP_PLANE4); + gl.glDisable(GL2.GL_CLIP_PLANE5); } if (!b['s']) { @@ -492,12 +509,12 @@ public class InfiniteShadowVolumes extends Demo { // Be aware that this can cause some multipass artifacts // due to invariance issues. if (b['X']) { - gl.glEnable(GL.GL_CLIP_PLANE0); - gl.glEnable(GL.GL_CLIP_PLANE1); - gl.glEnable(GL.GL_CLIP_PLANE2); - gl.glEnable(GL.GL_CLIP_PLANE3); - gl.glEnable(GL.GL_CLIP_PLANE4); - gl.glEnable(GL.GL_CLIP_PLANE5); + gl.glEnable(GL2.GL_CLIP_PLANE0); + gl.glEnable(GL2.GL_CLIP_PLANE1); + gl.glEnable(GL2.GL_CLIP_PLANE2); + gl.glEnable(GL2.GL_CLIP_PLANE3); + gl.glEnable(GL2.GL_CLIP_PLANE4); + gl.glEnable(GL2.GL_CLIP_PLANE5); } if (!b['d']) { if (!b['R']) @@ -523,12 +540,12 @@ public class InfiniteShadowVolumes extends Demo { // Be aware that this can cause some multipass artifacts // due to invariance issues. if (b['X']) { - gl.glDisable(GL.GL_CLIP_PLANE0); - gl.glDisable(GL.GL_CLIP_PLANE1); - gl.glDisable(GL.GL_CLIP_PLANE2); - gl.glDisable(GL.GL_CLIP_PLANE3); - gl.glDisable(GL.GL_CLIP_PLANE4); - gl.glDisable(GL.GL_CLIP_PLANE5); + gl.glDisable(GL2.GL_CLIP_PLANE0); + gl.glDisable(GL2.GL_CLIP_PLANE1); + gl.glDisable(GL2.GL_CLIP_PLANE2); + gl.glDisable(GL2.GL_CLIP_PLANE3); + gl.glDisable(GL2.GL_CLIP_PLANE4); + gl.glDisable(GL2.GL_CLIP_PLANE5); } drawLight(gl); @@ -795,7 +812,7 @@ public class InfiniteShadowVolumes extends Demo { // This routine draws the end caps (both local and infinite) for an // occluder. These caps are required for the zfail approach to work. - private void drawShadowVolumeEndCaps(GL gl, int mindex) { + private void drawShadowVolumeEndCaps(GL2 gl, int mindex) { Vec4f olight = new Vec4f(); Mat4f ml = new Mat4f(objectManipXform); @@ -807,7 +824,7 @@ public class InfiniteShadowVolumes extends Demo { gl.glPushMatrix(); gl.glMultMatrixf(getData(objectManipXform), 0); - gl.glBegin(GL.GL_TRIANGLES); + gl.glBegin(GL2.GL_TRIANGLES); for (int i = 0; i < m[mindex].mod.tri.length; i++) { if (m[mindex].mod.tri[i].kill) continue; @@ -833,38 +850,38 @@ public class InfiniteShadowVolumes extends Demo { gl.glPopMatrix(); } - private void drawModel(GL gl, int mindex, boolean do_diffuse) { + private void drawModel(GL2 gl, int mindex, boolean do_diffuse) { MD2.PositionNormal[] vpn = m[mindex].interp_frame.pn; float[] zero = new float[] { 0, 0, 0, 0}; float[] dim = new float[] {.2f,.2f,.2f,.2f}; float[] diffuse = new float[4]; float[] specular = new float[4]; - gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, getData(m[mindex].ambient), 0); - gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, getData(m[mindex].diffuse), 0); - gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, getData(m[mindex].specular), 0); - gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, m[mindex].shininess); + gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, getData(m[mindex].ambient), 0); + gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, getData(m[mindex].diffuse), 0); + gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, getData(m[mindex].specular), 0); + gl.glMaterialf(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, m[mindex].shininess); if (!do_diffuse) { - gl.glGetLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, dim, 0); - gl.glGetLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, specular, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, zero, 0); + gl.glGetLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuse, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, dim, 0); + gl.glGetLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, specular, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, zero, 0); } else { - gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE); - gl.glEnable(GL.GL_BLEND); - gl.glStencilFunc(GL.GL_EQUAL, 128, ~0); - gl.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP); - gl.glEnable(GL.GL_STENCIL_TEST); - gl.glDepthFunc(GL.GL_EQUAL); + gl.glBlendFunc(GL2.GL_ONE, GL2.GL_ONE); + gl.glEnable(GL2.GL_BLEND); + gl.glStencilFunc(GL2.GL_EQUAL, 128, ~0); + gl.glStencilOp(GL2.GL_KEEP, GL2.GL_KEEP, GL2.GL_KEEP); + gl.glEnable(GL2.GL_STENCIL_TEST); + gl.glDepthFunc(GL2.GL_EQUAL); } gl.glPushMatrix(); gl.glMultMatrixf(getData(objectManipXform), 0); - gl.glEnable(GL.GL_LIGHTING); + gl.glEnable(GL2.GL_LIGHTING); gl.glPolygonOffset(0,-2); - gl.glEnable(GL.GL_POLYGON_OFFSET_FILL); + gl.glEnable(GL2.GL_POLYGON_OFFSET_FILL); - gl.glBegin(GL.GL_TRIANGLES); + gl.glBegin(GL2.GL_TRIANGLES); { for (int i = 0; i < m[mindex].mod.tri.length; i++) { for(int j=0; j < 3; j++) { @@ -876,28 +893,28 @@ public class InfiniteShadowVolumes extends Demo { } gl.glEnd(); - gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); + gl.glDisable(GL2.GL_POLYGON_OFFSET_FILL); - gl.glDisable(GL.GL_LIGHTING); + gl.glDisable(GL2.GL_LIGHTING); gl.glPopMatrix(); - gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, new float[] { 0.8f, 0.8f, 0.8f, 1}, 0); - gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, new float[] { 0.3f, 0.3f, 0.3f, 1}, 0); + gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, new float[] { 0.8f, 0.8f, 0.8f, 1}, 0); + gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, new float[] { 0.3f, 0.3f, 0.3f, 1}, 0); if (!do_diffuse) { - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, specular, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuse, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, specular, 0); } else { - gl.glDisable(GL.GL_BLEND); - //glDisable(GL.GL_STENCIL_TEST); - gl.glStencilFunc(GL.GL_ALWAYS, 128, ~0); - gl.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP); + gl.glDisable(GL2.GL_BLEND); + //glDisable(GL2.GL_STENCIL_TEST); + gl.glStencilFunc(GL2.GL_ALWAYS, 128, ~0); + gl.glStencilOp(GL2.GL_KEEP, GL2.GL_KEEP, GL2.GL_KEEP); - gl.glDepthFunc(GL.GL_LESS); + gl.glDepthFunc(GL2.GL_LESS); } } // This is for drawing the walls of the room. - private void drawMesh(GL gl, float size, int tess) { + private void drawMesh(GL2 gl, float size, int tess) { float hsize = size/2; float delta = size/(tess-1); @@ -909,7 +926,7 @@ public class InfiniteShadowVolumes extends Demo { float x = 0; for(int i=0; i < tess-1; i++) { float y = 0; - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for(int j=0; j < tess; j++) { gl.glTexCoord2f( x, y); gl.glVertex2f ( x, y); @@ -923,9 +940,9 @@ public class InfiniteShadowVolumes extends Demo { gl.glPopMatrix(); } - private void drawCube(GL gl) { - gl.glBindTexture(GL.GL_TEXTURE_2D, wallTexObject); - gl.glEnable(GL.GL_TEXTURE_2D); + private void drawCube(GL2 gl) { + gl.glBindTexture(GL2.GL_TEXTURE_2D, wallTexObject); + gl.glEnable(GL2.GL_TEXTURE_2D); gl.glPushMatrix(); // FIXME // room.apply_transform(); @@ -942,10 +959,10 @@ public class InfiniteShadowVolumes extends Demo { gl.glRotatef(180, 0, 1, 0); gl.glCallList(faceDisplayList); gl.glPopMatrix(); - gl.glDisable(GL.GL_TEXTURE_2D); + gl.glDisable(GL2.GL_TEXTURE_2D); } - private void drawRoom(GL gl, boolean do_diffuse) { + private void drawRoom(GL2 gl, boolean do_diffuse) { float[] zero = new float[] {0,0,0,0}; float[] a = new float[4]; a[0] = room_ambient; @@ -961,53 +978,53 @@ public class InfiniteShadowVolumes extends Demo { float[] diffuse = new float[4]; float[] specular = new float[4]; - gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, a, 0); - gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, new float[] {0.8f, 0.8f, 0.8f, 1}, 0); - gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, new float[] {0.4f, 0.4f, 0.4f, 1}, 0); - gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, 64.0f); + gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, a, 0); + gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, new float[] {0.8f, 0.8f, 0.8f, 1}, 0); + gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, new float[] {0.4f, 0.4f, 0.4f, 1}, 0); + gl.glMaterialf(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 64.0f); if (!do_diffuse) { - gl.glGetLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, d1, 0); - gl.glGetLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, specular, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, zero, 0); - gl.glStencilFunc(GL.GL_ALWAYS, 128, ~0); + gl.glGetLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuse, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, d1, 0); + gl.glGetLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, specular, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, zero, 0); + gl.glStencilFunc(GL2.GL_ALWAYS, 128, ~0); } else { - gl.glGetLightfv(GL.GL_LIGHT0, GL.GL_EMISSION, emission, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_EMISSION, zero, 0); - gl.glGetLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, zero, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, d2, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, s, 0); - - gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE); - gl.glEnable(GL.GL_BLEND); - gl.glStencilFunc(GL.GL_EQUAL, 128, ~0); - gl.glDepthFunc(GL.GL_EQUAL); + gl.glGetLightfv(GL2.GL_LIGHT0, GL2.GL_EMISSION, emission, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_EMISSION, zero, 0); + gl.glGetLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambient, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, zero, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, d2, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, s, 0); + + gl.glBlendFunc(GL2.GL_ONE, GL2.GL_ONE); + gl.glEnable(GL2.GL_BLEND); + gl.glStencilFunc(GL2.GL_EQUAL, 128, ~0); + gl.glDepthFunc(GL2.GL_EQUAL); } gl.glPushMatrix(); gl.glTranslatef(0,9,0); - gl.glEnable(GL.GL_LIGHTING); - gl.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP); - gl.glEnable(GL.GL_STENCIL_TEST); + gl.glEnable(GL2.GL_LIGHTING); + gl.glStencilOp(GL2.GL_KEEP, GL2.GL_KEEP, GL2.GL_KEEP); + gl.glEnable(GL2.GL_STENCIL_TEST); drawCube(gl); - gl.glStencilFunc(GL.GL_ALWAYS, 128, ~0); - gl.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP); + gl.glStencilFunc(GL2.GL_ALWAYS, 128, ~0); + gl.glStencilOp(GL2.GL_KEEP, GL2.GL_KEEP, GL2.GL_KEEP); - gl.glDisable(GL.GL_LIGHTING); + gl.glDisable(GL2.GL_LIGHTING); gl.glPopMatrix(); if (!do_diffuse) { - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, specular, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, diffuse, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, specular, 0); } else { - gl.glLightfv(GL.GL_LIGHT0, GL.GL_EMISSION, emission, 0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_EMISSION, emission, 0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambient, 0); - gl.glDisable(GL.GL_BLEND); - gl.glDepthFunc(GL.GL_LESS); + gl.glDisable(GL2.GL_BLEND); + gl.glDepthFunc(GL2.GL_LESS); } } @@ -1021,7 +1038,7 @@ public class InfiniteShadowVolumes extends Demo { // This routine also doubles as the routine for drawing the local and ininite // silhouette edges (when prim == GL_LINES). - private void drawShadowVolumeEdges(GL gl, + private void drawShadowVolumeEdges(GL2 gl, int mindex, int prim, boolean local, @@ -1076,12 +1093,12 @@ public class InfiniteShadowVolumes extends Demo { MD2.PositionNormal pn0 = f.pn[edge[0]]; MD2.PositionNormal pn1 = f.pn[edge[1]]; - if(prim == GL.GL_QUADS || local) { + if(prim == GL2.GL_QUADS || local) { // local segment gl.glVertex4f(pn0.x, pn0.y, pn0.z, 1); gl.glVertex4f(pn1.x, pn1.y, pn1.z, 1); } - if(prim == GL.GL_QUADS || infinity) { + if(prim == GL2.GL_QUADS || infinity) { // segment projected to infinity gl.glVertex4f(pn1.x*olight.get(3) - olight.get(0), pn1.y*olight.get(3) - olight.get(1), @@ -1097,56 +1114,56 @@ public class InfiniteShadowVolumes extends Demo { gl.glPopMatrix(); } - private void drawShadowVolumeExtrudedEdges(GL gl, int mindex) { - drawShadowVolumeEdges(gl, mindex, GL.GL_QUADS, true, true); + private void drawShadowVolumeExtrudedEdges(GL2 gl, int mindex) { + drawShadowVolumeEdges(gl, mindex, GL2.GL_QUADS, true, true); } - private void drawPossibleSilhouette(GL gl, int mindex) { + private void drawPossibleSilhouette(GL2 gl, int mindex) { gl.glLineWidth(3); gl.glColor3f(1,1,1); - drawShadowVolumeEdges(gl, mindex, GL.GL_LINES, true, !b['-']); + drawShadowVolumeEdges(gl, mindex, GL2.GL_LINES, true, !b['-']); gl.glLineWidth(1); } // Draw the shadow volume into the stencil buffer. - private void drawShadowVolumeToStencil(GL gl, int mindex) { - gl.glDepthFunc(GL.GL_LESS); + private void drawShadowVolumeToStencil(GL2 gl, int mindex) { + gl.glDepthFunc(GL2.GL_LESS); gl.glDepthMask(false); - gl.glStencilFunc(GL.GL_ALWAYS, 128, ~0); - gl.glEnable(GL.GL_STENCIL_TEST); + gl.glStencilFunc(GL2.GL_ALWAYS, 128, ~0); + gl.glEnable(GL2.GL_STENCIL_TEST); - gl.glEnable(GL.GL_CULL_FACE); - gl.glCullFace(GL.GL_FRONT); - gl.glStencilOp(GL.GL_KEEP, GL.GL_INCR, GL.GL_KEEP); + gl.glEnable(GL2.GL_CULL_FACE); + gl.glCullFace(GL2.GL_FRONT); + gl.glStencilOp(GL2.GL_KEEP, GL2.GL_INCR, GL2.GL_KEEP); gl.glColorMask(false, false, false, false); drawShadowVolumeExtrudedEdges(gl, mindex); drawShadowVolumeEndCaps(gl, mindex); - gl.glCullFace(GL.GL_BACK); - gl.glStencilOp(GL.GL_KEEP, GL.GL_DECR, GL.GL_KEEP); + gl.glCullFace(GL2.GL_BACK); + gl.glStencilOp(GL2.GL_KEEP, GL2.GL_DECR, GL2.GL_KEEP); drawShadowVolumeExtrudedEdges(gl, mindex); drawShadowVolumeEndCaps(gl, mindex); gl.glColorMask(true, true, true, true); - gl.glDisable(GL.GL_CULL_FACE); + gl.glDisable(GL2.GL_CULL_FACE); - gl.glStencilFunc(GL.GL_ALWAYS, 128, ~0); - gl.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP); + gl.glStencilFunc(GL2.GL_ALWAYS, 128, ~0); + gl.glStencilOp(GL2.GL_KEEP, GL2.GL_KEEP, GL2.GL_KEEP); gl.glDepthMask(true); - gl.glDepthFunc(GL.GL_LESS); + gl.glDepthFunc(GL2.GL_LESS); } // Draw the shadow volume into the color buffer. - private void drawShadowVolumeToColor(GL gl, int mindex) { - gl.glDepthFunc(GL.GL_LESS); + private void drawShadowVolumeToColor(GL2 gl, int mindex) { + gl.glDepthFunc(GL2.GL_LESS); gl.glDepthMask(false); - gl.glEnable(GL.GL_BLEND); - gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); + gl.glEnable(GL2.GL_BLEND); + gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA); gl.glColor4f(1,1,1,.7f * volume_alpha); drawShadowVolumeEndCaps(gl, mindex); @@ -1154,13 +1171,13 @@ public class InfiniteShadowVolumes extends Demo { drawShadowVolumeExtrudedEdges(gl, mindex); gl.glDepthMask(true); - gl.glDepthFunc(GL.GL_LESS); - gl.glDisable(GL.GL_BLEND); + gl.glDepthFunc(GL2.GL_LESS); + gl.glDisable(GL2.GL_BLEND); } // Draw an icon to show where the local light is // or in what direction the infinite light is pointing. - private void drawLight(GL gl) { + private void drawLight(GL2 gl) { gl.glColor3f(1,1,0); gl.glPushMatrix(); gl.glMultMatrixf(getData(lightManipXform), 0); diff --git a/src/demos/j2d/CustomText.java b/src/demos/j2d/CustomText.java index aba7b97..031dfa3 100755 --- a/src/demos/j2d/CustomText.java +++ b/src/demos/j2d/CustomText.java @@ -39,6 +39,14 @@ package demos.j2d; +import com.sun.opengl.util.texture.Texture; +import com.sun.opengl.util.texture.TextureCoords; +import com.sun.opengl.util.texture.TextureIO; +import demos.common.Demo; +import demos.util.FPSCounter; +import demos.util.SystemTime; +import demos.util.Time; +import gleem.linalg.Vec2f; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; @@ -47,24 +55,29 @@ import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.GraphicsEnvironment; -import java.awt.event.*; -import java.awt.geom.*; -import java.awt.font.*; -import java.awt.image.*; -import java.text.*; -import java.util.*; -import javax.swing.*; -import javax.swing.event.*; - -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.j2d.*; -import com.sun.opengl.util.texture.*; - -import demos.common.*; -import demos.util.*; -import gleem.linalg.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.media.opengl.util.Animator; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import sun.java2d.pipe.TextRenderer; + /** Illustrates more advanced use of the TextRenderer class; shows how to do text filled with a linear Java 2D gradient. */ @@ -101,7 +114,7 @@ public class CustomText extends Demo { }).start(); } }); - frame.show(); + frame.setVisible(true); animator.start(); } @@ -263,7 +276,7 @@ public class CustomText extends Demo { } } - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); @@ -279,8 +292,8 @@ public class CustomText extends Demo { int h = drawable.getHeight(); float fw = w / 100.0f; float fh = h / 100.0f; - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); - gl.glBegin(GL.GL_QUADS); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); + gl.glBegin(GL2.GL_QUADS); gl.glTexCoord2f(fw * coords.left(), fh * coords.bottom()); gl.glVertex3f(0, 0, 0); gl.glTexCoord2f(fw * coords.right(), fh * coords.bottom()); diff --git a/src/demos/j2d/FlyingText.java b/src/demos/j2d/FlyingText.java index 81deeec..b42d5ce 100755 --- a/src/demos/j2d/FlyingText.java +++ b/src/demos/j2d/FlyingText.java @@ -39,6 +39,14 @@ package demos.j2d; +import com.sun.opengl.util.texture.Texture; +import com.sun.opengl.util.texture.TextureCoords; +import com.sun.opengl.util.texture.TextureIO; +import demos.common.Demo; +import demos.util.FPSCounter; +import demos.util.SystemTime; +import demos.util.Time; +import gleem.linalg.Vec2f; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; @@ -46,22 +54,30 @@ import java.awt.DisplayMode; import java.awt.Font; import java.awt.Graphics2D; import java.awt.GraphicsEnvironment; -import java.awt.event.*; -import java.awt.image.*; -import java.text.*; -import java.util.*; -import javax.swing.*; -import javax.swing.event.*; - -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.j2d.*; -import com.sun.opengl.util.texture.*; - -import demos.common.*; -import demos.util.*; -import gleem.linalg.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.media.opengl.util.Animator; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JSlider; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import sun.java2d.pipe.TextRenderer; + + /** Illustrates more advanced use of the TextRenderer class; shows how to do animated translated and rotated text as well as a drop @@ -99,7 +115,7 @@ public class FlyingText extends Demo { }).start(); } }); - frame.show(); + frame.setVisible(true); animator.start(); } @@ -223,10 +239,10 @@ public class FlyingText extends Demo { g.dispose(); backgroundTexture = TextureIO.newTexture(bgImage, false); backgroundTexture.bind(); - backgroundTexture.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); - backgroundTexture.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); - backgroundTexture.setTexParameteri(GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); - backgroundTexture.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); + backgroundTexture.setTexParameteri(GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); + backgroundTexture.setTexParameteri(GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); + backgroundTexture.setTexParameteri(GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT); + backgroundTexture.setTexParameteri(GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT); // Create the text renderer renderer = new TextRenderer(new Font("Serif", Font.PLAIN, 72), true, true); @@ -253,7 +269,7 @@ public class FlyingText extends Demo { // Set up properties; note we don't need the depth buffer in this demo GL gl = drawable.getGL(); - gl.glDisable(GL.GL_DEPTH_TEST); + gl.glDisable(GL2.GL_DEPTH_TEST); // Turn off vsync if we can gl.setSwapInterval(0); } @@ -311,12 +327,12 @@ public class FlyingText extends Demo { } } - GL gl = drawable.getGL(); - gl.glClear(GL.GL_COLOR_BUFFER_BIT); - gl.glMatrixMode(GL.GL_PROJECTION); + GL2 gl = drawable.getGL().getGL2(); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluOrtho2D(0, drawable.getWidth(), 0, drawable.getHeight()); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); // Draw the background texture @@ -327,8 +343,8 @@ public class FlyingText extends Demo { int h = drawable.getHeight(); float fw = w / 100.0f; float fh = h / 100.0f; - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); - gl.glBegin(GL.GL_QUADS); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); + gl.glBegin(GL2.GL_QUADS); gl.glTexCoord2f(fw * coords.left(), fh * coords.bottom()); gl.glVertex3f(0, 0, 0); gl.glTexCoord2f(fw * coords.right(), fh * coords.bottom()); @@ -347,7 +363,7 @@ public class FlyingText extends Demo { // We tell the text renderer to render the text at the origin, and // manipulate the modelview matrix to put the text where we want. - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); // First render drop shadows renderer.setColor(0, 0, 0, 0.5f); diff --git a/src/demos/j2d/TestOverlay.java b/src/demos/j2d/TestOverlay.java index b0bcae2..9d6212d 100755 --- a/src/demos/j2d/TestOverlay.java +++ b/src/demos/j2d/TestOverlay.java @@ -39,23 +39,28 @@ package demos.j2d; + + +import demos.gears.Gears; +import demos.util.*; +import gleem.linalg.*; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; import java.awt.Frame; import java.awt.Graphics2D; import java.awt.Rectangle; -import java.awt.event.*; -import java.awt.font.*; -import java.text.*; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.j2d.*; - -import demos.gears.Gears; -import demos.util.*; -import gleem.linalg.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.text.DecimalFormat; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.Animator; /** A simple test of the Overlay utility class. Draws gears underneath with moving Java 2D-rendered text on top. */ @@ -84,7 +89,7 @@ public class TestOverlay implements GLEventListener { }).start(); } }); - frame.show(); + frame.setVisible(true); animator.start(); } diff --git a/src/demos/j2d/TestTextRenderer.java b/src/demos/j2d/TestTextRenderer.java index 281476f..8b5284a 100755 --- a/src/demos/j2d/TestTextRenderer.java +++ b/src/demos/j2d/TestTextRenderer.java @@ -39,20 +39,25 @@ package demos.j2d; +import demos.gears.Gears; +import demos.util.FPSCounter; +import demos.util.SystemTime; +import demos.util.Time; +import gleem.linalg.Vec2f; import java.awt.Font; import java.awt.Frame; -import java.awt.event.*; -import java.awt.geom.*; -import java.text.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.geom.Rectangle2D; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.Animator; +import sun.java2d.pipe.TextRenderer; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.j2d.*; -import demos.gears.Gears; -import demos.util.*; -import gleem.linalg.*; /** A simple test of the TextRenderer class. Draws gears underneath with moving Java 2D-rendered text on top. */ @@ -82,7 +87,7 @@ public class TestTextRenderer implements GLEventListener { } }); - frame.show(); + frame.setVisible(true); animator.start(); } diff --git a/src/demos/j2d/TestTextureRenderer.java b/src/demos/j2d/TestTextureRenderer.java index 5702743..bcb7b96 100755 --- a/src/demos/j2d/TestTextureRenderer.java +++ b/src/demos/j2d/TestTextureRenderer.java @@ -39,24 +39,30 @@ package demos.j2d; +import demos.gears.Gears; +import demos.util.SystemTime; +import demos.util.Time; +import gleem.linalg.Vec2f; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; import java.awt.Frame; import java.awt.Graphics2D; import java.awt.Rectangle; -import java.awt.event.*; -import java.awt.font.*; -import java.text.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.text.DecimalFormat; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.media.opengl.util.Animator; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.j2d.*; -import demos.gears.Gears; -import demos.util.*; -import gleem.linalg.*; /** A simple test of the TextureRenderer utility class. Draws gears underneath with moving Java 2D-rendered text on top. */ @@ -85,7 +91,7 @@ public class TestTextureRenderer implements GLEventListener { }).start(); } }); - frame.show(); + frame.setVisible(true); animator.start(); } diff --git a/src/demos/j2d/TextCube.java b/src/demos/j2d/TextCube.java index 10d97b7..0480358 100755 --- a/src/demos/j2d/TextCube.java +++ b/src/demos/j2d/TextCube.java @@ -39,20 +39,25 @@ package demos.j2d; +import demos.common.Demo; +import demos.util.FPSCounter; +import demos.util.SystemTime; +import demos.util.Time; import java.awt.BorderLayout; -import java.awt.Color; import java.awt.Font; import java.awt.Frame; -import java.awt.event.*; -import java.awt.geom.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.geom.Rectangle2D; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.media.opengl.util.Animator; +import sun.java2d.pipe.TextRenderer; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.j2d.*; -import demos.common.*; -import demos.util.*; /** Shows how to place 2D text in 3D using the TextRenderer. */ @@ -90,14 +95,14 @@ public class TextCube extends Demo { }).start(); } }); - frame.show(); + frame.setVisible(true); animator.start(); } public void init(GLAutoDrawable drawable) { renderer = new TextRenderer(new Font("SansSerif", Font.PLAIN, 72)); GL gl = drawable.getGL(); - gl.glEnable(GL.GL_DEPTH_TEST); + gl.glEnable(GL2.GL_DEPTH_TEST); // Compute the scale factor of the largest string which will make // them all fit on the faces of the cube @@ -113,10 +118,10 @@ public class TextCube extends Demo { } public void display(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + GL2 gl = drawable.getGL().getGL2(); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); glu.gluLookAt(0, 0, 10, 0, 0, 0, @@ -160,14 +165,14 @@ public class TextCube extends Demo { public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL gl = drawable.getGL(); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(15, (float) width / (float) height, 5, 15); } public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} - private void drawFace(GL gl, + private void drawFace(GL2 gl, float faceSize, float r, float g, float b, String text) { @@ -175,7 +180,7 @@ public class TextCube extends Demo { // Face is centered around the local coordinate system's z axis, // at a z depth of faceSize / 2 gl.glColor3f(r, g, b); - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); gl.glVertex3f(-halfFaceSize, -halfFaceSize, halfFaceSize); gl.glVertex3f( halfFaceSize, -halfFaceSize, halfFaceSize); gl.glVertex3f( halfFaceSize, halfFaceSize, halfFaceSize); @@ -191,8 +196,8 @@ public class TextCube extends Demo { // internally we don't have to reset the depth test or cull face // bits after we're done. renderer.begin3DRendering(); - gl.glDisable(GL.GL_DEPTH_TEST); - gl.glEnable(GL.GL_CULL_FACE); + gl.glDisable(GL2.GL_DEPTH_TEST); + gl.glEnable(GL2.GL_CULL_FACE); // Note that the defaults for glCullFace and glFrontFace are // GL_BACK and GL_CCW, which match the TextRenderer's definition // of front-facing text. diff --git a/src/demos/j2d/TextFlow.java b/src/demos/j2d/TextFlow.java index 3dfcf14..11e8ea5 100755 --- a/src/demos/j2d/TextFlow.java +++ b/src/demos/j2d/TextFlow.java @@ -39,21 +39,29 @@ package demos.j2d; +import demos.common.Demo; +import demos.util.SystemTime; +import demos.util.Time; import java.awt.BorderLayout; import java.awt.Font; import java.awt.Frame; -import java.awt.event.*; -import java.awt.font.*; -import java.awt.geom.*; -import java.text.*; -import java.util.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.font.FontRenderContext; +import java.awt.font.LineBreakMeasurer; +import java.awt.font.TextAttribute; +import java.awt.geom.Rectangle2D; +import java.text.AttributedString; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.Animator; +import sun.java2d.pipe.TextRenderer; -import javax.media.opengl.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.j2d.*; - -import demos.common.*; -import demos.util.*; /** Illustrates both the TextRenderer's capability for handling relatively large amounts of text (more than drawn on the screen -- @@ -88,7 +96,7 @@ public class TextFlow extends Demo { }).start(); } }); - frame.show(); + frame.setVisible(true); animator.start(); } diff --git a/src/demos/jgears/JGears.java b/src/demos/jgears/JGears.java index 9da0f46..0c10bab 100644 --- a/src/demos/jgears/JGears.java +++ b/src/demos/jgears/JGears.java @@ -1,17 +1,29 @@ package demos.jgears; -import java.awt.*; -import java.awt.event.*; -import java.awt.geom.*; -import java.awt.image.*; -import java.io.*; -import java.text.*; -import javax.imageio.*; -import javax.swing.*; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; + import demos.gears.Gears; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.io.InputStream; +import java.text.DecimalFormat; +import javax.imageio.ImageIO; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.awt.gl2.GL2JPanel; +import javax.media.opengl.util.Animator; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JPanel; /** * JGears.java <BR> @@ -20,7 +32,7 @@ import demos.gears.Gears; * This version is equal to Brian Paul's version 1.2 1999/10/21 */ -public class JGears extends GLJPanel { +public class JGears extends GL2JPanel { private static GLCapabilities caps; private long startTime; private int frameCount; @@ -107,7 +119,7 @@ public class JGears extends GLJPanel { public static void main(String[] args) { JFrame frame = new JFrame("Gear Demo"); frame.getContentPane().setLayout(new BorderLayout()); - final GLJPanel drawable = new JGears(); + final GL2JPanel drawable = new JGears(); drawable.setOpaque(false); JPanel gradientPanel = createGradientPanel(); @@ -137,7 +149,7 @@ public class JGears extends GLJPanel { }).start(); } }); - frame.show(); + frame.setVisible(true); animator.start(); } } diff --git a/src/demos/jrefract/JRefract.java b/src/demos/jrefract/JRefract.java index ee659da..6a46230 100755 --- a/src/demos/jrefract/JRefract.java +++ b/src/demos/jrefract/JRefract.java @@ -33,28 +33,46 @@ package demos.jrefract; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.swing.*; -import javax.swing.event.*; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.*; -import demos.common.*; +import demos.common.Demo; +import demos.common.DemoListener; import demos.hdr.HDR; import demos.hwShadowmapsSimple.HWShadowmapsSimple; import demos.infiniteShadowVolumes.InfiniteShadowVolumes; import demos.j2d.FlyingText; import demos.jgears.JGears; import demos.proceduralTexturePhysics.ProceduralTexturePhysics; -import demos.util.*; import demos.vertexBufferObject.VertexBufferObject; import demos.vertexProgRefract.VertexProgRefract; import demos.vertexProgWarp.VertexProgWarp; +import demos.xtrans.XTDesktopPane; +import java.awt.BorderLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.awt.gl2.GL2JPanel; +import javax.media.opengl.util.Animator; +import javax.media.opengl.util.FPSAnimator; +import javax.swing.JCheckBox; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; -import demos.xtrans.*; /** Wavelength-dependent refraction demo<br> @@ -120,10 +138,10 @@ public class JRefract { if (which == INFINITE) { caps.setStencilBits(16); } - final GLJPanel canvas = + final GL2JPanel canvas = (which == GEARS) ? new JGears() : - new GLJPanel(caps); + new GL2JPanel(caps); final DemoListener demoListener = new DemoListener() { public void shutdownDemo() { removeJPanel(canvas); @@ -402,11 +420,11 @@ public class JRefract { }).start(); } - private synchronized void addJPanel(GLJPanel panel) { + private synchronized void addJPanel(GL2JPanel panel) { animator.add(panel); } - private synchronized void removeJPanel(GLJPanel panel) { + private synchronized void removeJPanel(GL2JPanel panel) { animator.remove(panel); } diff --git a/src/demos/misc/GLCapsTableDemo.java b/src/demos/misc/GLCapsTableDemo.java index 767c4d5..940079c 100755 --- a/src/demos/misc/GLCapsTableDemo.java +++ b/src/demos/misc/GLCapsTableDemo.java @@ -1,16 +1,30 @@ package demos.misc; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import javax.swing.*; -import com.sun.opengl.util.FPSAnimator; + import javax.swing.border.TitledBorder; import javax.swing.table.TableColumn; import demos.gears.Gears; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import javax.media.opengl.DefaultGLCapabilitiesChooser; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.FPSAnimator; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTable; /******************************************************************************* * @file GLCapsTableDemo.java diff --git a/src/demos/misc/Picking.java b/src/demos/misc/Picking.java index 2fe8b2d..c985894 100755 --- a/src/demos/misc/Picking.java +++ b/src/demos/misc/Picking.java @@ -14,10 +14,11 @@ import java.awt.*; import java.awt.event.*; import java.awt.Canvas.*; import java.nio.*; -import java.util.*; import javax.media.opengl.*; +import javax.media.opengl.awt.GLCanvas; import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; +import javax.media.opengl.util.Animator; +import javax.media.opengl.util.BufferUtil; public class Picking { @@ -32,7 +33,10 @@ public class Picking GLDrawableFactory factory = GLDrawableFactory.getFactory(); GLCapabilities capabilities = new GLCapabilities(); GLCanvas drawable = new GLCanvas(capabilities); - drawable.addGLEventListener(new Renderer()); + final Renderer renderer = new Renderer(); + drawable.addGLEventListener(renderer); + drawable.addMouseListener(renderer); + drawable.addMouseMotionListener(renderer); frame.add(drawable); frame.setSize(400, 400); final Animator animator = new Animator(drawable); @@ -44,7 +48,7 @@ public class Picking System.exit(0); } }); - frame.show(); + frame.setVisible(true); animator.start(); } @@ -61,12 +65,10 @@ public class Picking { GL gl = drawable.getGL(); this.gldrawable = drawable; - gl.glEnable(GL.GL_CULL_FACE); - gl.glEnable(GL.GL_DEPTH_TEST); - gl.glEnable(GL.GL_NORMALIZE); + gl.glEnable(GL2.GL_CULL_FACE); + gl.glEnable(GL2.GL_DEPTH_TEST); + gl.glEnable(GL2.GL_NORMALIZE); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - drawable.addMouseListener(this); - drawable.addMouseMotionListener(this); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) @@ -74,14 +76,14 @@ public class Picking GL gl = drawable.getGL(); float h = (float) height / (float) width; gl.glViewport(0, 0, width, height); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluOrtho2D(0.0f,1.0f,0.0f,1.0f); } public void display(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); switch(cmd) { case UPDATE: @@ -93,20 +95,20 @@ public class Picking int[] viewPort = new int[4]; IntBuffer selectBuffer = BufferUtil.newIntBuffer(buffsize); int hits = 0; - gl.glGetIntegerv(GL.GL_VIEWPORT, viewPort, 0); + gl.glGetIntegerv(GL2.GL_VIEWPORT, viewPort, 0); gl.glSelectBuffer(buffsize, selectBuffer); - gl.glRenderMode(GL.GL_SELECT); + gl.glRenderMode(GL2.GL_SELECT); gl.glInitNames(); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); glu.gluPickMatrix(x, (double) viewPort[3] - y, 5.0d, 5.0d, viewPort, 0); glu.gluOrtho2D(0.0d, 1.0d, 0.0d, 1.0d); drawScene(gl); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glPopMatrix(); gl.glFlush(); - hits = gl.glRenderMode(GL.GL_RENDER); + hits = gl.glRenderMode(GL2.GL_RENDER); processHits(hits, selectBuffer); cmd = UPDATE; break; @@ -149,20 +151,20 @@ public class Picking public int viewPortWidth(GL gl) { int[] viewPort = new int[4]; - gl.glGetIntegerv(GL.GL_VIEWPORT, viewPort, 0); + gl.glGetIntegerv(GL2.GL_VIEWPORT, viewPort, 0); return viewPort[2]; } public int viewPortHeight(GL gl) { int[] viewPort = new int[4]; - gl.glGetIntegerv(GL.GL_VIEWPORT, viewPort, 0); + gl.glGetIntegerv(GL2.GL_VIEWPORT, viewPort, 0); return viewPort[3]; } - public void drawScene(GL gl) + public void drawScene(GL2 gl) { - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); // Colors float red[] = {1.0f,0.0f,0.0f,1.0f}; @@ -227,9 +229,9 @@ public class Picking float[] c; int id = 0; boolean outline = false; - GL gl; + GL2 gl; GLU glu; - public GLEntity(GL gl, GLU glu) + public GLEntity(GL2 gl, GLU glu) { this.gl = gl; this.glu = glu; @@ -246,19 +248,19 @@ public class Picking { float w = 0.1f; float h = 0.1f; - public GLRectangleEntity(GL gl, GLU glu) + public GLRectangleEntity(GL2 gl, GLU glu) { super(gl, glu); } public void _draw() { if (outline) - gl.glPolygonMode(GL.GL_FRONT, GL.GL_LINE); + gl.glPolygonMode(GL2.GL_FRONT, GL2.GL_LINE); else - gl.glPolygonMode(GL.GL_FRONT, GL.GL_FILL); + gl.glPolygonMode(GL2.GL_FRONT, GL2.GL_FILL); gl.glColor4fv(c, 0); - gl.glBegin(GL.GL_POLYGON); + gl.glBegin(GL2.GL_POLYGON); gl.glVertex3f(x, y, z); gl.glVertex3f(x + w, y, z); gl.glVertex3f(x + w, y + h, z); diff --git a/src/demos/misc/TiledRendering.java b/src/demos/misc/TiledRendering.java index f5b857e..6d9806e 100755 --- a/src/demos/misc/TiledRendering.java +++ b/src/demos/misc/TiledRendering.java @@ -6,8 +6,9 @@ import java.nio.*; import javax.imageio.*; import javax.media.opengl.*; -import com.sun.opengl.util.*; +import com.sun.opengl.util.awt.*; +import com.sun.opengl.util.io.TGAWriter; import demos.gears.Gears; /** Demonstrates the TileRenderer class by rendering a large version @@ -74,7 +75,7 @@ public class TiledRendering { System.exit(1); } - GL gl = pbuffer.getGL(); + GL2 gl = pbuffer.getGL().getGL2(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f, 0.0f, -40.0f); @@ -98,7 +99,7 @@ public class TiledRendering { } } - private static void drawGears(GL gl) { + private static void drawGears(GL2 gl) { float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; float angle = 0.0f; float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; diff --git a/src/demos/multisample/Multisample.java b/src/demos/multisample/Multisample.java index 4db572a..c3c9a01 100755 --- a/src/demos/multisample/Multisample.java +++ b/src/demos/multisample/Multisample.java @@ -42,6 +42,7 @@ package demos.multisample; import java.awt.*; import java.awt.event.*; import javax.media.opengl.*; +import javax.media.opengl.awt.GLCanvas; public class Multisample { private GLCanvas canvas; @@ -89,7 +90,7 @@ public class Multisample { canvas.setSize(512, 512); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); frame.setLocation(0, 0); canvas.requestFocus(); @@ -109,7 +110,7 @@ public class Multisample { canvas.setSize(512, 512); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); frame.setLocation(512, 0); canvas.requestFocus(); @@ -122,7 +123,7 @@ public class Multisample { class Listener implements GLEventListener { public void init(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); gl.glClearColor(0, 0, 0, 0); // gl.glEnable(GL.GL_DEPTH_TEST); @@ -136,7 +137,7 @@ public class Multisample { } public void display(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); diff --git a/src/demos/nurbs/icons/IconFactory.java b/src/demos/nurbs/icons/IconFactory.java index 88d8539..81c906a 100755 --- a/src/demos/nurbs/icons/IconFactory.java +++ b/src/demos/nurbs/icons/IconFactory.java @@ -1,8 +1,8 @@ package demos.nurbs.icons; +import com.sun.opengl.impl.io.StreamUtil; import java.io.*; import javax.swing.ImageIcon; -import com.sun.opengl.util.StreamUtil; public class IconFactory { private IconFactory() {} @@ -10,7 +10,7 @@ public class IconFactory { public static ImageIcon getIcon(String resourceName) { try { InputStream input = IconFactory.class.getClassLoader().getResourceAsStream(resourceName); - byte[] data = StreamUtil.readAll(input); + byte[] data = StreamUtil.readAll2Array(input); return new ImageIcon(data, resourceName); } catch (IOException e) { return new ImageIcon(); diff --git a/src/demos/nurbs/surfaceapp/GLListener.java b/src/demos/nurbs/surfaceapp/GLListener.java index fe0918f..d83f28e 100755 --- a/src/demos/nurbs/surfaceapp/GLListener.java +++ b/src/demos/nurbs/surfaceapp/GLListener.java @@ -5,7 +5,8 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.glu.*; -import com.sun.opengl.util.GLUT; +import com.sun.opengl.util.glut.gl2.GLUTgl2; +import javax.media.opengl.GL2; /** * Listener reacting to events occuring on OpenGL canvas @@ -18,7 +19,7 @@ public class GLListener implements GLEventListener { * Object realizing OpenGL functions * objekt realizující základní OpenGL funkce */ - private GL gl; + private GL2 gl; /** * GLU object @@ -91,7 +92,7 @@ public class GLListener implements GLEventListener { * GLUT object * Objekt pro podporu funkcionality GL utility toolkit */ - private GLUT glut; + private GLUTgl2 glut; /** @@ -112,18 +113,18 @@ public class GLListener implements GLEventListener { * @see javax.media.opengl.GLEventListener#init(javax.media.opengl.GLAutoDrawable) */ public void init(GLAutoDrawable drawable) { - this.gl = drawable.getGL(); + this.gl = drawable.getGL().getGL2(); this.glu = new GLU(); - this.glut = new GLUT(); + this.glut = new GLUTgl2(); this.nurbs = glu.gluNewNurbsRenderer(); // gl.glClearColor(0, 0, 0, 0); gl.glClearColor(1, 1, 1, 0); - gl.glEnable(GL.GL_DEPTH_TEST); - gl.glDepthFunc(GL.GL_LESS); + gl.glEnable(GL2.GL_DEPTH_TEST); + gl.glDepthFunc(GL2.GL_LESS); gl.glClearDepth(1000.0f); - gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); + gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST); } /* (non-Javadoc) @@ -131,36 +132,35 @@ public class GLListener implements GLEventListener { */ public void display(GLAutoDrawable drawable) { - gl.glClear(GL.GL_COLOR_BUFFER_BIT| GL.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT| GL2.GL_DEPTH_BUFFER_BIT); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); - glu.gluLookAt(0,0,400, 0,0,0, 0,1,0); - - + glu.gluLookAt(0,0,400, 0,0,0, 0,1,0); + // gl.glPushMatrix(); - gl.glShadeModel(GL.GL_SMOOTH); - gl.glPolygonMode(GL.GL_FRONT, GL.GL_FILL); - gl.glPolygonMode(GL.GL_BACK, GL.GL_FILL); - gl.glDisable(GL.GL_CULL_FACE); + gl.glShadeModel(GL2.GL_SMOOTH); + gl.glPolygonMode(GL2.GL_FRONT, GL2.GL_FILL); + gl.glPolygonMode(GL2.GL_BACK, GL2.GL_FILL); + gl.glDisable(GL2.GL_CULL_FACE); - gl.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, materialDiffuse,0); - gl.glMaterialfv(GL.GL_BACK, GL.GL_DIFFUSE, materialDiffuse,0); + gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_DIFFUSE, materialDiffuse,0); + gl.glMaterialfv(GL2.GL_BACK, GL2.GL_DIFFUSE, materialDiffuse,0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition,0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, materialDiffuse,0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, lightAmbient,0); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, lightAmbient,0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, lightPosition,0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, materialDiffuse,0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, lightAmbient,0); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, lightAmbient,0); - gl.glLightfv(GL.GL_LIGHT2, GL.GL_POSITION, lightPosition3,0); - gl.glLightfv(GL.GL_LIGHT2, GL.GL_DIFFUSE, lightDiffuse,0); + gl.glLightfv(GL2.GL_LIGHT2, GL2.GL_POSITION, lightPosition3,0); + gl.glLightfv(GL2.GL_LIGHT2, GL2.GL_DIFFUSE, lightDiffuse,0); - if(app.isLightingEnabled())gl.glEnable(GL.GL_LIGHTING); - else gl.glDisable(GL.GL_LIGHTING); - gl.glEnable(GL.GL_LIGHT0); - gl.glEnable(GL.GL_LIGHT2); + if(app.isLightingEnabled())gl.glEnable(GL2.GL_LIGHTING); + else gl.glDisable(GL2.GL_LIGHTING); + gl.glEnable(GL2.GL_LIGHT0); + gl.glEnable(GL2.GL_LIGHT2); // gl.glPopMatrix(); @@ -179,14 +179,14 @@ public class GLListener implements GLEventListener { - gl.glGetIntegerv(GL.GL_VIEWPORT,viewport,0); - gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX,mvmatrix,0); - gl.glGetDoublev(GL.GL_PROJECTION_MATRIX,projmatrix,0); + gl.glGetIntegerv(GL2.GL_VIEWPORT,viewport,0); + gl.glGetDoublev(GL2.GL_MODELVIEW_MATRIX,mvmatrix,0); + gl.glGetDoublev(GL2.GL_PROJECTION_MATRIX,projmatrix,0); - gl.glEnable(GL.GL_LINE_SMOOTH); - gl.glEnable(GL.GL_BLEND); - gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); - gl.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_DONT_CARE); + gl.glEnable(GL2.GL_LINE_SMOOTH); + gl.glEnable(GL2.GL_BLEND); + gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA); + gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_DONT_CARE); gl.glLineWidth(3); @@ -203,16 +203,16 @@ public class GLListener implements GLEventListener { ctrlpoints, Surface.getInstance().getOrderU(), Surface.getInstance().getOrderV(), - GL.GL_MAP2_VERTEX_4); + GL2.GL_MAP2_VERTEX_4); glu.gluEndSurface(nurbs); } - gl.glDisable(GL.GL_LIGHTING); + gl.glDisable(GL2.GL_LIGHTING); // gl.glColor3f(1,1,1); gl.glColor3f(0,0,0); gl.glPointSize(5); - gl.glBegin(GL.GL_POINTS); + gl.glBegin(GL2.GL_POINTS); for (int i = 0; i < ctrlpoints.length / 4; i++) { gl.glVertex3d(ctrlpoints[i * 4]/ctrlpoints[i * 4 + 3], ctrlpoints[i * 4 + 1]/ctrlpoints[i * 4 + 3], ctrlpoints[i * 4 + 2]/ctrlpoints[i * 4 + 3]); @@ -225,7 +225,7 @@ public class GLListener implements GLEventListener { ctrlpoints[i * 4 + 2]/ctrlpoints[i * 4 + 3]); //gl.glRasterPos2f((int)coords[0], (int)(viewport[3]-coords[1]-1-5)); // gl.glRasterPos2d(20,20); - glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18,String.valueOf(i+1)); + glut.glutBitmapString(GLUTgl2.BITMAP_HELVETICA_18,String.valueOf(i+1)); } @@ -234,7 +234,7 @@ public class GLListener implements GLEventListener { //TODO zobrazovat síť - musí to být pomocí dvou vnořených forcyklů //TODO draw mesh - it needs two nested for statements gl.glLineWidth(1); - // gl.glBegin(GL.GL_LINE_STRIP); + // gl.glBegin(GL2.GL_LINE_STRIP); int baseIndex=0 ; @@ -243,7 +243,7 @@ public class GLListener implements GLEventListener { //"příčná žebra" //"cross ribs" for(int i=0;i<Surface.getInstance().getPointsInU();i++){ - gl.glBegin(GL.GL_LINE_STRIP); + gl.glBegin(GL2.GL_LINE_STRIP); for(int j=0;j<Surface.getInstance().getPointsInV();j++){ baseIndex=i*Surface.getInstance().getPointsInV()*4+j*4; gl.glVertex3f(ctrlpoints[baseIndex+0]/ctrlpoints[baseIndex+3], @@ -255,7 +255,7 @@ public class GLListener implements GLEventListener { //"podélná žebra" //"alongway ribs" for(int j=0;j<Surface.getInstance().getPointsInV();j++){ - gl.glBegin(GL.GL_LINE_STRIP); + gl.glBegin(GL2.GL_LINE_STRIP); for(int i=0;i<Surface.getInstance().getPointsInU();i++){ baseIndex=i*Surface.getInstance().getPointsInV()*4+j*4; gl.glVertex3f(ctrlpoints[baseIndex+0]/ctrlpoints[baseIndex+3], @@ -268,7 +268,7 @@ public class GLListener implements GLEventListener { gl.glColor3f(0,0,1); if(Surface.getInstance().getBodIndex()>=0){ gl.glPointSize(8); - gl.glBegin(GL.GL_POINTS); + gl.glBegin(GL2.GL_POINTS); int i=Surface.getInstance().getBodIndex(); gl.glVertex3d(ctrlpoints[i * 4]/ctrlpoints[i * 4 + 3], ctrlpoints[i * 4 + 1]/ctrlpoints[i * 4 + 3], ctrlpoints[i * 4 + 2]/ctrlpoints[i * 4 + 3]); @@ -284,7 +284,7 @@ public class GLListener implements GLEventListener { public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { gl.glViewport(0, 0, width, height); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(65.0, (double) width / height, 0.1, 1000.0); // gl.glScalef(1, -1, 1); diff --git a/src/demos/nurbs/surfaceapp/SurfaceApp.java b/src/demos/nurbs/surfaceapp/SurfaceApp.java index 7f2a546..4018967 100755 --- a/src/demos/nurbs/surfaceapp/SurfaceApp.java +++ b/src/demos/nurbs/surfaceapp/SurfaceApp.java @@ -9,10 +9,8 @@ import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import javax.media.opengl.GLCanvas; import javax.swing.AbstractAction; import javax.swing.ButtonGroup; -import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; @@ -33,6 +31,7 @@ import javax.swing.ToolTipManager; import demos.nurbs.icons.*; import demos.nurbs.knotslidercomponent.JKnotSlider; +import javax.media.opengl.awt.GLCanvas; /** * Main class for application demostrating capabilitues of JOGL library extend by NURBS surface functionalities diff --git a/src/demos/particles/engine/Engine.java b/src/demos/particles/engine/Engine.java index 62a6237..2b60175 100755 --- a/src/demos/particles/engine/Engine.java +++ b/src/demos/particles/engine/Engine.java @@ -68,7 +68,7 @@ public class Engine { particles.remove(particles.size()-1); } - public void draw(GL gl) { + public void draw(GL2 gl) { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); diff --git a/src/demos/particles/engine/GLComponent.java b/src/demos/particles/engine/GLComponent.java index 299578f..ddde39e 100755 --- a/src/demos/particles/engine/GLComponent.java +++ b/src/demos/particles/engine/GLComponent.java @@ -38,9 +38,9 @@ package demos.particles.engine; import javax.media.opengl.*; import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; +import javax.media.opengl.awt.*; -import java.io.*; +import javax.media.opengl.util.FPSAnimator; public class GLComponent extends GLCanvas implements GLEventListener { @@ -70,7 +70,7 @@ public class GLComponent extends GLCanvas implements GLEventListener { } public void display(GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); + final GL2 gl = drawable.getGL().getGL2(); engine.draw(gl); } @@ -94,9 +94,9 @@ public class GLComponent extends GLCanvas implements GLEventListener { gl.glEnable(GL.GL_BLEND); gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); // Get nice perspective calculations. - gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); + gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST); // Nice point smoothing. - gl.glHint(GL.GL_POINT_SMOOTH_HINT, GL.GL_NICEST); + gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_NICEST); // Enable texture mapping. gl.glEnable(GL.GL_TEXTURE_2D); diff --git a/src/demos/particles/engine/Particle.java b/src/demos/particles/engine/Particle.java index 82e0756..ad4955e 100755 --- a/src/demos/particles/engine/Particle.java +++ b/src/demos/particles/engine/Particle.java @@ -56,12 +56,12 @@ public class Particle { (float)Math.random()); } - public void draw(GL gl, Texture texture, RGBA tendToColor) { + public void draw(GL2 gl, Texture texture, RGBA tendToColor) { adjust(tendToColor); texture.bind(); gl.glColor4f(rgba.r,rgba.g,rgba.b,rgba.a); - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(currentPos.x, currentPos.y-2, currentPos.z); gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(currentPos.x+2, currentPos.y-2, currentPos.z); gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(currentPos.x+2, currentPos.y, currentPos.z); diff --git a/src/demos/printext/PrintExt.java b/src/demos/printext/PrintExt.java index fa76031..0d5e101 100755 --- a/src/demos/printext/PrintExt.java +++ b/src/demos/printext/PrintExt.java @@ -5,8 +5,13 @@ package demos.printext; -import java.awt.*; -import javax.media.opengl.*; +import java.awt.Frame; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; + + public class PrintExt { public static void main(String[] args) { diff --git a/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java b/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java index e20d811..774885a 100644 --- a/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java +++ b/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java @@ -30,19 +30,33 @@ * EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * */ - package demos.proceduralTexturePhysics; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; -import demos.common.*; -import demos.util.*; -import gleem.*; -import gleem.linalg.*; +import demos.common.Demo; +import demos.common.DemoListener; +import demos.util.DurationTimer; +import gleem.BSphere; +import gleem.BSphereProvider; +import gleem.CameraParameters; +import gleem.ExaminerViewer; +import gleem.ManipManager; +import gleem.MouseButtonHelper; +import gleem.linalg.Vec3f; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLException; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.Animator; +import javax.swing.JOptionPane; /** * Water demonstration by NVidia Corporation - <a href = @@ -57,325 +71,341 @@ import gleem.linalg.*; * Ported to Java and ARB_fragment_program by Kenneth Russell * */ - public class ProceduralTexturePhysics extends Demo { - public static void main(String[] args) { - GLCanvas canvas = new GLCanvas(); - ProceduralTexturePhysics demo = new ProceduralTexturePhysics(); - canvas.addGLEventListener(demo); - - final Animator animator = new Animator(canvas); - demo.setDemoListener(new DemoListener() { - public void shutdownDemo() { - runExit(animator); - } - public void repaint() {} - }); - - Frame frame = new Frame("Procedural Texture Waves"); - frame.setLayout(new BorderLayout()); - canvas.setSize(512, 512); - frame.add(canvas, BorderLayout.CENTER); - frame.pack(); - frame.show(); - canvas.requestFocus(); - - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - runExit(animator); - } - }); - - animator.start(); - } - - //---------------------------------------------------------------------- - // Internals only below this point - // - - public void shutdownDemo() { - viewer.detach(); - ManipManager.getManipManager().unregisterWindow(drawable); - drawable.removeGLEventListener(this); - super.shutdownDemo(); - } - - private volatile boolean drawing; - private volatile int mousePosX; - private volatile int mousePosY; - - private GLAutoDrawable drawable; - private Water water = new Water(); - private volatile ExaminerViewer viewer; - private boolean[] b = new boolean[256]; - private boolean doViewAll = true; - private float zNear = 0.1f; - private float zFar = 10.0f; - - private DurationTimer timer = new DurationTimer(); - private boolean firstRender = true; - private int frameCount; - - private float blurIncrement = 0.01f; - private float bumpIncrement = 0.01f; - private float frequencyIncrement = 0.1f; - - public void init(GLAutoDrawable drawable) { - water.destroy(); - water.initialize("demos/data/images/nvfixed.tga", - "demos/data/images/nvspin.tga", - "demos/data/images/droplet.tga", - "demos/data/cubemaps/CloudyHills_", - "tga", - drawable); - - GL gl = drawable.getGL(); - gl.setSwapInterval(1); - - try { - checkExtension(gl, "GL_VERSION_1_3"); // For multitexture - checkExtension(gl, "GL_ARB_vertex_program"); - checkExtension(gl, "GL_ARB_fragment_program"); - checkExtension(gl, "GL_ARB_pbuffer"); - checkExtension(gl, "GL_ARB_pixel_format"); - } catch (GLException e) { - e.printStackTrace(); - throw(e); - } - - gl.glClearColor(0, 0.2f, 0.5f, 0); - gl.glDisable(GL.GL_LIGHTING); - gl.glDisable(GL.GL_DEPTH_TEST); - gl.glDisable(GL.GL_CULL_FACE); - - doViewAll = true; - - if (firstRender) { - firstRender = false; - - // Register the window with the ManipManager - ManipManager manager = ManipManager.getManipManager(); - manager.registerWindow(drawable); - this.drawable = drawable; - - viewer = new ExaminerViewer(MouseButtonHelper.numMouseButtons()); - viewer.setAutoRedrawMode(false); - viewer.attach(drawable, new BSphereProvider() { - public BSphere getBoundingSphere() { - return new BSphere(new Vec3f(0, 0, 0), 1.2f); - } + + private ProceduralTexturePhysics() { + + GLCanvas canvas = new GLCanvas(); + ProceduralTexturePhysics demo = new ProceduralTexturePhysics(); + canvas.addGLEventListener(demo); + + canvas.addKeyListener(new KeyAdapter() { + + public void keyPressed(KeyEvent e) { + dispatchKey(e.getKeyChar()); + } }); - viewer.setVertFOV((float) (15.0f * Math.PI / 32.0f)); - viewer.setZNear(zNear); - viewer.setZFar(zFar); - - drawable.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - dispatchKey(e.getKeyChar()); - } + + canvas.addMouseListener(new MouseAdapter() { + + public void mousePressed(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && + !e.isAltDown() && !e.isMetaDown()) { + drawing = true; + } + } + + public void mouseReleased(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1) { + drawing = false; + } + } }); - drawable.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON1 && - !e.isAltDown() && !e.isMetaDown()) { - drawing = true; + canvas.addMouseMotionListener(new MouseMotionAdapter() { + + public void mouseDragged(MouseEvent e) { + mousePosX = e.getX(); + mousePosY = e.getY(); } - } + }); + + final Animator animator = new Animator(canvas); + demo.setDemoListener(new DemoListener() { - public void mouseReleased(MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON1) { - drawing = false; + public void shutdownDemo() { + runExit(animator); + } + + public void repaint() { } - } }); - drawable.addMouseMotionListener(new MouseMotionAdapter() { - public void mouseDragged(MouseEvent e) { - mousePosX = e.getX(); - mousePosY = e.getY(); - } + Frame frame = new Frame("Procedural Texture Waves"); + frame.setLayout(new BorderLayout()); + canvas.setSize(512, 512); + frame.add(canvas, BorderLayout.CENTER); + frame.pack(); + frame.setVisible(true); + canvas.requestFocus(); + + frame.addWindowListener(new WindowAdapter() { + + public void windowClosing(WindowEvent e) { + runExit(animator); + } }); - timer.start(); + animator.start(); } - } - - public void display(GLAutoDrawable drawable) { - if (++frameCount == 30) { - timer.stop(); - System.err.println("Frames per second: " + (30.0f / timer.getDurationAsSeconds())); - timer.reset(); - timer.start(); - frameCount = 0; + + public void shutdownDemo() { + viewer.detach(); + ManipManager.getManipManager().unregisterWindow(drawable); + drawable.removeGLEventListener(this); + super.shutdownDemo(); } + private volatile boolean drawing; + private volatile int mousePosX; + private volatile int mousePosY; + private GLAutoDrawable drawable; + private Water water = new Water(); + private volatile ExaminerViewer viewer; + private boolean[] b = new boolean[256]; + private boolean doViewAll = true; + private float zNear = 0.1f; + private float zFar = 10.0f; + private DurationTimer timer = new DurationTimer(); + private boolean firstRender = true; + private int frameCount; + private float blurIncrement = 0.01f; + private float bumpIncrement = 0.01f; + private float frequencyIncrement = 0.1f; + + public void init(GLAutoDrawable drawable) { + water.destroy(); + water.initialize("demos/data/images/nvfixed.tga", + "demos/data/images/nvspin.tga", + "demos/data/images/droplet.tga", + "demos/data/cubemaps/CloudyHills_", + "tga", + drawable); + + GL gl = drawable.getGL(); + gl.setSwapInterval(1); + + try { + checkExtension(gl, "GL_VERSION_1_3"); // For multitexture + checkExtension(gl, "GL_ARB_vertex_program"); + checkExtension(gl, "GL_ARB_fragment_program"); + checkExtension(gl, "GL_ARB_pbuffer"); + checkExtension(gl, "GL_ARB_pixel_format"); + } catch (GLException e) { + e.printStackTrace(); + throw (e); + } - GL gl = drawable.getGL(); + gl.glClearColor(0, 0.2f, 0.5f, 0); + gl.glDisable(GL.GL_LIGHTING); + gl.glDisable(GL.GL_DEPTH_TEST); + gl.glDisable(GL.GL_CULL_FACE); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + doViewAll = true; - if (doViewAll) { - viewer.viewAll(gl); - doViewAll = false; - } + if (firstRender) { + firstRender = false; + + // Register the window with the ManipManager + ManipManager manager = ManipManager.getManipManager(); + manager.registerWindow(drawable); + this.drawable = drawable; + + viewer = new ExaminerViewer(MouseButtonHelper.numMouseButtons()); + viewer.setAutoRedrawMode(false); + viewer.attach(drawable, new BSphereProvider() { - viewer.update(gl); - ManipManager.getManipManager().updateCameraParameters(drawable, viewer.getCameraParameters()); - ManipManager.getManipManager().render(drawable, gl); + public BSphere getBoundingSphere() { + return new BSphere(new Vec3f(0, 0, 0), 1.2f); + } + }); + viewer.setVertFOV((float) (15.0f * Math.PI / 32.0f)); + viewer.setZNear(zNear); + viewer.setZFar(zFar); - if (drawing) { - int w = drawable.getWidth(); - int h = drawable.getHeight(); - water.addDroplet(new Water.Droplet( 2 * (mousePosX / (float) w - 0.5f), - -2 * (mousePosY / (float) h - 0.5f), - 0.08f)); + timer.start(); + } } - water.tick(); - CameraParameters params = viewer.getCameraParameters(); - water.draw(gl, params.getOrientation().inverse()); - } + public void display(GLAutoDrawable drawable) { + if (++frameCount == 30) { + timer.stop(); + System.err.println("Frames per second: " + (30.0f / timer.getDurationAsSeconds())); + timer.reset(); + timer.start(); + frameCount = 0; + } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + GL gl = drawable.getGL(); - // Unused routines - public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - private void setFlag(char key, boolean val) { - b[((int) key) & 0xFF] = val; - } + if (doViewAll) { + viewer.viewAll(gl); + doViewAll = false; + } - private boolean getFlag(char key) { - return b[((int) key) & 0xFF]; - } + viewer.update(gl); + ManipManager.getManipManager().updateCameraParameters(drawable, viewer.getCameraParameters()); + ManipManager.getManipManager().render(drawable, gl); - private void checkExtension(GL gl, String extensionName) { - if (!gl.isExtensionAvailable(extensionName)) { - String message = "Unable to initialize " + extensionName + " OpenGL extension"; - JOptionPane.showMessageDialog(null, message, "Unavailable extension", JOptionPane.ERROR_MESSAGE); - shutdownDemo(); + if (drawing) { + int w = drawable.getWidth(); + int h = drawable.getHeight(); + water.addDroplet(new Water.Droplet(2 * (mousePosX / (float) w - 0.5f), + -2 * (mousePosY / (float) h - 0.5f), + 0.08f)); + } + water.tick(); + + CameraParameters params = viewer.getCameraParameters(); + water.draw(gl, params.getOrientation().inverse()); + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } - } - - private void dispatchKey(char k) { - setFlag(k, !getFlag(k)); - - switch (k) { - case 27: - case 'q': - shutdownDemo(); - break; - case 'w': - water.enableWireframe(getFlag('w')); - break; - case 'd': - // FIXME - /* - if (getKey('d')) { - glutMouseFunc(glh::glut_mouse_function); - glutMotionFunc(glh::glut_motion_function); - } - else - { - glutMouseFunc(Mouse); - glutMotionFunc(Motion); - } - */ - break; - case ' ': - water.enableAnimation(getFlag(' ')); - break; - case 'b': - water.enableBorderWrapping(getFlag('b')); - break; - case 'n': - water.singleStep(); - break; - case 's': - water.enableSlowAnimation(getFlag('s')); - break; - case '1': - water.setRenderMode(Water.CA_FULLSCREEN_REFLECT); - break; - case '2': - water.setRenderMode(Water.CA_FULLSCREEN_HEIGHT); - break; - case '3': - water.setRenderMode(Water.CA_FULLSCREEN_FORCE); - break; - case '4': - water.setRenderMode(Water.CA_FULLSCREEN_NORMALMAP); - break; - case '5': - water.setRenderMode(Water.CA_TILED_THREE_WINDOWS); - break; - case 'r': - water.reset(); - break; - case 'i': - // FIXME: make sure this is what this does - doViewAll = true; - // gluPerspective(90, 1, .01, 10); - break; - case 'c': { - float dist = water.getBlurDistance(); - if (dist > blurIncrement) - water.setBlurDistance(dist - blurIncrement); - break; + // Unused routines + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { } - case 'v': { - float dist = water.getBlurDistance(); - if (dist < 1) - water.setBlurDistance(dist + blurIncrement); - break; + + private void setFlag(char key, boolean val) { + b[((int) key) & 0xFF] = val; } - case '-': { - float scale = water.getBumpScale(); - if (scale > -1) - water.setBumpScale(scale - bumpIncrement); - break; + + private boolean getFlag(char key) { + return b[((int) key) & 0xFF]; } - case '=': { - float scale = water.getBumpScale(); - if (scale < 1) - water.setBumpScale(scale + bumpIncrement); - break; + + private void checkExtension(GL gl, String extensionName) { + if (!gl.isExtensionAvailable(extensionName)) { + String message = "Unable to initialize " + extensionName + " OpenGL extension"; + JOptionPane.showMessageDialog(null, message, "Unavailable extension", JOptionPane.ERROR_MESSAGE); + shutdownDemo(); + } } - case 'l': - water.enableBoundaryApplication(getFlag('l')); - break; - case 'o': - water.enableSpinningLogo(getFlag('o')); - break; - case '.': { - float frequency = water.getBumpScale(); - if (frequency < 1) - water.setDropFrequency(frequency + frequencyIncrement); - break; + + private void dispatchKey(char k) { + setFlag(k, !getFlag(k)); + + switch (k) { + case 27: + case 'q': + shutdownDemo(); + break; + case 'w': + water.enableWireframe(getFlag('w')); + break; + case 'd': + // FIXME + /* + + if (getKey('d')) { + glutMouseFunc(glh::glut_mouse_function); + glutMotionFunc(glh::glut_motion_function); + } + else + { + glutMouseFunc(Mouse); + glutMotionFunc(Motion); + } + */ + break; + case ' ': + water.enableAnimation(getFlag(' ')); + break; + case 'b': + water.enableBorderWrapping(getFlag('b')); + break; + case 'n': + water.singleStep(); + break; + case 's': + water.enableSlowAnimation(getFlag('s')); + break; + case '1': + water.setRenderMode(Water.CA_FULLSCREEN_REFLECT); + break; + case '2': + water.setRenderMode(Water.CA_FULLSCREEN_HEIGHT); + break; + case '3': + water.setRenderMode(Water.CA_FULLSCREEN_FORCE); + break; + case '4': + water.setRenderMode(Water.CA_FULLSCREEN_NORMALMAP); + break; + case '5': + water.setRenderMode(Water.CA_TILED_THREE_WINDOWS); + break; + case 'r': + water.reset(); + break; + case 'i': + // FIXME: make sure this is what this does + doViewAll = true; + // gluPerspective(90, 1, .01, 10); + break; + case 'c': { + float dist = water.getBlurDistance(); + if (dist > blurIncrement) { + water.setBlurDistance(dist - blurIncrement); + } + break; + } + case 'v': { + float dist = water.getBlurDistance(); + if (dist < 1) { + water.setBlurDistance(dist + blurIncrement); + } + break; + } + case '-': { + float scale = water.getBumpScale(); + if (scale > -1) { + water.setBumpScale(scale - bumpIncrement); + } + break; + } + case '=': { + float scale = water.getBumpScale(); + if (scale < 1) { + water.setBumpScale(scale + bumpIncrement); + } + break; + } + case 'l': + water.enableBoundaryApplication(getFlag('l')); + break; + case 'o': + water.enableSpinningLogo(getFlag('o')); + break; + case '.': { + float frequency = water.getBumpScale(); + if (frequency < 1) { + water.setDropFrequency(frequency + frequencyIncrement); + } + break; + } + case ',': { + float frequency = water.getBumpScale(); + if (frequency > 0) { + water.setDropFrequency(frequency - frequencyIncrement); + } + break; + } + default: + break; + } } - case ',': { - float frequency = water.getBumpScale(); - if (frequency > 0) - water.setDropFrequency(frequency - frequencyIncrement); - break; + + private static void runExit(final Animator animator) { + // Note: calling System.exit() synchronously inside the draw, + // reshape or init callbacks can lead to deadlocks on certain + // platforms (in particular, X11) because the JAWT's locking + // routines cause a global AWT lock to be grabbed. Run the + // exit routine in another thread. + new Thread(new Runnable() { + + public void run() { + animator.stop(); + System.exit(0); + } + }).start(); } - default: - break; + + + + public static void main(String[] args) { + new ProceduralTexturePhysics(); } - } - - private static void runExit(final Animator animator) { - // Note: calling System.exit() synchronously inside the draw, - // reshape or init callbacks can lead to deadlocks on certain - // platforms (in particular, X11) because the JAWT's locking - // routines cause a global AWT lock to be grabbed. Run the - // exit routine in another thread. - new Thread(new Runnable() { - public void run() { - animator.stop(); - System.exit(0); - } - }).start(); - } } diff --git a/src/demos/proceduralTexturePhysics/Water.java b/src/demos/proceduralTexturePhysics/Water.java index 50be158..566b848 100644 --- a/src/demos/proceduralTexturePhysics/Water.java +++ b/src/demos/proceduralTexturePhysics/Water.java @@ -33,19 +33,28 @@ package demos.proceduralTexturePhysics; -import java.awt.Image; -import java.awt.image.*; -import java.io.*; -import java.nio.*; -import java.text.*; -import java.util.*; - -import gleem.linalg.*; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.texture.*; -import demos.util.*; +import com.sun.opengl.impl.io.FileUtil; +import com.sun.opengl.util.texture.Texture; +import com.sun.opengl.util.texture.TextureData; +import com.sun.opengl.util.texture.TextureIO; +import demos.util.Cubemap; +import gleem.linalg.Mat4f; +import gleem.linalg.Rotf; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLPbuffer; +import javax.media.opengl.glu.GLU; + + /** * Auxiliary Water simulation class used by ProceduralTexturePhysics @@ -226,22 +235,22 @@ public class Water { pbuffer.display(); } - public void draw(GL gl, Rotf cameraOrientation) { + public void draw(GL2 gl, Rotf cameraOrientation) { this.cameraOrientation.set(cameraOrientation); if (skipCount >= skipInterval && renderMode != CA_DO_NOT_RENDER) { skipCount = 0; // Display the results of the rendering to texture if (wireframe) { - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE); + gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE); // chances are the texture will be all dark, so lets not use a texture - gl.glDisable(GL.GL_TEXTURE_2D); + gl.glDisable(GL2.GL_TEXTURE_2D); } else { - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL); + gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL); - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glEnable(GL.GL_TEXTURE_2D); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glEnable(GL2.GL_TEXTURE_2D); } switch (renderMode) { @@ -259,51 +268,51 @@ public class Water { gl.glCallList(displayListIDs[CA_FRAGMENT_PROGRAM_REFLECT]); // Draw quad over full display - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(); dynamicTextures[CA_TEXTURE_NORMAL_MAP].disable(); - gl.glActiveTexture(GL.GL_TEXTURE3); + gl.glActiveTexture(GL2.GL_TEXTURE3); cubemap.bind(); cubemap.enable(); gl.glColor4f(1, 1, 1, 1); - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); - gl.glMultiTexCoord2f(GL.GL_TEXTURE0, 0,0); - gl.glMultiTexCoord4f(GL.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2), 1); - gl.glMultiTexCoord4f(GL.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2), 1); - gl.glMultiTexCoord4f(GL.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2), 1); + gl.glMultiTexCoord2f(GL2.GL_TEXTURE0, 0,0); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2), 1); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2), 1); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2), 1); gl.glVertex2f(-1,-1); - gl.glMultiTexCoord2f(GL.GL_TEXTURE0, 1,0); - gl.glMultiTexCoord4f(GL.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2), -1); - gl.glMultiTexCoord4f(GL.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2), 1); - gl.glMultiTexCoord4f(GL.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2), 1); + gl.glMultiTexCoord2f(GL2.GL_TEXTURE0, 1,0); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2), -1); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2), 1); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2), 1); gl.glVertex2f( 1,-1); - gl.glMultiTexCoord2f(GL.GL_TEXTURE0, 1,1); - gl.glMultiTexCoord4f(GL.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2), -1); - gl.glMultiTexCoord4f(GL.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2), -1); - gl.glMultiTexCoord4f(GL.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2), 1); + gl.glMultiTexCoord2f(GL2.GL_TEXTURE0, 1,1); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2), -1); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2), -1); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2), 1); gl.glVertex2f( 1, 1); - gl.glMultiTexCoord2f(GL.GL_TEXTURE0, 0,1); - gl.glMultiTexCoord4f(GL.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2), 1); - gl.glMultiTexCoord4f(GL.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2), -1); - gl.glMultiTexCoord4f(GL.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2), 1); + gl.glMultiTexCoord2f(GL2.GL_TEXTURE0, 0,1); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE1, matRot.get(0,0), matRot.get(0,1), matRot.get(0,2), 1); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE2, matRot.get(1,0), matRot.get(1,1), matRot.get(1,2), -1); + gl.glMultiTexCoord4f(GL2.GL_TEXTURE3, matRot.get(2,0), matRot.get(2,1), matRot.get(2,2), 1); gl.glVertex2f(-1, 1); gl.glEnd(); cubemap.disable(); - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glDisable(GL2.GL_FRAGMENT_PROGRAM); break; } case CA_FULLSCREEN_NORMALMAP: { // Draw quad over full display - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(); gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); @@ -312,8 +321,8 @@ public class Water { case CA_FULLSCREEN_HEIGHT: { // Draw quad over full display - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glBindTexture(GL.GL_TEXTURE_2D, texHeightOutput); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texHeightOutput); gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); break; @@ -321,7 +330,7 @@ public class Water { case CA_FULLSCREEN_FORCE: { // Draw quad over full display - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(); gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); @@ -331,9 +340,9 @@ public class Water { case CA_TILED_THREE_WINDOWS: { // Draw quad over full display // lower left - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glTranslatef(-0.5f, -0.5f, 0); @@ -342,7 +351,7 @@ public class Water { gl.glPopMatrix(); // lower right - gl.glBindTexture(GL.GL_TEXTURE_2D, texVelocityOutput); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texVelocityOutput); gl.glPushMatrix(); gl.glTranslatef(0.5f, -0.5f, 0); @@ -352,7 +361,7 @@ public class Water { // upper left dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glTranslatef(-0.5f, 0.5f, 0); @@ -361,8 +370,8 @@ public class Water { gl.glPopMatrix(); // upper right - gl.glBindTexture(GL.GL_TEXTURE_2D, texHeightOutput); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texHeightOutput); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glTranslatef(0.5f, 0.5f, 0); @@ -426,14 +435,16 @@ public class Water { // class Listener implements GLEventListener { + public void init(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); initOpenGL(gl); } public void display(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + + GL2 gl = drawable.getGL().getGL2(); if (mustUpdateBlurOffsets) { updateBlurVertOffset(gl); mustUpdateBlurOffsets = false; @@ -442,7 +453,7 @@ public class Water { // Take a single step in the cellular automaton // Disable culling - gl.glDisable(GL.GL_CULL_FACE); + gl.glDisable(GL2.GL_CULL_FACE); if (reset) { reset = false; @@ -488,7 +499,7 @@ public class Water { initialMapDimensions[1] = initialMapData.getHeight(); } - private void initOpenGL(GL gl) { + private void initOpenGL(GL2 gl) { try { loadTextures(gl, tmpSpinFilename, tmpDropletFilename, tmpCubeMapFilenamePrefix, tmpCubeMapFilenameSuffix); } catch (IOException e) { @@ -499,30 +510,30 @@ public class Water { tmpCubeMapFilenamePrefix = null; tmpCubeMapFilenameSuffix = null; - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluOrtho2D(-1, 1, -1, 1); gl.glClearColor(0, 0, 0, 0); - gl.glDisable(GL.GL_LIGHTING); - gl.glDisable(GL.GL_DEPTH_TEST); + gl.glDisable(GL2.GL_LIGHTING); + gl.glDisable(GL2.GL_DEPTH_TEST); createAndWriteUVOffsets(gl, initialMapDimensions[0], initialMapDimensions[1]); - checkExtension(gl, "GL_ARB_vertex_program"); - checkExtension(gl, "GL_ARB_fragment_program"); - checkExtension(gl, "GL_ARB_multitexture"); + checkExtension(gl, "GL_vertex_program"); + checkExtension(gl, "GL_fragment_program"); + checkExtension(gl, "GL_multitexture"); /////////////////////////////////////////////////////////////////////////// // UV Offset Vertex Program /////////////////////////////////////////////////////////////////////////// int[] tmpInt = new int[1]; - gl.glGenProgramsARB(1, tmpInt, 0); + gl.glGenPrograms(1, tmpInt, 0); vertexProgramID = tmpInt[0]; - gl.glBindProgramARB(GL.GL_VERTEX_PROGRAM_ARB, vertexProgramID); + gl.glBindProgram(GL2.GL_VERTEX_PROGRAM, vertexProgramID); String programBuffer = "!!ARBvp1.0\n" + @@ -600,9 +611,9 @@ public class Water { // set up constants (not currently used in the vertex program, though) float[] rCVConsts = new float[] { 0, 0.5f, 1.0f, 2.0f }; - gl.glProgramEnvParameter4fvARB(GL.GL_VERTEX_PROGRAM_ARB, CV_CONSTS_1, rCVConsts, 0); + gl.glProgramEnvParameter4fv(GL2.GL_VERTEX_PROGRAM, CV_CONSTS_1, rCVConsts, 0); - loadProgram(gl, GL.GL_VERTEX_PROGRAM_ARB, programBuffer); + loadProgram(gl, GL2.GL_VERTEX_PROGRAM, programBuffer); /////////////////////////////////////////////////////////////////////////// // fragment program setup for equal weight combination of texels @@ -650,9 +661,9 @@ public class Water { // display list to render a single screen space quad. /////////////////////////////////////////////////////////////////////////// displayListIDs[CA_DRAW_SCREEN_QUAD] = gl.glGenLists(1); - gl.glNewList(displayListIDs[CA_DRAW_SCREEN_QUAD], GL.GL_COMPILE); + gl.glNewList(displayListIDs[CA_DRAW_SCREEN_QUAD], GL2.GL_COMPILE); gl.glColor4f(1, 1, 1, 1); - gl.glBegin(GL.GL_TRIANGLE_STRIP); + gl.glBegin(GL2.GL_TRIANGLE_STRIP); gl.glTexCoord2f(0, 1); gl.glVertex2f(-1, 1); gl.glTexCoord2f(0, 0); gl.glVertex2f(-1, -1); gl.glTexCoord2f(1, 1); gl.glVertex2f( 1, 1); @@ -667,7 +678,7 @@ public class Water { } } - private void doSingleTimeStep(GL gl) { + private void doSingleTimeStep(GL2 gl) { int temp; // Swap texture source & target indices & pointers @@ -684,14 +695,14 @@ public class Water { // Clear initial velocity texture to 0x80 == gray gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f); - gl.glClear(GL.GL_COLOR_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT); // Now we need to copy the resulting pixels into the intermediate force field texture - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glBindTexture(GL.GL_TEXTURE_2D, texVelocityInput); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texVelocityInput); // use CopyTexSubImage for speed (even though we copy all of it) since we pre-allocated the texture - gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); + gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); break; @@ -718,7 +729,7 @@ public class Water { } // even if wireframe mode, render to texture as solid - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL); + gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL); ///////////////////////////////////////////////////////////// // Render first 3 components of force from three neighbors @@ -732,36 +743,36 @@ public class Water { // set current source texture for stage 0 texture for (int i = 0; i < 4; i++) { - gl.glActiveTexture(GL.GL_TEXTURE0 + i); - gl.glBindTexture(GL.GL_TEXTURE_2D, texHeightInput); - gl.glEnable(GL.GL_TEXTURE_2D); + gl.glActiveTexture(GL2.GL_TEXTURE0 + i); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texHeightInput); + gl.glEnable(GL2.GL_TEXTURE_2D); } - int wrapMode = wrap ? GL.GL_REPEAT : GL.GL_CLAMP_TO_EDGE; - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, wrapMode); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, wrapMode); + int wrapMode = wrap ? GL2.GL_REPEAT : GL2.GL_CLAMP_TO_EDGE; + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, wrapMode); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, wrapMode); // disable blending - gl.glDisable(GL.GL_BLEND); + gl.glDisable(GL2.GL_BLEND); // render using offset 1 (type 1 -- center + 3 of 4 nearest neighbors). - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, CV_UV_OFFSET_TO_USE, 1, 0, 0, 0); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, CV_UV_OFFSET_TO_USE, 1, 0, 0, 0); // bind the vertex program to be used for this step and the next one. - gl.glBindProgramARB(GL.GL_VERTEX_PROGRAM_ARB, vertexProgramID); - gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); + gl.glBindProgram(GL2.GL_VERTEX_PROGRAM, vertexProgramID); + gl.glEnable(GL2.GL_VERTEX_PROGRAM); // render a screen quad. with texture coords doing difference of nearby texels for force calc. gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glDisable(GL2.GL_FRAGMENT_PROGRAM); // Now we need to copy the resulting pixels into the intermediate force field texture - gl.glActiveTexture(GL.GL_TEXTURE2); + gl.glActiveTexture(GL2.GL_TEXTURE2); dynamicTextures[CA_TEXTURE_FORCE_INTERMEDIATE].bind(); // use CopyTexSubImage for speed (even though we copy all of it) since we pre-allocated the texture - gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); + gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); //////////////////////////////////////////////////////////////// // Now add in last component of force for the 4th neighbor @@ -783,27 +794,27 @@ public class Water { //; t2 = previous partial result texture sampled at center (result of last phase copied to texture) //; t3 = not used (disable now) - gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, wrapMode); - gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, wrapMode); + gl.glTexParameterf(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, wrapMode); + gl.glTexParameterf(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, wrapMode); - gl.glActiveTexture(GL.GL_TEXTURE3); - gl.glDisable(GL.GL_TEXTURE_2D); + gl.glActiveTexture(GL2.GL_TEXTURE3); + gl.glDisable(GL2.GL_TEXTURE_2D); // vertex program already bound. // render using offset 2 (type 2 -- final nearest neighbor plus center of previous result). - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, CV_UV_OFFSET_TO_USE, 2, 0, 0, 0); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, CV_UV_OFFSET_TO_USE, 2, 0, 0, 0); // render a screen quad gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glDisable(GL2.GL_FRAGMENT_PROGRAM); // Now we need to copy the resulting pixels into the intermediate force field texture - gl.glActiveTexture(GL.GL_TEXTURE1); + gl.glActiveTexture(GL2.GL_TEXTURE1); dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(); // use CopyTexSubImage for speed (even though we copy all of it) since we pre-allocated the texture - gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); + gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); ///////////////////////////////////////////////////////////////// // Apply the force with a scale factor to reduce it's magnitude. @@ -812,23 +823,23 @@ public class Water { gl.glCallList(displayListIDs[CA_FRAGMENT_PROGRAM_APPLY_FORCE]); // use offsets of zero - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, CV_UV_OFFSET_TO_USE, 0, 0, 0, 0); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, CV_UV_OFFSET_TO_USE, 0, 0, 0, 0); // bind the vertex program to be used for this step and the next one. - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glBindTexture(GL.GL_TEXTURE_2D, texVelocityInput); - gl.glActiveTexture(GL.GL_TEXTURE1); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texVelocityInput); + gl.glActiveTexture(GL2.GL_TEXTURE1); dynamicTextures[CA_TEXTURE_FORCE_TARGET].bind(); - gl.glActiveTexture(GL.GL_TEXTURE2); - gl.glDisable(GL.GL_TEXTURE_2D); - gl.glActiveTexture(GL.GL_TEXTURE3); - gl.glDisable(GL.GL_TEXTURE_2D); + gl.glActiveTexture(GL2.GL_TEXTURE2); + gl.glDisable(GL2.GL_TEXTURE_2D); + gl.glActiveTexture(GL2.GL_TEXTURE3); + gl.glDisable(GL2.GL_TEXTURE_2D); // Draw the quad to add in force. gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glDisable(GL2.GL_FRAGMENT_PROGRAM); /////////////////////////////////////////////////////////////////// // With velocity texture selected, render new excitation droplets @@ -851,36 +862,36 @@ public class Water { } // Now we need to copy the resulting pixels into the velocity texture - gl.glActiveTexture(GL.GL_TEXTURE1); - gl.glBindTexture(GL.GL_TEXTURE_2D, texVelocityOutput); + gl.glActiveTexture(GL2.GL_TEXTURE1); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texVelocityOutput); // use CopyTexSubImage for speed (even though we copy all of it) since we pre-allocated the texture - gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); + gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); ////////////////////////////////////////////////////////////////////// // Apply velocity to position gl.glCallList(displayListIDs[CA_FRAGMENT_PROGRAM_APPLY_VELOCITY]); - gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); + gl.glEnable(GL2.GL_VERTEX_PROGRAM); - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glBindTexture(GL.GL_TEXTURE_2D, texHeightInput); - gl.glActiveTexture(GL.GL_TEXTURE1); // velocity output already bound - gl.glEnable(GL.GL_TEXTURE_2D); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texHeightInput); + gl.glActiveTexture(GL2.GL_TEXTURE1); // velocity output already bound + gl.glEnable(GL2.GL_TEXTURE_2D); // use offsets of zero - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, CV_UV_OFFSET_TO_USE, 0, 0, 0, 0); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, CV_UV_OFFSET_TO_USE, 0, 0, 0, 0); // Draw the quad to add in force. gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glDisable(GL2.GL_FRAGMENT_PROGRAM); // Now we need to copy the resulting pixels into the input height texture - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glBindTexture(GL.GL_TEXTURE_2D, texHeightInput); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texHeightInput); // use CopyTexSubImage for speed (even though we copy all of it) since we pre-allocated the texture - gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); + gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); /////////////////////////////////////////////////////////////////// // blur positions to smooth noise & generaly dampen things @@ -888,31 +899,31 @@ public class Water { // offsets with bilinear on for (int i = 1; i < 4; i++) { - gl.glActiveTexture(GL.GL_TEXTURE0 + i); - gl.glBindTexture(GL.GL_TEXTURE_2D, texHeightInput); - gl.glEnable(GL.GL_TEXTURE_2D); + gl.glActiveTexture(GL2.GL_TEXTURE0 + i); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texHeightInput); + gl.glEnable(GL2.GL_TEXTURE_2D); } // use offsets of 3 - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, CV_UV_OFFSET_TO_USE, 3, 0, 0, 0); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, CV_UV_OFFSET_TO_USE, 3, 0, 0, 0); gl.glCallList(displayListIDs[CA_FRAGMENT_PROGRAM_EQ_WEIGHT_COMBINE]); gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glDisable(GL2.GL_FRAGMENT_PROGRAM); // Draw the logo in the water. if (applyInteriorBoundaries) { - gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); + gl.glDisable(GL2.GL_VERTEX_PROGRAM); drawInteriorBoundaryObjects(gl); } // Now we need to copy the resulting pixels into the velocity texture - gl.glActiveTexture(GL.GL_TEXTURE0); - gl.glBindTexture(GL.GL_TEXTURE_2D, texHeightOutput); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texHeightOutput); // use CopyTexSubImage for speed (even though we copy all of it) since we pre-allocated the texture - gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); + gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); /////////////////////////////////////////////////////////////////// // If selected, create a normal map from the height @@ -936,67 +947,67 @@ public class Water { } } - private void createNormalMap(GL gl) { + private void createNormalMap(GL2 gl) { // use the height output on all four texture stages for (int i = 0; i < 4; i++) { - gl.glActiveTexture(GL.GL_TEXTURE0 + i); - gl.glBindTexture(GL.GL_TEXTURE_2D, texHeightOutput); - gl.glEnable(GL.GL_TEXTURE_2D); + gl.glActiveTexture(GL2.GL_TEXTURE0 + i); + gl.glBindTexture(GL2.GL_TEXTURE_2D, texHeightOutput); + gl.glEnable(GL2.GL_TEXTURE_2D); } // Set constants for red & green scale factors (also essential color masks) // Red mask first float[] pixMasks = new float[] { normalSTScale, 0.0f, 0.0f, 0.0f }; - gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 0, pixMasks, 0); + gl.glProgramEnvParameter4fv(GL2.GL_FRAGMENT_PROGRAM, 0, pixMasks, 0); // Now green mask & scale: pixMasks[0] = 0.0f; pixMasks[1] = normalSTScale; - gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 1, pixMasks, 0); + gl.glProgramEnvParameter4fv(GL2.GL_FRAGMENT_PROGRAM, 1, pixMasks, 0); gl.glCallList(displayListIDs[CA_FRAGMENT_PROGRAM_CREATE_NORMAL_MAP]); // set vp offsets to nearest neighbors - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, CV_UV_OFFSET_TO_USE, 4, 0, 0, 0); - gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, CV_UV_OFFSET_TO_USE, 4, 0, 0, 0); + gl.glEnable(GL2.GL_VERTEX_PROGRAM); gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glDisable(GL2.GL_FRAGMENT_PROGRAM); // Now we need to copy the resulting pixels into the normal map - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); dynamicTextures[CA_TEXTURE_NORMAL_MAP].bind(); // use CopyTexSubImage for speed (even though we copy all of it) since we pre-allocated the texture - gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); + gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, initialMapDimensions[0], initialMapDimensions[1]); } - private void drawInteriorBoundaryObjects(GL gl) { - gl.glDisable(GL.GL_REGISTER_COMBINERS_NV); + private void drawInteriorBoundaryObjects(GL2 gl) { + gl.glDisable(GL2.GL_REGISTER_COMBINERS_NV); - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); initialMapTex.bind(); initialMapTex.enable(); - gl.glEnable(GL.GL_ALPHA_TEST); + gl.glEnable(GL2.GL_ALPHA_TEST); // disable other texture units. for (int i = 1; i < 4; i++) { - gl.glActiveTexture(GL.GL_TEXTURE0 + i); - gl.glDisable(GL.GL_TEXTURE_2D); + gl.glActiveTexture(GL2.GL_TEXTURE0 + i); + gl.glDisable(GL2.GL_TEXTURE_2D); } - gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); - gl.glEnable(GL.GL_BLEND); + gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA); + gl.glEnable(GL2.GL_BLEND); gl.glCallList(displayListIDs[CA_DRAW_SCREEN_QUAD]); if (spinLogo) { - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); spinTex.bind(); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPushMatrix(); gl.glRotatef(angle, 0, 0, 1); angle += 1; @@ -1006,8 +1017,8 @@ public class Water { gl.glPopMatrix(); } - gl.glDisable(GL.GL_ALPHA_TEST); - gl.glDisable(GL.GL_BLEND); + gl.glDisable(GL2.GL_ALPHA_TEST); + gl.glDisable(GL2.GL_BLEND); } private void loadTextures(GL gl, @@ -1045,7 +1056,7 @@ public class Water { texVelocityOutput = dynamicTextures[CA_TEXTURE_VELOCITY_TARGET].getTextureObject(); // next velocity. } - private void createAndWriteUVOffsets(GL gl, int width, int height) { + private void createAndWriteUVOffsets(GL2 gl, int width, int height) { // This sets vertex shader constants used to displace the // source texture over several additive samples. This is // used to accumulate neighboring texel information that we @@ -1105,14 +1116,14 @@ public class Water { float type2Offset[] = { type2OffsetX[i], type2OffsetY[i], 0.0f, 0.0f }; float type4Offset[] = { type4OffsetX[i], type4OffsetY[i], 0.0f, 0.0f }; - gl.glProgramEnvParameter4fvARB(GL.GL_VERTEX_PROGRAM_ARB, CV_UV_T0_NO_OFFSET + 5 * i, noOffset, 0); - gl.glProgramEnvParameter4fvARB(GL.GL_VERTEX_PROGRAM_ARB, CV_UV_T0_TYPE1 + 5 * i, type1Offset, 0); - gl.glProgramEnvParameter4fvARB(GL.GL_VERTEX_PROGRAM_ARB, CV_UV_T0_TYPE2 + 5 * i, type2Offset, 0); - gl.glProgramEnvParameter4fvARB(GL.GL_VERTEX_PROGRAM_ARB, CV_UV_T0_TYPE4 + 5 * i, type4Offset, 0); + gl.glProgramEnvParameter4fv(GL2.GL_VERTEX_PROGRAM, CV_UV_T0_NO_OFFSET + 5 * i, noOffset, 0); + gl.glProgramEnvParameter4fv(GL2.GL_VERTEX_PROGRAM, CV_UV_T0_TYPE1 + 5 * i, type1Offset, 0); + gl.glProgramEnvParameter4fv(GL2.GL_VERTEX_PROGRAM, CV_UV_T0_TYPE2 + 5 * i, type2Offset, 0); + gl.glProgramEnvParameter4fv(GL2.GL_VERTEX_PROGRAM, CV_UV_T0_TYPE4 + 5 * i, type4Offset, 0); } } - private void updateBlurVertOffset(GL gl) { + private void updateBlurVertOffset(GL2 gl) { float[] type3OffsetX = new float[] { -perTexelWidth * 0.5f, perTexelWidth, perTexelWidth * 0.5f, @@ -1128,25 +1139,25 @@ public class Water { for (int i = 0; i < 4; ++i) { offsets[0] = blurDist * ( type3OffsetX[i]); offsets[1] = blurDist * ( type3OffsetY[i]); - gl.glProgramEnvParameter4fvARB(GL.GL_VERTEX_PROGRAM_ARB, CV_UV_T0_TYPE3 + 5 * i, offsets, 0); + gl.glProgramEnvParameter4fv(GL2.GL_VERTEX_PROGRAM, CV_UV_T0_TYPE3 + 5 * i, offsets, 0); } } - private synchronized void drawDroplets(GL gl) { - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); - gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); + private synchronized void drawDroplets(GL2 gl) { + gl.glDisable(GL2.GL_FRAGMENT_PROGRAM); + gl.glDisable(GL2.GL_VERTEX_PROGRAM); - gl.glActiveTexture(GL.GL_TEXTURE0); + gl.glActiveTexture(GL2.GL_TEXTURE0); dropletTex.bind(); dropletTex.enable(); - gl.glActiveTexture(GL.GL_TEXTURE1); - gl.glDisable(GL.GL_TEXTURE_2D); + gl.glActiveTexture(GL2.GL_TEXTURE1); + gl.glDisable(GL2.GL_TEXTURE_2D); - gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE); - gl.glEnable(GL.GL_BLEND); + gl.glBlendFunc(GL2.GL_ONE, GL2.GL_ONE); + gl.glEnable(GL2.GL_BLEND); - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); gl.glColor4f(1, 1, 1, 1); for (Iterator iter = droplets.iterator(); iter.hasNext(); ) { Droplet droplet = (Droplet) iter.next(); @@ -1164,14 +1175,14 @@ public class Water { } gl.glEnd(); - gl.glDisable(GL.GL_BLEND); + gl.glDisable(GL2.GL_BLEND); } //---------------------------------------------------------------------- // Inlined register combiner and texture shader programs // (don't want to port nvparse as it's a dead-end; we'll focus on Cg instead) - private void initEqWeightCombine_PostMult(GL gl, int displayListID) { + private void initEqWeightCombine_PostMult(GL2 gl, int displayListID) { // Take samples of all four texture inputs and average them, // adding on a bias // @@ -1212,9 +1223,9 @@ public class Water { float[] const0 = new float[] { 0.5f, 0.5f, 0.5f, 1.0f }; int[] tmpInt = new int[1]; - gl.glGenProgramsARB(1, tmpInt, 0); + gl.glGenPrograms(1, tmpInt, 0); int fragProg = tmpInt[0]; - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); String program = "!!ARBfp1.0\n" + @@ -1236,16 +1247,16 @@ public class Water { "\n" + "END\n"; - loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); + loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM, program); - gl.glNewList(displayListID, GL.GL_COMPILE); - gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 0, const0, 0); - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glNewList(displayListID, GL2.GL_COMPILE); + gl.glProgramEnvParameter4fv(GL2.GL_FRAGMENT_PROGRAM, 0, const0, 0); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); + gl.glEnable(GL2.GL_FRAGMENT_PROGRAM); gl.glEndList(); } - private void initNeighborForceCalcStep1(GL gl, int displayListID) { + private void initNeighborForceCalcStep1(GL2 gl, int displayListID) { // Step one in the nearest-neighbor force calculation for height-based water // simulation. NeighborForceCalc2 is the second step. // @@ -1339,9 +1350,9 @@ public class Water { float[] const0 = new float[] { 0.5f, 0.5f, 0.5f, 1.0f }; int[] tmpInt = new int[1]; - gl.glGenProgramsARB(1, tmpInt, 0); + gl.glGenPrograms(1, tmpInt, 0); int fragProg = tmpInt[0]; - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); String program = "!!ARBfp1.0\n" + @@ -1380,16 +1391,16 @@ public class Water { "\n" + "END\n"; - loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); + loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM, program); - gl.glNewList(displayListID, GL.GL_COMPILE); - gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 0, const0, 0); - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glNewList(displayListID, GL2.GL_COMPILE); + gl.glProgramEnvParameter4fv(GL2.GL_FRAGMENT_PROGRAM, 0, const0, 0); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); + gl.glEnable(GL2.GL_FRAGMENT_PROGRAM); gl.glEndList(); } - private void initNeighborForceCalcStep2(GL gl, int displayListID) { + private void initNeighborForceCalcStep2(GL2 gl, int displayListID) { // 2nd step of force calc for render-to-texture // water simulation. // @@ -1426,9 +1437,9 @@ public class Water { // } int[] tmpInt = new int[1]; - gl.glGenProgramsARB(1, tmpInt, 0); + gl.glGenPrograms(1, tmpInt, 0); int fragProg = tmpInt[0]; - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); String program = "!!ARBfp1.0\n" + @@ -1444,15 +1455,15 @@ public class Water { "\n" + "END\n"; - loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); + loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM, program); - gl.glNewList(displayListID, GL.GL_COMPILE); - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glNewList(displayListID, GL2.GL_COMPILE); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); + gl.glEnable(GL2.GL_FRAGMENT_PROGRAM); gl.glEndList(); } - private void initApplyForce(GL gl, int displayListID) { + private void initApplyForce(GL2 gl, int displayListID) { // This shader samples t1, biases its value to a signed number, and applies this // value multiplied by a scale factor to the t0 sample. // @@ -1498,9 +1509,9 @@ public class Water { float[] const1 = new float[] { 0.5f, 0.5f, 0.5f, 1.0f }; int[] tmpInt = new int[1]; - gl.glGenProgramsARB(1, tmpInt, 0); + gl.glGenPrograms(1, tmpInt, 0); int fragProg = tmpInt[0]; - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); String program = "!!ARBfp1.0\n" + @@ -1521,17 +1532,17 @@ public class Water { "\n" + "END\n"; - loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); + loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM, program); - gl.glNewList(displayListID, GL.GL_COMPILE); - gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 0, const0, 0); - gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 1, const1, 0); - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glNewList(displayListID, GL2.GL_COMPILE); + gl.glProgramEnvParameter4fv(GL2.GL_FRAGMENT_PROGRAM, 0, const0, 0); + gl.glProgramEnvParameter4fv(GL2.GL_FRAGMENT_PROGRAM, 1, const1, 0); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); + gl.glEnable(GL2.GL_FRAGMENT_PROGRAM); gl.glEndList(); } - private void initApplyVelocity(GL gl, int displayListID) { + private void initApplyVelocity(GL2 gl, int displayListID) { // This shader samples t1, biases its value to a signed number, and applies this // value multiplied by a scale factor to the t0 sample. // @@ -1577,9 +1588,9 @@ public class Water { float[] const0 = new float[] { 0.5f, 0.5f, 0.5f, 1.0f }; int[] tmpInt = new int[1]; - gl.glGenProgramsARB(1, tmpInt, 0); + gl.glGenPrograms(1, tmpInt, 0); int fragProg = tmpInt[0]; - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); String program = "!!ARBfp1.0\n" + @@ -1599,16 +1610,16 @@ public class Water { "\n" + "END\n"; - loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); + loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM, program); - gl.glNewList(displayListID, GL.GL_COMPILE); - gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 0, const0, 0); - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glNewList(displayListID, GL2.GL_COMPILE); + gl.glProgramEnvParameter4fv(GL2.GL_FRAGMENT_PROGRAM, 0, const0, 0); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); + gl.glEnable(GL2.GL_FRAGMENT_PROGRAM); gl.glEndList(); } - private void initCreateNormalMap(GL gl, int displayListID) { + private void initCreateNormalMap(GL2 gl, int displayListID) { // Neighbor-differencing for RGB normal map creation. Scale factors for s and t // axis components are set in program code. // This does a crude 1-s^2-t^2 calculation for the blue component in order to @@ -1694,9 +1705,9 @@ public class Water { float[] const0 = new float[] { 0.5f, 0.5f, 0.5f, 1.0f }; int[] tmpInt = new int[1]; - gl.glGenProgramsARB(1, tmpInt, 0); + gl.glGenPrograms(1, tmpInt, 0); int fragProg = tmpInt[0]; - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); String program = "!!ARBfp1.0\n" + @@ -1730,15 +1741,15 @@ public class Water { "\n" + "END\n"; - loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); + loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM, program); - gl.glNewList(displayListID, GL.GL_COMPILE); - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glNewList(displayListID, GL2.GL_COMPILE); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); + gl.glEnable(GL2.GL_FRAGMENT_PROGRAM); gl.glEndList(); } - private void initDotProductReflect(GL gl, int displayListID) { + private void initDotProductReflect(GL2 gl, int displayListID) { // Pseudocode for this operation, derived from the NVidia // texture_shader.txt documentation at // http://oss.sgi.com/projects/ogl-sample/registry/NV/texture_shader.txt @@ -1769,9 +1780,9 @@ public class Water { // of a visual difference so they are skipped as well. int[] tmpInt = new int[1]; - gl.glGenProgramsARB(1, tmpInt, 0); + gl.glGenPrograms(1, tmpInt, 0); int fragProg = tmpInt[0]; - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); String program = "!!ARBfp1.0\n" + @@ -1793,29 +1804,29 @@ public class Water { "\n" + "END"; - loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); + loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM, program); - gl.glNewList(displayListID, GL.GL_COMPILE); - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glNewList(displayListID, GL2.GL_COMPILE); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); + gl.glEnable(GL2.GL_FRAGMENT_PROGRAM); gl.glEndList(); } - private void loadProgram(GL gl, + private void loadProgram(GL2 gl, int target, String programBuffer) { - gl.glProgramStringARB(target, GL.GL_PROGRAM_FORMAT_ASCII_ARB, programBuffer.length(), programBuffer); + gl.glProgramString(target, GL2.GL_PROGRAM_FORMAT_ASCII, programBuffer.length(), programBuffer); int[] errPos = new int[1]; - gl.glGetIntegerv(GL.GL_PROGRAM_ERROR_POSITION_ARB, errPos, 0); + gl.glGetIntegerv(GL2.GL_PROGRAM_ERROR_POSITION, errPos, 0); if (errPos[0] >= 0) { String kind = "Program"; - if (target == GL.GL_VERTEX_PROGRAM_ARB) { + if (target == GL2.GL_VERTEX_PROGRAM) { kind = "Vertex program"; - } else if (target == GL.GL_FRAGMENT_PROGRAM_ARB) { + } else if (target == GL2.GL_FRAGMENT_PROGRAM) { kind = "Fragment program"; } System.out.println(kind + " failed to load:"); - String errMsg = gl.glGetString(GL.GL_PROGRAM_ERROR_STRING_ARB); + String errMsg = gl.glGetString(GL2.GL_PROGRAM_ERROR_STRING); if (errMsg == null) { System.out.println("[No error message available]"); } else { @@ -1829,10 +1840,10 @@ public class Water { System.out.println(programBuffer.substring(errPos[0], endPos)); throw new GLException("Error loading " + kind); } else { - if (target == GL.GL_FRAGMENT_PROGRAM_ARB) { + if (target == GL2.GL_FRAGMENT_PROGRAM) { int[] isNative = new int[1]; - gl.glGetProgramivARB(GL.GL_FRAGMENT_PROGRAM_ARB, - GL.GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, + gl.glGetProgramiv(GL2.GL_FRAGMENT_PROGRAM, + GL2.GL_PROGRAM_UNDER_NATIVE_LIMITS, isNative, 0); if (isNative[0] != 1) { System.out.println("WARNING: fragment program is over native resource limits"); diff --git a/src/demos/tess/Tess.java b/src/demos/tess/Tess.java index 555214f..9709de7 100644 --- a/src/demos/tess/Tess.java +++ b/src/demos/tess/Tess.java @@ -42,6 +42,17 @@ package demos.tess; +import java.awt.Frame; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.DebugGL2; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.media.opengl.glu.GLUtessellator; + /** * tess.java * This program demonstrates polygon tessellation. @@ -58,13 +69,7 @@ package demos.tess; * @author Ported by Nathan Parker Burg, July 2003 */ -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import java.awt.*; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; public class Tess { public static void main(String[] args) { @@ -87,21 +92,22 @@ public class Tess { }).start(); } }); - frame.show(); + frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } public static class TessRenderer implements GLEventListener { - private GL gl; + private GL2 gl; private GLU glu = new GLU(); private int startList; public void init(GLAutoDrawable drawable) { - drawable.setGL(new DebugGL(drawable.getGL())); - gl = drawable.getGL(); + gl = drawable.getGL().getGL2(); + + drawable.setGL(new DebugGL2(gl)); double[][] rect = new double[][]{{50.0, 50.0, 0.0}, {200.0, 50.0, 0.0}, @@ -128,8 +134,8 @@ public class Tess { glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback); - gl.glNewList(startList, GL.GL_COMPILE); - gl.glShadeModel(GL.GL_FLAT); + gl.glNewList(startList, GL2.GL_COMPILE); + gl.glShadeModel(GL2.GL_FLAT); glu.gluTessBeginPolygon(tobj, null); glu.gluTessBeginContour(tobj); glu.gluTessVertex(tobj, rect[0], 0, rect[0]); @@ -151,8 +157,8 @@ public class Tess { glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback); glu.gluTessCallback(tobj, GLU.GLU_TESS_COMBINE, tessCallback); - gl.glNewList(startList + 1, GL.GL_COMPILE); - gl.glShadeModel(GL.GL_SMOOTH); + gl.glNewList(startList + 1, GL2.GL_COMPILE); + gl.glShadeModel(GL2.GL_SMOOTH); glu.gluTessProperty(tobj, GLU.GLU_TESS_WINDING_RULE, GLU.GLU_TESS_WINDING_POSITIVE); glu.gluTessBeginPolygon(tobj, null); glu.gluTessBeginContour(tobj); @@ -169,10 +175,10 @@ public class Tess { public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho( 0, 450, 0, 250, -1, 1 ); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); } @@ -180,7 +186,7 @@ public class Tess { } public void display(GLAutoDrawable drawable) { - gl.glClear(GL.GL_COLOR_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT); gl.glColor3d(1.0, 1.0, 1.0); gl.glCallList(startList); gl.glCallList(startList + 1); @@ -191,10 +197,10 @@ public class Tess { public static class TessCallback extends javax.media.opengl.glu.GLUtessellatorCallbackAdapter { - GL gl; + GL2 gl; GLU glu; - public TessCallback(GL gl, GLU glu) { + public TessCallback(GL2 gl, GLU glu) { this.gl = gl; this.glu = glu; }; diff --git a/src/demos/testContextDestruction/TestContextDestruction.java b/src/demos/testContextDestruction/TestContextDestruction.java index 1355d11..a2344bc 100755 --- a/src/demos/testContextDestruction/TestContextDestruction.java +++ b/src/demos/testContextDestruction/TestContextDestruction.java @@ -39,13 +39,28 @@ package demos.testContextDestruction; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.swing.*; +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Component; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import javax.media.opengl.DebugGL2; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.util.Animator; +import javax.swing.JButton; +import javax.swing.JFrame; + -import javax.media.opengl.*; -import com.sun.opengl.util.*; /** A simple demonstration exercising context creation and destruction as a GLCanvas is added to and removed from its parent container. */ @@ -88,9 +103,9 @@ public class TestContextDestruction { frame2ContainedComponent = emptyCanvas; frame1.pack(); - frame1.show(); + frame1.setVisible(true); frame2.pack(); - frame2.show(); + frame2.setVisible(true); frame2.setLocation(256 + BORDER_WIDTH, 0); JFrame uiFrame = new JFrame("Controls"); @@ -153,7 +168,7 @@ public class TestContextDestruction { }); uiFrame.getContentPane().add(button); uiFrame.pack(); - uiFrame.show(); + uiFrame.setVisible(true); uiFrame.setLocation(512 + BORDER_WIDTH + BORDER_WIDTH, 0); final Animator animator = new Animator(canvas); @@ -178,21 +193,24 @@ public class TestContextDestruction { class Listener implements GLEventListener { public void init(GLAutoDrawable drawable) { + System.out.println("Listener.init()"); - drawable.setGL(new DebugGL(drawable.getGL())); - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); + + drawable.setGL(new DebugGL2(gl)); + float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, pos, 0); - gl.glEnable(GL.GL_CULL_FACE); - gl.glEnable(GL.GL_LIGHTING); - gl.glEnable(GL.GL_LIGHT0); - gl.glEnable(GL.GL_DEPTH_TEST); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0); + gl.glEnable(GL2.GL_CULL_FACE); + gl.glEnable(GL2.GL_LIGHTING); + gl.glEnable(GL2.GL_LIGHT0); + gl.glEnable(GL2.GL_DEPTH_TEST); initializeDisplayList(gl); - gl.glEnable(GL.GL_NORMALIZE); + gl.glEnable(GL2.GL_NORMALIZE); reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); } @@ -200,9 +218,9 @@ public class TestContextDestruction { public void display(GLAutoDrawable drawable) { angle += 2.0f; - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glPushMatrix(); gl.glRotatef(angle, 0.0f, 0.0f, 1.0f); @@ -212,21 +230,21 @@ public class TestContextDestruction { public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { System.out.println("Listener.reshape()"); - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); float h = (float)height / (float)width; - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f, 0.0f, -40.0f); } public void destroy(GLAutoDrawable drawable) { System.out.println("Listener.destroy()"); - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); gl.glDeleteLists(gearDisplayList, 1); gearDisplayList = 0; } @@ -235,16 +253,16 @@ public class TestContextDestruction { public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} } - private synchronized void initializeDisplayList(GL gl) { + private synchronized void initializeDisplayList(GL2 gl) { gearDisplayList = gl.glGenLists(1); - gl.glNewList(gearDisplayList, GL.GL_COMPILE); + gl.glNewList(gearDisplayList, GL2.GL_COMPILE); float red[] = { 0.8f, 0.1f, 0.0f, 1.0f }; - gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, red, 0); + gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT_AND_DIFFUSE, red, 0); gear(gl, 1.0f, 4.0f, 1.0f, 20, 0.7f); gl.glEndList(); } - private void gear(GL gl, + private void gear(GL2 gl, float inner_radius, float outer_radius, float width, @@ -262,12 +280,12 @@ public class TestContextDestruction { da = 2.0f * (float) Math.PI / teeth / 4.0f; - gl.glShadeModel(GL.GL_FLAT); + gl.glShadeModel(GL2.GL_FLAT); gl.glNormal3f(0.0f, 0.0f, 1.0f); /* draw front face */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -282,7 +300,7 @@ public class TestContextDestruction { gl.glEnd(); /* draw front sides of teeth */ - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -294,7 +312,7 @@ public class TestContextDestruction { gl.glEnd(); /* draw back face */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -306,7 +324,7 @@ public class TestContextDestruction { gl.glEnd(); /* draw back sides of teeth */ - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -318,7 +336,7 @@ public class TestContextDestruction { gl.glEnd(); /* draw outward faces of teeth */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -346,10 +364,10 @@ public class TestContextDestruction { gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), -width * 0.5f); gl.glEnd(); - gl.glShadeModel(GL.GL_SMOOTH); + gl.glShadeModel(GL2.GL_SMOOTH); /* draw inside radius cylinder */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; diff --git a/src/demos/testContextSharing/TestContextSharing.java b/src/demos/testContextSharing/TestContextSharing.java index d0be0c1..d83dced 100644 --- a/src/demos/testContextSharing/TestContextSharing.java +++ b/src/demos/testContextSharing/TestContextSharing.java @@ -39,10 +39,16 @@ package demos.testContextSharing; -import java.awt.*; -import java.util.*; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.util.Random; +import javax.media.opengl.DebugGL2; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; + -import javax.media.opengl.*; /** A simple demonstration of sharing of display lists between drawables. */ @@ -80,7 +86,7 @@ public class TestContextSharing { } System.err.println("Showing first frame"); frame.pack(); - frame.show(); + frame.setVisible(true); new Thread(new Runnable() { public void run() { try { @@ -89,48 +95,50 @@ public class TestContextSharing { } System.err.println("Showing other frame"); delayedFrame.pack(); - delayedFrame.show(); + delayedFrame.setVisible(true); delayedFrame.setLocation(256, 0); } }).start(); } class Listener implements GLEventListener { + public void init(GLAutoDrawable drawable) { - drawable.setGL(new DebugGL(drawable.getGL())); - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); + + drawable.setGL(new DebugGL2(gl)); float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, pos, 0); - gl.glEnable(GL.GL_CULL_FACE); - gl.glEnable(GL.GL_LIGHTING); - gl.glEnable(GL.GL_LIGHT0); - gl.glEnable(GL.GL_DEPTH_TEST); + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0); + gl.glEnable(GL2.GL_CULL_FACE); + gl.glEnable(GL2.GL_LIGHTING); + gl.glEnable(GL2.GL_LIGHT0); + gl.glEnable(GL2.GL_DEPTH_TEST); initializeDisplayList(gl); - gl.glEnable(GL.GL_NORMALIZE); + gl.glEnable(GL2.GL_NORMALIZE); } public void display(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); System.err.println("Drawing display list " + gearDisplayList); gl.glCallList(gearDisplayList); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); float h = (float)height / (float)width; - gl.glMatrixMode(GL.GL_PROJECTION); + gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); - gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f, 0.0f, -40.0f); } @@ -139,20 +147,20 @@ public class TestContextSharing { public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} } - private synchronized void initializeDisplayList(GL gl) { + private synchronized void initializeDisplayList(GL2 gl) { if (gearDisplayList != 0) { return; } gearDisplayList = gl.glGenLists(1); - gl.glNewList(gearDisplayList, GL.GL_COMPILE); + gl.glNewList(gearDisplayList, GL2.GL_COMPILE); float red[] = { 0.8f, 0.1f, 0.0f, 1.0f }; - gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, red, 0); + gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT_AND_DIFFUSE, red, 0); gear(gl, 1.0f, 4.0f, 1.0f, 20, 0.7f); gl.glEndList(); } - private void gear(GL gl, + private void gear(GL2 gl, float inner_radius, float outer_radius, float width, @@ -170,12 +178,12 @@ public class TestContextSharing { da = 2.0f * (float) Math.PI / teeth / 4.0f; - gl.glShadeModel(GL.GL_FLAT); + gl.glShadeModel(GL2.GL_FLAT); gl.glNormal3f(0.0f, 0.0f, 1.0f); /* draw front face */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -190,7 +198,7 @@ public class TestContextSharing { gl.glEnd(); /* draw front sides of teeth */ - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -202,7 +210,7 @@ public class TestContextSharing { gl.glEnd(); /* draw back face */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -214,7 +222,7 @@ public class TestContextSharing { gl.glEnd(); /* draw back sides of teeth */ - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -226,7 +234,7 @@ public class TestContextSharing { gl.glEnd(); /* draw outward faces of teeth */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i < teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; @@ -254,10 +262,10 @@ public class TestContextSharing { gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), -width * 0.5f); gl.glEnd(); - gl.glShadeModel(GL.GL_SMOOTH); + gl.glShadeModel(GL2.GL_SMOOTH); /* draw inside radius cylinder */ - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for (i = 0; i <= teeth; i++) { angle = i * 2.0f * (float) Math.PI / teeth; diff --git a/src/demos/texture/TestSubImage.java b/src/demos/texture/TestSubImage.java index b4e395e..f7ddde4 100755 --- a/src/demos/texture/TestSubImage.java +++ b/src/demos/texture/TestSubImage.java @@ -39,20 +39,41 @@ package demos.texture; +import com.sun.opengl.util.texture.Texture; +import com.sun.opengl.util.texture.TextureCoords; +import com.sun.opengl.util.texture.TextureData; +import com.sun.opengl.util.texture.TextureIO; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.GradientPaint; -import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; -import java.awt.event.*; -import java.awt.image.*; -import javax.swing.*; -import java.util.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.KeyStroke; + -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.texture.*; /** Demonstrates and tests updates of sub-rectangles of a Texture generated from a BufferedImage. Draws a cursor in texel space @@ -87,7 +108,7 @@ public class TestSubImage { } public void display(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); if (convertedImage == null) { @@ -165,9 +186,9 @@ public class TestSubImage { // Now draw one quad with the texture texture.enable(); texture.bind(); - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); TextureCoords coords = texture.getImageTexCoords(); - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); gl.glTexCoord2f(coords.left(), coords.bottom()); gl.glVertex3f(0, 0, 0); gl.glTexCoord2f(coords.right(), coords.bottom()); diff --git a/src/demos/texture/TestTexture.java b/src/demos/texture/TestTexture.java index ff0ff14..c32fc8c 100755 --- a/src/demos/texture/TestTexture.java +++ b/src/demos/texture/TestTexture.java @@ -39,14 +39,34 @@ package demos.texture; -import java.awt.geom.*; -import java.awt.event.*; -import java.io.*; -import javax.swing.*; +import com.sun.opengl.util.texture.Texture; +import com.sun.opengl.util.texture.TextureCoords; +import com.sun.opengl.util.texture.TextureIO; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.PrintStream; +import javax.media.opengl.DebugGL2; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; +import javax.swing.KeyStroke; + -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.texture.*; /** Demonstrates simple use of the TextureIO texture loader. */ @@ -109,7 +129,7 @@ public class TestTexture implements GLEventListener { frame.getContentPane().add(canvas); frame.setJMenuBar(menuBar); frame.setSize(800, 600); - frame.show(); + frame.setVisible(true); } private boolean newTexture; @@ -128,9 +148,10 @@ public class TestTexture implements GLEventListener { } public void init(GLAutoDrawable drawable) { - drawable.setGL(new DebugGL(drawable.getGL())); GL gl = drawable.getGL(); + drawable.setGL(new DebugGL2(gl.getGL2())); + gl.glClearColor(0, 0, 0, 0); gl.glEnable(GL.GL_DEPTH_TEST); } @@ -145,7 +166,7 @@ public class TestTexture implements GLEventListener { } public void display(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); if (flushTexture) { @@ -183,10 +204,10 @@ public class TestTexture implements GLEventListener { if (texture != null) { texture.enable(); texture.bind(); - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); TextureCoords coords = texture.getImageTexCoords(); - gl.glBegin(GL.GL_QUADS); + gl.glBegin(GL2.GL_QUADS); gl.glTexCoord2f(coords.left(), coords.bottom()); gl.glVertex3f(0, 0, 0); gl.glTexCoord2f(coords.right(), coords.bottom()); diff --git a/src/demos/texture/TextureConvert.java b/src/demos/texture/TextureConvert.java index 728aa9c..cd0a033 100755 --- a/src/demos/texture/TextureConvert.java +++ b/src/demos/texture/TextureConvert.java @@ -39,12 +39,18 @@ package demos.texture; -import java.io.*; +import com.sun.opengl.impl.io.FileUtil; +import com.sun.opengl.util.texture.Texture; +import com.sun.opengl.util.texture.TextureData; +import com.sun.opengl.util.texture.TextureIO; +import java.io.File; +import java.io.IOException; +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLPbuffer; + -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.texture.*; /** Demonstrates how the TextureIO subsystem may be used to convert textures between multiple file formats, including texture diff --git a/src/demos/util/Bunny.java b/src/demos/util/Bunny.java index b9565d6..c4afd0c 100644 --- a/src/demos/util/Bunny.java +++ b/src/demos/util/Bunny.java @@ -57,7 +57,7 @@ import javax.media.opengl.*; public class Bunny { /** Generates and returns a display list for the bunny model. */ - public static int gen3DObjectList(GL gl) throws IOException { + public static int gen3DObjectList(GL2 gl) throws IOException { StreamTokenizer tok = new StreamTokenizer(new BufferedReader(new InputStreamReader( Bunny.class.getClassLoader().getResourceAsStream("demos/data/models/bunny.txt")))); // Reset tokenizer's syntax so numbers are not parsed @@ -96,7 +96,7 @@ public class Bunny { } int lid = gl.glGenLists(1); - gl.glNewList(lid, GL.GL_COMPILE); + gl.glNewList(lid, GL2.GL_COMPILE); gl.glBegin(GL.GL_TRIANGLES); for (int i = 0; i < faceIndices.length; i += 6) { diff --git a/src/demos/util/Cubemap.java b/src/demos/util/Cubemap.java index 52e2977..61b942a 100755 --- a/src/demos/util/Cubemap.java +++ b/src/demos/util/Cubemap.java @@ -39,15 +39,20 @@ package demos.util; -import java.io.*; +import com.sun.opengl.impl.io.FileUtil; +import com.sun.opengl.util.texture.Texture; +import com.sun.opengl.util.texture.TextureData; +import com.sun.opengl.util.texture.TextureIO; +import java.io.IOException; +import javax.media.opengl.GL; +import javax.media.opengl.GLException; + -import javax.media.opengl.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.texture.*; /** Helper class for loading cubemaps from a set of textures. */ public class Cubemap { + private static final String[] suffixes = { "posx", "negx", "posy", "negy", "posz", "negz" }; private static final int[] targets = { GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, diff --git a/src/demos/util/DxTex.java b/src/demos/util/DxTex.java index 433a2b4..fbe1963 100644 --- a/src/demos/util/DxTex.java +++ b/src/demos/util/DxTex.java @@ -101,7 +101,7 @@ public class DxTex { desktop = new JDesktopPane(); frame.getContentPane().add(desktop); frame.setSize(640, 480); - frame.show(); + frame.setVisible(true); frameListener = new InternalFrameAdapter() { public void internalFrameActivated(InternalFrameEvent e) { @@ -219,7 +219,7 @@ public class DxTex { try { ImageFrame fr = new ImageFrame(filename, image, mipMapLevel); desktop.add(fr); - fr.show(); + fr.setVisible(true); } catch (Exception e) { showMessageDialog("Error while loading file:" + endl + exceptionToString(e), diff --git a/src/demos/util/FPSCounter.java b/src/demos/util/FPSCounter.java index b0ca200..1251d64 100755 --- a/src/demos/util/FPSCounter.java +++ b/src/demos/util/FPSCounter.java @@ -39,12 +39,14 @@ package demos.util; +import com.sun.opengl.util.texture.Texture; import java.awt.Font; -import java.awt.geom.*; -import java.text.*; +import java.awt.geom.Rectangle2D; +import java.text.DecimalFormat; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLException; + -import javax.media.opengl.*; -import com.sun.opengl.util.j2d.*; /** A simple class which uses the TextRenderer to provide an FPS counter overlaid on top of the scene. */ diff --git a/src/demos/util/ObjReader.java b/src/demos/util/ObjReader.java index 51da398..33f5c21 100644 --- a/src/demos/util/ObjReader.java +++ b/src/demos/util/ObjReader.java @@ -39,11 +39,22 @@ package demos.util; -import java.io.*; -import java.nio.*; -import java.util.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.nio.FloatBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; +import javax.media.opengl.util.BufferUtil; + -import com.sun.opengl.util.*; /** Simple parser for Wavefront .OBJ files. Does not support all file options -- currently requires vertices and normals (only) to be diff --git a/src/demos/util/Triceratops.java b/src/demos/util/Triceratops.java index c7fa115..55857f0 100644 --- a/src/demos/util/Triceratops.java +++ b/src/demos/util/Triceratops.java @@ -39,9 +39,15 @@ package demos.util; -import java.io.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StreamTokenizer; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; + -import javax.media.opengl.*; /** Renders a triceratops. <P> @@ -55,7 +61,7 @@ public class Triceratops { /** Draws the triceratops object. Callers should capture the result in a display list. */ - public static void drawObject(GL gl) throws IOException { + public static void drawObject(GL2 gl) throws IOException { Reader reader = new BufferedReader(new InputStreamReader( Triceratops.class.getClassLoader().getResourceAsStream("demos/data/models/triceratops.txt"))); StreamTokenizer tok = new StreamTokenizer(reader); @@ -97,7 +103,7 @@ public class Triceratops { reader.close(); float sf = 0.1f; - gl.glBegin(GL.GL_TRIANGLES); + gl.glBegin(GL2.GL_TRIANGLES); for (int i = 0; i < faceIndices.length; i += 9) { for (int j = 0; j < 3; j++) { int vi = faceIndices[i + j ] & 0xFFFF; diff --git a/src/demos/vertexArrayRange/VertexArrayRange.java b/src/demos/vertexArrayRange/VertexArrayRange.java index 8007232..a91cb10 100644 --- a/src/demos/vertexArrayRange/VertexArrayRange.java +++ b/src/demos/vertexArrayRange/VertexArrayRange.java @@ -33,18 +33,27 @@ package demos.vertexArrayRange; -import java.awt.*; -import java.awt.event.*; -import java.nio.*; -import java.util.*; -import javax.swing.*; - -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.*; -import demos.common.*; -import demos.util.*; +import demos.common.Demo; +import demos.common.DemoListener; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.media.opengl.util.Animator; +import javax.swing.JOptionPane; + + /** <P> A port of NVidia's [tm] Vertex Array Range demonstration to OpenGL[tm] for Java[tm] and the Java programming language. The @@ -119,7 +128,7 @@ public class VertexArrayRange extends Demo { canvas.setSize(800, 800); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); canvas.requestFocus(); animator.start(); @@ -168,7 +177,7 @@ public class VertexArrayRange extends Demo { private float[] cosArray; // Primitive: GL_QUAD_STRIP, GL_LINE_STRIP, or GL_POINTS - private int primitive = GL.GL_QUAD_STRIP; + private int primitive = GL2.GL_QUAD_STRIP; // Animation parameters private float hicoef = .06f; @@ -273,7 +282,7 @@ public class VertexArrayRange extends Demo { // drawable.setGL(new TraceGL(drawable.getGL(), System.err)); // drawable.setGL(new DebugGL(drawable.getGL())); - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); // Try and disable synch-to-retrace for fastest framerate gl.setSwapInterval(0); @@ -303,7 +312,7 @@ public class VertexArrayRange extends Demo { gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, 128.f); gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[] { .5f, 0, .5f, 0}, 0); - gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 0); + gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, 0); // NOTE: it looks like GLUT (or something else) sets up the // projection matrix in the C version of this demo. @@ -325,7 +334,7 @@ public class VertexArrayRange extends Demo { } if (getFlag('v')) { - gl.glEnableClientState(GL.GL_VERTEX_ARRAY_RANGE_NV); + gl.glEnableClientState(GL2.GL_VERTEX_ARRAY_RANGE_NV); gl.glVertexArrayRangeNV(bufferSize, bigArrayVar); bigArray = bigArrayVar; } else { @@ -382,17 +391,17 @@ public class VertexArrayRange extends Demo { if (k == 'w') { if (getFlag(k)) { - primitive = GL.GL_LINE_STRIP; + primitive = GL2.GL_LINE_STRIP; } else { - primitive = GL.GL_QUAD_STRIP; + primitive = GL2.GL_QUAD_STRIP; } } if (k == 'p') { if (getFlag(k)) { - primitive = GL.GL_POINTS; + primitive = GL2.GL_POINTS; } else { - primitive = GL.GL_QUAD_STRIP; + primitive = GL2.GL_QUAD_STRIP; } } @@ -451,7 +460,7 @@ public class VertexArrayRange extends Demo { } public void display(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); // Check to see whether to animate if (getFlag(' ')) { @@ -500,10 +509,10 @@ public class VertexArrayRange extends Demo { if(getFlag('i')) { // infinite light gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[] { .5f, 0, .5f, 0 }, 0); - gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 0); + gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, 0); } else { gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[] { .5f, 0, -.5f, 1 }, 0); - gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 1); + gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, 1); } toggleLightingModel = false; } diff --git a/src/demos/vertexBufferObject/VertexBufferObject.java b/src/demos/vertexBufferObject/VertexBufferObject.java index e58d0fa..efd8ee0 100644 --- a/src/demos/vertexBufferObject/VertexBufferObject.java +++ b/src/demos/vertexBufferObject/VertexBufferObject.java @@ -33,17 +33,29 @@ package demos.vertexBufferObject; -import java.awt.*; -import java.awt.event.*; -import java.nio.*; -import java.util.*; -import javax.swing.*; - -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import demos.common.*; -import demos.util.*; +import demos.common.Demo; +import demos.common.DemoListener; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.media.opengl.util.Animator; +import javax.media.opengl.util.BufferUtil; +import javax.swing.JOptionPane; + + /** <P> A port of NVidia's [tm] Vertex Array Range demonstration to OpenGL[tm] for Java[tm], the Java programming language, and the @@ -55,7 +67,7 @@ import demos.util.*; <ul> <li> A JDK 1.4 implementation - <li> A card supporting the GL_ARB_vertex_buffer_object extension + <li> A card supporting the GL_vertex_buffer_object extension (only in recent drivers) </ul> @@ -64,12 +76,14 @@ import demos.util.*; <P> This demonstration illustrates the use of the java.nio direct buffer classes in JDK 1.4 to access memory outside of the Java garbage-collected heap, in particular that returned from the call - glMapBufferARB, to achieve higher performance than accessing the + glMapBuffer, to achieve higher performance than accessing the same data in system memory allows. </P> */ public class VertexBufferObject extends Demo { + public static void main(String[] args) { + boolean vboEnabled = true; if (args.length > 1) { @@ -85,10 +99,16 @@ public class VertexBufferObject extends Demo { } GLCanvas canvas = new GLCanvas(); - VertexBufferObject demo = new VertexBufferObject(); + final VertexBufferObject demo = new VertexBufferObject(); demo.vboEnabled = vboEnabled; canvas.addGLEventListener(demo); + canvas.addKeyListener(new KeyAdapter() { + public void keyTyped(KeyEvent e) { + demo.dispatchKey(e.getKeyChar()); + } + }); + final Animator animator = new Animator(canvas); animator.setRunAsFastAsPossible(true); demo.setDemoListener(new DemoListener() { @@ -108,7 +128,7 @@ public class VertexBufferObject extends Demo { canvas.setSize(800, 800); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); canvas.requestFocus(); animator.start(); @@ -164,7 +184,7 @@ public class VertexBufferObject extends Demo { private float[] cosArray; // Primitive: GL_QUAD_STRIP, GL_LINE_STRIP, or GL_POINTS - private int primitive = GL.GL_QUAD_STRIP; + private int primitive = GL2.GL_QUAD_STRIP; // Animation parameters private float hicoef = .06f; @@ -187,7 +207,6 @@ public class VertexBufferObject extends Demo { private volatile boolean toggleLighting = false; private volatile boolean toggleLightingModel = false; private volatile boolean recomputeElements = false; - private volatile boolean quit = false; // Frames-per-second computation private boolean firstProfiledFrame; @@ -275,13 +294,13 @@ public class VertexBufferObject extends Demo { // drawable.setGL(new TraceGL(drawable.getGL(), System.err)); // drawable.setGL(new DebugGL(drawable.getGL())); - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); // Try and disable synch-to-retrace for fastest framerate gl.setSwapInterval(0); try { - initExtension(gl, "GL_ARB_vertex_buffer_object"); + initExtension(gl, "GL_vertex_buffer_object"); } catch (RuntimeException e) { throw (e); } @@ -299,7 +318,7 @@ public class VertexBufferObject extends Demo { gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, 128.f); gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[] { .5f, 0, .5f, 0}, 0); - gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 0); + gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, 0); // NOTE: it looks like GLUT (or something else) sets up the // projection matrix in the C version of this demo. @@ -331,11 +350,6 @@ public class VertexBufferObject extends Demo { computeElements(gl); - drawable.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { - dispatchKey(e.getKeyChar()); - } - }); initComplete = true; } @@ -378,7 +392,7 @@ public class VertexBufferObject extends Demo { if (getFlag(k)) { primitive = GL.GL_LINE_STRIP; } else { - primitive = GL.GL_QUAD_STRIP; + primitive = GL2.GL_QUAD_STRIP; } } @@ -386,7 +400,7 @@ public class VertexBufferObject extends Demo { if (getFlag(k)) { primitive = GL.GL_POINTS; } else { - primitive = GL.GL_QUAD_STRIP; + primitive = GL2.GL_QUAD_STRIP; } } @@ -449,7 +463,7 @@ public class VertexBufferObject extends Demo { return; } - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); // Check to see whether to animate if (getFlag(' ')) { @@ -494,10 +508,10 @@ public class VertexBufferObject extends Demo { if(getFlag('i')) { // infinite light gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[] { .5f, 0, .5f, 0 }, 0); - gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 0); + gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, 0); } else { gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[] { .5f, 0, -.5f,1 }, 0); - gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 1); + gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, 1); } toggleLightingModel = false; } @@ -527,16 +541,16 @@ public class VertexBufferObject extends Demo { int numSlabs = tileSize / STRIP_SIZE; if (vboEnabled) { - gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, bigBufferObject); + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, bigBufferObject); } else { - gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, 0); + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } for(int slab = numSlabs; --slab>=0; ) { cur = slab % numBuffers; if (vboEnabled) { - ByteBuffer tmp = gl.glMapBufferARB(GL.GL_ARRAY_BUFFER_ARB, GL.GL_WRITE_ONLY_ARB); + ByteBuffer tmp = gl.glMapBuffer(GL.GL_ARRAY_BUFFER, GL2.GL_WRITE_ONLY); if (tmp == null) { throw new RuntimeException("Unable to map vertex buffer object"); } @@ -618,27 +632,27 @@ public class VertexBufferObject extends Demo { hiX.reset(); if (vboEnabled) { - gl.glUnmapBufferARB(GL.GL_ARRAY_BUFFER_ARB); + gl.glUnmapBuffer(GL.GL_ARRAY_BUFFER); } if (getFlag('m')) { // Elements merged into buffer object (doesn't seem to improve performance) int len = tileSize - 1; - gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, elementBufferObject); + gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, elementBufferObject); for (int i = 0; i < len; i++) { ++numDrawElementsCalls; - gl.glDrawElements(primitive, 2 * STRIP_SIZE, GL.GL_UNSIGNED_INT, + gl.glDrawElements(primitive, 2 * STRIP_SIZE, GL2.GL_UNSIGNED_INT, i * 2 * STRIP_SIZE * BufferUtil.SIZEOF_INT); if(getFlag('f')) { gl.glFlush(); } } - gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0); } else { for (int i = 0; i < elements.length; i++) { ++numDrawElementsCalls; - gl.glDrawElements(primitive, elements[i].remaining(), GL.GL_UNSIGNED_INT, elements[i]); + gl.glDrawElements(primitive, elements[i].remaining(), GL2.GL_UNSIGNED_INT, elements[i]); if(getFlag('f')) { gl.glFlush(); } @@ -674,20 +688,20 @@ public class VertexBufferObject extends Demo { // Unused routines public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} - private void allocateBigArray(GL gl) { + private void allocateBigArray(GL2 gl) { bigArraySystem = setupBuffer(ByteBuffer.allocateDirect(bufferSize)); int[] tmp = new int[1]; - gl.glGenBuffersARB(1, tmp, 0); + gl.glGenBuffers(1, tmp, 0); bigBufferObject = tmp[0]; - gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, bigBufferObject); + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, bigBufferObject); // Initialize data store of buffer object - gl.glBufferDataARB(GL.GL_ARRAY_BUFFER_ARB, bufferSize, (Buffer) null, GL.GL_DYNAMIC_DRAW_ARB); - bigArrayVBOBytes = gl.glMapBufferARB(GL.GL_ARRAY_BUFFER_ARB, GL.GL_WRITE_ONLY_ARB); + gl.glBufferData(GL.GL_ARRAY_BUFFER, bufferSize, (Buffer) null, GL.GL_DYNAMIC_DRAW); + bigArrayVBOBytes = gl.glMapBuffer(GL.GL_ARRAY_BUFFER, GL2.GL_WRITE_ONLY); bigArrayVBO = setupBuffer(bigArrayVBOBytes); - gl.glUnmapBufferARB(GL.GL_ARRAY_BUFFER_ARB); + gl.glUnmapBuffer(GL.GL_ARRAY_BUFFER); // Unbind buffer; will be bound again in main loop - gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, 0); + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); float megabytes = (bufferSize / 1000000.f); System.err.println("Allocated " + megabytes + " megabytes of fast memory"); @@ -707,7 +721,7 @@ public class VertexBufferObject extends Demo { return ret; } - private void computeElements(GL gl) { + private void computeElements(GL2 gl) { xyArray = new float[tileSize]; for (int i = 0; i < tileSize; i++) { xyArray[i] = i / (tileSize - 1.0f) - 0.5f; @@ -732,14 +746,14 @@ public class VertexBufferObject extends Demo { } } int[] tmp = new int[1]; - gl.glGenBuffersARB(1, tmp, 0); + gl.glGenBuffers(1, tmp, 0); elementBufferObject = tmp[0]; - gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, elementBufferObject); - gl.glBufferDataARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, + gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, elementBufferObject); + gl.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, linearElements.remaining() * BufferUtil.SIZEOF_INT, linearElements, - GL.GL_STATIC_DRAW_ARB); - gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + GL.GL_STATIC_DRAW); + gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0); } private static void runExit(final Animator animator) { diff --git a/src/demos/vertexProgRefract/VertexProgRefract.java b/src/demos/vertexProgRefract/VertexProgRefract.java index 11daed9..7717a36 100644 --- a/src/demos/vertexProgRefract/VertexProgRefract.java +++ b/src/demos/vertexProgRefract/VertexProgRefract.java @@ -33,24 +33,37 @@ package demos.vertexProgRefract; -import java.awt.*; -import java.awt.event.*; -import java.awt.image.*; -import java.io.*; -import java.nio.*; -import java.util.*; -import javax.imageio.*; -import javax.imageio.stream.*; -import javax.swing.*; - -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import com.sun.opengl.util.texture.*; -import demos.common.*; -import demos.util.*; -import gleem.*; -import gleem.linalg.*; +import com.sun.opengl.util.glut.gl2.GLUTgl2; +import com.sun.opengl.util.texture.Texture; +import demos.common.Demo; +import demos.common.DemoListener; +import demos.util.Bunny; +import demos.util.Cubemap; +import demos.util.SystemTime; +import demos.util.Time; +import gleem.BSphere; +import gleem.BSphereProvider; +import gleem.ExaminerViewer; +import gleem.ManipManager; +import gleem.MouseButtonHelper; +import gleem.linalg.Rotf; +import gleem.linalg.Vec3f; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.media.opengl.util.Animator; +import javax.swing.JOptionPane; + + /** Wavelength-dependent refraction demo<br> @@ -66,9 +79,16 @@ import gleem.linalg.*; public class VertexProgRefract extends Demo { public static void main(String[] args) { + GLCanvas canvas = new GLCanvas(); - VertexProgRefract demo = new VertexProgRefract(); + final VertexProgRefract demo = new VertexProgRefract(); + canvas.addGLEventListener(demo); + canvas.addKeyListener(new KeyAdapter() { + public void keyTyped(KeyEvent e) { + demo.dispatchKey(e.getKeyChar()); + } + }); final Animator animator = new Animator(canvas); demo.setDemoListener(new DemoListener() { @@ -83,7 +103,7 @@ public class VertexProgRefract extends Demo { canvas.setSize(512, 512); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); canvas.requestFocus(); frame.addWindowListener(new WindowAdapter() { @@ -105,7 +125,7 @@ public class VertexProgRefract extends Demo { private int obj; private GLU glu = new GLU(); - private GLUT glut = new GLUT(); + private GLUTgl2 glut = new GLUTgl2(); private GLAutoDrawable drawable; private ExaminerViewer viewer; @@ -224,21 +244,24 @@ public class VertexProgRefract extends Demo { "END\n"; public void init(GLAutoDrawable drawable) { + initComplete = false; - GL gl = drawable.getGL(); + + GL2 gl = drawable.getGL().getGL2(); + float cc = 1.0f; gl.glClearColor(cc, cc, cc, 1); gl.glColor3f(1,1,1); gl.glEnable(GL.GL_DEPTH_TEST); try { - initExtension(gl, "GL_ARB_vertex_program"); + initExtension(gl, "GL_vertex_program"); initExtension(gl, "GL_VERSION_1_3"); // For multitexturing support - if (!gl.isExtensionAvailable("GL_ARB_fragment_program")) { + if (!gl.isExtensionAvailable("GL_fragment_program")) { if (gl.isExtensionAvailable("GL_NV_register_combiners")) { useRegisterCombiners = true; } else { - final String message = "This demo requires either the GL_ARB_fragment_program\n" + + final String message = "This demo requires either the GL_fragment_program\n" + "or GL_NV_register_combiners extension"; new Thread(new Runnable() { public void run() { @@ -257,17 +280,17 @@ public class VertexProgRefract extends Demo { b[' '] = true; // animate by default int[] vtxProgTmp = new int[1]; - gl.glGenProgramsARB(1, vtxProgTmp, 0); + gl.glGenPrograms(1, vtxProgTmp, 0); vtxProg = vtxProgTmp[0]; - gl.glBindProgramARB (GL.GL_VERTEX_PROGRAM_ARB, vtxProg); - gl.glProgramStringARB(GL.GL_VERTEX_PROGRAM_ARB, GL.GL_PROGRAM_FORMAT_ASCII_ARB, transformRefract.length(), transformRefract); + gl.glBindProgram(GL2.GL_VERTEX_PROGRAM, vtxProg); + gl.glProgramString(GL2.GL_VERTEX_PROGRAM, GL2.GL_PROGRAM_FORMAT_ASCII, transformRefract.length(), transformRefract); - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 0, 0.0f, 0.0f, 0.0f, 1.0f); // eye position + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 0, 0.0f, 0.0f, 0.0f, 1.0f); // eye position - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 1, fresnel, fresnel, fresnel, 1.0f); // fresnel multiplier + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 1, fresnel, fresnel, fresnel, 1.0f); // fresnel multiplier - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 2, 1.0f, -1.0f, 1.0f, 0.0f); // texture scale - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 3, 0.0f, 1.0f, 2.0f, 3.0f); // misc constants + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 2, 1.0f, -1.0f, 1.0f, 0.0f); // texture scale + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 3, 0.0f, 1.0f, 2.0f, 3.0f); // misc constants try { cubemap = Cubemap.loadFromStreams(getClass().getClassLoader(), @@ -279,7 +302,7 @@ public class VertexProgRefract extends Demo { throw new RuntimeException(e); } - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); gl.glDisable(GL.GL_CULL_FACE); @@ -302,12 +325,6 @@ public class VertexProgRefract extends Demo { if (firstRender) { firstRender = false; - drawable.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { - dispatchKey(e.getKeyChar()); - } - }); - // Register the window with the ManipManager ManipManager manager = ManipManager.getManipManager(); manager.registerWindow(drawable); @@ -336,7 +353,7 @@ public class VertexProgRefract extends Demo { time.update(); - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL.GL_COLOR_BUFFER_BIT|GL.GL_DEPTH_BUFFER_BIT); if (doViewAll) { @@ -352,9 +369,9 @@ public class VertexProgRefract extends Demo { toggleWire = false; wire = !wire; if (wire) { - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE); + gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_LINE); } else { - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL); + gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_FILL); } } @@ -369,10 +386,10 @@ public class VertexProgRefract extends Demo { ManipManager.getManipManager().updateCameraParameters(drawable, viewer.getCameraParameters()); ManipManager.getManipManager().render(drawable, gl); - gl.glBindProgramARB(GL.GL_VERTEX_PROGRAM_ARB, vtxProg); + gl.glBindProgram(GL2.GL_VERTEX_PROGRAM, vtxProg); - gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 62, fresnel, fresnel, fresnel, 1.0f); + gl.glEnable(GL2.GL_VERTEX_PROGRAM); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 62, fresnel, fresnel, fresnel, 1.0f); // set texture transforms gl.glActiveTexture(GL.GL_TEXTURE0); @@ -390,10 +407,10 @@ public class VertexProgRefract extends Demo { viewer.updateInverseRotation(gl); if (useRegisterCombiners) { - gl.glEnable(GL.GL_REGISTER_COMBINERS_NV); + gl.glEnable(GL2.GL_REGISTER_COMBINERS_NV); } else { - gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); + gl.glEnable(GL2.GL_FRAGMENT_PROGRAM); } gl.glColor3f(1.0f, 1.0f, 1.0f); @@ -428,11 +445,11 @@ public class VertexProgRefract extends Demo { } if (useRegisterCombiners) { - gl.glDisable(GL.GL_REGISTER_COMBINERS_NV); + gl.glDisable(GL2.GL_REGISTER_COMBINERS_NV); } else { - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); + gl.glDisable(GL2.GL_FRAGMENT_PROGRAM); } - gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); + gl.glDisable(GL2.GL_VERTEX_PROGRAM); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glPopMatrix(); @@ -540,9 +557,9 @@ public class VertexProgRefract extends Demo { gl.glFinalCombinerInputNV(GL.GL_VARIABLE_D_NV, GL.GL_ZERO, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB); } - private void initFragmentProgram(GL gl) { + private void initFragmentProgram(GL2 gl) { int[] fragProgTmp = new int[1]; - gl.glGenProgramsARB(1, fragProgTmp, 0); + gl.glGenPrograms(1, fragProgTmp, 0); fragProg = fragProgTmp[0]; String combineFragProg = "!!ARBfp1.0\n" + @@ -559,14 +576,14 @@ public class VertexProgRefract extends Demo { "MOV result.color, texSamp0;\n" + "END"; - gl.glBindProgramARB (GL.GL_FRAGMENT_PROGRAM_ARB, fragProg); - gl.glProgramStringARB(GL.GL_FRAGMENT_PROGRAM_ARB, GL.GL_PROGRAM_FORMAT_ASCII_ARB, + gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg); + gl.glProgramString(GL2.GL_FRAGMENT_PROGRAM, GL2.GL_PROGRAM_FORMAT_ASCII, combineFragProg.length(), combineFragProg); int[] errPos = new int[1]; - gl.glGetIntegerv(GL.GL_PROGRAM_ERROR_POSITION_ARB, errPos, 0); + gl.glGetIntegerv(GL2.GL_PROGRAM_ERROR_POSITION, errPos, 0); if (errPos[0] >= 0) { System.out.println("Fragment program failed to load:"); - String errMsg = gl.glGetString(GL.GL_PROGRAM_ERROR_STRING_ARB); + String errMsg = gl.glGetString(GL2.GL_PROGRAM_ERROR_STRING); if (errMsg == null) { System.out.println("[No error message available]"); } else { @@ -581,7 +598,7 @@ public class VertexProgRefract extends Demo { } } - private void drawSkyBox(GL gl) { + private void drawSkyBox(GL2 gl) { // Compensates for ExaminerViewer's modification of modelview matrix gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); @@ -599,15 +616,15 @@ public class VertexProgRefract extends Demo { // causes the normals to be sent down. Thanks to Ken Dyke. gl.glEnable(GL.GL_LIGHTING); - gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); - gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); - gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); + gl.glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_NORMAL_MAP); + gl.glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_NORMAL_MAP); + gl.glTexGeni(GL2.GL_R, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_NORMAL_MAP); - gl.glEnable(GL.GL_TEXTURE_GEN_S); - gl.glEnable(GL.GL_TEXTURE_GEN_T); - gl.glEnable(GL.GL_TEXTURE_GEN_R); + gl.glEnable(GL2.GL_TEXTURE_GEN_S); + gl.glEnable(GL2.GL_TEXTURE_GEN_T); + gl.glEnable(GL2.GL_TEXTURE_GEN_R); - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); gl.glMatrixMode(GL.GL_TEXTURE); gl.glPushMatrix(); @@ -621,12 +638,12 @@ public class VertexProgRefract extends Demo { gl.glPopMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); - gl.glDisable(GL.GL_TEXTURE_GEN_S); - gl.glDisable(GL.GL_TEXTURE_GEN_T); - gl.glDisable(GL.GL_TEXTURE_GEN_R); + gl.glDisable(GL2.GL_TEXTURE_GEN_S); + gl.glDisable(GL2.GL_TEXTURE_GEN_T); + gl.glDisable(GL2.GL_TEXTURE_GEN_R); } - private void drawObj(GL gl, int obj) { + private void drawObj(GL2 gl, int obj) { switch(obj) { case 0: gl.glCallList(bunnydl); @@ -646,12 +663,12 @@ public class VertexProgRefract extends Demo { } } - private void setRefraction(GL gl, float index) { - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 4, index, index*index, 0.0f, 0.0f); + private void setRefraction(GL2 gl, float index) { + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 4, index, index*index, 0.0f, 0.0f); } // draw square subdivided into quad strips - private void drawPlane(GL gl, float w, float h, int rows, int cols) { + private void drawPlane(GL2 gl, float w, float h, int rows, int cols) { int x, y; float vx, vy, s, t; float ts, tt, tw, th; @@ -665,7 +682,7 @@ public class VertexProgRefract extends Demo { gl.glNormal3f(0.0f, 0.0f, 1.0f); for(y=0; y<rows; y++) { - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for(x=0; x<=cols; x++) { vx = tw * x -(w/2.0f); vy = th * y -(h/2.0f); diff --git a/src/demos/vertexProgWarp/VertexProgWarp.java b/src/demos/vertexProgWarp/VertexProgWarp.java index 4eab14d..c013647 100644 --- a/src/demos/vertexProgWarp/VertexProgWarp.java +++ b/src/demos/vertexProgWarp/VertexProgWarp.java @@ -33,20 +33,35 @@ package demos.vertexProgWarp; -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.nio.*; -import java.util.*; -import javax.swing.*; - -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.util.*; -import demos.common.*; -import demos.util.*; -import gleem.*; -import gleem.linalg.*; +import demos.common.Demo; +import demos.common.DemoListener; +import demos.util.DurationTimer; +import demos.util.SystemTime; +import demos.util.Time; +import demos.util.Triceratops; +import gleem.BSphere; +import gleem.BSphereProvider; +import gleem.ExaminerViewer; +import gleem.ManipManager; +import gleem.MouseButtonHelper; +import gleem.linalg.Vec3f; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; +import javax.media.opengl.glu.GLUquadric; +import javax.media.opengl.util.Animator; +import javax.swing.JOptionPane; + + /** Simple space-warp/distortion vertex program demo<br> @@ -94,7 +109,7 @@ public class VertexProgWarp extends Demo { canvas.setSize(512, 512); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); canvas.requestFocus(); frame.addWindowListener(new WindowAdapter() { @@ -144,7 +159,7 @@ public class VertexProgWarp extends Demo { public void init(GLAutoDrawable drawable) { initComplete = false; - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); float cc = 0.0f; gl.glClearColor(cc, cc, cc, 1); @@ -154,45 +169,45 @@ public class VertexProgWarp extends Demo { gl.glDisable(GL.GL_CULL_FACE); try { - initExtension(gl, "GL_ARB_vertex_program"); + initExtension(gl, "GL_vertex_program"); } catch (RuntimeException e) { shutdownDemo(); throw(e); } for(int i=0; i<NUM_OBJS; i++) { - gl.glNewList(i+1, GL.GL_COMPILE); + gl.glNewList(i+1, GL2.GL_COMPILE); drawObject(gl, i); gl.glEndList(); } for(int i=0; i<NUM_PROGS; i++) { int[] vtxProgTmp = new int[1]; - gl.glGenProgramsARB(1, vtxProgTmp, 0); + gl.glGenPrograms(1, vtxProgTmp, 0); programs[i] = vtxProgTmp[0]; - gl.glBindProgramARB(GL.GL_VERTEX_PROGRAM_ARB, programs[i]); - gl.glProgramStringARB(GL.GL_VERTEX_PROGRAM_ARB, GL.GL_PROGRAM_FORMAT_ASCII_ARB, programTexts[i].length(), programTexts[i]); + gl.glBindProgram(GL2.GL_VERTEX_PROGRAM, programs[i]); + gl.glProgramString(GL2.GL_VERTEX_PROGRAM, GL2.GL_PROGRAM_FORMAT_ASCII, programTexts[i].length(), programTexts[i]); } - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 0, 0.0f, 0.0f, 1.0f, 0.0f); // light position/direction - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 1, 0.0f, 1.0f, 0.0f, 0.0f); // diffuse color - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 2, 1.0f, 1.0f, 1.0f, 0.0f); // specular color + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 0, 0.0f, 0.0f, 1.0f, 0.0f); // light position/direction + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 1, 0.0f, 1.0f, 0.0f, 0.0f); // diffuse color + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 2, 1.0f, 1.0f, 1.0f, 0.0f); // specular color - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 3, 0.0f, 1.0f, 2.0f, 3.0f); // smoothstep constants + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 3, 0.0f, 1.0f, 2.0f, 3.0f); // smoothstep constants // sin Taylor series constants - 1, 1/3!, 1/5!, 1/7! - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 4, 1.0f, 1.0f / (3*2), 1.0f / (5*4*3*2), 1.0f / (7*6*5*4*3*2)); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 4, 1.0f, 1.0f / (3*2), 1.0f / (5*4*3*2), 1.0f / (7*6*5*4*3*2)); - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 5, 1.0f / (2.0f * SIN_PERIOD), 2.0f * SIN_PERIOD, SIN_PERIOD, SIN_PERIOD/2.0f); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 5, 1.0f / (2.0f * SIN_PERIOD), 2.0f * SIN_PERIOD, SIN_PERIOD, SIN_PERIOD/2.0f); // sin wave frequency, amplitude - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 6, 1.0f, 0.2f, 0.0f, 0.0f); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 6, 1.0f, 0.2f, 0.0f, 0.0f); // phase animation - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 7, 0.0f, 0.0f, 0.0f, 0.0f); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 7, 0.0f, 0.0f, 0.0f, 0.0f); // fisheye sphere radius - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 8, 1.0f, 0.0f, 0.0f, 0.0f); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 8, 1.0f, 0.0f, 0.0f, 0.0f); setWindowTitle(); @@ -245,16 +260,16 @@ public class VertexProgWarp extends Demo { time.update(); - GL gl = drawable.getGL(); + GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); if (toggleWire) { wire = !wire; if (wire) - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE); + gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_LINE); else - gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL); + gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_FILL); toggleWire = false; } @@ -273,21 +288,21 @@ public class VertexProgWarp extends Demo { ManipManager.getManipManager().updateCameraParameters(drawable, viewer.getCameraParameters()); ManipManager.getManipManager().render(drawable, gl); - gl.glBindProgramARB(GL.GL_VERTEX_PROGRAM_ARB, programs[program]); - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 7, anim, 0.0f, 0.0f, 0.0f); + gl.glBindProgram(GL2.GL_VERTEX_PROGRAM, programs[program]); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 7, anim, 0.0f, 0.0f, 0.0f); if (program==6) - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 6, (float) Math.sin(anim)*amp*50.0f, 0.0f, 0.0f, 0.0f); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 6, (float) Math.sin(anim)*amp*50.0f, 0.0f, 0.0f, 0.0f); else - gl.glProgramEnvParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, 6, freq, amp, d, d+1); + gl.glProgramEnvParameter4f(GL2.GL_VERTEX_PROGRAM, 6, freq, amp, d, d+1); if (b['p']) - gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); + gl.glEnable(GL2.GL_VERTEX_PROGRAM); gl.glDisable(GL.GL_TEXTURE_2D); gl.glCallList(obj+1); - gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); + gl.glDisable(GL2.GL_VERTEX_PROGRAM); gl.glPopMatrix(); } @@ -430,7 +445,7 @@ public class VertexProgWarp extends Demo { titleSetter.setTitle("SpaceWarp - " + programNames[program]); } - private void drawObject(GL gl, int which) { + private void drawObject(GL2 gl, int which) { switch(which) { case 0: drawSphere(gl, 0.5f, 100, 100); @@ -459,16 +474,19 @@ public class VertexProgWarp extends Demo { } } - private void drawSphere(GL gl, float radius, int slices, int stacks) { + private void drawSphere(GL2 gl, float radius, int slices, int stacks) { + int J = stacks; int I = slices; + for(int j = 0; j < J; j++) { float v = j/(float) J; float phi = (float) (v * 2 * Math.PI); float v2 = (j+1)/(float) J; float phi2 = (float) (v2 * 2 * Math.PI); - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); + for(int i = 0; i < I; i++) { float u = i/(I-1.0f); float theta = (float) (u * Math.PI); @@ -500,16 +518,20 @@ public class VertexProgWarp extends Demo { } } - private void drawTorus(GL gl, float meridian_radius, float core_radius, + private void drawTorus(GL2 gl, float meridian_radius, float core_radius, int meridian_slices, int core_slices) { + int J = meridian_slices; int I = core_slices; + for(int j = 0; j < J-1; j++) { + float v = j/(J-1.0f); float rho = (float) (v * 2.0f * Math.PI); float v2 = (j+1)/(J-1.0f); float rho2 = (float) (v2 * 2.0f * Math.PI); - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); + for(int i = 0; i < I; i++) { float u = i/(I-1.0f); float theta = (float) (u * 2.0f * Math.PI); @@ -541,7 +563,7 @@ public class VertexProgWarp extends Demo { } } - private void drawCube(GL gl) { + private void drawCube(GL2 gl) { int cr = 40; float scaleFactor = 0.5f; @@ -576,7 +598,7 @@ public class VertexProgWarp extends Demo { drawGrid(gl, cr, cr, scaleFactor, -1.0f, 1.0f, -1.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f); } - private void drawGrid(GL gl, int rows, int cols, + private void drawGrid(GL2 gl, int rows, int cols, float scaleFactor, float sx, float sy, float sz, float ux, float uy, float uz, @@ -584,7 +606,7 @@ public class VertexProgWarp extends Demo { int x, y; for(y=0; y<rows; y++) { - gl.glBegin(GL.GL_QUAD_STRIP); + gl.glBegin(GL2.GL_QUAD_STRIP); for(x=0; x<=cols; x++) { float u = x / (float) cols; float v = y / (float) rows; diff --git a/src/demos/xtrans/OffscreenComponentWrapper.java b/src/demos/xtrans/OffscreenComponentWrapper.java index fa7ad03..47b7995 100755 --- a/src/demos/xtrans/OffscreenComponentWrapper.java +++ b/src/demos/xtrans/OffscreenComponentWrapper.java @@ -39,13 +39,16 @@ package demos.xtrans; -import java.awt.*; -import javax.swing.*; + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Rectangle; +import javax.swing.JComponent; // Internal JOGL API references import com.sun.opengl.impl.Debug; // FIXME: debugging only -import com.sun.opengl.impl.Java2D; +import com.sun.opengl.impl.awt.Java2D; /** Provides an interposition point where we can install a new * Graphics object in the rendering pipeline. Because lightweight diff --git a/src/demos/xtrans/OffscreenDesktopManager.java b/src/demos/xtrans/OffscreenDesktopManager.java index 1aabb67..72349df 100755 --- a/src/demos/xtrans/OffscreenDesktopManager.java +++ b/src/demos/xtrans/OffscreenDesktopManager.java @@ -39,18 +39,31 @@ package demos.xtrans; -import java.awt.*; -import java.awt.geom.*; -import java.awt.image.*; -import java.beans.*; -import java.nio.*; -import java.util.*; -import javax.swing.*; + +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.image.VolatileImage; +import java.beans.PropertyVetoException; +import java.util.Map; +import java.util.WeakHashMap; +import javax.swing.DesktopManager; +import javax.swing.JComponent; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JLayeredPane; +import javax.swing.JPanel; // Internal JOGL API references import com.sun.opengl.impl.Debug; // FIXME: debugging only -import com.sun.opengl.impl.Java2D; +import com.sun.opengl.impl.awt.Java2D; // FIXME: we need a way to lock a portion of the off-screen back // buffer to be persistent for a while during component removals. It diff --git a/src/demos/xtrans/XTBasicTransition.java b/src/demos/xtrans/XTBasicTransition.java index 5621788..d9d37f1 100755 --- a/src/demos/xtrans/XTBasicTransition.java +++ b/src/demos/xtrans/XTBasicTransition.java @@ -39,8 +39,10 @@ package demos.xtrans; -import javax.media.opengl.*; -import gleem.linalg.*; +import gleem.linalg.Vec3f; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; + /** A basic transition supporting animated translation, rotation about * a pivot point, scrolling and fading effects. @@ -67,7 +69,7 @@ public class XTBasicTransition implements XTTransition { this.percentage = percentage; } - public void draw(GL gl) { + public void draw(GL2 gl) { float percent = percentage; Quad3f vts = vertices.getCurrent(percent); Quad2f tex = texcoords.getCurrent(percent); diff --git a/src/demos/xtrans/XTDesktopManager.java b/src/demos/xtrans/XTDesktopManager.java index 5701d13..a184ea6 100755 --- a/src/demos/xtrans/XTDesktopManager.java +++ b/src/demos/xtrans/XTDesktopManager.java @@ -39,16 +39,19 @@ package demos.xtrans; -import java.awt.*; -import java.awt.geom.*; -import java.awt.image.*; -import java.beans.*; -import java.nio.*; -import java.util.*; -import javax.swing.*; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.impl.*; +import com.sun.opengl.impl.awt.Java2D; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.geom.Rectangle2D; +import javax.media.opengl.DebugGL2; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.swing.JDesktopPane; + /** A desktop manager implementation supporting accelerated * transitions of the components on the desktop via OpenGL. This class @@ -94,10 +97,12 @@ public class XTDesktopManager extends OffscreenDesktopManager { the rendering results available to OpenGL in the form of a texture object. */ public void updateOffscreenBuffer(OffscreenDesktopPane parent) { + boolean needsCopy = needsCopyBack(); boolean hadPrevBackBuffer = false; super.updateOffscreenBuffer(parent); Image img = getOffscreenBackBuffer(); + final boolean mustResizeOGLTexture = ((oglTextureId == 0) || (img == null) || (prevBackBufferWidth != img.getWidth(null)) || @@ -111,13 +116,13 @@ public class XTDesktopManager extends OffscreenDesktopManager { if (j2dContext == null || j2dContextSurfaceIdentifier != Java2D.getOGLSurfaceIdentifier(g)) { j2dContext = GLDrawableFactory.getFactory().createExternalGLContext(); - j2dContext.setGL(new DebugGL(j2dContext.getGL())); + j2dContext.setGL(new DebugGL2(j2dContext.getGL().getGL2())); j2dContextSurfaceIdentifier = Java2D.getOGLSurfaceIdentifier(g); } j2dContext.makeCurrent(); // No-op try { - GL gl = j2dContext.getGL(); + GL2 gl = j2dContext.getGL().getGL2(); if (oglTextureId == 0) { // Set up and initialize texture @@ -155,26 +160,26 @@ public class XTDesktopManager extends OffscreenDesktopManager { // NOTE: assumes read buffer is set up // FIXME: could be more efficient by copying only bounding rectangle - gl.glPixelStorei(GL.GL_UNPACK_SWAP_BYTES, GL.GL_FALSE); - gl.glPixelStorei(GL.GL_PACK_SWAP_BYTES, GL.GL_FALSE); - gl.glPixelStorei(GL.GL_UNPACK_LSB_FIRST, GL.GL_FALSE); - gl.glPixelStorei(GL.GL_PACK_LSB_FIRST, GL.GL_FALSE); - gl.glPixelStorei(GL.GL_UNPACK_ROW_LENGTH, 0); - gl.glPixelStorei(GL.GL_PACK_ROW_LENGTH, 0); - gl.glPixelStorei(GL.GL_UNPACK_SKIP_ROWS, 0); - gl.glPixelStorei(GL.GL_PACK_SKIP_ROWS, 0); - gl.glPixelStorei(GL.GL_UNPACK_SKIP_PIXELS, 0); - gl.glPixelStorei(GL.GL_PACK_SKIP_PIXELS, 0); - gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1); - gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1); - gl.glPixelTransferf(GL.GL_RED_SCALE, 1); - gl.glPixelTransferf(GL.GL_GREEN_SCALE, 1); - gl.glPixelTransferf(GL.GL_BLUE_SCALE, 1); - gl.glPixelTransferf(GL.GL_ALPHA_SCALE, 1); - gl.glPixelTransferf(GL.GL_RED_BIAS, 0); - gl.glPixelTransferf(GL.GL_GREEN_BIAS, 0); - gl.glPixelTransferf(GL.GL_BLUE_BIAS, 0); - gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 0); + gl.glPixelStorei(GL2.GL_UNPACK_SWAP_BYTES, GL.GL_FALSE); + gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, GL.GL_FALSE); + gl.glPixelStorei(GL2.GL_UNPACK_LSB_FIRST, GL.GL_FALSE); + gl.glPixelStorei(GL2.GL_PACK_LSB_FIRST, GL.GL_FALSE); + gl.glPixelStorei(GL2.GL_UNPACK_ROW_LENGTH, 0); + gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, 0); + gl.glPixelStorei(GL2.GL_UNPACK_SKIP_ROWS, 0); + gl.glPixelStorei(GL2.GL_PACK_SKIP_ROWS, 0); + gl.glPixelStorei(GL2.GL_UNPACK_SKIP_PIXELS, 0); + gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, 0); + gl.glPixelStorei(GL2.GL_UNPACK_ALIGNMENT, 1); + gl.glPixelStorei(GL2.GL_PACK_ALIGNMENT, 1); + gl.glPixelTransferf(GL2.GL_RED_SCALE, 1); + gl.glPixelTransferf(GL2.GL_GREEN_SCALE, 1); + gl.glPixelTransferf(GL2.GL_BLUE_SCALE, 1); + gl.glPixelTransferf(GL2.GL_ALPHA_SCALE, 1); + gl.glPixelTransferf(GL2.GL_RED_BIAS, 0); + gl.glPixelTransferf(GL2.GL_GREEN_BIAS, 0); + gl.glPixelTransferf(GL2.GL_BLUE_BIAS, 0); + gl.glPixelTransferf(GL2.GL_ALPHA_BIAS, 0); // long start = System.currentTimeMillis(); gl.glCopyTexSubImage2D(textureTarget, diff --git a/src/demos/xtrans/XTDesktopPane.java b/src/demos/xtrans/XTDesktopPane.java index 0786618..5940172 100755 --- a/src/demos/xtrans/XTDesktopPane.java +++ b/src/demos/xtrans/XTDesktopPane.java @@ -39,13 +39,22 @@ package demos.xtrans; -import java.awt.*; -import java.awt.geom.*; -import java.util.*; -import javax.swing.*; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import com.sun.opengl.impl.*; +import com.sun.opengl.impl.awt.Java2D; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; +import java.util.Iterator; +import javax.media.opengl.DebugGL2; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.glu.GLU; + + /** A JDesktopPane subclass supporting Accelerated Transitions (XT) of * the components contained within. @@ -54,6 +63,7 @@ import com.sun.opengl.impl.*; */ public class XTDesktopPane extends OffscreenDesktopPane { + private GLContext j2dContext; private Object j2dContextSurfaceIdentifier; @@ -177,13 +187,13 @@ public class XTDesktopPane extends OffscreenDesktopPane { if (j2dContext == null || j2dContextSurfaceIdentifier != Java2D.getOGLSurfaceIdentifier(g)) { j2dContext = GLDrawableFactory.getFactory().createExternalGLContext(); - j2dContext.setGL(new DebugGL(j2dContext.getGL())); + j2dContext.setGL(new DebugGL2(j2dContext.getGL().getGL2())); j2dContextSurfaceIdentifier = Java2D.getOGLSurfaceIdentifier(g); } j2dContext.makeCurrent(); // No-op try { - GL gl = j2dContext.getGL(); + GL2 gl = j2dContext.getGL().getGL2(); // Figure out where JDesktopPane is on the Swing back buffer Rectangle oglRect = Java2D.getOGLViewport(g, getWidth(), getHeight()); @@ -264,13 +274,13 @@ public class XTDesktopPane extends OffscreenDesktopPane { gl.glBindTexture(textureTarget, getXTDesktopManager().getOpenGLTextureObject()); gl.glEnable(textureTarget); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP); + gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP); + gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP); gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); gl.glEnable(GL.GL_BLEND); - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); // Iterate down children in z order bottom-to-top @@ -352,7 +362,7 @@ public class XTDesktopPane extends OffscreenDesktopPane { gl.glDisable(textureTarget); gl.glDisable(GL.GL_BLEND); - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); gl.glMatrixMode(GL.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_TEXTURE); diff --git a/src/demos/xtrans/XTTransition.java b/src/demos/xtrans/XTTransition.java index b250567..1f683ac 100755 --- a/src/demos/xtrans/XTTransition.java +++ b/src/demos/xtrans/XTTransition.java @@ -53,5 +53,5 @@ public interface XTTransition { public void update(float fraction); /** Draws this transition using the passed OpenGL object. */ - public void draw(GL gl); + public void draw(GL2 gl); } diff --git a/src/gleem/TestExaminerViewer.java b/src/gleem/TestExaminerViewer.java index 6a7bf1c..ee73c9b 100644 --- a/src/gleem/TestExaminerViewer.java +++ b/src/gleem/TestExaminerViewer.java @@ -39,15 +39,23 @@ package gleem; -import java.awt.*; -import java.awt.event.*; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import gleem.linalg.*; +import gleem.linalg.Vec3f; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; + + /** Tests the Examiner Viewer. */ public class TestExaminerViewer { + private static final int X_SIZE = 400; private static final int Y_SIZE = 400; @@ -147,6 +155,6 @@ public class TestExaminerViewer { canvas.addGLEventListener(new Listener()); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); } } diff --git a/src/gleem/TestHandleBox.java b/src/gleem/TestHandleBox.java index cbf5327..f911d46 100644 --- a/src/gleem/TestHandleBox.java +++ b/src/gleem/TestHandleBox.java @@ -39,15 +39,22 @@ package gleem; -import java.awt.*; -import java.awt.event.*; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import gleem.linalg.*; +import gleem.linalg.Vec3f; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; + /** Tests the HandleBox Manip. */ public class TestHandleBox { + private static final int X_SIZE = 400; private static final int Y_SIZE = 400; @@ -137,6 +144,6 @@ public class TestHandleBox { canvas.addGLEventListener(new Listener()); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); } } diff --git a/src/gleem/TestMultiWin.java b/src/gleem/TestMultiWin.java index b79b821..dbf624c 100644 --- a/src/gleem/TestMultiWin.java +++ b/src/gleem/TestMultiWin.java @@ -39,11 +39,19 @@ package gleem; -import java.awt.*; -import java.awt.event.*; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import gleem.linalg.*; +import gleem.linalg.Vec3f; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; + + /** Tests viewing manipulators in multiple winodws. */ @@ -147,7 +155,7 @@ public class TestMultiWin { frame.add(canvas, BorderLayout.CENTER); frame.pack(); frame.setLocation(location); - frame.show(); + frame.setVisible(true); } public static void main(String[] args) { diff --git a/src/gleem/TestTranslate1.java b/src/gleem/TestTranslate1.java index 9b1cd23..83a2a00 100644 --- a/src/gleem/TestTranslate1.java +++ b/src/gleem/TestTranslate1.java @@ -39,11 +39,18 @@ package gleem; -import java.awt.*; -import java.awt.event.*; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import gleem.linalg.*; +import gleem.linalg.Vec3f; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; + + /** Tests the Translate1 Manip. */ @@ -138,6 +145,6 @@ public class TestTranslate1 { canvas.addGLEventListener(new Listener()); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); } } diff --git a/src/gleem/TestTranslate2.java b/src/gleem/TestTranslate2.java index 7bfa6c4..cebe32e 100644 --- a/src/gleem/TestTranslate2.java +++ b/src/gleem/TestTranslate2.java @@ -39,11 +39,18 @@ package gleem; -import java.awt.*; -import java.awt.event.*; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import gleem.linalg.*; +import gleem.linalg.Vec3f; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; + + /** Tests the Translate2 Manip. */ @@ -138,6 +145,6 @@ public class TestTranslate2 { canvas.addGLEventListener(new Listener()); frame.add(canvas, BorderLayout.CENTER); frame.pack(); - frame.show(); + frame.setVisible(true); } } |