Talk:OpenGL:Tutorials:Java:JOGL:Introduction
<Note from a reader: You may want to use Frame instead of JFrame. JOGL is much slower in lightweight swing applications because GLCanvas is a heavyweight object.>
Also please note that setting fullscreen window is problematic with jogl on version "1.4.2_08-b03". It probably works without the fullscreen part.
Hm, I never considered that. Java 5 has been out for a while though, maybe it is you who should upgrade. :P --Dial-Up 20:54, 14 Jun 2005 (EDT)
Anonymous user wrote: And if you get the following:
"Exception in thread "main" java.lang.UnsatisfiedLinkError: no jogl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)"
Then..... ?
Make sure that the files are in the proper directories. Remember that the "natives" JAR file actually needs to be extracted. --Dial-Up 22:25, 28 Jun 2005 (EDT)
JOGL import problems
This looks like a great tutorial--unforturnately I haven't been able to run it. I've been reading through this tutorial after reading over several others and I've found that some tutorials refer to javax.media.opengl.*; as the proper JOGL import path (such as http://thepanda.org/article/joglness half way down the page) while this tutorial and others refer to net.java.games.jogl.*;. Based on the version I got from the website I can import the javax mentioned above and not the net extension. Under an earlier installation of OpenGL (and yet another tutorial), the opposite was true. In both cases I followed the process of extracting the native JOGL jar to the bin folder while the main jar was placed in the lib/ext folder.
- I figured this issue out: for JOGL version 1.x, the proper import path is
import net.java.games.jogl.*; Version 2.0 requires an import path of javax.media.opengl.*; Unfortunately this doesn't seem to be documented anywhere.
getGLU()
getGLU() is no longer a method of GLAutoDrawable; instead, you just create a new GLU() and it seems to automatically detect what GL to use (if someone could explain that to me, that'd be great)
JOGL in java
Hi this is kasiram i am new in jogl,i use this version jogl-1.1.1-windows-i586,and i am running bellow program this error will come G:\kasi\FUNCTIONS\OpenGL>java HelloWorld Exception in thread "main" java.lang.ExceptionInInitializerError
at HelloWorld.main(HelloWorld.java:18)
Caused by: javax.media.opengl.GLException: No profile available: [GL2, GL2ES2, G L2ES1, GLES2, GLES1, GL2GL3, GL3]
at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:750)
... 1 more
and i add jar files in gluegen-rt.jar,jogl.all.jar,jogl.jar,nativewindow.all.jar,newt.all.jar files in this place and i add class path also
E:\Program Files\Java\jdk1.5.0_06\jre\lib\ext place
and i add ddl files in jogl.ddl,jogl_awt.ddl,jogl_cg.ddl,natinewindow_awt.ddl,nativewindoe_jvm.ddl in the this
E:\Program Files\Java\jdk1.5.0_06\jre\bin place add path also
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; import javax.media.opengl.glu.GLU; import javax.media.opengl.GLBase; import javax.media.opengl.GL2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.glu.GLU;
public class HelloWorld
{
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 );
}
}
class Renderer implements GLEventListener
{
private GLU glu = new GLU();
public void display(GLAutoDrawable gLDrawable)
{
final GL2 gl = gLDrawable.getGL().getGL2();
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(-1.5f, 0.0f, -6.0f);
gl.glBegin(GL2.GL_TRIANGLES);
gl.glVertex3f(0.0f, 1.0f, 0.0f);
gl.glVertex3f(-1.0f, -1.0f, 0.0f);
gl.glVertex3f(1.0f, -1.0f, 0.0f);
gl.glEnd();
gl.glTranslatef(3.0f, 0.0f, 0.0f);
gl.glBegin(GL2.GL_QUADS);
gl.glVertex3f(-1.0f, 1.0f, 0.0f);
gl.glVertex3f(1.0f, 1.0f, 0.0f);
gl.glVertex3f(1.0f, -1.0f, 0.0f);
gl.glVertex3f(-1.0f, -1.0f, 0.0f);
gl.glEnd();
gl.glFlush();
}
public void displayChanged(GLAutoDrawable gLDrawable, boolean modeChanged, boolean deviceChanged)
{
System.out.println("displayChanged called");
}
public void init(GLAutoDrawable gLDrawable)
{
System.out.println("init() called");
GL2 gl = gLDrawable.getGL().getGL2();
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glShadeModel(GL2.GL_FLAT);
}
public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height)
{
System.out.println("reshape() called: x = "+x+", y = "+y+", width = "+width+", height = "+height);
final GL2 gl = gLDrawable.getGL().getGL2();
if (height <= 0) // avoid a divide by zero error!
{
height = 1;
}
final float h = (float) width / (float) height;
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(45.0f, h, 1.0, 20.0);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
public void dispose(GLAutoDrawable arg0) { System.out.println("dispose() called"); } }
how to setup advanced jogl in java tellme and help me
regards.
kasi