fix: make it all compile

This commit is contained in:
Brian Matzon 2003-03-28 22:12:45 +00:00
parent 16d8c3c053
commit 07fdc052e0
7 changed files with 83 additions and 107 deletions

View File

@ -37,8 +37,6 @@ import java.lang.reflect.Field;
import java.util.HashMap; import java.util.HashMap;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.lwjgl.Display;
/** /**
* $Id$ * $Id$
* *

View File

@ -7,7 +7,7 @@
package org.lwjgl.test; package org.lwjgl.test;
import org.lwjgl.*; import org.lwjgl.*;
import org.lwjgl.opengl.BaseGL; import org.lwjgl.opengl.GL;
/** /**
* @author Brian * @author Brian
@ -15,35 +15,34 @@ import org.lwjgl.opengl.BaseGL;
public class WindowCreationTest { public class WindowCreationTest {
public static void main(String[] args) { public static void main(String[] args) {
GL gl = null;
DisplayMode[] modes = Display.getAvailableDisplayModes(); DisplayMode[] modes = Display.getAvailableDisplayModes();
System.out.println("Found " + modes.length + " display modes"); System.out.println("Found " + modes.length + " display modes");
//find 640*480*32*100
DisplayMode mode = modes[0];
for(int i=0;i<modes.length;i++) {
if(modes[i].width == 640 &&
modes[i].height == 480 &&
modes[i].bpp == 16 &&
mode.freq <= modes[i].freq) {
mode = modes[i];
}
}
if(mode == null) {
System.out.println("Unable to find displaymode with following features: 640*480*16*60");
System.exit(-1);
}
System.out.println("mode: " + mode);
try { try {
Display.create(mode, 0, 0, 0, false, "WindowCreationTest"); gl = new GL("WindowCreationTest", 50, 50, 320, 240, 32, 0, 0, 0);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try {
gl.create();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Display created"); System.out.println("Display created");
while(!gl.isCloseRequested()) {
gl.tick();
try {
Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
}
}
BaseGL.destroy(); gl.destroy();
} }
} }

View File

@ -35,7 +35,6 @@ import org.lwjgl.Sys;
import org.lwjgl.Display; import org.lwjgl.Display;
import org.lwjgl.DisplayMode; import org.lwjgl.DisplayMode;
import org.lwjgl.input.Controller; import org.lwjgl.input.Controller;
import org.lwjgl.opengl.*;
import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GLU; import org.lwjgl.opengl.GLU;
import org.lwjgl.vector.Vector2f; import org.lwjgl.vector.Vector2f;
@ -84,8 +83,7 @@ public class ControllerCreationTest {
private void setupDisplay(boolean fullscreen) { private void setupDisplay(boolean fullscreen) {
try { try {
Display.create(displayMode, 0, 0, 0, fullscreen, "MouseTest"); gl = new GL("ControllerCreationTest", 50, 50, 640, 480, 32, 0, 0, 0);
gl = new GL();
gl.create(); gl.create();
glu = new GLU(gl); glu = new GLU(gl);
@ -119,7 +117,7 @@ public class ControllerCreationTest {
// recreate display in fullscreen mode // recreate display in fullscreen mode
System.out.print("Destroying display..."); System.out.print("Destroying display...");
BaseGL.destroy(); gl.destroy();
System.out.println("success"); System.out.println("success");
System.out.print("Entering fullscreen mode..."); System.out.print("Entering fullscreen mode...");
@ -141,7 +139,6 @@ public class ControllerCreationTest {
System.out.print("Shutting down..."); System.out.print("Shutting down...");
Controller.destroy(); Controller.destroy();
gl.destroy(); gl.destroy();
BaseGL.destroy();
System.out.println("shutdown complete"); System.out.println("shutdown complete");
} }
@ -164,6 +161,8 @@ public class ControllerCreationTest {
while (Sys.getTime() < endtime) { while (Sys.getTime() < endtime) {
gl.tick();
Controller.poll(); Controller.poll();
//controller is a bit fuzzy //controller is a bit fuzzy
@ -180,7 +179,7 @@ public class ControllerCreationTest {
render(); render();
gl.swapBuffers(); gl.paint();
if (Sys.getTime() - statustime > Sys.getTimerResolution()) { if (Sys.getTime() - statustime > Sys.getTimerResolution()) {
System.out.print("."); System.out.print(".");

View File

@ -35,7 +35,6 @@ import org.lwjgl.Sys;
import org.lwjgl.Display; import org.lwjgl.Display;
import org.lwjgl.DisplayMode; import org.lwjgl.DisplayMode;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.*;
import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GLU; import org.lwjgl.opengl.GLU;
import org.lwjgl.vector.Vector2f; import org.lwjgl.vector.Vector2f;
@ -67,25 +66,19 @@ public class MouseCreationTest {
} }
private void initialize() { private void initialize() {
// find first display mode that allows us 640*480*16 // find first display mode that allows us 640*480*16
DisplayMode[] modes = Display.getAvailableDisplayModes(); DisplayMode[] modes = Display.getAvailableDisplayModes();
for (int i = 0; i < modes.length; i++) { for (int i = 0; i < modes.length; i++) {
if (modes[i].width == 640 if (modes[i].width == 640
&& modes[i].height == 480 && modes[i].height == 480
&& modes[i].bpp >= 16) { && modes[i].bpp >= 16) {
displayMode = modes[i]; displayMode = modes[i];
break; break;
} }
} }
// create display and opengl
setupDisplay(false);
}
private void setupDisplay(boolean fullscreen) {
try { try {
Display.create(displayMode, 0, 0, 0, fullscreen, "MouseTest"); gl = new GL("MouseCreationTest", 50, 50, 640, 480, 32, 0, 0, 0);
gl = new GL();
gl.create(); gl.create();
glu = new GLU(gl); glu = new GLU(gl);
@ -95,11 +88,11 @@ public class MouseCreationTest {
} }
initializeOpenGL(); initializeOpenGL();
} }
private void initializeOpenGL() { private void initializeOpenGL() {
gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
glu.ortho2D(0.0, Display.getWidth(), 0, Display.getHeight()); glu.ortho2D(0.0, 640, 0, 480);
} }
public void executeTest() { public void executeTest() {
@ -119,11 +112,17 @@ public class MouseCreationTest {
// recreate display in fullscreen mode // recreate display in fullscreen mode
System.out.print("Destroying display..."); System.out.print("Destroying display...");
BaseGL.destroy();
System.out.println("success"); System.out.println("success");
System.out.print("Entering fullscreen mode..."); System.out.print("Entering fullscreen mode...");
setupDisplay(true); try {
gl.destroy();
initialize();
Display.setDisplayMode(displayMode);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("success"); System.out.println("success");
@ -141,7 +140,6 @@ public class MouseCreationTest {
System.out.print("Shutting down..."); System.out.print("Shutting down...");
Mouse.destroy(); Mouse.destroy();
gl.destroy(); gl.destroy();
BaseGL.destroy();
System.out.println("shutdown complete"); System.out.println("shutdown complete");
} }
@ -163,6 +161,7 @@ public class MouseCreationTest {
long endtime = Sys.getTime() + Sys.getTimerResolution() * 5; long endtime = Sys.getTime() + Sys.getTimerResolution() * 5;
while (Sys.getTime() < endtime) { while (Sys.getTime() < endtime) {
gl.tick();
Mouse.poll(); Mouse.poll();
@ -171,19 +170,19 @@ public class MouseCreationTest {
if(position.x<0) { if(position.x<0) {
position.x = 0; position.x = 0;
} else if (position.x>Display.getWidth()-60) { } else if (position.x>640-60) {
position.x = Display.getWidth()-60; position.x = 640-60;
} }
if(position.y < 0) { if(position.y < 0) {
position.y = 0; position.y = 0;
} else if (position.y>Display.getHeight()-30) { } else if (position.y>480-30) {
position.y = Display.getHeight()-30; position.y = 480-30;
} }
render(); render();
gl.swapBuffers(); gl.paint();
if (Sys.getTime() - statustime > Sys.getTimerResolution()) { if (Sys.getTime() - statustime > Sys.getTimerResolution()) {
System.out.print("."); System.out.print(".");

View File

@ -31,11 +31,9 @@
*/ */
package org.lwjgl.test.input; package org.lwjgl.test.input;
import org.lwjgl.Display;
import org.lwjgl.DisplayMode; import org.lwjgl.DisplayMode;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.*;
import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GLU; import org.lwjgl.opengl.GLU;
import org.lwjgl.vector.Vector2f; import org.lwjgl.vector.Vector2f;
@ -67,17 +65,6 @@ public class MouseTest {
} }
private void initialize() { private void initialize() {
// 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].width == 640
&& modes[i].height == 480
&& modes[i].bpp >= 16) {
displayMode = modes[i];
break;
}
}
// create display and opengl // create display and opengl
setupDisplay(false); setupDisplay(false);
@ -91,8 +78,7 @@ public class MouseTest {
private void setupDisplay(boolean fullscreen) { private void setupDisplay(boolean fullscreen) {
try { try {
Display.create(displayMode, 0, 0, 0, fullscreen, "MouseTest"); gl = new GL("MouseTest", 50, 50, 640, 480, 32, 0, 0, 0);
gl = new GL();
gl.create(); gl.create();
glu = new GLU(gl); glu = new GLU(gl);
@ -106,7 +92,7 @@ public class MouseTest {
private void initializeOpenGL() { private void initializeOpenGL() {
gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
glu.ortho2D(0.0, Display.getWidth(), 0, Display.getHeight()); glu.ortho2D(0.0, 640, 0, 480);
} }
public void executeTest() { public void executeTest() {
@ -119,7 +105,6 @@ public class MouseTest {
Mouse.destroy(); Mouse.destroy();
Keyboard.destroy(); Keyboard.destroy();
gl.destroy(); gl.destroy();
BaseGL.destroy();
} }
private void createMouse() { private void createMouse() {
@ -132,10 +117,12 @@ public class MouseTest {
} }
private void wiggleMouse() { private void wiggleMouse() {
while (!BaseGL.isCloseRequested()) { while (!gl.isCloseRequested()) {
if(BaseGL.isMinimized()) { if(gl.isMinimized()) {
continue; continue;
} }
gl.tick();
Mouse.poll(); Mouse.poll();
Keyboard.poll(); Keyboard.poll();
@ -149,20 +136,20 @@ public class MouseTest {
if(position.x<0) { if(position.x<0) {
position.x = 0; position.x = 0;
} else if (position.x>Display.getWidth()-60) { } else if (position.x>640-60) {
position.x = Display.getWidth()-60; position.x = 640-60;
} }
if(position.y < 0) { if(position.y < 0) {
position.y = 0; position.y = 0;
} else if (position.y>Display.getHeight()-30) { } else if (position.y>480-30) {
position.y = Display.getHeight()-30; position.y = 480-30;
} }
render(); render();
gl.swapBuffers(); gl.paint();
} }
} }

View File

@ -35,8 +35,7 @@ import org.lwjgl.openal.AL;
import org.lwjgl.openal.eax.*; import org.lwjgl.openal.eax.*;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.Sys; import org.lwjgl.Sys;
import org.lwjgl.Display; import org.lwjgl.opengl.GL;
import org.lwjgl.DisplayMode;
import java.nio.IntBuffer; import java.nio.IntBuffer;
@ -52,6 +51,7 @@ import java.nio.IntBuffer;
public class MovingSoundTest extends BasicTest { public class MovingSoundTest extends BasicTest {
public static float MOVEMENT = 50.00f; public static float MOVEMENT = 50.00f;
private GL gl = new GL("Moving Sound Test", 100, 100, 320, 240, 32, 0 ,0 ,0);
/** /**
* Creates an instance of MovingSoundTest * Creates an instance of MovingSoundTest
@ -69,6 +69,13 @@ public class MovingSoundTest extends BasicTest {
return; return;
} }
try {
gl.create();
} catch (Exception e) {
e.printStackTrace();
}
int lastError; int lastError;
float sourcex = 0.0f, sourcey = 0.0f, sourcez = 0.0f; float sourcex = 0.0f, sourcey = 0.0f, sourcez = 0.0f;
float listenerx = 0.0f, listenery = 0.0f, listenerz = 0.0f; float listenerx = 0.0f, listenery = 0.0f, listenerz = 0.0f;
@ -80,24 +87,6 @@ public class MovingSoundTest extends BasicTest {
//initialize AL, using ALC //initialize AL, using ALC
alInitialize(); alInitialize();
//initialize display
try {
int mode = -1;
DisplayMode[] modes = Display.getAvailableDisplayModes();
for (int i = 0; i < modes.length; i ++) {
if( modes[i].width == 640 &&
modes[i].height == 480 &&
modes[i].bpp >= 16) {
mode = i;
break;
}
}
Display.create(modes[mode], 0, 0, 0, false, "MovingSoundTest");
} catch (Exception e) {
e.printStackTrace();
exit(-1);
}
//initialize keyboard //initialize keyboard
try { try {
Keyboard.create(); Keyboard.create();
@ -175,6 +164,8 @@ public class MovingSoundTest extends BasicTest {
System.out.println("Move source with arrow keys\nMove listener with right shift and arrowkeys\nEnable EAX effect by pressing e (if available)\nExit with ESC"); System.out.println("Move source with arrow keys\nMove listener with right shift and arrowkeys\nEnable EAX effect by pressing e (if available)\nExit with ESC");
while(!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { while(!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
gl.tick();
Keyboard.poll(); Keyboard.poll();
if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
@ -219,6 +210,10 @@ public class MovingSoundTest extends BasicTest {
eaxApplied = !eaxApplied; eaxApplied = !eaxApplied;
} }
} }
if(gl.isCloseRequested()) {
break;
}
try { try {
Thread.sleep(100); Thread.sleep(100);

View File

@ -81,7 +81,7 @@ public class Grass {
} }
// For now let's just pick a mode we're certain to have // For now let's just pick a mode we're certain to have
Display.create(modes[mode], 0, 16, 0, false, "Grass"); Display.setDisplayMode(modes[mode]);
System.out.println("Created display."); System.out.println("Created display.");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -89,7 +89,7 @@ public class Grass {
} }
} }
public static final GL gl = new GL(); public static final GL gl = new GL("LWJGL Grass", 50, 50, 640, 480, 16, 0, 0,0);
public static final GLU glu = new GLU(gl); public static final GLU glu = new GLU(gl);
static { static {
@ -209,12 +209,11 @@ public class Grass {
grsDraw(); grsDraw();
gl.swapBuffers(); gl.paint();
} }
Mouse.destroy(); Mouse.destroy();
Keyboard.destroy(); Keyboard.destroy();
gl.destroy(); gl.destroy();
BaseGL.destroy();
} }
private static float myrand() { private static float myrand() {