minor updates
This commit is contained in:
parent
760bb65d5a
commit
bb7bc889a4
|
@ -58,19 +58,8 @@ public class ControllerCreationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize(boolean fullscreen) {
|
private void initialize(boolean fullscreen) {
|
||||||
// find first display mode that allows us 640*480*16
|
|
||||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
|
||||||
for (int i = 0; i < modes.length; i++) {
|
|
||||||
if (modes[i].getWidth() == 640
|
|
||||||
&& modes[i].getHeight() == 480
|
|
||||||
&& modes[i].getBitsPerPixel() >= 16) {
|
|
||||||
displayMode = modes[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Display.setDisplayMode(displayMode);
|
setDisplayMode();
|
||||||
Display.setFullscreen(fullscreen);
|
Display.setFullscreen(fullscreen);
|
||||||
Display.create();
|
Display.create();
|
||||||
|
|
||||||
|
@ -82,6 +71,28 @@ public class ControllerCreationTest {
|
||||||
initializeOpenGL();
|
initializeOpenGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the display mode for fullscreen mode
|
||||||
|
*/
|
||||||
|
protected boolean setDisplayMode() {
|
||||||
|
// get modes
|
||||||
|
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||||
|
|
||||||
|
try {
|
||||||
|
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||||
|
"width=" + 640,
|
||||||
|
"height=" + 480,
|
||||||
|
"freq=" + 60,
|
||||||
|
"bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import java.awt.event.WindowEvent;
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
import org.lwjgl.input.Controller;
|
import org.lwjgl.input.Controller;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
|
import org.lwjgl.opengl.DisplayMode;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +84,9 @@ public class ControllerFieldTest {
|
||||||
String buttons;
|
String buttons;
|
||||||
while(frame.isVisible()) {
|
while(frame.isVisible()) {
|
||||||
buttons = "";
|
buttons = "";
|
||||||
Display.update();
|
if(Display.isActive()) {
|
||||||
|
Display.update();
|
||||||
|
}
|
||||||
|
|
||||||
labels[0].setText("" + Controller.getX());
|
labels[0].setText("" + Controller.getX());
|
||||||
labels[1].setText("" + Controller.getRx());
|
labels[1].setText("" + Controller.getRx());
|
||||||
|
@ -100,6 +103,28 @@ public class ControllerFieldTest {
|
||||||
labels[17].setText(buttons);
|
labels[17].setText(buttons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the display mode for fullscreen mode
|
||||||
|
*/
|
||||||
|
protected boolean setDisplayMode() {
|
||||||
|
// get modes
|
||||||
|
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(320, 240, -1, -1, -1, -1, 60, 60);
|
||||||
|
|
||||||
|
try {
|
||||||
|
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||||
|
"width=" + 320,
|
||||||
|
"height=" + 240,
|
||||||
|
"freq=" + 60,
|
||||||
|
"bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -107,7 +132,8 @@ public class ControllerFieldTest {
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Display.create();
|
setDisplayMode();
|
||||||
|
Display.create();
|
||||||
} catch (LWJGLException lwjgle) {
|
} catch (LWJGLException lwjgle) {
|
||||||
lwjgle.printStackTrace();
|
lwjgle.printStackTrace();
|
||||||
return;
|
return;
|
||||||
|
@ -138,7 +164,7 @@ public class ControllerFieldTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
frame = new Frame("ControllerFieldTest");
|
frame = new Frame("ControllerFieldTest");
|
||||||
frame.setBounds(100, 100, 640, 480);
|
frame.setBounds(400, 400, 640, 480);
|
||||||
frame.add(panel);
|
frame.add(panel);
|
||||||
|
|
||||||
frame.addWindowListener(new WindowAdapter() {
|
frame.addWindowListener(new WindowAdapter() {
|
||||||
|
|
|
@ -34,6 +34,7 @@ package org.lwjgl.test.input;
|
||||||
import org.lwjgl.input.Controller;
|
import org.lwjgl.input.Controller;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
|
import org.lwjgl.opengl.DisplayMode;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.util.vector.Vector2f;
|
import org.lwjgl.util.vector.Vector2f;
|
||||||
import org.lwjgl.util.vector.Vector3f;
|
import org.lwjgl.util.vector.Vector3f;
|
||||||
|
@ -112,12 +113,10 @@ public class ControllerTest {
|
||||||
*/
|
*/
|
||||||
private void setupDisplay() {
|
private void setupDisplay() {
|
||||||
try {
|
try {
|
||||||
if (FULLSCREEN) {
|
setDisplayMode();
|
||||||
Display.create();
|
Display.setFullscreen(FULLSCREEN);
|
||||||
} else {
|
|
||||||
Display.create();
|
|
||||||
}
|
|
||||||
Display.setVSyncEnabled(true);
|
Display.setVSyncEnabled(true);
|
||||||
|
Display.create();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
|
@ -125,6 +124,28 @@ public class ControllerTest {
|
||||||
|
|
||||||
initializeOpenGL();
|
initializeOpenGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the display mode for fullscreen mode
|
||||||
|
*/
|
||||||
|
protected boolean setDisplayMode() {
|
||||||
|
// get modes
|
||||||
|
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(WINDOW_WIDTH, WINDOW_HEIGHT, -1, -1, -1, -1, 60, 60);
|
||||||
|
|
||||||
|
try {
|
||||||
|
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||||
|
"width=" + WINDOW_WIDTH,
|
||||||
|
"height=" + WINDOW_HEIGHT,
|
||||||
|
"freq=" + 60,
|
||||||
|
"bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes OpenGL
|
* Initializes OpenGL
|
||||||
|
|
|
@ -53,9 +53,6 @@ import org.lwjgl.opengl.glu.GLU;
|
||||||
*/
|
*/
|
||||||
public class HWCursorTest {
|
public class HWCursorTest {
|
||||||
|
|
||||||
/** Intended deiplay mode */
|
|
||||||
private DisplayMode mode;
|
|
||||||
|
|
||||||
/** The native cursor */
|
/** The native cursor */
|
||||||
private static Cursor[] cursor = null;
|
private static Cursor[] cursor = null;
|
||||||
|
|
||||||
|
@ -74,17 +71,36 @@ public class HWCursorTest {
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the display mode for fullscreen mode
|
||||||
|
*/
|
||||||
|
protected boolean setDisplayMode() {
|
||||||
|
// get modes
|
||||||
|
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||||
|
|
||||||
|
try {
|
||||||
|
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||||
|
"width=" + 640,
|
||||||
|
"height=" + 480,
|
||||||
|
"freq=" + 60,
|
||||||
|
"bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the test
|
* Initializes the test
|
||||||
*/
|
*/
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
try {
|
try {
|
||||||
//find displaymode
|
|
||||||
mode = findDisplayMode(800, 600, 16);
|
|
||||||
Display.setDisplayMode(mode);
|
|
||||||
|
|
||||||
// start of in windowed mode
|
// start of in windowed mode
|
||||||
|
setDisplayMode();
|
||||||
Display.create();
|
Display.create();
|
||||||
|
|
||||||
glInit();
|
glInit();
|
||||||
|
@ -358,26 +374,6 @@ public class HWCursorTest {
|
||||||
Display.destroy();
|
Display.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a displaymode, if one such is available
|
|
||||||
*
|
|
||||||
* @param width Required width
|
|
||||||
* @param height Required height
|
|
||||||
* @param bpp Minimum required bits per pixel
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private DisplayMode findDisplayMode(int width, int height, int bpp) {
|
|
||||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
|
||||||
for (int i = 0; i < modes.length; i++) {
|
|
||||||
if (modes[i].getWidth() == width
|
|
||||||
&& modes[i].getHeight() == height
|
|
||||||
&& modes[i].getBitsPerPixel() >= bpp) {
|
|
||||||
return modes[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes OGL
|
* Initializes OGL
|
||||||
*/
|
*/
|
||||||
|
@ -385,10 +381,10 @@ public class HWCursorTest {
|
||||||
// Go into orthographic projection mode.
|
// Go into orthographic projection mode.
|
||||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||||
GL11.glLoadIdentity();
|
GL11.glLoadIdentity();
|
||||||
GLU.gluOrtho2D(0, mode.getWidth(), 0, mode.getHeight());
|
GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
|
||||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||||
GL11.glLoadIdentity();
|
GL11.glLoadIdentity();
|
||||||
GL11.glViewport(0, 0, mode.getWidth(), mode.getHeight());
|
GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
|
||||||
|
|
||||||
//set clear color to black
|
//set clear color to black
|
||||||
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
|
@ -73,9 +73,32 @@ public class KeyboardTest {
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the display mode for fullscreen mode
|
||||||
|
*/
|
||||||
|
protected boolean setDisplayMode() {
|
||||||
|
// get modes
|
||||||
|
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||||
|
|
||||||
|
try {
|
||||||
|
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||||
|
"width=" + 640,
|
||||||
|
"height=" + 480,
|
||||||
|
"freq=" + 60,
|
||||||
|
"bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void setupDisplay(boolean fullscreen) {
|
private void setupDisplay(boolean fullscreen) {
|
||||||
try {
|
try {
|
||||||
|
setDisplayMode();
|
||||||
Display.create();
|
Display.create();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -58,22 +58,10 @@ public class MouseCreationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize(boolean fullscreen) {
|
private void initialize(boolean fullscreen) {
|
||||||
// find first display mode that allows us 640*480*16
|
|
||||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
|
||||||
for (int i = 0; i < modes.length; i++) {
|
|
||||||
if (modes[i].getWidth() == 640
|
|
||||||
&& modes[i].getHeight() == 480
|
|
||||||
&& modes[i].getBitsPerPixel() >= 16) {
|
|
||||||
displayMode = modes[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Display.setDisplayMode(displayMode);
|
setDisplayMode();
|
||||||
Display.setFullscreen(fullscreen);
|
Display.setFullscreen(fullscreen);
|
||||||
Display.create();
|
Display.create();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
|
@ -82,6 +70,28 @@ public class MouseCreationTest {
|
||||||
initializeOpenGL();
|
initializeOpenGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the display mode for fullscreen mode
|
||||||
|
*/
|
||||||
|
protected boolean setDisplayMode() {
|
||||||
|
// get modes
|
||||||
|
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||||
|
|
||||||
|
try {
|
||||||
|
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||||
|
"width=" + 640,
|
||||||
|
"height=" + 480,
|
||||||
|
"freq=" + 60,
|
||||||
|
"bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ package org.lwjgl.test.input;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
|
import org.lwjgl.opengl.DisplayMode;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.util.vector.Vector2f;
|
import org.lwjgl.util.vector.Vector2f;
|
||||||
import org.lwjgl.util.vector.Vector3f;
|
import org.lwjgl.util.vector.Vector3f;
|
||||||
|
@ -111,12 +112,10 @@ public class MouseTest {
|
||||||
*/
|
*/
|
||||||
private void setupDisplay() {
|
private void setupDisplay() {
|
||||||
try {
|
try {
|
||||||
if (FULLSCREEN) {
|
setDisplayMode();
|
||||||
Display.create();
|
Display.setFullscreen(FULLSCREEN);
|
||||||
} else {
|
|
||||||
Display.create();
|
|
||||||
}
|
|
||||||
Display.setVSyncEnabled(true);
|
Display.setVSyncEnabled(true);
|
||||||
|
Display.create();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
|
@ -124,6 +123,28 @@ public class MouseTest {
|
||||||
|
|
||||||
initializeOpenGL();
|
initializeOpenGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the display mode for fullscreen mode
|
||||||
|
*/
|
||||||
|
protected boolean setDisplayMode() {
|
||||||
|
// get modes
|
||||||
|
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(WINDOW_WIDTH, WINDOW_HEIGHT, -1, -1, -1, -1, 60, 60);
|
||||||
|
|
||||||
|
try {
|
||||||
|
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||||
|
"width=" + WINDOW_WIDTH,
|
||||||
|
"height=" + WINDOW_HEIGHT,
|
||||||
|
"freq=" + 60,
|
||||||
|
"bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes OpenGL
|
* Initializes OpenGL
|
||||||
|
|
Loading…
Reference in New Issue