minor updates

This commit is contained in:
Brian Matzon 2004-07-22 14:56:40 +00:00
parent 760bb65d5a
commit bb7bc889a4
7 changed files with 175 additions and 67 deletions

View File

@ -58,19 +58,8 @@ public class ControllerCreationTest {
}
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 {
Display.setDisplayMode(displayMode);
setDisplayMode();
Display.setFullscreen(fullscreen);
Display.create();
@ -82,6 +71,28 @@ public class ControllerCreationTest {
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() {
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}

View File

@ -41,6 +41,7 @@ import java.awt.event.WindowEvent;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Controller;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
/**
@ -83,7 +84,9 @@ public class ControllerFieldTest {
String buttons;
while(frame.isVisible()) {
buttons = "";
Display.update();
if(Display.isActive()) {
Display.update();
}
labels[0].setText("" + Controller.getX());
labels[1].setText("" + Controller.getRx());
@ -100,6 +103,28 @@ public class ControllerFieldTest {
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() {
try {
Display.create();
setDisplayMode();
Display.create();
} catch (LWJGLException lwjgle) {
lwjgle.printStackTrace();
return;
@ -138,7 +164,7 @@ public class ControllerFieldTest {
}
frame = new Frame("ControllerFieldTest");
frame.setBounds(100, 100, 640, 480);
frame.setBounds(400, 400, 640, 480);
frame.add(panel);
frame.addWindowListener(new WindowAdapter() {

View File

@ -34,6 +34,7 @@ package org.lwjgl.test.input;
import org.lwjgl.input.Controller;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector2f;
import org.lwjgl.util.vector.Vector3f;
@ -112,12 +113,10 @@ public class ControllerTest {
*/
private void setupDisplay() {
try {
if (FULLSCREEN) {
Display.create();
} else {
Display.create();
}
setDisplayMode();
Display.setFullscreen(FULLSCREEN);
Display.setVSyncEnabled(true);
Display.create();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
@ -125,6 +124,28 @@ public class ControllerTest {
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

View File

@ -53,9 +53,6 @@ import org.lwjgl.opengl.glu.GLU;
*/
public class HWCursorTest {
/** Intended deiplay mode */
private DisplayMode mode;
/** The native cursor */
private static Cursor[] cursor = null;
@ -74,17 +71,36 @@ public class HWCursorTest {
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
*/
private void initialize() {
try {
//find displaymode
mode = findDisplayMode(800, 600, 16);
Display.setDisplayMode(mode);
// start of in windowed mode
setDisplayMode();
Display.create();
glInit();
@ -358,26 +374,6 @@ public class HWCursorTest {
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
*/
@ -385,10 +381,10 @@ public class HWCursorTest {
// Go into orthographic projection mode.
GL11.glMatrixMode(GL11.GL_PROJECTION);
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.glLoadIdentity();
GL11.glViewport(0, 0, mode.getWidth(), mode.getHeight());
GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
//set clear color to black
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

View File

@ -73,9 +73,32 @@ public class KeyboardTest {
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) {
try {
setDisplayMode();
Display.create();
} catch (Exception e) {
e.printStackTrace();

View File

@ -58,22 +58,10 @@ public class MouseCreationTest {
}
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 {
Display.setDisplayMode(displayMode);
setDisplayMode();
Display.setFullscreen(fullscreen);
Display.create();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
@ -82,6 +70,28 @@ public class MouseCreationTest {
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() {
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}

View File

@ -34,6 +34,7 @@ package org.lwjgl.test.input;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector2f;
import org.lwjgl.util.vector.Vector3f;
@ -111,12 +112,10 @@ public class MouseTest {
*/
private void setupDisplay() {
try {
if (FULLSCREEN) {
Display.create();
} else {
Display.create();
}
setDisplayMode();
Display.setFullscreen(FULLSCREEN);
Display.setVSyncEnabled(true);
Display.create();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
@ -124,6 +123,28 @@ public class MouseTest {
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