parent
8a2d246060
commit
afb8491cfa
|
@ -35,12 +35,11 @@ package org.lwjgl.input;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.lwjgl.Sys;
|
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
|
import org.lwjgl.Sys;
|
||||||
import org.lwjgl.opengl.Window;
|
import org.lwjgl.opengl.Window;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,12 +33,11 @@
|
||||||
package org.lwjgl.input;
|
package org.lwjgl.input;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.lwjgl.Sys;
|
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
|
import org.lwjgl.Sys;
|
||||||
import org.lwjgl.opengl.Window;
|
import org.lwjgl.opengl.Window;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,6 +33,7 @@ package org.lwjgl.test;
|
||||||
|
|
||||||
import org.lwjgl.Display;
|
import org.lwjgl.Display;
|
||||||
import org.lwjgl.DisplayMode;
|
import org.lwjgl.DisplayMode;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.opengl.Window;
|
import org.lwjgl.opengl.Window;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,6 +74,10 @@ public class WindowCreationTest {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nuke window and get out
|
// nuke window and get out
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.lwjgl.Sys;
|
||||||
import org.lwjgl.input.Controller;
|
import org.lwjgl.input.Controller;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.Window;
|
import org.lwjgl.opengl.Window;
|
||||||
import org.lwjgl.opengl.glu.GLU;
|
|
||||||
import org.lwjgl.vector.Vector2f;
|
import org.lwjgl.vector.Vector2f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,7 +88,6 @@ public class ControllerCreationTest {
|
||||||
|
|
||||||
private void initializeOpenGL() {
|
private void initializeOpenGL() {
|
||||||
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
GLU.gluOrtho2D(0.0f, 640f, 0f, 480f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeTest() {
|
public void executeTest() {
|
||||||
|
@ -101,9 +99,7 @@ public class ControllerCreationTest {
|
||||||
System.out.println("=========== WINDOWED MODE ==============");
|
System.out.println("=========== WINDOWED MODE ==============");
|
||||||
for(int i=0; i<2; i++) {
|
for(int i=0; i<2; i++) {
|
||||||
System.out.println("Test " + (i+1) + ":");
|
System.out.println("Test " + (i+1) + ":");
|
||||||
createController();
|
|
||||||
wiggleController();
|
wiggleController();
|
||||||
destroyController();
|
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,31 +123,17 @@ public class ControllerCreationTest {
|
||||||
System.out.println("=========== FULLSCREEN MODE ==============");
|
System.out.println("=========== FULLSCREEN MODE ==============");
|
||||||
for(int i=0; i<2; i++) {
|
for(int i=0; i<2; i++) {
|
||||||
System.out.println("Test " + (i+3) + ":");
|
System.out.println("Test " + (i+3) + ":");
|
||||||
createController();
|
|
||||||
wiggleController();
|
wiggleController();
|
||||||
destroyController();
|
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Test completed successfully!");
|
System.out.println("Test completed successfully!");
|
||||||
System.out.print("Shutting down...");
|
System.out.print("Shutting down...");
|
||||||
Display.resetDisplayMode();
|
Display.resetDisplayMode();
|
||||||
Controller.destroy();
|
|
||||||
Window.destroy();
|
Window.destroy();
|
||||||
System.out.println("shutdown complete");
|
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() {
|
private void wiggleController() {
|
||||||
System.out.print("Please move the controller around");
|
System.out.print("Please move the controller around");
|
||||||
|
|
||||||
|
@ -162,8 +144,6 @@ public class ControllerCreationTest {
|
||||||
|
|
||||||
Window.update();
|
Window.update();
|
||||||
|
|
||||||
Controller.poll();
|
|
||||||
|
|
||||||
//controller is a bit fuzzy
|
//controller is a bit fuzzy
|
||||||
if(Controller.getX() > 100) {
|
if(Controller.getX() > 100) {
|
||||||
position.x += 1;
|
position.x += 1;
|
||||||
|
@ -186,12 +166,6 @@ public class ControllerCreationTest {
|
||||||
System.out.println("thank you");
|
System.out.println("thank you");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroyController() {
|
|
||||||
System.out.print("Destroying controller...");
|
|
||||||
Controller.destroy();
|
|
||||||
System.out.print("success");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void render() {
|
private void render() {
|
||||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.lwjgl.input.Controller;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.Window;
|
import org.lwjgl.opengl.Window;
|
||||||
import org.lwjgl.opengl.glu.GLU;
|
|
||||||
import org.lwjgl.vector.Vector2f;
|
import org.lwjgl.vector.Vector2f;
|
||||||
import org.lwjgl.vector.Vector3f;
|
import org.lwjgl.vector.Vector3f;
|
||||||
|
|
||||||
|
@ -106,9 +105,6 @@ public class ControllerTest {
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
// create display and opengl
|
// create display and opengl
|
||||||
setupDisplay();
|
setupDisplay();
|
||||||
|
|
||||||
createController();
|
|
||||||
createKeyboard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +132,6 @@ public class ControllerTest {
|
||||||
*/
|
*/
|
||||||
private void initializeOpenGL() {
|
private void initializeOpenGL() {
|
||||||
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
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();
|
runTest();
|
||||||
|
|
||||||
Controller.destroy();
|
|
||||||
Keyboard.destroy();
|
|
||||||
Window.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
|
* Runs the test
|
||||||
*/
|
*/
|
||||||
|
@ -195,10 +162,8 @@ public class ControllerTest {
|
||||||
|
|
||||||
// pause and continue if minimized
|
// pause and continue if minimized
|
||||||
if(Window.isMinimized()) {
|
if(Window.isMinimized()) {
|
||||||
if(Window.isDirty()) {
|
|
||||||
render();
|
|
||||||
}
|
|
||||||
pause(100);
|
pause(100);
|
||||||
|
render();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,9 +207,6 @@ public class ControllerTest {
|
||||||
* Reads the controller
|
* Reads the controller
|
||||||
*/
|
*/
|
||||||
private void readController() {
|
private void readController() {
|
||||||
// poll for current values
|
|
||||||
Controller.poll();
|
|
||||||
|
|
||||||
// get last button down
|
// get last button down
|
||||||
for(int i=0;i<Controller.getButtonCount(); i++) {
|
for(int i=0;i<Controller.getButtonCount(); i++) {
|
||||||
if(Controller.isButtonDown(i)) {
|
if(Controller.isButtonDown(i)) {
|
||||||
|
@ -346,8 +308,6 @@ public class ControllerTest {
|
||||||
* Handles the keyboard
|
* Handles the keyboard
|
||||||
*/
|
*/
|
||||||
private void handleKeyboard() {
|
private void handleKeyboard() {
|
||||||
Keyboard.poll();
|
|
||||||
|
|
||||||
// closing on ESCAPE
|
// closing on ESCAPE
|
||||||
if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
|
if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
|
||||||
closing = true;
|
closing = true;
|
||||||
|
|
|
@ -260,9 +260,6 @@ public class HWCursorTest {
|
||||||
* Processes keyboard input
|
* Processes keyboard input
|
||||||
*/
|
*/
|
||||||
private void processKeyboard() {
|
private void processKeyboard() {
|
||||||
Keyboard.poll();
|
|
||||||
Mouse.poll();
|
|
||||||
|
|
||||||
if (Mouse.getDX() != 0 || Mouse.getDY() != 0) {
|
if (Mouse.getDX() != 0 || Mouse.getDY() != 0) {
|
||||||
mouse_x += Mouse.getDX() / 2;
|
mouse_x += Mouse.getDX() / 2;
|
||||||
mouse_y += Mouse.getDY() / 2;
|
mouse_y += Mouse.getDY() / 2;
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.lwjgl.Sys;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.Window;
|
import org.lwjgl.opengl.Window;
|
||||||
import org.lwjgl.opengl.glu.GLU;
|
|
||||||
import org.lwjgl.vector.Vector2f;
|
import org.lwjgl.vector.Vector2f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,7 +88,6 @@ public class MouseCreationTest {
|
||||||
|
|
||||||
private void initializeOpenGL() {
|
private void initializeOpenGL() {
|
||||||
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
GLU.gluOrtho2D(0.0f, 640f, 0f, 480f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeTest() {
|
public void executeTest() {
|
||||||
|
@ -101,9 +99,7 @@ public class MouseCreationTest {
|
||||||
System.out.println("=========== WINDOWED MODE ==============");
|
System.out.println("=========== WINDOWED MODE ==============");
|
||||||
for(int i=0; i<2; i++) {
|
for(int i=0; i<2; i++) {
|
||||||
System.out.println("Test " + (i+1) + ":");
|
System.out.println("Test " + (i+1) + ":");
|
||||||
createMouse();
|
|
||||||
wiggleMouse();
|
wiggleMouse();
|
||||||
destroyMouse();
|
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,31 +123,17 @@ public class MouseCreationTest {
|
||||||
System.out.println("=========== FULLSCREEN MODE ==============");
|
System.out.println("=========== FULLSCREEN MODE ==============");
|
||||||
for(int i=0; i<2; i++) {
|
for(int i=0; i<2; i++) {
|
||||||
System.out.println("Test " + (i+3) + ":");
|
System.out.println("Test " + (i+3) + ":");
|
||||||
createMouse();
|
|
||||||
wiggleMouse();
|
wiggleMouse();
|
||||||
destroyMouse();
|
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Test completed successfully!");
|
System.out.println("Test completed successfully!");
|
||||||
System.out.print("Shutting down...");
|
System.out.print("Shutting down...");
|
||||||
Display.resetDisplayMode();
|
Display.resetDisplayMode();
|
||||||
Mouse.destroy();
|
|
||||||
Window.destroy();
|
Window.destroy();
|
||||||
System.out.println("shutdown complete");
|
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() {
|
private void wiggleMouse() {
|
||||||
System.out.print("Please move the mouse around");
|
System.out.print("Please move the mouse around");
|
||||||
|
|
||||||
|
@ -161,8 +143,6 @@ public class MouseCreationTest {
|
||||||
while (Sys.getTime() < endtime) {
|
while (Sys.getTime() < endtime) {
|
||||||
Window.update();
|
Window.update();
|
||||||
|
|
||||||
Mouse.poll();
|
|
||||||
|
|
||||||
position.x += Mouse.getDX();
|
position.x += Mouse.getDX();
|
||||||
position.y += Mouse.getDY();
|
position.y += Mouse.getDY();
|
||||||
|
|
||||||
|
@ -188,12 +168,6 @@ public class MouseCreationTest {
|
||||||
System.out.println("thank you");
|
System.out.println("thank you");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroyMouse() {
|
|
||||||
System.out.print("Destroying mouse...");
|
|
||||||
Mouse.destroy();
|
|
||||||
System.out.print("success");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void render() {
|
private void render() {
|
||||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.Window;
|
import org.lwjgl.opengl.Window;
|
||||||
import org.lwjgl.opengl.glu.GLU;
|
|
||||||
import org.lwjgl.vector.Vector2f;
|
import org.lwjgl.vector.Vector2f;
|
||||||
import org.lwjgl.vector.Vector3f;
|
import org.lwjgl.vector.Vector3f;
|
||||||
|
|
||||||
|
@ -95,11 +94,6 @@ public class MouseTest {
|
||||||
/** Fullscreen or not */
|
/** Fullscreen or not */
|
||||||
public static final boolean FULLSCREEN = false;
|
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 */
|
/** Creates a new instance of MouseTest */
|
||||||
public MouseTest() {
|
public MouseTest() {
|
||||||
}
|
}
|
||||||
|
@ -108,8 +102,8 @@ public class MouseTest {
|
||||||
// create display and opengl
|
// create display and opengl
|
||||||
setupDisplay();
|
setupDisplay();
|
||||||
|
|
||||||
createMouse();
|
setupMouse();
|
||||||
createKeyboard();
|
setupKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,7 +131,6 @@ public class MouseTest {
|
||||||
*/
|
*/
|
||||||
private void initializeOpenGL() {
|
private void initializeOpenGL() {
|
||||||
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
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();
|
runTest();
|
||||||
|
|
||||||
Mouse.destroy();
|
|
||||||
Keyboard.destroy();
|
|
||||||
Window.destroy();
|
Window.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the mouse
|
* Creates the mouse
|
||||||
*/
|
*/
|
||||||
private void createMouse() {
|
private void setupMouse() {
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the keyboard
|
* Creates the keyboard
|
||||||
*/
|
*/
|
||||||
private void createKeyboard() {
|
private void setupKeyboard() {
|
||||||
try {
|
|
||||||
Keyboard.create();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,23 +214,13 @@ public class MouseTest {
|
||||||
* handles the mouse
|
* handles the mouse
|
||||||
*/
|
*/
|
||||||
private void handleMouse() {
|
private void handleMouse() {
|
||||||
if(BUFFERED_MOUSE) {
|
|
||||||
readBufferedMouse();
|
readBufferedMouse();
|
||||||
} else {
|
|
||||||
readUnbufferedMouse();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reads a mouse in buffered mode
|
* reads a mouse in buffered mode
|
||||||
*/
|
*/
|
||||||
private void readBufferedMouse() {
|
private void readBufferedMouse() {
|
||||||
// poll for current values
|
|
||||||
Mouse.poll();
|
|
||||||
|
|
||||||
// read events
|
|
||||||
Mouse.read();
|
|
||||||
|
|
||||||
// iterate all events, use the last button down
|
// iterate all events, use the last button down
|
||||||
while(Mouse.next()) {
|
while(Mouse.next()) {
|
||||||
if(Mouse.getEventButtonState()) {
|
if(Mouse.getEventButtonState()) {
|
||||||
|
@ -272,23 +231,6 @@ public class MouseTest {
|
||||||
updateState();
|
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"
|
* Updates our "model"
|
||||||
*
|
*
|
||||||
|
@ -300,7 +242,6 @@ public class MouseTest {
|
||||||
if (Mouse.getDX() == Mouse.getDY() && Mouse.getDX() == 0 && Mouse.getDWheel() == 0) {
|
if (Mouse.getDX() == Mouse.getDY() && Mouse.getDX() == 0 && Mouse.getDWheel() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine direction moved
|
// determine direction moved
|
||||||
// ============================
|
// ============================
|
||||||
if(Mouse.getDX() > 0) {
|
if(Mouse.getDX() > 0) {
|
||||||
|
@ -371,8 +312,6 @@ public class MouseTest {
|
||||||
* Handles the keyboard
|
* Handles the keyboard
|
||||||
*/
|
*/
|
||||||
private void handleKeyboard() {
|
private void handleKeyboard() {
|
||||||
Keyboard.poll();
|
|
||||||
|
|
||||||
// closing on ESCAPE
|
// closing on ESCAPE
|
||||||
if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
|
if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
|
||||||
closing = true;
|
closing = true;
|
||||||
|
|
|
@ -77,9 +77,9 @@ public class ALCTest extends BasicTest {
|
||||||
|
|
||||||
//mo query
|
//mo query
|
||||||
buffer.rewind();
|
buffer.rewind();
|
||||||
buffer.limit(1);
|
buffer.position(0);
|
||||||
ALC.alcGetInteger(ALC.ALC_MAJOR_VERSION, buffer);
|
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_MAJOR_VERSION: " + buffer.get(0));
|
||||||
System.out.println("ALC_MINOR_VERSION: " + buffer.get(1));
|
System.out.println("ALC_MINOR_VERSION: " + buffer.get(1));
|
||||||
|
|
|
@ -194,20 +194,6 @@ public class PositionTest extends BasicTest {
|
||||||
|
|
||||||
Sys.log("Soundfiles loaded successfully");
|
Sys.log("Soundfiles loaded successfully");
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
||||||
// Setup Keyboard
|
|
||||||
// =====================================================
|
|
||||||
Sys.log("Setting up Keyboard");
|
|
||||||
|
|
||||||
Keyboard.create();
|
|
||||||
// -----------------------------------------------------
|
|
||||||
|
|
||||||
// Setup Mouse
|
|
||||||
// =====================================================
|
|
||||||
Sys.log("Setting up Mouse");
|
|
||||||
|
|
||||||
Mouse.create();
|
|
||||||
// -----------------------------------------------------
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -239,17 +225,17 @@ public class PositionTest extends BasicTest {
|
||||||
// handle any input
|
// handle any input
|
||||||
handleInput();
|
handleInput();
|
||||||
|
|
||||||
|
// allow window to process internal messages
|
||||||
|
Window.update();
|
||||||
|
|
||||||
// render and paint if !minimized and not dirty
|
// render and paint if !minimized and not dirty
|
||||||
if(Window.isFocused() || Window.isDirty()) {
|
if(!Window.isMinimized()) {
|
||||||
render();
|
render();
|
||||||
} else {
|
} else {
|
||||||
// sleeeeeep
|
// sleeeeeep
|
||||||
pause(100);
|
pause(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// allow window to process internal messages
|
|
||||||
Window.update();
|
|
||||||
|
|
||||||
// act on pause mode
|
// act on pause mode
|
||||||
paused(Window.isMinimized() || !Window.isFocused());
|
paused(Window.isMinimized() || !Window.isFocused());
|
||||||
|
|
||||||
|
@ -300,9 +286,6 @@ public class PositionTest extends BasicTest {
|
||||||
* Handles any input
|
* Handles any input
|
||||||
*/
|
*/
|
||||||
private void handleInput() {
|
private void handleInput() {
|
||||||
Mouse.poll();
|
|
||||||
Keyboard.poll();
|
|
||||||
|
|
||||||
// User wants to exit?
|
// User wants to exit?
|
||||||
finished = Window.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE);
|
finished = Window.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE);
|
||||||
if (finished) {
|
if (finished) {
|
||||||
|
@ -445,12 +428,6 @@ public class PositionTest extends BasicTest {
|
||||||
* Shutdown of demonstration
|
* Shutdown of demonstration
|
||||||
*/
|
*/
|
||||||
private void shutdown() {
|
private void shutdown() {
|
||||||
Sys.log("Shutting down Keyboard");
|
|
||||||
Keyboard.destroy();
|
|
||||||
|
|
||||||
Sys.log("Shutting down Mouse");
|
|
||||||
Mouse.destroy();
|
|
||||||
|
|
||||||
Sys.log("Shutting down OpenAL");
|
Sys.log("Shutting down OpenAL");
|
||||||
AL10.alSourceStop(soundSources);
|
AL10.alSourceStop(soundSources);
|
||||||
AL10.alDeleteSources(soundSources);
|
AL10.alDeleteSources(soundSources);
|
||||||
|
|
|
@ -163,6 +163,7 @@ public class FullScreenWindowedTest {
|
||||||
//check for fullscreen key
|
//check for fullscreen key
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_F)) {
|
if (Keyboard.isKeyDown(Keyboard.KEY_F)) {
|
||||||
try {
|
try {
|
||||||
|
Window.destroy();
|
||||||
Display.setDisplayMode(mode);
|
Display.setDisplayMode(mode);
|
||||||
Window.create("Test", mode.bpp, 0, 0, 0, 0);
|
Window.create("Test", mode.bpp, 0, 0, 0, 0);
|
||||||
glInit();
|
glInit();
|
||||||
|
@ -173,6 +174,7 @@ public class FullScreenWindowedTest {
|
||||||
//check for window key
|
//check for window key
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
|
if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
|
||||||
try {
|
try {
|
||||||
|
Window.destroy();
|
||||||
Display.resetDisplayMode();
|
Display.resetDisplayMode();
|
||||||
Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0);
|
Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0, 0);
|
||||||
glInit();
|
glInit();
|
||||||
|
|
|
@ -117,7 +117,6 @@ public final class VBOIndexTest {
|
||||||
else if (Window.isCloseRequested())
|
else if (Window.isCloseRequested())
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
|
||||||
Keyboard.poll();
|
|
||||||
mainLoop();
|
mainLoop();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
@ -136,16 +135,13 @@ public final class VBOIndexTest {
|
||||||
if (angle > 360.0f)
|
if (angle > 360.0f)
|
||||||
angle = 0.0f;
|
angle = 0.0f;
|
||||||
|
|
||||||
Mouse.poll();
|
|
||||||
if (Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0)
|
if (Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0)
|
||||||
System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
|
System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
|
||||||
for (int i = 0; i < Mouse.getButtonCount(); i++)
|
for (int i = 0; i < Mouse.getButtonCount(); i++)
|
||||||
if (Mouse.isButtonDown(i))
|
if (Mouse.isButtonDown(i))
|
||||||
System.out.println("Button " + i + " down");
|
System.out.println("Button " + i + " down");
|
||||||
/* Keyboard.poll();
|
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
|
if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
|
||||||
finished = true;*/
|
finished = true;
|
||||||
Keyboard.read();
|
|
||||||
for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) {
|
for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) {
|
||||||
Keyboard.next();
|
Keyboard.next();
|
||||||
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState())
|
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState())
|
||||||
|
@ -192,9 +188,6 @@ public final class VBOIndexTest {
|
||||||
* Initialize
|
* Initialize
|
||||||
*/
|
*/
|
||||||
private static void init() throws Exception {
|
private static void init() throws Exception {
|
||||||
Keyboard.create();
|
|
||||||
Keyboard.enableBuffer();
|
|
||||||
Mouse.create();
|
|
||||||
Sys.setTime(0);
|
Sys.setTime(0);
|
||||||
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
|
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
|
||||||
System.out.println("Timer resolution: " + Sys.getTimerResolution());
|
System.out.println("Timer resolution: " + Sys.getTimerResolution());
|
||||||
|
@ -235,8 +228,6 @@ public final class VBOIndexTest {
|
||||||
int_buffer.put(0, buffer_id);
|
int_buffer.put(0, buffer_id);
|
||||||
int_buffer.put(1, indices_buffer_id);
|
int_buffer.put(1, indices_buffer_id);
|
||||||
ARBVertexBufferObject.glDeleteBuffersARB(int_buffer);
|
ARBVertexBufferObject.glDeleteBuffersARB(int_buffer);
|
||||||
Keyboard.destroy();
|
|
||||||
Mouse.destroy();
|
|
||||||
Window.destroy();
|
Window.destroy();
|
||||||
try {
|
try {
|
||||||
Display.resetDisplayMode();
|
Display.resetDisplayMode();
|
||||||
|
|
|
@ -113,7 +113,6 @@ public final class VBOTest {
|
||||||
else if (Window.isCloseRequested())
|
else if (Window.isCloseRequested())
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
|
||||||
Keyboard.poll();
|
|
||||||
mainLoop();
|
mainLoop();
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
@ -132,16 +131,13 @@ public final class VBOTest {
|
||||||
if (angle > 360.0f)
|
if (angle > 360.0f)
|
||||||
angle = 0.0f;
|
angle = 0.0f;
|
||||||
|
|
||||||
Mouse.poll();
|
|
||||||
if (Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0)
|
if (Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0)
|
||||||
System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
|
System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
|
||||||
for (int i = 0; i < Mouse.getButtonCount(); i++)
|
for (int i = 0; i < Mouse.getButtonCount(); i++)
|
||||||
if (Mouse.isButtonDown(i))
|
if (Mouse.isButtonDown(i))
|
||||||
System.out.println("Button " + i + " down");
|
System.out.println("Button " + i + " down");
|
||||||
/* Keyboard.poll();
|
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
|
if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
|
||||||
finished = true;*/
|
finished = true;
|
||||||
Keyboard.read();
|
|
||||||
for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) {
|
for (int i = 0; i < Keyboard.getNumKeyboardEvents(); i++) {
|
||||||
Keyboard.next();
|
Keyboard.next();
|
||||||
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState())
|
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState())
|
||||||
|
@ -175,9 +171,6 @@ public final class VBOTest {
|
||||||
* Initialize
|
* Initialize
|
||||||
*/
|
*/
|
||||||
private static void init() throws Exception {
|
private static void init() throws Exception {
|
||||||
Keyboard.create();
|
|
||||||
Keyboard.enableBuffer();
|
|
||||||
Mouse.create();
|
|
||||||
Sys.setTime(0);
|
Sys.setTime(0);
|
||||||
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
|
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
|
||||||
System.out.println("Timer resolution: " + Sys.getTimerResolution());
|
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();
|
IntBuffer int_buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||||
int_buffer.put(0, buffer_id);
|
int_buffer.put(0, buffer_id);
|
||||||
ARBVertexBufferObject.glDeleteBuffersARB(int_buffer);
|
ARBVertexBufferObject.glDeleteBuffersARB(int_buffer);
|
||||||
Keyboard.destroy();
|
|
||||||
Mouse.destroy();
|
|
||||||
Window.destroy();
|
Window.destroy();
|
||||||
try {
|
try {
|
||||||
Display.resetDisplayMode();
|
Display.resetDisplayMode();
|
||||||
|
|
Loading…
Reference in New Issue