0
import java.awt.Button;
import java.awt.Frame;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import com.jogamp.opengl.util.FPSAnimator;
public void init (GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //black
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glEnable(GL.GL_CULL_FACE);
gl.glFrontFace(GL.GL_CCW);
gl.glCullFace(GL.GL_BACK);
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_LINE);
scene = new A1E5Scene();
}
/* Called to indicate the drawing surface has been moved and/or resized */
public void reshape (GLAutoDrawable drawable, int x, int y, int width, int height) {
GL2 gl = drawable.getGL().getGL2();
float fAspect=(float) width/height;
float fovy=60.0f;
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
float top=(float) Math.tan(Math.toRadians(fovy*0.5))*NEAR_CLIP;
float bottom=-top;
float left=fAspect*bottom;
float right=fAspect*top;
gl.glFrustum(left, right, bottom, top, NEAR_CLIP, FAR_CLIP);
gl.glMatrixMode(GL2.GL_MODELVIEW);
}
/* draw */
public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
scene.update();
scene.render(gl);
}
public void dispose(GLAutoDrawable drawable) {
}
我目前正試圖讓eclipse上運行的JOGL,但它發現這部分代碼的問題。它拋出的錯誤與getGL2()有關,似乎可能有一個庫缺失,但我不確定哪一個。日食中的JOGL錯誤
這是我曾經用過的libaries:
/usr/share/java/jogl.jar
/usr/share/java/jogl2.jar
在/ usr/share/java目錄/gluegen-rt.jar
/usr/share/java/gluegen2-rt.jar
/usr/share/java/jogl-1.1.1+dak1.jar
/usr/share/java/jogl-all.jar
任何幫助,將不勝感激。