diff options
Diffstat (limited to 'src/demos/es1')
-rwxr-xr-x | src/demos/es1/RedSquare.java | 5 | ||||
-rwxr-xr-x | src/demos/es1/angeles/AngelesES1.java | 29 | ||||
-rwxr-xr-x | src/demos/es1/angeles/AngelesGL.java | 32 | ||||
-rwxr-xr-x | src/demos/es1/angeles/AngelesGLil.java | 24 | ||||
-rw-r--r-- | src/demos/es1/cube/Cube.java | 20 | ||||
-rw-r--r-- | src/demos/es1/cube/CubeImmModeSink.java | 9 |
6 files changed, 61 insertions, 58 deletions
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java index d391442..4741258 100755 --- a/src/demos/es1/RedSquare.java +++ b/src/demos/es1/RedSquare.java @@ -1,5 +1,6 @@ package demos.es1; +import com.jogamp.gluegen.runtime.Buffers; import java.nio.*; import java.util.*; import javax.media.opengl.*; @@ -241,8 +242,8 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo System.err.println(Thread.currentThread()+" GLU: " + glu); // Allocate vertex arrays - colors = BufferUtil.newFloatBuffer(16); - vertices = BufferUtil.newFloatBuffer(12); + colors = Buffers.newDirectFloatBuffer(16); + vertices = Buffers.newDirectFloatBuffer(12); // Fill them up colors.put( 0, 1); colors.put( 1, 0); colors.put( 2, 0); colors.put( 3, 1); colors.put( 4, 0); colors.put( 5, 0); colors.put( 6, 1); colors.put( 7, 1); diff --git a/src/demos/es1/angeles/AngelesES1.java b/src/demos/es1/angeles/AngelesES1.java index edba727..6c868c4 100755 --- a/src/demos/es1/angeles/AngelesES1.java +++ b/src/demos/es1/angeles/AngelesES1.java @@ -24,6 +24,7 @@ package demos.es1.angeles; +import com.jogamp.gluegen.runtime.Buffers; import javax.media.opengl.*; import javax.media.opengl.glu.*; import com.jogamp.opengl.util.*; @@ -37,7 +38,7 @@ public class AngelesES1 implements GLEventListener { public AngelesES1(boolean enableBlending) { blendingEnabled = enableBlending; - quadVertices = BufferUtil.newIntBuffer(12); + quadVertices = Buffers.newDirectIntBuffer(12); quadVertices.put(new int[]{ -0x10000, -0x10000, 0x10000, -0x10000, @@ -48,13 +49,13 @@ public class AngelesES1 implements GLEventListener { }); quadVertices.flip(); - light0Position=BufferUtil.newIntBuffer(4); - light0Diffuse=BufferUtil.newIntBuffer(4); - light1Position=BufferUtil.newIntBuffer(4); - light1Diffuse=BufferUtil.newIntBuffer(4); - light2Position=BufferUtil.newIntBuffer(4); - light2Diffuse=BufferUtil.newIntBuffer(4); - materialSpecular=BufferUtil.newIntBuffer(4); + light0Position=Buffers.newDirectIntBuffer(4); + light0Diffuse=Buffers.newDirectIntBuffer(4); + light1Position=Buffers.newDirectIntBuffer(4); + light1Diffuse=Buffers.newDirectIntBuffer(4); + light2Position=Buffers.newDirectIntBuffer(4); + light2Diffuse=Buffers.newDirectIntBuffer(4); + materialSpecular=Buffers.newDirectIntBuffer(4); light0Position.put(new int[] { -0x40000, 0x10000, 0x10000, 0 }); light0Diffuse.put(new int[] { 0x10000, 0x6666, 0, 0x10000 }); @@ -245,11 +246,11 @@ public class GLObject { boolean useNormalArray) { this.count = vertices; this.vertexComponents = vertexComponents; - this.vertexArray = BufferUtil.newIntBuffer( vertices * vertexComponents ); - this.colorArray = BufferUtil.newByteBuffer (vertices * 4 ); + this.vertexArray = Buffers.newDirectIntBuffer( vertices * vertexComponents ); + this.colorArray = Buffers.newDirectByteBuffer (vertices * 4 ); if (useNormalArray) { - this.normalArray = BufferUtil.newIntBuffer (vertices * 3 ); + this.normalArray = Buffers.newDirectIntBuffer (vertices * 3 ); } else { this.normalArray = null; } @@ -262,18 +263,18 @@ public class GLObject { gl.glGenBuffers(3, vbo, 0); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[0]); - gl.glBufferData(GL.GL_ARRAY_BUFFER, vertexArray.capacity() * BufferUtil.SIZEOF_INT, vertexArray, GL.GL_STATIC_DRAW); + gl.glBufferData(GL.GL_ARRAY_BUFFER, vertexArray.capacity() * Buffers.SIZEOF_INT, vertexArray, GL.GL_STATIC_DRAW); gl.glVertexPointer(vertexComponents, gl.GL_FIXED, 0, 0); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[1]); - gl.glBufferData(GL.GL_ARRAY_BUFFER, colorArray.capacity() * BufferUtil.SIZEOF_BYTE, colorArray, GL.GL_STATIC_DRAW); + gl.glBufferData(GL.GL_ARRAY_BUFFER, colorArray.capacity() * Buffers.SIZEOF_BYTE, colorArray, GL.GL_STATIC_DRAW); gl.glColorPointer(4, gl.GL_UNSIGNED_BYTE, 0, 0); if (null!=normalArray) { gl.glEnableClientState(gl.GL_NORMAL_ARRAY); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[2]); - gl.glBufferData(GL.GL_ARRAY_BUFFER, normalArray.capacity() * BufferUtil.SIZEOF_INT, normalArray, GL.GL_STATIC_DRAW); + gl.glBufferData(GL.GL_ARRAY_BUFFER, normalArray.capacity() * Buffers.SIZEOF_INT, normalArray, GL.GL_STATIC_DRAW); gl.glNormalPointer(gl.GL_FIXED, 0, 0); } else { gl.glDisableClientState(gl.GL_NORMAL_ARRAY); diff --git a/src/demos/es1/angeles/AngelesGL.java b/src/demos/es1/angeles/AngelesGL.java index afcc356..bc367d7 100755 --- a/src/demos/es1/angeles/AngelesGL.java +++ b/src/demos/es1/angeles/AngelesGL.java @@ -38,7 +38,7 @@ public class AngelesGL implements GLEventListener { public AngelesGL(boolean enableBlending) { blendingEnabled = enableBlending; - quadVertices = BufferUtil.newFloatBuffer(12); + quadVertices = GLBuffers.newDirectFloatBuffer(12); quadVertices.put(new float[]{ -1.0f, -1.0f, 1.0f, -1.0f, @@ -49,13 +49,13 @@ public class AngelesGL implements GLEventListener { }); quadVertices.flip(); - light0Position=BufferUtil.newFloatBuffer(4); - light0Diffuse=BufferUtil.newFloatBuffer(4); - light1Position=BufferUtil.newFloatBuffer(4); - light1Diffuse=BufferUtil.newFloatBuffer(4); - light2Position=BufferUtil.newFloatBuffer(4); - light2Diffuse=BufferUtil.newFloatBuffer(4); - materialSpecular=BufferUtil.newFloatBuffer(4); + light0Position=GLBuffers.newDirectFloatBuffer(4); + light0Diffuse=GLBuffers.newDirectFloatBuffer(4); + light1Position=GLBuffers.newDirectFloatBuffer(4); + light1Diffuse=GLBuffers.newDirectFloatBuffer(4); + light2Position=GLBuffers.newDirectFloatBuffer(4); + light2Diffuse=GLBuffers.newDirectFloatBuffer(4); + materialSpecular=GLBuffers.newDirectFloatBuffer(4); light0Position.put(new float[] { FixedPoint.toFloat(-0x40000), 1.0f, 1.0f, 0.0f }); light0Diffuse.put(new float[] { 1.0f, FixedPoint.toFloat(0x6666), 0.0f, 1.0f }); @@ -271,24 +271,24 @@ public class GLSpatial { vComps= vertexComponents; nComps = useNormalArray ? 3 : 0; - int bSize = BufferUtil.sizeOfGLType(GL.GL_FLOAT) * count * ( vComps + cComps + nComps) ; - pBuffer = BufferUtil.newByteBuffer(bSize); + int bSize = GLBuffers.sizeOfGLType(GL.GL_FLOAT) * count * ( vComps + cComps + nComps) ; + pBuffer = GLBuffers.newDirectByteBuffer(bSize); int pos = 0; - int size= BufferUtil.sizeOfGLType(GL.GL_FLOAT) * count * vComps ; - vertexArray = (FloatBuffer) BufferUtil.sliceGLBuffer(pBuffer, pos, size, GL.GL_FLOAT); + int size= GLBuffers.sizeOfGLType(GL.GL_FLOAT) * count * vComps ; + vertexArray = (FloatBuffer) GLBuffers.sliceGLBuffer(pBuffer, pos, size, GL.GL_FLOAT); int vOffset = 0; pos+=size; - size=BufferUtil.sizeOfGLType(GL.GL_FLOAT) * count * cComps ; - colorArray = (FloatBuffer) BufferUtil.sliceGLBuffer(pBuffer, pos, size, GL.GL_FLOAT); + size=GLBuffers.sizeOfGLType(GL.GL_FLOAT) * count * cComps ; + colorArray = (FloatBuffer) GLBuffers.sliceGLBuffer(pBuffer, pos, size, GL.GL_FLOAT); int cOffset=pos; pos+=size; int nOffset=0; if(useNormalArray) { - size=BufferUtil.sizeOfGLType(GL.GL_FLOAT) * count * nComps ; - normalArray = (FloatBuffer) BufferUtil.sliceGLBuffer(pBuffer, pos, size, GL.GL_FLOAT); + size=GLBuffers.sizeOfGLType(GL.GL_FLOAT) * count * nComps ; + normalArray = (FloatBuffer) GLBuffers.sliceGLBuffer(pBuffer, pos, size, GL.GL_FLOAT); nOffset=pos; pos+=size; } diff --git a/src/demos/es1/angeles/AngelesGLil.java b/src/demos/es1/angeles/AngelesGLil.java index bbfb86a..92be109 100755 --- a/src/demos/es1/angeles/AngelesGLil.java +++ b/src/demos/es1/angeles/AngelesGLil.java @@ -34,7 +34,7 @@ public class AngelesGLil implements GLEventListener { public AngelesGLil(boolean enableBlending) { blendingEnabled = enableBlending; - quadVertices = BufferUtil.newFloatBuffer(12); + quadVertices = GLBuffers.newDirectFloatBuffer(12); quadVertices.put(new float[]{ -1.0f, -1.0f, 1.0f, -1.0f, @@ -45,13 +45,13 @@ public class AngelesGLil implements GLEventListener { }); quadVertices.flip(); - light0Position=BufferUtil.newFloatBuffer(4); - light0Diffuse=BufferUtil.newFloatBuffer(4); - light1Position=BufferUtil.newFloatBuffer(4); - light1Diffuse=BufferUtil.newFloatBuffer(4); - light2Position=BufferUtil.newFloatBuffer(4); - light2Diffuse=BufferUtil.newFloatBuffer(4); - materialSpecular=BufferUtil.newFloatBuffer(4); + light0Position=GLBuffers.newDirectFloatBuffer(4); + light0Diffuse=GLBuffers.newDirectFloatBuffer(4); + light1Position=GLBuffers.newDirectFloatBuffer(4); + light1Diffuse=GLBuffers.newDirectFloatBuffer(4); + light2Position=GLBuffers.newDirectFloatBuffer(4); + light2Diffuse=GLBuffers.newDirectFloatBuffer(4); + materialSpecular=GLBuffers.newDirectFloatBuffer(4); light0Position.put(new float[] { FixedPoint.toFloat(-0x40000), 1.0f, 1.0f, 0.0f }); light0Diffuse.put(new float[] { 1.0f, FixedPoint.toFloat(0x6666), 0.0f, 1.0f }); @@ -277,15 +277,15 @@ public class GLSpatial { vComps= vertexComponents; nComps = useNormalArray ? 3 : 0; - int bStride = BufferUtil.sizeOfGLType(GL.GL_FLOAT) * ( vComps + cComps + nComps ); + int bStride = GLBuffers.sizeOfGLType(GL.GL_FLOAT) * ( vComps + cComps + nComps ); int bSize = count * bStride; - pBuffer = BufferUtil.newByteBuffer(bSize); + pBuffer = GLBuffers.newDirectByteBuffer(bSize); interlArray = pBuffer.asFloatBuffer(); int vOffset = 0; - int cOffset = BufferUtil.sizeOfGLType(GL.GL_FLOAT) * (vComps); - int nOffset = BufferUtil.sizeOfGLType(GL.GL_FLOAT) * (vComps + cComps); + int cOffset = GLBuffers.sizeOfGLType(GL.GL_FLOAT) * (vComps); + int nOffset = GLBuffers.sizeOfGLType(GL.GL_FLOAT) * (vComps + cComps); int[] tmp = new int[1]; gl.glGenBuffers(1, tmp, 0); diff --git a/src/demos/es1/cube/Cube.java b/src/demos/es1/cube/Cube.java index 198bba8..d2a3277 100644 --- a/src/demos/es1/cube/Cube.java +++ b/src/demos/es1/cube/Cube.java @@ -31,12 +31,12 @@ */ package demos.es1.cube; +import com.jogamp.gluegen.runtime.Buffers; import java.nio.*; import javax.media.opengl.*; import javax.media.opengl.glu.*; import javax.media.nativewindow.*; -import com.jogamp.opengl.util.*; import com.jogamp.opengl.util.glsl.fixedfunc.*; import com.jogamp.newt.*; @@ -55,24 +55,24 @@ public class Cube implements GLEventListener { this.innerCube = innerCube; // Initialize data Buffers - this.cubeVertices = BufferUtil.newShortBuffer(s_cubeVertices.length); + this.cubeVertices = Buffers.newDirectShortBuffer(s_cubeVertices.length); cubeVertices.put(s_cubeVertices); cubeVertices.flip(); - this.cubeColors = BufferUtil.newFloatBuffer(s_cubeColors.length); + this.cubeColors = Buffers.newDirectFloatBuffer(s_cubeColors.length); cubeColors.put(s_cubeColors); cubeColors.flip(); - this.cubeNormals = BufferUtil.newByteBuffer(s_cubeNormals.length); + this.cubeNormals = Buffers.newDirectByteBuffer(s_cubeNormals.length); cubeNormals.put(s_cubeNormals); cubeNormals.flip(); - this.cubeIndices = BufferUtil.newByteBuffer(s_cubeIndices.length); + this.cubeIndices = Buffers.newDirectByteBuffer(s_cubeIndices.length); cubeIndices.put(s_cubeIndices); cubeIndices.flip(); if (useTexCoords) { - this.cubeTexCoords = BufferUtil.newShortBuffer(s_cubeTexCoords.length); + this.cubeTexCoords = Buffers.newDirectShortBuffer(s_cubeTexCoords.length); cubeTexCoords.put(s_cubeTexCoords); cubeTexCoords.flip(); } @@ -153,23 +153,23 @@ public class Cube implements GLEventListener { 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.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() * BufferUtil.SIZEOF_BYTE, cubeNormals, GL.GL_STATIC_DRAW); + 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); 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.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() * BufferUtil.SIZEOF_SHORT, cubeTexCoords, GL.GL_STATIC_DRAW); + gl.glBufferData(GL.GL_ARRAY_BUFFER, cubeTexCoords.limit() * Buffers.SIZEOF_SHORT, cubeTexCoords, GL.GL_STATIC_DRAW); gl.glTexCoordPointer(2, gl.GL_SHORT, 0, 0); /* issues an GL_INVALID_ENUM gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_INCR); diff --git a/src/demos/es1/cube/CubeImmModeSink.java b/src/demos/es1/cube/CubeImmModeSink.java index fccbb5a..e91a595 100644 --- a/src/demos/es1/cube/CubeImmModeSink.java +++ b/src/demos/es1/cube/CubeImmModeSink.java @@ -31,6 +31,7 @@ */ package demos.es1.cube; +import com.jogamp.gluegen.runtime.Buffers; import javax.media.opengl.*; import javax.media.opengl.glu.*; import javax.media.nativewindow.*; @@ -54,7 +55,7 @@ public class CubeImmModeSink implements GLEventListener { ImmModeSink vboCubeF = null; public void drawCube(GL2ES1 gl, float extent) { if(cubeIndices==null) { - cubeIndices = BufferUtil.newByteBuffer(s_cubeIndices); + cubeIndices = Buffers.newDirectByteBuffer(s_cubeIndices); } if(vboCubeF==null) { @@ -66,9 +67,9 @@ public class CubeImmModeSink implements GLEventListener { vbo.glBegin(GL.GL_TRIANGLES); - vbo.glVertexv(BufferUtil.newShortBuffer(s_cubeVertices)); - vbo.glColorv(BufferUtil.newFloatBuffer(s_cubeColors)); - vbo.glNormalv(BufferUtil.newByteBuffer(s_cubeNormals)); + vbo.glVertexv(Buffers.newDirectShortBuffer(s_cubeVertices)); + vbo.glColorv(Buffers.newDirectFloatBuffer(s_cubeColors)); + vbo.glNormalv(Buffers.newDirectByteBuffer(s_cubeNormals)); if(VBO_CACHE) { vbo.glEnd(gl, false); |