We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Processing + OpenGL Library on Equinox (OSGi)
Page Index Toggle Pages: 1
Processing + OpenGL Library on Equinox (OSGi) (Read 4490 times)
Processing + OpenGL Library on Equinox (OSGi)
Apr 6th, 2009, 8:27pm
 
Hi.
I'm developing an OSGi application which integrates Processing and its OpenGL library running on Equinox.  First of all, I've wrapped core.jar file and I can run it as an OSGi bundle without problem.  The OSGi bundle version of core.jar v1.0.3 is available here:

http://cytoscape.wodaklab.org/nexus/content/repositories/snapshots/org/cytoscape/processing-core-osgi/

And for the next step, I've tried to create an OSGi-fied version of OpenGL library for Processing.  The bundle includes all of the native library files and simple test cases to draw cubes, etc. works fine.  I've used maven bundle plugin to generate the bundle and the setting file includes something like the following (this is for linux):

DynamicImport-Package: *
Import-Package: *;resolution:=optional
Export-Package: com.sun.gluegen.runtime, com.sun.opengl.*, javax.media.opengl, javax.media.opengl.glu
Bundle-NativeCode: native/linux/x86/libgluegen-rt.so; native/linux/x86/libjogl_cg.so; native/linux/x86/libjogl_awt.so; native/linux/x86/libjogl.so; osname=linux; processor=x86, native/linux/x86-64/libgluegen-rt.so; native/linux/x86-64/libjogl_cg.so; native/linux/x86-64/libjogl_awt.so; native/linux/x86-64/libjogl.so; osname=linux; processor=x86-64

Embed-Dependency:\
jogl;groupId=net.java.jogl;inline=true,\
gluegen-rt;groupId=net.java.jogl;inline=true,\
processing-opengl;groupId=org.processing;inline=true

Here is the problem.  Although I can use any of the OpenGL classes (like GLCanvas) in my test code, but even a very simple test case (just setup window by size(400, 300, OPENGL)) with Processing always fails with the following error:

Exception in thread "Animation Thread"
java.lang.RuntimeException: You need to use "Import Library" to add processing.opengl.PGraphicsOpenGL to your sketch.
       at processing.core.PApplet.makeGraphics(PApplet.java:1193)
       at processing.core.PApplet.size(PApplet.java:999)
       at processing.core.PApplet.size(PApplet.java:959)
       .

Any idea...?
Re: Processing + OpenGL Library on Equinox (OSGi)
Reply #1 - Apr 6th, 2009, 8:28pm
 
By the way, my simple test case includes import statement:


import processing.core.*;
import processing.opengl.*;

public class ProcessingPanel extends PApplet {

     public void setup() {
           size(400, 300, OPENGL);

     }

     public void draw() {
           background(50);
           fill(255);
           rect(10, 10, frameCount % 100, 10);
     }
}
Re: Processing + OpenGL Library on Equinox (OSGi)
Reply #2 - Apr 7th, 2009, 10:08am
 
