JOGL - A “Getting Started” As I Wished
Feb 9th, 2008 by rb
Something I’ll probably never understand is why most “getting started”-, tutorial-, whatever-guides are so bloated and full of text, which only distracts you from the essence of your task. So, if you want to get started rather than getting reading, here you are:
Step 1 - Create and integrate an OpenGL Widget
// Create an OpenGL capable widget GLCanvas canvas = new GLCanvas(new GLCapabilities()); JFrame jframe = new JFrame(); jframe.getContentPane().add(canvas); jframe.setSize(800, 600); jframe.setVisible(true);
Step 2 - Add the .JARs and set the VM parameter to
-Djava.library.path=relative_path_to_the_jogl_native_libraries
for example
-Djava.library.path=lib/
This will prevent you from getting those Exception in thread “main” java.lang.UnsatisfiedLinkError: no jogl in java.library.path messages.
Step 3 - Add your rendering code
// Rendering code comes here canvas.addGLEventListener(new GLEventListener() { public void display(GLAutoDrawable arg0) { GL gl = arg0.getGL(); // Do your drawing in here } public void init(GLAutoDrawable arg0) { GL gl = arg0.getGL(); // Do your setup in here } // There are more methods to implement, but they // are not really necessary for getting started. });
Yes, you’re right!
I also hate these “tutorials” - especially when written by Linux freaks who tend to explain the whole world and non-microsoftness amongst their so-called “tutorial”.
I like a “most minimal(istic) code snippet” first, then some remarks/variations, and then…maybe later, later… some documentation and further explanations.
Good work!
Sven
Good work - I don’t use jogl, (or Java) much, and this was exactly what I needed to get started =).