Hello all. I have made a program that could run while dragging the window around using just pure java. But for some reason I am unable to do that with LWJGL3.
Here is the code. As you should be able to spot, it runs as normal. However, if I drag the window around my desktop, notice, it stops the program. Now with pure java you can do this. Repainting the screen even while dragging is very doable. But I am unable to "fix" this for LWJGL3.
Any ideas ? Here is the code I am currently working with as a test.
package main;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.system.MemoryUtil.*;
import java.nio.ByteBuffer;
import org.lwjgl.glfw.GLFWvidmode;
public class Main implements Runnable {
private int width = 800;
private int height = 600;
private Thread thread;
private boolean running = false;
private long window;
public void start() {
running = true;
thread = new Thread(this, "Test");
thread.start();
}
private void init() {
if(glfwInit() != GL_TRUE) {
// To Do Later
return;
}
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
window = glfwCreateWindow(width, height, "Test", NULL, NULL);
if(window == NULL) {
// To Do Later
return;
}
ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
glfwSetWindowPos(window, (GLFWvidmode.width(vidmode) - width) / 2, (GLFWvidmode.height(vidmode) - height) / 2);
glfwMakeContextCurrent(window);
glfwShowWindow(window);
}
public void run() {
init();
while(running) {
update();
render();
if(glfwWindowShouldClose(window) == GL_TRUE) {
running = false;
}
}
}
private void update() {
glfwPollEvents();
System.out.println("This is rendering !!!!!");
}
private void render() {
glfwSwapBuffers(window);
}
public static void main(String[] args) {
new Main().start();
}
}