drawScene for all events?

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

drawScene for all events?

The.Scotsman
Hi everybody.
Sorry in advance if I'm asking a question that's already been answered.
Couldn't figure out proper search terms.

Like most people just getting started with JOGL, I've been working with the demos.
Specifically, the HDR demo that loads and displays an OBJ file.

I've successfully extended this to load an X3D file. Works great - with small X3D's.
However, the X3D file that I intend to eventually load is about 1.5GB in size.
Loaded into memory as an XML Document, it's more like 3GB.

In all the examples I've seen, display() is called for every change (or if there's an Animator, every frame.)
And all the example display() methods call drawScene() to load the content.

Since it's taking about 5 seconds to load the content of my 1.5GB X3D (from document to GL2), it's hard to see how this paradigm can work. (1.5GB x 60FPS = 90GB/S !!!)

It seems like there must be a way to, for example, change the viewport width/height, without reloading the content each time. Same with rotation/zoom via UserSceneInteraction.

A simple example (I'm a simple guy...) would be highly appreciated.

If that's just not how OpenGL works (i.e. always requires top down scene building), are there some strategies to improve performance?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: drawScene for all events?

Wade Walker
Administrator
Hi Scotsman,

This is more a general OpenGL question, rather than a JOGL question, but I'll take a stab at it anyway :) If you're loading an object from a file, then creating a vertex buffer from that, then drawing the vertex buffer, the only part of that process that needs to be in your display() method is the vertex buffer drawing. Reading the file and creating the vertex buffer should only need to be done once (unless the object's shape or texture is changing, then you would have to remake your vertex buffer too). You can set the viewport and camera different at the beginning of each display() without changing the vertex buffer.
Reply | Threaded
Open this post in threaded view
|

Re: drawScene for all events?

gouessej
Administrator
In reply to this post by The.Scotsman
Hi

You should rather use binary (instead of XML) X3D to handle such a big model.

Do only operations requiring a current OpenGL context in the GLEventListener and do the rest elsewhere if it is possible. Personally, when I used raw JOGL without high level engines, I loaded models by pieces, each display() call loaded a single piece if there was still at least a remaining piece to load. You have only a single model, you can load it once and use a flag to indicate that it is already loaded in order to avoid loading it at each display() call. Just keep in memory the VBO(s) and the texture(s) of your model.

I don't really see what is difficult in that, it has nothing to do with OpenGL, just keep the data required to render the model multiple times and use a flag to avoid loading it several times.

Of course, I agree with Wade.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: drawScene for all events?

The.Scotsman
Thanks guys.

Never heard of VBO's until now.
But I found WavefrontObjectLoader_VertexBufferObject.java to use as an example.

It also appears to address my next question, which was to be about multiple "USE's" for a single "DEF" (i.e. one gear definition driving multiple displayed gears at different transforms).

And a topic in the JOCL forum indicates that VBO's can be interoperated.
Hopefully, that will be enough to get me through this.