using GLWindow ?

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

using GLWindow ?

ElJojo
Hi,
I try to use NEWT in my app but I have 2 bugs :
- animation is too fast (like there's no limitation) but I set my animator to 5 fps !
- when I close my app, I get this message :
Exception in thread "AWT-EventQueue-0-AWTAnimator-1" javax.media.opengl.GLException: drawable has invalid handle: WindowsOnscreenWGLDrawable...

I think that comes from my constructor :
public class GLPvwShader extends NewtCanvasAWT implements GLEventListener {
    private Animator animator;

    public GLPvwShader() {
                GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2GL3));
                caps.setBackgroundOpaque(false);
                final GLWindow glWindow = GLWindow.create(caps);
                glWindow.addGLEventListener(this);
                
                animator = new Animator(glWindow);
                animator.setUpdateFPSFrames(5, null);
                animator.start();
                
                setNEWTChild(glWindow);
    }
...

Thank you to tell me what's wrong or missing ?
Reply | Threaded
Open this post in threaded view
|

Re: using GLWindow ?

gouessej
Administrator
Hi

At first, you have misunderstood the effect of AnimatorBase.setUpdateFPSFrames(), it allows to modify the the update rate of the FPS counter, not the real frame rate. Rather use FPSAnimator. This problem has nothing to do with NEWT.

Secondly, please try to reproduce your bug ("invalid handle") with an existing test case or give us a small one.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: using GLWindow ?

ElJojo
I tried :
                animator = new FPSAnimator(25,true);
                glWindow.setAnimator(animator);
but it doesn't work.
I tried :
                animator = new FPSAnimator(25,true);
                animator.add(glWindow);
and it works.
For the second bug, does I need to clean or destroy GLWindow or something else when I close app ?
Reply | Threaded
Open this post in threaded view
|

Re: using GLWindow ?

gouessej
Administrator
ElJojo wrote
I tried :
                animator = new FPSAnimator(25,true);
                glWindow.setAnimator(animator);
but it doesn't work.
I tried :
                animator = new FPSAnimator(25,true);
                animator.add(glWindow);
and it works.
It's not a bug but I understand it is a bit annoying. Setting the animator of a GLAutoDrawable doesn't automatically add this drawable to the list of animated drawables of this animator.

ElJojo wrote
For the second bug, does I need to clean or destroy GLWindow or something else when I close app ?
Stop your animator. If you use Java Web Start, you might be forced to call System.exit(0) even though you stop your animator.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: using GLWindow ?

Sven Gothel
Administrator
On 12/01/2012 05:38 PM, gouessej [via jogamp] wrote:

>     ElJojo wrote
>     I tried :
>
>                     animator = new FPSAnimator(25,true);
>                     glWindow.setAnimator(animator);
>
>     but it doesn't work.
>     I tried :
>
>                     animator = new FPSAnimator(25,true);
>                     animator.add(glWindow);
>
>     and it works.
>
> It's not a bug but I understand it is a bit annoying. Setting the animator of
> a GLAutoDrawable doesn't automatically add this drawable to the list of
> animated drawables of this animator.
Yes, the GLAutoDrawable API 'hook' is for the Animator implementation,
this is described in the API doc itself - please read.

>
>     ElJojo wrote
>     For the second bug, does I need to clean or destroy GLWindow or something
>     else when I close app ?
>
> Stop your animator.

Yup, read API doc of Animator - this is related to the animator Thread,
which is a non daemon thread.

Note: You can use Animator at 'native' FPS speed of the monitor update,
if you set v-sync true via your GL object's setSwapInterval(int) - read API doc.

~Sven


signature.asc (909 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: using GLWindow ?

ElJojo
I read the Javadoc but it's not really helpfull : I took many days to understand there are functions specific to jogamp and others which are just translation from C. Examples are diffcult to understood because they mostly come from a project with UITestCase extention that make confusion with Assert...
As a user, I would prefer to have more general examples where I can identify clearly the use of jogamp functions. For example, I search for an example on how to use texture on a simple quad with shaders and I needed to understand and adapt from C (OpenGL superbible) combined with 5-6 examples from the web.
The most confusing thing is the mix of OpenGL versions and the mix of jogl, lwjgl, etc in the examples I search on the web because I didn't have enough informations on the jogl documentation.
You do a very good job guys and I just explain my beginner vision. Thanks for all and continue this way.

I tried to put the "animator.stop" in dispose() but I didn't saw a call to this function !
adi
Reply | Threaded
Open this post in threaded view
|

Re: using GLWindow ?

adi
Hold it simple.

Do
 
GLAutoDrawable glDrawable = display.getGLDrawable();
(display.getDrawable() gets the configured GLWindow)

then do a

Animator anim = new Animator( glDrawable );
anim.start();

Later you can (eg. with a key ESC or so) make a
anim.stop();

Where is the problem?