*** empty log message ***
This commit is contained in:
parent
df0866d4fb
commit
d359a6b7e1
|
@ -4,7 +4,7 @@
|
|||
* To change this generated comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code Template
|
||||
*/
|
||||
package org.lwjgl;
|
||||
package org.lwjgl.opengl;
|
||||
|
||||
/**
|
||||
* This is the abstract class for a Window in LWJGL. LWJGL windows have some
|
||||
|
@ -20,6 +20,10 @@ package org.lwjgl;
|
|||
*
|
||||
* @author foo
|
||||
*/
|
||||
|
||||
import org.lwjgl.Display;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
public final class Window {
|
||||
|
||||
static {
|
||||
|
@ -29,18 +33,6 @@ public final class Window {
|
|||
/** Whether the window is currently created, ie. has a native peer */
|
||||
private static boolean created;
|
||||
|
||||
/** Whether the window is currently minimized */
|
||||
private static boolean minimized;
|
||||
|
||||
/** Whether the window has focus */
|
||||
private static boolean focused = true;
|
||||
|
||||
/** Whether the window has been asked to close by the user or underlying OS */
|
||||
private static boolean closeRequested;
|
||||
|
||||
/** Whether the window is dirty, ie. needs painting */
|
||||
private static boolean dirty;
|
||||
|
||||
/** X coordinate of the window */
|
||||
private static int x;
|
||||
|
||||
|
@ -142,28 +134,31 @@ public final class Window {
|
|||
*/
|
||||
public static boolean isCloseRequested() {
|
||||
assert isCreated();
|
||||
|
||||
boolean currentValue = closeRequested;
|
||||
closeRequested = false;
|
||||
return currentValue;
|
||||
return nIsCloseRequested();
|
||||
}
|
||||
|
||||
private static native boolean nIsCloseRequested();
|
||||
|
||||
/**
|
||||
* @return true if the window is minimized or otherwise not visible
|
||||
*/
|
||||
public static boolean isMinimized() {
|
||||
assert isCreated();
|
||||
return minimized;
|
||||
return nIsMinimized();
|
||||
}
|
||||
|
||||
private static native boolean nIsMinimized();
|
||||
|
||||
/**
|
||||
* @return true if window is focused
|
||||
*/
|
||||
public static boolean isFocused() {
|
||||
assert isCreated();
|
||||
return focused;
|
||||
return nIsFocused();
|
||||
}
|
||||
|
||||
private static native boolean nIsFocused();
|
||||
|
||||
/**
|
||||
* Minimize the game and allow the operating system's default display to become
|
||||
* visible. It is the responsibility of LWJGL's native code to restore the display
|
||||
|
@ -193,15 +188,16 @@ public final class Window {
|
|||
*/
|
||||
public static boolean isDirty() {
|
||||
assert isCreated();
|
||||
return dirty;
|
||||
return nIsDirty();
|
||||
}
|
||||
|
||||
private static native boolean nIsDirty();
|
||||
|
||||
/**
|
||||
* Paint the window. This clears the dirty flag and swaps the buffers.
|
||||
*/
|
||||
public static void paint() {
|
||||
assert isCreated();
|
||||
dirty = false;
|
||||
swapBuffers();
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
package org.lwjgl.test;
|
||||
|
||||
import org.lwjgl.*;
|
||||
import org.lwjgl.opengl.GLWindow;
|
||||
import org.lwjgl.opengl.Window;
|
||||
|
||||
/**
|
||||
* @author Brian
|
||||
|
@ -15,14 +15,11 @@ import org.lwjgl.opengl.GLWindow;
|
|||
public class WindowCreationTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
GLWindow gl = null;
|
||||
|
||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
||||
System.out.println("Found " + modes.length + " display modes");
|
||||
|
||||
try {
|
||||
gl = new GLWindow("WindowCreationTest", 50, 50, 320, 240, 16, 0, 0, 0);
|
||||
gl.create();
|
||||
Window.create("WindowCreationTest", 50, 50, 320, 240, 16, 0, 0, 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -38,6 +35,6 @@ public class WindowCreationTest {
|
|||
}
|
||||
}
|
||||
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,10 +34,9 @@ package org.lwjgl.test.input;
|
|||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.Display;
|
||||
import org.lwjgl.DisplayMode;
|
||||
import org.lwjgl.Window;
|
||||
import org.lwjgl.input.Controller;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GLWindow;
|
||||
import org.lwjgl.opengl.Window;
|
||||
import org.lwjgl.opengl.GLU;
|
||||
import org.lwjgl.vector.Vector2f;
|
||||
|
||||
|
@ -50,10 +49,6 @@ import org.lwjgl.vector.Vector2f;
|
|||
* @version $Revision$
|
||||
*/
|
||||
public class ControllerCreationTest {
|
||||
|
||||
/** OpenGL instance */
|
||||
private GLWindow gl;
|
||||
|
||||
/** position of quad to draw */
|
||||
private Vector2f position = new Vector2f(320.0f, 240.0f);
|
||||
|
||||
|
@ -79,11 +74,10 @@ public class ControllerCreationTest {
|
|||
try {
|
||||
if(fullscreen) {
|
||||
Display.setDisplayMode(displayMode);
|
||||
gl = new GLWindow("ControllerCreationTest", 16, 0, 0, 0);
|
||||
Window.create("ControllerCreationTest", 16, 0, 0, 0);
|
||||
} else {
|
||||
gl = new GLWindow("ControllerCreationTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
Window.create("ControllerCreationTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
}
|
||||
gl.create();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -115,12 +109,12 @@ public class ControllerCreationTest {
|
|||
|
||||
// recreate display in fullscreen mode
|
||||
System.out.print("Destroying display...");
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
System.out.println("success");
|
||||
|
||||
System.out.print("Entering fullscreen mode...");
|
||||
try {
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
initialize(true);
|
||||
Display.setDisplayMode(displayMode);
|
||||
} catch (Exception e) {
|
||||
|
@ -143,7 +137,7 @@ public class ControllerCreationTest {
|
|||
System.out.print("Shutting down...");
|
||||
Display.resetDisplayMode();
|
||||
Controller.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
System.out.println("shutdown complete");
|
||||
}
|
||||
|
||||
|
|
|
@ -32,11 +32,10 @@
|
|||
package org.lwjgl.test.input;
|
||||
|
||||
import org.lwjgl.DisplayMode;
|
||||
import org.lwjgl.Window;
|
||||
import org.lwjgl.input.Controller;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GLWindow;
|
||||
import org.lwjgl.opengl.Window;
|
||||
import org.lwjgl.opengl.GLU;
|
||||
import org.lwjgl.vector.Vector2f;
|
||||
|
||||
|
@ -50,9 +49,6 @@ import org.lwjgl.vector.Vector2f;
|
|||
*/
|
||||
public class ControllerTest {
|
||||
|
||||
/** OpenGL instance */
|
||||
private GLWindow gl;
|
||||
|
||||
/** GLU instance */
|
||||
private GLU glu;
|
||||
|
||||
|
@ -80,8 +76,7 @@ public class ControllerTest {
|
|||
|
||||
private void setupDisplay(boolean fullscreen) {
|
||||
try {
|
||||
gl = new GLWindow("ControllerTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
gl.create();
|
||||
Window.create("ControllerTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
|
@ -104,7 +99,7 @@ public class ControllerTest {
|
|||
|
||||
Controller.destroy();
|
||||
Keyboard.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
}
|
||||
|
||||
private void createController() {
|
||||
|
|
|
@ -50,9 +50,6 @@ public class HWCursorTest {
|
|||
/** Intended deiplay mode */
|
||||
private DisplayMode mode;
|
||||
|
||||
/** GL instance */
|
||||
private GLWindow gl;
|
||||
|
||||
/** GLU instance */
|
||||
private GLU glu;
|
||||
|
||||
|
@ -83,8 +80,7 @@ public class HWCursorTest {
|
|||
mode = findDisplayMode(800, 600, 16);
|
||||
|
||||
// start of in windowed mode
|
||||
gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
|
||||
glInit();
|
||||
|
||||
|
@ -230,11 +226,10 @@ public class HWCursorTest {
|
|||
}
|
||||
cursor.destroy();
|
||||
Mouse.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
|
||||
Display.setDisplayMode(mode);
|
||||
gl = new GLWindow("Test", mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
Window.create("Test", mode.bpp, 0, 0, 0);
|
||||
|
||||
glInit();
|
||||
|
||||
|
@ -257,11 +252,10 @@ public class HWCursorTest {
|
|||
}
|
||||
cursor.destroy();
|
||||
Mouse.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
|
||||
Display.resetDisplayMode();
|
||||
gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
|
||||
glInit();
|
||||
|
||||
|
@ -304,7 +298,7 @@ public class HWCursorTest {
|
|||
cursor.destroy();
|
||||
Mouse.destroy();
|
||||
Display.resetDisplayMode();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,10 +32,9 @@
|
|||
package org.lwjgl.test.input;
|
||||
|
||||
import org.lwjgl.DisplayMode;
|
||||
import org.lwjgl.Window;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GLWindow;
|
||||
import org.lwjgl.opengl.Window;
|
||||
import org.lwjgl.opengl.GLU;
|
||||
import org.lwjgl.vector.Vector2f;
|
||||
|
||||
|
@ -49,9 +48,6 @@ import org.lwjgl.vector.Vector2f;
|
|||
*/
|
||||
public class KeyboardTest {
|
||||
|
||||
/** OpenGL instance */
|
||||
private GLWindow gl;
|
||||
|
||||
/** GLU instance */
|
||||
private GLU glu;
|
||||
|
||||
|
@ -83,9 +79,7 @@ public class KeyboardTest {
|
|||
|
||||
private void setupDisplay(boolean fullscreen) {
|
||||
try {
|
||||
gl = new GLWindow("KeyboardTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
gl.create();
|
||||
|
||||
Window.create("KeyboardTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
|
@ -107,7 +101,7 @@ public class KeyboardTest {
|
|||
wiggleKeyboard();
|
||||
|
||||
Keyboard.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
}
|
||||
|
||||
private void createKeyboard() {
|
||||
|
|
|
@ -34,10 +34,9 @@ package org.lwjgl.test.input;
|
|||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.Display;
|
||||
import org.lwjgl.DisplayMode;
|
||||
import org.lwjgl.Window;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GLWindow;
|
||||
import org.lwjgl.opengl.Window;
|
||||
import org.lwjgl.opengl.GLU;
|
||||
import org.lwjgl.vector.Vector2f;
|
||||
|
||||
|
@ -50,10 +49,6 @@ import org.lwjgl.vector.Vector2f;
|
|||
* @version $Revision$
|
||||
*/
|
||||
public class MouseCreationTest {
|
||||
|
||||
/** OpenGL instance */
|
||||
private GLWindow gl;
|
||||
|
||||
/** GLU instance */
|
||||
private GLU glu;
|
||||
|
||||
|
@ -82,11 +77,10 @@ public class MouseCreationTest {
|
|||
try {
|
||||
if(fullscreen) {
|
||||
Display.setDisplayMode(displayMode);
|
||||
gl = new GLWindow("MouseCreationTest", 16, 0, 0, 0);
|
||||
Window.create("MouseCreationTest", 16, 0, 0, 0);
|
||||
} else {
|
||||
gl = new GLWindow("MouseCreationTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
Window.create("MouseCreationTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
}
|
||||
gl.create();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -123,7 +117,7 @@ public class MouseCreationTest {
|
|||
|
||||
System.out.print("Entering fullscreen mode...");
|
||||
try {
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
initialize(true);
|
||||
Display.setDisplayMode(displayMode);
|
||||
} catch (Exception e) {
|
||||
|
@ -146,7 +140,7 @@ public class MouseCreationTest {
|
|||
System.out.print("Shutting down...");
|
||||
Display.resetDisplayMode();
|
||||
Mouse.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
System.out.println("shutdown complete");
|
||||
}
|
||||
|
||||
|
|
|
@ -32,11 +32,10 @@
|
|||
package org.lwjgl.test.input;
|
||||
|
||||
import org.lwjgl.DisplayMode;
|
||||
import org.lwjgl.Window;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GLWindow;
|
||||
import org.lwjgl.opengl.Window;
|
||||
import org.lwjgl.opengl.GLU;
|
||||
import org.lwjgl.vector.Vector2f;
|
||||
|
||||
|
@ -50,9 +49,6 @@ import org.lwjgl.vector.Vector2f;
|
|||
*/
|
||||
public class MouseTest {
|
||||
|
||||
/** OpenGL instance */
|
||||
private GLWindow gl;
|
||||
|
||||
/** GLU instance */
|
||||
private GLU glu;
|
||||
|
||||
|
@ -80,9 +76,7 @@ public class MouseTest {
|
|||
|
||||
private void setupDisplay(boolean fullscreen) {
|
||||
try {
|
||||
gl = new GLWindow("MouseTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
gl.create();
|
||||
|
||||
Window.create("MouseTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
|
@ -105,7 +99,7 @@ public class MouseTest {
|
|||
|
||||
Mouse.destroy();
|
||||
Keyboard.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
}
|
||||
|
||||
private void createMouse() {
|
||||
|
|
|
@ -31,11 +31,10 @@
|
|||
*/
|
||||
package org.lwjgl.test.openal;
|
||||
|
||||
import org.lwjgl.Window;
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.eax.*;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GLWindow;
|
||||
import org.lwjgl.opengl.Window;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
|
@ -52,7 +51,6 @@ import java.nio.FloatBuffer;
|
|||
public class MovingSoundTest extends BasicTest {
|
||||
|
||||
public static float MOVEMENT = 50.00f;
|
||||
private GLWindow gl = new GLWindow("Moving Sound Test", 100, 100, 320, 240, 32, 0 ,0 ,0);
|
||||
|
||||
/**
|
||||
* Creates an instance of MovingSoundTest
|
||||
|
@ -71,7 +69,7 @@ public class MovingSoundTest extends BasicTest {
|
|||
}
|
||||
|
||||
try {
|
||||
gl.create();
|
||||
Window.create("Moving Sound Test", 100, 100, 320, 240, 32, 0 ,0 ,0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -49,9 +49,6 @@ public class FullScreenWindowedTest {
|
|||
/** Intended deiplay mode */
|
||||
private DisplayMode mode;
|
||||
|
||||
/** GL instance */
|
||||
private GLWindow gl;
|
||||
|
||||
/** GLU instance */
|
||||
private GLU glu;
|
||||
|
||||
|
@ -96,8 +93,7 @@ public class FullScreenWindowedTest {
|
|||
mode = findDisplayMode(800, 600, 16);
|
||||
|
||||
// start of in windowed mode
|
||||
gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
|
||||
glInit();
|
||||
|
||||
|
@ -202,11 +198,10 @@ public class FullScreenWindowedTest {
|
|||
|
||||
try {
|
||||
Keyboard.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
|
||||
Display.setDisplayMode(mode);
|
||||
gl = new GLWindow("Test", mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
Window.create("Test", mode.bpp, 0, 0, 0);
|
||||
|
||||
glInit();
|
||||
|
||||
|
@ -220,11 +215,10 @@ public class FullScreenWindowedTest {
|
|||
if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
|
||||
try {
|
||||
Keyboard.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
|
||||
Display.resetDisplayMode();
|
||||
gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
|
||||
glInit();
|
||||
|
||||
|
@ -282,7 +276,7 @@ public class FullScreenWindowedTest {
|
|||
*/
|
||||
private void cleanup() {
|
||||
Keyboard.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,10 +72,9 @@ public final class Game {
|
|||
}
|
||||
}
|
||||
|
||||
public static final GLWindow gl = new GLWindow("LWJGL Game Example", 16, 0, 0,0);
|
||||
static {
|
||||
try {
|
||||
gl.create();
|
||||
Window.create("LWJGL Game Example", 16, 0, 0,0);
|
||||
System.out.println("Created OpenGL.");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to create OpenGL due to "+e);
|
||||
|
@ -184,7 +183,7 @@ public final class Game {
|
|||
GL.glGetInteger(GL.GL_MAX_TEXTURE_UNITS_ARB, num_tex_units_buf.asIntBuffer());
|
||||
System.out.println("Number of texture units: " + num_tex_units_buf.getInt());
|
||||
// Fix the refresh rate to the display frequency.
|
||||
// gl.wglSwapIntervalEXT(1);
|
||||
// GL.wglSwapIntervalEXT(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,7 +192,7 @@ public final class Game {
|
|||
private static void cleanup() {
|
||||
Keyboard.destroy();
|
||||
Mouse.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
try {
|
||||
Display.resetDisplayMode();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -88,11 +88,9 @@ public class Grass {
|
|||
}
|
||||
}
|
||||
|
||||
public static final GLWindow gl = new GLWindow("LWJGL Grass", 50, 50, 640, 480, 16, 0, 0,0);
|
||||
|
||||
static {
|
||||
try {
|
||||
gl.create();
|
||||
Window.create("LWJGL Grass", 50, 50, 640, 480, 16, 0, 0,0);
|
||||
Keyboard.create();
|
||||
Keyboard.enableBuffer();
|
||||
Mouse.create();
|
||||
|
@ -149,7 +147,7 @@ public class Grass {
|
|||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
program_handle,
|
||||
program_buf);
|
||||
/*gl.getIntegerv(GL.PROGRAM_ERROR_POSITION_NV, Sys.getDirectBufferAddress(int_buf));
|
||||
/*GL.glGetInteger(GL.PROGRAM_ERROR_POSITION_NV, int_buf);
|
||||
System.out.println("error position: " + int_buf.get(0));*/
|
||||
|
||||
genMesh();
|
||||
|
@ -205,7 +203,7 @@ public class Grass {
|
|||
}
|
||||
Mouse.destroy();
|
||||
Keyboard.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
}
|
||||
|
||||
private static float myrand() {
|
||||
|
@ -433,27 +431,6 @@ public class Grass {
|
|||
|
||||
}
|
||||
|
||||
/* private static void ptrDraw()
|
||||
{
|
||||
glRotatef((aslod.angle * 180.0f) / 3.1415f, 0, 1, 0);
|
||||
glTranslatef(0, 4.5, -7.5);
|
||||
glRotatef(-90, 0, 1, 0);
|
||||
glRotatef(-45, 0, 0, 1);
|
||||
|
||||
glMaterialfv(GL.FRONT, GL.AMBIENT, vec4f(.1f,.1f,0,1).v);
|
||||
glMaterialfv(GL.FRONT, GL.DIFFUSE, vec4f(.6f,.6f,.1f,1).v);
|
||||
glMaterialfv(GL.FRONT, GL.SPECULAR, vec4f(1,1,.75f,1).v);
|
||||
glMaterialf(GL.FRONT, GL.SHININESS, 128.f);
|
||||
|
||||
glutSolidTeapot(aslod.value*5);
|
||||
|
||||
gl.rotatef(45, 0, 0, 1);
|
||||
gl.totatef(90, 0, 1, 0);
|
||||
gl.translatef(0, -4.5, 7.5);
|
||||
gl.rotatef(-(aslod.angle * 180.0f) / 3.1415f, 0f, 1f, 0f);
|
||||
|
||||
}
|
||||
*/
|
||||
private static void ptrAnimate(float degree) {
|
||||
aslod.count += degree;
|
||||
aslod.ripple = (float) (java.lang.Math.cos(aslod.count) / 80.0);
|
||||
|
|
|
@ -51,9 +51,6 @@ public class PbufferTest {
|
|||
/** Intended deiplay mode */
|
||||
private DisplayMode mode;
|
||||
|
||||
/** GL instance */
|
||||
private GLWindow gl;
|
||||
|
||||
/** GLU instance */
|
||||
private GLU glu;
|
||||
|
||||
|
@ -98,9 +95,8 @@ public class PbufferTest {
|
|||
mode = findDisplayMode(800, 600, 16);
|
||||
|
||||
// start of in windowed mode
|
||||
gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
// gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
if ((Pbuffer.getPbufferCaps() & Pbuffer.PBUFFER_SUPPORTED) == 0) {
|
||||
System.out.println("No Pbuffer support!");
|
||||
System.exit(1);
|
||||
|
@ -259,11 +255,10 @@ public class PbufferTest {
|
|||
Keyboard.destroy();
|
||||
Pbuffer.releaseContext();
|
||||
pbuffer.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
|
||||
Display.setDisplayMode(mode);
|
||||
gl = new GLWindow("Test", mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
Window.create("Test", mode.bpp, 0, 0, 0);
|
||||
glInit();
|
||||
initPbuffer();
|
||||
|
||||
|
@ -280,11 +275,10 @@ public class PbufferTest {
|
|||
Keyboard.destroy();
|
||||
Pbuffer.releaseContext();
|
||||
pbuffer.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
|
||||
Display.resetDisplayMode();
|
||||
gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
Window.create("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
glInit();
|
||||
initPbuffer();
|
||||
|
||||
|
@ -352,7 +346,7 @@ public class PbufferTest {
|
|||
Keyboard.destroy();
|
||||
Pbuffer.releaseContext();
|
||||
pbuffer.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,10 +72,9 @@ public final class VBOTest {
|
|||
}
|
||||
}
|
||||
|
||||
public static final GLWindow gl = new GLWindow("LWJGL Game Example", 16, 0, 0,0);
|
||||
static {
|
||||
try {
|
||||
gl.create();
|
||||
Window.create("LWJGL Game Example", 16, 0, 0,0);
|
||||
System.out.println("Created OpenGL.");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to create OpenGL due to "+e);
|
||||
|
@ -210,7 +209,7 @@ public final class VBOTest {
|
|||
GL.glDeleteBuffersARB(int_buffer);
|
||||
Keyboard.destroy();
|
||||
Mouse.destroy();
|
||||
gl.destroy();
|
||||
Window.destroy();
|
||||
try {
|
||||
Display.resetDisplayMode();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_lwjgl_Window */
|
||||
|
||||
#ifndef _Included_org_lwjgl_Window
|
||||
#define _Included_org_lwjgl_Window
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Inaccessible static: _00024assertionsDisabled */
|
||||
/* Inaccessible static: created */
|
||||
/* Inaccessible static: minimized */
|
||||
/* Inaccessible static: focused */
|
||||
/* Inaccessible static: closeRequested */
|
||||
/* Inaccessible static: dirty */
|
||||
/* Inaccessible static: x */
|
||||
/* Inaccessible static: y */
|
||||
/* Inaccessible static: width */
|
||||
/* Inaccessible static: height */
|
||||
/* Inaccessible static: title */
|
||||
/* Inaccessible static: color */
|
||||
/* Inaccessible static: alpha */
|
||||
/* Inaccessible static: depth */
|
||||
/* Inaccessible static: stencil */
|
||||
/* Inaccessible static: fullscreen */
|
||||
/* Inaccessible static: class_000240 */
|
||||
/*
|
||||
* Class: org_lwjgl_Window
|
||||
* Method: nSetTitle
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Window_nSetTitle
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Window
|
||||
* Method: minimize
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Window_minimize
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Window
|
||||
* Method: restore
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Window_restore
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Window
|
||||
* Method: swapBuffers
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Window_swapBuffers
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Window
|
||||
* Method: nCreate
|
||||
* Signature: (Ljava/lang/String;IIIIZIIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Window_nCreate
|
||||
(JNIEnv *, jclass, jstring, jint, jint, jint, jint, jboolean, jint, jint, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Window
|
||||
* Method: nDestroy
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Window_nDestroy
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Window
|
||||
* Method: tick
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Window_tick
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -47,7 +47,9 @@
|
|||
#include "extgl.h"
|
||||
#include "checkGLerror.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
extern HDC hdc;
|
||||
#endif
|
||||
|
||||
static inline void * safeGetBufferAddress(JNIEnv *env, jobject buffer) {
|
||||
if (buffer == NULL)
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_lwjgl_opengl_Window */
|
||||
|
||||
#ifndef _Included_org_lwjgl_opengl_Window
|
||||
#define _Included_org_lwjgl_opengl_Window
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Inaccessible static: _00024assertionsDisabled */
|
||||
/* Inaccessible static: created */
|
||||
/* Inaccessible static: x */
|
||||
/* Inaccessible static: y */
|
||||
/* Inaccessible static: width */
|
||||
/* Inaccessible static: height */
|
||||
/* Inaccessible static: title */
|
||||
/* Inaccessible static: color */
|
||||
/* Inaccessible static: alpha */
|
||||
/* Inaccessible static: depth */
|
||||
/* Inaccessible static: stencil */
|
||||
/* Inaccessible static: fullscreen */
|
||||
/* Inaccessible static: class_00024org_00024lwjgl_00024opengl_00024Window */
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: nSetTitle
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetTitle
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: nIsCloseRequested
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsCloseRequested
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: nIsMinimized
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsMinimized
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: nIsFocused
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsFocused
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: minimize
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_minimize
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: restore
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_restore
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: nIsDirty
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsDirty
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: swapBuffers
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: nCreate
|
||||
* Signature: (Ljava/lang/String;IIIIZIIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate
|
||||
(JNIEnv *, jclass, jstring, jint, jint, jint, jint, jboolean, jint, jint, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: nDestroy
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nDestroy
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: tick
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_tick
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -51,8 +51,8 @@ if test "x$JAVA_HOME" = x; then
|
|||
else
|
||||
AC_MSG_RESULT($JAVA_HOME)
|
||||
JAVA_HOME="$JAVA_HOME"
|
||||
CPPFLAGS="$CPPFLAGS -fno-rtti -fno-exceptions -pthread -D_X11 -Wall -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
|
||||
CFLAGS="$CFLAGS -pthread -D_X11 -Wall -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
|
||||
CPPFLAGS="$CPPFLAGS -D_DEBUG -fno-rtti -fno-exceptions -pthread -D_X11 -Wall -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
|
||||
CFLAGS="$CFLAGS -D_DEBUG -pthread -D_X11 -Wall -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
|
||||
fi
|
||||
|
||||
dnl Checks for libraries.
|
||||
|
|
|
@ -10,9 +10,8 @@ NATIVE = \
|
|||
org_lwjgl_input_Keyboard.cpp \
|
||||
org_lwjgl_input_Mouse.cpp \
|
||||
org_lwjgl_input_Cursor.cpp \
|
||||
org_lwjgl_opengl_GLWindow.cpp \
|
||||
org_lwjgl_opengl_Window.cpp \
|
||||
org_lwjgl_opengl_GLCaps.cpp \
|
||||
org_lwjgl_opengl_Pbuffer.cpp \
|
||||
org_lwjgl_Window.cpp \
|
||||
extxcursor.cpp
|
||||
|
||||
|
|
|
@ -70,16 +70,6 @@
|
|||
extern void acquireKeyboard(void);
|
||||
extern void acquirePointer(void);
|
||||
|
||||
/*
|
||||
* destroy the window
|
||||
*/
|
||||
extern void destroyWindow(void);
|
||||
|
||||
/*
|
||||
* create a new X window with the specified visual
|
||||
*/
|
||||
extern void createWindow(JNIEnv *env, Display *disp, int screen, XVisualInfo *vis_info, jstring title, int x, int y, int width, int height, bool fullscreen);
|
||||
|
||||
/*
|
||||
* get the current window width
|
||||
*/
|
||||
|
|
|
@ -1,262 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Light Weight Java Game Library Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* Linux specific window functions.
|
||||
*
|
||||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <jni.h>
|
||||
#include "Window.h"
|
||||
#include "org_lwjgl_Window.h"
|
||||
|
||||
static Atom delete_atom;
|
||||
static Display *current_disp;
|
||||
static Window current_win;
|
||||
static int current_screen;
|
||||
static bool current_fullscreen;
|
||||
static int current_height;
|
||||
static int current_width;
|
||||
|
||||
static bool input_released;
|
||||
|
||||
static void waitMapped(Display *disp, Window win) {
|
||||
XEvent event;
|
||||
|
||||
do {
|
||||
XMaskEvent(disp, StructureNotifyMask, &event);
|
||||
} while ((event.type != MapNotify) || (event.xmap.event != win));
|
||||
}
|
||||
|
||||
static void acquireInput(void) {
|
||||
if (input_released) {
|
||||
acquireKeyboard();
|
||||
acquirePointer();
|
||||
input_released = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void doReleaseInput(void) {
|
||||
releaseKeyboard();
|
||||
releasePointer();
|
||||
input_released = true;
|
||||
}
|
||||
|
||||
void updateInput(void) {
|
||||
if (!input_released) {
|
||||
doReleaseInput();
|
||||
acquireInput();
|
||||
}
|
||||
}
|
||||
|
||||
bool releaseInput(void) {
|
||||
if (current_fullscreen || input_released)
|
||||
return false;
|
||||
doReleaseInput();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isFullscreen(void) {
|
||||
return current_fullscreen;
|
||||
}
|
||||
|
||||
static void handleMessages(JNIEnv *env, jobject window_obj) {
|
||||
XEvent event;
|
||||
while (XPending(current_disp) > 0) {
|
||||
XNextEvent(current_disp, &event);
|
||||
switch (event.type) {
|
||||
case ClientMessage:
|
||||
if ((event.xclient.format == 32) && ((Atom)event.xclient.data.l[0] == delete_atom))
|
||||
env->SetBooleanField(window_obj, env->GetFieldID(env->GetObjectClass(window_obj), "closeRequested", "Z"), JNI_TRUE);
|
||||
break;
|
||||
case FocusOut:
|
||||
releaseInput();
|
||||
env->SetBooleanField(window_obj, env->GetFieldID(env->GetObjectClass(window_obj), "focused", "Z"), JNI_FALSE);
|
||||
break;
|
||||
case FocusIn:
|
||||
acquireInput();
|
||||
env->SetBooleanField(window_obj, env->GetFieldID(env->GetObjectClass(window_obj), "focused", "Z"), JNI_TRUE);
|
||||
break;
|
||||
case MapNotify:
|
||||
env->SetBooleanField(window_obj, env->GetFieldID(env->GetObjectClass(window_obj), "dirty", "Z"), JNI_TRUE);
|
||||
env->SetBooleanField(window_obj, env->GetFieldID(env->GetObjectClass(window_obj), "minimized", "Z"), JNI_FALSE);
|
||||
break;
|
||||
case UnmapNotify:
|
||||
env->SetBooleanField(window_obj, env->GetFieldID(env->GetObjectClass(window_obj), "minimized", "Z"), JNI_TRUE);
|
||||
break;
|
||||
case Expose:
|
||||
// XSetInputFocus(current_disp, current_win, RevertToParent, CurrentTime);
|
||||
env->SetBooleanField(window_obj, env->GetFieldID(env->GetObjectClass(window_obj), "dirty", "Z"), JNI_TRUE);
|
||||
break;
|
||||
case ButtonPress:
|
||||
handleButtonPress(&(event.xbutton));
|
||||
break;
|
||||
case ButtonRelease:
|
||||
handleButtonRelease(&(event.xbutton));
|
||||
break;
|
||||
case MotionNotify:
|
||||
handlePointerMotion(&(event.xmotion));
|
||||
break;
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
handleKeyEvent(&(event.xkey));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void setWindowTitle(const char *title) {
|
||||
XStoreName(current_disp, current_win, title);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Window_nSetTitle
|
||||
(JNIEnv * env, jobject obj, jstring title_obj)
|
||||
{
|
||||
const char * title = env->GetStringUTFChars(title_obj, NULL);
|
||||
setWindowTitle(title);
|
||||
env->ReleaseStringUTFChars(title_obj, title);
|
||||
}
|
||||
|
||||
void createWindow(JNIEnv* env, Display *disp, int screen, XVisualInfo *vis_info, jstring title, int x, int y, int width, int height, bool fullscreen) {
|
||||
Window root_win;
|
||||
Window win;
|
||||
XSetWindowAttributes attribs;
|
||||
Colormap cmap;
|
||||
int attribmask;
|
||||
|
||||
current_disp = disp;
|
||||
current_screen = screen;
|
||||
input_released = false;
|
||||
current_fullscreen = fullscreen;
|
||||
current_width = width;
|
||||
current_height = height;
|
||||
|
||||
root_win = RootWindow(disp, screen);
|
||||
cmap = XCreateColormap(disp, root_win, vis_info->visual, AllocNone);
|
||||
attribs.colormap = cmap;
|
||||
attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask| StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
|
||||
attribs.background_pixel = 0xFF000000;
|
||||
attribmask = CWColormap | CWBackPixel | CWEventMask;
|
||||
if (fullscreen) {
|
||||
attribmask |= CWOverrideRedirect;
|
||||
attribs.override_redirect = True;
|
||||
}
|
||||
win = XCreateWindow(disp, root_win, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs);
|
||||
XFreeColormap(disp, cmap);
|
||||
#ifdef _DEBUG
|
||||
printf("Created window\n");
|
||||
#endif
|
||||
current_win = win;
|
||||
Java_org_lwjgl_Window_nSetTitle(env, NULL, title);
|
||||
XSizeHints * size_hints = XAllocSizeHints();
|
||||
size_hints->flags = PMinSize | PMaxSize;
|
||||
size_hints->min_width = width;
|
||||
size_hints->max_width = width;
|
||||
size_hints->min_height = height;
|
||||
size_hints->max_height = height;
|
||||
XSetWMNormalHints(disp, win, size_hints);
|
||||
XFree(size_hints);
|
||||
delete_atom = XInternAtom(disp, "WM_DELETE_WINDOW", False);
|
||||
XSetWMProtocols(disp, win, &delete_atom, 1);
|
||||
XMapRaised(disp, win);
|
||||
waitMapped(disp, win);
|
||||
XClearWindow(disp, win);
|
||||
XSetInputFocus(current_disp, current_win, RevertToParent, CurrentTime);
|
||||
XSync(disp, True);
|
||||
}
|
||||
|
||||
void destroyWindow() {
|
||||
XDestroyWindow(current_disp, current_win);
|
||||
current_disp = NULL;
|
||||
}
|
||||
|
||||
Display *getCurrentDisplay(void) {
|
||||
return current_disp;
|
||||
}
|
||||
|
||||
int getCurrentScreen(void) {
|
||||
return current_screen;
|
||||
}
|
||||
|
||||
Window getCurrentWindow(void) {
|
||||
return current_win;
|
||||
}
|
||||
|
||||
int getWindowWidth(void) {
|
||||
return current_width;
|
||||
}
|
||||
|
||||
int getWindowHeight(void) {
|
||||
return current_height;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Window
|
||||
* Method: tick
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Window_tick
|
||||
(JNIEnv *env, jobject obj)
|
||||
{
|
||||
handleMessages(env, obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility function to throw an Exception
|
||||
*/
|
||||
void throwException(JNIEnv * env, const char * err)
|
||||
{
|
||||
jclass cls = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(cls, err);
|
||||
env->DeleteLocalRef(cls);
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility function to throw a RuntimeException
|
||||
*/
|
||||
void throwRuntimeException(JNIEnv * env, const char * err)
|
||||
{
|
||||
jclass cls = env->FindClass("java/lang/RuntimeException");
|
||||
env->ThrowNew(cls, err);
|
||||
env->DeleteLocalRef(cls);
|
||||
}
|
|
@ -1,53 +1,282 @@
|
|||
/*
|
||||
/*
|
||||
* Copyright (c) 2002 Light Weight Java Game Library Project
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||
* its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* Base linux functionality for GL.
|
||||
* Linux specific window functions.
|
||||
*
|
||||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <jni.h>
|
||||
#include "extgl.h"
|
||||
#include "Window.h"
|
||||
#include "org_lwjgl_opengl_GLWindow.h"
|
||||
#include "org_lwjgl_opengl_Window.h"
|
||||
|
||||
#define USEGLX13 true
|
||||
|
||||
static GLXContext context = NULL; // OpenGL rendering context
|
||||
static GLXWindow glx_window;
|
||||
|
||||
static Atom delete_atom;
|
||||
static Display *current_disp;
|
||||
static Window current_win;
|
||||
static int current_screen;
|
||||
static bool current_fullscreen;
|
||||
static int current_height;
|
||||
static int current_width;
|
||||
|
||||
static bool input_released;
|
||||
|
||||
static bool dirty;
|
||||
static bool minimized;
|
||||
static bool focused;
|
||||
static bool closerequested;
|
||||
|
||||
static void waitMapped(Display *disp, Window win) {
|
||||
XEvent event;
|
||||
|
||||
do {
|
||||
XMaskEvent(disp, StructureNotifyMask, &event);
|
||||
} while ((event.type != MapNotify) || (event.xmap.event != win));
|
||||
}
|
||||
|
||||
static void acquireInput(void) {
|
||||
if (input_released) {
|
||||
acquireKeyboard();
|
||||
acquirePointer();
|
||||
input_released = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void doReleaseInput(void) {
|
||||
releaseKeyboard();
|
||||
releasePointer();
|
||||
input_released = true;
|
||||
}
|
||||
|
||||
void updateInput(void) {
|
||||
if (!input_released) {
|
||||
doReleaseInput();
|
||||
acquireInput();
|
||||
}
|
||||
}
|
||||
|
||||
bool releaseInput(void) {
|
||||
if (current_fullscreen || input_released)
|
||||
return false;
|
||||
doReleaseInput();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isFullscreen(void) {
|
||||
return current_fullscreen;
|
||||
}
|
||||
|
||||
static void handleMessages() {
|
||||
XEvent event;
|
||||
while (XPending(current_disp) > 0) {
|
||||
XNextEvent(current_disp, &event);
|
||||
switch (event.type) {
|
||||
case ClientMessage:
|
||||
if ((event.xclient.format == 32) && ((Atom)event.xclient.data.l[0] == delete_atom))
|
||||
closerequested = true;
|
||||
break;
|
||||
case FocusOut:
|
||||
releaseInput();
|
||||
focused = false;
|
||||
break;
|
||||
case FocusIn:
|
||||
acquireInput();
|
||||
focused = true;
|
||||
break;
|
||||
case MapNotify:
|
||||
dirty = true;
|
||||
minimized = false;
|
||||
break;
|
||||
case UnmapNotify:
|
||||
minimized = true;
|
||||
break;
|
||||
case Expose:
|
||||
// XSetInputFocus(current_disp, current_win, RevertToParent, CurrentTime);
|
||||
dirty = true;
|
||||
break;
|
||||
case ButtonPress:
|
||||
handleButtonPress(&(event.xbutton));
|
||||
break;
|
||||
case ButtonRelease:
|
||||
handleButtonRelease(&(event.xbutton));
|
||||
break;
|
||||
case MotionNotify:
|
||||
handlePointerMotion(&(event.xmotion));
|
||||
break;
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
handleKeyEvent(&(event.xkey));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void setWindowTitle(const char *title) {
|
||||
XStoreName(current_disp, current_win, title);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetTitle
|
||||
(JNIEnv * env, jclass clazz, jstring title_obj)
|
||||
{
|
||||
const char * title = env->GetStringUTFChars(title_obj, NULL);
|
||||
setWindowTitle(title);
|
||||
env->ReleaseStringUTFChars(title_obj, title);
|
||||
}
|
||||
|
||||
static void createWindow(JNIEnv* env, Display *disp, int screen, XVisualInfo *vis_info, jstring title, int x, int y, int width, int height, bool fullscreen) {
|
||||
dirty = true;
|
||||
focused = true;
|
||||
minimized = false;
|
||||
closerequested = false;
|
||||
|
||||
Window root_win;
|
||||
Window win;
|
||||
XSetWindowAttributes attribs;
|
||||
Colormap cmap;
|
||||
int attribmask;
|
||||
|
||||
current_disp = disp;
|
||||
current_screen = screen;
|
||||
input_released = false;
|
||||
current_fullscreen = fullscreen;
|
||||
current_width = width;
|
||||
current_height = height;
|
||||
|
||||
root_win = RootWindow(disp, screen);
|
||||
cmap = XCreateColormap(disp, root_win, vis_info->visual, AllocNone);
|
||||
attribs.colormap = cmap;
|
||||
attribs.event_mask = ExposureMask | FocusChangeMask | VisibilityChangeMask| StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
|
||||
attribs.background_pixel = 0xFF000000;
|
||||
attribmask = CWColormap | CWBackPixel | CWEventMask;
|
||||
if (fullscreen) {
|
||||
attribmask |= CWOverrideRedirect;
|
||||
attribs.override_redirect = True;
|
||||
}
|
||||
win = XCreateWindow(disp, root_win, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs);
|
||||
XFreeColormap(disp, cmap);
|
||||
#ifdef _DEBUG
|
||||
printf("Created window\n");
|
||||
#endif
|
||||
current_win = win;
|
||||
Java_org_lwjgl_opengl_Window_nSetTitle(env, NULL, title);
|
||||
XSizeHints * size_hints = XAllocSizeHints();
|
||||
size_hints->flags = PMinSize | PMaxSize;
|
||||
size_hints->min_width = width;
|
||||
size_hints->max_width = width;
|
||||
size_hints->min_height = height;
|
||||
size_hints->max_height = height;
|
||||
XSetWMNormalHints(disp, win, size_hints);
|
||||
XFree(size_hints);
|
||||
delete_atom = XInternAtom(disp, "WM_DELETE_WINDOW", False);
|
||||
XSetWMProtocols(disp, win, &delete_atom, 1);
|
||||
XMapRaised(disp, win);
|
||||
waitMapped(disp, win);
|
||||
XClearWindow(disp, win);
|
||||
XSetInputFocus(current_disp, current_win, RevertToParent, CurrentTime);
|
||||
XSync(disp, True);
|
||||
}
|
||||
|
||||
static void destroyWindow() {
|
||||
XDestroyWindow(current_disp, current_win);
|
||||
current_disp = NULL;
|
||||
}
|
||||
|
||||
Display *getCurrentDisplay(void) {
|
||||
return current_disp;
|
||||
}
|
||||
|
||||
int getCurrentScreen(void) {
|
||||
return current_screen;
|
||||
}
|
||||
|
||||
Window getCurrentWindow(void) {
|
||||
return current_win;
|
||||
}
|
||||
|
||||
int getWindowWidth(void) {
|
||||
return current_width;
|
||||
}
|
||||
|
||||
int getWindowHeight(void) {
|
||||
return current_height;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Window
|
||||
* Method: tick
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_tick
|
||||
(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
handleMessages();
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility function to throw an Exception
|
||||
*/
|
||||
void throwException(JNIEnv * env, const char * err)
|
||||
{
|
||||
jclass cls = env->FindClass("java/lang/Exception");
|
||||
env->ThrowNew(cls, err);
|
||||
env->DeleteLocalRef(cls);
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility function to throw a RuntimeException
|
||||
*/
|
||||
void throwRuntimeException(JNIEnv * env, const char * err)
|
||||
{
|
||||
jclass cls = env->FindClass("java/lang/RuntimeException");
|
||||
env->ThrowNew(cls, err);
|
||||
env->DeleteLocalRef(cls);
|
||||
}
|
||||
|
||||
void makeCurrent(void) {
|
||||
if (USEGLX13 && extgl_Extensions.glx.GLX13)
|
||||
glXMakeContextCurrent(getCurrentDisplay(), glx_window, glx_window, context);
|
||||
|
@ -208,8 +437,8 @@ static bool initWindowGLX(JNIEnv *env, Display *disp, int screen, jstring title,
|
|||
* Method: nCreate
|
||||
* Signature: (IIII)Z
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLWindow_nCreate
|
||||
(JNIEnv * env, jobject obj, jstring title, jint x, jint y, jint width, jint height, jint bpp, jint alpha, jint depth, jint stencil, jboolean fullscreen)
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate
|
||||
(JNIEnv * env, jclass clazz, jstring title, jint x, jint y, jint width, jint height, jboolean fullscreen, jint bpp, jint alpha, jint depth, jint stencil)
|
||||
{
|
||||
int screen;
|
||||
Display *disp;
|
||||
|
@ -260,8 +489,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLWindow_nCreate
|
|||
* Method: nDestroy
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLWindow_nDestroyGL
|
||||
(JNIEnv * env, jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nDestroy
|
||||
(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
@ -271,10 +500,71 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLWindow_nDestroyGL
|
|||
* Method: swapBuffers
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLWindow_swapBuffers(JNIEnv * env, jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
dirty = false;
|
||||
if (USEGLX13 && extgl_Extensions.glx.GLX13)
|
||||
glXSwapBuffers(getCurrentDisplay(), glx_window);
|
||||
else
|
||||
glXSwapBuffers(getCurrentDisplay(), getCurrentWindow());
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: minimize
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_minimize
|
||||
(JNIEnv *env, jclass clazz) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: restore
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_restore
|
||||
(JNIEnv *env, jclass clazz) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: nIsDirty
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsDirty
|
||||
(JNIEnv *env, jclass clazz) {
|
||||
return dirty;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: nIsMinimized
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsMinimized
|
||||
(JNIEnv *env, jclass clazz) {
|
||||
return minimized;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: nIsCloseRequested
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsCloseRequested
|
||||
(JNIEnv *, jclass) {
|
||||
bool saved = closerequested;
|
||||
closerequested = false;
|
||||
return saved;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_Window
|
||||
* Method: nIsFocused
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsFocused
|
||||
(JNIEnv *env, jclass clazz) {
|
||||
return focused;
|
||||
}
|
1243
src/native/win32/org_lwjgl_Window.cpp → src/native/win32/org_lwjgl_opengl_Window.cpp
Normal file → Executable file
1243
src/native/win32/org_lwjgl_Window.cpp → src/native/win32/org_lwjgl_opengl_Window.cpp
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue