From 69f64249e908851fda06ba6e6c2c4c45b837c16f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 30 Mar 2010 05:12:50 +0200 Subject: Adaptions to jogl:1a2a54a83a9adb95b4bfe9c337751acbef0cb0d3 gluegen:7220416bcef3140883d3966d921442feae3107c4 ; Fix build.xml: using rootrel.build --- src/demos/es2/RedSquare.java | 7 +++++++ src/redbook/src/glredbook1314/mvarray.java | 20 +++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/demos/es2/RedSquare.java b/src/demos/es2/RedSquare.java index 59dec30..2099fd0 100755 --- a/src/demos/es2/RedSquare.java +++ b/src/demos/es2/RedSquare.java @@ -197,6 +197,7 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo System.err.println(Thread.currentThread()+" GL_EXTENSIONS:"); System.err.println(Thread.currentThread()+" " + gl.glGetString(gl.GL_EXTENSIONS)); System.err.println(Thread.currentThread()+" swapInterval: " + swapInterval + " (GL: "+gl.getSwapInterval()+")"); + System.err.println(Thread.currentThread()+" isShaderCompilerAvailable: " + ShaderUtil.isShaderCompilerAvailable(gl)); if(debuggl) { try { @@ -257,6 +258,8 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + if(null==st) return; + GL2ES2 gl = drawable.getGL().getGL2ES2(); st.glUseProgram(gl, true); @@ -277,6 +280,8 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo } public void dispose(GLAutoDrawable drawable) { + if(null==st) return; + GL2ES2 gl = drawable.getGL().getGL2ES2(); System.out.println(Thread.currentThread()+" RedSquare.dispose: "+gl.getContext()); @@ -288,6 +293,8 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo } public void display(GLAutoDrawable drawable) { + if(null==st) return; + GL2ES2 gl = drawable.getGL().getGL2ES2(); st.glUseProgram(gl, true); diff --git a/src/redbook/src/glredbook1314/mvarray.java b/src/redbook/src/glredbook1314/mvarray.java index 0885d9e..b59ff13 100644 --- a/src/redbook/src/glredbook1314/mvarray.java +++ b/src/redbook/src/glredbook1314/mvarray.java @@ -10,6 +10,7 @@ import java.nio.IntBuffer; import javax.media.opengl.*; import javax.swing.JFrame; +import com.jogamp.gluegen.runtime.PointerBuffer; import com.jogamp.opengl.util.GLBuffers; import javax.media.opengl.awt.GLJPanel; import javax.media.opengl.glu.GLU; @@ -48,19 +49,16 @@ public class mvarray // private int count[] = { 7, 6 }; - private ByteBuffer indices[] = {// - GLBuffers.newDirectByteBuffer(oneIndices.length), - GLBuffers.newDirectByteBuffer(twoIndices.length) }; - // static GLvoid * indices[2] = {oneIndices, twoIndices}; + private PointerBuffer indices = PointerBuffer.allocateDirect(2); + { vertexBuf.put(vertices); - indices[0].put(oneIndices); - indices[1].put(twoIndices); - vertexBuf.rewind(); - indices[0].rewind(); - indices[1].rewind(); + + indices.referenceBuffer(GLBuffers.newDirectByteBuffer(oneIndices)); + indices.referenceBuffer(GLBuffers.newDirectByteBuffer(twoIndices)); + indices.rewind(); } private boolean mde_bug; @@ -92,9 +90,9 @@ public class mvarray // GL.GL_UNSIGNED_BYTE, indices, 2); else { // workaround for glMultiDrawElem bug before July - for (int i = 0; i < indices.length; i++) + for (int i = 0; i < indices.capacity(); i++) gl.glDrawElements(GL.GL_LINE_STRIP, count[i], // - GL.GL_UNSIGNED_BYTE, indices[i]); + GL.GL_UNSIGNED_BYTE, (ByteBuffer)indices.getReferencedBuffer(i)); } gl.glFlush(); } -- cgit v1.2.3