aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/javax/media
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/javax/media')
-rw-r--r--src/classes/javax/media/opengl/util/FixedPoint.java29
-rw-r--r--src/classes/javax/media/opengl/util/VBOBufferDraw.java9
2 files changed, 30 insertions, 8 deletions
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;