Couple of questions

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Couple of questions

tomd
I have the gears demo running in the main window of my existing application, which is a great step forward. Just a couple of questions.

My application is largely static, the scene changes rarely. It seems quite wasteful to redraw the frame over and over when it isn't even changing. But I can't seem to get GLCanvas to paint itself outside of the Animator - I get null pointers because the canvas doesn't appear to be fully initialised. Is it possible to just draw the canvas once, without the animator?

Also, I notice in the gears example, the mouse handler updates xRot amd yRot, which the display callback uses to position the gears. Is that thread safe, there is no synchronisation? Not sure if it is just to keep the example simple, or if there is a reason the two areas of code can't trip each other up?
Reply | Threaded
Open this post in threaded view
|

Re: Couple of questions

Sven Gothel
Administrator
On Friday, November 12, 2010 15:53:18 tomd [via jogamp] wrote:
>
> I have the gears demo running in the main window of my existing application,
> which is a great step forward. Just a couple of questions.
>
> My application is largely static, the scene changes rarely. It seems quite
> wasteful to redraw the frame over and over when it isn't even changing. But
> I can't seem to get GLCanvas to paint itself outside of the Animator - I get
> null pointers because the canvas doesn't appear to be fully initialised. Is
> it possible to just draw the canvas once, without the animator?

It should be possible, sure.
Works with NEWT though.
Wait until the upcoming builds and file a bug report,
look at the wiki how to do this right.
I assume Wade had a similar 'experience'.

>
> Also, I notice in the gears example, the mouse handler updates xRot amd
> yRot, which the display callback uses to position the gears. Is that thread
> safe, there is no synchronisation? Not sure if it is just to keep the
> example simple, or if there is a reason the two areas of code can't trip
> each other up?

Good point.
If you use an animator it's not 'thread safe' correct,
but I guess the demo is coming from the one thread AWT ages :)
So with NEWT it's not safe, however this data is not as critical
as memory references would be - I assume.

~Sven



Reply | Threaded
Open this post in threaded view
|

Re: Couple of questions

Wade Walker
Administrator
In reply to this post by tomd
tomd wrote
My application is largely static, the scene changes rarely. It seems quite wasteful to redraw the frame over and over when it isn't even changing.
Totally true, and that's what we do at my day job with JOGL 1.1.1a and SWT. Game apps update the frame constantly and keep the CPU pegged, but for engineering/science/graphics apps, the user only expects a redraw in response to user action. If you're not touching the mouse, the CPU should be at 0%

I'll try this out with JOGL 2.0 and see if there's something wrong with drawing without an animator.
Reply | Threaded
Open this post in threaded view
|

Re: Couple of questions

tomd
In reply to this post by Sven Gothel
I dropped back to 1.1.1a as someone suggested this was more stable and, to be honest, I am not looking for any real cutting edge features - just a good quality, reliable visualisation of shapes and curves.

The gears demo doesn't seem to make any noticeable difference to the performance of my PC (and it isn't the best PC in the world), so for the sort of things I need to do it will probably be OK.

With thread safety, I agree that if xRot gets corrupted one in a million times it probably doesn't matter too much because it will correct itself next frame. Unless it causes a serious exception somewhere, which is unlikely. I will synchronize to be on the safe side.

Thanks for the help, I am starting to like JOGL :)
Reply | Threaded
Open this post in threaded view
|

Re: Couple of questions

Wade Walker
Administrator
I did a test of JOGL 2 with no animator, and it seems to work fine. The attached file draws a single triangle, and only redraws it when the window is reshaped or something is dragged in front of it.

OneTriangle.java

To build this example, just put it in a project with swt.jar (from http://www.eclipse.org/swt/) and the JOGL 2 JAR and DLL files for your platform. Here's how it looks on CentOS 5.4:



It works on Windows 7/Vista/XP too (except for some XP systems that suffer from bug 429 http://jogamp.org/bugzilla/show_bug.cgi?id=429).
Reply | Threaded
Open this post in threaded view
|

Re: Couple of questions

Martin
In reply to this post by tomd
When designing Jzy3d [0], I have also relied on the "repaint-on-demand" model as you wish to do for your project.

As mentionned in an earlier post [1], when porting to JOGL 2, all calls to GLAutoDrawable.reshape() (that should be performed when you either hide/show your window, resize it, or uncover it with another window) are locked somewhere, and mysteriously unlocked by a mouse click.

I don't really know if it is a synchronization issue in Jzy3d, but it did not happen with Jogl1.1.1-rc3. Since I haven't found working demos not using the Animator, I have added an Animator for the AWT canvas. Since I still encounter bugs with Swing canvas, I can't say that much about it.

Martin

[0] http://code.google.com/p/jzy3d
[1] http://jogamp.762907.n3.nabble.com/Port-to-JOGL2-questions-td1845722.html, see point (5)