Bullet Physics Block Toy
Game Physics with a 3D Physics Engine
Loading...
Searching...
No Matches
CRenderer Class Reference

The renderer. More...

#include <Renderer.h>

Inheritance diagram for CRenderer:
Collaboration diagram for CRenderer:

Public Member Functions

 CRenderer ()
 Constructor.
 
 ~CRenderer ()
 Destructor.
 
void Initialize ()
 Initialize.
 
void LoadGeometricPrimitives ()
 Load meshes.
 
void LoadModel (eModel, const std::wstring &)
 Load model from file.
 
void Render (CObject *)
 Render an object.
 
ID3D12Device * GetD3DDevice () const
 Get the D3D device pointer.
 
const Vector3 & GetExtents (const eModel) const
 Get model extents.
 
CMeshDescGetPrimitiveDesc (const eMesh) const
 Get mesh descriptor.
 

Private Member Functions

void BeginResourceUpload ()
 Begin resource upload.
 
void EndResourceUpload ()
 End resource upload.
 
void UploadTexture (char *, eMesh)
 Upload texture to GPU.
 
void UploadDefaultEffect (CMeshDesc *)
 Upload default effect to GPU.
 
void UploadSphereMesh (CMeshDesc *)
 Upload sphere mesh to GPU.
 
void UploadBoxMesh (CMeshDesc *)
 Upload box mesh to GPU.
 
void UploadPrimitiveMesh (CMeshDesc *)
 Upload geometric primitive mesh to GPU.
 

Private Attributes

CMeshDesc ** m_pPrimitive
 Array of primitive descriptors.
 
Sage::CTextureDesc * m_pTextureDesc = nullptr
 Array of texture descriptors.
 
size_t m_nNumTextures = 0
 Number of textures.
 
std::map< eModel, CModelDesc * > m_mapModelDesc
 Model descriptor map.
 
const XMVECTOR m_vAmbientColor {0.9f, 0.9f, 0.9f, 1.0f}
 Ambient light color.
 
const XMVECTOR m_vDiffuseColor {0.5f, 0.5f, 0.5f, 1.0f}
 Diffuse light color.
 
const Vector3 m_vLightDirection = Vector3(-0.417f, -0.674f, -0.608f)
 Light direction.
 

Additional Inherited Members

- Protected Attributes inherited from CCommon
const float m_fFloorHt = 1.0f
 Floor height.
 
const Vector3 m_vPlanePos
 Plane position.
 
const Vector3 m_vPlaneSize
 Plane size.
 
const bool m_bWireFrame = false
 Draw in wireframe.
 
const float m_fMoonRadius = 25.0f
 Moon radius.
 
const float m_fBallRadius = 2.0f
 Ball radius.
 
const Vector3 m_vBoxSize = Vector3(9.0f, 6.0f, 6.0f)
 Box size.

 
const float m_fTetrahedronSize = 16.0f
 Tetrahedron size.
 
const float m_fIcosahedronSize = 16.0f
 Icosahedron size.
 
const float m_fDodecahedronSize = 16.0f
 Dodecahedron size.
 
const float m_fTeapotSize = 8.0f
 Teapot size.
 
- Static Protected Attributes inherited from CCommon
static CRendererm_pRenderer = nullptr
 Pointer to the renderer.
 
static Sage::CCamera * m_pCamera = nullptr
 Pointer to the camera.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to object manager.
 
static btDiscreteDynamicsWorld * m_pPhysicsWorld = nullptr
 Pointer to physics engine.
 
static btDefaultCollisionConfiguration * m_pConfig = nullptr
 Bullet physics configuration.
 
static btCollisionDispatcher * m_pDispatcher = nullptr
 Bullet physics dispatcher.
 
static btBroadphaseInterface * m_pBroadphase = nullptr
 Bullet physics broadphase.
 
static btSequentialImpulseConstraintSolver * m_pSolver = nullptr
 Bullet physics constraint solver.
 
static btAlignedObjectArray< btCollisionShape * > m_btCollisionShapes
 Collision shapes.
 
static bool m_bCollisionSoundsMuted = false
 Mute collision sounds.
 

Detailed Description

CRenderer handles the game-specific rendering tasks, relying on the base class to do all of the actual API-specific rendering.

Member Function Documentation

◆ EndResourceUpload()

void CRenderer::EndResourceUpload ( )
private

Wait for the upload thread to terminate.

Here is the caller graph for this function:

◆ GetD3DDevice()

ID3D12Device * CRenderer::GetD3DDevice ( ) const

Reader function for the D3D device pointer.

Returns
the D3D device pointer.

◆ GetExtents()

const Vector3 & CRenderer::GetExtents ( const eModel t) const

Reader function for the model extents (half width, height, and depth).

Parameters
tModel type.
Returns
Const reference to the bounding box extents of a model of type t.
Here is the caller graph for this function:

◆ GetPrimitiveDesc()

CMeshDesc * CRenderer::GetPrimitiveDesc ( const eMesh t) const

Get a pointer to the geometric primitive descriptor for a mesh type.

Parameters
tMesh type.
Returns
Pointer to the geometric primitive descriptor for the mesh type.
Here is the caller graph for this function:

◆ Initialize()

void CRenderer::Initialize ( )

Initialize the renderer, set the background color, and create a perspective camera.

Here is the caller graph for this function:

◆ LoadGeometricPrimitives()

void CRenderer::LoadGeometricPrimitives ( )

Load meshes, textures, and effects for geometric primitives.

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

◆ LoadModel()

void CRenderer::LoadModel ( eModel t,
const std::wstring & strPath )

Load a model mesh and texture from a file to the GPU.

Parameters
tModel type.
strPathWide string containing path and file name.
Here is the caller graph for this function:

◆ Render()

void CRenderer::Render ( CObject * pObj)

Render an object.

Parameters
pObjPointer to the object to be rendered. May be nullptr.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UploadBoxMesh()

void CRenderer::UploadBoxMesh ( CMeshDesc * pDesc)
private

Upload box mesh to GPU. This gets its own function because we will be repeating the texture across each face.

Parameters
pDescPointer to geometric primitive descriptor.
Here is the caller graph for this function:

◆ UploadDefaultEffect()

void CRenderer::UploadDefaultEffect ( CMeshDesc * pDesc)
private

Upload default effect to GPU.

Parameters
pDescPointer to geometric primitive descriptor.
Here is the caller graph for this function:

◆ UploadPrimitiveMesh()

void CRenderer::UploadPrimitiveMesh ( CMeshDesc * pDesc)
private

General function for uploading a geometric primitive mesh. Creates a new primitive mesh descriptor and fills it with mesh information including a local copy of vertices, and stores a pointer to it in m_vecPrimitives[t] for later use, for example, in physics calculations such as collision detection and response.

Parameters
pDescPointer to geometric primitive descriptor.
Here is the caller graph for this function:

◆ UploadSphereMesh()

void CRenderer::UploadSphereMesh ( CMeshDesc * pDesc)
private

Upload sphere mesh to GPU. The sphere gets its own function because it has its own level of triangulation, which will be larger for large spheres.

Parameters
pDescPointer to geometric primitive descriptor.
Here is the caller graph for this function:

◆ UploadTexture()

void CRenderer::UploadTexture ( char * name,
eMesh t )
private

Upload texture to GPU.

Parameters
nameName string found in gamesettings.xml.
tTexture type.
Here is the caller graph for this function: