Loading...
Logo
Processing Forum
Hi,

I'm porting a Processing based project to version 2.0 and I have problems with OpenGL.

Namely I'm getting the infamous " OpenGL error 1282 at top endDraw(): invalid operation" and nothing is drawn on the window.

I'm working under mac os 10.6.8, Processing V 2.0b3.

I'm looking for a way to debug my OpenGL code using gDebugger - a free debugging and profiling tool for openGL - but I have not been successful yet.

What I did so far is export the Sketch as a Mac OS application and run it within gDebugger, but the tool does not log any call to OpenGL or any error for that matter.
Moreover if I launch the exported app from the Finder, no window appears (I suspect the OpenGL error 1282 to be the culprit).

In the gDebugger documentation it is advised to run the runtime when debugging a Java or Python program. Thus I tried to run my project with the command line but I can't get it to work.

My sketch is called Runner, after exporting as Application all the dependencies are in 
/Runner/application.macosx/Runner.app/Contents/Resources/Java/

Command I tried:
Copy code
  1. java -cp /Runner/application.macosx/Runner.app/Contents/Resources/Java/* Runner

Copy code
  1. java -cp /Runner/application.macosx/Runner.app/Contents/Resources/Java/* -jar Runner.jar

Copy code
  1. java -cp /Runner/application.macosx/Runner.app/Contents/Resources/Java/* -jar /Runner/application.macosx/Runner.app/Contents/Resources/Java/Runner.jar

Which always results in a
Exception in thread "main" java.lang.NoClassDefFoundError

What are the correct arguments to execute from the command line? (I suspect some arguments must also be set for OpenGL)

Has anybody tried gDebugger with JOGL (I read on this forum that it does partially work, that would be enough for me )  ?

Do you know of any other tools that I could use to debug? I'm using Eclipse to code my project as a Processing library and the Processing editor/run environment only to run the application.

I hope this is the right forum to ask this question, please feel free to move it somewhere else.

Regards.
-
Jonsku

Replies(6)

I was able to run an application exported from 2.0b3 via command line on Windows. The application folder on Windows contains a folder called lib with all the jars needed including the sketch jar. The command I used from the application folder:

java -Djava.ext.dirs=lib -jar lib\test.jar
Hi,
thanks that helped a lot as I could start the program using java.ext.dirs. However, then I faced another problem where the program crashed due to a  java.lang.ClassNotFoundException: com.jogamp.common.type.WriteCloneable

I tried different settings for j ava.ext.dir, the class path and  java.library.path (this should reference the native library for jogl/opengl, which is the same folder as the jars on Mac Os X) without luck.

The class com.jogamp.common.type.WriteCloneable should be in the glugen runtime (glugen-rt.jat)  - see here. But when I looked into the jar archive it was not there... It seems like the export application function of Processing did not copy the right jars. How is that possible?

So finally to make my program run from the command line, I copied the jars from /Processing.app/Contents/Resources/Java/core/library to /Runner/application.macosx/Runner.app/Contents/Resources/Java/
I can now also run the exported application directly from Finder.

Here is the java command line I used : 
Copy code
  1. java -Djava.ext.dirs=/Runner/application.macosx/Runner.app/Contents/Resources/Java/ -Djava.library.path=/Runner/application.macosx/Runner.app/Contents/Resources/Java Runner
Note:
The -verbose flag can be quite useful to check what jars are loaded.
On other OS the path might need to be enclosed between quotes, check java documentation

I'm still having difficulties running this code in gDebugger because it refuses to run the java runtime directly and when I load the Processing exported application no OpenGL function is logged and the program crash with a BAD_MEMORY_ACCESS


A while ago I tried to do GL debugging on Windows, and gave glslDevil a try, but I had basically the same problem: the debugger wasn't not able to catch the GL calls from the exported application. My guess is that since the code in the application is not native, but Java bytecode that needs to be interpreted by the JVM, then the interception mechanisms in these debuggers don't work properly...

Maybe you could ask on the JOGL forum and get more info.


I also found these classes in the JOGL API: DebugGL2, DebugGL3, etc., which seem to be designed to perform error checking after each GL call.
I found out that there are also OpenGL debugging tools specially for Mac OS X (e.g. OpenGL profiler, it comes with the other Mac OS dev tools such as XCode).

I tried it but without success.

I looked at the JOGL DebugGLX classes and it seems that they work by wrapping another GL context. I tried wrapping the GL context returned by PGL but then I can't make GL call through the Debug object as it is detected as a different context than the one that was initialized (or something like that).

I guess one solution would be to extend PGL and use the wrapper instead. Unfortunately I'm running out of time, and I'll have to take a break from attempting to debug JOGL code this way as I'm not making any progress anymore.

My biggest problem at the moment has to do with FBOs, would you mind taking a look?
From the docs of the DebugGL classes, it seems that all you need is to access the drawable and the GL object:
GL gl = drawable.setGL(new DebugGL(drawable.getGL()));
The drawable object in Processing is currently protected inside PGL, so this would need some re-working of the API in order to access the low-level GL objects. I'll try to do this when fixing issue 1259.


Please post the processing sketch source.
Is your problem related to that you try to update color and vertice data nested?
https://forum.processing.org/topic/glgraphics-issue-opengl-error-1282-at-top-enddraw#25080000001500061