OpenBarnyard
 
Loading...
Searching...
No Matches
TRenderInterface_DX8.h
Go to the documentation of this file.
1#pragma once
5#include "TDebugText_DX8.h"
6
8
9#include <d3d8.h>
10
12
18{
19public:
21
22 friend TMSWindow;
23
24public:
27
28 //-----------------------------------------------------------------------------
29 // TRenderInterface
30 //-----------------------------------------------------------------------------
31
37 virtual TBOOL CreateDisplay( const DISPLAYPARAMS& a_rParams ) OVERRIDE;
38
44
50 virtual TBOOL Update( float a_fDeltaTime ) OVERRIDE;
51
56 virtual TBOOL BeginScene() OVERRIDE;
57
62 virtual TBOOL EndScene() OVERRIDE;
63
68 virtual TRenderAdapter::Mode::Device* GetCurrentDevice() OVERRIDE;
69
75
80 virtual TBOOL Create() OVERRIDE;
81
86 virtual TBOOL Destroy() OVERRIDE;
87
97 virtual void RenderIndexPrimitive( TINT param_2, TINT param_3, TINT param_4, TINT param_5, TINT param_6, TINT param_7 ) OVERRIDE;
98
103 virtual float GetPixelAspectRatio() OVERRIDE;
104
110 virtual TBOOL SetPixelAspectRatio( float a_fPixelAspectRatio ) OVERRIDE;
111
115 virtual void FlushOrderTables() OVERRIDE;
116
122 virtual TBOOL IsTextureFormatSupported( TINT a_eTextureFormat ) OVERRIDE;
123
129
135
141
146 virtual void DestroyCapture( TRenderCapture* a_pRenderCapture ) OVERRIDE;
147
156 virtual void* CreateUnknown( const TCHAR* a_szName, TINT a_iUnk1, TINT a_iUnk2, TINT a_iUnk3 ) OVERRIDE;
157
164 virtual TModel* CreateModel( TTMD* a_pTMD, TBOOL a_bLoad ) OVERRIDE;
165
172 virtual TModel* CreateModel( const TCHAR* a_szFilePath, TBOOL a_bLoad ) OVERRIDE;
173
182 virtual TModel* CreateModel( const TCHAR* a_szFilePath, TBOOL a_bLoad, TTRB* a_pAssetTRB, TUINT8 a_ui8FileNameLen ) OVERRIDE;
183
188
193
199
203 virtual void DestroyDebugText() OVERRIDE;
204
210 virtual TBOOL RecreateDisplay( const DISPLAYPARAMS& a_rDisplayParams );
211
216 virtual void SetContrast( TFLOAT a_fConstrast );
217
222 virtual void SetBrightness( TFLOAT a_fBrightness );
223
228 virtual void SetGamma( TFLOAT a_fGamma );
229
234 virtual void SetSaturate( TFLOAT a_fSaturate );
235
240 virtual TFLOAT GetContrast() const;
241
246 virtual TFLOAT GetBrightness() const;
247
252 virtual TFLOAT GetGamma() const;
253
258 virtual TFLOAT GetSaturate() const;
259
263 virtual void UpdateColourSettings();
264
270
275 virtual void EnableColourCorrection( TBOOL a_bEnable );
276
281 virtual void ForceEnableColourCorrection( TBOOL a_bEnable );
282
287 virtual TBOOL IsColourCorrection();
288
294 TBOOL IsTextureFormatSupportedImpl( D3DFORMAT a_eFormat );
295
301 TBOOL Create( const TCHAR* a_szWindowName );
302
307
311 void DestroyAccelTable();
312
316 void CreateAccelTable();
317
322
328 TDebugD3DText* InitDebugText( TINT a_iBufferSize );
329
334
341 void SetTextureAddress( TINT a_iStage, ADDRESSINGMODE a_eAddressing, TEXCOORD a_eTextureCoordinate = TEXCOORD_UV );
342
356 void ClearRegion( TINT a_iX, TINT a_iY, TINT a_iWidth, TINT a_iHeight, TUINT8 a_eClearFlags, TUINT8 a_uiColorR, TUINT8 a_uiColorG, TUINT8 a_uiColorB, TFLOAT a_fZ, TUINT a_uiStencil );
357
361 void Exit() { m_bExited = TTRUE; }
362
367 void RegisterOrderTable( TOrderTable* a_pOrderTable );
368
373 TFORCEINLINE TMSWindow* GetMSWindow() { return &m_Window; }
374
380
385 TFORCEINLINE IDirect3D8* GetDirect3D() const { return m_pDirect3D; }
386
391 TFORCEINLINE IDirect3DDevice8* GetDirect3DDevice() const { return m_pDirectDevice; }
392
393public:
397 static void FlushShaders();
398
406 static TBOOL CreateVertexShader( const DWORD* a_ShaderDeclaration, const DWORD* a_pFunction, DWORD* a_pOutVertexShader );
407
412 static void DestroyVertexShader( DWORD a_hVertexShader );
413
420 static TBOOL CreatePixelShader( const DWORD* a_pFunction, DWORD* a_pOutPixelShader );
421
426 static void DestroyPixelShader( DWORD a_hPixelShader );
427
433 static void PrintError( TINT32 a_eError, const TCHAR* a_szInfo );
434
440 static const TCHAR* GetErrorString( TINT32 a_eError );
441
447 static const TCHAR* GetErrorDescription( TINT32 a_eError );
448
457
458private:
462 void OnD3DDeviceLost();
463
467 void OnD3DDeviceFound();
468
469private:
470 IDirect3D8* m_pDirect3D; // Direct3D interface
471 IDirect3DDevice8* m_pDirectDevice; // Direct3D device
472 D3DPRESENT_PARAMETERS m_PresentParams; // Presentation parameters
473 D3DSURFACE_DESC m_SurfaceDesk; // Surface description
474 float m_fPixelAspectRatio; // Pixel aspect ratio
475 HACCEL m_AcceleratorTable; // Accelerator table
476 TD3DAdapter::Mode::Device* m_pDevice; // Current device
477 DISPLAYPARAMS m_oDisplayParams; // Display parameters
478 TMSWindow m_Window; // Window
479 TBOOL m_bExited; // Exit flag
480 TFLOAT m_fContrast; // Contrast value
481 TFLOAT m_fBrightness; // Brightness value
482 TFLOAT m_fGamma; // Gamma value
483 TFLOAT m_fSaturate; // Saturation value
484 TBOOL m_bChangedColourSettings; // Color settings changed flag
485 TBOOL m_bCheckedCapableColourCorrection; // Color correction capability checked flag
486 TBOOL m_bCapableColourCorrection; // Color correction capability flag
487 TBOOL m_bEnableColourCorrection; // Color correction enabled flag
488 D3DGAMMARAMP m_GammaRamp; // Gamma ramp
489 TBOOL m_bFailed; // Failure flag
490 void* m_Unk1; // Unknown 1
491 void* m_Unk2; // Unknown 2
492 TPriList<TOrderTable> m_OrderTables; // Order tables
493};
494
ADDRESSINGMODE
Texture addressing modes.
Definition TRender.h:39
TEXCOORD
Texture coordinate types for addressing modes.
Definition TRender.h:28
@ TEXCOORD_UV
Definition TRender.h:29
Rendering system interface for the Toshi engine.
#define TSTATICCAST(POINTERTYPE, VALUE)
Definition Defines.h:69
#define OVERRIDE
Definition Defines.h:12
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TFORCEINLINE
Definition Defines.h:74
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
#define TDECLARE_CLASS(THIS_CLASS, PARENT_CLASS)
Definition TObject.h:38
int32_t TINT32
Definition Typedefs.h:12
unsigned int TUINT
Definition Typedefs.h:8
char TCHAR
Definition Typedefs.h:20
uint8_t TUINT8
Definition Typedefs.h:17
float TFLOAT
Definition Typedefs.h:4
int TINT
Definition Typedefs.h:7
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
Definition TTRB.h:253
static const TCHAR * GetErrorDescription(TINT32 a_eError)
Gets the error description for an error code.
virtual TBOOL Supports32BitTextures() OVERRIDE
Checks if 32-bit textures are supported.
virtual void DestroyDebugText() OVERRIDE
Destroys debug text.
virtual void RenderIndexPrimitive(TINT param_2, TINT param_3, TINT param_4, TINT param_5, TINT param_6, TINT param_7) OVERRIDE
Renders an indexed primitive.
virtual TBOOL Create() OVERRIDE
Creates the render interface.
virtual void FlushOrderTables() OVERRIDE
Flushes all order tables.
void RegisterOrderTable(TOrderTable *a_pOrderTable)
Registers an order table.
virtual TBOOL Destroy() OVERRIDE
Destroys the render interface and releases all resources.
void BuildAdapterDatabase()
Builds the adapter database.
virtual TBOOL SetPixelAspectRatio(float a_fPixelAspectRatio) OVERRIDE
Sets the pixel aspect ratio.
virtual void * CreateUnknown(const TCHAR *a_szName, TINT a_iUnk1, TINT a_iUnk2, TINT a_iUnk3) OVERRIDE
Creates an unknown object.
TFORCEINLINE TMSWindow * GetMSWindow()
Gets the MS window.
virtual TBOOL IsTextureFormatSupported(TINT a_eTextureFormat) OVERRIDE
Checks if a texture format is supported.
TFORCEINLINE IDirect3D8 * GetDirect3D() const
Gets the Direct3D interface.
static void PrintError(TINT32 a_eError, const TCHAR *a_szInfo)
Prints error text caused by some directx call.
virtual void UpdateColourSettings()
Updates color correction settings.
void ClearRegion(TINT a_iX, TINT a_iY, TINT a_iWidth, TINT a_iHeight, TUINT8 a_eClearFlags, TUINT8 a_uiColorR, TUINT8 a_uiColorG, TUINT8 a_uiColorB, TFLOAT a_fZ, TUINT a_uiStencil)
Clears a region of the screen.
virtual TBOOL RecreateDisplay(const DISPLAYPARAMS &a_rDisplayParams)
Recreates the display with new parameters.
virtual TBOOL IsCapableColourCorrection()
Checks if color correction is supported.
virtual void SetContrast(TFLOAT a_fConstrast)
Sets the contrast value.
virtual TBOOL IsColourCorrection()
Checks if color correction is enabled.
virtual TFLOAT GetBrightness() const
Gets the current brightness value.
virtual TRenderCapture * CreateCapture() OVERRIDE
Creates a new render capture.
virtual void ForceEnableColourCorrection(TBOOL a_bEnable)
Forces color correction on or off.
static TBOOL CreateVertexShader(const DWORD *a_ShaderDeclaration, const DWORD *a_pFunction, DWORD *a_pOutVertexShader)
Creates a vertex shader.
TFORCEINLINE IDirect3DDevice8 * GetDirect3DDevice() const
Gets the Direct3D device.
void Exit()
Signals the render interface to exit.
static void FlushShaders()
Flushes all order tables and shaders.
virtual void DestroyCapture(TRenderCapture *a_pRenderCapture) OVERRIDE
Destroys a render capture.
virtual void SetSaturate(TFLOAT a_fSaturate)
Sets the saturation value.
void DestroyAccelTable()
Destroys the accelerator table.
virtual TBOOL BeginScene() OVERRIDE
Begins a new rendering scene.
virtual void SetBrightness(TFLOAT a_fBrightness)
Sets the brightness value.
virtual TRenderContext * CreateRenderContext() OVERRIDE
Creates a new render context.
static TFORCEINLINE TRenderD3DInterface * Interface()
Gets the render interface singleton.
virtual void EnableColourCorrection(TBOOL a_bEnable)
Enables or disables color correction.
void GetCurrentColourRamp()
Gets the current color ramp.
virtual TBOOL Update(float a_fDeltaTime) OVERRIDE
Updates the render interface state.
void SetTextureAddress(TINT a_iStage, ADDRESSINGMODE a_eAddressing, TEXCOORD a_eTextureCoordinate=TEXCOORD_UV)
Sets texture addressing mode.
virtual TFLOAT GetGamma() const
Gets the current gamma value.
TFORCEINLINE TPriList< TOrderTable > & GetOrderTables()
Gets the order tables.
virtual float GetPixelAspectRatio() OVERRIDE
Gets the pixel aspect ratio.
static void DestroyPixelShader(DWORD a_hPixelShader)
Destroys a pixel shader.
virtual TFLOAT GetContrast() const
Gets the current contrast value.
static const TCHAR * GetErrorString(TINT32 a_eError)
Gets the error string for an error code.
void CreateAccelTable()
Creates the accelerator table.
virtual DISPLAYPARAMS * GetCurrentDisplayParams() OVERRIDE
Gets the current display parameters.
virtual TModel * CreateModel(TTMD *a_pTMD, TBOOL a_bLoad) OVERRIDE
Creates a model from a TMD file.
TDebugD3DText * InitDebugText(TINT a_iBufferSize)
Initializes debug text.
virtual TDebugText * CreateDebugText() OVERRIDE
Creates debug text.
TBOOL IsTextureFormatSupportedImpl(D3DFORMAT a_eFormat)
Checks if a specific D3D format is supported.
virtual void SetGamma(TFLOAT a_fGamma)
Sets the gamma value.
virtual TBOOL DestroyDisplay() OVERRIDE
Destroys the current display and releases associated resources.
void SetDeviceDefaultStates()
Sets default device states.
virtual TRenderAdapter::Mode::Device * GetCurrentDevice() OVERRIDE
Gets the current rendering device.
virtual void OnInitializationFailureDisplay() OVERRIDE
Called when display initialization fails.
static TBOOL CreatePixelShader(const DWORD *a_pFunction, DWORD *a_pOutPixelShader)
Creates a pixel shader.
virtual TBOOL EndScene() OVERRIDE
Ends the current rendering scene and presents the results.
static void DestroyVertexShader(DWORD a_hVertexShader)
Destroys a vertex shader.
virtual TFLOAT GetSaturate() const
Gets the current saturation value.
virtual void OnInitializationFailureDevice() OVERRIDE
Called when device initialization fails.
static TFORCEINLINE TRenderInterface * GetSingleton()
Definition TSingleton.h:49