diff --git a/.idea/libraries/lwjgl.xml b/.idea/libraries/lwjgl.xml new file mode 100644 index 0000000..e577f96 --- /dev/null +++ b/.idea/libraries/lwjgl.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/skunkworks.iml b/.idea/skunkworks.iml index b107a2d..781861a 100644 --- a/.idea/skunkworks.iml +++ b/.idea/skunkworks.iml @@ -7,5 +7,6 @@ + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test.java b/Test.java index 442e6b7..60135df 100644 --- a/Test.java +++ b/Test.java @@ -1,7 +1,13 @@ -import com.danitheskunk.skunkworks.Window; +import com.danitheskunk.skunkworks.Engine; +import com.danitheskunk.skunkworks.GLWindow; public class Test { public static void main(String[] args) { - var window = new Window(); + var engine = new Engine(); + var window = engine.openWindow(1280, 720, "Skunkworks"); + + while(!window.shouldClose()) { + window.tick(); + } } } diff --git a/com/danitheskunk/skunkworks/GLWindow.java b/com/danitheskunk/skunkworks/GLWindow.java new file mode 100644 index 0000000..27eef33 --- /dev/null +++ b/com/danitheskunk/skunkworks/GLWindow.java @@ -0,0 +1,58 @@ +package com.danitheskunk.skunkworks; + +import org.lwjgl.glfw.GLFWErrorCallback; +import org.lwjgl.opengl.GL; +import org.lwjgl.opengl.GL11; +import org.lwjgl.stb.STBRectPack; + +import static org.lwjgl.glfw.GLFW.*; +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.system.MemoryUtil.NULL; + +public class GLWindow implements IWindow { + private long window; + private boolean shouldClose; + + public GLWindow(int width, int height, String title) { + GLFWErrorCallback.createPrint(System.err).set(); + if (!glfwInit()) + throw new IllegalStateException("Unable to initialize GLFW"); + + glfwDefaultWindowHints(); + + window = glfwCreateWindow(width, height, title, NULL, NULL); + if (window == NULL) + throw new RuntimeException("Failed to create GLFW window"); + + glfwMakeContextCurrent(window); + glfwSwapInterval(1); //vsync + + glfwShowWindow(window); + + GL.createCapabilities(); + + shouldClose = false; + + System.out.println("Skunkworks window initialised"); + System.out.print("Maximum Texture Size: "); + System.out.println(GL11.glGetInteger(GL_MAX_TEXTURE_SIZE)); + } + + @Override + public boolean shouldClose() { + return shouldClose; + } + + @Override + public void tick() { + if(glfwWindowShouldClose(window)) { + shouldClose = true; + return; + } + + glClearColor(0.1f, 0.2f, 0.3f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glfwSwapBuffers(window); + glfwPollEvents(); + } +} diff --git a/com/danitheskunk/skunkworks/GraphicsBackend.java b/com/danitheskunk/skunkworks/GraphicsBackend.java new file mode 100644 index 0000000..d55d4be --- /dev/null +++ b/com/danitheskunk/skunkworks/GraphicsBackend.java @@ -0,0 +1,5 @@ +package com.danitheskunk.skunkworks; + +public enum GraphicsBackend { + OPENGL +} diff --git a/com/danitheskunk/skunkworks/IWindow.java b/com/danitheskunk/skunkworks/IWindow.java new file mode 100644 index 0000000..f348b03 --- /dev/null +++ b/com/danitheskunk/skunkworks/IWindow.java @@ -0,0 +1,6 @@ +package com.danitheskunk.skunkworks; + +public interface IWindow { + boolean shouldClose(); + void tick(); +} diff --git a/com/danitheskunk/skunkworks/Window.java b/com/danitheskunk/skunkworks/Window.java deleted file mode 100644 index 79b229d..0000000 --- a/com/danitheskunk/skunkworks/Window.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.danitheskunk.skunkworks; - -public class Window { - public Window() { - System.out.println("Skunkworks window initialised"); - } -}