Window refactors
This commit is contained in:
@@ -27,11 +27,10 @@ public class Window {
|
||||
}
|
||||
|
||||
public static Window get() {
|
||||
if (Window.window == null) {
|
||||
Window.window = new Window();
|
||||
if (window == null) {
|
||||
window = new Window();
|
||||
}
|
||||
|
||||
return Window.window;
|
||||
return window;
|
||||
}
|
||||
|
||||
public void blastOff() {
|
||||
@@ -40,13 +39,17 @@ public class Window {
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
logVersion();
|
||||
createWindow();
|
||||
createShader();
|
||||
}
|
||||
|
||||
private void logVersion() {
|
||||
System.out.println("LWJGL Version: " + Version.getVersion());
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
logVersion();
|
||||
|
||||
private void createWindow() {
|
||||
GLFWErrorCallback.createPrint(System.err).set();
|
||||
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);
|
||||
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);
|
||||
glfwSetMouseButtonCallback(glfwWindow, Mouse::mouseButtonCallback);
|
||||
glfwSetKeyCallback(glfwWindow, Keyboard::keyCallback);
|
||||
@@ -82,6 +71,9 @@ public class Window {
|
||||
|
||||
GL.createCapabilities();
|
||||
glClearColor(0.0f, 0.0f, 2.0f, 0.0f);
|
||||
}
|
||||
|
||||
private void createShader() {
|
||||
Shader someShader = new Shader();
|
||||
this.shader = someShader;
|
||||
someShader.init();
|
||||
|
||||
Reference in New Issue
Block a user