TazGraph Project v0.1.0
Loading...
Searching...
No Matches
Render Engine

Graph Rendering Pipeline

All rendering logic is handled in Graph::draw().

1. Shader Setup

GLSL shader programs are loaded and set up using the resource manager. Uniforms (e.g. camera matrix, rotation) are passed before rendering:

_resourceManager.setupShader(glsl_color, *main_camera2D);
GLint pLocation = glsl_color.getUniformLocation("rotationMatrix");
glUniformMatrix4fv(pLocation, 1, GL_FALSE, glm::value_ptr(rotationMatrix));

2. Render Pass Initialization

Before batching begins, the renderers are prepared. This includes setting up internal buffers and clearing previous frame data.

_PlaneModelRenderer.initTextureQuadBatch(
manager->getVisibleGroup<NodeEntity>(Manager::groupRenderSprites).size()
);
...
_PlaneModelRenderer.initBatchSize();
...
Definition GECSEntity.h:40

3. Render Batching (Multithreaded)

Entities are grouped and passed to the appropriate renderer via renderBatch. This uses multithreading to fill buffers (meshElements & meshArrays) efficiently.

renderBatch(
manager->getVisibleGroup<LinkEntity>(Manager::groupLinks_0),
_LineRenderer
);
Definition GECSEntity.h:108

4. Instance Rendering

After batching, each renderer draws its instances and clears its buffers:

_PlaneColorRenderer.end();
_PlaneColorRenderer.renderBatch(&glsl_color);
glsl_color.unuse();

Repeat for each renderer (e.g. _LineRenderer, _PlaneModelRenderer, _LightRenderer) in your preferred draw order.

Not all Entity Components can draw with all renderers (e.g. Sprite Component is used to specifically draw for PlaneModelRenderer). The draw function in the component indicates the renderers used: void draw(size_t v_index,PlaneModelRenderer& batch, TazGraphEngine::Window& window) { ... }

Custom Renderers

Renderers in TazGraph are grouped by the attributes they support, which directly affects the shaders they use.
This design makes rendering highly memory-efficient, but each renderer is tailored for a specific use case.

Each renderer sets a fixed number of per-vertex and per-instance attributes. For example, the PlaneColorRenderer expects shaders with the following layout:

layout (location = 0) in vec3 aPos; //vertex Pos
layout (location = 1) in vec3 aNormal; //vertex Normal
layout (location = 2) in vec3 instanceSize;
layout (location = 3) in vec3 instanceBodyCenter;
layout (location = 4) in vec3 instanceRotation;
layout (location = 5) in vec4 instanceColor;

Your GLSL shader must match the expected attribute layout of the renderer you're using.

Currently, the engine includes the following specific renderers:

To create a new renderer - for example, a textured plane with shading

  • you need to implement a new renderer class that matches the data layout and rendering logic required for that effect.

In the following folder: TazGraphEngine/Renderers/PlaneRenderers/PlaneLitTextRenderer
use one of the existing renderers as a base, then write glsl shader to match the renderer under TazGraph/Src/Shaders,
implement a draw function in a component that uses that renderer and then pass that renderer as argument for renderBatch in Graph::draw().