Login  Register

Re: Can JOGL be used without requiring GLAutoDrawable instances?

Posted by Sven Gothel on Aug 22, 2015; 10:17am
URL: https://forum.jogamp.org/Can-JOGL-be-used-without-requiring-GLAutoDrawable-instances-tp4034953p4035107.html

On 08/22/2015 04:28 AM, xghost [via jogamp] wrote:

(Ignoring the 'competitor' thingy, since I dunno)

>     Sven Gothel wrote
>     Just to make this long story maybe shorter:
>
>     It is 'just' about *work*.
>
>     Using the assisted API, i.e. GLAutoDrawable/GLEventListener
>     allows you to rely on our OpenGL + resources lifecycle support
>     and certain 'quirks' required to allow seamless operation on all
>     platforms, e.g. Android and OSX/AWT special cases.
>
> Hi Sven,
>
> I hear you. Perhaps the title is, in hindsight, a bit misleading. I understand
> why I want to use the assisted API and I wholeheartedly agree. To briefly
> illustrate the issue I'm trying to understand how to manage with JOGL,
> consider this:
>
> // You have something like this in a client
> RenderSystem rs = ...
> rs.enableDepthTesting(true);
>
>
> Internally, you'd expect this method to end up calling
> gl.glEnable(GL.GL_DEPTH_TEST) and might be tempted to start by writing GL4 gl
> = GLContext.getCurrentGL().getGL4() to use glEnable.
>
> The client may want to issue this kind of call outside of void
> display(GLAutoDrawable) and does not take a GL instance as a parameter (i.e.
> not rs.enableDepthTesting(gl4, true) to keep the JOGL details hidden from the
> client.)
>
> Of course the 'RenderSystem' would be implementing GLEventListener and,
> therefore, display(...), but the client is not expected to 'see' those and
> when display(...).
Well, in case your API spec constraints the RenderSystem.display() call
appropriately, you may do maintain a local GL reference in the RenderSystem
instance. Your constraints simply must match the GLAutoDrawable semantics
here ofc, i.e. update GL ref at the latter GLAutoDrawable.display(drawable)
and clear it (null) afterwards. You may also want to ensure the user is not
calling RenderSystem.display() outside of that call flow ..

If it would be named 'RenderThing' one could assume similar semantics
as JOGL's GLAutoDrawable, which does hold all required associations,
i.e. drawable -> GL.
Hence exposing the current GL object for the time being (display call)
might not seem wrong in any way here.
However - one could now argue that even the GL object is JOGL,
which you work so hard to hide? :) Dunno ..

>
>     Sven Gothel wrote
>     The assisted model also supports certain features like:
>       - Suspend an GLContext (make offscreen, destroy drawable -> re-animate).
>       - Swap On- offscreen drawable
>       - ..
>
>     If you control GLDrawable/GLContext yourself,
>     you operate on a much lower level.
>     This gives you more freedom, but also implies a much
>     higher responsibility, since you can crash things more easily.
>     Everything is available for this low level hacking
>     and you can of course copy/paste our code pieces from
>     GLAutoDrawable, GLCanvas etc. However, maintenance might become
>     your burden here.
>     This approach may also end up in just reinventing the wheel :)
>
>     In case you dislike the assisted path b/c of a missing
>     but essential feature, we can discuss it and add it together.
>
> I agree and definitely want to avoid doing that stuff. There's nothing I
> "dislike" about JOGL, if this is the way my posts have somehow been
> interpreted --quite the opposite, actually. I'm just trying to understand that
> the correct way of using JOGL for what I'm trying to achieve is and this is
> the part where I'm not sure my understanding has been that great.
I meant 'dislike' purely in a technical context here :)
So 'unfavor' or better words may suit better.

>
> I'm open to possibility that I may need to go back several "steps" and
> re-design something, but I need to better understand where my goal and JOGL's
> proper usage meet.

Is your API free software, in such case we all may be able and willing
to share thoughts.

>
> I apologize if there's anything I've said here that was not too clear and
> ended up causing the confusion that I think I had to clear up in this post and
> hopefully, I'll get the benefit of the doubt in the future.

All good. If I am upset or anything, I always make sure the audience knows,
no reading between the lines is required then :)

Cheers, Sven



signature.asc (828 bytes) Download Attachment