Skip to Content

Renderer

This is a WIP project - Expect breaking changes to occur.

Overview

Handles rendering of GameObject instances using OpenGL.

Each call to #renderMesh binds the object’s VAO, activates the shader, uploads all required uniforms (model view, projection matrices, plus Phong lighting parameters), issues a draw call, then cleans up state.

Renderer(...)

public Renderer(Shader shader) {}

Constructor for the Renderer that uses the given shader for all draw calls.

renderMesh(...)

public void renderMesh(GameObject object, Matrix4f view, Matrix4f projection, TextureAtlas atlas, boolean useTexture) {}

Renders a single GameObject using the provided view and projection matrices.

Uploads the following uniforms each frame:

  • model - Object transform (position x rotation x scale)
  • view - Camera view matrix
  • projection - Perspective projection matrix
  • lightPos - World-space position of the point light
  • lightColor - RGB color/intensity of the point light
  • viewPos - World-space camera position for specular lighting calculations
  • atlas - Texture sampler bound to unit 0
  • useTexture - Whether to sample from the texture atlas or use a vertex color
Last updated on