From f25bdef3b6bc423a08390ab17e86897c85b71282 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Thu, 20 Nov 2008 23:53:23 +0000 Subject: Applied second jogl-demos patch from Michael Bien. Adjusted build.xml to not try to compile jbullet sources, and to merge the ES1 and ES2 targets. To build the full set of demos (including the OpenGL ES demos), run "ant". To build just the OpenGL ES demos, run "ant -Djogl.es=1". git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JOGL_2_SANDBOX@290 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4 --- src/demos/hdr/ARBFPPipeline.java | 118 ++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 57 deletions(-) (limited to 'src/demos/hdr/ARBFPPipeline.java') 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]); } } } -- cgit v1.2.3