Jogl code typical structure

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

Jogl code typical structure

devildon
Hello,
I'm quite new with JOGL, so I would need your help to understand if I'm using it properly.
I'm rendering pallets (parallelepipeds), bins (rectangles) and shelves (as a mix of parallelepipeds of different sizes). Each shelf is made out of four parallelepipeds for its legs and one parallelepiped for the shelf itself.

I'm also using VBO to improve performance as the "world" I'm building has many objects (around 15000 between bins and shelves). In particular, I use two VBOs for the bins (one for vertices, colors and normals and one for the indices), two VBOs for the shelves (same as before), two VBOs for other kind of rectangles which I need to paint and two VBOs for the pallets. Is this correct or should I use, for example, only one VBO for bins, shelves and rectangles and one VBO for pallets?

I'm not using texture, as the graphics have to be quite simple (it's a warehouse environment), so I give the "3D effect" by using different tone of the color of each side of a parallelepiped. This implies that, for example, the pallet has more than 40 vertices instead of just 8. Do you think I should use the texture instead?

Furthermore my software was quite fast and smooth without the shelves, but as I introduced them it started to be slightly slower on some computers. I guess it depends on the fact that each shelf has too many vertices to be painted. I also tried to have a look at the shaders, but I haven't found an easy-to-understand manual so far, so I have no idea if they can help in my case or not.

Finally, do you use any particular tools to check your JOGL application's performance?
Thanks a lot.
Cheers
Reply | Threaded
Open this post in threaded view
|

Re: Jogl code typical structure

gouessej
Administrator
Hi

Do you use a 3D engine based on JOGL?

Use the static draw mode for the VBOs that you rarely or never modify. Don't put the colors into your VBOs, use the mesh instancing, use the instance id in the shader to pick a different color per object. Then, use the same interleaved VBO for all identical objects, bind it only once per frame and draw it many times per frame instead of creating as much VBOs as objects or huge VBOs.

JOGL is a Java binding for the OpenGL/OpenGL-ES API. It contains some helpers but it doesn't do everything for you, you have to understand OpenGL. Have you looked at our wiki and at jogl-demos on GitHub?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Jogl code typical structure

devildon
Hi, thanks a lot for the reply.

No, I don't use any 3D engine. I implemented the graphics just by using geometry and I do use static draw for static objects, as you suggested.

One of the problems I have is that the 3D world is "dynamically" created as all the points data to be drawn are stored in a database and they might change event frequently. So every time the application starts it loads data from the DB, it builds all the Java objects and then it "translates" them in the OpenGL 3D objects (mainly VBOs). At the beginning the application starting time was huge, but then I considerably reduced it. Anyway, as you can see, I still have the problem that I can't recycle the vertices too much, since I need to build the 3D world time by time. The procedure which I use to build a 3D object starting from a Java object doesn't let me re-use vertices.

As far as I understood from your answer, shaders are essential to improve performance and you also use them for colors picking. But unfortunately I'm unfamiliar with shaders. Could you please suggest me a good manual? I mean possibly a kind of step by step guide... but any suggestion will be welcome.

About the OpenGL, I started studying them a few months ago: I firstly read songho examples and then I found other matherial and books. Finally I started using the JOGL wrapper as I needed to develop my application in Java. I think it's fine, even if I believe the hard part comes when you want to improve performance (of course :D).
Reply | Threaded
Open this post in threaded view
|

Re: Jogl code typical structure

gouessej
Administrator
You can delete VBOs and release their native resources when you no longer need them.

If your bins have completely different sizes and vertices, you can't use mesh instancing, some of my suggestions aren't suitable :s If you use exactly the same model of bin/pallet/whatever at multiple locations, then they are still suitable. Please can you clarify this aspect?

I don't advise you to use build-in OpenGL picking or color picking, we already had a very long discussion about that in this forum.

If you can't use mesh instancing, shaders won't be absolutely necessary to improve the performance. I advise you to look at elect86's examples in the wiki.

Finally, you can implement several kinds of culling to send less geometry to the graphics card(s), for example contribution culling, frustum culling, ...
Julien Gouesse | Personal blog | Website