Getting GLAutoDrawable from GL4

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

Getting GLAutoDrawable from GL4

siddharth.cmdz
hi,

Is there a way to get the GLAutoDrawable from the GL4 object? I see that the GLAutoDrawable is essentially the canvas. In my design, i pass the GL4 instance to places where they can direcctly call gl functions. However, there are places where it would be nice to get back the GLAutoDrawable from the GL4 instance. Is this possible?

-Siddharth
Reply | Threaded
Open this post in threaded view
|

Re: Getting GLAutoDrawable from GL4

gouessej
Administrator
Hi

Don't pass GL instances, rather use GLContext.getCurrentGL(). Look at how I use JOGL in various engines to have an idea of the good practices. Your design seems to be really wrong. You can store the GLAutoDrawable anyway but it shouldn't be necessary most of the time.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Getting GLAutoDrawable from GL4

siddharth.cmdz
thanks , its just that my view which is basically a GLEventListener is passed GLAutoDrawable. When i want my View to render using framebuffer object, I have GL4 at that point.

Basically I have a "Drawable" that takes in a View, render to an FBO and uses the texture from the FBO for to texture a quad that the Drawable renders. Call it "RenderToTextureDrawable". The Drawable(s) in my case have draw(GL4..) method (as well as other methods like init(GL4 ..), dispose(GL4..) etc )that takes in a GL instance. So its a matter of function signature. And as the View (Which is a GLEventListener) takes in a GLAutoDrawable in its init(..) method, I was wondering if i could get the GLAutoDrawable from GL instance since the drawable needs to init, draw the fbo view.

PS.. this isnt production code, just something for me to experiment with. I stored the instance of the GLAutoDrawable as you mentioned and everything works, however like you mentioned, I would like to refactor that. Since this is just educational, I dont want to use scenegraphs.

I might be reinventing the wheel here because I think I saw APIs for fbos within the GLAutoDrawable (I might be mistaken here).. but thats ok by me ..since this is experimental and learning the APIs.
Reply | Threaded
Open this post in threaded view
|

Re: Getting GLAutoDrawable from GL4

gouessej
Administrator
I don't suggest you to use a scenegraph, I suggest you to look at the source code of some scenegraphs to learn how to implement the same features correctly.

A single GLEventListener can be used by several GLAutoDrawable instances, therefore there is no way to get the GLAutoDrawable from the GLEventListener but you can get the GLAutoDrawable in GLEventListener.display() and pass it to other methods.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Getting GLAutoDrawable from GL4

siddharth.cmdz
thanks goussej.  I'll look into ardor3d, which you had recommended on other threads..unless you have a better suggestion.
Reply | Threaded
Open this post in threaded view
|

Re: Getting GLAutoDrawable from GL4

gouessej
Administrator
You're welcome. Look at the subproject ardor3d-jogl, it contains the JOGL backend.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Getting GLAutoDrawable from GL4

Sven Gothel
Administrator
In reply to this post by siddharth.cmdz
On 11/25/2014 02:18 AM, siddharth.cmdz [via jogamp] wrote:
> hi,
>
> Is there a way to get the GLAutoDrawable from the GL4 object? I see that the
> GLAutoDrawable is essentially the canvas. In my design, i pass the GL4
> instance to places where they can direcctly call gl functions. However, there
> are places where it would be nice to get back the GLAutoDrawable from the GL4
> instance. Is this possible?

Downstream objects as GL <-> GLContext <-> GLDrawable
have no association to an [optional] GLAutoDrawable.

<http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GLAutoDrawable.html>

GLAutoDrawable's may have an is_a or an has_a (delegation)
relationship to GLDrawable:

<http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GLAutoDrawable.html#getDelegatedDrawable%28%29>

GLAutoDrawable has a association to
its upstream UI toolkit object:

<http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GLAutoDrawable.html#getUpstreamWidget%28%29>

I am afraid you would need to pass the GLAutoDrawable instance
to your other methods.

~Sven




signature.asc (828 bytes) Download Attachment