From 62b4718ef453cc7ef72bc801d2bed69f52ad1805 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 16 Jun 2024 15:53:07 +0200 Subject: [PATCH] Windows! Not really working! --- .../sosengine/graphics/opengl/classes/Window.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/Window.java b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/Window.java index 97a9288..9874e9e 100644 --- a/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/Window.java +++ b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/Window.java @@ -22,8 +22,11 @@ package de.staropensource.sosengine.graphics.opengl.classes; import de.staropensource.sosengine.base.classes.Vec2i; import de.staropensource.sosengine.base.logging.LoggerInstance; import de.staropensource.sosengine.base.types.LogIssuer; +import de.staropensource.sosengine.graphics.events.GraphicsApiErrorEvent; import lombok.Getter; import org.jetbrains.annotations.NotNull; +import org.lwjgl.opengl.GL; +import org.lwjgl.system.MemoryUtil; import java.util.HashSet; import java.util.Set; @@ -100,6 +103,14 @@ public class Window implements de.staropensource.sosengine.graphics.classes.Wind windowName = title; windowSize = size; - glfwCreateWindow(windowSize.getX(), windowSize.getY(), windowName, NULL, NULL); + long windowId = glfwCreateWindow(windowSize.getX(), windowSize.getY(), windowName, NULL, NULL); + if (windowId == NULL) + new GraphicsApiErrorEvent().callEvent("Unable to create window: ID is null"); + + glfwMakeContextCurrent(windowId); + glfwShowWindow(windowId); + GL.createCapabilities(); + glfwSwapBuffers(windowId); + glfwPollEvents(); } }