2012-10-09 90 views
2

我想在Mountain Lion上設置JOGL。我想使用它沒有像Eclipse或者IDE這樣的IDE。但我無法完成它的工作。Mountain Lion上的JOGL設置

我所做的:

  • 下載最新從這裏JOGL建設:http://jogamp.org/wiki/index.php/Downloading_and_installing_JOGL#Downloading_the_latest_automatic_build
  • 把文件JOGL-所有本地人,MacOSX的-universal.jar - gluegen-java-src.zip - JOGL -all.jar - gluegen-rt-natives-macosx-universal.jar - jogl-java-src.zip - gluegen-rt.jar(就像它在上面的鏈接中描述的一樣,至少我是這樣理解的)目錄:〜/ jogl
  • 下一步:配置類路徑。在我的系統上,此時CLASSPATH變量爲空。所以我用自己的全名添加了我的jar,比如export CLASSPATH = $ CLASSPATH:〜/ jogl/gluegen-rt-natives -macosx-universal.jar:〜/ jogl/...
  • 試圖編譯測試代碼。錯誤:javax.media.opengl不存在
  • 嘗試更改類路徑以匹配所有具有通配符「*」的文件 - >相同問題
  • 試圖用javac -classpath進行編譯「〜/ jogl/*」源的.java,同樣的錯誤
  • 添加的所有文件seperately到javac的-classpath,同樣的錯誤

這個問題或許非常簡單和明顯的解決,但我不會在這裏問,如果我沒試過幾乎所有的東西得到它工作!

下面是測試代碼我使用:

import java.awt.event.WindowAdapter; 
import java.awt.event.WindowEvent; 

import javax.media.opengl.GLCapabilities; 
import javax.media.opengl.GLProfile; 
import javax.media.opengl.awt.GLCanvas; 
import javax.swing.JFrame; 

public class test 
{ 
    public static void main(String[] args) 
    { 
     // setup OpenGL Version 2 
     GLProfile profile = GLProfile.get(GLProfile.GL2); 
     GLCapabilities capabilities = new GLCapabilities(profile); 

     // The canvas is the widget that's drawn in the JFrame 
     GLCanvas glcanvas = new GLCanvas(capabilities); 
     glcanvas.addGLEventListener(new Renderer()); 
     glcanvas.setSize(300, 300); 

     JFrame frame = new JFrame("Hello World"); 
     frame.getContentPane().add(glcanvas); 

     // shutdown the program on windows close event 
     frame.addWindowListener(new WindowAdapter() { 
      public void windowClosing(WindowEvent ev) { 
       System.exit(0); 
      } 
     }); 

     frame.setSize(frame.getContentPane().getPreferredSize()); 
     frame.setVisible(true); 
    } 
} 

我的系統: - OSX 10.8.2 - 的javac 1.6.0_35

+0

只有gluegen-rt.jar和jogl-all.jar必須位於類路徑中。包含JOGL 2.0和GlueGen的本地庫的JAR必須位於相同的目錄中,但不在類路徑中。 – gouessej

回答

1

試試這個(在同一個JOGL-all.jar在目錄test.java):

javac -classpath jogl-all.jar test.java 

代碼引用未供給,所以我不能讓你的榜樣編譯類叫做渲染器(),但是這有一名的J ar包含javax.media.opengl.*

+1

thx很多這樣做對我來說... 它甚至可以像 一樣的方式與多個罐子一起使用javac -classpath jogl-all.jar:gluegen-rt.jar test.java – japedo