Require OpenGL version during window creation

This commit is contained in:
JeremyStar™ 2024-07-21 21:17:06 +02:00
parent 80478e6a69
commit 8b09290c81
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -68,12 +68,18 @@ public class Window extends de.staropensource.sosengine.graphics.classes.Window
if (!Miscellaneous.onMainThread())
throw new NotOnMainThreadException();
// Set required version and profile
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
// Create window
long identifier = glfwCreateWindow(getSize().getX(), getSize().getY(), getTitle(), MemoryUtil.NULL, MemoryUtil.NULL);
if (identifier == MemoryUtil.NULL) {
new GraphicsApiErrorEvent().callEvent("Unable to create window: Identifier is null");
throw new de.staropensource.sosengine.graphics.opengl.exceptions.WindowCreationFailureException();
}
// Set identifier
setIdentifier(String.valueOf(identifier));
ownContext(identifier); // Own context