Move graphics initialization code around in method

This commit is contained in:
JeremyStar™ 2024-07-25 04:14:17 +02:00
parent f5af9b34a0
commit 24e26e6a82
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -217,24 +217,25 @@ public final class GraphicsSubsystem implements SubsystemMainClass {
} else
logger.diag(apiName + " is incompatible with this system");
logger.diag("Compatible is/are " + ListFormatter.formatList(compatibleApis));
// Choose last item in list.
if (!compatibleApis.isEmpty()) {
api = registeredApis.get(compatibleApis.getLast());
try {
logger.diag("Initializing Graphics API");
logger.diag("Initialized Graphics API in " + Miscellaneous.measureExecutionTime(() -> api.initializeApi()) + "ms");
} catch (Throwable throwable) {
logger.crash("Graphics API failed to initialize", throwable, true);
throw throwable;
}
return true;
} else {
if (compatibleApis.isEmpty()) {
logger.error("No compatible Graphics API was found");
return false;
} else if (compatibleApis.size() == 1)
logger.diag("Compatible is " + compatibleApis.getFirst());
else
logger.diag("Compatible are " + ListFormatter.formatList(compatibleApis));
// Choose last item in list.
api = registeredApis.get(compatibleApis.getLast());
try {
logger.diag("Initializing Graphics API");
logger.diag("Initialized Graphics API in " + Miscellaneous.measureExecutionTime(() -> api.initializeApi()) + "ms");
} catch (Throwable throwable) {
logger.crash("Graphics API failed to initialize", throwable, true);
throw throwable;
}
return true;
}
/**