diff options
author | Sven Gothel <[email protected]> | 2009-10-04 00:19:32 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-10-04 00:19:32 -0700 |
commit | 4b9a72c24bb97ed81c79c3931d4ffb5fa53d9978 (patch) | |
tree | 0237b562f04fbe56fe0245dbbefecfc6c608caee /src/demos/es1 | |
parent | 30c1fe267c0cf47a25db06ac93c6065881af2a20 (diff) |
Add ReadBuffer Demos/ModuleTests; Incl. SurfaceUpdated Listener, ReadPixel to file, texture - direct or via attaching the drawable to another context as it's readbuffer
Diffstat (limited to 'src/demos/es1')
-rwxr-xr-x | src/demos/es1/RedSquare.java | 48 | ||||
-rw-r--r-- | src/demos/es1/cube/Cube.java | 28 |
2 files changed, 55 insertions, 21 deletions
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java index 02e8454..53485b0 100755 --- a/src/demos/es1/RedSquare.java +++ b/src/demos/es1/RedSquare.java @@ -14,6 +14,9 @@ import com.sun.javafx.newt.opengl.*; public class RedSquare extends Thread implements WindowListener, KeyListener, MouseListener, GLEventListener { + public static boolean glDebugEmu = false; + public static boolean glDebug = false ; + public static boolean glTrace = false ; public GLWindow window; private GLProfile glp; private GLU glu; @@ -171,15 +174,18 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo public void init(GLAutoDrawable drawable) { GL _gl = drawable.getGL(); - if(debugffemu) { - debuggl = false; + if(glDebugEmu) { try { // Debug .. _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) ); - // Trace .. - _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) ); + if(glTrace) { + // Trace .. + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) ); + } } catch (Exception e) {e.printStackTrace();} + glDebug = false; + glTrace = false; } GL2ES1 gl = FixedFuncUtil.getFixedFuncImpl(_gl); @@ -187,7 +193,21 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo gl.setSwapInterval(swapInterval); } - glu = GLU.createGLU(); + if(glDebug) { + try { + // Debug .. + gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) ); + } catch (Exception e) {e.printStackTrace();} + } + + if(glTrace) { + try { + // Trace .. + gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) ); + } catch (Exception e) {e.printStackTrace();} + } + + glu = GLU.createGLU(gl); System.err.println(glp+" Entering initialization"); System.err.println(glp+" GL Profile: "+gl.getGLProfile()); @@ -198,16 +218,6 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo System.err.println(glp+" swapInterval: " + swapInterval + " (GL: "+gl.getSwapInterval()+")"); System.err.println(glp+" GLU: " + glu); - if(debuggl) { - try { - // Debug .. - gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) ); - - // Trace .. - gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) ); - } catch (Exception e) {e.printStackTrace();} - } - // Allocate vertex arrays colors = BufferUtil.newFloatBuffer(16); vertices = BufferUtil.newFloatBuffer(12); @@ -281,8 +291,6 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo public static boolean oneThread = false; public static boolean pumpOnce = true; public static int swapInterval = -1; - public static boolean debuggl = false; - public static boolean debugffemu = false; public static void main(String[] args) { int type = USE_NEWT ; @@ -293,10 +301,12 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo try { swapInterval = Integer.parseInt(args[i]); } catch (Exception ex) { ex.printStackTrace(); } + } else if(args[i].equals("-trace")) { + glTrace=true; } else if(args[i].equals("-debug")) { - debuggl=true; + glDebug=true; } else if(args[i].equals("-debugff")) { - debugffemu=true; + glDebugEmu=true; } else if(args[i].equals("-pumponce")) { pumpOnce=true; } else if(args[i].equals("-1thread")) { diff --git a/src/demos/es1/cube/Cube.java b/src/demos/es1/cube/Cube.java index d9c00b2..d46f41b 100644 --- a/src/demos/es1/cube/Cube.java +++ b/src/demos/es1/cube/Cube.java @@ -43,6 +43,8 @@ import com.sun.javafx.newt.*; import com.sun.javafx.newt.opengl.*; public class Cube implements GLEventListener { + public boolean glDebug = false ; + public boolean glTrace = false ; boolean quit = false; public Cube () { @@ -77,7 +79,23 @@ public class Cube implements GLEventListener { } public void init(GLAutoDrawable drawable) { - GL2ES1 gl = FixedFuncUtil.getFixedFuncImpl(drawable.getGL()); + GL _gl = drawable.getGL(); + + _gl.glGetError(); // flush error .. + + if(glDebug) { + try { + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, _gl, null) ); + } catch (Exception e) {e.printStackTrace();} + } + + if(glTrace) { + try { + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, _gl, new Object[] { System.err } ) ); + } catch (Exception e) {e.printStackTrace();} + } + + GL2ES1 gl = FixedFuncUtil.getFixedFuncImpl(_gl); glu = GLU.createGLU(); @@ -179,9 +197,15 @@ public class Cube implements GLEventListener { } public void display(GLAutoDrawable drawable) { + display(drawable, true); + } + + public void display(GLAutoDrawable drawable, boolean clear) { GL2ES1 gl = drawable.getGL().getGL2ES1(); - gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); + if(clear) { + gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); + } gl.glMatrixMode(gl.GL_MODELVIEW); gl.glLoadIdentity(); |