summaryrefslogtreecommitdiffstats
path: root/src/demos/es2
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/es2')
-rwxr-xr-xsrc/demos/es2/RedSquare.java310
-rw-r--r--src/demos/es2/openmax/Cube.java364
-rwxr-xr-xsrc/demos/es2/openmax/MovieCube.java209
-rwxr-xr-xsrc/demos/es2/openmax/MovieSimple.java352
-rwxr-xr-xsrc/demos/es2/openmax/shader/bin/nvidia/moviesimple.bfpbin0 -> 684 bytes
-rwxr-xr-xsrc/demos/es2/openmax/shader/bin/nvidia/moviesimple.bvpbin0 -> 940 bytes
-rw-r--r--src/demos/es2/openmax/shader/moviesimple.fp21
-rw-r--r--src/demos/es2/openmax/shader/moviesimple.vp22
-rwxr-xr-xsrc/demos/es2/openmax/shader/scripts/nvidia-apx/glslc-ff.bat9
-rw-r--r--src/demos/es2/perftst/PerfModule.java95
-rwxr-xr-xsrc/demos/es2/perftst/PerfTextLoad.java219
-rwxr-xr-xsrc/demos/es2/perftst/PerfUniLoad.java189
-rwxr-xr-xsrc/demos/es2/perftst/PerfVBOLoad.java239
-rwxr-xr-xsrc/demos/es2/perftst/Perftst.java185
-rw-r--r--src/demos/es2/perftst/data/bob2.gifbin0 -> 23146 bytes
-rw-r--r--src/demos/es2/perftst/data/gif2tgas.sh28
-rwxr-xr-xsrc/demos/es2/perftst/shader/bin/nvidia/fcolor.bfpbin0 -> 524 bytes
-rwxr-xr-xsrc/demos/es2/perftst/shader/bin/nvidia/ftext.bfpbin0 -> 620 bytes
-rwxr-xr-xsrc/demos/es2/perftst/shader/bin/nvidia/uni-vert-col.bvpbin0 -> 6404 bytes
-rwxr-xr-xsrc/demos/es2/perftst/shader/bin/nvidia/vbo-vert-col.bvpbin0 -> 864 bytes
-rwxr-xr-xsrc/demos/es2/perftst/shader/bin/nvidia/vbo-vert-text.bvpbin0 -> 876 bytes
-rw-r--r--src/demos/es2/perftst/shader/fcolor.fp16
-rw-r--r--src/demos/es2/perftst/shader/ftext.fp17
-rwxr-xr-xsrc/demos/es2/perftst/shader/scripts/nvidia-apx/glslc-ff.bat9
-rw-r--r--src/demos/es2/perftst/shader/uni-vert-col.vp61
-rw-r--r--src/demos/es2/perftst/shader/vbo-vert-col.vp19
-rw-r--r--src/demos/es2/perftst/shader/vbo-vert-text.vp19
-rwxr-xr-xsrc/demos/es2/shader/bin/nvidia/redsquare.bfpbin0 -> 524 bytes
-rwxr-xr-xsrc/demos/es2/shader/bin/nvidia/redsquare.bvpbin0 -> 864 bytes
-rw-r--r--src/demos/es2/shader/redsquare.fp16
-rw-r--r--src/demos/es2/shader/redsquare.vp19
-rwxr-xr-xsrc/demos/es2/shader/scripts/nvidia-apx/glslc-ff.bat9
32 files changed, 2427 insertions, 0 deletions
diff --git a/src/demos/es2/RedSquare.java b/src/demos/es2/RedSquare.java
new file mode 100755
index 0000000..58c55c8
--- /dev/null
+++ b/src/demos/es2/RedSquare.java
@@ -0,0 +1,310 @@
+package demos.es2;
+
+import java.nio.*;
+import java.util.*;
+import javax.media.opengl.*;
+import javax.media.opengl.glu.*;
+import javax.media.nativewindow.*;
+
+import com.sun.opengl.util.*;
+import com.sun.opengl.util.glsl.*;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.opengl.*;
+
+public class RedSquare extends Thread implements WindowListener, KeyListener, MouseListener, GLEventListener {
+
+ private GLWindow window;
+ private GLProfile glp;
+ private GLU glu;
+ private boolean quit = false;
+ private long startTime;
+ private long curTime;
+ private String glprofile;
+ private int type;
+
+ public RedSquare(String glprofile, int type) {
+ super();
+ this.glprofile=glprofile;
+ this.type=type;
+ }
+
+ public void windowResized(WindowEvent e) { }
+
+ public void windowMoved(WindowEvent e) { }
+
+ public void windowGainedFocus(WindowEvent e) { }
+
+ public void windowLostFocus(WindowEvent e) { }
+
+ public void windowDestroyNotify(WindowEvent e) {
+ quit = true;
+ }
+
+ public void keyPressed(KeyEvent e) {
+ System.out.println(glp+" "+e);
+ if(e.getKeyChar()=='q') {
+ quit = true;
+ }
+ }
+ public void keyReleased(KeyEvent e) {
+ System.out.println(glp+" "+e);
+ }
+ public void keyTyped(KeyEvent e) {
+ System.out.println(glp+" "+e);
+ }
+
+ public void mouseClicked(MouseEvent e) {
+ System.out.println(glp+" mouseevent: "+e);
+ switch(e.getClickCount()) {
+ case 1:
+ window.setFullscreen(!window.isFullscreen());
+ break;
+ default:
+ quit=true;
+ break;
+ }
+ }
+ public void mouseEntered(MouseEvent e) {
+ }
+ public void mouseExited(MouseEvent e) {
+ }
+ public void mousePressed(MouseEvent e) {
+ }
+ public void mouseReleased(MouseEvent e) {
+ }
+ public void mouseMoved(MouseEvent e) {
+ }
+ public void mouseDragged(MouseEvent e) {
+ }
+ public void mouseWheelMoved(MouseEvent e) {
+ }
+
+ public void run() {
+ System.err.println(glp+" RedSquare.run()");
+ int width = 800;
+ int height = 480;
+ glp = GLProfile.get(glprofile);
+ try {
+ GLCapabilities caps = new GLCapabilities(glp);
+
+ Window nWindow = null;
+ if(0!=(type&USE_AWT)) {
+ Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display
+ Screen nScreen = NewtFactory.createScreen(NativeWindowFactory.TYPE_AWT, nDisplay, 0); // screen 0
+ nWindow = NewtFactory.createWindow(NativeWindowFactory.TYPE_AWT, nScreen, caps);
+ }
+ window = GLWindow.create(nWindow, caps);
+
+ window.addWindowListener(this);
+ window.addMouseListener(this);
+ window.addKeyListener(this);
+ window.addGLEventListener(this);
+ // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_CURRENT); // default
+ // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_NONE); // no current ..
+
+ // Size OpenGL to Video Surface
+ window.setSize(width, height);
+ // window.setFullscreen(true);
+ window.setVisible(true);
+ window.enablePerfLog(true);
+
+ startTime = System.currentTimeMillis();
+
+ while (!quit && ((curTime = System.currentTimeMillis()) - startTime) < 20000) {
+ window.display();
+ }
+
+ // Shut things down cooperatively
+ window.destroy();
+ window.getFactory().shutdown();
+ System.out.println(glp+" RedSquare shut down cleanly.");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ ShaderState st;
+ PMVMatrix pmvMatrix;
+
+ private void initShader(GL2ES2 gl) {
+ int tmpI;
+
+ // Create & Compile the shader objects
+ ShaderCode rsVp = ShaderCode.create(gl, gl.GL_VERTEX_SHADER, 1, RedSquare.class,
+ "shader", "shader/bin", "redsquare");
+ ShaderCode rsFp = ShaderCode.create(gl, gl.GL_FRAGMENT_SHADER, 1, RedSquare.class,
+ "shader", "shader/bin", "redsquare");
+
+ // Create & Link the shader program
+ ShaderProgram sp = new ShaderProgram();
+ sp.add(rsVp);
+ sp.add(rsFp);
+ if(!sp.link(gl, System.err)) {
+ throw new GLException("Couldn't link program: "+sp);
+ }
+
+ // Let's manage all our states using ShaderState.
+ st = new ShaderState();
+ st.attachShaderProgram(gl, sp);
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ glu = GLU.createGLU();
+ System.err.println(glp+" Entering initialization");
+ System.err.println(glp+" GL_VERSION=" + gl.glGetString(gl.GL_VERSION));
+ System.err.println(glp+" GL_EXTENSIONS:");
+ System.err.println(glp+" " + gl.glGetString(gl.GL_EXTENSIONS));
+
+ pmvMatrix = new PMVMatrix();
+
+ initShader(gl);
+
+ // Push the 1st uniform down the path
+ st.glUseProgram(gl, true);
+
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+
+ if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) {
+ throw new GLException("Error setting PMVMatrix in shader: "+st);
+ }
+ // Allocate vertex arrays
+ GLArrayDataClient vertices = GLArrayDataClient.createGLSL(gl, "mgl_Vertex", 3, gl.GL_FLOAT, false, 4);
+ {
+ // Fill them up
+ FloatBuffer verticeb = (FloatBuffer)vertices.getBuffer();
+ verticeb.put(-2); verticeb.put( 2); verticeb.put( 0);
+ verticeb.put( 2); verticeb.put( 2); verticeb.put( 0);
+ verticeb.put(-2); verticeb.put( -2); verticeb.put( 0);
+ verticeb.put( 2); verticeb.put( -2); verticeb.put( 0);
+ }
+ vertices.seal(gl, true);
+
+ GLArrayDataClient colors = GLArrayDataClient.createGLSL(gl, "mgl_Color", 4, gl.GL_FLOAT, false, 4);
+ {
+ // Fill them up
+ FloatBuffer colorb = (FloatBuffer)colors.getBuffer();
+ colorb.put( 1); colorb.put( 0); colorb.put( 0); colorb.put( 1);
+ colorb.put( 0); colorb.put( 0); colorb.put( 1); colorb.put( 1);
+ colorb.put( 1); colorb.put( 0); colorb.put( 0); colorb.put( 1);
+ colorb.put( 1); colorb.put( 0); colorb.put( 0); colorb.put( 1);
+ }
+ colors.seal(gl, true);
+
+ // OpenGL Render Settings
+ gl.glClearColor(0, 0, 0, 1);
+ gl.glEnable(GL2ES2.GL_DEPTH_TEST);
+
+ st.glUseProgram(gl, false);
+
+ // Let's show the completed shader state ..
+ System.out.println(glp+" "+st);
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ st.glUseProgram(gl, true);
+
+ // Set location in front of camera
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.gluPerspective(45.0f, (float)width / (float)height, 1.0f, 100.0f);
+ //pmvMatrix.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f);
+
+ GLUniformData ud = st.getUniform("mgl_PMVMatrix");
+ if(null!=ud) {
+ // same data object
+ st.glUniform(gl, ud);
+ }
+
+ st.glUseProgram(gl, false);
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ System.out.println(glp+" RedSquare.dispose: "+gl.getContext());
+
+ st.destroy(gl);
+ st=null;
+ pmvMatrix.destroy();
+ pmvMatrix=null;
+ System.out.println(glp+" RedSquare.dispose: fin");
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ st.glUseProgram(gl, true);
+
+ gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
+
+ // One rotation every four seconds
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glTranslatef(0, 0, -10);
+ float ang = ((float) (curTime - startTime) * 360.0f) / 4000.0f;
+ pmvMatrix.glRotatef(ang, 0, 0, 1);
+ pmvMatrix.glRotatef(ang, 0, 1, 0);
+
+ GLUniformData ud = st.getUniform("mgl_PMVMatrix");
+ if(null!=ud) {
+ // same data object
+ st.glUniform(gl, ud);
+ }
+
+ // Draw a square
+ gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);
+
+ st.glUseProgram(gl, false);
+ }
+
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+
+ public static int USE_NEWT = 0;
+ public static int USE_AWT = 1 << 0;
+
+ public static void main(String[] args) {
+ int type = USE_NEWT ;
+ List threads = new ArrayList();
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-awt")) {
+ type |= USE_AWT;
+ }
+ if(args[i].startsWith("-GL")) {
+ threads.add(new RedSquare(args[i].substring(1), type));
+ }
+ }
+ if(threads.size()==0) {
+ threads.add(new RedSquare(null, type));
+ }
+ Thread firstT = (Thread) threads.remove(0);
+
+ for(Iterator i = threads.iterator(); i.hasNext(); ) {
+ ((Thread)i.next()).start();
+ }
+
+ // always run the first on main ..
+ firstT.run();
+
+ boolean done = false;
+
+ while(!done) {
+ int aliveCount = 0;
+ for(Iterator i = threads.iterator(); i.hasNext(); ) {
+ if ( ((Thread)i.next()).isAlive() ) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException ie) {}
+ aliveCount++;
+ }
+ }
+ done = 0==aliveCount ;
+ }
+ }
+}
diff --git a/src/demos/es2/openmax/Cube.java b/src/demos/es2/openmax/Cube.java
new file mode 100644
index 0000000..706d8b5
--- /dev/null
+++ b/src/demos/es2/openmax/Cube.java
@@ -0,0 +1,364 @@
+/*
+ *
+ * Copyright (c) 2007, Sun Microsystems, Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Sun Microsystems nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package demos.es2.openmax;
+
+import java.nio.*;
+import javax.media.opengl.*;
+import javax.media.opengl.glu.*;
+import javax.media.nativewindow.*;
+
+import com.sun.opengl.util.*;
+import com.sun.opengl.util.glsl.fixedfunc.*;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.opengl.*;
+
+public class Cube implements GLEventListener {
+ boolean quit = false;
+
+ public Cube () {
+ this(false, false);
+ }
+
+ public Cube (boolean useTexCoords, boolean innerCube) {
+ this.innerCube = innerCube;
+
+ // Initialize data Buffers
+ this.cubeVertices = BufferUtil.newShortBuffer(s_cubeVertices.length);
+ cubeVertices.put(s_cubeVertices);
+ cubeVertices.flip();
+
+ this.cubeColors = BufferUtil.newFloatBuffer(s_cubeColors.length);
+ cubeColors.put(s_cubeColors);
+ cubeColors.flip();
+
+ this.cubeNormals = BufferUtil.newByteBuffer(s_cubeNormals.length);
+ cubeNormals.put(s_cubeNormals);
+ cubeNormals.flip();
+
+ this.cubeIndices = BufferUtil.newByteBuffer(s_cubeIndices.length);
+ cubeIndices.put(s_cubeIndices);
+ cubeIndices.flip();
+
+ if (useTexCoords) {
+ float aspect = 16.0f/9.0f;
+ float ss=1f, ts=1f; // scale tex-coord
+
+ ss = 1f/aspect; // b > h, crop width
+ for(int i=0; i<s_cubeTexCoords.length; i++) {
+ if(s_cubeTexCoords[i]>0) {
+ if ( (i+1) % 2 == 0 ) {
+ // y
+ s_cubeTexCoords[i] *= ts;
+ } else {
+ // x
+ s_cubeTexCoords[i] *= ss;
+ }
+ }
+ }
+
+ this.cubeTexCoords = BufferUtil.newFloatBuffer(s_cubeTexCoords.length);
+ cubeTexCoords.put(s_cubeTexCoords);
+ cubeTexCoords.flip();
+ }
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ GL2ES1 gl = FixedFuncUtil.getFixedFuncImpl(drawable.getGL());
+
+ glu = GLU.createGLU();
+
+ gl.glGenBuffers(4, vboNames, 0);
+
+ if(!innerCube) {
+ System.err.println("Entering initialization");
+ System.err.println("GL Profile: "+gl.getGLProfile());
+ System.err.println("GL:" + gl);
+ 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("GLF:" + gl);
+ }
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ float aspect = (height != 0) ? ((float)width / (float)height) : 1.0f;
+
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ gl.glViewport(0, 0, width, height);
+
+ gl.glMatrixMode(gl.GL_MODELVIEW);
+ gl.glLoadIdentity();
+
+ // JAU gl.glScissor(0, 0, width, height);
+ if(innerCube) {
+ // Clear background to white
+ gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f);
+ } else {
+ // Clear background to blue
+ gl.glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
+ }
+
+ if(!innerCube) {
+ gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, light_position, 0);
+ gl.glLightfv(gl.GL_LIGHT0, gl.GL_AMBIENT, light_ambient, 0);
+ gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, light_diffuse, 0);
+ gl.glLightfv(gl.GL_LIGHT0, gl.GL_SPECULAR, zero_vec4, 0);
+ gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR, material_spec, 0);
+
+ gl.glEnable(gl.GL_LIGHTING);
+ gl.glEnable(gl.GL_LIGHT0);
+ gl.glEnable(gl.GL_COLOR_MATERIAL);
+ } else {
+ gl.glDisable(gl.GL_LIGHTING);
+ gl.glDisable(gl.GL_LIGHT0);
+ }
+ gl.glEnable(gl.GL_CULL_FACE);
+ gl.glEnable(gl.GL_NORMALIZE);
+
+ gl.glShadeModel(gl.GL_SMOOTH);
+ gl.glDisable(GL.GL_DITHER);
+
+ gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[0]);
+ gl.glBufferData(GL.GL_ARRAY_BUFFER, cubeVertices.limit() * BufferUtil.SIZEOF_SHORT, cubeVertices, GL.GL_STATIC_DRAW);
+ gl.glVertexPointer(3, gl.GL_SHORT, 0, 0);
+
+ gl.glEnableClientState(gl.GL_NORMAL_ARRAY);
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[1]);
+ gl.glBufferData(GL.GL_ARRAY_BUFFER, cubeNormals.limit() * BufferUtil.SIZEOF_BYTE, cubeNormals, GL.GL_STATIC_DRAW);
+ gl.glNormalPointer(gl.GL_BYTE, 0, 0);
+
+ gl.glEnableClientState(gl.GL_COLOR_ARRAY);
+ if (cubeColors != null) {
+ gl.glEnableClientState(gl.GL_COLOR_ARRAY);
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[2]);
+ gl.glBufferData(GL.GL_ARRAY_BUFFER, cubeColors.limit() * BufferUtil.SIZEOF_FLOAT, cubeColors, GL.GL_STATIC_DRAW);
+ gl.glColorPointer(4, gl.GL_FLOAT, 0, 0);
+ }
+
+ if (cubeTexCoords != null) {
+ gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY);
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[3]);
+ gl.glBufferData(GL.GL_ARRAY_BUFFER, cubeTexCoords.limit() * BufferUtil.SIZEOF_SHORT, cubeTexCoords, GL.GL_STATIC_DRAW);
+ gl.glTexCoordPointer(2, gl.GL_SHORT, 0, 0);
+ gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_INCR);
+ } else {
+ gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY);
+ }
+ gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
+
+ gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_FASTEST);
+
+ gl.glMatrixMode(gl.GL_PROJECTION);
+ gl.glLoadIdentity();
+
+ if(!innerCube) {
+ glu.gluPerspective(90.0f, aspect, 1.0f, 100.0f);
+ } else {
+ gl.glOrthof(-20.0f, 20.0f, -20.0f, 20.0f, 1.0f, 40.0f);
+ }
+ // weird effect ..: gl.glCullFace(gl.GL_FRONT);
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ quit=true;
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
+
+ gl.glMatrixMode(gl.GL_MODELVIEW);
+ gl.glLoadIdentity();
+
+ gl.glTranslatef(0.f, 0.f, -30.f);
+ gl.glRotatef((float)(time * 29.77f), 1.0f, 2.0f, 0.0f);
+ gl.glRotatef((float)(time * 22.311f), -0.1f, 0.0f, -5.0f);
+
+ gl.glDrawElements(gl.GL_TRIANGLES, 6 * 6, gl.GL_UNSIGNED_BYTE, cubeIndices);
+
+ time += 0.01f;
+ }
+
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+
+ static final float[] light_position = { -50.f, 50.f, 50.f, 0.f };
+ static final float[] light_ambient = { 0.125f, 0.125f, 0.125f, 1.f };
+ static final float[] light_diffuse = { 1.0f, 1.0f, 1.0f, 1.f };
+ 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 };
+
+ int[] vboNames = new int[4];
+ boolean innerCube;
+ boolean initialized = false;
+ float time = 0.0f;
+ ShortBuffer cubeVertices;
+ FloatBuffer cubeTexCoords;
+ FloatBuffer cubeColors;
+ ByteBuffer cubeNormals;
+ ByteBuffer cubeIndices;
+ private GLU glu;
+
+ private static final short[] s_cubeVertices =
+ {
+ -10, 10, 10, 10, -10, 10, 10, 10, 10, -10, -10, 10,
+
+ -10, 10, -10, 10, -10, -10, 10, 10, -10, -10, -10, -10,
+
+ -10, -10, 10, 10, -10, -10, 10, -10, 10, -10, -10, -10,
+
+ -10, 10, 10, 10, 10, -10, 10, 10, 10, -10, 10, -10,
+
+ 10, -10, 10, 10, 10, -10, 10, 10, 10, 10, -10, -10,
+
+ -10, -10, 10, -10, 10, -10, -10, 10, 10, -10, -10, -10
+ };
+ private static final float[] s_cubeTexCoords =
+ {
+ 0, 1f, 1f, 0, 1f, 1f, 0, 0,
+
+ 0, 1f, 1f, 0, 1f, 1f, 0, 0,
+
+ 0, 1f, 1f, 0, 1f, 1f, 0, 0,
+
+ 0, 1f, 1f, 0, 1f, 1f, 0, 0,
+
+ 0, 1f, 1f, 0, 1f, 1f, 0, 0,
+
+ 0, 1f, 1f, 0, 1f, 1f, 0, 0,
+ };
+
+ private static final float[] s_cubeColors =
+ {
+ 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
+ 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
+
+ 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
+ 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
+
+ 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f,
+ 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f,
+
+ 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f,
+ 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f,
+
+ 255f/255f, 110f/255f, 10f/255f, 255f/255f, 255f/255f, 110f/255f, 10f/255f, 255f/255f,
+ 255f/255f, 110f/255f, 10f/255f, 255f/255f, 255f/255f, 110f/255f, 10f/255f, 255f/255f,
+
+ 255f/255f, 70f/255f, 60f/255f, 255f/255f, 255f/255f, 70f/255f, 60f/255f, 255f/255f,
+ 255f/255f, 70f/255f, 60f/255f, 255f/255f, 255f/255f, 70f/255f, 60f/255f, 255
+ };
+ private static final byte[] s_cubeIndices =
+ {
+ 0, 3, 1, 2, 0, 1, /* front */
+ 6, 5, 4, 5, 7, 4, /* back */
+ 8, 11, 9, 10, 8, 9, /* top */
+ 15, 12, 13, 12, 14, 13, /* bottom */
+ 16, 19, 17, 18, 16, 17, /* right */
+ 23, 20, 21, 20, 22, 21 /* left */
+ };
+ private static final byte[] s_cubeNormals =
+ {
+ 0, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 127,
+
+ 0, 0, -128, 0, 0, -128, 0, 0, -128, 0, 0, -128,
+
+ 0, -128, 0, 0, -128, 0, 0, -128, 0, 0, -128, 0,
+
+ 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 127, 0,
+
+ 127, 0, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0,
+
+ -128, 0, 0, -128, 0, 0, -128, 0, 0, -128, 0, 0
+ };
+
+ private void run(int type) {
+ int width = 800;
+ int height = 480;
+ System.err.println("Cube.run()");
+ try {
+ GLCapabilities caps = new GLCapabilities(null);
+ // For emulation library, use 16 bpp
+ caps.setRedBits(5);
+ caps.setGreenBits(6);
+ caps.setBlueBits(5);
+ caps.setDepthBits(16);
+
+ Window nWindow = null;
+ if(0!=(type&USE_AWT)) {
+ Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display
+ Screen nScreen = NewtFactory.createScreen(NativeWindowFactory.TYPE_AWT, nDisplay, 0); // screen 0
+ nWindow = NewtFactory.createWindow(NativeWindowFactory.TYPE_AWT, nScreen, caps);
+ }
+
+ GLWindow window = GLWindow.create(nWindow, caps);
+
+ window.addGLEventListener(this);
+
+ window.enablePerfLog(true);
+ // Size OpenGL to Video Surface
+ window.setSize(width, height);
+ window.setFullscreen(true);
+ window.setVisible(true);
+
+ while (!quit && window.getDuration() < 31000) {
+ window.display();
+ }
+
+ // Shut things down cooperatively
+ window.destroy();
+ window.getFactory().shutdown();
+ System.out.println("Cube shut down cleanly.");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ public static int USE_NEWT = 0;
+ public static int USE_AWT = 1 << 0;
+
+ public static void main(String[] args) {
+ int type = USE_NEWT ;
+ for(int i=args.length-1; i>=0; i--) {
+ if(args[i].equals("-awt")) {
+ type |= USE_AWT;
+ }
+ }
+ new Cube().run(type);
+ System.exit(0);
+ }
+}
+
diff --git a/src/demos/es2/openmax/MovieCube.java b/src/demos/es2/openmax/MovieCube.java
new file mode 100755
index 0000000..40ba583
--- /dev/null
+++ b/src/demos/es2/openmax/MovieCube.java
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package demos.es2.openmax;
+
+// import demos.es1.cube.Cube;
+
+import javax.media.opengl.*;
+import com.sun.opengl.util.glsl.fixedfunc.*;
+
+import com.sun.openmax.*;
+
+import java.nio.*;
+import java.net.*;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.opengl.*;
+
+public class MovieCube implements MouseListener, GLEventListener, OMXEventListener {
+ GLWindow window;
+ boolean quit = false;
+ Cube cube=null;
+ String stream;
+ OMXInstance movie=null;
+
+ public void changedAttributes(OMXInstance omx, int event_mask) {
+ System.out.println("changed stream attr ("+event_mask+"): "+omx);
+ }
+
+ public void mouseClicked(MouseEvent e) {
+ switch(e.getClickCount()) {
+ case 2:
+ quit=true;
+ break;
+ }
+ }
+ public void mouseEntered(MouseEvent e) {
+ }
+ public void mouseExited(MouseEvent e) {
+ }
+ public void mousePressed(MouseEvent e) {
+ }
+ public void mouseReleased(MouseEvent e) {
+ }
+ public void mouseMoved(MouseEvent e) {
+ }
+ public void mouseDragged(MouseEvent e) {
+ }
+ public void mouseWheelMoved(MouseEvent e) {
+ }
+
+ public MovieCube (String stream) {
+ cube = new Cube(true, false);
+ this.stream = stream;
+ }
+
+ private void run() {
+ System.err.println("MovieCube.run()");
+ try {
+ GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
+ // For emulation library, use 16 bpp
+ caps.setRedBits(5);
+ caps.setGreenBits(6);
+ caps.setBlueBits(5);
+ caps.setDepthBits(16);
+
+ window = GLWindow.create(caps);
+
+ window.addMouseListener(this);
+ window.addGLEventListener(this);
+ // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_CURRENT); // default
+ // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_NONE); // no current ..
+
+ // Size OpenGL to Video Surface
+ window.setFullscreen(true);
+ window.setVisible(true);
+
+ while (!quit) {
+ window.display();
+ }
+
+ // Shut things down cooperatively
+ if(null!=movie) {
+ movie.destroy(window.getGL());
+ movie=null;
+ }
+ window.destroy();
+ window.getFactory().shutdown();
+ System.out.println("MovieCube shut down cleanly.");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ GL2ES1 gl = FixedFuncUtil.getFixedFuncImpl(drawable.getGL());
+ System.out.println(gl);
+
+ gl.glGetError(); // flush error ..
+
+ gl.glActiveTexture(GL.GL_TEXTURE0);
+
+ try {
+ movie = new OMXInstance();
+ movie.addEventListener(this);
+ movie.setStream(4, new URL(stream));
+ System.out.println("p0 "+movie);
+ } catch (MalformedURLException mue) { mue.printStackTrace(); }
+ if(null!=movie) {
+ movie.setStreamAllEGLImageTexture2D(gl);
+ movie.activateStream();
+ System.out.println("p1 "+movie);
+ movie.play();
+ }
+
+ cube.init(drawable);
+
+ /*
+ if(gl.isGLES2()) {
+ GLES2 gles2 = gl.getGLES2();
+
+ // Debug ..
+ //DebugGLES2 gldbg = new DebugGLES2(gles2);
+ //gles2.getContext().setGL(gldbg);
+ //gles2 = gldbg;
+
+ // Trace ..
+ //TraceGLES2 gltrace = new TraceGLES2(gles2, System.err);
+ gles2.getContext().setGL(gltrace);
+ gl = gltrace;
+ }*/
+
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ cube.reshape(drawable, x, y, width, height);
+
+ System.out.println("reshape "+width+"x"+height);
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ movie.destroy(gl);
+ movie=null;
+ cube.dispose(drawable);
+ cube=null;
+ quit=true;
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
+
+ com.sun.opengl.util.texture.Texture tex = null;
+ if(null!=movie) {
+ tex=movie.getNextTextureID();
+ if(null!=tex) {
+ System.out.println("Use: "+tex);
+ tex.enable();
+ tex.bind();
+ }
+ }
+ cube.display(drawable);
+ if(null!=tex) {
+ tex.disable();
+ }
+ }
+
+ public void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+
+ public static void main(String[] args) {
+ String fname="file:///Storage Card/resources/a.mp4";
+ if(args.length>0) fname=args[0];
+ new MovieCube(fname).run();
+ System.exit(0);
+ }
+}
+
diff --git a/src/demos/es2/openmax/MovieSimple.java b/src/demos/es2/openmax/MovieSimple.java
new file mode 100755
index 0000000..9088977
--- /dev/null
+++ b/src/demos/es2/openmax/MovieSimple.java
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+
+package demos.es2.openmax;
+
+import javax.media.opengl.*;
+
+import com.sun.opengl.util.glsl.*;
+import com.sun.opengl.util.*;
+
+import com.sun.openmax.*;
+
+import java.nio.*;
+import java.net.*;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.opengl.*;
+
+public class MovieSimple implements MouseListener, GLEventListener, OMXEventListener {
+ private GLWindow window;
+ private boolean quit = false;
+ private boolean rotate = false;
+ private float zoom = -2.5f;
+ private float ang = 0f;
+ private long startTime;
+ private long curTime;
+ private String stream;
+
+ public void changedAttributes(OMXInstance omx, int event_mask) {
+ System.out.println("changed stream attr ("+event_mask+"): "+omx);
+ }
+
+ public void mouseClicked(MouseEvent e) {
+ switch(e.getClickCount()) {
+ case 2:
+ quit=true;
+ break;
+ }
+ }
+ public void mouseEntered(MouseEvent e) {
+ }
+ public void mouseExited(MouseEvent e) {
+ }
+ public void mousePressed(MouseEvent e) {
+ }
+ public void mouseReleased(MouseEvent e) {
+ rotate = false;
+ zoom = -2.5f;
+ }
+ public void mouseMoved(MouseEvent e) {
+ }
+ public void mouseDragged(MouseEvent e) {
+ rotate = true;
+ zoom = -5;
+ }
+ public void mouseWheelMoved(MouseEvent e) {
+ }
+
+ public MovieSimple(String stream) {
+ this.stream = stream ;
+ }
+
+ private void run() {
+ System.err.println("MovieSimple.run()");
+ try {
+ GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
+ // For emulation library, use 16 bpp
+ caps.setRedBits(5);
+ caps.setGreenBits(6);
+ caps.setBlueBits(5);
+ caps.setDepthBits(16);
+
+ window = GLWindow.create(caps);
+
+ window.addMouseListener(this);
+ window.addGLEventListener(this);
+ // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_CURRENT); // default
+ // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_NONE); // no current ..
+
+ // Size OpenGL to Video Surface
+ window.setFullscreen(true);
+ window.setVisible(true);
+
+ startTime = System.currentTimeMillis();
+ while (!quit) {
+ window.display();
+ }
+
+ // Shut things down cooperatively
+ if(null!=movie) {
+ movie.destroy(window.getGL());
+ movie=null;
+ }
+ window.destroy();
+ window.getFactory().shutdown();
+ System.out.println("MovieSimple shut down cleanly.");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ ShaderState st;
+ PMVMatrix pmvMatrix;
+
+ private void initShader(GL2ES2 gl) {
+ int tmpI;
+
+ // Create & Compile the shader objects
+ ShaderCode rsVp = ShaderCode.create(gl, gl.GL_VERTEX_SHADER, 1, MovieSimple.class,
+ "shader", "shader/bin", "moviesimple");
+ ShaderCode rsFp = ShaderCode.create(gl, gl.GL_FRAGMENT_SHADER, 1, MovieSimple.class,
+ "shader", "shader/bin", "moviesimple");
+
+ // Create & Link the shader program
+ ShaderProgram sp = new ShaderProgram();
+ sp.add(rsVp);
+ sp.add(rsFp);
+ if(!sp.link(gl, System.err)) {
+ throw new GLException("Couldn't link program: "+sp);
+ }
+
+ // Let's manage all our states using ShaderState.
+ st = new ShaderState();
+ st.attachShaderProgram(gl, sp);
+ }
+
+ OMXInstance movie=null;
+
+ public void init(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ System.err.println("Entering initialization");
+ System.err.println("GL_VERSION=" + gl.glGetString(gl.GL_VERSION));
+ System.err.println("GL_EXTENSIONS:");
+ System.err.println(" " + gl.glGetString(gl.GL_EXTENSIONS));
+
+ pmvMatrix = new PMVMatrix();
+
+ initShader(gl);
+
+ // Push the 1st uniform down the path
+ st.glUseProgram(gl, true);
+
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+
+ if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) {
+ throw new GLException("Error setting PMVMatrix in shader: "+st);
+ }
+ if(!st.glUniform(gl, new GLUniformData("mgl_ActiveTexture", 0))) {
+ throw new GLException("Error setting mgl_ActiveTexture in shader: "+st);
+ }
+ gl.glActiveTexture(GL.GL_TEXTURE0);
+
+ float aspect = 16.0f/9.0f;
+ float xs=1f, ys=1f; // scale object
+ float ss=1f, ts=1f; // scale tex-coord
+
+ if(true) {
+ xs = aspect; // b > h
+ ys = 1f; // b > h
+ } else {
+ ss = 1f/aspect; // b > h, crop width
+ ts = 1f; // b > h
+ }
+
+ // Allocate vertex array
+ GLArrayDataServer vertices = GLArrayDataServer.createGLSL(gl, "mgl_Vertex", 3, gl.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
+ {
+ // Fill them up
+ FloatBuffer verticeb = (FloatBuffer)vertices.getBuffer();
+ verticeb.put(-1f*xs); verticeb.put( -1f*ys); verticeb.put( 0);
+ verticeb.put(-1f*xs); verticeb.put( 1f*ys); verticeb.put( 0);
+ verticeb.put( 1f*xs); verticeb.put( -1f*ys); verticeb.put( 0);
+ verticeb.put( 1f*xs); verticeb.put( 1f*ys); verticeb.put( 0);
+ }
+ vertices.seal(gl, true);
+
+ // Allocate texcoord array
+ GLArrayDataServer texcoord = GLArrayDataServer.createGLSL(gl, "mgl_MultiTexCoord", 2, gl.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
+ {
+ // Fill them up
+ FloatBuffer texcoordb = (FloatBuffer)texcoord.getBuffer();
+ texcoordb.put( 0f*ss); texcoordb.put( 0f*ts);
+ texcoordb.put( 0f*ss); texcoordb.put( 1f*ts);
+ texcoordb.put( 1f*ss); texcoordb.put( 0f*ts);
+ texcoordb.put( 1f*ss); texcoordb.put( 1f*ts);
+ }
+ texcoord.seal(gl, true);
+
+ GLArrayDataServer colors = GLArrayDataServer.createGLSL(gl, "mgl_Color", 4, gl.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
+ {
+ // Fill them up
+ FloatBuffer colorb = (FloatBuffer)colors.getBuffer();
+ colorb.put( 0); colorb.put( 0); colorb.put( 0); colorb.put( 1);
+ colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put( 1);
+ colorb.put( 0); colorb.put( 0); colorb.put( 0); colorb.put( 1);
+ colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put( 1);
+ }
+ colors.seal(gl, true);
+
+ // OpenGL Render Settings
+ gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
+ gl.glEnable(GL2ES2.GL_DEPTH_TEST);
+
+ st.glUseProgram(gl, false);
+
+ // Let's show the completed shader state ..
+ System.out.println(st);
+
+ try {
+ movie = new OMXInstance();
+ movie.addEventListener(this);
+ movie.setStream(4, new URL(stream));
+ System.out.println("p0 "+movie);
+ } catch (MalformedURLException mue) { mue.printStackTrace(); }
+ if(null!=movie) {
+ //movie.setStreamAllEGLImageTexture2D(gl);
+ //movie.activateStream();
+ //System.out.println("p1 "+movie);
+ movie.play();
+ }
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ st.glUseProgram(gl, true);
+
+ // Set location in front of camera
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.gluPerspective(45.0f, (float)width / (float)height, 1.0f, 100.0f);
+ //pmvMatrix.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f);
+
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glTranslatef(0, 0, zoom);
+
+ GLUniformData ud = st.getUniform("mgl_PMVMatrix");
+ if(null!=ud) {
+ // same data object
+ st.glUniform(gl, ud);
+ }
+
+ st.glUseProgram(gl, false);
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ movie.destroy(gl);
+ movie=null;
+ pmvMatrix.destroy();
+ pmvMatrix=null;
+ st.destroy(gl);
+ st=null;
+ quit=true;
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ st.glUseProgram(gl, true);
+
+ gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
+
+ if(rotate) {
+ curTime = System.currentTimeMillis();
+ ang = ((float) (curTime - startTime) * 360.0f) / 8000.0f;
+ }
+
+ if(rotate || zoom!=0f) {
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glTranslatef(0, 0, zoom);
+ pmvMatrix.glRotatef(ang, 0, 0, 1);
+ // pmvMatrix.glRotatef(ang, 0, 1, 0);
+
+ GLUniformData ud = st.getUniform("mgl_PMVMatrix");
+ if(null!=ud) {
+ // same data object
+ st.glUniform(gl, ud);
+ }
+
+ if(!rotate) {
+ zoom=0f;
+ }
+ }
+
+
+ com.sun.opengl.util.texture.Texture tex = null;
+ if(null!=movie) {
+ tex=movie.getNextTextureID();
+ if(null!=tex) {
+ tex.enable();
+ tex.bind();
+ }
+ }
+
+ // Draw a square
+ gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4);
+
+ if(null!=tex) {
+ tex.disable();
+ }
+
+ st.glUseProgram(gl, false);
+ }
+
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+
+ public static void main(String[] args) {
+ String fname="file:///Storage Card/resources/a.mp4";
+ if(args.length>0) fname=args[0];
+ new MovieSimple(fname).run();
+ System.exit(0);
+ }
+}
diff --git a/src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bfp b/src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bfp
new file mode 100755
index 0000000..97a6980
--- /dev/null
+++ b/src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bfp
Binary files differ
diff --git a/src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bvp b/src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bvp
new file mode 100755
index 0000000..2ca3dff
--- /dev/null
+++ b/src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bvp
Binary files differ
diff --git a/src/demos/es2/openmax/shader/moviesimple.fp b/src/demos/es2/openmax/shader/moviesimple.fp
new file mode 100644
index 0000000..c711641
--- /dev/null
+++ b/src/demos/es2/openmax/shader/moviesimple.fp
@@ -0,0 +1,21 @@
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+#else
+ #define MEDIUMP
+ #define HIGHP
+#endif
+
+uniform sampler2D mgl_ActiveTexture;
+varying HIGHP vec4 mgl_texCoord;
+varying HIGHP vec4 frontColor;
+
+void main (void)
+{
+ vec4 texColor = texture2D(mgl_ActiveTexture, mgl_texCoord.st);
+
+ // mix frontColor with texture ..
+ gl_FragColor = vec4(frontColor.rgb*texColor.rgb, frontColor.a);
+}
+
diff --git a/src/demos/es2/openmax/shader/moviesimple.vp b/src/demos/es2/openmax/shader/moviesimple.vp
new file mode 100644
index 0000000..0b78eb9
--- /dev/null
+++ b/src/demos/es2/openmax/shader/moviesimple.vp
@@ -0,0 +1,22 @@
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+#else
+ #define MEDIUMP
+ #define HIGHP
+#endif
+
+uniform MEDIUMP mat4 mgl_PMVMatrix[2];
+attribute HIGHP vec4 mgl_Vertex;
+attribute HIGHP vec4 mgl_Color;
+attribute HIGHP vec4 mgl_MultiTexCoord;
+varying HIGHP vec4 frontColor;
+varying HIGHP vec4 mgl_texCoord;
+
+void main(void)
+{
+ frontColor=mgl_Color;
+ mgl_texCoord = mgl_MultiTexCoord;
+ gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex;
+}
diff --git a/src/demos/es2/openmax/shader/scripts/nvidia-apx/glslc-ff.bat b/src/demos/es2/openmax/shader/scripts/nvidia-apx/glslc-ff.bat
new file mode 100755
index 0000000..a93f43c
--- /dev/null
+++ b/src/demos/es2/openmax/shader/scripts/nvidia-apx/glslc-ff.bat
@@ -0,0 +1,9 @@
+REM
+REM You have to call it from the 'shader' directory, e.g.:
+REM scripts\nvidia-apx\glslc-ff.bat
+REM
+IF !"%JOGLDIR%"==""! GOTO YESPATH
+set JOGLDIR=..\lib
+:YESPATH
+
+java -cp %JOGLDIR%\jogl.core.jar;%JOGLDIR%\jogl.gles2.jar;%JOGLDIR%\jogl.fixed.jar;%JOGLDIR%\jogl.sdk.jar javax.media.opengl.sdk.glsl.CompileShaderNVidia moviesimple.vp moviesimple.fp
diff --git a/src/demos/es2/perftst/PerfModule.java b/src/demos/es2/perftst/PerfModule.java
new file mode 100644
index 0000000..1a6cda1
--- /dev/null
+++ b/src/demos/es2/perftst/PerfModule.java
@@ -0,0 +1,95 @@
+package demos.es2.perftst;
+
+import java.nio.*;
+import javax.media.opengl.*;
+
+import com.sun.opengl.util.*;
+import com.sun.opengl.util.glsl.*;
+
+public abstract class PerfModule {
+
+ public abstract void 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;
+
+ long t0, t1;
+
+ st = new ShaderState();
+
+ // Create & Compile the shader objects
+ ShaderCode vp = ShaderCode.create(gl, gl.GL_VERTEX_SHADER, 1, Perftst.class,
+ "shader", "shader/bin", vShaderName);
+ ShaderCode fp = ShaderCode.create(gl, gl.GL_FRAGMENT_SHADER, 1, Perftst.class,
+ "shader", "shader/bin", fShaderName);
+
+ // Create & Link the shader program
+ ShaderProgram sp = new ShaderProgram();
+ sp.add(vp);
+ sp.add(fp);
+
+ t0 = System.currentTimeMillis();
+
+ if(!sp.link(gl, System.err)) {
+ throw new GLException("Couldn't link program: "+sp);
+ }
+
+ t1 = System.currentTimeMillis();
+
+ long dt = t1-t0;
+
+ System.out.println("shader creation: "+dt+" ms");
+
+ // Let's manage all our states using ShaderState.
+ st.attachShaderProgram(gl, sp);
+
+ st.glUseProgram(gl, true);
+ }
+
+ public static final void put(Buffer buffer, int type, float v) {
+ switch (type) {
+ case GL.GL_UNSIGNED_BYTE:
+ ((ByteBuffer)buffer).put((byte)(v*(float)0xFF));
+ break;
+ case GL.GL_BYTE:
+ ((ByteBuffer)buffer).put((byte)(v*(float)0x7F));
+ break;
+ case GL.GL_UNSIGNED_SHORT:
+ ((ShortBuffer)buffer).put((short)(v*(float)0xFFFF));
+ break;
+ case GL.GL_SHORT:
+ ((ShortBuffer)buffer).put((short)(v*(float)0x7FFF));
+ break;
+ case GL.GL_FLOAT:
+ ((FloatBuffer)buffer).put(v);
+ break;
+ case GL.GL_FIXED:
+ ((IntBuffer)buffer).put(FixedPoint.toFixed(v));
+ break;
+ }
+ }
+
+ public static final String getTypeName(int type) {
+ switch (type) {
+ case GL.GL_UNSIGNED_BYTE:
+ return "GL_UNSIGNED_BYTE";
+ case GL.GL_BYTE:
+ return "GL_BYTE";
+ case GL.GL_UNSIGNED_SHORT:
+ return "GL_UNSIGNED_SHORT";
+ case GL.GL_SHORT:
+ return "GL_SHORT";
+ case GL.GL_FLOAT:
+ return "GL_FLOAT";
+ case GL.GL_FIXED:
+ return "GL_FIXED";
+ }
+ return null;
+ }
+
+}
+
diff --git a/src/demos/es2/perftst/PerfTextLoad.java b/src/demos/es2/perftst/PerfTextLoad.java
new file mode 100755
index 0000000..55aad9a
--- /dev/null
+++ b/src/demos/es2/perftst/PerfTextLoad.java
@@ -0,0 +1,219 @@
+package demos.es2.perftst;
+
+import java.nio.*;
+import java.io.*;
+import java.net.*;
+import javax.media.opengl.*;
+import com.sun.opengl.util.*;
+import com.sun.opengl.util.texture.*;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.opengl.*;
+
+public class PerfTextLoad extends PerfModule {
+ static final int MAX_TEXTURE_ENGINES = 8;
+
+ public PerfTextLoad() {
+ }
+
+ public void initShaderState(GL2ES2 gl) {
+ initShaderState(gl, "vbo-vert-text", "ftext");
+ }
+
+ Texture[] textures = null;
+ TextureData[] textDatas = null;
+
+ protected void runOneSet(GLAutoDrawable drawable, String textBaseName, int numObjs, int numTextures, int loops) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ if(numTextures>MAX_TEXTURE_ENGINES) {
+ throw new GLException("numTextures must be within 1.."+MAX_TEXTURE_ENGINES);
+ }
+
+ String textName = null;
+ textDatas = new TextureData[numObjs];
+ textures = new Texture[numTextures];
+ try {
+ for(int i=0; i<numObjs; i++) {
+ textName = "data/"+textBaseName+"."+(i+1)+".tga";
+ URL urlText = Locator.getResource(Perftst.class, textName);
+ if(urlText==null) {
+ throw new RuntimeException("couldn't fetch "+textName);
+ }
+ textDatas[i] = TextureIO.newTextureData(urlText.openStream(), false, TextureIO.TGA);
+ System.out.println(textBaseName+": "+textDatas[i]);
+ }
+
+ for(int i=0; i<numTextures; i++) {
+ gl.glActiveTexture(i);
+ textures[i] = new Texture(GL.GL_TEXTURE_2D);
+ }
+ } catch (IOException ioe) {
+ System.err.println("couldn't fetch "+textName);
+ throw new RuntimeException(ioe);
+ }
+
+ //
+ // Vertices Data setup
+ //
+
+ st.glUseProgram(gl, true);
+
+ GLArrayDataServer vertices = GLArrayDataServer.createGLSL(gl, "mgl_Vertex", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW);
+ {
+ FloatBuffer vb = (FloatBuffer)vertices.getBuffer();
+ vb.put(0f); vb.put(0f);
+ vb.put(1f); vb.put(0f);
+ vb.put(0f); vb.put(1f);
+ vb.put(1f); vb.put(1f);
+ }
+ vertices.seal(gl, true);
+
+ GLArrayDataServer texCoords = GLArrayDataServer.createGLSL(gl, "mgl_MultiTexCoord0", 2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW);
+ {
+ FloatBuffer cb = (FloatBuffer)texCoords.getBuffer();
+ cb.put(0f); cb.put(0f);
+ cb.put(1f); cb.put(0f);
+ cb.put(0f); cb.put(1f);
+ cb.put(1f); cb.put(1f);
+ }
+ texCoords.seal(gl, true);
+
+ //
+ // texture setup
+ //
+ long[] tU = new long[numObjs+1];
+ tU[0] = System.currentTimeMillis();
+ for(int j=0; j<numTextures; j++) {
+ gl.glActiveTexture(j);
+ textures[j].updateImage(textDatas[0]);
+ tU[j+1] = System.currentTimeMillis();
+ }
+
+ GLUniformData activeTexture = new GLUniformData("mgl_ActiveTexture", 0);
+ st.glUniform(gl, activeTexture);
+
+ //
+ // run loops
+ //
+
+ long dtC, dt, dt2, dt3, dtF, dtS, dtT;
+ long[][] tC = new long[loops][numObjs];
+ long[][] t0 = new long[loops][numObjs];
+ long[][][] t1 = new long[loops][numObjs][numTextures];
+ long[][][] t2 = new long[loops][numObjs][numTextures];
+ long[][][] t3 = new long[loops][numObjs][numTextures];
+ long[][] tF = new long[loops][numObjs];
+ long[][] tS = new long[loops][numObjs];
+
+ for(int i=0; i<loops; i++) {
+ for(int j=0; j<numObjs; j++) {
+ tC[i][j] = System.currentTimeMillis();
+
+ gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
+
+ t0[i][j] = System.currentTimeMillis();
+
+ for(int k=0; k<numTextures; k++) {
+ gl.glActiveTexture(GL.GL_TEXTURE0+k);
+ textures[k].enable();
+ textures[k].bind();
+ activeTexture.setData(k);
+ st.glUniform(gl, activeTexture);
+
+ t1[i][j][k] = System.currentTimeMillis();
+
+ textures[k].updateSubImage(textDatas[j], 0, 0, 0);
+
+ t2[i][j][k] = System.currentTimeMillis();
+
+ gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, vertices.getElementNumber());
+
+ t3[i][j][k] = System.currentTimeMillis();
+ }
+ gl.glFinish();
+
+ tF[i][j] = System.currentTimeMillis();
+
+ drawable.swapBuffers();
+
+ tS[i][j] = System.currentTimeMillis();
+
+ /*try {
+ Thread.sleep(100);
+ } catch (Exception e) {} */
+ }
+
+ }
+
+ int textBytes = 0;
+ for(int j=0; j<numObjs; j++) {
+ textBytes += textDatas[j].getEstimatedMemorySize();
+ }
+ textBytes*=numTextures;
+
+ dt = 0;
+ for(int i=1; i<loops; i++) {
+ for(int j=0; j<numObjs; j++) {
+ dt += tS[i][j] - tC[i][j];
+ }
+ }
+
+ System.out.println("");
+ System.out.println("Texture "+textBaseName+", loops "+loops+", textures "+numTextures+", objects "+numObjs+
+ ", total bytes "+textBytes+", total time: "+dt +
+ "ms, fps(-1): "+(((loops-1)*numObjs*1000)/dt)+
+ ",\n text kB/s: " + ( ((double)(loops*textBytes)/1024.0) / ((double)dt/1000.0) ) );
+
+ for(int i=0; i<loops; i++) {
+ dtC = 0;
+ dtF = 0;
+ dtS = 0;
+ dtT = 0;
+ for(int j=0; j<numObjs; j++) {
+ dtC += t0[i][j] - tC[i][j];
+ dtF += tF[i][j] - t3[i][j][numTextures-1];
+ dtS += tS[i][j] - tF[i][j];
+ dtT += tS[i][j] - tC[i][j];
+ }
+ if(dtT<=0) dtT=1;
+ System.out.println("\tloop "+i+": clear "+dtC+"ms, finish "+dtF+", swap "+dtS+"ms, total: "+ dtT+"ms, fps "+(numObjs*1000)/dtT);
+ /*
+ for(int j=0; j<dummyUni.length; j++) {
+ dt = t1[i][j] - t0[i];
+ dt2= t2[i][j] - t1[i][j];
+ dt3= t3[i][j] - t2[i][j];
+ dtT= dt+dt2+dt3;
+ System.out.println("\t\tobj "+j+": setup "+dt +"ms, update "+dt2 +"ms, draw "+dt3+"ms, total: "+ dtT);
+ } */
+ }
+ System.out.println("*****************************************************************");
+
+ st.glUseProgram(gl, false);
+
+ for(int i=0; i<numTextures; i++) {
+ textures[i].disable();
+ textures[i].dispose();
+ textures[i]=null;
+ }
+ for(int i=0; i<numObjs; i++) {
+ textDatas[i] = null;
+ }
+ textures=null;
+ textDatas=null;
+ System.gc();
+ try {
+ Thread.sleep(100);
+ } catch (Exception e) {}
+ System.gc();
+ }
+
+ public void run(GLAutoDrawable drawable, int loops) {
+ runOneSet(drawable, "bob2.64x64", 33, 1, loops);
+ runOneSet(drawable, "bob2.128x128", 33, 1, loops);
+ runOneSet(drawable, "bob2.128x128", 4, 1, loops);
+ runOneSet(drawable, "bob2.256x256", 4, 1, loops);
+ runOneSet(drawable, "bob2.512x512", 4, 1, loops);
+ }
+
+}
diff --git a/src/demos/es2/perftst/PerfUniLoad.java b/src/demos/es2/perftst/PerfUniLoad.java
new file mode 100755
index 0000000..a87d386
--- /dev/null
+++ b/src/demos/es2/perftst/PerfUniLoad.java
@@ -0,0 +1,189 @@
+package demos.es2.perftst;
+
+import java.nio.*;
+import javax.media.opengl.*;
+import com.sun.opengl.util.*;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.opengl.*;
+
+public class PerfUniLoad extends PerfModule {
+ static final int MAX_ARRAYS = 12;
+ static final int MAX_ARRAY_ELEM = 16;
+
+ GLUniformData[] dummyA, dummyB, dummyC;
+ final int dataType=GL.GL_FLOAT;
+
+ public PerfUniLoad() {
+ }
+
+ public void initShaderState(GL2ES2 gl) {
+ initShaderState(gl, "uni-vert-col", "fcolor");
+ }
+
+ protected void runOneSet(GLAutoDrawable drawable, int numObjs, int numArrayElem, int loops) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ //
+ // Vertices Data setup
+ //
+
+ if(numObjs>MAX_ARRAYS) {
+ throw new GLException("numObjs must be within 0.."+MAX_ARRAYS);
+ }
+
+ if(numArrayElem>MAX_ARRAY_ELEM) {
+ throw new GLException("numArrayElem must be within 0.."+MAX_ARRAY_ELEM);
+ }
+
+ st.glUseProgram(gl, true);
+
+ GLArrayDataServer vertices = GLArrayDataServer.createGLSL(gl, "mgl_Vertex", 3, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW);
+ {
+ FloatBuffer vb = (FloatBuffer)vertices.getBuffer();
+ vb.put(0f); vb.put(0f); vb.put(0f);
+ vb.put(1f); vb.put(0f); vb.put(0f);
+ vb.put(0f); vb.put(1f); vb.put(0f);
+ vb.put(1f); vb.put(1f); vb.put(0f);
+ }
+ vertices.seal(gl, true);
+
+ GLArrayDataServer colors = GLArrayDataServer.createGLSL(gl, "mgl_Color", 4, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW);
+ {
+ FloatBuffer cb = (FloatBuffer)colors.getBuffer();
+ cb.put(0f); cb.put(0f); cb.put(0f); cb.put(1f);
+ cb.put(1f); cb.put(0f); cb.put(0f); cb.put(1f);
+ cb.put(0f); cb.put(1f); cb.put(0f); cb.put(1f);
+ cb.put(0f); cb.put(0f); cb.put(1f); cb.put(1f);
+ }
+ colors.seal(gl, true);
+
+ //
+ // Uniform Data setup
+ //
+
+ GLUniformData[] dummyUni = new GLUniformData[numObjs];
+
+ float x=0f, y=0f, z=0f, w=0f;
+
+ for(int i=0; i<numObjs; i++) {
+ FloatBuffer fb = BufferUtil.newFloatBuffer(4*numArrayElem);
+
+ for(int j=0; j<numArrayElem; j++) {
+ // Fill them up
+ fb.put(x);
+ fb.put(y);
+ fb.put(z);
+ fb.put(w);
+ if(x==0f) x=1f;
+ else if(x==1f) { x=0f; y+=0.01f; }
+ if(y>1f) { x=0f; y=0f; z+=0.01f; }
+ }
+ fb.flip();
+
+ dummyUni[i] = new GLUniformData("mgl_Dummy"+i, 4, fb);
+ }
+
+ //
+ // run loops
+ //
+
+ long dtC, dt, dt2, dt3, dtF, dtS, dtT;
+ long[] tC = new long[loops];
+ long[] t0 = new long[loops];
+ long[][] t1 = new long[loops][numObjs];
+ long[][] t2 = new long[loops][numObjs];
+ long[] tF = new long[loops];
+ long[] tS = new long[loops];
+
+ for(int i=0; i<loops; i++) {
+ tC[i] = System.currentTimeMillis();
+
+ gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
+
+ t0[i] = System.currentTimeMillis();
+
+ for(int j=0; j<numObjs; j++) {
+ st.glUniform(gl, dummyUni[j]);
+
+ t1[i][j] = System.currentTimeMillis();
+
+ gl.glDrawArrays(GL.GL_LINE_STRIP, 0, vertices.getElementNumber());
+
+ t2[i][j] = System.currentTimeMillis();
+ }
+
+ gl.glFinish();
+
+ tF[i] = System.currentTimeMillis();
+
+ drawable.swapBuffers();
+
+ tS[i] = System.currentTimeMillis();
+ }
+
+ int uniElements = numObjs * numArrayElem ;
+ int uniBytes = uniElements * BufferUtil.SIZEOF_FLOAT;
+
+ dt = 0;
+ for(int i=1; i<loops; i++) {
+ dt += tS[i] - tC[i];
+ }
+
+ System.out.println("");
+ System.out.println("Loops "+loops+", uniform arrays "+dummyUni.length+", type FLOAT"+
+ ", uniforms array size "+numArrayElem+
+ ",\n total elements "+uniElements+
+ ", total bytes "+uniBytes+", total time: "+dt +
+ "ms, fps(-1): "+(((loops-1)*1000)/dt)+
+ ",\n uni elem/s: " + ((double)(loops*uniElements)/((double)dt/1000.0)));
+
+ for(int i=0; i<loops; i++) {
+ dtC= t0[i] - tC[i];
+ dtF= tF[i] - t2[i][dummyUni.length-1];
+ dtS= tS[i] - tF[i];
+ dtT= tS[i] - tC[i];
+ if(dtT<=0) dtT=1;
+ System.out.println("\tloop "+i+": clear "+dtC+"ms, finish "+dtF+", swap "+dtS+"ms, total: "+ dtT+"ms, fps "+1000/dtT);
+ /*
+ for(int j=0; j<dummyUni.length; j++) {
+ dt = t1[i][j] - t0[i];
+ dt2= t2[i][j] - t1[i][j];
+ dtT= dt+dt2;
+ System.out.println("\t\tobj "+j+": uniform "+dt +"ms, draw "+dt2+"ms, total: "+ dtT);
+ } */
+ }
+ System.out.println("*****************************************************************");
+
+
+ st.glUseProgram(gl, false);
+
+ try {
+ Thread.sleep(100);
+ } catch (Exception e) {}
+ }
+
+ public void run(GLAutoDrawable drawable, int loops) {
+ runOneSet(drawable, 1, 1, loops);
+
+ runOneSet(drawable, 4, 1, loops);
+ runOneSet(drawable, 1, 4, loops);
+
+ runOneSet(drawable, 8, 1, loops);
+ runOneSet(drawable, 1, 8, loops);
+
+ if(MAX_ARRAYS>8) {
+ runOneSet(drawable, MAX_ARRAYS, 1, loops);
+ runOneSet(drawable, 1, MAX_ARRAYS, loops);
+ }
+ runOneSet(drawable, 1, 16, loops);
+
+ runOneSet(drawable, 2, 16, loops);
+ runOneSet(drawable, 4, 16, loops);
+ runOneSet(drawable, 8, 16, loops);
+ if(MAX_ARRAYS>8) {
+ runOneSet(drawable, MAX_ARRAYS, 16, loops);
+ }
+ }
+
+}
diff --git a/src/demos/es2/perftst/PerfVBOLoad.java b/src/demos/es2/perftst/PerfVBOLoad.java
new file mode 100755
index 0000000..376ab0a
--- /dev/null
+++ b/src/demos/es2/perftst/PerfVBOLoad.java
@@ -0,0 +1,239 @@
+package demos.es2.perftst;
+
+import java.nio.*;
+import javax.media.opengl.*;
+import com.sun.opengl.util.*;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.opengl.*;
+
+public class PerfVBOLoad extends PerfModule {
+
+ public PerfVBOLoad() {
+ }
+
+ public void initShaderState(GL2ES2 gl) {
+ initShaderState(gl, "vbo-vert-col", "fcolor");
+ }
+
+ protected void runOneSet(GLAutoDrawable drawable, int dataType, int numObjs, int numVertices, int loops, boolean useVBO) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ //
+ // data setup
+ //
+
+ GLArrayDataServer[] vertices = new GLArrayDataServer[numObjs];
+ GLArrayDataServer[] colors = new GLArrayDataServer[numObjs];
+
+ float x=0f, y=0f, z=0f;
+ float r=1f, g=1f, b=1f;
+
+ for(int i=0; i<numObjs; i++) {
+ vertices[i] = GLArrayDataServer.createGLSL(gl, "mgl_Vertex", 3, dataType, true, numVertices, GL.GL_STATIC_DRAW);
+ vertices[i].setVBOUsage(useVBO);
+ {
+ Buffer verticeb = vertices[i].getBuffer();
+ for(int j=0; j<numVertices; j++) {
+ // Fill them up
+ put(verticeb, dataType, x);
+ put(verticeb, dataType, y);
+ put(verticeb, dataType, z);
+ if(x==0f) x=1f;
+ else if(x==1f) { x=0f; y+=0.01f; }
+ if(y>1f) { x=0f; y=0f; z+=0.01f; }
+ }
+ }
+ colors[i] = GLArrayDataServer.createGLSL(gl, "mgl_Color", 4, dataType, true, numVertices, GL.GL_STATIC_DRAW);
+ colors[i].setVBOUsage(useVBO);
+ {
+ // Fill them up
+ Buffer colorb = colors[i].getBuffer();
+ for(int j =0; j<numVertices; j++) {
+ put(colorb, dataType, r);
+ put(colorb, dataType, g);
+ put(colorb, dataType, b);
+ put(colorb, dataType, 1f-(float)i/10);
+ if(r<=1f) r+=0.01f;
+ else if(g<=1f) g+=0.01f;
+ else if(b<=1f) b+=0.01f;
+ else { r=0f; g=0f; b=0f; }
+ }
+ }
+ }
+
+ //
+ // run loops
+ //
+
+ long dtC, dt, dt2, dt3, dtF, dtS, dtT;
+ long[] tC = new long[loops];
+ long[] t0 = new long[loops];
+ long[][] t1 = new long[loops][numObjs];
+ long[][] t2 = new long[loops][numObjs];
+ long[][] t3 = new long[loops][numObjs];
+ long[] tF = new long[loops];
+ long[] tS = new long[loops];
+
+ // Push the 1st uniform down the path
+ st.glUseProgram(gl, true);
+
+ for(int i=0; i<loops; i++) {
+ tC[i] = System.currentTimeMillis();
+
+ gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
+
+ t0[i] = System.currentTimeMillis();
+
+ for(int j=0; j<numObjs; j++) {
+ if(i==0) {
+ vertices[j].seal(gl, true);
+ } else if(numObjs>1) {
+ // we need to re-enable the buffer,
+ // incl. the vertex attribute refresh
+ // in case we switch to another buffer
+ vertices[j].enableBuffer(gl, true);
+ }
+
+ t1[i][j] = System.currentTimeMillis();
+
+ if(i==0) {
+ colors[j].seal(gl, true);
+ } else {
+ colors[j].enableBuffer(gl, true);
+ }
+
+ t2[i][j] = System.currentTimeMillis();
+
+ gl.glDrawArrays(GL.GL_LINE_STRIP, 0, vertices[j].getElementNumber());
+
+ if(numObjs>1) {
+ vertices[j].enableBuffer(gl, false);
+ colors[j].enableBuffer(gl, false);
+ }
+
+ t3[i][j] = System.currentTimeMillis();
+ }
+
+ gl.glFinish();
+
+ tF[i] = System.currentTimeMillis();
+
+ drawable.swapBuffers();
+
+ tS[i] = System.currentTimeMillis();
+ }
+
+ if(numObjs==1) {
+ vertices[0].enableBuffer(gl, false);
+ colors[0].enableBuffer(gl, false);
+ }
+
+ int verticesElements = vertices[0].getElementNumber() * numObjs;
+ int verticesBytes = verticesElements * vertices[0].getComponentSize()* vertices[0].getComponentNumber();
+ int colorsElements = colors[0].getElementNumber() * colors.length;
+ int colorsBytes = colorsElements * colors[0].getComponentSize()* colors[0].getComponentNumber();
+
+ dt = 0;
+ for(int i=1; i<loops; i++) {
+ dt += tS[i] - tC[i];
+ }
+
+ System.out.println("");
+ System.out.println("Loops "+loops+", useVBO "+useVBO+", objects "+numObjs+", type "+getTypeName(dataType)+
+ ", vertices p.o. "+vertices[0].getElementNumber()+
+ ", colors p.o. "+colors[0].getElementNumber()+
+ ",\n total elements "+(verticesElements+colorsElements)+
+ ", total bytes "+(verticesBytes+colorsBytes)+", total time: "+dt +
+ "ms, fps(-1): "+(((loops-1)*1000)/dt)+
+ ",\n col.vert./s: " + ((double)(loops*verticesElements)/((double)dt/1000.0)));
+
+ for(int i=0; i<loops; i++) {
+ dtC= t0[i] - tC[i];
+ dtF= tF[i] - t3[i][numObjs-1];
+ dtS= tS[i] - tF[i];
+ dtT= tS[i] - tC[i];
+ if(dtT<=0) dtT=1;
+ System.out.println("\tloop "+i+": clear "+dtC+"ms, finish "+dtF+", swap "+dtS+"ms, total: "+ dtT+"ms, fps "+1000/dtT);
+ /*
+ for(int j=0; j<numObjs; j++) {
+ dt = t1[i][j] - t0[i];
+ dt2= t2[i][j] - t1[i][j];
+ dt3= t3[i][j] - t2[i][j];
+ dtT= dt+dt2+dt3;
+ System.out.println("\t\tobj "+j+": vertices "+dt +"ms, colors "+dt2+"ms, draw "+dt3+"ms, total: "+ dtT);
+ } */
+ }
+ System.out.println("*****************************************************************");
+
+ st.glUseProgram(gl, false);
+
+ for(int i=0; i<numObjs; i++) {
+ vertices[i].destroy(gl);
+ colors[i].destroy(gl);
+ vertices[i]=null;
+ colors[i]=null;
+ }
+ vertices=null;
+ colors=null;
+ System.gc();
+
+ try {
+ Thread.sleep(100);
+ } catch (Exception e) {}
+ }
+
+ protected void runOneSet(GLAutoDrawable drawable, int numObjs, int numVertices, int loops) {
+ runOneSet(drawable, GL.GL_UNSIGNED_BYTE, numObjs, numVertices, loops, true);
+ runOneSet(drawable, GL.GL_UNSIGNED_BYTE, numObjs, numVertices, loops, false);
+ runOneSet(drawable, GL.GL_BYTE, numObjs, numVertices, loops, true);
+ runOneSet(drawable, GL.GL_BYTE, numObjs, numVertices, loops, false);
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, numObjs, numVertices, loops, true);
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, numObjs, numVertices, loops, false);
+ runOneSet(drawable, GL.GL_SHORT, numObjs, numVertices, loops, true);
+ runOneSet(drawable, GL.GL_SHORT, numObjs, numVertices, loops, false);
+ runOneSet(drawable, GL.GL_FLOAT, numObjs, numVertices, loops, true);
+ runOneSet(drawable, GL.GL_FLOAT, numObjs, numVertices, loops, false);
+
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ if(gl.isGLES2()) {
+ runOneSet(drawable, GL.GL_FIXED, numObjs, numVertices, loops, true);
+ runOneSet(drawable, GL.GL_FIXED, numObjs, numVertices, loops, false);
+ }
+ }
+
+ public void run(GLAutoDrawable drawable, int loops) {
+ runOneSet(drawable, 1, 100, loops);
+ runOneSet(drawable, 3, 100, loops);
+
+ runOneSet(drawable, 1, 1000, loops);
+ runOneSet(drawable, 3, 1000, loops);
+
+ runOneSet(drawable, 1, 10000, loops);
+ runOneSet(drawable, 3, 10000, loops);
+
+ runOneSet(drawable, 1, 100000, loops);
+ runOneSet(drawable, 3, 100000, loops);
+
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 10, 150, loops, true);
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 10, 150, loops, false);
+
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 20, 150, loops, true);
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 20, 150, loops, false);
+
+ /*
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 30, 150, loops, true);
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 30, 150, loops, false);
+
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 40, 150, loops, true);
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 40, 150, loops, false);
+
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 50, 150, loops, true);
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 50, 150, loops, false);
+
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 60, 150, loops, true);
+ runOneSet(drawable, GL.GL_UNSIGNED_SHORT, 60, 150, loops, false);
+ */
+ }
+
+}
diff --git a/src/demos/es2/perftst/Perftst.java b/src/demos/es2/perftst/Perftst.java
new file mode 100755
index 0000000..f023e4d
--- /dev/null
+++ b/src/demos/es2/perftst/Perftst.java
@@ -0,0 +1,185 @@
+package demos.es2.perftst;
+
+import java.nio.*;
+import javax.media.opengl.*;
+import javax.media.nativewindow.*;
+
+import com.sun.opengl.util.*;
+import com.sun.opengl.util.glsl.*;
+
+import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.opengl.*;
+
+public class Perftst implements MouseListener, GLEventListener {
+
+ private GLWindow window;
+ private boolean quit = false;
+
+ private PerfModule pmod;
+ private ShaderState st;
+ private PMVMatrix pmvMatrix;
+
+
+ public void mouseClicked(MouseEvent e) {
+ quit=true;
+ }
+ public void mouseEntered(MouseEvent e) {
+ }
+ public void mouseExited(MouseEvent e) {
+ }
+ public void mousePressed(MouseEvent e) {
+ }
+ public void mouseReleased(MouseEvent e) {
+ }
+ public void mouseMoved(MouseEvent e) {
+ }
+ public void mouseDragged(MouseEvent e) {
+ }
+ public void mouseWheelMoved(MouseEvent e) {
+ }
+
+ private void run(int type, PerfModule pm) {
+ int width = 800;
+ int height = 480;
+ pmod = pm;
+ System.err.println("Perftst.run()");
+ try {
+ GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
+ // For emulation library, use 16 bpp
+ caps.setRedBits(5);
+ caps.setGreenBits(6);
+ caps.setBlueBits(5);
+ caps.setDepthBits(16);
+
+ Window nWindow = null;
+ if(0!=(type&USE_AWT)) {
+ Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display
+ Screen nScreen = NewtFactory.createScreen(NativeWindowFactory.TYPE_AWT, nDisplay, 0); // screen 0
+ nWindow = NewtFactory.createWindow(NativeWindowFactory.TYPE_AWT, nScreen, caps);
+ }
+ window = GLWindow.create(nWindow, caps);
+
+ window.addMouseListener(this);
+ window.addGLEventListener(this);
+ // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_CURRENT); // default
+ // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_NONE); // no current ..
+
+ // Size OpenGL to Video Surface
+ window.setSize(width, height);
+ window.setFullscreen(true);
+ window.setVisible(true);
+
+ window.display();
+
+ // Shut things down cooperatively
+ window.destroy();
+ window.getFactory().shutdown();
+ System.out.println("Perftst shut down cleanly.");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ drawable.setAutoSwapBufferMode(false);
+
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ System.err.println("Entering initialization");
+ System.err.println("GL_VERSION=" + gl.glGetString(gl.GL_VERSION));
+ System.err.println("GL_EXTENSIONS:");
+ System.err.println(" " + gl.glGetString(gl.GL_EXTENSIONS));
+
+ pmvMatrix = new PMVMatrix();
+
+ pmod.initShaderState(gl);
+ st = ShaderState.getCurrent();
+
+ // Push the 1st uniform down the path
+ st.glUseProgram(gl, true);
+
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+
+ if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) {
+ throw new GLException("Error setting PMVMatrix in shader: "+st);
+ }
+
+ // OpenGL Render Settings
+ gl.glClearColor(0, 0, 0, 1);
+ gl.glEnable(GL2ES2.GL_DEPTH_TEST);
+
+ st.glUseProgram(gl, false);
+
+ // Let's show the completed shader state ..
+ System.out.println(st);
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ st.glUseProgram(gl, true);
+
+ // Set location in front of camera
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glOrthof(0f, 1.0f, 0.0f, 1.0f, 1.0f, 100.0f);
+
+ pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glTranslatef(0, 0, -10);
+
+ GLUniformData ud = st.getUniform("mgl_PMVMatrix");
+ if(null!=ud) {
+ // same data object
+ st.glUniform(gl, ud);
+ }
+
+ st.glUseProgram(gl, false);
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ st.destroy(gl);
+ st=null;
+ pmvMatrix.destroy();
+ pmvMatrix=null;
+ quit=true;
+ }
+
+
+ public void display(GLAutoDrawable drawable) {
+ pmod.run(drawable, 10);
+ }
+
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+
+ public static int USE_NEWT = 0;
+ public static int USE_AWT = 1 << 0;
+
+ public static void main(String[] args) {
+ int type = USE_NEWT ;
+ String tstName = "demos.es2.perftst.PerfVBOLoad"; // default
+
+ for(int i=args.length-1; i>=0; i--) {
+ if(args[i].equals("-awt")) {
+ type |= USE_AWT;
+ }
+ if(args[i].equals("-test") && i+1<args.length ) {
+ tstName = args[i+1];
+ }
+ }
+
+ try {
+ PerfModule pmod = (PerfModule) Class.forName(tstName).newInstance();
+ new Perftst().run(type, pmod);
+ System.exit(0);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+}
diff --git a/src/demos/es2/perftst/data/bob2.gif b/src/demos/es2/perftst/data/bob2.gif
new file mode 100644
index 0000000..2faba51
--- /dev/null
+++ b/src/demos/es2/perftst/data/bob2.gif
Binary files differ
diff --git a/src/demos/es2/perftst/data/gif2tgas.sh b/src/demos/es2/perftst/data/gif2tgas.sh
new file mode 100644
index 0000000..2fd184b
--- /dev/null
+++ b/src/demos/es2/perftst/data/gif2tgas.sh
@@ -0,0 +1,28 @@
+#! /bin/sh
+
+rm -rf tmp
+mkdir -p tmp
+
+function gif2tga()
+{
+ bname=$1
+ shift
+ images=$1
+ shift
+ xysize=$1
+ shift
+
+ i=1 ;
+ while [ $i -le $images ] ; do
+ giftopnm -image $i $bname.gif > tmp/$bname.$i.pnm
+ pamscale -xsize=$xysize -ysize=$xysize tmp/$bname.$i.pnm > tmp/$bname.$xysize"x"$xysize.$i.pam
+ pamtotga -rgb -norle tmp/$bname.$xysize"x"$xysize.$i.pam > $bname.$xysize"x"$xysize.$i.tga
+ let i=$i+1
+ done
+}
+
+gif2tga bob2 33 64
+gif2tga bob2 33 128
+gif2tga bob2 33 256
+gif2tga bob2 33 512
+
diff --git a/src/demos/es2/perftst/shader/bin/nvidia/fcolor.bfp b/src/demos/es2/perftst/shader/bin/nvidia/fcolor.bfp
new file mode 100755
index 0000000..454354c
--- /dev/null
+++ b/src/demos/es2/perftst/shader/bin/nvidia/fcolor.bfp
Binary files differ
diff --git a/src/demos/es2/perftst/shader/bin/nvidia/ftext.bfp b/src/demos/es2/perftst/shader/bin/nvidia/ftext.bfp
new file mode 100755
index 0000000..2807387
--- /dev/null
+++ b/src/demos/es2/perftst/shader/bin/nvidia/ftext.bfp
Binary files differ
diff --git a/src/demos/es2/perftst/shader/bin/nvidia/uni-vert-col.bvp b/src/demos/es2/perftst/shader/bin/nvidia/uni-vert-col.bvp
new file mode 100755
index 0000000..b89137d
--- /dev/null
+++ b/src/demos/es2/perftst/shader/bin/nvidia/uni-vert-col.bvp
Binary files differ
diff --git a/src/demos/es2/perftst/shader/bin/nvidia/vbo-vert-col.bvp b/src/demos/es2/perftst/shader/bin/nvidia/vbo-vert-col.bvp
new file mode 100755
index 0000000..ba0c982
--- /dev/null
+++ b/src/demos/es2/perftst/shader/bin/nvidia/vbo-vert-col.bvp
Binary files differ
diff --git a/src/demos/es2/perftst/shader/bin/nvidia/vbo-vert-text.bvp b/src/demos/es2/perftst/shader/bin/nvidia/vbo-vert-text.bvp
new file mode 100755
index 0000000..9fe8667
--- /dev/null
+++ b/src/demos/es2/perftst/shader/bin/nvidia/vbo-vert-text.bvp
Binary files differ
diff --git a/src/demos/es2/perftst/shader/fcolor.fp b/src/demos/es2/perftst/shader/fcolor.fp
new file mode 100644
index 0000000..a94f705
--- /dev/null
+++ b/src/demos/es2/perftst/shader/fcolor.fp
@@ -0,0 +1,16 @@
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+#else
+ #define MEDIUMP
+ #define HIGHP
+#endif
+
+varying HIGHP vec4 frontColor;
+
+void main (void)
+{
+ gl_FragColor = frontColor;
+}
+
diff --git a/src/demos/es2/perftst/shader/ftext.fp b/src/demos/es2/perftst/shader/ftext.fp
new file mode 100644
index 0000000..726cc43
--- /dev/null
+++ b/src/demos/es2/perftst/shader/ftext.fp
@@ -0,0 +1,17 @@
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+#else
+ #define MEDIUMP
+ #define HIGHP
+#endif
+
+varying vec4 mgl_TexCoord0;
+uniform sampler2D mgl_ActiveTexture;
+
+void main (void)
+{
+ gl_FragColor = vec4(texture2D(mgl_ActiveTexture, mgl_TexCoord0.st).rgb, 1.0);
+}
+
diff --git a/src/demos/es2/perftst/shader/scripts/nvidia-apx/glslc-ff.bat b/src/demos/es2/perftst/shader/scripts/nvidia-apx/glslc-ff.bat
new file mode 100755
index 0000000..bf184f9
--- /dev/null
+++ b/src/demos/es2/perftst/shader/scripts/nvidia-apx/glslc-ff.bat
@@ -0,0 +1,9 @@
+REM
+REM You have to call it from the 'shader' directory, e.g.:
+REM scripts\nvidia-apx\glslc-ff.bat
+REM
+IF !"%JOGLDIR%"==""! GOTO YESPATH
+set JOGLDIR=..\lib
+:YESPATH
+
+java -cp %JOGLDIR%\jogl.core.jar;%JOGLDIR%\jogl.gles2.jar;%JOGLDIR%\jogl.fixed.jar;%JOGLDIR%\jogl.sdk.jar javax.media.opengl.sdk.glsl.CompileShaderNVidia fcolor.fp vbo-vert-col.vp uni-vert-col.vp ftext.fp vbo-vert-text.vp
diff --git a/src/demos/es2/perftst/shader/uni-vert-col.vp b/src/demos/es2/perftst/shader/uni-vert-col.vp
new file mode 100644
index 0000000..0550a8f
--- /dev/null
+++ b/src/demos/es2/perftst/shader/uni-vert-col.vp
@@ -0,0 +1,61 @@
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+#else
+ #define MEDIUMP
+ #define HIGHP
+#endif
+
+uniform MEDIUMP mat4 mgl_PMVMatrix[2];
+uniform MEDIUMP vec4 mgl_Dummy0[16];
+uniform MEDIUMP vec4 mgl_Dummy1[16];
+uniform MEDIUMP vec4 mgl_Dummy2[16];
+uniform MEDIUMP vec4 mgl_Dummy3[16];
+uniform MEDIUMP vec4 mgl_Dummy4[16];
+uniform MEDIUMP vec4 mgl_Dummy5[16];
+uniform MEDIUMP vec4 mgl_Dummy6[16];
+uniform MEDIUMP vec4 mgl_Dummy7[16];
+uniform MEDIUMP vec4 mgl_Dummy8[16];
+uniform MEDIUMP vec4 mgl_Dummy9[16];
+uniform MEDIUMP vec4 mgl_Dummy10[16];
+uniform MEDIUMP vec4 mgl_Dummy11[16];
+/*
+uniform MEDIUMP vec4 mgl_Dummy12[16];
+uniform MEDIUMP vec4 mgl_Dummy13[16];
+uniform MEDIUMP vec4 mgl_Dummy14[16];
+uniform MEDIUMP vec4 mgl_Dummy15[16];
+ */
+attribute HIGHP vec4 mgl_Vertex;
+attribute HIGHP vec4 mgl_Color;
+varying HIGHP vec4 frontColor;
+
+void main(void)
+{
+ int i;
+ vec4 val=vec4(0);
+
+ for(i=0; i<16; i++) {
+ val += mgl_Dummy0[i];
+ val += mgl_Dummy1[i];
+ val += mgl_Dummy2[i];
+ val += mgl_Dummy3[i];
+ val += mgl_Dummy4[i];
+ val += mgl_Dummy5[i];
+ val += mgl_Dummy6[i];
+ val += mgl_Dummy7[i];
+ val += mgl_Dummy8[i];
+ val += mgl_Dummy9[i];
+ val += mgl_Dummy10[i];
+ val += mgl_Dummy11[i];
+ /*
+ val += mgl_Dummy12[i];
+ val += mgl_Dummy13[i];
+ val += mgl_Dummy14[i];
+ val += mgl_Dummy15[i];
+ */
+ }
+
+ frontColor=mgl_Color+val;
+ gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex;
+}
diff --git a/src/demos/es2/perftst/shader/vbo-vert-col.vp b/src/demos/es2/perftst/shader/vbo-vert-col.vp
new file mode 100644
index 0000000..0348e90
--- /dev/null
+++ b/src/demos/es2/perftst/shader/vbo-vert-col.vp
@@ -0,0 +1,19 @@
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+#else
+ #define MEDIUMP
+ #define HIGHP
+#endif
+
+uniform MEDIUMP mat4 mgl_PMVMatrix[2];
+attribute HIGHP vec4 mgl_Vertex;
+attribute HIGHP vec4 mgl_Color;
+varying HIGHP vec4 frontColor;
+
+void main(void)
+{
+ frontColor=mgl_Color;
+ gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex;
+}
diff --git a/src/demos/es2/perftst/shader/vbo-vert-text.vp b/src/demos/es2/perftst/shader/vbo-vert-text.vp
new file mode 100644
index 0000000..283d676
--- /dev/null
+++ b/src/demos/es2/perftst/shader/vbo-vert-text.vp
@@ -0,0 +1,19 @@
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+#else
+ #define MEDIUMP
+ #define HIGHP
+#endif
+
+uniform MEDIUMP mat4 mgl_PMVMatrix[2];
+attribute HIGHP vec4 mgl_Vertex;
+attribute HIGHP vec4 mgl_MultiTexCoord0;
+varying vec4 mgl_TexCoord0;
+
+void main(void)
+{
+ mgl_TexCoord0 = mgl_MultiTexCoord0;
+ gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex;
+}
diff --git a/src/demos/es2/shader/bin/nvidia/redsquare.bfp b/src/demos/es2/shader/bin/nvidia/redsquare.bfp
new file mode 100755
index 0000000..454354c
--- /dev/null
+++ b/src/demos/es2/shader/bin/nvidia/redsquare.bfp
Binary files differ
diff --git a/src/demos/es2/shader/bin/nvidia/redsquare.bvp b/src/demos/es2/shader/bin/nvidia/redsquare.bvp
new file mode 100755
index 0000000..ba0c982
--- /dev/null
+++ b/src/demos/es2/shader/bin/nvidia/redsquare.bvp
Binary files differ
diff --git a/src/demos/es2/shader/redsquare.fp b/src/demos/es2/shader/redsquare.fp
new file mode 100644
index 0000000..a94f705
--- /dev/null
+++ b/src/demos/es2/shader/redsquare.fp
@@ -0,0 +1,16 @@
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+#else
+ #define MEDIUMP
+ #define HIGHP
+#endif
+
+varying HIGHP vec4 frontColor;
+
+void main (void)
+{
+ gl_FragColor = frontColor;
+}
+
diff --git a/src/demos/es2/shader/redsquare.vp b/src/demos/es2/shader/redsquare.vp
new file mode 100644
index 0000000..0348e90
--- /dev/null
+++ b/src/demos/es2/shader/redsquare.vp
@@ -0,0 +1,19 @@
+
+#ifdef GL_ES
+ #define MEDIUMP mediump
+ #define HIGHP highp
+#else
+ #define MEDIUMP
+ #define HIGHP
+#endif
+
+uniform MEDIUMP mat4 mgl_PMVMatrix[2];
+attribute HIGHP vec4 mgl_Vertex;
+attribute HIGHP vec4 mgl_Color;
+varying HIGHP vec4 frontColor;
+
+void main(void)
+{
+ frontColor=mgl_Color;
+ gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex;
+}
diff --git a/src/demos/es2/shader/scripts/nvidia-apx/glslc-ff.bat b/src/demos/es2/shader/scripts/nvidia-apx/glslc-ff.bat
new file mode 100755
index 0000000..024e469
--- /dev/null
+++ b/src/demos/es2/shader/scripts/nvidia-apx/glslc-ff.bat
@@ -0,0 +1,9 @@
+REM
+REM You have to call it from the 'shader' directory, e.g.:
+REM scripts\nvidia-apx\glslc-ff.bat
+REM
+IF !"%JOGLDIR%"==""! GOTO YESPATH
+set JOGLDIR=..\lib
+:YESPATH
+
+java -cp %JOGLDIR%\jogl.core.jar;%JOGLDIR%\jogl.gles2.jar;%JOGLDIR%\jogl.fixed.jar;%JOGLDIR%\jogl.sdk.jar javax.media.opengl.sdk.glsl.CompileShaderNVidia redsquare.vp redsquare.fp