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.StringTokenizer;
import org.lwjgl.Display;
/**
* $Id$
*

View File

@ -7,7 +7,7 @@
package org.lwjgl.test;
import org.lwjgl.*;
import org.lwjgl.opengl.BaseGL;
import org.lwjgl.opengl.GL;
/**
* @author Brian
@ -15,35 +15,34 @@ import org.lwjgl.opengl.BaseGL;
public class WindowCreationTest {
public static void main(String[] args) {
GL gl = null;
DisplayMode[] modes = Display.getAvailableDisplayModes();
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 {
Display.create(mode, 0, 0, 0, false, "WindowCreationTest");
gl = new GL("WindowCreationTest", 50, 50, 320, 240, 32, 0, 0, 0);
} catch (Exception e) {
e.printStackTrace();
}
try {
gl.create();
} catch (Exception e) {
e.printStackTrace();
}
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.DisplayMode;
import org.lwjgl.input.Controller;
import org.lwjgl.opengl.*;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GLU;
import org.lwjgl.vector.Vector2f;
@ -84,8 +83,7 @@ public class ControllerCreationTest {
private void setupDisplay(boolean fullscreen) {
try {
Display.create(displayMode, 0, 0, 0, fullscreen, "MouseTest");
gl = new GL();
gl = new GL("ControllerCreationTest", 50, 50, 640, 480, 32, 0, 0, 0);
gl.create();
glu = new GLU(gl);
@ -119,7 +117,7 @@ public class ControllerCreationTest {
// recreate display in fullscreen mode
System.out.print("Destroying display...");
BaseGL.destroy();
gl.destroy();
System.out.println("success");
System.out.print("Entering fullscreen mode...");
@ -141,7 +139,6 @@ public class ControllerCreationTest {
System.out.print("Shutting down...");
Controller.destroy();
gl.destroy();
BaseGL.destroy();
System.out.println("shutdown complete");
}
@ -164,6 +161,8 @@ public class ControllerCreationTest {
while (Sys.getTime() < endtime) {
gl.tick();
Controller.poll();
//controller is a bit fuzzy
@ -180,7 +179,7 @@ public class ControllerCreationTest {
render();
gl.swapBuffers();
gl.paint();
if (Sys.getTime() - statustime > Sys.getTimerResolution()) {
System.out.print(".");

View File

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

View File

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

View File

@ -35,8 +35,7 @@ import org.lwjgl.openal.AL;
import org.lwjgl.openal.eax.*;
import org.lwjgl.input.Keyboard;
import org.lwjgl.Sys;
import org.lwjgl.Display;
import org.lwjgl.DisplayMode;
import org.lwjgl.opengl.GL;
import java.nio.IntBuffer;
@ -52,6 +51,7 @@ import java.nio.IntBuffer;
public class MovingSoundTest extends BasicTest {
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
@ -69,6 +69,13 @@ public class MovingSoundTest extends BasicTest {
return;
}
try {
gl.create();
} catch (Exception e) {
e.printStackTrace();
}
int lastError;
float sourcex = 0.0f, sourcey = 0.0f, sourcez = 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
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
try {
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");
while(!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
gl.tick();
Keyboard.poll();
if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
@ -219,6 +210,10 @@ public class MovingSoundTest extends BasicTest {
eaxApplied = !eaxApplied;
}
}
if(gl.isCloseRequested()) {
break;
}
try {
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
Display.create(modes[mode], 0, 16, 0, false, "Grass");
Display.setDisplayMode(modes[mode]);
System.out.println("Created display.");
} catch (Exception e) {
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);
static {
@ -209,12 +209,11 @@ public class Grass {
grsDraw();
gl.swapBuffers();
gl.paint();
}
Mouse.destroy();
Keyboard.destroy();
gl.destroy();
BaseGL.destroy();
}
private static float myrand() {