forked from StarOpenSource/Engine
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
|
||||
*/
|
||||
private final GLFWErrorCallback errorCallback = GLFWErrorCallback.create(new GLFWErrorCallbackI() {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void invoke(int error, long description) {
|
||||
new WindowingErrorEvent().callEvent(description + " (" + error + ")");
|
||||
}
|
||||
});
|
||||
private GLFWErrorCallback errorCallback = null;
|
||||
|
||||
/**
|
||||
* Initializes this subsystem.
|
||||
|
@ -137,14 +131,22 @@ public final class GlfwSubsystem extends ApiClass {
|
|||
@Override
|
||||
public void initializeApi() {
|
||||
logger.verb("Initializing GLFW");
|
||||
|
||||
try {
|
||||
if (!Miscellaneous.onMainThread()) {
|
||||
logger.crash("Unable to initialize GLFW on a non-main thread", new NotOnMainThreadException(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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
|
||||
switch (GlfwSubsystemConfiguration.getInstance().getPlatform()) {
|
||||
|
@ -164,6 +166,9 @@ public final class GlfwSubsystem extends ApiClass {
|
|||
// Initialize classes
|
||||
internalApi = new GlfwInternalClass();
|
||||
management = new GlfwManagementClass();
|
||||
} catch (UnsatisfiedLinkError error) {
|
||||
logger.crash("Failed to load LWJGL native libraries", error);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
Loading…
Reference in a new issue