mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 14:35:58 +00:00
Linux: Moved display connection reference count to java. Linux: Load OpenGL library before opening display to work around a crash in NVIDIA drivers.
This commit is contained in:
parent
6fe0155a44
commit
c9fc024fa4
4 changed files with 44 additions and 38 deletions
|
|
@ -50,6 +50,8 @@ import org.lwjgl.input.Keyboard;
|
|||
final class LinuxDisplay implements DisplayImplementation {
|
||||
private static final int NUM_BUTTONS = 3;
|
||||
|
||||
private static int display_connection_usage_count = 0;
|
||||
|
||||
private static PeerInfo peer_info;
|
||||
|
||||
/* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL
|
||||
|
|
@ -62,8 +64,24 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
/**
|
||||
* increment and decrement display usage.
|
||||
*/
|
||||
static native void incDisplay() throws LWJGLException;
|
||||
static native void decDisplay();
|
||||
static void incDisplay() throws LWJGLException {
|
||||
if (display_connection_usage_count == 0) {
|
||||
openDisplay();
|
||||
}
|
||||
display_connection_usage_count++;
|
||||
}
|
||||
|
||||
static void decDisplay() {
|
||||
display_connection_usage_count--;
|
||||
if (display_connection_usage_count < 0)
|
||||
throw new InternalError("display_connection_usage_count < 0: " + display_connection_usage_count);
|
||||
if (display_connection_usage_count == 0) {
|
||||
closeDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
private static native void openDisplay() throws LWJGLException;
|
||||
private static native void closeDisplay();
|
||||
|
||||
public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException {
|
||||
lockAWT();
|
||||
|
|
|
|||
|
|
@ -47,17 +47,17 @@ final class LinuxDisplayPeerInfo extends LinuxPeerInfo {
|
|||
public LinuxDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException {
|
||||
LinuxDisplay.lockAWT();
|
||||
try {
|
||||
LinuxDisplay.incDisplay();
|
||||
GLContext.loadOpenGLLibrary();
|
||||
try {
|
||||
GLContext.loadOpenGLLibrary();
|
||||
LinuxDisplay.incDisplay();
|
||||
try {
|
||||
initDefaultPeerInfo(getHandle(), pixel_format);
|
||||
} catch (LWJGLException e) {
|
||||
GLContext.unloadOpenGLLibrary();
|
||||
LinuxDisplay.decDisplay();
|
||||
throw e;
|
||||
}
|
||||
} catch (LWJGLException e) {
|
||||
LinuxDisplay.decDisplay();
|
||||
GLContext.unloadOpenGLLibrary();
|
||||
throw e;
|
||||
}
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -47,17 +47,17 @@ final class LinuxPbufferPeerInfo extends LinuxPeerInfo {
|
|||
public LinuxPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException {
|
||||
LinuxDisplay.lockAWT();
|
||||
try {
|
||||
LinuxDisplay.incDisplay();
|
||||
GLContext.loadOpenGLLibrary();
|
||||
try {
|
||||
GLContext.loadOpenGLLibrary();
|
||||
LinuxDisplay.incDisplay();
|
||||
try {
|
||||
nInitHandle(getHandle(), width, height, pixel_format);
|
||||
} catch (LWJGLException e) {
|
||||
GLContext.unloadOpenGLLibrary();
|
||||
LinuxDisplay.decDisplay();
|
||||
throw e;
|
||||
}
|
||||
} catch (LWJGLException e) {
|
||||
LinuxDisplay.decDisplay();
|
||||
GLContext.unloadOpenGLLibrary();
|
||||
throw e;
|
||||
}
|
||||
} finally {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue