diff options
author | Kenneth Russel <[email protected]> | 2008-10-30 00:36:37 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2008-10-30 00:36:37 +0000 |
commit | 1d4b8640e128143707e6c19f6249d6b4dba0d2a0 (patch) | |
tree | 6e84ac75c88aee73b60255048a00cfd301f8db3f /src/demos/proceduralTexturePhysics/Water.java | |
parent | 0df738664c9ade75e38c3982560b5cf3e4cdf3df (diff) |
Incorporated patch from Michael Bien fixing roughly 80% of compilation errors
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JOGL_2_SANDBOX@287 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/proceduralTexturePhysics/Water.java')
-rw-r--r-- | src/demos/proceduralTexturePhysics/Water.java | 465 |
1 files changed, 238 insertions, 227 deletions
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"); |