![]() |
The LARC Game Engine
A Simple Game Engine from the Laboratory for Recreational Computing
|
The renderer. More...
#include <Renderer3D.h>
Public Member Functions | |
CRenderer3D () | |
Constructor. | |
virtual | ~CRenderer3D () |
Destructor. | |
void | Initialize (bool=true) |
Initialize renderer. More... | |
void | LoadTexture (const char *, CTextureDesc &) |
Load texture. More... | |
void | LoadTextureFile (const char *, CTextureDesc &) |
Load texture from file. More... | |
void | BeginResourceUpload () |
Begin uploading textures. More... | |
void | EndResourceUpload () |
End uploading textures. More... | |
virtual void | BeginFrame () |
Begin frame. More... | |
virtual void | EndFrame () |
End frame. More... | |
void | SetBgColor (const XMVECTORF32 &) |
Set default background color. More... | |
void | DrawScreenText (const char *, const Vector2 &, XMVECTORF32=Colors::Black) |
Draw screen text. More... | |
void | DrawScreenText (const wchar_t *, const Vector2 &, XMVECTORF32=Colors::Black) |
Draw screen text, wide version. More... | |
void | DrawCenteredText (const char *, XMVECTORF32=Colors::Black) |
Draw centered text. More... | |
void | DrawCenteredText (const wchar_t *, XMVECTORF32=Colors::Black) |
Draw centered text, wide version. More... | |
void | SaveScreenShot () |
Save a screenshot. More... | |
virtual void | OnDeviceLost () override |
Handler for device lost notification. More... | |
virtual void | OnDeviceRestored () override |
Handler for device restored notification. More... | |
![]() | |
template<typename t0 , typename t1 , typename t2 > | |
int | WinMain (_In_ HINSTANCE, bool, const t0 &, const t1 &, const t2 &) |
WinMain. | |
![]() | |
void | Load () |
Load game settings. More... | |
Protected Member Functions | |
void | CreateDDSTexture (_In_z_ const wchar_t *, CTextureDesc &) |
Load a texture from a DirectDraw surface file (contains mipmaps). More... | |
void | CreateWICTexture (_In_z_ const wchar_t *, CTextureDesc &) |
Load a texture from a an image file (does not contain mipmaps). More... | |
void | ProcessTexture (_In_ ComPtr< ID3D12Resource >, CTextureDesc &) |
Process a loaded texture. More... | |
void | LoadScreenFont () |
Load screen font. More... | |
![]() | |
void | SetWinSize (int, int) |
Set window size information. More... | |
Protected Attributes | |
unique_ptr< GraphicsMemory > | m_pGraphicsMemory |
Pointer to graphics memory. | |
unique_ptr< DescriptorHeap > | m_pDescriptorHeap |
Pointer to a descriptor heap. | |
UINT | m_nNumResourceDesc = 0 |
Number of resource descriptors in descriptor heap. | |
unique_ptr< CommonStates > | m_pStates |
Pointer to render state object. | |
unique_ptr< SpriteBatch > | m_pSpriteBatch |
SpriteBatch object for rendering sprites in screen space (from the DirectXTK). | |
unique_ptr< PrimitiveBatch< VertexPositionColor > > | m_pPrimitiveBatch |
PrimitiveBatch object from the DirectXTK. | |
unique_ptr< SpriteBatch > | m_pTextSpriteBatch |
SpriteBatch object for rendering text in screen space. | |
unique_ptr< SpriteFont > | m_pFont |
Text font. | |
unique_ptr< DeviceResources > | m_pDeviceResources |
Pointer to device resources. | |
ID3D12Device * | m_pD3DDevice = nullptr |
Pointer to the D3D device. | |
ResourceUploadBatch * | m_pResourceUpload = nullptr |
Pointer to the resource upload batch object. | |
ID3D12GraphicsCommandList * | m_pCommandList = nullptr |
Pointer to the command list. | |
ID3D12DescriptorHeap * | m_pHeaps [2] |
A pair of pointers to heaps. | |
RenderTargetState | m_RenderTargetState |
The render target state. | |
XMVECTORF32 | m_f32BgColor = Colors::White |
The default background color. | |
Additional Inherited Members | |
![]() | |
static CStepTimer * | m_pStepTimer = &cStepTimer |
Pointer to a step timer. More... | |
static CRandom * | m_pRandom = &cRandom |
Pointer to a PRNG. More... | |
static CKeyboard * | m_pKeyboard = &cKeyboard |
Pointer to a keyboard handler. More... | |
static CXBoxController * | m_pController = &cController |
Pointer to a XBox controller. More... | |
static CAudio * | m_pAudio = &cAudio |
Pointer to an audio player. More... | |
![]() | |
static XMFLOAT4X4 | m_orient |
Orientation matrix. | |
static XMFLOAT4X4 | m_view |
View matrix. | |
static XMFLOAT4X4 | m_projection |
Projection matrix. | |
![]() | |
static HWND | m_Hwnd = 0 |
Window handle. | |
static HINSTANCE | m_hInst = 0 |
Instance handle. | |
static bool | m_bExitSizeMove |
User just finished moving/resizing window. | |
![]() | |
static XMLElement * | m_pXmlSettings = nullptr |
Pointer to the settings tag in the XML settings file. | |
static float | m_fAspectRatio = 1.0f |
Aspect ratio, width/ht. | |
![]() | |
static char | m_szName [MAX_PATH] |
Name of this game. | |
static int | m_nWinWidth = 0 |
Window width in pixels. | |
static int | m_nWinHeight = 0 |
Window height in pixels. | |
static Vector2 | m_vWinCenter = Vector2::Zero |
Window center. | |
The renderer uses DirectX 12 and DirectXTK 12.
|
virtual |
Must be called at the start of each animation frame to initialize the render pipeline.
Reimplemented in CSpriteRenderer.
void CRenderer3D::BeginResourceUpload | ( | ) |
Notify the resource upload object that uploading is about to begin.
|
protected |
Load a texture from a DirectDraw Surface file. Aborts if file not found.
szFileName | [in] Wide file name. |
tDesc | [out] Descriptor for the texture pointed to by p. |
|
protected |
Load a texture from a WIC file. Aborts if file not found.
szFileName | [in] Wide file name. |
tDesc | [out] Texture descriptor. |
void CRenderer3D::DrawCenteredText | ( | const char * | text, |
XMVECTORF32 | color = Colors::Black |
||
) |
Draw text to the screen center.
text | Null terminated text string. |
color | Text color, defaults to black. |
void CRenderer3D::DrawCenteredText | ( | const wchar_t * | text, |
XMVECTORF32 | color = Colors::Black |
||
) |
Draw text to the screen center.
text | Null terminated wide text string. |
color | Text color, defaults to black. |
void CRenderer3D::DrawScreenText | ( | const char * | text, |
const Vector2 & | p, | ||
XMVECTORF32 | color = Colors::Black |
||
) |
Draw text to the screen.
text | Null terminated text string. |
p | position of text. |
color | Text color, defaults to black. |
void CRenderer3D::DrawScreenText | ( | const wchar_t * | text, |
const Vector2 & | p, | ||
XMVECTORF32 | color = Colors::Black |
||
) |
Draw text to the screen.
text | Null terminated wide text string. |
p | position of text. |
color | Text color, defaults to black. |
|
virtual |
Must be called at the end of each animation frame to render and present the current frame.
Reimplemented in CSpriteRenderer.
void CRenderer3D::EndResourceUpload | ( | ) |
Notify the resource upload object that uploading is over, and wait for any uploads in progress to finish.
void CRenderer3D::Initialize | ( | bool | bUseDepthStencil = true | ) |
Do the necessary voodoo to set up Direct3D 12 rendering.
bUseDepthStencil | true to use z-buffering. |
|
protected |
Load the font for the screen text from a font file specified in gamesettings.xml
.
void CRenderer3D::LoadTexture | ( | const char * | name, |
CTextureDesc & | tDesc | ||
) |
Load a texture from a file specified in gamesettings.xml. Aborts if gamesettings.xml
has not been loaded correctly.
name | [in] Name field in a sprite tag. |
tDesc | [out] Texture descriptor. |
void CRenderer3D::LoadTextureFile | ( | const char * | filename, |
CTextureDesc & | tDesc | ||
) |
Load a texture from a file. Aborts if file not found.
filename | [in] File name. |
tDesc | [out] Texture descriptor. |
|
overridevirtual |
TODO: fix this, it ain't complete.
|
overridevirtual |
TODO: fix this, it ain't complete.
|
protected |
Given a COM pointer to a texture that has just been loaded using CreateDDSTexture of CreateWICTexture, append it to the end of texture list, create a shader resource view for it, and record the texture's index, resource descriptor index, and dimensions in the texture descriptor.
p | [in] Pointer to the D3D12 resource for the texture. |
tDesc | [out] Descriptor for the texture pointed to by p. |
void CRenderer3D::SaveScreenShot | ( | ) |
Save a screenshot to screenshot0.png
, screenshot1.png
, etc.
void CRenderer3D::SetBgColor | ( | const XMVECTORF32 & | color | ) |
Set the background color.
color | New background color. |