Posted by
ac on
May 12, 2013; 10:56pm
URL: https://forum.jogamp.org/synchronization-issues-tp4029115p4029153.html
Hello gouessej,
I followed your suggestion of using (GLCanvas/GLWindow).invoke(), and in order to do so I looked at the rendering framework in Ardor3D (FrameHandler, JoglCanvasRenderer, JoglRenderer, etc).
I put the code I wrote so far in the following test program (which is part of a self-contained Eclipse project on github where I started committing this and other jogl-related "test cases"):
https://github.com/codeanticode/jogl2-tests/blob/master/src/test/applet/InvApplet.javaand although it seems that I'm close to solve the problem, I'm currently stumped with an issue that maybe you can help me with. I get the animation thread running without any errors, using either AWT or NEWT, and I'm able to execute my custom OpenGL code through the invoke() method. On Windows 7, the output appears without any glitches and running smoothly (I tried 2.0-RC11 and 2.0-b982).
However, there is something strange happening on OSX (running 10.8.3). The frame starts by clearing the screen with a red color, and then proceeds to enable the shader program that does all the work (I'm still using the raymarching effect I mentioned at the beginning). However, the output of the shader is never displayed, only a solid red screen as it results from the glClear() call. But if in the initGL() function I replace the lines:
applet.setLayout(new BorderLayout());
applet.add(newtCanvas, BorderLayout.CENTER);
with:
newtWindow.setSize(applet.width, applet.height);
newtWindow.setVisible(true);
then I see a separate NEWT window showing the ongoing shader rendering correctly. I believe I understand why is this happening: the newt windows doesn't get attached to the applet object, so it is all by itself. I though that maybe the problem is the unusual applet->frame structure of this program, but if I attach the newtCanvas to the frame instead, I still get the red screen.
I'm perplexed by the fact that the effect of the glClear() call is visible, but the rest of the frame rendering is not, unless the NEWT window is detached from the applet/frame. Since I'm not getting any error messages, and tried several combinations of things already (AWT vs NEWT, different GLCapabilities options, etc) but always with the same result, I'm not sure how to proceed at this point. Any help will be immensely appreciated!
Andres
Pd: I also starting working on an equivalent test program that uses the FPSAnimator instead (
https://github.com/codeanticode/jogl2-tests/blob/master/src/test/applet/AnimApplet.java), but so far I cannot make it work (the screen is not updated), but I will ask about this issue on a separate post.