Fix LWJGL initialization error handling
This commit is contained in:
parent
25a944baf4
commit
2cf769b599
1 changed files with 37 additions and 32 deletions
|
@ -102,13 +102,7 @@ public final class GlfwSubsystem extends ApiClass {
|
||||||
*
|
*
|
||||||
* @since v1-alpha2
|
* @since v1-alpha2
|
||||||
*/
|
*/
|
||||||
private final GLFWErrorCallback errorCallback = GLFWErrorCallback.create(new GLFWErrorCallbackI() {
|
private GLFWErrorCallback errorCallback = null;
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public void invoke(int error, long description) {
|
|
||||||
new WindowingErrorEvent().callEvent(description + " (" + error + ")");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this subsystem.
|
* Initializes this subsystem.
|
||||||
|
@ -137,14 +131,22 @@ public final class GlfwSubsystem extends ApiClass {
|
||||||
@Override
|
@Override
|
||||||
public void initializeApi() {
|
public void initializeApi() {
|
||||||
logger.verb("Initializing GLFW");
|
logger.verb("Initializing GLFW");
|
||||||
|
try {
|
||||||
if (!Miscellaneous.onMainThread()) {
|
if (!Miscellaneous.onMainThread()) {
|
||||||
logger.crash("Unable to initialize GLFW on a non-main thread", new NotOnMainThreadException(), true);
|
logger.crash("Unable to initialize GLFW on a non-main thread", new NotOnMainThreadException(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set error callback
|
// Set error callback
|
||||||
errorCallback.set();
|
errorCallback = GLFWErrorCallback.create(new GLFWErrorCallbackI() {
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void invoke(int error, long description) {
|
||||||
|
new WindowingErrorEvent().callEvent(description + " (" + error + ")");
|
||||||
|
}
|
||||||
|
}).set();
|
||||||
|
|
||||||
// Set init hints
|
// Set init hints
|
||||||
switch (GlfwSubsystemConfiguration.getInstance().getPlatform()) {
|
switch (GlfwSubsystemConfiguration.getInstance().getPlatform()) {
|
||||||
|
@ -164,6 +166,9 @@ public final class GlfwSubsystem extends ApiClass {
|
||||||
// Initialize classes
|
// Initialize classes
|
||||||
internalApi = new GlfwInternalClass();
|
internalApi = new GlfwInternalClass();
|
||||||
management = new GlfwManagementClass();
|
management = new GlfwManagementClass();
|
||||||
|
} catch (UnsatisfiedLinkError error) {
|
||||||
|
logger.crash("Failed to load LWJGL native libraries", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|
Loading…
Reference in a new issue