Window refactors
This commit is contained in:
@@ -27,11 +27,10 @@ public class Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Window get() {
|
public static Window get() {
|
||||||
if (Window.window == null) {
|
if (window == null) {
|
||||||
Window.window = new Window();
|
window = new Window();
|
||||||
}
|
}
|
||||||
|
return window;
|
||||||
return Window.window;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void blastOff() {
|
public void blastOff() {
|
||||||
@@ -40,13 +39,17 @@ public class Window {
|
|||||||
cleanUp();
|
cleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setup() {
|
||||||
|
logVersion();
|
||||||
|
createWindow();
|
||||||
|
createShader();
|
||||||
|
}
|
||||||
|
|
||||||
private void logVersion() {
|
private void logVersion() {
|
||||||
System.out.println("LWJGL Version: " + Version.getVersion());
|
System.out.println("LWJGL Version: " + Version.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup() {
|
private void createWindow() {
|
||||||
logVersion();
|
|
||||||
|
|
||||||
GLFWErrorCallback.createPrint(System.err).set();
|
GLFWErrorCallback.createPrint(System.err).set();
|
||||||
if (!glfwInit()) throw new IllegalStateException("Unable to initialize GLFW");
|
if (!glfwInit()) throw new IllegalStateException("Unable to initialize GLFW");
|
||||||
|
|
||||||
@@ -57,20 +60,6 @@ public class Window {
|
|||||||
glfwWindow = glfwCreateWindow(this.width, this.height, "Hello World!", NULL, NULL);
|
glfwWindow = glfwCreateWindow(this.width, this.height, "Hello World!", NULL, NULL);
|
||||||
if (glfwWindow == NULL) throw new RuntimeException("Failed to create the GLFW window");
|
if (glfwWindow == NULL) throw new RuntimeException("Failed to create the GLFW window");
|
||||||
|
|
||||||
// glfwSetKeyCallback(
|
|
||||||
// glfwWindow,
|
|
||||||
// (glfwWindow, key, scancode, action, mods) -> {
|
|
||||||
// if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE)
|
|
||||||
// glfwSetWindowShouldClose(glfwWindow, true);
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// try (MemoryStack stack = stackPush()) {
|
|
||||||
// IntBuffer pWidth = stack.mallocInt(1);
|
|
||||||
// IntBuffer pHeight = stack.mallocInt(1);
|
|
||||||
// glfwGetWindowSize(glfwWindow, pWidth, pHeight);
|
|
||||||
// GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
|
|
||||||
// }
|
|
||||||
|
|
||||||
glfwSetCursorPosCallback(glfwWindow, Mouse::cursorPositionCallback);
|
glfwSetCursorPosCallback(glfwWindow, Mouse::cursorPositionCallback);
|
||||||
glfwSetMouseButtonCallback(glfwWindow, Mouse::mouseButtonCallback);
|
glfwSetMouseButtonCallback(glfwWindow, Mouse::mouseButtonCallback);
|
||||||
glfwSetKeyCallback(glfwWindow, Keyboard::keyCallback);
|
glfwSetKeyCallback(glfwWindow, Keyboard::keyCallback);
|
||||||
@@ -82,6 +71,9 @@ public class Window {
|
|||||||
|
|
||||||
GL.createCapabilities();
|
GL.createCapabilities();
|
||||||
glClearColor(0.0f, 0.0f, 2.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 2.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createShader() {
|
||||||
Shader someShader = new Shader();
|
Shader someShader = new Shader();
|
||||||
this.shader = someShader;
|
this.shader = someShader;
|
||||||
someShader.init();
|
someShader.init();
|
||||||
|
|||||||
Reference in New Issue
Block a user