summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/demos/context/DualContext.java9
-rwxr-xr-xsrc/demos/cubefbo/CubeObject.java18
-rwxr-xr-xsrc/demos/cubefbo/FBCubes.java26
-rwxr-xr-xsrc/demos/cubefbo/FBObject.java65
-rwxr-xr-xsrc/demos/cubefbo/Main.java36
-rwxr-xr-xsrc/demos/hdr/ARBFPPipeline.java118
-rwxr-xr-xsrc/demos/hdr/HDR.java140
-rwxr-xr-xsrc/demos/hdr/Pipeline.java43
-rw-r--r--src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java4
-rwxr-xr-xsrc/demos/j2d/CustomText.java9
-rwxr-xr-xsrc/demos/j2d/FlyingText.java7
-rwxr-xr-xsrc/demos/j2d/TestOverlay.java5
-rwxr-xr-xsrc/demos/j2d/TestTextRenderer.java7
-rwxr-xr-xsrc/demos/j2d/TestTextureRenderer.java10
-rwxr-xr-xsrc/demos/j2d/TextCube.java10
-rwxr-xr-xsrc/demos/j2d/TextFlow.java10
-rwxr-xr-xsrc/demos/misc/TiledRendering.java30
-rw-r--r--src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java5
-rw-r--r--src/demos/proceduralTexturePhysics/Water.java8
-rwxr-xr-xsrc/demos/util/FPSCounter.java5
-rw-r--r--src/demos/vertexBufferObject/VertexBufferObject.java3
-rw-r--r--src/demos/vertexProgRefract/VertexProgRefract.java82
-rw-r--r--src/demos/vertexProgWarp/VertexProgWarp.java15
-rw-r--r--src/gleem/HandleBoxManip.java2
-rw-r--r--src/gleem/Manip.java2
-rw-r--r--src/gleem/ManipManager.java2
-rw-r--r--src/gleem/ManipPart.java2
-rw-r--r--src/gleem/ManipPartGroup.java2
-rw-r--r--src/gleem/ManipPartLineSeg.java2
-rw-r--r--src/gleem/ManipPartTriBased.java2
-rw-r--r--src/gleem/ManipPartTwoWayArrow.java2
-rw-r--r--src/gleem/NormalCalc.java2
-rw-r--r--src/gleem/Translate1Manip.java2
-rw-r--r--src/gleem/Translate2Manip.java2
-rw-r--r--src/gleem/WindowUpdateListener.java4
35 files changed, 358 insertions, 333 deletions
diff --git a/src/demos/context/DualContext.java b/src/demos/context/DualContext.java
index 8e23f1b..397b10b 100755
--- a/src/demos/context/DualContext.java
+++ b/src/demos/context/DualContext.java
@@ -65,6 +65,7 @@ import javax.swing.JFrame;
using the GLDrawable.swapBuffers() API. */
public class DualContext extends Canvas {
+
private GLDrawable drawable;
private GLContext context1;
private GLContext context2;
@@ -75,11 +76,11 @@ public class DualContext extends Canvas {
public DualContext(GLCapabilities capabilities) {
super(unwrap((AWTGraphicsConfiguration)
GLDrawableFactory.getFactory().chooseGraphicsConfiguration(capabilities, null, null)));
- drawable = GLDrawableFactory.getFactory().getGLDrawable(this, capabilities, null);
+ drawable = GLDrawableFactory.getFactory().createGLDrawable(this, capabilities, null);
context1 = drawable.createContext(null);
context2 = drawable.createContext(null);
glu = new GLU();
- glut = new GLUT();
+ glut = new GLUTgl2();
}
public void addNotify() {
@@ -131,12 +132,12 @@ public class DualContext extends Canvas {
gl.glEnable(GL.GL_SCISSOR_TEST);
gl.glClearColor(br, bg, bb, 1);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- float length = glut.glutStrokeLengthf(GLUT.STROKE_ROMAN, str);
+ float length = glut.glutStrokeLengthf(GLUTgl2.STROKE_ROMAN, str);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluOrtho2D(x, x + width, y, y + height);
gl.glTranslatef(x + (width - length) / 2, y + height / 2, 0);
- glut.glutStrokeString(GLUT.STROKE_ROMAN, str);
+ glut.glutStrokeString(GLUTgl2.STROKE_ROMAN, str);
}
public static void main(String[] args) {
diff --git a/src/demos/cubefbo/CubeObject.java b/src/demos/cubefbo/CubeObject.java
index 09a9be5..ffef04d 100755
--- a/src/demos/cubefbo/CubeObject.java
+++ b/src/demos/cubefbo/CubeObject.java
@@ -33,9 +33,11 @@
package demos.cubefbo;
-import javax.media.opengl.*;
-import com.sun.opengl.util.*;
-import java.nio.*;
+import java.nio.ByteBuffer;
+import java.nio.ShortBuffer;
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.util.BufferUtil;
class CubeObject {
public CubeObject (boolean useTexCoords) {
@@ -63,7 +65,7 @@ class CubeObject {
}
}
- private void perspective(GL gl, float fovy, float aspect, float zNear, float zFar) {
+ private void perspective(GL2 gl, float fovy, float aspect, float zNear, float zFar) {
float xmin;
float xmax;
float ymin;
@@ -83,7 +85,7 @@ class CubeObject {
static final float[] material_spec = { 1.0f, 1.0f, 1.0f, 0.f };
static final float[] zero_vec4 = { 0.0f, 0.0f, 0.0f, 0.f };
- public void reshape(GL gl, int x, int y, int width, int height) {
+ public void reshape(GL2 gl, int x, int y, int width, int height) {
float aspect = (height != 0) ? ((float)width / (float)height) : 1.0f;
gl.glViewport(0, 0, width, height);
@@ -104,7 +106,7 @@ class CubeObject {
gl.glEnable(GL.GL_COLOR_MATERIAL);
gl.glEnable(GL.GL_CULL_FACE);
- gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST);
+ gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST);
gl.glShadeModel(GL.GL_SMOOTH);
gl.glDisable(GL.GL_DITHER);
@@ -127,7 +129,7 @@ class CubeObject {
gl.glCullFace(GL.GL_BACK);
}
- public void display(GL gl, float xRot, float yRot) {
+ public void display(GL2 gl, float xRot, float yRot) {
// System.out.println("CubeObject .. p1: "+this);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
@@ -150,7 +152,7 @@ class CubeObject {
gl.glNormalPointer(GL.GL_BYTE, 0, cubeNormals);
if (cubeTexCoords != null) {
gl.glTexCoordPointer(2, GL.GL_SHORT, 0, cubeTexCoords);
- 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);
}
// System.out.println("CubeObject .. p8: "+this);
diff --git a/src/demos/cubefbo/FBCubes.java b/src/demos/cubefbo/FBCubes.java
index 3295c01..e588cc6 100755
--- a/src/demos/cubefbo/FBCubes.java
+++ b/src/demos/cubefbo/FBCubes.java
@@ -33,12 +33,20 @@
package demos.cubefbo;
-import java.awt.event.*;
-import javax.media.opengl.*;
-import com.sun.opengl.util.*;
-import java.nio.*;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+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;
+
+
class FBCubes implements GLEventListener, MouseListener, MouseMotionListener {
+
private static final int FBO_SIZE = 128;
public FBCubes () {
@@ -50,12 +58,10 @@ class FBCubes implements GLEventListener, MouseListener, MouseMotionListener {
}
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));
fbo1.init(gl);
fbo2.init(gl);
- drawable.addMouseListener(this);
- drawable.addMouseMotionListener(this);
}
int x, y, width, height;
@@ -67,13 +73,13 @@ class FBCubes implements GLEventListener, MouseListener, MouseMotionListener {
this.y = y;
this.width = width;
this.height = height;
- cubeOuter.reshape(drawable.getGL(), x, y, width, height);
+ cubeOuter.reshape(drawable.getGL().getGL2(), x, y, width, height);
motionIncr = 180.f / Math.max(width, height);
}
public void display(GLAutoDrawable drawable) {
// System.out.println("display");
- GL gl = drawable.getGL();
+ GL2 gl = drawable.getGL().getGL2();
fbo1.bind(gl);
cubeInner.reshape(gl, 0, 0, FBO_SIZE, FBO_SIZE);
diff --git a/src/demos/cubefbo/FBObject.java b/src/demos/cubefbo/FBObject.java
index a55096f..76e0ed9 100755
--- a/src/demos/cubefbo/FBObject.java
+++ b/src/demos/cubefbo/FBObject.java
@@ -33,9 +33,8 @@
package demos.cubefbo;
-import javax.media.opengl.*;
-import com.sun.opengl.util.*;
-import java.nio.*;
+import javax.media.opengl.GL2;
+
class FBObject {
private int fb, fbo_tex, depth_rb, stencil_rb, width, height;
@@ -46,7 +45,7 @@ class FBObject {
this.height = height;
}
- public void init(GL gl) {
+ public void init(GL2 gl) {
// generate fbo ..
int name[] = new int[1];
@@ -54,65 +53,65 @@ class FBObject {
fbo_tex = name[0];
System.out.println("fbo_tex: "+fbo_tex);
- gl.glBindTexture(GL.GL_TEXTURE_2D, fbo_tex);
- gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
- gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
- gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB8, width, height, 0,
- GL.GL_RGB, GL.GL_UNSIGNED_BYTE, null);
+ gl.glBindTexture(GL2.GL_TEXTURE_2D, fbo_tex);
+ gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
+ gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
+ gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_RGB8, width, height, 0,
+ GL2.GL_RGB, GL2.GL_UNSIGNED_BYTE, null);
- gl.glGenRenderbuffersEXT(1, name, 0);
+ gl.glGenRenderbuffers(1, name, 0);
depth_rb = name[0];
System.out.println("depth_rb: "+depth_rb);
// Initialize the depth buffer:
- gl.glBindRenderbufferEXT(GL.GL_RENDERBUFFER_EXT, depth_rb);
- gl.glRenderbufferStorageEXT(GL.GL_RENDERBUFFER_EXT,
- GL.GL_DEPTH_COMPONENT24, width, height);
+ gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER, depth_rb);
+ gl.glRenderbufferStorage(GL2.GL_RENDERBUFFER,
+ GL2.GL_DEPTH_COMPONENT24, width, height);
// gl.glGenRenderbuffersEXT(1, name, 0);
// stencil_rb = name[0];
stencil_rb = 0;
System.out.println("stencil_rb: "+stencil_rb);
- gl.glGenFramebuffersEXT(1, name, 0);
+ gl.glGenFramebuffers(1, name, 0);
fb = name[0];
System.out.println("fb: "+fb);
// bind fbo ..
- gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, fb);
+ gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, fb);
// Set up the color buffer for use as a renderable texture:
- gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT,
- GL.GL_COLOR_ATTACHMENT0_EXT,
- GL.GL_TEXTURE_2D, fbo_tex, 0);
+ gl.glFramebufferTexture2D(GL2.GL_FRAMEBUFFER,
+ GL2.GL_COLOR_ATTACHMENT0,
+ GL2.GL_TEXTURE_2D, fbo_tex, 0);
// Set up the depth buffer attachment:
- gl.glFramebufferRenderbufferEXT(GL.GL_FRAMEBUFFER_EXT,
- GL.GL_DEPTH_ATTACHMENT_EXT,
- GL.GL_RENDERBUFFER_EXT, depth_rb);
+ gl.glFramebufferRenderbuffer(GL2.GL_FRAMEBUFFER,
+ GL2.GL_DEPTH_ATTACHMENT,
+ GL2.GL_RENDERBUFFER, depth_rb);
if(stencil_rb!=0) {
// Initialize the stencil buffer:
- gl.glBindRenderbufferEXT(GL.GL_RENDERBUFFER_EXT, stencil_rb);
+ gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER, stencil_rb);
- gl.glRenderbufferStorageEXT(GL.GL_RENDERBUFFER_EXT,
- GL.GL_STENCIL_INDEX8_EXT, width, height);
+ gl.glRenderbufferStorage(GL2.GL_RENDERBUFFER,
+ GL2.GL_STENCIL_INDEX8, width, height);
- gl.glFramebufferRenderbufferEXT(GL.GL_FRAMEBUFFER_EXT,
- GL.GL_STENCIL_ATTACHMENT_EXT,
- GL.GL_RENDERBUFFER_EXT, stencil_rb);
+ gl.glFramebufferRenderbuffer(GL2.GL_FRAMEBUFFER,
+ GL2.GL_STENCIL_ATTACHMENT,
+ GL2.GL_RENDERBUFFER, stencil_rb);
}
unbind(gl);
}
- public void bind(GL gl) {
- gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, fb);
+ public void bind(GL2 gl) {
+ gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, fb);
}
- public void unbind(GL gl) {
- // gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
- // gl.glDisable (GL.GL_TEXTURE_2D);
- gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);
+ public void unbind(GL2 gl) {
+ // gl.glBindTexture(GL2.GL_TEXTURE_2D, 0);
+ // gl.glDisable (GL2.GL_TEXTURE_2D);
+ gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, 0);
}
public int getFBName() {
diff --git a/src/demos/cubefbo/Main.java b/src/demos/cubefbo/Main.java
index b1db392..57e8947 100755
--- a/src/demos/cubefbo/Main.java
+++ b/src/demos/cubefbo/Main.java
@@ -42,38 +42,22 @@ import javax.media.opengl.util.Animator;
import javax.media.opengl.util.FPSAnimator;
-public class Main
-{
-
- private Animator animator;
-
-/**
- public void init() {
- setLayout(new BorderLayout());
- GLCanvas canvas = new GLCanvas();
- canvas.addGLEventListener(new FBCubes());
- canvas.setSize(getSize());
- add(canvas, BorderLayout.CENTER);
- animator = new FPSAnimator(canvas, 30);
- }
-
- public void start() {
- animator.start();
- }
-
- public void stop() {
- // FIXME: do I need to do anything else here?
- animator.stop();
- }
- */
+public class Main {
public static void main(String[] args) {
- Frame frame = new Frame("FBCubes Demo ES 1.1");
+
GLCapabilities caps = new GLCapabilities();
GLCanvas canvas = new GLCanvas(caps);
- canvas.addGLEventListener(new FBCubes());
+
+ FBCubes cubes = new FBCubes();
+ canvas.addMouseListener(cubes);
+ canvas.addMouseMotionListener(cubes);
+ canvas.addGLEventListener(cubes);
+
+ Frame frame = new Frame("FBCubes Demo ES 1.1");
frame.add(canvas);
frame.setSize(800, 480);
+
final Animator animator = new FPSAnimator(canvas, 60);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
diff --git a/src/demos/hdr/ARBFPPipeline.java b/src/demos/hdr/ARBFPPipeline.java
index ca33ddb..6b1e28f 100755
--- a/src/demos/hdr/ARBFPPipeline.java
+++ b/src/demos/hdr/ARBFPPipeline.java
@@ -1,13 +1,17 @@
package demos.hdr;
-import java.io.*;
-import java.util.*;
+import demos.util.FileUtils;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLException;
-import javax.media.opengl.*;
-import demos.util.*;
public class ARBFPPipeline implements Pipeline {
+
private int textureFormat;
+
public ARBFPPipeline(int textureFormat) {
this.textureFormat = textureFormat;
}
@@ -15,52 +19,52 @@ public class ARBFPPipeline implements Pipeline {
public void init() {
}
- public void initFloatingPointTexture(GL gl, int textureObject, int w, int h) {
- gl.glBindTexture(GL.GL_TEXTURE_RECTANGLE_NV, textureObject);
- gl.glCopyTexImage2D(GL.GL_TEXTURE_RECTANGLE_NV, 0, textureFormat, 0, 0, w, h, 0);
+ public void initFloatingPointTexture(GL2 gl, int textureObject, int w, int h) {
+ gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, textureObject);
+ gl.glCopyTexImage2D(GL2.GL_TEXTURE_RECTANGLE, 0, textureFormat, 0, 0, w, h, 0);
}
- public void initTexture(GL gl, int textureObject, int w, int h) {
- gl.glBindTexture(GL.GL_TEXTURE_RECTANGLE_NV, textureObject);
- gl.glCopyTexImage2D(GL.GL_TEXTURE_RECTANGLE_NV, 0, GL.GL_RGBA, 0, 0, w, h, 0);
+ public void initTexture(GL2 gl, int textureObject, int w, int h) {
+ gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, textureObject);
+ gl.glCopyTexImage2D(GL2.GL_TEXTURE_RECTANGLE, 0, GL2.GL_RGBA, 0, 0, w, h, 0);
}
- public void copyToTexture(GL gl, int textureObject, int w, int h) {
- gl.glBindTexture(GL.GL_TEXTURE_RECTANGLE_NV, textureObject);
- gl.glCopyTexSubImage2D(GL.GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, w, h);
+ public void copyToTexture(GL2 gl, int textureObject, int w, int h) {
+ gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, textureObject);
+ gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_RECTANGLE, 0, 0, 0, 0, 0, w, h);
}
- public void bindTexture(GL gl, int textureObject) {
- gl.glBindTexture(GL.GL_TEXTURE_RECTANGLE_NV, textureObject);
+ public void bindTexture(GL2 gl, int textureObject) {
+ gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, textureObject);
}
private List programs = new ArrayList();
- public int loadVertexProgram(GL gl, String filename) throws IOException {
- return loadProgram(gl, filename, GL.GL_VERTEX_PROGRAM_ARB);
+ public int loadVertexProgram(GL2 gl, String filename) throws IOException {
+ return loadProgram(gl, filename, GL2.GL_VERTEX_PROGRAM);
}
- public int loadFragmentProgram(GL gl, String filename) throws IOException {
- return loadProgram(gl, filename, GL.GL_FRAGMENT_PROGRAM_ARB);
+ public int loadFragmentProgram(GL2 gl, String filename) throws IOException {
+ return loadProgram(gl, filename, GL2.GL_FRAGMENT_PROGRAM);
}
- private int loadProgram(GL gl, String fileName, int profile) throws IOException {
+ private int loadProgram(GL2 gl, String fileName, int profile) throws IOException {
String programBuffer = FileUtils.loadStreamIntoString(getClass().getClassLoader().getResourceAsStream(fileName));
int[] tmpInt = new int[1];
- gl.glGenProgramsARB(1, tmpInt, 0);
+ gl.glGenPrograms(1, tmpInt, 0);
int res = tmpInt[0];
- gl.glBindProgramARB(profile, res);
- gl.glProgramStringARB(profile, GL.GL_PROGRAM_FORMAT_ASCII_ARB, programBuffer.length(), programBuffer);
+ gl.glBindProgram(profile, res);
+ gl.glProgramString(profile, 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 (profile == GL.GL_VERTEX_PROGRAM_ARB) {
+ if (profile == GL2.GL_VERTEX_PROGRAM) {
kind = "Vertex program";
- } else if (profile == GL.GL_FRAGMENT_PROGRAM_ARB) {
+ } else if (profile == 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 {
@@ -74,10 +78,10 @@ public class ARBFPPipeline implements Pipeline {
System.out.println(programBuffer.substring(errPos[0], endPos));
throw new GLException("Error loading " + kind);
} else {
- if (profile == GL.GL_FRAGMENT_PROGRAM_ARB) {
+ if (profile == 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");
@@ -88,66 +92,66 @@ public class ARBFPPipeline implements Pipeline {
return res;
}
- public void enableVertexProgram(GL gl, int program) {
- gl.glBindProgramARB(GL.GL_VERTEX_PROGRAM_ARB, program);
- gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
+ public void enableVertexProgram(GL2 gl, int program) {
+ gl.glBindProgram(GL2.GL_VERTEX_PROGRAM, program);
+ gl.glEnable(GL2.GL_VERTEX_PROGRAM);
}
- public void enableFragmentProgram(GL gl, int program) {
- gl.glBindProgramARB(GL.GL_FRAGMENT_PROGRAM_ARB, program);
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
+ public void enableFragmentProgram(GL2 gl, int program) {
+ gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, program);
+ gl.glEnable(GL2.GL_FRAGMENT_PROGRAM);
}
- public void disableVertexProgram(GL gl) {
- gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
+ public void disableVertexProgram(GL2 gl) {
+ gl.glDisable(GL2.GL_VERTEX_PROGRAM);
}
- public void disableFragmentProgram(GL gl) {
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
+ public void disableFragmentProgram(GL2 gl) {
+ gl.glDisable(GL2.GL_FRAGMENT_PROGRAM);
}
public int getNamedParameter(int program, String name) {
throw new RuntimeException("Not supported");
}
- public void setVertexProgramParameter1f(GL gl, int param, float val) {
+ public void setVertexProgramParameter1f(GL2 gl, int param, float val) {
if (param < 0) return;
- gl.glProgramLocalParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, param, val, 0, 0, 0);
+ gl.glProgramLocalParameter4f(GL2.GL_VERTEX_PROGRAM, param, val, 0, 0, 0);
}
- public void setVertexProgramParameter3f(GL gl, int param, float x, float y, float z) {
+ public void setVertexProgramParameter3f(GL2 gl, int param, float x, float y, float z) {
if (param < 0) return;
- gl.glProgramLocalParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, param, x, y, z, 0);
+ gl.glProgramLocalParameter4f(GL2.GL_VERTEX_PROGRAM, param, x, y, z, 0);
}
- public void setVertexProgramParameter4f(GL gl, int param, float x, float y, float z, float w) {
+ public void setVertexProgramParameter4f(GL2 gl, int param, float x, float y, float z, float w) {
if (param < 0) return;
- gl.glProgramLocalParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, param, x, y, z, w);
+ gl.glProgramLocalParameter4f(GL2.GL_VERTEX_PROGRAM, param, x, y, z, w);
}
- public void setFragmentProgramParameter1f(GL gl, int param, float val) {
+ public void setFragmentProgramParameter1f(GL2 gl, int param, float val) {
if (param < 0) return;
- gl.glProgramLocalParameter4fARB(GL.GL_FRAGMENT_PROGRAM_ARB, param, val, 0, 0, 0);
+ gl.glProgramLocalParameter4f(GL2.GL_FRAGMENT_PROGRAM, param, val, 0, 0, 0);
}
- public void setFragmentProgramParameter3f(GL gl, int param, float x, float y, float z) {
+ public void setFragmentProgramParameter3f(GL2 gl, int param, float x, float y, float z) {
if (param < 0) return;
- gl.glProgramLocalParameter4fARB(GL.GL_FRAGMENT_PROGRAM_ARB, param, x, y, z, 0);
+ gl.glProgramLocalParameter4f(GL2.GL_FRAGMENT_PROGRAM, param, x, y, z, 0);
}
- public void setFragmentProgramParameter4f(GL gl, int param, float x, float y, float z, float w) {
+ public void setFragmentProgramParameter4f(GL2 gl, int param, float x, float y, float z, float w) {
if (param < 0) return;
- gl.glProgramLocalParameter4fARB(GL.GL_FRAGMENT_PROGRAM_ARB, param, x, y, z, w);
+ gl.glProgramLocalParameter4f(GL2.GL_FRAGMENT_PROGRAM, param, x, y, z, w);
}
- public void trackModelViewProjectionMatrix(GL gl, int param) {
+ public void trackModelViewProjectionMatrix(GL2 gl, int param) {
float[] modelView = new float[16];
float[] projection = new float[16];
float[] mvp = new float[16];
// Get matrices
- gl.glGetFloatv(GL.GL_PROJECTION_MATRIX, projection, 0);
- gl.glGetFloatv(GL.GL_MODELVIEW_MATRIX, modelView, 0);
+ gl.glGetFloatv(GL2.GL_PROJECTION_MATRIX, projection, 0);
+ gl.glGetFloatv(GL2.GL_MODELVIEW_MATRIX, modelView, 0);
// Multiply together
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
@@ -162,10 +166,10 @@ public class ARBFPPipeline implements Pipeline {
setMatrixParameterfc(gl, param, mvp);
}
- public void setMatrixParameterfc(GL gl, int param, float[] matrix) {
+ public void setMatrixParameterfc(GL2 gl, int param, float[] matrix) {
// Correct for row-major vs. column-major differences
for (int i = 0; i < 4; i++) {
- gl.glProgramLocalParameter4fARB(GL.GL_VERTEX_PROGRAM_ARB, param + i, matrix[i], matrix[4+i], matrix[8+i], matrix[12+i]);
+ gl.glProgramLocalParameter4f(GL2.GL_VERTEX_PROGRAM, param + i, matrix[i], matrix[4+i], matrix[8+i], matrix[12+i]);
}
}
}
diff --git a/src/demos/hdr/HDR.java b/src/demos/hdr/HDR.java
index 4c6efc6..fe08304 100755
--- a/src/demos/hdr/HDR.java
+++ b/src/demos/hdr/HDR.java
@@ -99,7 +99,7 @@ public class HDR extends Demo {
private int gamma_tex;
private int vignette_tex;
- private int textureTarget; // Either GL_TEXTURE_RECTANGLE_NV or GL_TEXTURE_RECTANGLE_EXT/ARB
+ private int textureTarget; // Either GL_TEXTURE_RECTANGLE or GL_TEXTURE_RECTANGLE_EXT/ARB
private GLPbuffer pbuffer;
private GLPbuffer blur_pbuffer;
@@ -131,10 +131,18 @@ public class HDR extends Demo {
0.0f, 0.0f, 0.0f, 1.0f };
public static void main(String[] args) {
+
GLCanvas canvas = new GLCanvas();
- HDR demo = new HDR();
+ final HDR demo = new HDR();
+
canvas.addGLEventListener(demo);
+ canvas.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ demo.dispatchKey(e.getKeyCode(), e.getKeyChar());
+ }
+ });
+
final Animator animator = new Animator(canvas);
demo.setDemoListener(new DemoListener() {
public void shutdownDemo() {
@@ -268,23 +276,23 @@ public class HDR extends Demo {
initComplete = false;
// printThreadName("init for Listener");
- GL gl = drawable.getGL();
+ GL2 gl = drawable.getGL().getGL2();
checkExtension(gl, "GL_VERSION_1_3"); // For multitexture
- checkExtension(gl, "GL_ARB_pbuffer");
- checkExtension(gl, "GL_ARB_vertex_program");
- checkExtension(gl, "GL_ARB_fragment_program");
- if (!gl.isExtensionAvailable("GL_NV_texture_rectangle") &&
+ checkExtension(gl, "GL_pbuffer");
+ checkExtension(gl, "GL_vertex_program");
+ checkExtension(gl, "GL_fragment_program");
+ if (!gl.isExtensionAvailable("GL_texture_rectangle") &&
!gl.isExtensionAvailable("GL_EXT_texture_rectangle") &&
- !gl.isExtensionAvailable("GL_ARB_texture_rectangle")) {
+ !gl.isExtensionAvailable("GL_texture_rectangle")) {
// NOTE: it turns out the constants associated with these extensions are all identical
- unavailableExtension("Texture rectangle extension not available (need one of GL_NV_texture_rectangle, GL_EXT_texture_rectangle or GL_ARB_texture_rectangle");
+ unavailableExtension("Texture rectangle extension not available (need one of GL_texture_rectangle, GL_EXT_texture_rectangle or GL_texture_rectangle");
}
- if (!gl.isExtensionAvailable("GL_NV_float_buffer") &&
+ if (!gl.isExtensionAvailable("GL_float_buffer") &&
!gl.isExtensionAvailable("GL_ATI_texture_float") &&
!gl.isExtensionAvailable("GL_APPLE_float_pixels")) {
- unavailableExtension("Floating-point textures not available (need one of GL_NV_float_buffer, GL_ATI_texture_float, or GL_APPLE_float_pixels");
+ unavailableExtension("Floating-point textures not available (need one of GL_float_buffer, GL_ATI_texture_float, or GL_APPLE_float_pixels");
}
setOrthoProjection(gl, 0, 0, win_w, win_h);
@@ -350,12 +358,6 @@ public class HDR extends Demo {
gl.glGenTextures(1, tmp, 0);
tonemap_pbuffer_tex = tmp[0];
- drawable.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- dispatchKey(e.getKeyCode(), e.getKeyChar());
- }
- });
-
doViewAll = true;
// Register the window with the ManipManager
@@ -398,7 +400,7 @@ public class HDR extends Demo {
time.update();
- GL gl = drawable.getGL();
+ GL2 gl = drawable.getGL().getGL2();
// OK, ready to go
if (b[' ']) {
@@ -447,7 +449,7 @@ public class HDR extends Demo {
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- setOrthoProjection(drawable.getGL(), x, y, width, height);
+ setOrthoProjection(drawable.getGL().getGL2(), x, y, width, height);
win_w = width;
win_h = height;
}
@@ -519,7 +521,7 @@ public class HDR extends Demo {
}
// create gamma lookup table texture
- private int createGammaTexture(GL gl, int size, float gamma) {
+ private int createGammaTexture(GL2 gl, int size, float gamma) {
int[] tmp = new int[1];
gl.glGenTextures(1, tmp, 0);
int texid = tmp[0];
@@ -551,11 +553,11 @@ public class HDR extends Demo {
gl.glGenTextures(1, tmp, 0);
int texid = tmp[0];
- 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.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, texid);
+ gl.glTexParameteri(GL2.GL_TEXTURE_RECTANGLE, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
+ gl.glTexParameteri(GL2.GL_TEXTURE_RECTANGLE, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
+ gl.glTexParameteri(GL2.GL_TEXTURE_RECTANGLE, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP_TO_EDGE);
+ gl.glTexParameteri(GL2.GL_TEXTURE_RECTANGLE, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP_TO_EDGE);
gl.glPixelStorei(GL2.GL_UNPACK_ALIGNMENT, 1);
@@ -579,7 +581,7 @@ public class HDR extends Demo {
}
}
- gl.glTexImage2D(GL2.GL_TEXTURE_RECTANGLE_NV, 0, GL2.GL_LUMINANCE, xsiz, ysiz, 0, GL2.GL_LUMINANCE, GL2.GL_FLOAT, FloatBuffer.wrap(img));
+ gl.glTexImage2D(GL2.GL_TEXTURE_RECTANGLE, 0, GL2.GL_LUMINANCE, xsiz, ysiz, 0, GL2.GL_LUMINANCE, GL2.GL_FLOAT, FloatBuffer.wrap(img));
return texid;
}
@@ -594,7 +596,7 @@ public class HDR extends Demo {
// drawable.setGL(new DebugGL(drawable.getGL()));
- GL gl = drawable.getGL();
+ GL2 gl = drawable.getGL().getGL2();
gl.glEnable(GL2.GL_DEPTH_TEST);
// FIXME: what about the ExaminerViewer?
@@ -608,7 +610,7 @@ public class HDR extends Demo {
System.err.println("Creating HILO cubemap");
hdr_tex = hdr.createCubemapHILO(gl, true);
hdr_tex2 = hdr.createCubemapHILO(gl, false);
- texmode = GL2.GL_FLOAT_RGBA16_NV;
+ texmode = GL2.GL_FLOAT_RGBA16;
hilo = true;
break;
case GLPbuffer.APPLE_FLOAT:
@@ -638,7 +640,7 @@ public class HDR extends Demo {
public void display(GLAutoDrawable drawable) {
// printThreadName("display for PbufferListener");
- GL gl = drawable.getGL();
+ GL2 gl = drawable.getGL().getGL2();
renderScene(gl);
@@ -655,7 +657,7 @@ public class HDR extends Demo {
//
// render scene to float pbuffer
- private void renderScene(GL gl) {
+ private void renderScene(GL2 gl) {
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
if (doViewAll) {
@@ -669,7 +671,7 @@ public class HDR extends Demo {
if (b['m']) {
gl.glEnable(GL2.GL_MULTISAMPLE);
- gl.glHint(GL2.GL_MULTISAMPLE_FILTER_HINT_NV, GL2.GL_NICEST);
+ gl.glHint(GL2.GL_MULTISAMPLE_FILTER_HINT, GL2.GL_NICEST);
} else {
gl.glDisable(GL2.GL_MULTISAMPLE);
}
@@ -783,7 +785,7 @@ public class HDR extends Demo {
// drawable.setGL(new DebugGL(drawable.getGL()));
- GL gl = drawable.getGL();
+ GL2 gl = drawable.getGL().getGL2();
// FIXME: what about the ExaminerViewer?
setOrthoProjection(gl, 0, 0, blur_w, blur_h);
@@ -794,10 +796,10 @@ public class HDR extends Demo {
public void display(GLAutoDrawable drawable) {
// printThreadName("display for BlurPbufferListener");
- GL gl = drawable.getGL();
+ GL2 gl = drawable.getGL().getGL2();
// horizontal blur
- gl.glBindProgramARB(GL2.GL_FRAGMENT_PROGRAM_ARB, blurh_fprog);
+ gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, blurh_fprog);
gl.glActiveTexture(GL2.GL_TEXTURE0);
pipeline.bindTexture(gl, blur2_pbuffer_tex);
glowPass(gl);
@@ -816,7 +818,7 @@ public class HDR extends Demo {
// drawable.setGL(new DebugGL(drawable.getGL()));
- GL gl = drawable.getGL();
+ GL2 gl = drawable.getGL().getGL2();
// FIXME: what about the ExaminerViewer?
setOrthoProjection(gl, 0, 0, blur_w, blur_h);
@@ -826,7 +828,7 @@ public class HDR extends Demo {
public void display(GLAutoDrawable drawable) {
// printThreadName("display for Blur2PbufferListener");
- GL gl = drawable.getGL();
+ GL2 gl = drawable.getGL().getGL2();
if (blur2Pass == BLUR2_SHRINK_PASS) {
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
@@ -834,14 +836,14 @@ public class HDR extends Demo {
pipeline.enableFragmentProgram(gl, shrink_fprog);
setOrthoProjection(gl, 0, 0, blur_w, blur_h);
gl.glActiveTexture(GL2.GL_TEXTURE0);
- gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE_NV, pbuffer_tex);
+ gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, 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(GL2.GL_FRAGMENT_PROGRAM_ARB, blurv_fprog);
+ gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, blurv_fprog);
gl.glActiveTexture(GL2.GL_TEXTURE0);
pipeline.bindTexture(gl, blur_pbuffer_tex);
glowPass(gl);
@@ -860,7 +862,7 @@ public class HDR extends Demo {
class TonemapPbufferListener implements GLEventListener {
public void init(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
+ GL2 gl = drawable.getGL().getGL2();
setOrthoProjection(gl, 0, 0, pbuffer_w, pbuffer_h);
@@ -868,7 +870,7 @@ public class HDR extends Demo {
}
public void display(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
+ GL2 gl = drawable.getGL().getGL2();
toneMappingPass(gl);
@@ -884,7 +886,7 @@ public class HDR extends Demo {
// Rendering routines
//
- private void setOrthoProjection(GL gl, int x, int y, int w, int h) {
+ private void setOrthoProjection(GL2 gl, int x, int y, int w, int h) {
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0, w, 0, h, -1.0, 1.0);
@@ -895,7 +897,7 @@ public class HDR extends Demo {
gl.glViewport(x, y, w, h);
}
- private void setPerspectiveProjection(GL gl, int w, int h) {
+ private void setPerspectiveProjection(GL2 gl, int w, int h) {
// FIXME: what about ExaminerViewer?
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
@@ -906,17 +908,17 @@ public class HDR extends Demo {
}
// blur floating point image
- private void glowPass(GL gl) {
+ private void glowPass(GL2 gl) {
gl.glDisable(GL2.GL_DEPTH_TEST);
- gl.glEnable(GL2.GL_FRAGMENT_PROGRAM_ARB);
+ gl.glEnable(GL2.GL_FRAGMENT_PROGRAM);
setOrthoProjection(gl, 0, 0, blur_w, blur_h);
drawQuadRect(gl, blur_w, blur_h);
- gl.glDisable(GL2.GL_FRAGMENT_PROGRAM_ARB);
+ gl.glDisable(GL2.GL_FRAGMENT_PROGRAM);
}
- private void drawQuadRect(GL gl, int w, int h) {
+ private void drawQuadRect(GL2 gl, int w, int h) {
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);
@@ -925,7 +927,7 @@ public class HDR extends Demo {
gl.glEnd();
}
- private void drawQuadRect2(GL gl, int w, int h, int tw, int th) {
+ private void drawQuadRect2(GL2 gl, int w, int h, int tw, int th) {
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(0, th); gl.glVertex3f(0, h, 0);
gl.glTexCoord2f(tw, th); gl.glVertex3f(w, h, 0);
@@ -934,7 +936,7 @@ public class HDR extends Demo {
gl.glEnd();
}
- private void drawQuadRect4(GL gl, int w, int h, int tw, int th) {
+ private void drawQuadRect4(GL2 gl, int w, int h, int tw, int th) {
float offset = 0.5f;
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(offset, th - offset); gl.glVertex3f(0, h, 0);
@@ -957,7 +959,7 @@ public class HDR extends Demo {
}
// draw cubemap background
- private void drawSkyBox(GL gl) {
+ private void drawSkyBox(GL2 gl) {
gl.glActiveTexture(GL2.GL_TEXTURE0);
gl.glBindTexture(GL2.GL_TEXTURE_CUBE_MAP, hdr_tex);
gl.glEnable(GL2.GL_TEXTURE_CUBE_MAP);
@@ -1009,15 +1011,15 @@ public class HDR extends Demo {
}
// read from float texture, apply tone mapping, render to regular 8/8/8 display
- private void toneMappingPass(GL gl) {
+ private void toneMappingPass(GL2 gl) {
gl.glFinish();
gl.glActiveTexture(GL2.GL_TEXTURE0);
- gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE_NV, pbuffer_tex);
+ gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, pbuffer_tex);
gl.glActiveTexture(GL2.GL_TEXTURE1);
if (blur2_pbuffer != null) {
- gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE_NV, blur2_pbuffer_tex);
+ gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, blur2_pbuffer_tex);
}
gl.glActiveTexture(GL2.GL_TEXTURE2);
@@ -1042,7 +1044,7 @@ public class HDR extends Demo {
//
private String shaderRoot = "demos/hdr/shaders/";
- private void initCg(GL gl) {
+ private void initCg(GL2 gl) {
// NOTE: need to instantiate CgPipeline reflectively to avoid
// compile-time dependence (since Cg support might not be present)
try {
@@ -1078,7 +1080,7 @@ public class HDR extends Demo {
}
}
- private void initARBFP(GL gl, int texmode) {
+ private void initARBFP(GL2 gl, int texmode) {
pipeline = new ARBFPPipeline(texmode);
pipeline.init();
@@ -1110,36 +1112,36 @@ public class HDR extends Demo {
}
}
- private void initBlurCode(GL gl, int blurWidth) {
+ private void initBlurCode(GL2 gl, int blurWidth) {
// generate blur code
String blurCode = generateBlurCodeFP2(blurWidth, false);
- blurh_fprog = loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM_ARB, blurCode);
+ blurh_fprog = loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM, blurCode);
// printf("%s\n", blurCode);
blurCode = generateBlurCodeFP2(blurWidth, true);
- blurv_fprog = loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM_ARB, blurCode);
+ blurv_fprog = loadProgram(gl, GL2.GL_FRAGMENT_PROGRAM, blurCode);
// printf("%s\n", blurCode);
}
- private int loadProgram(GL gl, int target, String code) {
+ private int loadProgram(GL2 gl, int target, String code) {
int prog_id;
int[] tmp = new int[1];
- gl.glGenProgramsARB(1, tmp, 0);
+ gl.glGenPrograms(1, tmp, 0);
prog_id = tmp[0];
- gl.glBindProgramARB(target, prog_id);
+ gl.glBindProgram(target, prog_id);
int size = code.length();
- gl.glProgramStringARB(target, GL2.GL_PROGRAM_FORMAT_ASCII_ARB, code.length(), code);
+ gl.glProgramString(target, GL2.GL_PROGRAM_FORMAT_ASCII, code.length(), code);
int[] errPos = new int[1];
- gl.glGetIntegerv(GL2.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 == GL2.GL_VERTEX_PROGRAM_ARB) {
+ if (target == GL2.GL_VERTEX_PROGRAM) {
kind = "Vertex program";
- } else if (target == GL2.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(GL2.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 {
@@ -1153,11 +1155,11 @@ public class HDR extends Demo {
System.out.println(code.substring(errPos[0], endPos));
throw new GLException("Error loading " + kind);
} else {
- if (target == GL2.GL_FRAGMENT_PROGRAM_ARB) {
+ if (target == GL2.GL_FRAGMENT_PROGRAM) {
int[] isNative = new int[1];
- gl.glGetProgramivARB(GL2.GL_FRAGMENT_PROGRAM_ARB,
- GL2.GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB,
- isNative, 0);
+ 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");
Thread.dumpStack();
diff --git a/src/demos/hdr/Pipeline.java b/src/demos/hdr/Pipeline.java
index 91faff4..8a3c742 100755
--- a/src/demos/hdr/Pipeline.java
+++ b/src/demos/hdr/Pipeline.java
@@ -1,31 +1,28 @@
package demos.hdr;
-import java.io.*;
-import java.util.*;
+import java.io.IOException;
+import javax.media.opengl.GL2;
-import javax.media.opengl.*;
-import com.sun.opengl.cg.*;
-import demos.util.*;
public interface Pipeline {
public void init();
- public void initFloatingPointTexture (GL gl, int textureObject, int w, int h);
- public void initTexture (GL gl, int textureObject, int w, int h);
- public void copyToTexture (GL gl, int textureObject, int w, int h);
- public void bindTexture (GL gl, int textureObject);
- public int loadVertexProgram (GL gl, String filename) throws IOException;
- public int loadFragmentProgram (GL gl, String filename) throws IOException;
- public void enableVertexProgram (GL gl, int program);
- public void enableFragmentProgram (GL gl, int program);
- public void disableVertexProgram (GL gl);
- public void disableFragmentProgram (GL gl);
+ public void initFloatingPointTexture (GL2 gl, int textureObject, int w, int h);
+ public void initTexture (GL2 gl, int textureObject, int w, int h);
+ public void copyToTexture (GL2 gl, int textureObject, int w, int h);
+ public void bindTexture (GL2 gl, int textureObject);
+ public int loadVertexProgram (GL2 gl, String filename) throws IOException;
+ public int loadFragmentProgram (GL2 gl, String filename) throws IOException;
+ public void enableVertexProgram (GL2 gl, int program);
+ public void enableFragmentProgram (GL2 gl, int program);
+ public void disableVertexProgram (GL2 gl);
+ public void disableFragmentProgram (GL2 gl);
public int getNamedParameter (int program, String name);
- public void setVertexProgramParameter1f (GL gl, int param, float val);
- public void setVertexProgramParameter3f (GL gl, int param, float x, float y, float z);
- public void setVertexProgramParameter4f (GL gl, int param, float x, float y, float z, float w);
- public void setFragmentProgramParameter1f (GL gl, int param, float val);
- public void setFragmentProgramParameter3f (GL gl, int param, float x, float y, float z);
- public void setFragmentProgramParameter4f (GL gl, int param, float x, float y, float z, float w);
- public void trackModelViewProjectionMatrix(GL gl, int param);
- public void setMatrixParameterfc (GL gl, int param, float[] matrix);
+ public void setVertexProgramParameter1f (GL2 gl, int param, float val);
+ public void setVertexProgramParameter3f (GL2 gl, int param, float x, float y, float z);
+ public void setVertexProgramParameter4f (GL2 gl, int param, float x, float y, float z, float w);
+ public void setFragmentProgramParameter1f (GL2 gl, int param, float val);
+ public void setFragmentProgramParameter3f (GL2 gl, int param, float x, float y, float z);
+ public void setFragmentProgramParameter4f (GL2 gl, int param, float x, float y, float z, float w);
+ public void trackModelViewProjectionMatrix(GL2 gl, int param);
+ public void setMatrixParameterfc (GL2 gl, int param, float[] matrix);
}
diff --git a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
index fddef16..72bed96 100644
--- a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
+++ b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
@@ -428,8 +428,8 @@ public class HWShadowmapsSimple extends Demo {
int[] depth_bits = new int[1];
gl.glGetIntegerv(GL2.GL_DEPTH_BITS, depth_bits, 0);
- if (depth_bits[0] == 16) depth_format = GL2.GL_DEPTH_COMPONENT16_ARB;
- else depth_format = GL2.GL_DEPTH_COMPONENT24_ARB;
+ if (depth_bits[0] == 16) depth_format = GL2.GL_DEPTH_COMPONENT16;
+ else depth_format = GL2.GL_DEPTH_COMPONENT24;
light_view_depth = genTexture(gl);
gl.glBindTexture(GL2.GL_TEXTURE_2D, light_view_depth);
diff --git a/src/demos/j2d/CustomText.java b/src/demos/j2d/CustomText.java
index 031dfa3..ccb940b 100755
--- a/src/demos/j2d/CustomText.java
+++ b/src/demos/j2d/CustomText.java
@@ -39,6 +39,7 @@
package demos.j2d;
+import com.sun.opengl.util.awt.gl2.GL2TextRenderer;
import com.sun.opengl.util.texture.Texture;
import com.sun.opengl.util.texture.TextureCoords;
import com.sun.opengl.util.texture.TextureIO;
@@ -76,7 +77,6 @@ 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
@@ -137,7 +137,7 @@ public class CustomText extends Demo {
private List/*<TextInfo>*/ textInfo = new ArrayList/*<TextInfo>*/();
private Time time;
private Texture backgroundTexture;
- private TextRenderer renderer;
+ private GL2TextRenderer renderer;
private Random random = new Random();
private GLU glu = new GLU();
private int width;
@@ -205,7 +205,7 @@ public class CustomText extends Demo {
backgroundTexture.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
// Create the text renderer
- renderer = new TextRenderer(new Font("Serif", Font.PLAIN, 72), true, true,
+ renderer = new GL2TextRenderer(new Font("Serif", Font.PLAIN, 72), true, true,
new CustomRenderDelegate(52, 10, Color.BLUE, Color.CYAN));
// Create the FPS counter
@@ -380,7 +380,8 @@ public class CustomText extends Demo {
}
private static final Color DROP_SHADOW_COLOR = new Color(0, 0, 0, 0.5f);
- class CustomRenderDelegate implements TextRenderer.RenderDelegate {
+
+ class CustomRenderDelegate implements GL2TextRenderer.RenderDelegate {
private float gradientSize;
private int dropShadowDepth;
private Color color1;
diff --git a/src/demos/j2d/FlyingText.java b/src/demos/j2d/FlyingText.java
index b42d5ce..a8682a1 100755
--- a/src/demos/j2d/FlyingText.java
+++ b/src/demos/j2d/FlyingText.java
@@ -39,6 +39,7 @@
package demos.j2d;
+import com.sun.opengl.util.awt.gl2.GL2TextRenderer;
import com.sun.opengl.util.texture.Texture;
import com.sun.opengl.util.texture.TextureCoords;
import com.sun.opengl.util.texture.TextureIO;
@@ -75,7 +76,6 @@ import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import sun.java2d.pipe.TextRenderer;
@@ -84,6 +84,7 @@ import sun.java2d.pipe.TextRenderer;
shadow effect. */
public class FlyingText extends Demo {
+
public static void main(String[] args) {
JFrame frame = new JFrame("Flying Text");
frame.getContentPane().setLayout(new BorderLayout());
@@ -151,7 +152,7 @@ public class FlyingText extends Demo {
private int dropShadowDistance = DEFAULT_DROP_SHADOW_DIST;
private Time time;
private Texture backgroundTexture;
- private TextRenderer renderer;
+ private GL2TextRenderer renderer;
private Random random = new Random();
private GLU glu = new GLU();
private int width;
@@ -245,7 +246,7 @@ public class FlyingText extends Demo {
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);
+ renderer = new GL2TextRenderer(new Font("Serif", Font.PLAIN, 72), true, true);
// Create the FPS counter
fps = new FPSCounter(drawable, 36);
diff --git a/src/demos/j2d/TestOverlay.java b/src/demos/j2d/TestOverlay.java
index 9d6212d..6212def 100755
--- a/src/demos/j2d/TestOverlay.java
+++ b/src/demos/j2d/TestOverlay.java
@@ -41,6 +41,7 @@ package demos.j2d;
+import com.sun.opengl.util.awt.gl2.GL2Overlay;
import demos.gears.Gears;
import demos.util.*;
import gleem.linalg.*;
@@ -93,7 +94,7 @@ public class TestOverlay implements GLEventListener {
animator.start();
}
- private Overlay overlay;
+ private GL2Overlay overlay;
private Time time;
private Font font;
private Color TRANSPARENT_BLACK = new Color(0.0f, 0.0f, 0.0f, 0.0f);
@@ -114,7 +115,7 @@ public class TestOverlay implements GLEventListener {
GL gl = drawable.getGL();
gl.setSwapInterval(0);
- overlay = new Overlay(drawable);
+ overlay = new GL2Overlay(drawable);
time = new SystemTime();
((SystemTime) time).rebase();
diff --git a/src/demos/j2d/TestTextRenderer.java b/src/demos/j2d/TestTextRenderer.java
index 8b5284a..d05d5fb 100755
--- a/src/demos/j2d/TestTextRenderer.java
+++ b/src/demos/j2d/TestTextRenderer.java
@@ -39,6 +39,7 @@
package demos.j2d;
+import com.sun.opengl.util.awt.gl2.GL2TextRenderer;
import demos.gears.Gears;
import demos.util.FPSCounter;
import demos.util.SystemTime;
@@ -55,7 +56,6 @@ 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;
@@ -63,6 +63,7 @@ import sun.java2d.pipe.TextRenderer;
with moving Java 2D-rendered text on top. */
public class TestTextRenderer implements GLEventListener {
+
public static void main(String[] args) {
Frame frame = new Frame("Text Renderer Test");
GLCapabilities caps = new GLCapabilities();
@@ -91,7 +92,7 @@ public class TestTextRenderer implements GLEventListener {
animator.start();
}
- private TextRenderer renderer;
+ private GL2TextRenderer renderer;
private Time time;
private Font font;
private Vec2f velocity = new Vec2f(100.0f, 150.0f);
@@ -110,7 +111,7 @@ public class TestTextRenderer implements GLEventListener {
// Gears demo)
gl.setSwapInterval(0);
- renderer = new TextRenderer(new Font("SansSerif", Font.BOLD, 36));
+ renderer = new GL2TextRenderer(new Font("SansSerif", Font.BOLD, 36));
time = new SystemTime();
((SystemTime) time).rebase();
diff --git a/src/demos/j2d/TestTextureRenderer.java b/src/demos/j2d/TestTextureRenderer.java
index bcb7b96..138c4c6 100755
--- a/src/demos/j2d/TestTextureRenderer.java
+++ b/src/demos/j2d/TestTextureRenderer.java
@@ -39,6 +39,7 @@
package demos.j2d;
+import com.sun.opengl.util.awt.gl2.GL2TextureRenderer;
import demos.gears.Gears;
import demos.util.SystemTime;
import demos.util.Time;
@@ -58,6 +59,7 @@ import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.util.Animator;
@@ -68,10 +70,14 @@ import javax.media.opengl.util.Animator;
underneath with moving Java 2D-rendered text on top. */
public class TestTextureRenderer implements GLEventListener {
+
public static void main(String[] args) {
+
Frame frame = new Frame("Java 2D Renderer Test");
GLCapabilities caps = new GLCapabilities();
caps.setAlphaBits(8);
+
+ GLProfile.setProfile("GL2");
GLCanvas canvas = new GLCanvas(caps);
canvas.addGLEventListener(new Gears());
canvas.addGLEventListener(new TestTextureRenderer());
@@ -95,7 +101,7 @@ public class TestTextureRenderer implements GLEventListener {
animator.start();
}
- private TextureRenderer renderer;
+ private GL2TextureRenderer renderer;
private Time time;
private Font font;
private Color TRANSPARENT_BLACK = new Color(0.0f, 0.0f, 0.0f, 0.0f);
@@ -113,7 +119,7 @@ public class TestTextureRenderer implements GLEventListener {
GL gl = drawable.getGL();
gl.setSwapInterval(0);
- renderer = new TextureRenderer(256, 256, true);
+ renderer = new GL2TextureRenderer(256, 256, true);
time = new SystemTime();
((SystemTime) time).rebase();
diff --git a/src/demos/j2d/TextCube.java b/src/demos/j2d/TextCube.java
index 0480358..c04b57e 100755
--- a/src/demos/j2d/TextCube.java
+++ b/src/demos/j2d/TextCube.java
@@ -39,6 +39,7 @@
package demos.j2d;
+import com.sun.opengl.util.awt.gl2.GL2TextRenderer;
import demos.common.Demo;
import demos.util.FPSCounter;
import demos.util.SystemTime;
@@ -52,10 +53,10 @@ import java.awt.geom.Rectangle2D;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.util.Animator;
-import sun.java2d.pipe.TextRenderer;
@@ -66,7 +67,7 @@ public class TextCube extends Demo {
private float yAng;
private GLU glu = new GLU();
private Time time;
- private TextRenderer renderer;
+ private GL2TextRenderer renderer;
private FPSCounter fps;
private float textScaleFactor;
@@ -74,6 +75,7 @@ public class TextCube extends Demo {
Frame frame = new Frame("Text Cube");
frame.setLayout(new BorderLayout());
+ GLProfile.setProfile("GL2");
GLCanvas canvas = new GLCanvas();
final TextCube demo = new TextCube();
@@ -100,7 +102,7 @@ public class TextCube extends Demo {
}
public void init(GLAutoDrawable drawable) {
- renderer = new TextRenderer(new Font("SansSerif", Font.PLAIN, 72));
+ renderer = new GL2TextRenderer(new Font("SansSerif", Font.PLAIN, 72));
GL gl = drawable.getGL();
gl.glEnable(GL2.GL_DEPTH_TEST);
@@ -114,7 +116,7 @@ public class TextCube extends Demo {
time = new SystemTime();
((SystemTime) time).rebase();
- gl.setSwapInterval(0);
+// gl.setSwapInterval(0);
}
public void display(GLAutoDrawable drawable) {
diff --git a/src/demos/j2d/TextFlow.java b/src/demos/j2d/TextFlow.java
index 11e8ea5..8fbbc2a 100755
--- a/src/demos/j2d/TextFlow.java
+++ b/src/demos/j2d/TextFlow.java
@@ -39,6 +39,7 @@
package demos.j2d;
+import com.sun.opengl.util.awt.gl2.GL2TextRenderer;
import demos.common.Demo;
import demos.util.SystemTime;
import demos.util.Time;
@@ -58,9 +59,9 @@ import java.util.List;
import java.util.Map;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.util.Animator;
-import sun.java2d.pipe.TextRenderer;
/** Illustrates both the TextRenderer's capability for handling
@@ -71,10 +72,13 @@ import sun.java2d.pipe.TextRenderer;
screen. */
public class TextFlow extends Demo {
+
public static void main(String[] args) {
+
Frame frame = new Frame("Text Flow");
frame.setLayout(new BorderLayout());
+ GLProfile.setProfile("GL2");
GLCanvas canvas = new GLCanvas();
final TextFlow demo = new TextFlow();
@@ -102,7 +106,7 @@ public class TextFlow extends Demo {
private List/*<String>*/ lines = new ArrayList();
private Time time;
- private TextRenderer renderer;
+ private GL2TextRenderer renderer;
private int curParagraph;
private float x = 30;
private float y;
@@ -139,7 +143,7 @@ public class TextFlow extends Demo {
}
public void init(GLAutoDrawable drawable) {
- renderer = new TextRenderer(new Font("SansSerif", Font.PLAIN, 36));
+ renderer = new GL2TextRenderer(new Font("SansSerif", Font.PLAIN, 36), true, false);
time = new SystemTime();
((SystemTime) time).rebase();
}
diff --git a/src/demos/misc/TiledRendering.java b/src/demos/misc/TiledRendering.java
index 6d9806e..2c55db9 100755
--- a/src/demos/misc/TiledRendering.java
+++ b/src/demos/misc/TiledRendering.java
@@ -1,21 +1,31 @@
package demos.misc;
-import java.awt.image.*;
-import java.io.*;
-import java.nio.*;
-import javax.imageio.*;
-
-import javax.media.opengl.*;
-import com.sun.opengl.util.awt.*;
-
+import com.sun.opengl.impl.io.FileUtil;
+import com.sun.opengl.util.awt.ImageUtil;
+import com.sun.opengl.util.gl2.GL2TileRenderer;
import com.sun.opengl.util.io.TGAWriter;
import demos.gears.Gears;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferByte;
+import java.io.File;
+import java.io.IOException;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import javax.imageio.ImageIO;
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLPbuffer;
/** Demonstrates the TileRenderer class by rendering a large version
of the Gears demo to the specified file. */
public class TiledRendering {
+
public static void main(String[] args) throws IOException {
+
if (args.length != 1) {
System.out.println("Usage: java TiledRendering [output file name]");
System.out.println("Writes output (a large version of the Gears demo) to");
@@ -63,10 +73,10 @@ public class TiledRendering {
}
// Initialize the tile rendering library
- TileRenderer renderer = new TileRenderer();
+ GL2TileRenderer renderer = new GL2TileRenderer();
renderer.setTileSize(tileWidth, tileHeight, 0);
renderer.setImageSize(imageWidth, imageHeight);
- renderer.setImageBuffer(GL.GL_BGR, GL.GL_UNSIGNED_BYTE, buf);
+ renderer.setImageBuffer(GL2.GL_BGR, GL.GL_UNSIGNED_BYTE, buf);
renderer.trPerspective(20.0f, (float) imageWidth / (float) imageHeight, 5.0f, 60.0f);
GLContext context = pbuffer.getContext();
diff --git a/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java b/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java
index 774885a..c5059b5 100644
--- a/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java
+++ b/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java
@@ -52,6 +52,7 @@ import java.awt.event.MouseMotionAdapter;
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.GLException;
import javax.media.opengl.awt.GLCanvas;
@@ -73,7 +74,7 @@ import javax.swing.JOptionPane;
*/
public class ProceduralTexturePhysics extends Demo {
- private ProceduralTexturePhysics() {
+ public ProceduralTexturePhysics() {
GLCanvas canvas = new GLCanvas();
ProceduralTexturePhysics demo = new ProceduralTexturePhysics();
@@ -225,7 +226,7 @@ public class ProceduralTexturePhysics extends Demo {
frameCount = 0;
}
- 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/proceduralTexturePhysics/Water.java b/src/demos/proceduralTexturePhysics/Water.java
index 566b848..3acf6b9 100644
--- a/src/demos/proceduralTexturePhysics/Water.java
+++ b/src/demos/proceduralTexturePhysics/Water.java
@@ -41,6 +41,7 @@ import demos.util.Cubemap;
import gleem.linalg.Mat4f;
import gleem.linalg.Rotf;
import java.io.IOException;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -53,6 +54,7 @@ import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLPbuffer;
import javax.media.opengl.glu.GLU;
+import javax.media.opengl.util.BufferUtil;
@@ -985,7 +987,6 @@ public class Water {
}
private void drawInteriorBoundaryObjects(GL2 gl) {
- gl.glDisable(GL2.GL_REGISTER_COMBINERS_NV);
gl.glActiveTexture(GL2.GL_TEXTURE0);
initialMapTex.bind();
@@ -1815,7 +1816,10 @@ public class Water {
private void loadProgram(GL2 gl,
int target,
String programBuffer) {
- gl.glProgramString(target, GL2.GL_PROGRAM_FORMAT_ASCII, programBuffer.length(), programBuffer);
+
+ ByteBuffer bb = BufferUtil.newByteBuffer(programBuffer.getBytes());
+ gl.glProgramString(target, GL2.GL_PROGRAM_FORMAT_ASCII, programBuffer.length(), bb);
+
int[] errPos = new int[1];
gl.glGetIntegerv(GL2.GL_PROGRAM_ERROR_POSITION, errPos, 0);
if (errPos[0] >= 0) {
diff --git a/src/demos/util/FPSCounter.java b/src/demos/util/FPSCounter.java
index 1251d64..820070e 100755
--- a/src/demos/util/FPSCounter.java
+++ b/src/demos/util/FPSCounter.java
@@ -39,6 +39,7 @@
package demos.util;
+import com.sun.opengl.util.awt.gl2.GL2TextRenderer;
import com.sun.opengl.util.texture.Texture;
import java.awt.Font;
import java.awt.geom.Rectangle2D;
@@ -60,7 +61,7 @@ public class FPSCounter {
private int textLocation = LOWER_RIGHT;
private GLDrawable drawable;
- private TextRenderer renderer;
+ private GL2TextRenderer renderer;
private DecimalFormat format = new DecimalFormat("####.00");
private int frameCount;
private long startTime;
@@ -107,7 +108,7 @@ public class FPSCounter {
boolean antialiased,
boolean useFractionalMetrics) throws GLException {
this.drawable = drawable;
- renderer = new TextRenderer(font, antialiased, useFractionalMetrics);
+ renderer = new GL2TextRenderer(font, antialiased, useFractionalMetrics);
}
/** Gets the relative location where the text of this FPSCounter
diff --git a/src/demos/vertexBufferObject/VertexBufferObject.java b/src/demos/vertexBufferObject/VertexBufferObject.java
index efd8ee0..5b26f8e 100644
--- a/src/demos/vertexBufferObject/VertexBufferObject.java
+++ b/src/demos/vertexBufferObject/VertexBufferObject.java
@@ -49,6 +49,7 @@ import java.nio.IntBuffer;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.util.Animator;
@@ -97,7 +98,7 @@ public class VertexBufferObject extends Demo {
usage();
}
}
-
+ GLProfile.setProfile("GL2");
GLCanvas canvas = new GLCanvas();
final VertexBufferObject demo = new VertexBufferObject();
demo.vboEnabled = vboEnabled;
diff --git a/src/demos/vertexProgRefract/VertexProgRefract.java b/src/demos/vertexProgRefract/VertexProgRefract.java
index 7717a36..943bd7a 100644
--- a/src/demos/vertexProgRefract/VertexProgRefract.java
+++ b/src/demos/vertexProgRefract/VertexProgRefract.java
@@ -115,7 +115,7 @@ public class VertexProgRefract extends Demo {
animator.start();
}
- private boolean useRegisterCombiners;
+// private boolean useRegisterCombiners;
private boolean initComplete;
private boolean firstRender = true;
private int vtxProg;
@@ -258,11 +258,11 @@ public class VertexProgRefract extends Demo {
initExtension(gl, "GL_vertex_program");
initExtension(gl, "GL_VERSION_1_3"); // For multitexturing support
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_fragment_program\n" +
- "or GL_NV_register_combiners extension";
+// if (gl.isExtensionAvailable("GL_NV_register_combiners")) {
+// useRegisterCombiners = true;
+// } else {
+ final String message = "This demo requires either the GL_fragment_program";
+// + "or GL_NV_register_combiners extension";
new Thread(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, message, "Unavailable extension", JOptionPane.ERROR_MESSAGE);
@@ -270,7 +270,7 @@ public class VertexProgRefract extends Demo {
}
}).start();
throw new RuntimeException(message);
- }
+// }
}
} catch (RuntimeException e) {
shutdownDemo();
@@ -306,11 +306,11 @@ public class VertexProgRefract extends Demo {
gl.glDisable(GL.GL_CULL_FACE);
- if (useRegisterCombiners) {
- initCombiners(gl);
- } else {
+// if (useRegisterCombiners) {
+// initCombiners(gl);
+// } else {
initFragmentProgram(gl);
- }
+// }
try {
bunnydl = Bunny.gen3DObjectList(gl);
@@ -406,12 +406,12 @@ public class VertexProgRefract extends Demo {
gl.glLoadIdentity();
viewer.updateInverseRotation(gl);
- if (useRegisterCombiners) {
- gl.glEnable(GL2.GL_REGISTER_COMBINERS_NV);
- } else {
+// if (useRegisterCombiners) {
+// gl.glEnable(GL2.GL_REGISTER_COMBINERS_NV);
+// } else {
gl.glBindProgram(GL2.GL_FRAGMENT_PROGRAM, fragProg);
gl.glEnable(GL2.GL_FRAGMENT_PROGRAM);
- }
+// }
gl.glColor3f(1.0f, 1.0f, 1.0f);
@@ -444,11 +444,11 @@ public class VertexProgRefract extends Demo {
gl.glColorMask(true, true, true, false);
}
- if (useRegisterCombiners) {
- gl.glDisable(GL2.GL_REGISTER_COMBINERS_NV);
- } else {
+// if (useRegisterCombiners) {
+// gl.glDisable(GL2.GL_REGISTER_COMBINERS_NV);
+// } else {
gl.glDisable(GL2.GL_FRAGMENT_PROGRAM);
- }
+// }
gl.glDisable(GL2.GL_VERTEX_PROGRAM);
gl.glMatrixMode(GL.GL_MODELVIEW);
@@ -534,28 +534,28 @@ public class VertexProgRefract extends Demo {
// initalize texture combiners to compute:
// refraction*(1-fresnel) + reflection*fresnel
- private void initCombiners(GL gl) {
- gl.glCombinerParameteriNV(GL.GL_NUM_GENERAL_COMBINERS_NV, 1);
-
- // combiner 0
- // a*b+c*d
- gl.glCombinerInputNV(GL.GL_COMBINER0_NV, GL.GL_RGB, GL.GL_VARIABLE_A_NV, GL.GL_TEXTURE0, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
- gl.glCombinerInputNV(GL.GL_COMBINER0_NV, GL.GL_RGB, GL.GL_VARIABLE_B_NV, GL.GL_PRIMARY_COLOR_NV, GL.GL_UNSIGNED_INVERT_NV, GL.GL_RGB);
- gl.glCombinerInputNV(GL.GL_COMBINER0_NV, GL.GL_RGB, GL.GL_VARIABLE_C_NV, GL.GL_TEXTURE1, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
- gl.glCombinerInputNV(GL.GL_COMBINER0_NV, GL.GL_RGB, GL.GL_VARIABLE_D_NV, GL.GL_PRIMARY_COLOR_NV, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
-
- // output:
- // (stage, portion, abOutput, cdOutput, sumOutput, scale, bias, abDotProduct, cdDotProduct, muxSum)
- gl.glCombinerOutputNV(GL.GL_COMBINER0_NV, GL.GL_RGB, GL.GL_DISCARD_NV, GL.GL_DISCARD_NV, GL.GL_SPARE0_NV, GL.GL_NONE, GL.GL_NONE, false, false, false);
-
- // final combiner
- // output: Frgb = A*B + (1-A)*C + D
- // (variable, input, mapping, componentUsage);
- gl.glFinalCombinerInputNV(GL.GL_VARIABLE_A_NV, GL.GL_SPARE0_NV, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
- gl.glFinalCombinerInputNV(GL.GL_VARIABLE_B_NV, GL.GL_ZERO, GL.GL_UNSIGNED_INVERT_NV, GL.GL_RGB);
- gl.glFinalCombinerInputNV(GL.GL_VARIABLE_C_NV, GL.GL_ZERO, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
- gl.glFinalCombinerInputNV(GL.GL_VARIABLE_D_NV, GL.GL_ZERO, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
- }
+// private void initCombiners(GL gl) {
+// gl.glCombinerParameteriNV(GL.GL_NUM_GENERAL_COMBINERS_NV, 1);
+//
+// // combiner 0
+// // a*b+c*d
+// gl.glCombinerInputNV(GL.GL_COMBINER0_NV, GL.GL_RGB, GL.GL_VARIABLE_A_NV, GL.GL_TEXTURE0, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
+// gl.glCombinerInputNV(GL.GL_COMBINER0_NV, GL.GL_RGB, GL.GL_VARIABLE_B_NV, GL.GL_PRIMARY_COLOR_NV, GL.GL_UNSIGNED_INVERT_NV, GL.GL_RGB);
+// gl.glCombinerInputNV(GL.GL_COMBINER0_NV, GL.GL_RGB, GL.GL_VARIABLE_C_NV, GL.GL_TEXTURE1, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
+// gl.glCombinerInputNV(GL.GL_COMBINER0_NV, GL.GL_RGB, GL.GL_VARIABLE_D_NV, GL.GL_PRIMARY_COLOR_NV, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
+//
+// // output:
+// // (stage, portion, abOutput, cdOutput, sumOutput, scale, bias, abDotProduct, cdDotProduct, muxSum)
+// gl.glCombinerOutputNV(GL.GL_COMBINER0_NV, GL.GL_RGB, GL.GL_DISCARD_NV, GL.GL_DISCARD_NV, GL.GL_SPARE0_NV, GL.GL_NONE, GL.GL_NONE, false, false, false);
+//
+// // final combiner
+// // output: Frgb = A*B + (1-A)*C + D
+// // (variable, input, mapping, componentUsage);
+// gl.glFinalCombinerInputNV(GL.GL_VARIABLE_A_NV, GL.GL_SPARE0_NV, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
+// gl.glFinalCombinerInputNV(GL.GL_VARIABLE_B_NV, GL.GL_ZERO, GL.GL_UNSIGNED_INVERT_NV, GL.GL_RGB);
+// gl.glFinalCombinerInputNV(GL.GL_VARIABLE_C_NV, GL.GL_ZERO, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
+// gl.glFinalCombinerInputNV(GL.GL_VARIABLE_D_NV, GL.GL_ZERO, GL.GL_UNSIGNED_IDENTITY_NV, GL.GL_RGB);
+// }
private void initFragmentProgram(GL2 gl) {
int[] fragProgTmp = new int[1];
diff --git a/src/demos/vertexProgWarp/VertexProgWarp.java b/src/demos/vertexProgWarp/VertexProgWarp.java
index c013647..76c43d5 100644
--- a/src/demos/vertexProgWarp/VertexProgWarp.java
+++ b/src/demos/vertexProgWarp/VertexProgWarp.java
@@ -87,10 +87,17 @@ public class VertexProgWarp extends Demo {
}
public void run(String[] args) {
- GLCanvas canvas = new GLCanvas();
+
VertexProgWarp demo = new VertexProgWarp();
+ GLCanvas canvas = new GLCanvas();
canvas.addGLEventListener(demo);
+ canvas.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent e) {
+ dispatchKey(e.getKeyCode(), e.getKeyChar());
+ }
+ });
+
final Animator animator = new Animator(canvas);
demo.setDemoListener(new DemoListener() {
public void shutdownDemo() {
@@ -215,12 +222,6 @@ public class VertexProgWarp extends Demo {
b['p'] = true;
- drawable.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- dispatchKey(e.getKeyCode(), e.getKeyChar());
- }
- });
-
// Register the window with the ManipManager
ManipManager manager = ManipManager.getManipManager();
manager.registerWindow(drawable);
diff --git a/src/gleem/HandleBoxManip.java b/src/gleem/HandleBoxManip.java
index e35ad40..a0e55d7 100644
--- a/src/gleem/HandleBoxManip.java
+++ b/src/gleem/HandleBoxManip.java
@@ -262,7 +262,7 @@ public class HandleBoxManip extends Manip {
dest.mul(tmp1, tmp2);
}
- public void render(GL gl) {
+ public void render(GL2 gl) {
int i;
for (i = 0; i < 12; i++)
lineSegs[i].render(gl);
diff --git a/src/gleem/Manip.java b/src/gleem/Manip.java
index 9891501..d498534 100644
--- a/src/gleem/Manip.java
+++ b/src/gleem/Manip.java
@@ -116,5 +116,5 @@ public abstract class Manip {
/** Render this Manipulator now using the given OpenGL routines and
assuming an OpenGL context is current. */
- public abstract void render(GL gl);
+ public abstract void render(GL2 gl);
}
diff --git a/src/gleem/ManipManager.java b/src/gleem/ManipManager.java
index 4929bae..e793348 100644
--- a/src/gleem/ManipManager.java
+++ b/src/gleem/ManipManager.java
@@ -201,7 +201,7 @@ public class ManipManager {
drawing occurs immediately; this routine must be called when an
OpenGL context is valid, i.e., from within the display() method
of a GLEventListener. */
- public synchronized void render(GLAutoDrawable window, GL gl) {
+ public synchronized void render(GLAutoDrawable window, GL2 gl) {
WindowInfo info = (WindowInfo) windowToInfoMap.get(window);
if (info == null) {
throw new RuntimeException("Window not registered");
diff --git a/src/gleem/ManipPart.java b/src/gleem/ManipPart.java
index e0416a0..936f755 100644
--- a/src/gleem/ManipPart.java
+++ b/src/gleem/ManipPart.java
@@ -90,5 +90,5 @@ public abstract class ManipPart {
/** Render this ManipPart now using the given OpenGL routines and
assuming an OpenGL context is current. */
- public abstract void render(GL gl);
+ public abstract void render(GL2 gl);
}
diff --git a/src/gleem/ManipPartGroup.java b/src/gleem/ManipPartGroup.java
index 14a73ef..5cf8f71 100644
--- a/src/gleem/ManipPartGroup.java
+++ b/src/gleem/ManipPartGroup.java
@@ -125,7 +125,7 @@ public class ManipPartGroup extends ManipPart {
return visible;
}
- public void render(GL gl) {
+ public void render(GL2 gl) {
for (Iterator iter = children.iterator(); iter.hasNext(); ) {
((ManipPart) iter.next()).render(gl);
}
diff --git a/src/gleem/ManipPartLineSeg.java b/src/gleem/ManipPartLineSeg.java
index ce560c9..682c5c0 100644
--- a/src/gleem/ManipPartLineSeg.java
+++ b/src/gleem/ManipPartLineSeg.java
@@ -123,7 +123,7 @@ public class ManipPartLineSeg extends ManipPart {
return visible;
}
- public void render(GL gl) {
+ public void render(GL2 gl) {
if (!visible)
return;
// FIXME: probably too slow
diff --git a/src/gleem/ManipPartTriBased.java b/src/gleem/ManipPartTriBased.java
index 759c491..ea75079 100644
--- a/src/gleem/ManipPartTriBased.java
+++ b/src/gleem/ManipPartTriBased.java
@@ -165,7 +165,7 @@ public class ManipPartTriBased extends ManipPart {
return visible;
}
- public void render(GL gl) {
+ public void render(GL2 gl) {
if (!visible)
return;
boolean lightingOn = true;
diff --git a/src/gleem/ManipPartTwoWayArrow.java b/src/gleem/ManipPartTwoWayArrow.java
index 77ba507..179bbc7 100644
--- a/src/gleem/ManipPartTwoWayArrow.java
+++ b/src/gleem/ManipPartTwoWayArrow.java
@@ -39,8 +39,6 @@
package gleem;
-import java.util.*;
-
import gleem.linalg.*;
/** Piece of geometry defining a two-way arrow, used in Translate1 and
diff --git a/src/gleem/NormalCalc.java b/src/gleem/NormalCalc.java
index 635bd78..004eb76 100644
--- a/src/gleem/NormalCalc.java
+++ b/src/gleem/NormalCalc.java
@@ -39,8 +39,6 @@
package gleem;
-import java.util.*;
-
import gleem.linalg.*;
/** Calculates normals for a set of polygons. */
diff --git a/src/gleem/Translate1Manip.java b/src/gleem/Translate1Manip.java
index 0cde2d0..15af612 100644
--- a/src/gleem/Translate1Manip.java
+++ b/src/gleem/Translate1Manip.java
@@ -163,7 +163,7 @@ public class Translate1Manip extends Manip {
parts.clearHighlight();
}
- public void render(GL gl) {
+ public void render(GL2 gl) {
parts.render(gl);
}
diff --git a/src/gleem/Translate2Manip.java b/src/gleem/Translate2Manip.java
index 7fe8416..fc2011c 100644
--- a/src/gleem/Translate2Manip.java
+++ b/src/gleem/Translate2Manip.java
@@ -165,7 +165,7 @@ public class Translate2Manip extends Manip {
parts.clearHighlight();
}
- public void render(GL gl) {
+ public void render(GL2 gl) {
parts.render(gl);
}
diff --git a/src/gleem/WindowUpdateListener.java b/src/gleem/WindowUpdateListener.java
index efc139f..193d801 100644
--- a/src/gleem/WindowUpdateListener.java
+++ b/src/gleem/WindowUpdateListener.java
@@ -39,8 +39,8 @@
package gleem;
-import javax.media.opengl.*;
-import com.sun.opengl.util.*;
+import javax.media.opengl.GLAutoDrawable;
+
/** A WindowUpdateListener is used by the ManipManager to transmit
repaint() notifications to windows containing Manips. When a Manip