Replaced asserts with proper runtime exceptions
This commit is contained in:
parent
afb8491cfa
commit
c093f3ace1
|
@ -196,8 +196,10 @@ public final class Display {
|
||||||
* @param contrast The contrast, larger than 0.0.
|
* @param contrast The contrast, larger than 0.0.
|
||||||
*/
|
*/
|
||||||
public static void setDisplayConfiguration(float gamma, float brightness, float contrast) throws Exception {
|
public static void setDisplayConfiguration(float gamma, float brightness, float contrast) throws Exception {
|
||||||
assert brightness >= -1.0f && brightness <= 1.0f;
|
if (brightness < -1.0f || brightness > 1.0f)
|
||||||
assert contrast >= 0.0f;
|
throw new IllegalArgumentException("Invalid brightness value");
|
||||||
|
if (contrast < 0.0f)
|
||||||
|
throw new IllegalArgumentException("Invalid contrast value");
|
||||||
int rampSize = getGammaRampLength();
|
int rampSize = getGammaRampLength();
|
||||||
if (rampSize == 0) {
|
if (rampSize == 0) {
|
||||||
throw new Exception("Display configuration not supported");
|
throw new Exception("Display configuration not supported");
|
||||||
|
|
|
@ -164,9 +164,8 @@ public class Controller {
|
||||||
* @throws Exception if the controller could not be created for any reason
|
* @throws Exception if the controller could not be created for any reason
|
||||||
*/
|
*/
|
||||||
public static void create() throws Exception {
|
public static void create() throws Exception {
|
||||||
|
if (!Window.isCreated())
|
||||||
assert Window.isCreated() : "Window must be created prior to creating controller";
|
throw new IllegalStateException("Window must be created before you can create Controller");
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
@ -203,7 +202,8 @@ public class Controller {
|
||||||
* Polls the controller.
|
* Polls the controller.
|
||||||
*/
|
*/
|
||||||
public static void poll() {
|
public static void poll() {
|
||||||
assert created : "The controller has not been created.";
|
if (!created)
|
||||||
|
throw new IllegalStateException("Controller must be created before you can poll the device");
|
||||||
nPoll();
|
nPoll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,8 @@ public class Controller {
|
||||||
* @see #buttonCount
|
* @see #buttonCount
|
||||||
*/
|
*/
|
||||||
public static boolean isButtonDown(int button) {
|
public static boolean isButtonDown(int button) {
|
||||||
assert created : "The controller has not been created.";
|
if (!created)
|
||||||
|
throw new IllegalStateException("Controller must be created before you can query button state");
|
||||||
return buttons[button];
|
return buttons[button];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +232,7 @@ public class Controller {
|
||||||
* it always throws a RuntimeException.
|
* it always throws a RuntimeException.
|
||||||
*/
|
*/
|
||||||
public static void read() {
|
public static void read() {
|
||||||
throw new RuntimeException("Buffering is not implemented for Controllers.");
|
throw new UnsupportedOperationException("Buffering is not implemented for Controllers.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -75,11 +75,16 @@ public class Cursor {
|
||||||
* @throws Exception if the cursor could not be created for any reason
|
* @throws Exception if the cursor could not be created for any reason
|
||||||
*/
|
*/
|
||||||
public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws Exception {
|
public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws Exception {
|
||||||
assert Mouse.isCreated();
|
if (!Mouse.isCreated())
|
||||||
assert width*height*numImages <= images.remaining() : "width*height*numImages > images.remaining()";
|
throw new IllegalStateException("Mouse must be created before creating cursor objects");
|
||||||
assert delays == null || numImages <= delays.remaining() : "delays != null && numImages > delays.remaining()";
|
if (width*height*numImages > images.remaining())
|
||||||
assert xHotspot < width && xHotspot >= 0 : "xHotspot > width || xHotspot < 0";
|
throw new IllegalArgumentException("width*height*numImages > images.remaining()");
|
||||||
assert yHotspot < height && yHotspot >= 0 : "yHotspot > height || yHotspot < 0";
|
if (delays != null && numImages > delays.remaining())
|
||||||
|
throw new IllegalArgumentException("delays != null && numImages > delays.remaining()");
|
||||||
|
if (xHotspot >= width || xHotspot < 0)
|
||||||
|
throw new IllegalArgumentException("xHotspot > width || xHotspot < 0");
|
||||||
|
if (yHotspot >= height || yHotspot < 0)
|
||||||
|
throw new IllegalArgumentException("yHotspot > height || yHotspot < 0");
|
||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
|
|
|
@ -285,7 +285,8 @@ public class Keyboard {
|
||||||
* @throws Exception if the keyboard could not be created for any reason
|
* @throws Exception if the keyboard could not be created for any reason
|
||||||
*/
|
*/
|
||||||
public static void create() throws Exception {
|
public static void create() throws Exception {
|
||||||
assert Window.isCreated() : "Window must be created prior to creating keyboard";
|
if (!Window.isCreated())
|
||||||
|
throw new IllegalStateException("Window must be created before you can create Keyboard");
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
initialize();
|
initialize();
|
||||||
if (created)
|
if (created)
|
||||||
|
@ -334,7 +335,8 @@ public class Keyboard {
|
||||||
* @see org.lwjgl.input.Keyboard#read()
|
* @see org.lwjgl.input.Keyboard#read()
|
||||||
*/
|
*/
|
||||||
public static void poll() {
|
public static void poll() {
|
||||||
assert created : "The keyboard has not been created.";
|
if (!created)
|
||||||
|
throw new IllegalStateException("Keyboard must be created before you can poll the device");
|
||||||
nPoll(keyDownBuffer);
|
nPoll(keyDownBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,8 +363,10 @@ public class Keyboard {
|
||||||
* @see org.lwjgl.input.Keyboard#getEventCharacter()
|
* @see org.lwjgl.input.Keyboard#getEventCharacter()
|
||||||
*/
|
*/
|
||||||
public static void read() {
|
public static void read() {
|
||||||
assert created : "The keyboard has not been created.";
|
if (!created)
|
||||||
assert readBuffer != null : "Keyboard buffering has not been enabled.";
|
throw new IllegalStateException("Keyboard must be created before you can read events");
|
||||||
|
if (readBuffer == null)
|
||||||
|
throw new IllegalStateException("Event buffering must be enabled before you can read events");
|
||||||
readBuffer.compact();
|
readBuffer.compact();
|
||||||
int numEvents = nRead(readBuffer, readBuffer.position());
|
int numEvents = nRead(readBuffer, readBuffer.position());
|
||||||
if (translationEnabled)
|
if (translationEnabled)
|
||||||
|
@ -383,8 +387,10 @@ public class Keyboard {
|
||||||
* and keyboard buffering must be enabled.
|
* and keyboard buffering must be enabled.
|
||||||
*/
|
*/
|
||||||
public static void enableTranslation() throws Exception {
|
public static void enableTranslation() throws Exception {
|
||||||
assert created : "The keyboard has not been created.";
|
if (!created)
|
||||||
assert readBuffer != null : "Keyboard buffering has not been enabled.";
|
throw new IllegalStateException("Keyboard must be created before you can read events");
|
||||||
|
if (readBuffer == null)
|
||||||
|
throw new IllegalStateException("Event buffering must be enabled before you can read events");
|
||||||
nEnableTranslation();
|
nEnableTranslation();
|
||||||
translationEnabled = true;
|
translationEnabled = true;
|
||||||
}
|
}
|
||||||
|
@ -398,7 +404,8 @@ public class Keyboard {
|
||||||
* Enable keyboard buffering. Must be called after the keyboard is created.
|
* Enable keyboard buffering. Must be called after the keyboard is created.
|
||||||
*/
|
*/
|
||||||
public static void enableBuffer() throws Exception {
|
public static void enableBuffer() throws Exception {
|
||||||
assert created : "The keyboard has not been created.";
|
if (!created)
|
||||||
|
throw new IllegalStateException("Keyboard must be created before you can enable buffering");
|
||||||
readBuffer = BufferUtils.createByteBuffer(4*BUFFER_SIZE);
|
readBuffer = BufferUtils.createByteBuffer(4*BUFFER_SIZE);
|
||||||
readBuffer.limit(0);
|
readBuffer.limit(0);
|
||||||
nEnableBuffer();
|
nEnableBuffer();
|
||||||
|
@ -417,7 +424,8 @@ public class Keyboard {
|
||||||
* @return true if the key is down according to the last poll()
|
* @return true if the key is down according to the last poll()
|
||||||
*/
|
*/
|
||||||
public static boolean isKeyDown(int key) {
|
public static boolean isKeyDown(int key) {
|
||||||
assert created : "The keyboard has not been created.";
|
if (!created)
|
||||||
|
throw new IllegalStateException("Keyboard must be created before you can query key state");
|
||||||
return keyDownBuffer.get(key) != 0;
|
return keyDownBuffer.get(key) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +450,8 @@ public class Keyboard {
|
||||||
* @return STATE_ON if on, STATE_OFF if off and STATE_UNKNOWN if the state is unknown
|
* @return STATE_ON if on, STATE_OFF if off and STATE_UNKNOWN if the state is unknown
|
||||||
*/
|
*/
|
||||||
public static int isStateKeySet(int key) {
|
public static int isStateKeySet(int key) {
|
||||||
assert created : "The keyboard has not been created.";
|
if (!created)
|
||||||
|
throw new IllegalStateException("Keyboard must be created before you can query key state");
|
||||||
return nisStateKeySet(key);
|
return nisStateKeySet(key);
|
||||||
}
|
}
|
||||||
private static native int nisStateKeySet(int key);
|
private static native int nisStateKeySet(int key);
|
||||||
|
@ -473,7 +482,8 @@ public class Keyboard {
|
||||||
* @return the number of keyboard events
|
* @return the number of keyboard events
|
||||||
*/
|
*/
|
||||||
public static int getNumKeyboardEvents() {
|
public static int getNumKeyboardEvents() {
|
||||||
assert created : "The keyboard has not been created.";
|
if (!created)
|
||||||
|
throw new IllegalStateException("Keyboard must be created before you can read events");
|
||||||
if (translationEnabled)
|
if (translationEnabled)
|
||||||
return readBuffer.remaining()/4;
|
return readBuffer.remaining()/4;
|
||||||
else
|
else
|
||||||
|
@ -492,8 +502,10 @@ public class Keyboard {
|
||||||
* @return true if a keyboard event was read, false otherwise
|
* @return true if a keyboard event was read, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean next() {
|
public static boolean next() {
|
||||||
assert created : "The keyboard has not been created.";
|
if (!created)
|
||||||
assert readBuffer != null : "Keyboard buffering has not been enabled.";
|
throw new IllegalStateException("Keyboard must be created before you can read events");
|
||||||
|
if (readBuffer == null)
|
||||||
|
throw new IllegalStateException("Event buffering must be enabled before you can read events");
|
||||||
|
|
||||||
if (readBuffer.hasRemaining()) {
|
if (readBuffer.hasRemaining()) {
|
||||||
eventKey = readBuffer.get() & 0xFF;
|
eventKey = readBuffer.get() & 0xFF;
|
||||||
|
|
|
@ -167,7 +167,10 @@ public class Mouse {
|
||||||
* @throws Exception if the cursor could not be set for any reason
|
* @throws Exception if the cursor could not be set for any reason
|
||||||
*/
|
*/
|
||||||
public static Cursor setNativeCursor(Cursor cursor) throws Exception {
|
public static Cursor setNativeCursor(Cursor cursor) throws Exception {
|
||||||
assert created && ((getNativeCursorCaps() | CURSOR_ONE_BIT_TRANSPARENCY) != 0);
|
if (!created)
|
||||||
|
throw new IllegalStateException("Create the Mouse before setting the native cursor");
|
||||||
|
if ((getNativeCursorCaps() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
|
||||||
|
throw new IllegalStateException("Mouse doesn't support native cursors");
|
||||||
Cursor oldCursor = currentCursor;
|
Cursor oldCursor = currentCursor;
|
||||||
currentCursor = cursor;
|
currentCursor = cursor;
|
||||||
if (currentCursor != null) {
|
if (currentCursor != null) {
|
||||||
|
@ -239,7 +242,8 @@ public class Mouse {
|
||||||
*/
|
*/
|
||||||
public static void create() throws Exception {
|
public static void create() throws Exception {
|
||||||
|
|
||||||
assert Window.isCreated() : "Window must be created prior to creating mouse";
|
if (!Window.isCreated())
|
||||||
|
throw new IllegalStateException("Window must be created prior to creating mouse");
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
initialize();
|
initialize();
|
||||||
|
@ -327,7 +331,8 @@ public class Mouse {
|
||||||
* @see org.lwjgl.input.Mouse#read()
|
* @see org.lwjgl.input.Mouse#read()
|
||||||
*/
|
*/
|
||||||
public static void poll() {
|
public static void poll() {
|
||||||
assert created : "The mouse has not been created.";
|
if (!created)
|
||||||
|
throw new IllegalStateException("Mouse must be created before you can poll it");
|
||||||
nPoll();
|
nPoll();
|
||||||
|
|
||||||
// set absolute position
|
// set absolute position
|
||||||
|
@ -363,7 +368,8 @@ public class Mouse {
|
||||||
* @return true if the specified button is down
|
* @return true if the specified button is down
|
||||||
*/
|
*/
|
||||||
public static boolean isButtonDown(int button) {
|
public static boolean isButtonDown(int button) {
|
||||||
assert created : "The mouse has not been created.";
|
if (!created)
|
||||||
|
throw new IllegalStateException("Mouse must be created before you can poll the button state");
|
||||||
if (button >= buttonCount || button < 0)
|
if (button >= buttonCount || button < 0)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
|
@ -398,7 +404,8 @@ public class Mouse {
|
||||||
* Enable mouse button buffering. Must be called after the mouse is created.
|
* Enable mouse button buffering. Must be called after the mouse is created.
|
||||||
*/
|
*/
|
||||||
public static void enableBuffer() throws Exception {
|
public static void enableBuffer() throws Exception {
|
||||||
assert created : "The mouse has not been created.";
|
if (!created)
|
||||||
|
throw new IllegalStateException("Mouse must be created before you can enable buffering");
|
||||||
readBuffer = BufferUtils.createByteBuffer(2*BUFFER_SIZE);
|
readBuffer = BufferUtils.createByteBuffer(2*BUFFER_SIZE);
|
||||||
readBuffer.limit(0);
|
readBuffer.limit(0);
|
||||||
nEnableBuffer();
|
nEnableBuffer();
|
||||||
|
@ -424,8 +431,10 @@ public class Mouse {
|
||||||
* @see org.lwjgl.input.Mouse#getEventButtonState()
|
* @see org.lwjgl.input.Mouse#getEventButtonState()
|
||||||
*/
|
*/
|
||||||
public static void read() {
|
public static void read() {
|
||||||
assert created : "The mouse has not been created.";
|
if (!created)
|
||||||
assert readBuffer != null : "Mouse buffering has not been enabled.";
|
throw new IllegalStateException("Mouse must be created before you can read events");
|
||||||
|
if (readBuffer == null)
|
||||||
|
throw new IllegalStateException("Event buffering must be enabled before you can read events");
|
||||||
readBuffer.compact();
|
readBuffer.compact();
|
||||||
int numEvents = nRead(readBuffer, readBuffer.position());
|
int numEvents = nRead(readBuffer, readBuffer.position());
|
||||||
readBuffer.position(readBuffer.position() + numEvents*2);
|
readBuffer.position(readBuffer.position() + numEvents*2);
|
||||||
|
@ -447,8 +456,10 @@ public class Mouse {
|
||||||
* @return true if a mouse event was read, false otherwise
|
* @return true if a mouse event was read, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean next() {
|
public static boolean next() {
|
||||||
assert created : "The mouse has not been created.";
|
if (!created)
|
||||||
assert readBuffer != null : "Mouse buffering has not been enabled.";
|
throw new IllegalStateException("Mouse must be created before you can read events");
|
||||||
|
if (readBuffer == null)
|
||||||
|
throw new IllegalStateException("Event buffering must be enabled before you can read events");
|
||||||
|
|
||||||
if (readBuffer.hasRemaining()) {
|
if (readBuffer.hasRemaining()) {
|
||||||
eventButton = readBuffer.get() & 0xFF;
|
eventButton = readBuffer.get() & 0xFF;
|
||||||
|
|
|
@ -458,7 +458,8 @@ public final class AL10 {
|
||||||
* @param data Buffer to place the integers in
|
* @param data Buffer to place the integers in
|
||||||
*/
|
*/
|
||||||
public static void alGetInteger(int pname, IntBuffer data) {
|
public static void alGetInteger(int pname, IntBuffer data) {
|
||||||
assert data.remaining() > 0;
|
if (data.remaining() <= 0)
|
||||||
|
throw new IllegalArgumentException("data.remaining() <= 0");
|
||||||
nalGetIntegerv(pname, data, data.position());
|
nalGetIntegerv(pname, data, data.position());
|
||||||
}
|
}
|
||||||
private static native void nalGetIntegerv(int pname, IntBuffer data, int offset);
|
private static native void nalGetIntegerv(int pname, IntBuffer data, int offset);
|
||||||
|
@ -478,7 +479,8 @@ public final class AL10 {
|
||||||
* @param data Buffer to place the floats in
|
* @param data Buffer to place the floats in
|
||||||
*/
|
*/
|
||||||
public static void alGetFloat(int pname, FloatBuffer data) {
|
public static void alGetFloat(int pname, FloatBuffer data) {
|
||||||
assert data.remaining() > 0;
|
if (data.remaining() <= 0)
|
||||||
|
throw new IllegalArgumentException("data.remaining() <= 0");
|
||||||
nalGetFloatv(pname, data, data.position());
|
nalGetFloatv(pname, data, data.position());
|
||||||
}
|
}
|
||||||
private static native void nalGetFloatv(int pname, FloatBuffer data, int position);
|
private static native void nalGetFloatv(int pname, FloatBuffer data, int position);
|
||||||
|
@ -786,7 +788,8 @@ public final class AL10 {
|
||||||
* @param floatdata Buffer to write floats to
|
* @param floatdata Buffer to write floats to
|
||||||
*/
|
*/
|
||||||
public static void alGetSource(int source, int pname, FloatBuffer floatdata) {
|
public static void alGetSource(int source, int pname, FloatBuffer floatdata) {
|
||||||
assert floatdata.remaining() > 0;
|
if (floatdata.remaining() <= 0)
|
||||||
|
throw new IllegalArgumentException("floatdata.remaining() <= 0");
|
||||||
nalGetSourcefv(source, pname, floatdata, floatdata.position());
|
nalGetSourcefv(source, pname, floatdata, floatdata.position());
|
||||||
}
|
}
|
||||||
private static native void nalGetSourcefv(int source, int pname, FloatBuffer floatdata, int position);
|
private static native void nalGetSourcefv(int source, int pname, FloatBuffer floatdata, int position);
|
||||||
|
|
|
@ -89,7 +89,7 @@ public final class ARBVertexBufferObject {
|
||||||
case GL_ARRAY_BUFFER_ARB:
|
case GL_ARRAY_BUFFER_ARB:
|
||||||
VBOTracker.getVBOArrayStack().setState(buffer);
|
VBOTracker.getVBOArrayStack().setState(buffer);
|
||||||
break;
|
break;
|
||||||
default: assert false: "Unsupported VBO target " + target;
|
default: throw new IllegalArgumentException("Unsupported VBO target " + target);
|
||||||
}
|
}
|
||||||
nglBindBufferARB(target, buffer);
|
nglBindBufferARB(target, buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public final class ARBVertexShader {
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
public static void glBindAttribLocationARB(int programObj, int index, ByteBuffer name) {
|
public static void glBindAttribLocationARB(int programObj, int index, ByteBuffer name) {
|
||||||
if ( name.get(name.limit() - 1) != 0 ) {
|
if ( name.get(name.limit() - 1) != 0 ) {
|
||||||
throw new RuntimeException("<name> must be a null-terminated string.");
|
throw new IllegalArgumentException("<name> must be a null-terminated string.");
|
||||||
}
|
}
|
||||||
nglBindAttribLocationARB(programObj, index, name, name.position());
|
nglBindAttribLocationARB(programObj, index, name, name.position());
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public final class ARBVertexShader {
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
public static int glGetAttribLocationARB(int programObj, ByteBuffer name) {
|
public static int glGetAttribLocationARB(int programObj, ByteBuffer name) {
|
||||||
if ( name.get(name.limit() - 1) != 0 ) {
|
if ( name.get(name.limit() - 1) != 0 ) {
|
||||||
throw new RuntimeException("<name> must be a null-terminated string.");
|
throw new IllegalArgumentException("<name> must be a null-terminated string.");
|
||||||
}
|
}
|
||||||
return nglGetAttribLocationARB(programObj, name, name.position());
|
return nglGetAttribLocationARB(programObj, name, name.position());
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public final class ATIDrawBuffers {
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
public static void glDrawBuffersATI(IntBuffer buffers) {
|
public static void glDrawBuffersATI(IntBuffer buffers) {
|
||||||
if (buffers.remaining() == 0) {
|
if (buffers.remaining() == 0) {
|
||||||
throw new RuntimeException("<buffers> must have at least 1 integer available.");
|
throw new IllegalArgumentException("<buffers> must have at least 1 integer available.");
|
||||||
}
|
}
|
||||||
nglDrawBuffersATI(buffers.remaining(), buffers, buffers.position());
|
nglDrawBuffersATI(buffers.remaining(), buffers, buffers.position());
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public final class GL15 {
|
||||||
VBOTracker.getVBOArrayStack().setState(buffer);
|
VBOTracker.getVBOArrayStack().setState(buffer);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert false: "Unsupported VBO target " + target;
|
throw new IllegalArgumentException("Unsupported VBO target " + target);
|
||||||
}
|
}
|
||||||
nglBindBuffer(target, buffer);
|
nglBindBuffer(target, buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,8 @@ public final class Window {
|
||||||
* @return the width of the window
|
* @return the width of the window
|
||||||
*/
|
*/
|
||||||
public static int getWidth() {
|
public static int getWidth() {
|
||||||
assert isCreated() : "Cannot get width on uncreated window";
|
if (!isCreated())
|
||||||
|
throw new IllegalStateException("Cannot get width on uncreated window");
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +117,8 @@ public final class Window {
|
||||||
* @return the height of the window
|
* @return the height of the window
|
||||||
*/
|
*/
|
||||||
public static int getHeight() {
|
public static int getHeight() {
|
||||||
assert isCreated() : "Cannot get height on uncreated window";
|
if (!isCreated())
|
||||||
|
throw new IllegalStateException("Cannot get height on uncreated window");
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +126,8 @@ public final class Window {
|
||||||
* @return the title of the window
|
* @return the title of the window
|
||||||
*/
|
*/
|
||||||
public static String getTitle() {
|
public static String getTitle() {
|
||||||
assert isCreated() : "Cannot get title on uncreated window";
|
if (!isCreated())
|
||||||
|
throw new IllegalStateException("Cannot get title on uncreated window");
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +135,8 @@ public final class Window {
|
||||||
* @return whether this window is in fullscreen mode
|
* @return whether this window is in fullscreen mode
|
||||||
*/
|
*/
|
||||||
public static boolean isFullscreen() {
|
public static boolean isFullscreen() {
|
||||||
assert isCreated() : "Cannot determine state of uncreated window";
|
if (!isCreated())
|
||||||
|
throw new IllegalStateException("Cannot determine fullscreen state of uncreated window");
|
||||||
return fullscreen;
|
return fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +145,8 @@ public final class Window {
|
||||||
* @param newTitle The new window title
|
* @param newTitle The new window title
|
||||||
*/
|
*/
|
||||||
public static void setTitle(String newTitle) {
|
public static void setTitle(String newTitle) {
|
||||||
assert isCreated() : "Cannot set title of uncreated window";
|
if (!isCreated())
|
||||||
|
throw new IllegalStateException("Cannot set title on uncreated window");
|
||||||
title = newTitle;
|
title = newTitle;
|
||||||
nSetTitle(title);
|
nSetTitle(title);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +161,8 @@ public final class Window {
|
||||||
* @return true if the user or operating system has asked the window to close
|
* @return true if the user or operating system has asked the window to close
|
||||||
*/
|
*/
|
||||||
public static boolean isCloseRequested() {
|
public static boolean isCloseRequested() {
|
||||||
assert isCreated() : "Cannot determine state of uncreated window";
|
if (!isCreated())
|
||||||
|
throw new IllegalStateException("Cannot determine close requested state of uncreated window");
|
||||||
return nIsCloseRequested();
|
return nIsCloseRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +172,8 @@ public final class Window {
|
||||||
* @return true if the window is minimized or otherwise not visible
|
* @return true if the window is minimized or otherwise not visible
|
||||||
*/
|
*/
|
||||||
public static boolean isMinimized() {
|
public static boolean isMinimized() {
|
||||||
assert isCreated() : "Cannot determine state of uncreated window";
|
if (!isCreated())
|
||||||
|
throw new IllegalStateException("Cannot determine minimized state of uncreated window");
|
||||||
return nIsMinimized();
|
return nIsMinimized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +183,8 @@ public final class Window {
|
||||||
* @return true if window is focused
|
* @return true if window is focused
|
||||||
*/
|
*/
|
||||||
public static boolean isFocused() {
|
public static boolean isFocused() {
|
||||||
assert isCreated() : "Cannot determine state of uncreated window";
|
if (!isCreated())
|
||||||
|
throw new IllegalStateException("Cannot determine focused state of uncreated window");
|
||||||
return nIsFocused();
|
return nIsFocused();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +218,8 @@ public final class Window {
|
||||||
* and needs to repaint itself
|
* and needs to repaint itself
|
||||||
*/
|
*/
|
||||||
public static boolean isDirty() {
|
public static boolean isDirty() {
|
||||||
assert isCreated() : "Cannot determine state of uncreated window";
|
if (!isCreated())
|
||||||
|
throw new IllegalStateException("Cannot determine dirty state of uncreated window");
|
||||||
return nIsDirty();
|
return nIsDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +231,8 @@ public final class Window {
|
||||||
* @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError()
|
* @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError()
|
||||||
*/
|
*/
|
||||||
public static void update() {
|
public static void update() {
|
||||||
assert isCreated() : "Cannot paint uncreated window";
|
if (!isCreated())
|
||||||
|
throw new IllegalStateException("Cannot determine update uncreated window");
|
||||||
nUpdate();
|
nUpdate();
|
||||||
if ((isDirty() && !isMinimized()) || (isFocused() && !isMinimized())) {
|
if ((isDirty() && !isMinimized()) || (isFocused() && !isMinimized())) {
|
||||||
Util.checkGLError();
|
Util.checkGLError();
|
||||||
|
@ -259,7 +269,8 @@ public final class Window {
|
||||||
* Make the Window the current rendering context for GL calls.
|
* Make the Window the current rendering context for GL calls.
|
||||||
*/
|
*/
|
||||||
public static synchronized void makeCurrent() {
|
public static synchronized void makeCurrent() {
|
||||||
assert isCreated() : "No window has been created.";
|
if (!isCreated())
|
||||||
|
throw new IllegalStateException("No window created to make current");
|
||||||
nMakeCurrent();
|
nMakeCurrent();
|
||||||
GLContext.useContext(context);
|
GLContext.useContext(context);
|
||||||
}
|
}
|
||||||
|
@ -315,7 +326,7 @@ public final class Window {
|
||||||
*/
|
*/
|
||||||
public static void create(String title, int bpp, int alpha, int depth, int stencil, int samples) throws Exception {
|
public static void create(String title, int bpp, int alpha, int depth, int stencil, int samples) throws Exception {
|
||||||
if (isCreated())
|
if (isCreated())
|
||||||
throw new Exception("Only one LWJGL window may be instantiated at any one time.");
|
throw new IllegalStateException("Only one LWJGL window may be instantiated at any one time.");
|
||||||
Window.fullscreen = true;
|
Window.fullscreen = true;
|
||||||
Window.x = 0;
|
Window.x = 0;
|
||||||
Window.y = 0;
|
Window.y = 0;
|
||||||
|
@ -371,7 +382,7 @@ public final class Window {
|
||||||
public static void create(String title, int x, int y, int width, int height, int bpp, int alpha, int depth, int stencil, int samples)
|
public static void create(String title, int x, int y, int width, int height, int bpp, int alpha, int depth, int stencil, int samples)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
if (isCreated())
|
if (isCreated())
|
||||||
throw new Exception("Only one LWJGL window may be instantiated at any one time.");
|
throw new IllegalStateException("Only one LWJGL window may be instantiated at any one time.");
|
||||||
Window.fullscreen = false;
|
Window.fullscreen = false;
|
||||||
Window.x = x;
|
Window.x = x;
|
||||||
Window.y = y;
|
Window.y = y;
|
||||||
|
@ -518,7 +529,8 @@ public final class Window {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean isVSyncEnabled() {
|
public static boolean isVSyncEnabled() {
|
||||||
assert isCreated() : "Cannot determine sync of uncreated window";
|
if (isCreated())
|
||||||
|
throw new IllegalStateException("Cannot determine vsync state of uncreated window");
|
||||||
return nIsVSyncEnabled();
|
return nIsVSyncEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,11 +543,10 @@ public final class Window {
|
||||||
* @param sync true to synchronize; false to ignore synchronization
|
* @param sync true to synchronize; false to ignore synchronization
|
||||||
*/
|
*/
|
||||||
public static void setVSyncEnabled(boolean sync) {
|
public static void setVSyncEnabled(boolean sync) {
|
||||||
assert isCreated() : "Cannot set sync of uncreated window";
|
if (isCreated())
|
||||||
|
throw new IllegalStateException("Cannot set vsync state of uncreated window");
|
||||||
nSetVSyncEnabled(sync);
|
nSetVSyncEnabled(sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void nSetVSyncEnabled(boolean sync);
|
private static native void nSetVSyncEnabled(boolean sync);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue