diff options
-rw-r--r-- | src/demos/dualDepthPeeling/DualDepthPeeling.java | 12 | ||||
-rwxr-xr-x | src/demos/es2/RedSquare.java | 8 | ||||
-rw-r--r-- | src/demos/es2/openmax/Cube.java | 365 | ||||
-rwxr-xr-x | src/demos/es2/openmax/MovieCube.java | 208 | ||||
-rwxr-xr-x | src/demos/es2/openmax/MovieSimple.java | 352 | ||||
-rwxr-xr-x | src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bfp | bin | 684 -> 0 bytes | |||
-rwxr-xr-x | src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bvp | bin | 940 -> 0 bytes | |||
-rw-r--r-- | src/demos/es2/openmax/shader/moviesimple.fp | 21 | ||||
-rw-r--r-- | src/demos/es2/openmax/shader/moviesimple.vp | 22 | ||||
-rwxr-xr-x | src/demos/es2/openmax/shader/scripts/nvidia-apx/glslc-ff.bat | 9 | ||||
-rw-r--r-- | src/demos/es2/perftst/PerfModule.java | 8 |
11 files changed, 14 insertions, 991 deletions
diff --git a/src/demos/dualDepthPeeling/DualDepthPeeling.java b/src/demos/dualDepthPeeling/DualDepthPeeling.java index f1e841c..41d50d0 100644 --- a/src/demos/dualDepthPeeling/DualDepthPeeling.java +++ b/src/demos/dualDepthPeeling/DualDepthPeeling.java @@ -430,10 +430,10 @@ public class DualDepthPeeling implements GLEventListener, KeyListener, MouseList ShaderProgram build(GL2ES2 gl, String basename, boolean link) { ShaderProgram sp = new ShaderProgram(); - ShaderCode vp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, DualDepthPeeling.class, - "shader", null, basename); - ShaderCode fp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, DualDepthPeeling.class, - "shader", null, basename); + ShaderCode vp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, DualDepthPeeling.class, + "shader", null, basename, false); + ShaderCode fp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, DualDepthPeeling.class, + "shader", null, basename, false); sp.add(vp); sp.add(fp); if(link && !sp.link(gl, System.err)) { @@ -444,10 +444,10 @@ public class DualDepthPeeling implements GLEventListener, KeyListener, MouseList ShaderProgram build(GL2ES2 gl, String[] basenames, boolean link) { ShaderProgram sp = new ShaderProgram(); ShaderCode vp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, basenames.length, DualDepthPeeling.class, - "shader", basenames, null, null); + "shader", basenames, null, null, false); sp.add(vp); ShaderCode fp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, basenames.length, DualDepthPeeling.class, - "shader", basenames, null, null); + "shader", basenames, null, null, false); sp.add(fp); if(link && !sp.link(gl, System.err)) { throw new GLException("Couldn't link program: "+sp); diff --git a/src/demos/es2/RedSquare.java b/src/demos/es2/RedSquare.java index 536deb2..1269342 100755 --- a/src/demos/es2/RedSquare.java +++ b/src/demos/es2/RedSquare.java @@ -162,10 +162,10 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo private void initShader(GL2ES2 gl) { // Create & Compile the shader objects - ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, RedSquare.class, - "shader", "shader/bin", "redsquare"); - ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, RedSquare.class, - "shader", "shader/bin", "redsquare"); + ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquare.class, + "shader", "shader/bin", "redsquare", false); + ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquare.class, + "shader", "shader/bin", "redsquare", false); // Create & Link the shader program ShaderProgram sp = new ShaderProgram(); diff --git a/src/demos/es2/openmax/Cube.java b/src/demos/es2/openmax/Cube.java deleted file mode 100644 index 51578dd..0000000 --- a/src/demos/es2/openmax/Cube.java +++ /dev/null @@ -1,365 +0,0 @@ -/* - * - * 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 com.jogamp.common.nio.Buffers; -import java.nio.*; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import javax.media.nativewindow.*; - -import com.jogamp.opengl.util.glsl.fixedfunc.*; - -import com.jogamp.newt.*; -import com.jogamp.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 = Buffers.newDirectShortBuffer(s_cubeVertices.length); - cubeVertices.put(s_cubeVertices); - cubeVertices.flip(); - - this.cubeColors = Buffers.newDirectFloatBuffer(s_cubeColors.length); - cubeColors.put(s_cubeColors); - cubeColors.flip(); - - this.cubeNormals = Buffers.newDirectByteBuffer(s_cubeNormals.length); - cubeNormals.put(s_cubeNormals); - cubeNormals.flip(); - - this.cubeIndices = Buffers.newDirectByteBuffer(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 = Buffers.newDirectFloatBuffer(s_cubeTexCoords.length); - cubeTexCoords.put(s_cubeTexCoords); - cubeTexCoords.flip(); - } - } - - public void init(GLAutoDrawable drawable) { - GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(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() * Buffers.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() * Buffers.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() * Buffers.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() * Buffers.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; - GLWindow window; - if(0!=(type&USE_AWT)) { - Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display - Screen nScreen = NewtFactory.createScreen(nDisplay, 0); // screen 0 - nWindow = NewtFactory.createWindow(nScreen, caps); - window = GLWindow.create(nWindow); - } else { - window = GLWindow.create(caps); - } - - window.addGLEventListener(this); - - window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); - // Size OpenGL to Video Surface - window.setSize(width, height); - window.setFullscreen(true); - window.setVisible(true); - - while (!quit && window.getTotalFPSDuration() < 31000) { - window.display(); - } - - // Shut things down cooperatively - window.destroy(); - 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 deleted file mode 100755 index 932fcf8..0000000 --- a/src/demos/es2/openmax/MovieCube.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * 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.jogamp.opengl.util.glsl.fixedfunc.*; - -import com.jogamp.openmax.*; - -import java.net.*; - -import com.jogamp.newt.*; -import com.jogamp.newt.event.*; -import com.jogamp.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(); - System.out.println("MovieCube shut down cleanly."); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - public void init(GLAutoDrawable drawable) { - GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(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.jogamp.opengl.util.texture.Texture tex = null; - if(null!=movie) { - tex=movie.getNextTextureID(); - if(null!=tex) { - System.out.println("Use: "+tex); - tex.enable(gl); - tex.bind(gl); - } - } - cube.display(drawable); - if(null!=tex) { - tex.disable(gl); - } - } - - 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 deleted file mode 100755 index eaf5221..0000000 --- a/src/demos/es2/openmax/MovieSimple.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * 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.jogamp.opengl.util.glsl.*; -import com.jogamp.opengl.util.*; - -import com.jogamp.openmax.*; - -import java.nio.*; -import java.net.*; - -import com.jogamp.newt.*; -import com.jogamp.newt.event.*; -import com.jogamp.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(); - 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, GL2ES2.GL_VERTEX_SHADER, 1, MovieSimple.class, - "shader", "shader/bin", "moviesimple"); - ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.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, false); - } - - 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.useProgram(gl, true); - - pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION); - pmvMatrix.glLoadIdentity(); - pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW); - pmvMatrix.glLoadIdentity(); - - if(!st.uniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) { - throw new GLException("Error setting PMVMatrix in shader: "+st); - } - if(!st.uniform(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("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("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("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.useProgram(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.useProgram(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.uniform(gl, ud); - } - - st.useProgram(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.useProgram(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.uniform(gl, ud); - } - - if(!rotate) { - zoom=0f; - } - } - - - com.jogamp.opengl.util.texture.Texture tex = null; - if(null!=movie) { - tex=movie.getNextTextureID(); - if(null!=tex) { - tex.enable(gl); - tex.bind(gl); - } - } - - // Draw a square - gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4); - - if(null!=tex) { - tex.disable(gl); - } - - st.useProgram(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 Binary files differdeleted file mode 100755 index 97a6980..0000000 --- a/src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bfp +++ /dev/null diff --git a/src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bvp b/src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bvp Binary files differdeleted file mode 100755 index 2ca3dff..0000000 --- a/src/demos/es2/openmax/shader/bin/nvidia/moviesimple.bvp +++ /dev/null diff --git a/src/demos/es2/openmax/shader/moviesimple.fp b/src/demos/es2/openmax/shader/moviesimple.fp deleted file mode 100644 index c711641..0000000 --- a/src/demos/es2/openmax/shader/moviesimple.fp +++ /dev/null @@ -1,21 +0,0 @@ - -#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 deleted file mode 100644 index 0b78eb9..0000000 --- a/src/demos/es2/openmax/shader/moviesimple.vp +++ /dev/null @@ -1,22 +0,0 @@ - -#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 deleted file mode 100755 index a93f43c..0000000 --- a/src/demos/es2/openmax/shader/scripts/nvidia-apx/glslc-ff.bat +++ /dev/null @@ -1,9 +0,0 @@ -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 index ec2314b..d7cfb2c 100644 --- a/src/demos/es2/perftst/PerfModule.java +++ b/src/demos/es2/perftst/PerfModule.java @@ -22,10 +22,10 @@ public abstract class PerfModule { st = new ShaderState(); // Create & Compile the shader objects - ShaderCode vp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, Perftst.class, - "shader", "shader/bin", vShaderName); - ShaderCode fp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, Perftst.class, - "shader", "shader/bin", fShaderName); + ShaderCode vp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, Perftst.class, + "shader", "shader/bin", vShaderName, false); + ShaderCode fp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, Perftst.class, + "shader", "shader/bin", fShaderName, false); // Create & Link the shader program ShaderProgram sp = new ShaderProgram(); |