summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <sgothel@jausoft.com>2012-12-23 06:58:20 +0100
committerSven Gothel <sgothel@jausoft.com>2012-12-23 06:58:20 +0100
commit1c1e83011a726f49aa29a40df81f7bceceba31f8 (patch)
treeacbfe6e845359587707f6c53a9e308b4ff868210
parentcbc8b07376eb3aab3c35d768b3323159bd79a4a1 (diff)
Adapt to JOGL ShaderState changes - track our own instance.
-rw-r--r--src/demos/es2/perftst/PerfModule.java29
-rwxr-xr-xsrc/demos/es2/perftst/PerfTextLoad.java5
-rwxr-xr-xsrc/demos/es2/perftst/PerfUniLoad.java5
-rwxr-xr-xsrc/demos/es2/perftst/PerfVBOLoad.java5
-rwxr-xr-xsrc/demos/es2/perftst/Perftst.java44
5 files changed, 58 insertions, 30 deletions
diff --git a/src/demos/es2/perftst/PerfModule.java b/src/demos/es2/perftst/PerfModule.java
index 218b49c..1418038 100644
--- a/src/demos/es2/perftst/PerfModule.java
+++ b/src/demos/es2/perftst/PerfModule.java
@@ -1,22 +1,35 @@
package demos.es2.perftst;
-import java.nio.*;
-import javax.media.opengl.*;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.ShortBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLException;
import com.jogamp.opengl.math.FixedPoint;
-import com.jogamp.opengl.util.*;
-import com.jogamp.opengl.util.glsl.*;
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+import com.jogamp.opengl.util.glsl.ShaderState;
public abstract class PerfModule {
- public abstract void initShaderState(GL2ES2 gl);
+ public abstract ShaderState initShaderState(GL2ES2 gl);
public abstract void run(GLAutoDrawable drawable, int loops);
ShaderState st = null;
- public void initShaderState(GL2ES2 gl, String vShaderName, String fShaderName) {
- if(st!=null) return;
+ public ShaderState getShaderState() { return st; }
+
+ public ShaderState initShaderState(GL2ES2 gl, String vShaderName, String fShaderName) {
+ if(st!=null) {
+ return st;
+ }
long t0, t1;
@@ -47,6 +60,8 @@ public abstract class PerfModule {
// Let's manage all our states using ShaderState.
st.attachShaderProgram(gl, sp, true);
+
+ return st;
}
public static final void put(Buffer buffer, int type, float v) {
diff --git a/src/demos/es2/perftst/PerfTextLoad.java b/src/demos/es2/perftst/PerfTextLoad.java
index 543ce93..429e833 100755
--- a/src/demos/es2/perftst/PerfTextLoad.java
+++ b/src/demos/es2/perftst/PerfTextLoad.java
@@ -7,6 +7,7 @@ import java.io.*;
import java.net.*;
import javax.media.opengl.*;
import com.jogamp.opengl.util.*;
+import com.jogamp.opengl.util.glsl.ShaderState;
import com.jogamp.opengl.util.texture.*;
public class PerfTextLoad extends PerfModule {
@@ -15,8 +16,8 @@ public class PerfTextLoad extends PerfModule {
public PerfTextLoad() {
}
- public void initShaderState(GL2ES2 gl) {
- initShaderState(gl, "vbo-vert-text", "ftext");
+ public ShaderState initShaderState(GL2ES2 gl) {
+ return initShaderState(gl, "vbo-vert-text", "ftext");
}
Texture[] textures = null;
diff --git a/src/demos/es2/perftst/PerfUniLoad.java b/src/demos/es2/perftst/PerfUniLoad.java
index 92626b0..d553d64 100755
--- a/src/demos/es2/perftst/PerfUniLoad.java
+++ b/src/demos/es2/perftst/PerfUniLoad.java
@@ -4,6 +4,7 @@ import com.jogamp.common.nio.Buffers;
import java.nio.*;
import javax.media.opengl.*;
import com.jogamp.opengl.util.*;
+import com.jogamp.opengl.util.glsl.ShaderState;
public class PerfUniLoad extends PerfModule {
@@ -16,8 +17,8 @@ public class PerfUniLoad extends PerfModule {
public PerfUniLoad() {
}
- public void initShaderState(GL2ES2 gl) {
- initShaderState(gl, "uni-vert-col", "fcolor");
+ public ShaderState initShaderState(GL2ES2 gl) {
+ return initShaderState(gl, "uni-vert-col", "fcolor");
}
protected void runOneSet(GLAutoDrawable drawable, int numObjs, int numArrayElem, int loops) {
diff --git a/src/demos/es2/perftst/PerfVBOLoad.java b/src/demos/es2/perftst/PerfVBOLoad.java
index 8e73197..597d8d1 100755
--- a/src/demos/es2/perftst/PerfVBOLoad.java
+++ b/src/demos/es2/perftst/PerfVBOLoad.java
@@ -3,6 +3,7 @@ package demos.es2.perftst;
import java.nio.*;
import javax.media.opengl.*;
import com.jogamp.opengl.util.*;
+import com.jogamp.opengl.util.glsl.ShaderState;
public class PerfVBOLoad extends PerfModule {
@@ -10,8 +11,8 @@ public class PerfVBOLoad extends PerfModule {
public PerfVBOLoad() {
}
- public void initShaderState(GL2ES2 gl) {
- initShaderState(gl, "vbo-vert-col", "fcolor");
+ public ShaderState initShaderState(GL2ES2 gl) {
+ return initShaderState(gl, "vbo-vert-col", "fcolor");
}
protected void runOneSet(GLAutoDrawable drawable, int dataType, int numObjs, int numVertices, int loops, boolean useVBO) {
diff --git a/src/demos/es2/perftst/Perftst.java b/src/demos/es2/perftst/Perftst.java
index dba9e48..e50e867 100755
--- a/src/demos/es2/perftst/Perftst.java
+++ b/src/demos/es2/perftst/Perftst.java
@@ -1,14 +1,25 @@
package demos.es2.perftst;
-import javax.media.opengl.*;
-import javax.media.nativewindow.*;
-
-import com.jogamp.opengl.util.*;
-import com.jogamp.opengl.util.glsl.*;
-
-import com.jogamp.newt.*;
-import com.jogamp.newt.event.*;
-import com.jogamp.newt.opengl.*;
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLUniformData;
+import javax.media.opengl.fixedfunc.GLMatrixFunc;
+
+import com.jogamp.newt.Display;
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.Screen;
+import com.jogamp.newt.Window;
+import com.jogamp.newt.event.MouseEvent;
+import com.jogamp.newt.event.MouseListener;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.glsl.ShaderState;
public class Perftst implements MouseListener, GLEventListener {
@@ -86,21 +97,20 @@ public class Perftst implements MouseListener, GLEventListener {
GL2ES2 gl = drawable.getGL().getGL2ES2();
System.err.println("Entering initialization");
- System.err.println("GL_VERSION=" + gl.glGetString(gl.GL_VERSION));
+ System.err.println("GL_VERSION=" + gl.glGetString(GL.GL_VERSION));
System.err.println("GL_EXTENSIONS:");
- System.err.println(" " + gl.glGetString(gl.GL_EXTENSIONS));
+ System.err.println(" " + gl.glGetString(GL.GL_EXTENSIONS));
pmvMatrix = new PMVMatrix();
- pmod.initShaderState(gl);
- st = ShaderState.getShaderState(gl);
+ st = pmod.initShaderState(gl);
// Push the 1st uniform down the path
st.useProgram(gl, true);
- pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION);
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmvMatrix.glLoadIdentity();
- pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW);
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
if(!st.uniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) {
@@ -123,11 +133,11 @@ public class Perftst implements MouseListener, GLEventListener {
st.useProgram(gl, true);
// Set location in front of camera
- pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION);
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmvMatrix.glLoadIdentity();
pmvMatrix.glOrthof(0f, 1.0f, 0.0f, 1.0f, 1.0f, 100.0f);
- pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW);
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
pmvMatrix.glTranslatef(0, 0, -10);