jogl with netbeans gui builder

Hi

I’m new to jogl and thought I would simply add a jogl component to an existing valid swing application that builds and executes fine.

However, if I add a GLJPanel component (from the JOGL Components Palette) on a JFrame the project still builds ok but I now get the runtime error pasted below.

I’m using Netbeans 6.1, with the swing application setup via new-project|java-application

Any help appreciated. Does nayone know of a link to a netbeans gui -jogl tutorial?

Graham

Exception in thread “AWT-EventQueue-0” java.lang.UnsatisfiedLinkError: no jogl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at com.sun.opengl.impl.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:189)
at com.sun.opengl.impl.NativeLibLoader.access$000(NativeLibLoader.java:49)
at com.sun.opengl.impl.NativeLibLoader$DefaultAction.loadLibrary(NativeLibLoader.java:80)
at com.sun.opengl.impl.NativeLibLoader.loadLibrary(NativeLibLoader.java:103)
at com.sun.opengl.impl.NativeLibLoader.access$200(NativeLibLoader.java:49)
at com.sun.opengl.impl.NativeLibLoader$1.run(NativeLibLoader.java:111)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.opengl.impl.NativeLibLoader.loadCore(NativeLibLoader.java:109)
at com.sun.opengl.impl.windows.WindowsGLDrawableFactory.(WindowsGLDrawableFactory.java:60)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:106)
at javax.media.opengl.GLJPanel.initialize(GLJPanel.java:889)
at javax.media.opengl.GLJPanel.paintComponent(GLJPanel.java:488)
at javax.swing.JComponent.paint(JComponent.java:1027)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:564)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5129)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285)
at javax.swing.RepaintManager.paint(RepaintManager.java:1128)
at javax.swing.JComponent.paint(JComponent.java:1013)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1797)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:734)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:679)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:659)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

You are missing the native library setup in your application. I assume you are using the OpenGL pack, so create a SimpleJOGL project instead of a normal java application and create your swing GUI from there.

Just out of curiosity, how would one make a non-JOGL project into a JOGL project? Do you just have to add the native library files into the build path?

If you have installed the OpenGL pack, do the following steps to have JOGL available in a normal java project:

  • Add JOGL to your project’s library list from the library manager
  • Add GLUEGEN-RT to your project’s library list from the library manager
  • Open your project’s properties and switch to the run category and configure your platform:

o For windows enter the following at “VM Options”
-Djava.library.path="${libs.JOGL.classpath}-natives-windows-i586";"${libs.GLUEGEN-RT.classpath}-natives-windows-i586"
o For linux
-Djava.library.path="${libs.JOGL.classpath}-natives-linux-i586":"${libs.GLUEGEN-RT.classpath}-natives-linux-i586"
o For mac
-Djava.library.path="${libs.JOGL.classpath}-natives-macosx-universal":"${libs.GLUEGEN-RT.classpath}-natives-macosx-universal"

Other possiblr platforms are:

linux-amd64
macosx-ppc
solaris-sparc
solaris-sparcv9
solaris-i586
windows-amd64

It is recomended, however, to use the jogl project templates, since you will loose some features otherwise, like working webstart-support.

Hi

Thanks for your reply. As suggested I used the SimpleJOGL as a template and started rebuilding my project.

After creating a new project via the SimpleJOGL template I notice that the only view available via the View|Editors menu item in Netbeans is only “Source”. Thus, for a new jogl project created from the SimpleJOGL do you know how do I get back the gui-builder “Design” visual functionality back, as the Palette is empty?

Graham

Just scrap the Main class and create yourself a new JFrame. Using SimpleJOGL is just for the overall project setup, you don’t have to keep the generated Main class.

Hi

Thanks again.

The SimpleJOGL does not generate the .form file and hence no “design” view. I gather there’s a form generator tool but did as suggested and created a new JFrame and moved over the relevant SmpleJOGL code and it now works fine.

Not a very intuitive process for a newby!!

Cheers

Graham

yes we should provide a SimpleJOGLFormDesigner project template which shows some best practises :wink: I put it on my list, expect it in the next version - thank you for your feedback.

and another tip regarding the form designer:

if you are dropping a JOGL GUI component into the form, NetBeans will instantiate the component with new GLCanvas|JPanel which is often not what you want.
But you can customize the code easily by using the ‘customize code’ option in the context menu of the designed component.

E.g invoking a custom method like createGLCanvas() instead of new GL…() which properly creates and initialises your component (hooks in listeners, configures GLCapabilities etc…) is often what you want.

I think we could even modify the SimpleJOGL template to just have a a valid .form file in it. I will take a look.

great,

but i would prefer to bundle it _additional to the current SimpleJOGL template, you often don’t need a gui builder when all you really want is only a canvas in a jframe :wink:

I think it wouldn’t hurt, since the only change would be using new MainFrame() instead of new JFrame() in the main menu where MainMenu is an GUI builder enabled JFrame subtype which only contains the GLCanvas. This way we would provide

  • SimpleJOGL (fastest)
  • SimpleJOGL (Swing compatible)

otherwise we would have

  • SimpleJOGL (minimal)
  • SimpleJOGL (fastest)
  • SimpleJOGL (Swing compatible)

I would prefer the former, what do you think?

to be honest I don’t know what you mean with minimal vs fastest etc :wink:

I thought to keep the “Simple JOGL Application” template unmodified as it is and provide additional to the template a “Simple JOGL Form Designer Application” which is identical to the former except that it was designed with the NB form designer. (GLCanvas component inside a JFrame component with generated initComonents() method, .form files etc).

Its main purpose is to demonstrate how to use JOGL with the form designer because this may not be strait forward for beginners. It should show how to setup the GLCanvas bean in custom code etc.

Its easier to code the 2 classes than explaining it how to code it ;D

(I try to make the pack ready for nb 6.5 this weekend the build should work now with 6.5 make sure you have latest JAXB libs in the ant path when you try to build it)