Rendering - TheShubham99/Terasology GitHub Wiki

DISCLAIMER: the Renderer is undergoing major refactoring. The information provided here is so far correct and describes the only way at this stage to access rendering functionality. A major goal of the refactoring work however is to eventually provide a much more powerful API that will allow to expand, improve and even replace the renderer functionality available. Stay tuned! =)

RenderSystem interface

To get the engine to call your custom rendering functions, you need to have a System implementing the RenderSystem interface. This interface contains a method for some of the rendering passes executed by the engine. Add your code to the method that best fits the type of rendering you want to do. Usually this will be either renderOpaque or renderAlphaBlend, depending on whether or not you want to display transparent objects. The functions will be called automatically, while the system is registered to the engine.

WorldRenderer

More often then not, you will need more information then just the description of the objects you want to render. It is likely that you also need to have access to the camera position. The WorldRenderer can provide this amongst other useful stuff, such as block lighting information. To get access to the WorldRenderer, add a public WorldRenderer attribute to your system, with a @In annotation. The engine will assign an instance of WorldRenderer to this automatically.

@RegisterSystem(RegisterMode.CLIENT)
class MySystem implements WorldRenderer {
  @In
  public WorldRenderer worldRenderer;
  
  ... other code ...

  public void renderOpaque() {
    Camera camera = worldRenderer.getActiveCamera();
    ... rendering code ...
  }
}

OpenGL and GLSL

Terasology uses OpenGL 2.1 for all it's rendering. Shaders are written in the corresponding GLSL version 1.2.

Related Links