我正在使用maven导入jogamp依赖项。
这是pom.xml的内容:
<dependencies>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId>
<version>2.3.2</version>
</dependency>
</dependencies>
下面的代码应创建一个窗口。
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
public class Renderer {
private static GLWindow window = null;
public static void init(){
GLProfile.initSingleton();
GLProfile profile = GLProfile.get(GLProfile.GL2);
GLCapabilities caps = new GLCapabilities(profile);
window = GLWindow.create(caps);
window.setSize(640, 360);
window.setResizable(false);
window.setVisible(true);
}
public static void main(String[] args){
init();
}
}
就我而言,它创建了一个窗口,该窗口一打开就会关闭,并显示Process finished with exit code 0
。我遵循了these instructions,但是即使将joal和jocl支持添加到Maven中也无法正常工作。
答案 0 :(得分:2)
您需要FPSAnimator
public static void init(){
GLProfile.initSingleton();
GLProfile profile = GLProfile.get(GLProfile.GL2);
GLCapabilities caps = new GLCapabilities(profile);
window = GLWindow.create(caps);
window.setSize(640, 360);
window.setResizable(false);
window.setVisible(true);
FPSAnimator animator = new FPSAnimator(window, 30);
animator.start();
}