mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 14:35:58 +00:00
*** empty log message ***
This commit is contained in:
parent
895c751ec6
commit
4924c564d5
11 changed files with 168 additions and 76 deletions
|
|
@ -48,11 +48,6 @@ import java.util.Arrays;
|
|||
|
||||
public final class Display {
|
||||
|
||||
static {
|
||||
System.loadLibrary(Sys.getLibraryName());
|
||||
init();
|
||||
}
|
||||
|
||||
/** Has the display been created? */
|
||||
private static boolean created;
|
||||
|
||||
|
|
@ -79,6 +74,11 @@ public final class Display {
|
|||
/** MacOSX platform */
|
||||
public static final int PLATFORM_AGL = 2;
|
||||
|
||||
static {
|
||||
System.loadLibrary(Sys.getLibraryName());
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* No construction allowed.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,8 +26,11 @@ public abstract class Window {
|
|||
System.loadLibrary(Sys.getLibraryName());
|
||||
}
|
||||
|
||||
/** Whether we have a window already */
|
||||
/** The currently created window */
|
||||
private static Window currentWindow;
|
||||
|
||||
/** Whether the window is currently created, ie. has a native peer */
|
||||
private boolean created;
|
||||
|
||||
/** The window's native data structure. On Win32 this is an HWND. */
|
||||
private int handle;
|
||||
|
|
@ -66,7 +69,7 @@ public abstract class Window {
|
|||
* In this abstract base class, no actual window peer is constructed. This should be
|
||||
* done in specialised derived classes.
|
||||
*
|
||||
* Only one Window can be constructed at a time; to create another Window you must
|
||||
* Only one Window can be created() at a time; to create another Window you must
|
||||
* first destroy() the first window.
|
||||
*
|
||||
* @param title The window's title
|
||||
|
|
@ -76,15 +79,12 @@ public abstract class Window {
|
|||
* @throws RuntimeException if you attempt to create more than one window at the same time
|
||||
*/
|
||||
protected Window(String title, int x, int y, int width, int height) {
|
||||
if (currentWindow != null)
|
||||
throw new RuntimeException("Only one LWJGL window may be instantiated at any one time.");
|
||||
this.title = title;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
currentWindow = this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -164,14 +164,40 @@ public abstract class Window {
|
|||
*/
|
||||
private native void swapBuffers();
|
||||
|
||||
/**
|
||||
* Create the window.
|
||||
*/
|
||||
public final void create() throws Exception {
|
||||
if (currentWindow != null)
|
||||
throw new RuntimeException("Only one LWJGL window may be instantiated at any one time.");
|
||||
doCreate();
|
||||
currentWindow = this;
|
||||
created = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the window (derived classes).
|
||||
* @throws Exception
|
||||
*/
|
||||
protected abstract void doCreate() throws Exception;
|
||||
|
||||
/**
|
||||
* Destroy the window.
|
||||
*/
|
||||
public void destroy() {
|
||||
currentWindow = null;
|
||||
public final void destroy() {
|
||||
if (!created)
|
||||
return;
|
||||
doDestroy();
|
||||
nDestroy();
|
||||
currentWindow = null;
|
||||
created = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the window (derived classes)
|
||||
*/
|
||||
protected abstract void doDestroy();
|
||||
|
||||
/**
|
||||
* Natively destroy the window
|
||||
*/
|
||||
|
|
@ -185,10 +211,10 @@ public abstract class Window {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return true if a window has been created
|
||||
* @return true if the window's native peer has been created
|
||||
*/
|
||||
public static boolean isCreated() {
|
||||
return currentWindow != null;
|
||||
public final boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -197,4 +223,20 @@ public abstract class Window {
|
|||
*/
|
||||
public final native void tick();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#finalize()
|
||||
*/
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
|
||||
destroy();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return "Window["+title+"]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ package org.lwjgl.input;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.lwjgl.*;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
/**
|
||||
|
|
@ -249,8 +248,6 @@ public class Keyboard {
|
|||
public static void create() throws Exception {
|
||||
if (created)
|
||||
return;
|
||||
if (!Window.isCreated())
|
||||
throw new Exception("The display has not yet been created.");
|
||||
if (!nCreate())
|
||||
throw new Exception("The keyboard could not be created.");
|
||||
created = true;
|
||||
|
|
|
|||
|
|
@ -101,8 +101,6 @@ public class Mouse {
|
|||
public static void create() throws Exception {
|
||||
if (created)
|
||||
return;
|
||||
if (!Window.isCreated())
|
||||
throw new Exception("The display has not yet been created.");
|
||||
if (!nCreate())
|
||||
throw new Exception("The mouse could not be created.");
|
||||
created = true;
|
||||
|
|
|
|||
|
|
@ -51,16 +51,37 @@ import org.lwjgl.Window;
|
|||
* @author cix_foo <cix_foo@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public abstract class BaseGL extends Window {
|
||||
public class BaseGL extends Window {
|
||||
|
||||
static {
|
||||
System.loadLibrary(Sys.getLibraryName());
|
||||
}
|
||||
|
||||
/** The current rendering context */
|
||||
private static BaseGL currentContext;
|
||||
//private static BaseGL currentContext;
|
||||
|
||||
/** Has the GL been created yet? */
|
||||
private boolean created;
|
||||
|
||||
/** Handle to the native GL rendering context */
|
||||
protected int handle;
|
||||
|
||||
/** Color bits */
|
||||
protected final int color;
|
||||
|
||||
/** Alpha bits */
|
||||
protected final int alpha;
|
||||
|
||||
/** Depth bits */
|
||||
protected final int depth;
|
||||
|
||||
/** Stencil bits */
|
||||
protected final int stencil;
|
||||
|
||||
private int x, y;
|
||||
|
||||
/** Fullscreen */
|
||||
protected final boolean fullscreen;
|
||||
|
||||
/**
|
||||
* Construct a windowed instance of GL. If the underlying OS does not
|
||||
|
|
@ -78,7 +99,14 @@ public abstract class BaseGL extends Window {
|
|||
public BaseGL(String title, int x, int y, int width, int height, int bpp, int alpha, int depth, int stencil) throws Exception {
|
||||
super(title, x, y, width, height);
|
||||
|
||||
nCreate(title, x, y, width, height, false, bpp, alpha, depth, stencil);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.color = bpp;
|
||||
this.alpha = alpha;
|
||||
this.depth = depth;
|
||||
this.stencil = stencil;
|
||||
this.fullscreen = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -92,33 +120,44 @@ public abstract class BaseGL extends Window {
|
|||
public BaseGL(String title, int bpp, int alpha, int depth, int stencil) throws Exception {
|
||||
super(title, 0, 0, Display.getWidth(), Display.getHeight());
|
||||
|
||||
nCreate(title, 0, 0, Display.getWidth(), Display.getHeight(), true, bpp, alpha, depth, stencil);
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.color = bpp;
|
||||
this.alpha = alpha;
|
||||
this.depth = depth;
|
||||
this.stencil = stencil;
|
||||
this.fullscreen = true;
|
||||
|
||||
}
|
||||
|
||||
protected void doCreate() throws Exception {
|
||||
nCreate(x, y, getWidth(), getHeight(), color, alpha, depth, stencil, fullscreen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method to create a windowed GL
|
||||
*/
|
||||
private native void nCreate(String title, int x, int y, int width, int height, boolean fullscreen, int bpp, int alpha, int depth, int stencil) throws Exception;
|
||||
|
||||
/**
|
||||
* Finalizer, marked final. Ensures the window is destroyed.
|
||||
*/
|
||||
public final void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
|
||||
destroy();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.lwjgl.Window#destroy()
|
||||
*/
|
||||
public void destroy() {
|
||||
// Do native destroy first
|
||||
super.destroy();
|
||||
}
|
||||
private native void nCreate(
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int bpp,
|
||||
int alpha,
|
||||
int depth,
|
||||
int stencil,
|
||||
boolean fullscreen) throws Exception;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.lwjgl.Window#doDestroy()
|
||||
*/
|
||||
protected void doDestroy() {
|
||||
nDestroyGL();
|
||||
}
|
||||
|
||||
/**
|
||||
* Natively destroy any GL-related stuff
|
||||
*/
|
||||
private native void nDestroy();
|
||||
private native void nDestroyGL();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ public class GL extends CoreGL implements GLConstants {
|
|||
*/
|
||||
public GL(String title, int x, int y, int width, int height, int bpp, int alpha, int depth, int stencil) throws Exception {
|
||||
super(title, x, y, width, height, bpp, alpha, depth, stencil);
|
||||
determineAvailableExtensions();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -75,9 +74,18 @@ public class GL extends CoreGL implements GLConstants {
|
|||
*/
|
||||
public GL(String title, int bpp, int alpha, int depth, int stencil) throws Exception {
|
||||
super(title, bpp, alpha, depth, stencil);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.lwjgl.opengl.BaseGL#doCreate()
|
||||
*/
|
||||
protected void doCreate() throws Exception {
|
||||
super.doCreate();
|
||||
|
||||
determineAvailableExtensions();
|
||||
}
|
||||
|
||||
|
||||
public native void activeStencilFaceEXT(int face);
|
||||
|
||||
public native void activeTextureARB(int texture);
|
||||
|
|
@ -1573,7 +1581,7 @@ public class GL extends CoreGL implements GLConstants {
|
|||
/**
|
||||
* Determine which extensions are available
|
||||
*/
|
||||
private void determineAvailableExtensions() {
|
||||
public void determineAvailableExtensions() {
|
||||
|
||||
determineAvailableWGLExtensions();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue