fixed tests according to new way

cleaned up imports
This commit is contained in:
Brian Matzon 2004-03-26 21:57:57 +00:00
parent 8a2d246060
commit afb8491cfa
13 changed files with 23 additions and 215 deletions

View File

@ -35,12 +35,11 @@ package org.lwjgl.input;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.HashMap;
import java.util.Map;
import org.lwjgl.Sys;
import org.lwjgl.BufferUtils;
import org.lwjgl.Sys;
import org.lwjgl.opengl.Window;
/**

View File

@ -33,12 +33,11 @@
package org.lwjgl.input;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.HashMap;
import java.util.Map;
import org.lwjgl.Sys;
import org.lwjgl.BufferUtils;
import org.lwjgl.Sys;
import org.lwjgl.opengl.Window;
/**

View File

@ -33,6 +33,7 @@ package org.lwjgl.test;
import org.lwjgl.Display;
import org.lwjgl.DisplayMode;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Window;
/**
@ -73,6 +74,10 @@ public class WindowCreationTest {
} catch (Exception e) {
e.printStackTrace();
}
if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
break;
}
}
// nuke window and get out

View File

@ -37,7 +37,6 @@ import org.lwjgl.Sys;
import org.lwjgl.input.Controller;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.Window;
import org.lwjgl.opengl.glu.GLU;
import org.lwjgl.vector.Vector2f;
/**
@ -89,7 +88,6 @@ public class ControllerCreationTest {
private void initializeOpenGL() {
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GLU.gluOrtho2D(0.0f, 640f, 0f, 480f);
}
public void executeTest() {
@ -101,9 +99,7 @@ public class ControllerCreationTest {
System.out.println("=========== WINDOWED MODE ==============");
for(int i=0; i<2; i++) {
System.out.println("Test " + (i+1) + ":");
createController();
wiggleController();
destroyController();
System.out.println("");
}
@ -127,31 +123,17 @@ public class ControllerCreationTest {
System.out.println("=========== FULLSCREEN MODE ==============");
for(int i=0; i<2; i++) {
System.out.println("Test " + (i+3) + ":");
createController();
wiggleController();
destroyController();
System.out.println("");
}
System.out.println("Test completed successfully!");
System.out.print("Shutting down...");
Display.resetDisplayMode();
Controller.destroy();
Window.destroy();
System.out.println("shutdown complete");
}
private void createController() {
System.out.print("Creating controller...");
try {
Controller.create();
} catch (Exception e) {
System.out.println("failed");
System.exit(-1);
}
System.out.println("success");
}
private void wiggleController() {
System.out.print("Please move the controller around");
@ -161,8 +143,6 @@ public class ControllerCreationTest {
while (Sys.getTime() < endtime) {
Window.update();
Controller.poll();
//controller is a bit fuzzy
if(Controller.getX() > 100) {
@ -186,12 +166,6 @@ public class ControllerCreationTest {
System.out.println("thank you");
}
private void destroyController() {
System.out.print("Destroying controller...");
Controller.destroy();
System.out.print("success");
}
private void render() {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

View File

@ -35,7 +35,6 @@ import org.lwjgl.input.Controller;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.Window;
import org.lwjgl.opengl.glu.GLU;
import org.lwjgl.vector.Vector2f;
import org.lwjgl.vector.Vector3f;
@ -106,9 +105,6 @@ public class ControllerTest {
private void initialize() {
// create display and opengl
setupDisplay();
createController();
createKeyboard();
}
/**
@ -136,7 +132,6 @@ public class ControllerTest {
*/
private void initializeOpenGL() {
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GLU.gluOrtho2D(0.0f, WINDOW_WIDTH, 0, WINDOW_HEIGHT);
}
/**
@ -147,36 +142,8 @@ public class ControllerTest {
runTest();
Controller.destroy();
Keyboard.destroy();
Window.destroy();
}
/**
* Creates the controller
*/
private void createController() {
try {
Controller.create();
} catch (Exception e) {
e.printStackTrace();
System.out.println("No controller found, exiting...");
System.exit(-1);
}
}
/**
* Creates the keyboard
*/
private void createKeyboard() {
try {
Keyboard.create();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
/**
* Runs the test
*/
@ -195,10 +162,8 @@ public class ControllerTest {
// pause and continue if minimized
if(Window.isMinimized()) {
if(Window.isDirty()) {
render();
}
pause(100);
render();
continue;
}
@ -242,9 +207,6 @@ public class ControllerTest {
* Reads the controller
*/
private void readController() {
// poll for current values
Controller.poll();
// get last button down
for(int i=0;i<Controller.getButtonCount(); i++) {
if(Controller.isButtonDown(i)) {
@ -346,8 +308,6 @@ public class ControllerTest {
* Handles the keyboard
*/
private void handleKeyboard() {
Keyboard.poll();
// closing on ESCAPE
if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
closing = true;

View File

@ -260,9 +260,6 @@ public class HWCursorTest {
* Processes keyboard input
*/
private void processKeyboard() {
Keyboard.poll();
Mouse.poll();
if (Mouse.getDX() != 0 || Mouse.getDY() != 0) {
mouse_x += Mouse.getDX() / 2;
mouse_y += Mouse.getDY() / 2;

View File

@ -37,7 +37,6 @@ import org.lwjgl.Sys;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.Window;
import org.lwjgl.opengl.glu.GLU;
import org.lwjgl.vector.Vector2f;
/**
@ -89,7 +88,6 @@ public class MouseCreationTest {
private void initializeOpenGL() {
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GLU.gluOrtho2D(0.0f, 640f, 0f, 480f);
}
public void executeTest() {
@ -101,9 +99,7 @@ public class MouseCreationTest {
System.out.println("=========== WINDOWED MODE ==============");
for(int i=0; i<2; i++) {
System.out.println("Test " + (i+1) + ":");
createMouse();
wiggleMouse();
destroyMouse();
System.out.println("");
}
@ -127,31 +123,17 @@ public class MouseCreationTest {
System.out.println("=========== FULLSCREEN MODE ==============");
for(int i=0; i<2; i++) {
System.out.println("Test " + (i+3) + ":");
createMouse();
wiggleMouse();
destroyMouse();
System.out.println("");
}
System.out.println("Test completed successfully!");
System.out.print("Shutting down...");
Display.resetDisplayMode();
Mouse.destroy();
Window.destroy();
System.out.println("shutdown complete");
}
private void createMouse() {
System.out.print("Creating mouse...");
try {
Mouse.create();
} catch (Exception e) {
System.out.println("failed");
System.exit(-1);
}
System.out.println("success");
}
private void wiggleMouse() {
System.out.print("Please move the mouse around");
@ -161,8 +143,6 @@ public class MouseCreationTest {
while (Sys.getTime() < endtime) {
Window.update();
Mouse.poll();
position.x += Mouse.getDX();
position.y += Mouse.getDY();
@ -188,12 +168,6 @@ public class MouseCreationTest {
System.out.println("thank you");
}
private void destroyMouse() {
System.out.print("Destroying mouse...");
Mouse.destroy();
System.out.print("success");
}
private void render() {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

View File

@ -35,7 +35,6 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.Window;
import org.lwjgl.opengl.glu.GLU;
import org.lwjgl.vector.Vector2f;
import org.lwjgl.vector.Vector3f;
@ -95,11 +94,6 @@ public class MouseTest {
/** Fullscreen or not */
public static final boolean FULLSCREEN = false;
/** Buffered mouse or not */
public static final boolean BUFFERED_MOUSE = true;
private int bufferSize;
/** Creates a new instance of MouseTest */
public MouseTest() {
}
@ -108,8 +102,8 @@ public class MouseTest {
// create display and opengl
setupDisplay();
createMouse();
createKeyboard();
setupMouse();
setupKeyboard();
}
/**
@ -137,7 +131,6 @@ public class MouseTest {
*/
private void initializeOpenGL() {
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GLU.gluOrtho2D(0.0f, WINDOW_WIDTH, 0, WINDOW_HEIGHT);
}
/**
@ -148,43 +141,19 @@ public class MouseTest {
runTest();
Mouse.destroy();
Keyboard.destroy();
Window.destroy();
}
/**
* Creates the mouse
*/
private void createMouse() {
try {
Mouse.create();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
// if compiled for buffered mode, enable that
if(BUFFERED_MOUSE) {
try {
Mouse.enableBuffer();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
private void setupMouse() {
}
/**
* Creates the keyboard
*/
private void createKeyboard() {
try {
Keyboard.create();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
private void setupKeyboard() {
}
/**
@ -245,23 +214,13 @@ public class MouseTest {
* handles the mouse
*/
private void handleMouse() {
if(BUFFERED_MOUSE) {
readBufferedMouse();
} else {
readUnbufferedMouse();
}
readBufferedMouse();
}
/**
* reads a mouse in buffered mode
*/
private void readBufferedMouse() {
// poll for current values
Mouse.poll();
// read events
Mouse.read();
// iterate all events, use the last button down
while(Mouse.next()) {
if(Mouse.getEventButtonState()) {
@ -271,23 +230,6 @@ public class MouseTest {
updateState();
}
/**
* Reads the mouse in unbuffered mode
*/
private void readUnbufferedMouse() {
// poll for current values
Mouse.poll();
// get last button down
for(int i=0;i<Mouse.getButtonCount(); i++) {
if(Mouse.isButtonDown(i)) {
lastButton = i;
}
}
updateState();
}
/**
* Updates our "model"
@ -300,7 +242,6 @@ public class MouseTest {
if (Mouse.getDX() == Mouse.getDY() && Mouse.getDX() == 0 && Mouse.getDWheel() == 0) {
return;
}
// determine direction moved
// ============================
if(Mouse.getDX() > 0) {
@ -371,8 +312,6 @@ public class MouseTest {
* Handles the keyboard
*/
private void handleKeyboard() {
Keyboard.poll();
// closing on ESCAPE
if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
closing = true;

View File

@ -77,9 +77,9 @@ public class ALCTest extends BasicTest {
//mo query
buffer.rewind();
buffer.limit(1);
buffer.position(0);
ALC.alcGetInteger(ALC.ALC_MAJOR_VERSION, buffer);
ALC.alcGetInteger(ALC.ALC_MINOR_VERSION, (IntBuffer) buffer.position(1).limit(2));
ALC.alcGetInteger(ALC.ALC_MINOR_VERSION, (IntBuffer) buffer.position(1));
System.out.println("ALC_MAJOR_VERSION: " + buffer.get(0));
System.out.println("ALC_MINOR_VERSION: " + buffer.get(1));

View File

@ -194,20 +194,6 @@ public class PositionTest extends BasicTest {
Sys.log("Soundfiles loaded successfully");
// -----------------------------------------------------
// Setup Keyboard
// =====================================================
Sys.log("Setting up Keyboard");
Keyboard.create();
// -----------------------------------------------------
// Setup Mouse
// =====================================================
Sys.log("Setting up Mouse");
Mouse.create();
// -----------------------------------------------------
}
/**
@ -238,18 +224,18 @@ public class PositionTest extends BasicTest {
while (!finished) {
// handle any input
handleInput();
// allow window to process internal messages
Window.update();
// render and paint if !minimized and not dirty
if(Window.isFocused() || Window.isDirty()) {
if(!Window.isMinimized()) {
render();
} else {
// sleeeeeep
pause(100);
}
// allow window to process internal messages
Window.update();
// act on pause mode
paused(Window.isMinimized() || !Window.isFocused());
@ -300,9 +286,6 @@ public class PositionTest extends BasicTest {
* Handles any input
*/
private void handleInput() {
Mouse.poll();
Keyboard.poll();
// User wants to exit?
finished = Window.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE);
if (finished) {
@ -445,12 +428,6 @@ public class PositionTest extends BasicTest {
* Shutdown of demonstration
*/
private void shutdown() {
Sys.log("Shutting down Keyboard");
Keyboard.destroy();
Sys.log("Shutting down Mouse");
Mouse.destroy();
Sys.log("Shutting down OpenAL");
AL10.alSourceStop(soundSources);
AL10.alDeleteSources(soundSources);

View File

@ -163,6 +163,7 @@ public class FullScreenWindowedTest {
//check for fullscreen key
if (Keyboard.isKeyDown(Keyboard.KEY_F)) {
try {
Window.destroy();
Display.setDisplayMode(mode);
Window.create("Test", mode.bpp, 0, 0, 0, 0);
glInit();
@ -173,6 +174,7 @@ public class FullScreenWindowedTest {
//check for window key
if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
try {
Window.destroy();
Display.resetDisplayMode();
Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0);
glInit();

View File

@ -117,7 +117,6 @@ public final class VBOIndexTest {
else if (Window.isCloseRequested())
System.exit(0);
Keyboard.poll();
mainLoop();
render();
}
@ -136,16 +135,13 @@ public final class VBOIndexTest {
if (angle > 360.0f)
angle = 0.0f;
Mouse.poll();
if (Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0)
System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
for (int i = 0; i < Mouse.getButtonCount(); i++)
if (Mouse.isButtonDown(i))
System.out.println("Button " + i + " down");
/* Keyboard.poll();
if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
finished = true;*/
Keyboard.read();
finished = true;
for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) {
Keyboard.next();
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState())
@ -192,9 +188,6 @@ public final class VBOIndexTest {
* Initialize
*/
private static void init() throws Exception {
Keyboard.create();
Keyboard.enableBuffer();
Mouse.create();
Sys.setTime(0);
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
System.out.println("Timer resolution: " + Sys.getTimerResolution());
@ -235,8 +228,6 @@ public final class VBOIndexTest {
int_buffer.put(0, buffer_id);
int_buffer.put(1, indices_buffer_id);
ARBVertexBufferObject.glDeleteBuffersARB(int_buffer);
Keyboard.destroy();
Mouse.destroy();
Window.destroy();
try {
Display.resetDisplayMode();

View File

@ -113,7 +113,6 @@ public final class VBOTest {
else if (Window.isCloseRequested())
System.exit(0);
Keyboard.poll();
mainLoop();
render();
}
@ -132,16 +131,13 @@ public final class VBOTest {
if (angle > 360.0f)
angle = 0.0f;
Mouse.poll();
if (Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0)
System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
for (int i = 0; i < Mouse.getButtonCount(); i++)
if (Mouse.isButtonDown(i))
System.out.println("Button " + i + " down");
/* Keyboard.poll();
if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
finished = true;*/
Keyboard.read();
finished = true;
for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) {
Keyboard.next();
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState())
@ -175,9 +171,6 @@ public final class VBOTest {
* Initialize
*/
private static void init() throws Exception {
Keyboard.create();
Keyboard.enableBuffer();
Mouse.create();
Sys.setTime(0);
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
System.out.println("Timer resolution: " + Sys.getTimerResolution());
@ -210,8 +203,6 @@ public final class VBOTest {
IntBuffer int_buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
int_buffer.put(0, buffer_id);
ARBVertexBufferObject.glDeleteBuffersARB(int_buffer);
Keyboard.destroy();
Mouse.destroy();
Window.destroy();
try {
Display.resetDisplayMode();