1
所以我正在觀看這個關於LWJGL3的教程系列,當OpenGL被初始化爲init函數時,它不會執行函數本身。OpenGL glfwInit()自動執行?
所以在這裏檢查,如果glfwInit()執行,如果沒有它打印出一個錯誤代碼。但是,glfwInit()實際上是如何執行的?
我沒有任何地方調用它,又如何?
public void init() {
if(glfwInit() != GL_TRUE){
System.err.println("Failed to initilaize OpenGL");
}
}
下面
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 Driver implements Runnable {
private Thread thread = new Thread();
private boolean running = false;
public Driver() {
}
private synchronized void start() {
thread.start();
running = true;
}
private synchronized void stop() {
try {
thread.join();
running = false;
} catch(InterruptedException e) {
e.printStackTrace();
}
}
public void run() {
init();
while (running) {
System.out.println("The game is running...");
render();
update();
}
}
public void update() {
}
public void render() {
}
public void init() {
if (glfwInit() != GL_TRUE) {
System.err.println("Failed to initilaize OpenGL");
}
}
public static void main(String[] args) {
Driver game = new Driver();
game.start();
game.run();
}
}