Major (3d) render rewrite - need pointers

Hello everyone!

I am developer of DeedPlanner program (source is available here: https://github.com/Warlander/DeedPlanner-2 ). In a nutshell this is a program which allows you to rapidly design villages for Wurm Online/Unlimited games, preview it in 3d and evaluate costs before actually starting doing anything in-game. The program is relatively large, with over 100 versions published and its original version is over 3 years old.

The program is heavily depending on customized Swing GUI’s, with JOGL GLJPanel doing the actual 3d rendering. Due to Swing dependency, it is impossible to switch to any non-JOGL based library easily. In action, it looks like this:
https://dl.dropboxusercontent.com/u/67758055/Wurm/DeedPlanner/14_05_2015__04_34_01.png
https://dl.dropboxusercontent.com/u/67758055/Wurm/DeedPlanner/14_05_2015__04_32_42.png

Rendering itself without going into details looks like this:

  • Interface and JOGL panel is initialized
  • For each frame:
    [list]
    [li]Buffers are cleared
  • Set current camera (perspective or orthographic projection depending on view)
  • Render map: iterate all tiles in radius of “x” tiles around camera, in case of 3d view rendering everything but labels/2d borders, in 2d view - everything on current floor + 2 floors below
  • In 3d view, render skybox
    [/li]
    [/list]

When it comes to optimizations used, textures are pre-loaded on first use and models are pre-rendered to display lists on first use. Everything else is done every frame, including ground/cave rendering. Currently program uses mostly OpenGL 1 rendering with OGL 2 elements, but I can use OGL up to 4.1 easily.

The question

I want to rewrite the rendering in program. Why?

  • Program performs relatively bad when there are many objects in radius around user (can easily slow down even good PC)
  • Rendering seems inflexible
  • Shader support is minimal (especially as I want to implement lighting and water which actually looks like water)

Are there any specific resources I should take a look at or general guidelines I should follow? Maybe some pointers on how to refactor current rendering to make it easier to extend now and in a future?

Hi

I advise you to drop display lists and to learn how to use VBO/VAO/UBO/… wisely. elect can probably show you some examples.

I agree. VAOs are an array of VBOs. VBOs hold lighting data, vertex data, and any other primitive data typed data - they are arrays too.

So you would create a VAO, load your model data into a new VBO, store that VBO in a VAO then call glDraw*(). There is Element and Array for this. There is a VBO called an indices buffer which holds ints pointing to the correct point path to make the triangles on your model. This is optional in cases.

So now that you know basically what it is, it should make your research a bit easier!

https://www.opengl.org/wiki/Buffer_Object

vbo, ebo, pbo, tbo, ubo, ssbo, tfbo, acbo they’re all pretty much same.

https://www.opengl.org/registry/specs/NV/shader_buffer_load.txt if you want to run NV only, this is a very nice way to handle gl buffers.

… together with https://www.opengl.org/registry/specs/NV/vertex_buffer_unified_memory.txt to define formats.

https://www.opengl.org/wiki/Bindless_Texture or anything supported by https://www.opengl.org/wiki/Direct_State_Access might be interesting too.

if you want to run gl 4.4+ this is a good read too :

https://www.opengl.org/registry/specs/ARB/sparse_texture.txt
https://www.opengl.org/registry/specs/ARB/sparse_buffer.txt

o/