WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
Renderer Class Reference

#include <Renderer.h>

Collaboration diagram for Renderer:
[legend]

Classes

struct  LightSettings
 Plain-data description of a single light source. More...
 
struct  RenderState
 Aggregate rendering state exposed for UI binding. More...
 

Public Types

enum class  LightType : int { Directional = 0 , Point , Spot , AmbientOnly }
 

Public Member Functions

 Renderer ()=default
 
 ~Renderer ()
 
 Renderer (const Renderer &)=delete
 
Rendereroperator= (const Renderer &)=delete
 
void init ()
 Create GPU resources. Call once after the OpenGL context is current.
 
void shutdown ()
 Release GPU resources.
 
RenderStatestate () noexcept
 
const RenderStatestate () const noexcept
 
void applyLighting ()
 Configure OpenGL fixed-function lighting from the current state.
 
void applyLighting (const LightSettings &light)
 Configure OpenGL fixed-function lighting from explicit settings.
 
void drawCheckerboard (int w, int h)
 Draw a tiled checkerboard pattern in screen space.
 
void drawGradient (int w, int h, const glm::vec3 &top, const glm::vec3 &bottom)
 Draw a vertical gradient quad in screen space.
 
void drawBackground (int w, int h)
 Draw the background (checker or gradient) based on current state.
 
void drawGrid (float size=40.0f, float step=1.0f)
 Draw a ground grid with highlighted centre axes.
 
void applyProjection (int w, int h, float fov, float nearPlane=0.1f, float farPlane=6400.0f)
 Load a perspective projection matrix.
 
void applyView (const glm::mat4 &viewMatrix)
 Load a view (camera) matrix.
 
void beginPass (ViewportFBO &fbo, int w, int h, const glm::vec3 &clearColor)
 Begin an off-screen FBO render pass (resize, bind, clear).
 
void endPass (ViewportFBO &fbo)
 End the current FBO render pass (unbind).
 
void renderScene (ViewportFBO &fbo, int w, int h, const OrbitCamera &camera, float fov, const glm::vec3 &clearColor, bool drawGrid, const std::function< void()> &drawObjects)
 
GLuint checkerTexture () const noexcept
 

Private Attributes

GLuint m_checkerTex = 0
 
RenderState m_state
 

Detailed Description

Low-level rendering operations for the engine's OpenGL pipeline.

Encapsulates GPU resource management, fixed-function lighting, common backgrounds, grid drawing, and FBO render-pass bookkeeping. The application layer calls individual primitives or the composite renderScene() helper to draw a complete frame.

Definition at line 17 of file Renderer.h.

Member Enumeration Documentation

◆ LightType

enum class Renderer::LightType : int
strong
Enumerator
Directional 
Point 
Spot 
AmbientOnly 

Definition at line 22 of file Renderer.h.

Constructor & Destructor Documentation

◆ Renderer() [1/2]

Renderer::Renderer ( )
default

◆ ~Renderer()

Renderer::~Renderer ( )

Definition at line 9 of file Renderer.cpp.

Here is the call graph for this function:

◆ Renderer() [2/2]

Renderer::Renderer ( const Renderer )
delete

Member Function Documentation

◆ applyLighting() [1/2]

void Renderer::applyLighting ( )

Configure OpenGL fixed-function lighting from the current state.

Definition at line 261 of file Renderer.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyLighting() [2/2]

void Renderer::applyLighting ( const LightSettings light)

Configure OpenGL fixed-function lighting from explicit settings.

Definition at line 44 of file Renderer.cpp.

◆ applyProjection()

void Renderer::applyProjection ( int  w,
int  h,
float  fov,
float  nearPlane = 0.1f,
float  farPlane = 6400.0f 
)

Load a perspective projection matrix.

Definition at line 224 of file Renderer.cpp.

Here is the caller graph for this function:

◆ applyView()

void Renderer::applyView ( const glm::mat4 &  viewMatrix)

Load a view (camera) matrix.

Definition at line 235 of file Renderer.cpp.

Here is the caller graph for this function:

◆ beginPass()

void Renderer::beginPass ( ViewportFBO fbo,
int  w,
int  h,
const glm::vec3 &  clearColor 
)

Begin an off-screen FBO render pass (resize, bind, clear).

Definition at line 244 of file Renderer.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkerTexture()

GLuint Renderer::checkerTexture ( ) const
inlinenoexcept

Definition at line 118 of file Renderer.h.

◆ drawBackground()

void Renderer::drawBackground ( int  w,
int  h 
)

Draw the background (checker or gradient) based on current state.

Definition at line 266 of file Renderer.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawCheckerboard()

void Renderer::drawCheckerboard ( int  w,
int  h 
)

Draw a tiled checkerboard pattern in screen space.

Definition at line 110 of file Renderer.cpp.

Here is the caller graph for this function:

◆ drawGradient()

void Renderer::drawGradient ( int  w,
int  h,
const glm::vec3 &  top,
const glm::vec3 &  bottom 
)

Draw a vertical gradient quad in screen space.

Definition at line 151 of file Renderer.cpp.

Here is the caller graph for this function:

◆ drawGrid()

void Renderer::drawGrid ( float  size = 40.0f,
float  step = 1.0f 
)

Draw a ground grid with highlighted centre axes.

Definition at line 186 of file Renderer.cpp.

Here is the caller graph for this function:

◆ endPass()

void Renderer::endPass ( ViewportFBO fbo)

End the current FBO render pass (unbind).

Definition at line 254 of file Renderer.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

void Renderer::init ( )

Create GPU resources. Call once after the OpenGL context is current.

Definition at line 16 of file Renderer.cpp.

Here is the caller graph for this function:

◆ operator=()

Renderer & Renderer::operator= ( const Renderer )
delete

◆ renderScene()

void Renderer::renderScene ( ViewportFBO fbo,
int  w,
int  h,
const OrbitCamera camera,
float  fov,
const glm::vec3 &  clearColor,
bool  drawGrid,
const std::function< void()> &  drawObjects 
)

Composite render pass: background, projection, lighting, grid, then invoke drawObjects for application-specific geometry.

Definition at line 280 of file Renderer.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown()

void Renderer::shutdown ( )

Release GPU resources.

Definition at line 33 of file Renderer.cpp.

Here is the caller graph for this function:

◆ state() [1/2]

const RenderState & Renderer::state ( ) const
inlinenoexcept

Definition at line 72 of file Renderer.h.

◆ state() [2/2]

RenderState & Renderer::state ( )
inlinenoexcept

Definition at line 71 of file Renderer.h.

Here is the caller graph for this function:

Member Data Documentation

◆ m_checkerTex

GLuint Renderer::m_checkerTex = 0
private

Definition at line 121 of file Renderer.h.

◆ m_state

RenderState Renderer::m_state
private

Definition at line 122 of file Renderer.h.


The documentation for this class was generated from the following files: