diff --git a/src/java/org/lwjgl/Math.java b/src/java/org/lwjgl/Math.java
index 97c150ca..735e5cac 100644
--- a/src/java/org/lwjgl/Math.java
+++ b/src/java/org/lwjgl/Math.java
@@ -62,11 +62,6 @@ public final class Math {
super();
}
- /**
- * @return a random float between 0 and 1.
- */
- public static native float random();
-
/**
* Return the sine of theta
*
diff --git a/src/java/org/lwjgl/StructBuffer.java b/src/java/org/lwjgl/StructBuffer.java
new file mode 100644
index 00000000..3d246518
--- /dev/null
+++ b/src/java/org/lwjgl/StructBuffer.java
@@ -0,0 +1,345 @@
+/**
+ * (C) 2002 Shaven Puppy Ltd
+ *
+ * StructBuffer.java Created on Aug 10, 2002 by foo
+ */
+package org.lwjgl;
+
+import java.nio.*;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+
+/**
+ * A StructBuffer is an abstract class for wrapping arrays of C-structures.
+ * To use this class you should derive a class with methods to get individual
+ * data out of arbitrary locations in the buffer.
+ *
+ * The StructBuffer supports several simultaneously available datatypes which
+ * are implemented by having one underlying native byte buffer over which
+ * several views in different basic types are available.
+ *
+ * Longs and doubles are not implemented by default because of their limited
+ * usefulness in games.
+ *
+ * Note that because StructBuffer uses a fairly hefty amount of storage and
+ * setup overhead it should be used to store large and/or persistent allocations
+ * of data.
+ *
+ * @author foo
+ */
+public abstract class StructBuffer {
+
+ /** The native address of the buffer */
+ private final int address;
+
+ /** The stride of the underlying elements */
+ private final int stride;
+
+ // Precalculated strides
+ private final int strideBy2;
+ private final int strideBy4;
+
+ /** The current element position */
+ private int position;
+
+ /** The number of elements */
+ private final int capacity;
+
+ /** The current limit */
+ private int limit;
+
+ /** The current mark (-1 if no mark is defined) */
+ private int mark = -1;
+
+ /** The underlying native byte buffer */
+ protected final ByteBuffer bytes;
+
+ // Various views of the bytes
+ protected final IntBuffer ints;
+ protected final ShortBuffer shorts;
+ protected final FloatBuffer floats;
+ protected final CharBuffer chars;
+
+ /**
+ * Constructor for StructBuffer using an existing byte buffer.
+ *
+ * @param bytes An existing direct byte buffer, which must be in native endian order
+ * @param stride The distance between the starts of each element, in bytes
+ * @throws AssertionError if the byte buffer is not native-endian, or not direct
+ * @throws IllegalArgumentException if the stride is less than or equal to 0.
+ * @throws NullPointerException if the incoming byte buffer is null
+ */
+ public StructBuffer(ByteBuffer bytes, int stride) {
+
+ assert bytes.order() == ByteOrder.nativeOrder()
+ : "Incoming byte buffer is not native-endian.";
+ assert bytes.isDirect()
+ : "Incoming byte buffer is not direct.";
+
+ this.bytes = bytes;
+ floats = bytes.asFloatBuffer();
+ ints = bytes.asIntBuffer();
+ shorts = bytes.asShortBuffer();
+ chars = bytes.asCharBuffer();
+
+ if (stride <= 0)
+ throw new IllegalArgumentException("The stride must be > 0");
+ else
+ this.stride = stride;
+
+ strideBy2 = stride / 2;
+ strideBy4 = stride / 4;
+
+ capacity = bytes.capacity() / stride;
+ limit = capacity;
+ address = Sys.getDirectBufferAddress(bytes);
+
+ }
+
+ /**
+ * Constructor for StructBuffer which takes an address and size, and which
+ * allocates a direct byte buffer at this location and size. In addition a
+ * stride is specified which gives the distance between the starts of each
+ * structure element. For example, the C-struct
+ *
+ * struct vector {
+ * float x, y, z;
+ * } VECTOR_T;
+ *
+ * has a stride of 12; but it may also have a stride of 16 to allow more
+ * efficient memory access.
+ *
+ * Warning: No attempt is made to ensure that you are actually
+ * allowed to reference this memory or that the size is correct.
+ *
+ * The number of bytes that will be referenced is size * stride.
+ *
+ * @param address The address to allocate at
+ * @param capacity The number of elements to allocate
+ * @param stride The distance between the starts of each element, in bytes
+ * @throws AssertionError if the address is zero, the stride is <=0, or
+ * the size is <=0
+ */
+ public StructBuffer(int address, int capacity, int stride) {
+ assert address != 0 : "Illegal address";
+ assert capacity > 0 : "Capacity must be > 0";
+ assert stride > 0 : "Stride must be > 0";
+
+ this.address = address;
+ this.capacity = capacity;
+ this.stride = stride;
+ strideBy2 = stride / 2;
+ strideBy4 = stride / 4;
+
+ bytes = Sys.createDirectBuffer(address, capacity * stride);
+ floats = bytes.asFloatBuffer();
+ ints = bytes.asIntBuffer();
+ shorts = bytes.asShortBuffer();
+ chars = bytes.asCharBuffer();
+ limit = capacity;
+ }
+
+ /**
+ * Sets this buffer's position. If the mark is defined and larger than the
+ * new position then it is discarded.
+ * @param newPosition The new position value; must be non-negative and no
+ * larger than the current limit
+ * @return this
+ * @throws IllegalArgumentException If the preconditions on newPosition do
+ * not hold
+ */
+ public final int position(int newPosition) {
+ if (newPosition != position) {
+ if (newPosition < 0 || newPosition > limit)
+ throw new IllegalArgumentException("Position "+newPosition+" not valid");
+ if (mark > position)
+ mark = -1;
+ position = newPosition;
+ bytes.position(newPosition * stride);
+ chars.position(newPosition * strideBy2);
+ shorts.position(newPosition * strideBy2);
+ ints.position(newPosition * strideBy4);
+ floats.position(newPosition * strideBy4);
+ }
+ return position;
+ }
+
+ /**
+ * @return the current position
+ */
+ public final int position() {
+ return position;
+ }
+
+ /**
+ * @return the capacity
+ */
+ public final int capacity() {
+ return capacity;
+ }
+
+ /**
+ * Sets this buffer's limit. If the position is larger than the new limit
+ * then it is set to the new limit. If the mark is defined and larger than
+ * the new limit then it is discarded.
+ *
+ * @param newLimit The new limit value; must be non-negative and no larger
+ * than this buffer's capacity
+ * @return this
+ * @throws If the preconditions on newLimit do not hold
+ */
+ public final StructBuffer limit(int newLimit) {
+ if (newLimit != limit) {
+ if (newLimit < 0 || newLimit > capacity)
+ throw new IllegalArgumentException("Illegal new limit "+newLimit);
+ if (position > newLimit)
+ position = newLimit;
+ if (mark > newLimit)
+ mark = -1;
+ newLimit = limit;
+ }
+
+ return this;
+
+ }
+
+ /**
+ * @return the current limit
+ */
+ public final int limit() {
+ return limit;
+ }
+
+ /**
+ * Mark the current position.
+ * @return this
+ */
+ public final StructBuffer mark() {
+ mark = position;
+ return this;
+ }
+
+ /**
+ * Resets this buffer's position to the previously-marked position.
+ * Invoking this method neither changes nor discards the mark's value.
+ *
+ * @return this
+ * @throws InvalidMarkException if the mark has not been defined
+ */
+ public final StructBuffer reset() {
+ if (mark == -1)
+ throw new InvalidMarkException();
+ position = mark;
+ return this;
+ }
+
+ /**
+ * Clears this buffer. The position is set to zero, the limit is set to the
+ * capacity, and the mark is discarded.
+ *
+ * Invoke this method before using a sequence of channel-read or put
+ * operations to fill this buffer. This method does not actually erase the
+ * data in the buffer, but it is named as if it did because it will most
+ * often be used in situations in which that might as well be the case.
+ *
+ * @return this
+ */
+ public final StructBuffer clear() {
+ position = 0;
+ limit = capacity;
+ mark = -1;
+ return this;
+ }
+
+ /**
+ * Flips this buffer. The limit is set to the current position and then the
+ * position is set to zero. If the mark is defined then it is discarded.
+ *
+ * After a sequence of channel-read or put operations, invoke this method to
+ * prepare for a sequence of channel-write or relative get operations.
+ *
+ * @return this
+ */
+ public final StructBuffer flip() {
+ limit = position;
+ position = 0;
+ mark = -1;
+ return this;
+ }
+
+ /**
+ * Rewinds this buffer. The position is set to zero and the mark is
+ * discarded.
+ *
+ * Invoke this method before using a sequence of get operations to read the
+ * content of this buffer, assuming that the limit has already been set
+ * appropriately.
+ *
+ * @return this
+ */
+ public final StructBuffer rewind() {
+ position = 0;
+ mark = -1;
+ return this;
+ }
+
+ /**
+ * @return the number of elements between the current position and the limit.
+ */
+ public final int remaining() {
+ return limit - position;
+ }
+
+ /**
+ * @return true if there are any elements between the current position and
+ * the limit (ie. remaining() > 0)
+ */
+ public final boolean hasRemaining() {
+ return remaining() > 0;
+ }
+
+ /**
+ * Determine whether this buffer is read-only. This method is not abstract
+ * unlike the java.nio.Buffer version; by default we'll get the read-only
+ * status out of the bytes buffer. However this method can be overridden
+ * to force a StructBuffer to be read-only (or not).
+ *
+ * @return true if this buffer is read-only
+ */
+ public boolean isReadOnly() {
+ return bytes.isReadOnly();
+ }
+
+ /**
+ * @return a String representation of the buffer
+ */
+ public String toString() {
+ StringBuffer sb = new StringBuffer(32);
+
+ sb.append("StructBuffer[capacity=");
+ sb.append(capacity);
+ sb.append(", position=");
+ sb.append(position);
+ sb.append(", limit=");
+ sb.append(limit);
+ sb.append(", mark=");
+ sb.append(mark);
+ sb.append(']');
+
+ return sb.toString();
+ }
+
+ /**
+ * @return a hashcode
+ */
+ public int hashCode() {
+ return address;
+ }
+
+ /**
+ * @return the address used by this StructBuffer
+ */
+ public final int getAddress() {
+ return address;
+ }
+}
diff --git a/src/java/org/lwjgl/Sys.java b/src/java/org/lwjgl/Sys.java
index 5b6bb348..c02dc1fd 100644
--- a/src/java/org/lwjgl/Sys.java
+++ b/src/java/org/lwjgl/Sys.java
@@ -23,13 +23,30 @@ public final class Sys {
/** Low process priority. @see #setProcessPriority() */
public static final int LOW_PRIORITY = -1;
- /** Normal process priority. @see #setProcessPriority() */
+ /**
+ * Normal process priority. This priority equates to the priority that the
+ * JVM has when it is started up normally. Note that if the JVM is started
+ * inside a process which is already a different priority then this will not
+ * be the initial priority.
+ *
+ * @see #setProcessPriority()
+ */
public static final int NORMAL_PRIORITY = 0;
/** High process priority. @see #setProcessPriority() */
public static final int HIGH_PRIORITY = 1;
- /** Realtime priority. Use at your own risk. @see #setProcessPriority() */
+ /**
+ * Realtime priority. Use at your own risk. This will set the java process
+ * priority to the highest priority the OS will normally allow. It is likely
+ * that this puts it at a higher priority than many OS critical tasks, such
+ * as disk writes or mouse input and the like. Hence it is quite possible to
+ * completely freeze your machine if you have an errant thread.
+ *
+ * This priority is not recommended for gaming applications.
+ *
+ * @see #setProcessPriority()
+ */
public static final int REALTIME_PRIORITY = 2;
static {
@@ -50,7 +67,7 @@ public final class Sys {
*/
private static void initialize() {
System.loadLibrary(LIBRARY_NAME);
- setTime(0.0f);
+ setTime(0);
}
/**
@@ -76,47 +93,29 @@ public final class Sys {
throws IllegalArgumentException;
/**
- * Obtains the order of resolution of the hires system timer. The returned resolution
- * n describes the worst-case resolution in fractions of a second 1/10^n.
- * For example, a system timer which ticks every 1/5000th of a second will return 3
- * to indicate that the resolution is at least as good as 1/1000th of a second.
- * The reason for this simplistic measurement of resolution is to cut down on
- * the temptation to code to too many specific timer resolutions arbitrarily.
- * If no hires timer is available then this method returns -1. Any system incapable of
- * a resolution of at least 3 is deemed not to have a hires timer and so this method will
- * never return 0, 1, or 2. Furthermore this method will never advertise a
- * resolution which cannot be accurately measured by a float.
+ * Obtains the number of ticks that the hires timer does in a second.
*
- * @return the order of resolution or -1 if no timer is present.
+ * @return timer resolution in ticks per second or 0 if no timer is present.
*/
- public static native int getTimerResolution();
+ public static native long getTimerResolution();
/**
- * Gets the current value of the hires timer, in seconds. When the Sys class is first loaded
- * the hires timer is reset to 0.0f. If no hires timer is present then this method will always
+ * Gets the current value of the hires timer, in ticks. When the Sys class is first loaded
+ * the hires timer is reset to 0. If no hires timer is present then this method will always
* return whatever value the timer was last set to.
- *
- * Because the time is returned as a float, after a certain length of time the
- * hires timer can no longer represent time to the accuracy claimed by getTimerResolution().
- * Therefore the time is guaranteed only to be accurate for up to 100 seconds.
- * After 100 seconds has elapsed it is advisable to reset the timer. In reality
- * you should reset the timer every iteration of your game loop and simply use the
- * elapsed time for the iteration to increment your own, possibly more accurate
- * timers.
*
- * @return the current hires time, in seconds.
+ * @return the current hires time, in ticks.
*/
- public static native float getTime();
+ public static native long getTime();
/**
- * Sets the hires timer to a new time. This time may be rounded by the available
- * hires timer resolution; if the hires timer resolution is 3, and you specify
- * a time of 0.0002f then the time will in fact be set to 0.0f.
- * @param time the new time, in seconds
+ * Sets the hires timer to a new time, specified in ticks.
+ *
+ * @param time The new time, in ticks
* @see #getTime()
* @see #getTimerResolution()
*/
- public static native void setTime(float time);
+ public static native void setTime(long time);
/**
* Set the process priority in a system independent way. Because of the various
diff --git a/src/java/org/lwjgl/input/Keyboard.java b/src/java/org/lwjgl/input/Keyboard.java
index a2ba9d5e..4d6beda7 100644
--- a/src/java/org/lwjgl/input/Keyboard.java
+++ b/src/java/org/lwjgl/input/Keyboard.java
@@ -20,6 +20,132 @@ import org.lwjgl.Sys;
*/
public class Keyboard {
+ // Keyboard key codes.
+
+ public static final int KEY_ESCAPE = 0x01;
+ public static final int KEY_1 = 0x02;
+ public static final int KEY_2 = 0x03;
+ public static final int KEY_3 = 0x04;
+ public static final int KEY_4 = 0x05;
+ public static final int KEY_5 = 0x06;
+ public static final int KEY_6 = 0x07;
+ public static final int KEY_7 = 0x08;
+ public static final int KEY_8 = 0x09;
+ public static final int KEY_9 = 0x0A;
+ public static final int KEY_0 = 0x0B;
+ public static final int KEY_MINUS = 0x0C; /* - on main keyboard */
+ public static final int KEY_EQUALS = 0x0D;
+ public static final int KEY_BACK = 0x0E; /* backspace */
+ public static final int KEY_TAB = 0x0F;
+ public static final int KEY_Q = 0x10;
+ public static final int KEY_W = 0x11;
+ public static final int KEY_E = 0x12;
+ public static final int KEY_R = 0x13;
+ public static final int KEY_T = 0x14;
+ public static final int KEY_Y = 0x15;
+ public static final int KEY_U = 0x16;
+ public static final int KEY_I = 0x17;
+ public static final int KEY_O = 0x18;
+ public static final int KEY_P = 0x19;
+ public static final int KEY_LBRACKET = 0x1A;
+ public static final int KEY_RBRACKET = 0x1B;
+ public static final int KEY_RETURN = 0x1C; /* Enter on main keyboard */
+ public static final int KEY_LCONTROL = 0x1D;
+ public static final int KEY_A = 0x1E;
+ public static final int KEY_S = 0x1F;
+ public static final int KEY_D = 0x20;
+ public static final int KEY_F = 0x21;
+ public static final int KEY_G = 0x22;
+ public static final int KEY_H = 0x23;
+ public static final int KEY_J = 0x24;
+ public static final int KEY_K = 0x25;
+ public static final int KEY_L = 0x26;
+ public static final int KEY_SEMICOLON = 0x27;
+ public static final int KEY_APOSTROPHE = 0x28;
+ public static final int KEY_GRAVE = 0x29; /* accent grave */
+ public static final int KEY_LSHIFT = 0x2A;
+ public static final int KEY_BACKSLASH = 0x2B;
+ public static final int KEY_Z = 0x2C;
+ public static final int KEY_X = 0x2D;
+ public static final int KEY_C = 0x2E;
+ public static final int KEY_V = 0x2F;
+ public static final int KEY_B = 0x30;
+ public static final int KEY_N = 0x31;
+ public static final int KEY_M = 0x32;
+ public static final int KEY_COMMA = 0x33;
+ public static final int KEY_PERIOD = 0x34; /* . on main keyboard */
+ public static final int KEY_SLASH = 0x35; /* / on main keyboard */
+ public static final int KEY_RSHIFT = 0x36;
+ public static final int KEY_MULTIPLY = 0x37; /* * on numeric keypad */
+ public static final int KEY_LMENU = 0x38; /* left Alt */
+ public static final int KEY_SPACE = 0x39;
+ public static final int KEY_CAPITAL = 0x3A;
+ public static final int KEY_F1 = 0x3B;
+ public static final int KEY_F2 = 0x3C;
+ public static final int KEY_F3 = 0x3D;
+ public static final int KEY_F4 = 0x3E;
+ public static final int KEY_F5 = 0x3F;
+ public static final int KEY_F6 = 0x40;
+ public static final int KEY_F7 = 0x41;
+ public static final int KEY_F8 = 0x42;
+ public static final int KEY_F9 = 0x43;
+ public static final int KEY_F10 = 0x44;
+ public static final int KEY_NUMLOCK = 0x45;
+ public static final int KEY_SCROLL = 0x46; /* Scroll Lock */
+ public static final int KEY_NUMPAD7 = 0x47;
+ public static final int KEY_NUMPAD8 = 0x48;
+ public static final int KEY_NUMPAD9 = 0x49;
+ public static final int KEY_SUBTRACT = 0x4A; /* - on numeric keypad */
+ public static final int KEY_NUMPAD4 = 0x4B;
+ public static final int KEY_NUMPAD5 = 0x4C;
+ public static final int KEY_NUMPAD6 = 0x4D;
+ public static final int KEY_ADD = 0x4E; /* + on numeric keypad */
+ public static final int KEY_NUMPAD1 = 0x4F;
+ public static final int KEY_NUMPAD2 = 0x50;
+ public static final int KEY_NUMPAD3 = 0x51;
+ public static final int KEY_NUMPAD0 = 0x52;
+ public static final int KEY_DECIMAL = 0x53; /* . on numeric keypad */
+ public static final int KEY_F11 = 0x57;
+ public static final int KEY_F12 = 0x58;
+ public static final int KEY_F13 = 0x64; /* (NEC PC98) */
+ public static final int KEY_F14 = 0x65; /* (NEC PC98) */
+ public static final int KEY_F15 = 0x66; /* (NEC PC98) */
+ public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */
+ public static final int KEY_CONVERT = 0x79; /* (Japanese keyboard) */
+ public static final int KEY_NOCONVERT = 0x7B; /* (Japanese keyboard) */
+ public static final int KEY_YEN = 0x7D; /* (Japanese keyboard) */
+ public static final int KEY_NUMPADEQUALS = 0x8D; /* = on numeric keypad (NEC PC98) */
+ public static final int KEY_CIRCUMFLEX = 0x90; /* (Japanese keyboard) */
+ public static final int KEY_AT = 0x91; /* (NEC PC98) */
+ public static final int KEY_COLON = 0x92; /* (NEC PC98) */
+ public static final int KEY_UNDERLINE = 0x93; /* (NEC PC98) */
+ public static final int KEY_KANJI = 0x94; /* (Japanese keyboard) */
+ public static final int KEY_STOP = 0x95; /* (NEC PC98) */
+ public static final int KEY_AX = 0x96; /* (Japan AX) */
+ public static final int KEY_UNLABELED = 0x97; /* (J3100) */
+ public static final int KEY_NUMPADENTER = 0x9C; /* Enter on numeric keypad */
+ public static final int KEY_RCONTROL = 0x9D;
+ public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */
+ public static final int KEY_DIVIDE = 0xB5; /* / on numeric keypad */
+ public static final int KEY_SYSRQ = 0xB7;
+ public static final int KEY_RMENU = 0xB8; /* right Alt */
+ public static final int KEY_PAUSE = 0xC5; /* Pause */
+ public static final int KEY_HOME = 0xC7; /* Home on arrow keypad */
+ public static final int KEY_UP = 0xC8; /* UpArrow on arrow keypad */
+ public static final int KEY_PRIOR = 0xC9; /* PgUp on arrow keypad */
+ public static final int KEY_LEFT = 0xCB; /* LeftArrow on arrow keypad */
+ public static final int KEY_RIGHT = 0xCD; /* RightArrow on arrow keypad */
+ public static final int KEY_END = 0xCF; /* End on arrow keypad */
+ public static final int KEY_DOWN = 0xD0; /* DownArrow on arrow keypad */
+ public static final int KEY_NEXT = 0xD1; /* PgDn on arrow keypad */
+ public static final int KEY_INSERT = 0xD2; /* Insert on arrow keypad */
+ public static final int KEY_DELETE = 0xD3; /* Delete on arrow keypad */
+ public static final int KEY_LWIN = 0xDB; /* Left Windows key */
+ public static final int KEY_RWIN = 0xDC; /* Right Windows key */
+ public static final int KEY_APPS = 0xDD; /* AppMenu key */
+ public static final int KEY_POWER = 0xDE;
+ public static final int KEY_SLEEP = 0xDF;
+
static {
initialize();
}
@@ -42,6 +168,12 @@ public class Keyboard {
/** Address of the read buffer */
private static int readBufferAddress;
+ /** The current keyboard event key being examined */
+ public static int key;
+
+ /** The current state of the key being examined in the event queue */
+ public static boolean state;
+
/**
* Mouse cannot be constructed.
*/
@@ -116,20 +248,22 @@ public class Keyboard {
private static native void nPoll(int keyDownBufferAddress);
/**
- * Reads the keyboard
+ * Reads the keyboard buffer.
*/
public static void read() {
assert created : "The keyboard has not been created.";
assert readBuffer != null : "Keyboard buffering has not been enabled.";
- nRead(readBufferAddress);
+ readBuffer.clear();
+ readBuffer.limit(nRead(readBufferAddress) << 1);
}
/**
* Native method to read the keyboard buffer
*
* @param readBufferAddress the address of the keyboard buffer
+ * @return the number of keyboard events read
*/
- private static native void nRead(int readBufferAddress);
+ private static native int nRead(int readBufferAddress);
/**
* Enable keyboard buffering. Must be called after the keyboard is created.
@@ -147,5 +281,40 @@ public class Keyboard {
* or 0 if no buffer can be allocated
*/
private static native int nEnableBuffer();
-
+
+ /**
+ * Checks to see if a key is down.
+ * @param key Keycode to check
+ * @return true if the key is down according to the last poll()
+ */
+ public static boolean isKeyDown(int key) {
+ assert created : "The keyboard has not been created.";
+ return keyDownBuffer.get(key) != 0;
+ }
+
+ /**
+ * Gets the number of keyboard events waiting after doing a read().
+ * @return the number of keyboard events
+ */
+ public static int getNumKeyboardEvents() {
+ return readBuffer.limit() >> 1;
+ }
+
+ /**
+ * Gets the next keyboard event. This is stored in the publicly accessible
+ * static fields key and state.
+ * @return true if a keyboard event was read, false otherwise
+ */
+ public static boolean next() {
+ assert created : "The keyboard has not been created.";
+ assert readBuffer != null : "Keyboard buffering has not been enabled.";
+
+ if (readBuffer.hasRemaining()) {
+ key = readBuffer.get();
+ state = readBuffer.get() != 0;
+ return true;
+ } else
+ return false;
+
+ }
}
diff --git a/src/java/org/lwjgl/opengl/BaseGL.java b/src/java/org/lwjgl/opengl/BaseGL.java
index 2848df49..7ec987c9 100644
--- a/src/java/org/lwjgl/opengl/BaseGL.java
+++ b/src/java/org/lwjgl/opengl/BaseGL.java
@@ -102,7 +102,7 @@ abstract class BaseGL {
/**
* Destroy the GL context. Does nothing if the GL has not yet been created.
*/
- public void destroy() {
+ public final void destroy() {
if (!created)
return;
cleanup();
@@ -145,6 +145,11 @@ abstract class BaseGL {
nMakeCurrent();
}
+ /**
+ * Swap the buffers
+ */
+ public native void swapBuffers();
+
/**
* Native method to make this the current thread
*/
diff --git a/src/java/org/lwjgl/opengl/CoreGL11.java b/src/java/org/lwjgl/opengl/CoreGL11.java
index b5883f6c..db46d92f 100644
--- a/src/java/org/lwjgl/opengl/CoreGL11.java
+++ b/src/java/org/lwjgl/opengl/CoreGL11.java
@@ -43,7 +43,7 @@ public class CoreGL11 extends BaseGL implements CoreGL11Constants {
public native void glBegin(int mode);
public native void glEnd();
public native void glArrayElement(int i);
- public native boolean glAreTexturesResident(int n, int residences);
+ public native boolean glAreTexturesResident(int n, int textureNames, int residences);
public native void glClearDepth(double depth);
public native void glDeleteLists(int list, int range);
public native void glDeleteTextures(int n, int textures);
@@ -217,7 +217,7 @@ public class CoreGL11 extends BaseGL implements CoreGL11Constants {
public native void glEndList();
public native void glMultMatrixd(int m);
public native void glMultMatrixf(int m);
- public native void glPrioritizeTextures(int n, int priorities);
+ public native void glPrioritizeTextures(int n, int textureNames, int priorities);
public native void glShadeModel(int mode);
public native void glSelectBuffer(int size, int buffer);
public native void glScissor(int x, int y, int width, int height);
@@ -230,10 +230,10 @@ public class CoreGL11 extends BaseGL implements CoreGL11Constants {
public native void glRectf(float x1, float y1, float x2, float y2);
public native void glRecti(int x1, int y1, int x2, int y2);
public native void glRects(short x1, short y1, short x2, short y2);
- public native void glRectdv(int v2);
- public native void glRectfv(int v2);
- public native void glRectiv(int v2);
- public native void glRectsv(int v2);
+ public native void glRectdv(int v1, int v2);
+ public native void glRectfv(int v1, int v2);
+ public native void glRectiv(int v1, int v2);
+ public native void glRectsv(int v1, int v2);
public native void glReadPixels(int x, int y, int width, int height, int format, int type, int pixels);
public native void glReadBuffer(int mode);
public native void glRasterPos2d(double x, double y);
diff --git a/src/java/org/lwjgl/opengl/GLUConstants.java b/src/java/org/lwjgl/opengl/GLUConstants.java
index f7ceb041..9f8243bc 100644
--- a/src/java/org/lwjgl/opengl/GLUConstants.java
+++ b/src/java/org/lwjgl/opengl/GLUConstants.java
@@ -6,9 +6,185 @@
package org.lwjgl.opengl;
/**
+ * GLU constants.
*
* @author foo
*/
public interface GLUConstants {
-
+ /* Errors: (return value 0 = no error) */
+ public static final int GLU_INVALID_ENUM = 100900;
+ public static final int GLU_INVALID_VALUE = 100901;
+ public static final int GLU_OUT_OF_MEMORY = 100902;
+ public static final int GLU_INCOMPATIBLE_GL_VERSION = 100903;
+
+ /* StringName */
+ public static final int GLU_VERSION = 100800;
+ public static final int GLU_EXTENSIONS = 100801;
+
+ /* Boolean */
+ public static final int GLU_TRUE = CoreGL11Constants.GL_TRUE;
+ public static final int GLU_FALSE = CoreGL11Constants.GL_FALSE;
+
+
+ /**** Quadric constants ****/
+
+ /* QuadricNormal */
+ public static final int GLU_SMOOTH = 100000;
+ public static final int GLU_FLAT = 100001;
+ public static final int GLU_NONE = 100002;
+
+ /* QuadricDrawStyle */
+ public static final int GLU_POINT = 100010;
+ public static final int GLU_LINE = 100011;
+ public static final int GLU_FILL = 100012;
+ public static final int GLU_SILHOUETTE = 100013;
+
+ /* QuadricOrientation */
+ public static final int GLU_OUTSIDE = 100020;
+ public static final int GLU_INSIDE = 100021;
+
+ /* Callback types: */
+ /* GLU_ERROR = 100103 */;
+
+
+ /**** Tesselation constants ****/
+
+ public static final double GLU_TESS_MAX_COORD = 1.0e150;
+
+ /* TessProperty */
+ public static final int GLU_TESS_WINDING_RULE = 100140;
+ public static final int GLU_TESS_BOUNDARY_ONLY = 100141;
+ public static final int GLU_TESS_TOLERANCE = 100142;
+
+ /* TessWinding */
+ public static final int GLU_TESS_WINDING_ODD = 100130;
+ public static final int GLU_TESS_WINDING_NONZERO = 100131;
+ public static final int GLU_TESS_WINDING_POSITIVE = 100132;
+ public static final int GLU_TESS_WINDING_NEGATIVE = 100133;
+ public static final int GLU_TESS_WINDING_ABS_GEQ_TWO = 100134;
+
+ /* TessCallback */
+ public static final int GLU_TESS_BEGIN = 100100; /* void (CALLBACK*)(GLenum type) */
+ public static final int GLU_TESS_VERTEX = 100101; /* void (CALLBACK*)(void *data) */
+ public static final int GLU_TESS_END = 100102; /* void (CALLBACK*)(void) */
+ public static final int GLU_TESS_ERROR = 100103; /* void (CALLBACK*)(GLenum errno) */
+ public static final int GLU_TESS_EDGE_FLAG = 100104; /* void (CALLBACK*)(GLboolean boundaryEdge) */
+ public static final int GLU_TESS_COMBINE = 100105; /* void (CALLBACK*)(GLdouble coords[3],
+ void *data[4],
+ GLfloat weight[4],
+ void **dataOut) */
+ public static final int GLU_TESS_BEGIN_DATA = 100106; /* void (CALLBACK*)(GLenum type,
+ void *polygon_data) */
+ public static final int GLU_TESS_VERTEX_DATA = 100107; /* void (CALLBACK*)(void *data,
+ void *polygon_data) */
+ public static final int GLU_TESS_END_DATA = 100108; /* void (CALLBACK*)(void *polygon_data) */
+ public static final int GLU_TESS_ERROR_DATA = 100109; /* void (CALLBACK*)(GLenum errno,
+ void *polygon_data) */
+ public static final int GLU_TESS_EDGE_FLAG_DATA = 100110; /* void (CALLBACK*)(GLboolean boundaryEdge,
+ void *polygon_data) */
+ public static final int GLU_TESS_COMBINE_DATA = 100111; /* void (CALLBACK*)(GLdouble coords[3],
+ void *data[4],
+ GLfloat weight[4],
+ void **dataOut,
+ void *polygon_data) */
+
+ /* TessError */
+ public static final int GLU_TESS_ERROR1 = 100151;
+ public static final int GLU_TESS_ERROR2 = 100152;
+ public static final int GLU_TESS_ERROR3 = 100153;
+ public static final int GLU_TESS_ERROR4 = 100154;
+ public static final int GLU_TESS_ERROR5 = 100155;
+ public static final int GLU_TESS_ERROR6 = 100156;
+ public static final int GLU_TESS_ERROR7 = 100157;
+ public static final int GLU_TESS_ERROR8 = 100158;
+
+ public static final int GLU_TESS_MISSING_BEGIN_POLYGON = GLU_TESS_ERROR1;
+ public static final int GLU_TESS_MISSING_BEGIN_CONTOUR = GLU_TESS_ERROR2;
+ public static final int GLU_TESS_MISSING_END_POLYGON = GLU_TESS_ERROR3;
+ public static final int GLU_TESS_MISSING_END_CONTOUR = GLU_TESS_ERROR4;
+ public static final int GLU_TESS_COORD_TOO_LARGE = GLU_TESS_ERROR5;
+ public static final int GLU_TESS_NEED_COMBINE_CALLBACK = GLU_TESS_ERROR6;
+
+ /**** NURBS constants ****/
+
+ /* NurbsProperty */
+ public static final int GLU_AUTO_LOAD_MATRIX = 100200;
+ public static final int GLU_CULLING = 100201;
+ public static final int GLU_SAMPLING_TOLERANCE = 100203;
+ public static final int GLU_DISPLAY_MODE = 100204;
+ public static final int GLU_PARAMETRIC_TOLERANCE = 100202;
+ public static final int GLU_SAMPLING_METHOD = 100205;
+ public static final int GLU_U_STEP = 100206;
+ public static final int GLU_V_STEP = 100207;
+
+ /* NurbsSampling */
+ public static final int GLU_PATH_LENGTH = 100215;
+ public static final int GLU_PARAMETRIC_ERROR = 100216;
+ public static final int GLU_DOMAIN_DISTANCE = 100217;
+
+
+ /* NurbsTrim */
+ public static final int GLU_MAP1_TRIM_2 = 100210;
+ public static final int GLU_MAP1_TRIM_3 = 100211;
+
+ /* NurbsDisplay */
+ /* GLU_FILL = 100012 */;
+ public static final int GLU_OUTLINE_POLYGON = 100240;
+ public static final int GLU_OUTLINE_PATCH = 100241;
+
+ /* NurbsCallback */
+ /* GLU_ERROR = 100103 */;
+
+ /* NurbsErrors */
+ public static final int GLU_NURBS_ERROR1 = 100251;
+ public static final int GLU_NURBS_ERROR2 = 100252;
+ public static final int GLU_NURBS_ERROR3 = 100253;
+ public static final int GLU_NURBS_ERROR4 = 100254;
+ public static final int GLU_NURBS_ERROR5 = 100255;
+ public static final int GLU_NURBS_ERROR6 = 100256;
+ public static final int GLU_NURBS_ERROR7 = 100257;
+ public static final int GLU_NURBS_ERROR8 = 100258;
+ public static final int GLU_NURBS_ERROR9 = 100259;
+ public static final int GLU_NURBS_ERROR10 = 100260;
+ public static final int GLU_NURBS_ERROR11 = 100261;
+ public static final int GLU_NURBS_ERROR12 = 100262;
+ public static final int GLU_NURBS_ERROR13 = 100263;
+ public static final int GLU_NURBS_ERROR14 = 100264;
+ public static final int GLU_NURBS_ERROR15 = 100265;
+ public static final int GLU_NURBS_ERROR16 = 100266;
+ public static final int GLU_NURBS_ERROR17 = 100267;
+ public static final int GLU_NURBS_ERROR18 = 100268;
+ public static final int GLU_NURBS_ERROR19 = 100269;
+ public static final int GLU_NURBS_ERROR20 = 100270;
+ public static final int GLU_NURBS_ERROR21 = 100271;
+ public static final int GLU_NURBS_ERROR22 = 100272;
+ public static final int GLU_NURBS_ERROR23 = 100273;
+ public static final int GLU_NURBS_ERROR24 = 100274;
+ public static final int GLU_NURBS_ERROR25 = 100275;
+ public static final int GLU_NURBS_ERROR26 = 100276;
+ public static final int GLU_NURBS_ERROR27 = 100277;
+ public static final int GLU_NURBS_ERROR28 = 100278;
+ public static final int GLU_NURBS_ERROR29 = 100279;
+ public static final int GLU_NURBS_ERROR30 = 100280;
+ public static final int GLU_NURBS_ERROR31 = 100281;
+ public static final int GLU_NURBS_ERROR32 = 100282;
+ public static final int GLU_NURBS_ERROR33 = 100283;
+ public static final int GLU_NURBS_ERROR34 = 100284;
+ public static final int GLU_NURBS_ERROR35 = 100285;
+ public static final int GLU_NURBS_ERROR36 = 100286;
+ public static final int GLU_NURBS_ERROR37 = 100287;
+
+ /* Contours types -- obsolete! */
+ public static final int GLU_CW = 100120;
+ public static final int GLU_CCW = 100121;
+ public static final int GLU_INTERIOR = 100122;
+ public static final int GLU_EXTERIOR = 100123;
+ public static final int GLU_UNKNOWN = 100124;
+
+ /* Names without "TESS_" prefix */
+ public static final int GLU_BEGIN = GLU_TESS_BEGIN;
+ public static final int GLU_VERTEX = GLU_TESS_VERTEX;
+ public static final int GLU_END = GLU_TESS_END;
+ public static final int GLU_ERROR = GLU_TESS_ERROR;
+ public static final int GLU_EDGE_FLAG = GLU_TESS_EDGE_FLAG;
}