2015-09-06 1 views
1

code simple exemple dans CGUsingJava2d3d, j'ai problème avecpas jogl en java.library.path dans Eclipse

GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(cap); 

j'ai ajouté des fichiers jar jogl-all, jogl_old et des arguments -Djava.library.path=---- pour lier des fichiers dll de JOGL.

Et, ces fichiers proviennent de

http://jogamp.org/wiki/index.php/Downloading_and_installing_JOGL

(fichiers dll de \ jogamp-toutes les plates-formes \ windows-amd64 \ lib)

Ce code source est juste .... Cas.

package chapter1; 

import java.awt.*; 
import java.awt.event.*; 
import javax.swing.*; 
import net.java.games.jogl.*; 

public class JOGLDemo { 

    public static void main(String[] args) { 
    Frame frame = new Frame("JOGL Demo"); 
    GLCapabilities cap = new GLCapabilities(); 
    GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(cap); 
    canvas.setSize(300, 300); 
    canvas.addGLEventListener(new Renderer()); 
    frame.add(canvas); 
    frame.pack(); 
    frame.addWindowListener(new WindowAdapter() { 
     public void windowClosing(WindowEvent e) { 
     System.exit(0); 
     } 
    }); 
    frame.show(); 
    } 

    static class Renderer implements GLEventListener { 
    private GL gl; 
    private GLU glu; 
    private GLDrawable gldrawable; 

    public void init(GLDrawable drawable) { 
     gl = drawable.getGL(); 
     glu = drawable.getGLU(); 
     this.gldrawable = drawable; 
     gl.glMatrixMode(GL.GL_PROJECTION); 
     gl.glLoadIdentity(); 
     glu.gluOrtho2D(-1.2, 1.2, -1.2, 1.2); 
     gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); 
    }  

    public void display(GLDrawable drawable) { 
     int i; 
     int n = 80; 
     float a = (float)(2*3.1415926535/n); 
     float x; 
     float y; 

     gl.glClear(GL.GL_COLOR_BUFFER_BIT); 
     gl.glColor3f(1.0f,0,0); 
     gl.glBegin(GL.GL_LINE_LOOP); 
     for (i = 0; i < n; i++) { 
     x = (float)Math.cos(i*a); 
     y = (float)Math.sin(i*a); 
     gl.glVertex2f(x, y); 
     } 
     gl.glEnd(); 
     gl.glFlush(); 
    } 

    public void reshape(GLDrawable drawable, int x, int y, int width, 
     int height) {} 
    public void displayChanged(GLDrawable drawable, boolean modeChanged, 
     boolean deviceChanged) {} 
    } 
} 

S'il vous plaît, dites-moi ce que je dois faire plus ou vérifier somthing ..

un bon jour. Merci.

+1

Vous devez ajouter 'jogl-all.jar' et' gluegen-rt.jar' et leurs natifs correspondants, c'est-à-dire pour windows x64 'jogl-all-natifs-windows-amd64.jar' et' gluegen-rt -natives-windows-amd64.jar', cela fonctionne aussi si vous n'ajoutez pas explicitement les indigènes mais vous les laissez juste là avec les deux premiers jar listés. Ps: vous ne devriez pas utiliser OpenGL déconseillé, voici un simple [Triangle de Hello] moderne (https://jogamp.org/wiki/index.php/Jogl_Tutorial#Hello_Triangle) – elect

Répondre

1

Votre code n'a aucune chance de fonctionner, il utilise une ancienne pré-version de JOGL 1. Utilisez à la place com.jogamp.opengl et consultez notre documentation.

Je suis d'accord avec le commentaire de l'élu.