diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/classes/com/sun/opengl/impl/GLContextImpl.java | 7 | ||||
-rw-r--r-- | src/classes/javax/media/opengl/util/FixedPoint.java | 29 | ||||
-rw-r--r-- | src/classes/javax/media/opengl/util/VBOBufferDraw.java | 9 |
3 files changed, 37 insertions, 8 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLContextImpl.java b/src/classes/com/sun/opengl/impl/GLContextImpl.java index ffdf81f1a..90b52a285 100644 --- a/src/classes/com/sun/opengl/impl/GLContextImpl.java +++ b/src/classes/com/sun/opengl/impl/GLContextImpl.java @@ -395,6 +395,13 @@ public abstract class GLContextImpl extends GLContext { this.bufferSizeTracker = bufferSizeTracker; } + public GLBufferSizeTracker getOrCreateBufferSizeTracker() { + if(null==bufferSizeTracker) { + bufferSizeTracker=new GLBufferSizeTracker(); + } + return bufferSizeTracker; + } + public GLBufferSizeTracker getBufferSizeTracker() { return bufferSizeTracker; } diff --git a/src/classes/javax/media/opengl/util/FixedPoint.java b/src/classes/javax/media/opengl/util/FixedPoint.java new file mode 100644 index 000000000..35e2aaaf4 --- /dev/null +++ b/src/classes/javax/media/opengl/util/FixedPoint.java @@ -0,0 +1,29 @@ + +package javax.media.opengl.util; + +public class FixedPoint { + public static final int toFixed(int value) { + if (value < -32768) value = -32768; + if (value > 32767) value = 32767; + return value * 65536; + } + + public static final int toFixed(float value) { + if (value < -32768) value = -32768; + if (value > 32767) value = 32767; + return (int)(value * 65536.0f); + } + + public static final float toFloat(int value) { + return (float)value/65536.0f; + } + + public static final int mult(int x1, int x2) { + return (int) ( ((long)x1*(long)x2)/65536 ); + } + + public static final int div(int x1, int x2) { + return (int) ( (((long)x1)<<16)/x2 ); + } +} + diff --git a/src/classes/javax/media/opengl/util/VBOBufferDraw.java b/src/classes/javax/media/opengl/util/VBOBufferDraw.java index 7a7a3d9a6..34b1be0b1 100644 --- a/src/classes/javax/media/opengl/util/VBOBufferDraw.java +++ b/src/classes/javax/media/opengl/util/VBOBufferDraw.java @@ -325,7 +325,7 @@ public abstract class VBOBufferDraw { if(clazz==FloatBuffer.class) { ((FloatBuffer)buffer).put(v); } else if(clazz==IntBuffer.class) { - ((IntBuffer)buffer).put(Float2Fixed(v)); + ((IntBuffer)buffer).put(FixedPoint.toFixed(v)); } else { throw new GLException("Float doesn't match Buffer Class: "+clazz+" :\n\t"+this); } @@ -357,13 +357,6 @@ public abstract class VBOBufferDraw { "]"; } - public static final int Float2Fixed(float value) - { - if (value < -32768) value = -32768; - if (value > 32767) value = 32767; - return (int)(value * 65536); - } - protected int glArrayType; protected int glDataType; protected Class clazz; |