Login  Register

Re: Drawing more than a certain number of triangles at one time/method/stack crash

Posted by Sven Gothel on Dec 18, 2015; 10:21pm
URL: https://forum.jogamp.org/Drawing-more-than-a-certain-number-of-triangles-at-one-time-method-stack-crash-tp4035900p4035915.html

On 12/17/2015 12:50 PM, gouessej [via jogamp] wrote:
> You shouldn't pass GL instances, this is a bad practice, it might lead you to
> use an invalidated instance. I advise you to look at the renderers of the most
> famous 3D engines (JMonkeyEngine, LibGDX, JogAmp's Ardor3D Continuation, ...),

Well, I advise to pass the GL instance, but treat it only transient,
i.e. do not store/cache it (no persistance) - or you really have to
know what you are doing (lifecycle, threading, ..).

From my viewpoint, it is best practice to pass the GL instance
as it is done in most of our framework - and keep it transient.

> I call GLContext.getCurrentGL() instead of passing GL instances. If you called
> getCurrentGL() on the wrong thread or at the wrong time, it would throw an
> exception with an understandable error message instead of causing a crash.

getCurrentGL() works ofc, assuming operating from the right thread,
which you control.

It uses TLS storage and hence has a [very] little performance footprint.
Dunno which footprint is bigger, i.e. passing the GL instance or
accessing the TLS for the current GL instance.

In the end .. well, it might be just very academic discussion :)

~Sven



signature.asc (828 bytes) Download Attachment