Hi.
I've looked into PApplet code and looks like this issue is caused by ClassNotFoundException:

} catch (ClassNotFoundException cnfe) {
     if (cnfe.getMessage().indexOf("processing.opengl.PGraphicsGL") != -1) {
       throw new RuntimeException(openglError +
                                  " (The library .jar file is missing.)");
     } else {
       throw new RuntimeException("You need to use \"Import Library\" " +
                                  "to add " + irenderer + " to your sketch.");
     }

Probably I need to check the core.jar bundle's MANIFEST.MF file.  I'll try again with a new core bundle.

Thanks.
Kei
Re: Processing + OpenGL Library on Equinox (OSGi)
Reply #3 - Apr 8th, 2009, 6:36pm
 
OK, I've figured out why.
Basically, it was the problem in the core.jar bundle.  Since it uses OpenGL library classes implicitly, I need to add:

DynamicImport-Package: *

to import OpenGL related files dynamically.

I'll deploy new OSGi bundles shortly to our maven repository.

Thanks.
Kei
Re: Processing + OpenGL Library on Equinox (OSGi)
Reply #4 - May 23rd, 2009, 12:13am
 
I can't manage nativa library in maven. Can you help me? How do I tell maven to take native so/dll for glugen-rt/jogl?

Code:
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at com.sun.gluegen.runtime.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:91)
at com.sun.gluegen.runtime.NativeLibLoader.access$000(NativeLibLoader.java:50)
at com.sun.gluegen.runtime.NativeLibLoader$1.run(NativeLibLoader.java:69)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.gluegen.runtime.NativeLibLoader.loadGlueGenRT(NativeLibLoader.java:67)
at com.sun.gluegen.runtime.NativeLibrary.ensureNativeLibLoaded(NativeLibrary.java:399)
at com.sun.gluegen.runtime.NativeLibrary.open(NativeLibrary.java:163)
at com.sun.gluegen.runtime.NativeLibrary.open(NativeLibrary.java:129)
at com.sun.opengl.impl.x11.DRIHack.begin(DRIHack.java:109)
at com.sun.opengl.impl.x11.X11GLDrawableFactory.<clinit>(X11GLDrawableFactory.java:99)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:111)
at processing.opengl.PGraphicsOpenGL.allocate(PGraphicsOpenGL.java:172)
at processing.core.PGraphics3D.setSize(PGraphics3D.java:316)
at processing.core.PApplet.makeGraphics(PApplet.java:1165)
at processing.core.PApplet.size(PApplet.java:999)
at processing.core.PApplet.size(PApplet.java:959)
at eu.effetto.pros.App.setup(App.java:25)
at processing.core.PApplet.handleDraw(PApplet.java:1400)
at processing.core.PApplet.run(PApplet.java:1328)
at java.lang.Thread.run(Thread.java:619)
Re: Processing + OpenGL Library on Equinox (OSGi)
Reply #5 - Jun 25th, 2009, 11:47am
 
I've been having a similar issue concerning writing to PDF.  I have a processing app that is embedded in a java application.  I want to write to a PDF file using beingRecord().  Even though I've imported processing.pdf and everything compiles, running the application gives the error below.  What might be causing this? Thanks.
Code:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: You need to use "Import Library" to add processing.pdf.PGraphicsPDF to your sketch.
at processing.core.PApplet.makeGraphics(PApplet.java:1193)
at processing.core.PApplet.createGraphics(PApplet.java:1086)
at processing.core.PApplet.beginRecord(PApplet.java:6713)
at net.sourceforge.topiarytool.treevis.TreeVis.exportTreeImage(TreeVis.java:662)
at net.sourceforge.topiarytool.MainFrame.exportTreeImage(MainFrame.java:149)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at net.sourceforge.tahini.Tahini$ControllerLinker$1.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.AbstractButton.doClick(AbstractButton.java:334)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1051)
at apple.laf.CUIAquaMenuItem.doClick(CUIAquaMenuItem.java:119)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1092)
at java.awt.Component.processMouseEvent(Component.java:5602)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5367)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4068)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
at java.awt.Container.dispatchEventImpl(Container.java:2054)
at java.awt.Window.dispatchEventImpl(Window.java:1801)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Re: Processing + OpenGL Library on Equinox (OSGi)
Reply #6 - Jun 27th, 2009, 2:12pm
 
I hit the same exception while trying to write PDFs from a project in Eclipse. Had to add pdf.jar and itext.jar to the classpath. Not familiar with OSGi, but maybe add those to your bundle?
Re: Processing + OpenGL Library on Equinox (OSGi)
Reply #7 - Jun 27th, 2009, 2:20pm
 
As for the native issues, any shared libraries (DLL/SO) need to be on your library path. The JVM uses the java.library.path System property to find such libraries. You can set this property when the JVM starts by passing the argument like: "-Djava.library.path=/path/to/libs". This property will also generally contain the user's path and the current working directory.

I have no experience with Maven, maybe search "maven java.library.path".
Re: Processing + OpenGL Library on Equinox (OSGi)
Reply #8 - Jun 27th, 2009, 5:46pm
 
Hi.
I've made an example Processing+OpenGL+OSGi+SpringDM project.

http://chianti.ucsd.edu/kono/data/p5gl-osgi-demo.zip

just unpack the archive and type "mvn clean install pax:run"

This does not require any library path options.  However, this only works with Linux and Windows...  I can run some example JOGL code with these bundles, but Processing's OpenGL library crashes on Mac.

Kei

Page Index Toggle Pages: 1