Witma . Chciałem się troche podszkolic z dodatkowej bibloteki OpenGL dla javy (jogl) i napotkałem następujący problem . Opiszę wszystko co zrobiłem dla jasności :
- Ściągnełem z jakiejś strony plik "jogl-win32" w którym są następujące pliki
- jogl.dll
- jogl.jar
- jogl_cg.dll
- Odpaliłem Eclips i na folderze z projektem który nazywa sie "Test" nacisnełem prawy przycisk myszy
następnie "Build Path" -> "Configure build path" -> " Add External Jar's " - A oto kawałek przykładowego kodu .Eclips nie wyświetla błedu (to czerwone zaznaczenie) , dopiero po kompilacji przy próbie uruchomienia wysypuje się
oto kod :
import java.awt.BorderLayout;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import net.java.games.jogl.Animator;
import net.java.games.jogl.GL;
import net.java.games.jogl.GLCanvas;
import net.java.games.jogl.GLCapabilities;
import net.java.games.jogl.GLDrawable;
import net.java.games.jogl.GLDrawableFactory;
import net.java.games.jogl.GLEventListener;
import net.java.games.jogl.GLU;
public class Test extends JFrame {
// Causes our JOGL app to be animated- that is, it keeps calling display()
static Animator anim = null;
public static void main(String[] args) {
final Test app = new Test();
// Creates the window in another thread
SwingUtilities.invokeLater (
new Runnable() {
public void run() {
// Removes the normal title bar. Most games do this.
app.setUndecorated(true);
app.setVisible(true);
// Goes into fullscreen-exclusive mode
GraphicsDevice gd = GraphicsEnvironment.
getLocalGraphicsEnvironment().getDefaultScreenDevice();
gd.setFullScreenWindow(app);
}
}
);
// Starts the Animator in a new thread.
SwingUtilities.invokeLater (
new Runnable() {
public void run() {
anim.start();
}
}
);
}
public Test() {
// Set the JFrame title
super("JOGL Application");
// Kill the process when the JFrame is closed
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GLCapabilities glCaps = new GLCapabilities();
GLCanvas glCanvas =
GLDrawableFactory.getFactory().createGLCanvas(glCaps);
glCanvas.addGLEventListener(new GameGLEventListener());
// Add the GLCanvas just like we would any Component
getContentPane().add(glCanvas, BorderLayout.CENTER);
anim = new Animator(glCanvas);
}
public class GameGLEventListener implements GLEventListener {
float rotate = 0;
// Only put stuff here that should happen once, at the beginning of the program
public void init(GLDrawable gld) {
GL gl = gld.getGL();
GLU glu = gld.getGLU();
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glViewport(0,0,500,300);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(45.0f, 800.0f / 600.0f, 1.0f, 500.0f);
gl.glMatrixMode(GL.GL_MODELVIEW);
}
// This function will get called repeatedly by the Animator. Think of it as your game loop.
public void display(GLDrawable gld) {
GL gl = gld.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(0.0f,0.0f,-5f);
gl.glRotatef(rotate,0.0f,0.0f,1.0f);
gl.glBegin(GL.GL_TRIANGLES);
gl.glVertex3f( 0.0f, 1.5f,0.0f);
gl.glVertex3f(-1.0f,-1.0f,0.0f);
gl.glVertex3f( 1.0f,-1.0f,0.0f);
gl.glEnd();
rotate = rotate + 0.5f;
}
// This function is only called when the window is reshaped. You probably won't need this.
public void reshape(GLDrawable drawable, int x, int y, int width, int height) {}
// This function is only called when the display settings are changed. Again, not often used.
public void displayChanged(GLDrawable drawable, boolean a, boolean b) {}
}
}
a oto błędy
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jogl in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at net.java.games.jogl.impl.NativeLibLoader$1.run(NativeLibLoader.java:60)
at java.security.AccessController.doPrivileged(Native Method)
at net.java.games.jogl.impl.NativeLibLoader.<clinit>(NativeLibLoader.java:46)
at net.java.games.jogl.impl.GLContext.<clinit>(GLContext.java:51)
at net.java.games.jogl.impl.windows.WindowsGLContextFactory.createGLContext(WindowsGLContextFactory.java:52)
at net.java.games.jogl.GLCanvas.<init>(GLCanvas.java:68)
at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:117)
at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:80)
at Test.<init>(Test.java:64)
at Test.main(Test.java:24)
Jak na moje oko to on nie widzi tej dodatkowej bibloteki JOGL a ja co z tym zrobić :/