views:

310

answers:

3

I have an application using OpenGL code. Now I want to convert it into JOGL code. Is it possible to convert OpenGL code to JOGL? What are the changes we have to do?

A: 

This tutorial might be handy. Basically you need to make all the OpenGL global function calls into calls on the proper object instance. This goes for constants too:

glBegin(GL_WHATEVER);

becomes

gl.glBegin(GL.GL_WHATEVER);
unwind
Note that gl is generally of type GL2 now, gotten with drawable.getGL().getGL2(). Similarly, you would instead say GL2.GL_WHATEVER as of recent JOGL versions.
Ricket
A: 

Most opengl functions are named the same in jogl and reside in the GL class. If you know opengl then it will be very easy for you to port it to jogl.

the first steps are:

    GL gl = arg0.getGL();
    GLU glu = arg0.getGLU();

Have a look at some tutorial on the web which will help you to get started.

codymanix
This is assuming arg0 is a type GLAutoDrawable (or maybe GLDrawable?). Furthermore, you would actually need GL2 gl = arg0.getGL().getGL2();
Ricket
+1  A: 

There are the famous suit of Nehe Tutorials for OpenGL, as mentioned above. The best part of this tutorial is that you can view JOGL and Ogl side by side. In Jogl you basically get a thin wrapper around OpenGL with Java syntax, garbage collection and all other libraries available. Making streaming objects and textures over the net and rendering them via OpenGL a breeze, you can also play around with shaders and perform array calculations faster in java using Jogl.

whatnick