diff options
Diffstat (limited to 'src/jogl/classes/com')
11 files changed, 78 insertions, 417 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/BufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/BufferUtil.java index fde1e8681..41baf03d7 100755 --- a/src/jogl/classes/com/jogamp/opengl/util/BufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/BufferUtil.java @@ -36,31 +36,23 @@ * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ - package com.jogamp.opengl.util; +import com.jogamp.gluegen.runtime.Buffers; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GL2ES2; -import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; import java.nio.*; -import java.util.*; - -import java.lang.reflect.*; - -/** Utility routines for dealing with direct buffers. */ -public class BufferUtil { - public static final int SIZEOF_BYTE = 1; - public static final int SIZEOF_SHORT = 2; - public static final int SIZEOF_INT = 4; - public static final int SIZEOF_FLOAT = 4; - public static final int SIZEOF_LONG = 8; - public static final int SIZEOF_DOUBLE = 8; +/** + * Utility routines for dealing with direct buffers. + * @author Kenneth Russel + * @author Michael Bien + */ +public class BufferUtil extends Buffers { - public static final int sizeOfGLType(int glType) { + public static final int sizeOfGLType(int glType) { switch (glType) { case GL.GL_UNSIGNED_BYTE: return SIZEOF_BYTE; @@ -82,9 +74,9 @@ public class BufferUtil { return SIZEOF_DOUBLE; } return -1; - } + } - public static final int sizeOfBufferElem(Buffer buffer) { + public static final int sizeOfBufferElem(Buffer buffer) { if (buffer == null) { return 0; } @@ -99,38 +91,34 @@ public class BufferUtil { } else if (buffer instanceof DoubleBuffer) { return BufferUtil.SIZEOF_DOUBLE; } - throw new RuntimeException("Unexpected buffer type " + - buffer.getClass().getName()); - } - - private BufferUtil() {} - - //---------------------------------------------------------------------- - // Allocation routines - // + throw new RuntimeException("Unexpected buffer type " + + buffer.getClass().getName()); + } - public static final Buffer newGLBuffer(int glType, int numElements) { + public static final Buffer newDirectGLBuffer(int glType, int numElements) { switch (glType) { case GL.GL_UNSIGNED_BYTE: case GL.GL_BYTE: - return newByteBuffer(numElements); + return newDirectByteBuffer(numElements); case GL.GL_UNSIGNED_SHORT: case GL.GL_SHORT: - return newShortBuffer(numElements); + return newDirectShortBuffer(numElements); case GL.GL_FLOAT: - return newFloatBuffer(numElements); + return newDirectFloatBuffer(numElements); case GL.GL_FIXED: case GL2ES2.GL_INT: case GL2ES2.GL_UNSIGNED_INT: - return newIntBuffer(numElements); + return newDirectIntBuffer(numElements); case GL2.GL_DOUBLE: - return newDoubleBuffer(numElements); + return newDirectDoubleBuffer(numElements); } return null; - } + } - public static final Buffer sliceGLBuffer(ByteBuffer parent, int bytePos, int byteLen, int glType) { - if(parent==null || byteLen==0) return null; + public static final Buffer sliceGLBuffer(ByteBuffer parent, int bytePos, int byteLen, int glType) { + if (parent == null || byteLen == 0) { + return null; + } parent.position(bytePos); parent.limit(bytePos + byteLen); @@ -151,349 +139,18 @@ public class BufferUtil { return parent.asDoubleBuffer(); } return null; - } - - /** Allocates a new direct ByteBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static ByteBuffer newByteBuffer(int numElements) { - ByteBuffer bb = ByteBuffer.allocateDirect(numElements); - nativeOrder(bb); - return bb; - } - - public static ByteBuffer newByteBuffer(byte[] values, int offset, int len) { - ByteBuffer bb = newByteBuffer(len); - bb.put(values, offset, len); - bb.rewind(); - return bb; - } - - public static ByteBuffer newByteBuffer(byte[] values, int offset) { - return newByteBuffer(values, offset, values.length-offset); - } - - public static ByteBuffer newByteBuffer(byte[] values) { - return newByteBuffer(values, 0); - } - - - /** Allocates a new direct DoubleBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static DoubleBuffer newDoubleBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_DOUBLE); - return bb.asDoubleBuffer(); - } - - public static DoubleBuffer newDoubleBuffer(double[] values, int offset) { - int len = values.length-offset; - DoubleBuffer bb = newDoubleBuffer(len); - bb.put(values, offset, len); - bb.rewind(); - return bb; - } - - public static DoubleBuffer newDoubleBuffer(double[] values) { - return newDoubleBuffer(values, 0); - } - - - /** Allocates a new direct FloatBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static FloatBuffer newFloatBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT); - return bb.asFloatBuffer(); - } - - public static FloatBuffer newFloatBuffer(float[] values, int offset, int len) { - FloatBuffer bb = newFloatBuffer(len); - bb.put(values, offset, len); - bb.rewind(); - return bb; - } - - public static FloatBuffer newFloatBuffer(float[] values, int offset) { - return newFloatBuffer(values, 0, values.length-offset); - } - - public static FloatBuffer newFloatBuffer(float[] values) { - return newFloatBuffer(values, 0); - } - - - /** Allocates a new direct IntBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static IntBuffer newIntBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT); - return bb.asIntBuffer(); - } - - public static IntBuffer newIntBuffer(int[] values, int offset, int len) { - IntBuffer bb = newIntBuffer(len); - bb.put(values, offset, len); - bb.rewind(); - return bb; - } - - public static IntBuffer newIntBuffer(int[] values, int offset) { - return newIntBuffer(values, 0, values.length-offset); - } - - public static IntBuffer newIntBuffer(int[] values) { - return newIntBuffer(values, 0); - } - - /** Allocates a new direct LongBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static LongBuffer newLongBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_LONG); - return bb.asLongBuffer(); - } - - /** Allocates a new direct ShortBuffer with the specified number of - elements. The returned buffer will have its byte order set to - the host platform's native byte order. */ - public static ShortBuffer newShortBuffer(int numElements) { - ByteBuffer bb = newByteBuffer(numElements * SIZEOF_SHORT); - return bb.asShortBuffer(); - } - - public static ShortBuffer newShortBuffer(short[] values, int offset, int len) { - ShortBuffer bb = newShortBuffer(len); - bb.put(values, offset, len); - bb.rewind(); - return bb; - } - - public static ShortBuffer newShortBuffer(short[] values, int offset) { - return newShortBuffer(values, 0, values.length-offset); - } - - public static ShortBuffer newShortBuffer(short[] values) { - return newShortBuffer(values, 0); - } - - //---------------------------------------------------------------------- - // Copy routines (type-to-type) - // - - /** Copies the <i>remaining</i> elements (as defined by - <code>limit() - position()</code>) in the passed ByteBuffer into - a newly-allocated direct ByteBuffer. The returned buffer will - have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ByteBuffer copyByteBuffer(ByteBuffer orig) { - ByteBuffer dest = newByteBuffer(orig.remaining()); - dest.put(orig); - dest.rewind(); - return dest; - } - - /** Copies the <i>remaining</i> elements (as defined by - <code>limit() - position()</code>) in the passed FloatBuffer - into a newly-allocated direct FloatBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static FloatBuffer copyFloatBuffer(FloatBuffer orig) { - return copyFloatBufferAsByteBuffer(orig).asFloatBuffer(); - } - - /** Copies the <i>remaining</i> elements (as defined by - <code>limit() - position()</code>) in the passed IntBuffer - into a newly-allocated direct IntBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static IntBuffer copyIntBuffer(IntBuffer orig) { - return copyIntBufferAsByteBuffer(orig).asIntBuffer(); - } - - /** Copies the <i>remaining</i> elements (as defined by - <code>limit() - position()</code>) in the passed ShortBuffer - into a newly-allocated direct ShortBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ShortBuffer copyShortBuffer(ShortBuffer orig) { - return copyShortBufferAsByteBuffer(orig).asShortBuffer(); - } - - //---------------------------------------------------------------------- - // Copy routines (type-to-ByteBuffer) - // - - /** Copies the <i>remaining</i> elements (as defined by - <code>limit() - position()</code>) in the passed FloatBuffer - into a newly-allocated direct ByteBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ByteBuffer copyFloatBufferAsByteBuffer(FloatBuffer orig) { - ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_FLOAT); - dest.asFloatBuffer().put(orig); - dest.rewind(); - return dest; - } - - /** Copies the <i>remaining</i> elements (as defined by - <code>limit() - position()</code>) in the passed IntBuffer into - a newly-allocated direct ByteBuffer. The returned buffer will - have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ByteBuffer copyIntBufferAsByteBuffer(IntBuffer orig) { - ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_INT); - dest.asIntBuffer().put(orig); - dest.rewind(); - return dest; - } - - /** Copies the <i>remaining</i> elements (as defined by - <code>limit() - position()</code>) in the passed ShortBuffer - into a newly-allocated direct ByteBuffer. The returned buffer - will have its byte order set to the host platform's native byte - order. The position of the newly-allocated buffer will be zero, - and the position of the passed buffer is unchanged (though its - mark is changed). */ - public static ByteBuffer copyShortBufferAsByteBuffer(ShortBuffer orig) { - ByteBuffer dest = newByteBuffer(orig.remaining() * SIZEOF_SHORT); - dest.asShortBuffer().put(orig); - dest.rewind(); - return dest; - } - - //---------------------------------------------------------------------- - // Conversion routines - // - - public final static float[] getFloatArray(double[] source) { - int i=source.length; - float[] dest = new float[i--]; - while(i>=0) { dest[i]=(float)source[i]; i--; } - return dest; - } - - public final static FloatBuffer getFloatBuffer(DoubleBuffer source) { - source.rewind(); - FloatBuffer dest = BufferUtil.newFloatBuffer(source.limit()); - while(source.hasRemaining()) { dest.put((float)source.get()); } - return dest; - } - - public static ByteBuffer nativeOrder(ByteBuffer buf) { - if (!isCDCFP) { - try { - if (byteOrderClass == null) { - byteOrderClass = Class.forName("java.nio.ByteOrder"); - orderMethod = ByteBuffer.class.getMethod("order", new Class[] { byteOrderClass }); - Method nativeOrderMethod = byteOrderClass.getMethod("nativeOrder", null); - nativeOrderObject = nativeOrderMethod.invoke(null, null); - } - } catch (Throwable t) { - // Must be running on CDC / FP - isCDCFP = true; - } - - if (!isCDCFP) { - try { - orderMethod.invoke(buf, new Object[] { nativeOrderObject }); - } catch (Throwable t) { - } - } - } - return buf; - } - - //---------------------------------------------------------------------- - // Convenient GL put methods with generic target Buffer - // - public static void put(Buffer dest, Buffer v) { - if((dest instanceof ByteBuffer) && (v instanceof ByteBuffer)) { - ((ByteBuffer)dest).put((ByteBuffer)v); - } else if((dest instanceof ShortBuffer) && (v instanceof ShortBuffer)) { - ((ShortBuffer)dest).put((ShortBuffer)v); - } else if((dest instanceof IntBuffer) && (v instanceof IntBuffer)) { - ((IntBuffer)dest).put((IntBuffer)v); - } else if((dest instanceof FloatBuffer) && (v instanceof FloatBuffer)) { - ((FloatBuffer)dest).put((FloatBuffer)v); - } else { - throw new GLException("Incompatible Buffer classes: dest = "+dest.getClass().getName() + ", src = " + v.getClass().getName()); - } - } - - public static void putb(Buffer dest, byte v) { - if(dest instanceof ByteBuffer) { - ((ByteBuffer)dest).put(v); - } else if(dest instanceof ShortBuffer) { - ((ShortBuffer)dest).put((short)v); - } else if(dest instanceof IntBuffer) { - ((IntBuffer)dest).put((int)v); - } else { - throw new GLException("Byte doesn't match Buffer Class: "+dest); - } - } - - public static void puts(Buffer dest, short v) { - if(dest instanceof ShortBuffer) { - ((ShortBuffer)dest).put(v); - } else if(dest instanceof IntBuffer) { - ((IntBuffer)dest).put((int)v); - } else { - throw new GLException("Short doesn't match Buffer Class: "+dest); } - } - public static void puti(Buffer dest, int v) { - if(dest instanceof IntBuffer) { - ((IntBuffer)dest).put(v); - } else { - throw new GLException("Integer doesn't match Buffer Class: "+dest); - } - } - - public static void putx(Buffer dest, int v) { - puti(dest, v); - } - - public static void putf(Buffer dest, float v) { - if(dest instanceof FloatBuffer) { - ((FloatBuffer)dest).put(v); - } else if(dest instanceof IntBuffer) { - ((IntBuffer)dest).put(FixedPoint.toFixed(v)); - } else { - throw new GLException("Float doesn't match Buffer Class: "+dest); - } - } - - public static void putd(Buffer dest, double v) { - if(dest instanceof FloatBuffer) { - ((FloatBuffer)dest).put((float)v); - } else { - throw new GLException("Double doesn't match Buffer Class: "+dest); + //---------------------------------------------------------------------- + // Conversion routines + // + public final static float[] getFloatArray(double[] source) { + int i = source.length; + float[] dest = new float[i--]; + while (i >= 0) { + dest[i] = (float) source[i]; + i--; + } + return dest; } - } - - //---------------------------------------------------------------------- - // Internals only below this point - // - - // NOTE that this work must be done reflectively at the present time - // because this code must compile and run correctly on both CDC/FP and J2SE - private static boolean isCDCFP; - private static Class byteOrderClass; - private static Object nativeOrderObject; - private static Method orderMethod; - } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java index f8951f0fd..d41e4b922 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java @@ -1,6 +1,7 @@ package com.jogamp.opengl.util; +import com.jogamp.gluegen.runtime.Buffers; import java.security.*; import javax.media.opengl.*; @@ -189,7 +190,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData public void padding(int done) { if ( buffer==null || sealed ) return; while(done<strideL) { - BufferUtil.putb(buffer, (byte)0); + Buffers.putb(buffer, (byte)0); done++; } } @@ -206,25 +207,25 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData throw new GLException("Buffer length ("+v.remaining()+") is not a multiple of component-stride:\n\t"+this); } growBufferIfNecessary(v.remaining()); - BufferUtil.put(buffer, v); + Buffers.put(buffer, v); } public void putb(byte v) { if ( buffer==null || sealed ) return; growBufferIfNecessary(1); - BufferUtil.putb(buffer, v); + Buffers.putb(buffer, v); } public void puts(short v) { if ( buffer==null || sealed ) return; growBufferIfNecessary(1); - BufferUtil.puts(buffer, v); + Buffers.puts(buffer, v); } public void puti(int v) { if ( buffer==null || sealed ) return; growBufferIfNecessary(1); - BufferUtil.puti(buffer, v); + Buffers.puti(buffer, v); } public void putx(int v) { @@ -234,7 +235,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData public void putf(float v) { if ( buffer==null || sealed ) return; growBufferIfNecessary(1); - BufferUtil.putf(buffer, v); + Buffers.putf(buffer, v); } public String toString() { @@ -274,28 +275,28 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData if(components>0) { int osize = (buffer!=null)?buffer.capacity():0; if(clazz==ByteBuffer.class) { - ByteBuffer newBBuffer = BufferUtil.newByteBuffer( (osize+additional) * components ); + ByteBuffer newBBuffer = Buffers.newDirectByteBuffer( (osize+additional) * components ); if(buffer!=null) { buffer.flip(); newBBuffer.put((ByteBuffer)buffer); } buffer = newBBuffer; } else if(clazz==ShortBuffer.class) { - ShortBuffer newSBuffer = BufferUtil.newShortBuffer( (osize+additional) * components ); + ShortBuffer newSBuffer = Buffers.newDirectShortBuffer( (osize+additional) * components ); if(buffer!=null) { buffer.flip(); newSBuffer.put((ShortBuffer)buffer); } buffer = newSBuffer; } else if(clazz==IntBuffer.class) { - IntBuffer newIBuffer = BufferUtil.newIntBuffer( (osize+additional) * components ); + IntBuffer newIBuffer = Buffers.newDirectIntBuffer( (osize+additional) * components ); if(buffer!=null) { buffer.flip(); newIBuffer.put((IntBuffer)buffer); } buffer = newIBuffer; } else if(clazz==FloatBuffer.class) { - FloatBuffer newFBuffer = BufferUtil.newFloatBuffer( (osize+additional) * components ); + FloatBuffer newFBuffer = Buffers.newDirectFloatBuffer( (osize+additional) * components ); if(buffer!=null) { buffer.flip(); newFBuffer.put((FloatBuffer)buffer); diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java index 7c71c4309..22a2d8a9f 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java @@ -817,7 +817,7 @@ public class ImmModeSink { count = elements; bSize = count * ( vWidth + cWidth + nWidth + tWidth ) ; - buffer = BufferUtil.newByteBuffer(bSize); + buffer = BufferUtil.newDirectByteBuffer(bSize); int pos = 0; int size= count * vWidth ; diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index 9cf41804f..f6d5f1999 100755 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -33,6 +33,7 @@ package com.jogamp.opengl.util; +import com.jogamp.gluegen.runtime.Buffers; import com.jogamp.opengl.impl.ProjectFloat; import java.nio.*; @@ -47,7 +48,7 @@ public class PMVMatrix implements GLMatrixFunc { public PMVMatrix() { projectFloat = new ProjectFloat(); - matrixIdent = BufferUtil.newFloatBuffer(1*16); + matrixIdent = Buffers.newDirectFloatBuffer(1*16); projectFloat.gluMakeIdentityf(matrixIdent); matrixIdent.rewind(); @@ -57,7 +58,7 @@ public class PMVMatrix implements GLMatrixFunc { // Mvi Modelview-Inverse // Mvit Modelview-Inverse-Transpose // Pmv P * Mv - matrixTPMvMvitPmv = BufferUtil.newFloatBuffer(6*16); // grouping T + P + Mv + Mvi + Mvit + Pmv + matrixTPMvMvitPmv = Buffers.newDirectFloatBuffer(6*16); // grouping T + P + Mv + Mvi + Mvit + Pmv matrixPMvMvitPmv = slice(matrixTPMvMvitPmv, 1*16, 5*16); // grouping P + Mv + Mvi + Mvit + Pmv matrixT = slice(matrixTPMvMvitPmv, 0*16, 1*16); // T matrixPMvMvit = slice(matrixTPMvMvitPmv, 1*16, 4*16); // grouping P + Mv + Mvi + Mvit @@ -70,9 +71,9 @@ public class PMVMatrix implements GLMatrixFunc { matrixPmv = slice(matrixTPMvMvitPmv, 5*16, 1*16); // Pmv matrixTPMvMvitPmv.rewind(); - matrixMvit3 = BufferUtil.newFloatBuffer(3*3); + matrixMvit3 = Buffers.newDirectFloatBuffer(3*3); - localBuf = BufferUtil.newFloatBuffer(6*16); + localBuf = Buffers.newDirectFloatBuffer(6*16); matrixMult=slice(localBuf, 0*16, 16); diff --git a/src/jogl/classes/com/jogamp/opengl/util/StreamUtil.java b/src/jogl/classes/com/jogamp/opengl/util/StreamUtil.java index 294f86303..83186f6a0 100755 --- a/src/jogl/classes/com/jogamp/opengl/util/StreamUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/StreamUtil.java @@ -59,7 +59,7 @@ public class StreamUtil { public static ByteBuffer readAll2Buffer(InputStream stream) throws IOException { BytesRead bytesRead = readAllImpl(stream); - return BufferUtil.newByteBuffer(bytesRead.data, 0, bytesRead.payloadLen); + return BufferUtil.newDirectByteBuffer(bytesRead.data, 0, bytesRead.payloadLen); } private static BytesRead readAllImpl(InputStream stream) throws IOException { diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java index 1fbdade4e..4de2e5974 100755 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java @@ -38,6 +38,7 @@ */ package com.jogamp.opengl.util.awt; +import com.jogamp.gluegen.runtime.Buffers; import com.jogamp.opengl.impl.Debug; import com.jogamp.opengl.util.*; import com.jogamp.opengl.util.packrect.*; @@ -1707,8 +1708,8 @@ public class TextRenderer { Pipelined_QuadRenderer() { GL2 gl = GLContext.getCurrentGL().getGL2(); - mVertCoords = BufferUtil.newFloatBuffer(kTotalBufferSizeCoordsVerts); - mTexCoords = BufferUtil.newFloatBuffer(kTotalBufferSizeCoordsTex); + mVertCoords = Buffers.newDirectFloatBuffer(kTotalBufferSizeCoordsVerts); + mTexCoords = Buffers.newDirectFloatBuffer(kTotalBufferSizeCoordsTex); usingVBOs = is15Available(gl); diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index 01b94d0d9..94b329cd5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -1,6 +1,7 @@ package com.jogamp.opengl.util.glsl; +import com.jogamp.gluegen.runtime.Buffers; import javax.media.opengl.*; import com.jogamp.opengl.util.*; import com.jogamp.opengl.impl.Debug; @@ -34,7 +35,7 @@ public class ShaderCode { shaderBinaryFormat = -1; shaderBinary = null; shaderType = type; - shader = BufferUtil.newIntBuffer(number); + shader = Buffers.newDirectIntBuffer(number); id = getNextID(); if(DEBUG_CODE) { @@ -55,7 +56,7 @@ public class ShaderCode { shaderBinaryFormat = binFormat; shaderBinary = binary; shaderType = type; - shader = BufferUtil.newIntBuffer(number); + shader = Buffers.newDirectIntBuffer(number); id = getNextID(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java index 6e5bd2eb2..b69cc2b72 100755 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java @@ -128,7 +128,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun pmvMatrix.glLoadMatrixf(m); } public void glLoadMatrixf(float[] m, int m_offset) { - glLoadMatrixf(BufferUtil.newFloatBuffer(m, m_offset)); + glLoadMatrixf(BufferUtil.newDirectFloatBuffer(m, m_offset)); } public void glPopMatrix() { pmvMatrix.glPopMatrix(); @@ -143,7 +143,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun pmvMatrix.glMultMatrixf(m); } public void glMultMatrixf(float[] m, int m_offset) { - glMultMatrixf(BufferUtil.newFloatBuffer(m, m_offset)); + glMultMatrixf(BufferUtil.newDirectFloatBuffer(m, m_offset)); } public void glTranslatef(float x, float y, float z) { pmvMatrix.glTranslatef(x, y, z); @@ -165,23 +165,23 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun // LightingIf // public void glColor4f(float red, float green, float blue, float alpha) { - fixedFunction.glColor4fv(gl, BufferUtil.newFloatBuffer(new float[] { red, green, blue, alpha })); + fixedFunction.glColor4fv(gl, BufferUtil.newDirectFloatBuffer(new float[] { red, green, blue, alpha })); } public void glLightfv(int light, int pname, java.nio.FloatBuffer params) { fixedFunction.glLightfv(gl, light, pname, params); } public void glLightfv(int light, int pname, float[] params, int params_offset) { - glLightfv(light, pname, BufferUtil.newFloatBuffer(params, params_offset)); + glLightfv(light, pname, BufferUtil.newDirectFloatBuffer(params, params_offset)); } public void glMaterialfv(int face, int pname, java.nio.FloatBuffer params) { fixedFunction.glMaterialfv(gl, face, pname, params); } public void glMaterialfv(int face, int pname, float[] params, int params_offset) { - glMaterialfv(face, pname, BufferUtil.newFloatBuffer(params, params_offset)); + glMaterialfv(face, pname, BufferUtil.newDirectFloatBuffer(params, params_offset)); } public void glMaterialf(int face, int pname, float param) { - glMaterialfv(face, pname, BufferUtil.newFloatBuffer(new float[] { param })); + glMaterialfv(face, pname, BufferUtil.newDirectFloatBuffer(new float[] { param })); } public void glShadeModel(int mode) { fixedFunction.glShadeModel(gl, mode); diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncPipeline.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncPipeline.java index 1a60ab21e..9ead6c4eb 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncPipeline.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncPipeline.java @@ -1,11 +1,11 @@ package com.jogamp.opengl.util.glsl.fixedfunc.impl; +import com.jogamp.gluegen.runtime.Buffers; import javax.media.opengl.*; import javax.media.opengl.fixedfunc.*; import com.jogamp.opengl.util.*; import com.jogamp.opengl.util.glsl.*; -import com.jogamp.opengl.util.glsl.fixedfunc.*; import java.nio.*; public class FixedFuncPipeline { @@ -490,14 +490,14 @@ public class FixedFuncPipeline { protected boolean verbose=false; protected boolean textureEnabled=false; - protected IntBuffer textureCoordsEnabled = BufferUtil.newIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }); + protected IntBuffer textureCoordsEnabled = Buffers.newDirectIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }); protected boolean textureCoordsEnabledDirty = false; protected int activeTextureUnit=0; protected int cullFace=-2; // <=0 disabled, 1: front, 2: back (default, but disabled), 3: front & back protected boolean lightingEnabled=false; - protected IntBuffer lightsEnabled = BufferUtil.newIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }); + protected IntBuffer lightsEnabled = Buffers.newDirectIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }); protected boolean lightsEnabledDirty = false; protected PMVMatrix pmvMatrix; @@ -525,23 +525,23 @@ public class FixedFuncPipeline { protected static final String mgl_CullFace = "mgl_CullFace"; // 1i - protected static final FloatBuffer zero4f = BufferUtil.newFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f, 0.0f }); + protected static final FloatBuffer zero4f = Buffers.newDirectFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f, 0.0f }); - public static final FloatBuffer defAmbient = BufferUtil.newFloatBuffer(new float[] { 0f, 0f, 0f, 1f }); + public static final FloatBuffer defAmbient = Buffers.newDirectFloatBuffer(new float[] { 0f, 0f, 0f, 1f }); public static final FloatBuffer defDiffuse = zero4f; public static final FloatBuffer defSpecular= zero4f; - public static final FloatBuffer defPosition= BufferUtil.newFloatBuffer(new float[] { 0f, 0f, 1f, 0f }); - public static final FloatBuffer defSpotDir = BufferUtil.newFloatBuffer(new float[] { 0f, 0f, -1f }); + public static final FloatBuffer defPosition= Buffers.newDirectFloatBuffer(new float[] { 0f, 0f, 1f, 0f }); + public static final FloatBuffer defSpotDir = Buffers.newDirectFloatBuffer(new float[] { 0f, 0f, -1f }); public static final float defSpotExponent = 0f; public static final float defSpotCutoff = 180f; public static final float defConstantAtten = 1f; public static final float defLinearAtten = 0f; public static final float defQuadraticAtten= 0f; - public static final FloatBuffer defMatAmbient = BufferUtil.newFloatBuffer(new float[] { 0.2f, 0.2f, 0.2f, 1.0f }); - public static final FloatBuffer defMatDiffuse = BufferUtil.newFloatBuffer(new float[] { 0.8f, 0.8f, 0.8f, 1.0f }); - public static final FloatBuffer defMatSpecular= BufferUtil.newFloatBuffer(new float[] { 0f, 0f, 0f, 1f}); - public static final FloatBuffer defMatEmission= BufferUtil.newFloatBuffer(new float[] { 0f, 0f, 0f, 1f}); + public static final FloatBuffer defMatAmbient = Buffers.newDirectFloatBuffer(new float[] { 0.2f, 0.2f, 0.2f, 1.0f }); + public static final FloatBuffer defMatDiffuse = Buffers.newDirectFloatBuffer(new float[] { 0.8f, 0.8f, 0.8f, 1.0f }); + public static final FloatBuffer defMatSpecular= Buffers.newDirectFloatBuffer(new float[] { 0f, 0f, 0f, 1f}); + public static final FloatBuffer defMatEmission= Buffers.newDirectFloatBuffer(new float[] { 0f, 0f, 0f, 1f}); public static final float defMatShininess = 0f; protected static final String vertexColorFileDef = "FixedFuncColor"; diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javame_cdc_fp b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javame_cdc_fp index 4feeb9f4e..2ed1299da 100755 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javame_cdc_fp +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javame_cdc_fp @@ -478,7 +478,7 @@ public class DDSImage { } if (size == 0) size = 1; - return BufferUtil.newByteBuffer(size); + return BufferUtil.newDirectByteBuffer(size); } public void debugPrint() { diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javase b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javase index b1f18cc9e..4e9294870 100755 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javase +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javase @@ -503,7 +503,7 @@ public class DDSImage { } if (size == 0) size = 1; - return BufferUtil.newByteBuffer(size); + return BufferUtil.newDirectByteBuffer(size); } public void debugPrint() { |