From 2d1065985dff6e281d582810f51105441c386f53 Mon Sep 17 00:00:00 2001 From: AdventureT Date: Sat, 6 Jan 2024 13:15:57 +0100 Subject: [PATCH] Added vtable to TRenderInterface --- Toshi/Include/TKernel/TMatrix44.h | 11 ++ Toshi/Include/TRender/TModel.h | 11 ++ Toshi/Include/TRender/TRenderCapture.h | 30 +++++ Toshi/Include/TRender/TRenderInterface.h | 44 +++++++- Toshi/Include/TRender/TSceneObject.h | 12 ++ Toshi/Include/TRender/TViewport.h | 12 ++ .../Include/TRenderD3D/TRenderD3DInterface.h | 19 +++- Toshi/Source/TKernel/TMatrix44.cpp | 1 + Toshi/Source/TRender/TModel.cpp | 1 + Toshi/Source/TRender/TRenderCapture.cpp | 1 + Toshi/Source/TRender/TRenderInterface.cpp | 104 ++++++++++++++++++ Toshi/Source/TRender/TSceneObject.cpp | 5 + Toshi/Source/TRender/TViewport.cpp | 5 + .../Source/TRenderD3D/TRenderD3DInterface.cpp | 77 +++++++++++++ 14 files changed, 326 insertions(+), 7 deletions(-) create mode 100644 Toshi/Include/TKernel/TMatrix44.h create mode 100644 Toshi/Include/TRender/TModel.h create mode 100644 Toshi/Include/TRender/TRenderCapture.h create mode 100644 Toshi/Include/TRender/TSceneObject.h create mode 100644 Toshi/Include/TRender/TViewport.h create mode 100644 Toshi/Source/TKernel/TMatrix44.cpp create mode 100644 Toshi/Source/TRender/TModel.cpp create mode 100644 Toshi/Source/TRender/TRenderCapture.cpp create mode 100644 Toshi/Source/TRender/TSceneObject.cpp create mode 100644 Toshi/Source/TRender/TViewport.cpp diff --git a/Toshi/Include/TKernel/TMatrix44.h b/Toshi/Include/TKernel/TMatrix44.h new file mode 100644 index 0000000..477318f --- /dev/null +++ b/Toshi/Include/TKernel/TMatrix44.h @@ -0,0 +1,11 @@ +#pragma once +#include "TDebug.h" + +TOSHI_NAMESPACE_BEGIN + +class TKERNELINTERFACE_EXPORTS TMatrix44 +{ + +}; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Include/TRender/TModel.h b/Toshi/Include/TRender/TModel.h new file mode 100644 index 0000000..ae526db --- /dev/null +++ b/Toshi/Include/TRender/TModel.h @@ -0,0 +1,11 @@ +#pragma once +#include "Defines.h" + +TOSHI_NAMESPACE_BEGIN + +class TRENDERINTERFACE_EXPORTS TModel +{ + +}; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Include/TRender/TRenderCapture.h b/Toshi/Include/TRender/TRenderCapture.h new file mode 100644 index 0000000..2543517 --- /dev/null +++ b/Toshi/Include/TRender/TRenderCapture.h @@ -0,0 +1,30 @@ +#pragma once +#include "Defines.h" +#include "TKernel/TDebug.h" + +TOSHI_NAMESPACE_BEGIN + +class TRENDERINTERFACE_EXPORTS TRenderCapture +{ +public: + + enum FORMAT + { + FORMAT_RGBA32, + FORMAT_RGB24, + }; + + TRenderCapture() = default; + + virtual ~TRenderCapture() = default; + virtual TBOOL Create(FORMAT, TINT a_iUnk, TINT a_iUnk2) = 0; + virtual void Destroy() = 0; + virtual TBOOL Request() = 0; + virtual TBOOL Wait() = 0; + virtual TBOOL Poll() = 0; + virtual TPVOID ObtainBuffer() = 0; + virtual void ReleaseBuffer() = 0; + +}; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Include/TRender/TRenderInterface.h b/Toshi/Include/TRender/TRenderInterface.h index 5e143ca..e224d69 100644 --- a/Toshi/Include/TRender/TRenderInterface.h +++ b/Toshi/Include/TRender/TRenderInterface.h @@ -6,6 +6,11 @@ #include "TResource.h" #include "TRenderAdapter.h" #include "TTextureFactory.h" +#include "TViewport.h" +#include "TKernel/TVector2.h" +#include "TKernel/TMatrix44.h" +#include "TRenderCapture.h" +#include "TModel.h" TOSHI_NAMESPACE_BEGIN @@ -54,17 +59,48 @@ class TRENDERINTERFACE_EXPORTS TRenderInterface : public TObject SYSRESOURCES_NUMOF = 19 }; + struct DisplayParams + { + TUINT32 uiWidth; + TUINT32 uiHeight; + TUINT32 uiColourDepth; + TUINT32 eDepthStencilFormat; + TBOOL bWindowed; + }; + public: TRenderInterface(); +public: + virtual TBOOL CreateDisplay(const DisplayParams& a_rParams) = 0; + virtual TBOOL DestroyDisplay() = 0; + virtual TBOOL Update(float a_fDeltaTime) = 0; + virtual TBOOL BeginScene() = 0; + virtual TBOOL EndScene() = 0; + virtual TRenderAdapter::Mode::Device* GetCurrentDevice() = 0; + virtual DisplayParams* GetCurrentDisplayParams() = 0; virtual TBOOL Create(TKernelInterface* pKernelInterface); + virtual TBOOL Destroy(); + virtual void RenderIndexPrimitive(int param_2, int param_3, int param_4, int param_5, int param_6, int param_7); + virtual void DumpStats(); + virtual void GetScreenOffset(TVector2& a_rVec); + virtual void SetScreenOffset(const TVector2& a_rVec); + virtual float GetScreenAspectRatio(); + virtual float GetPixelAspectRatio(); + virtual TBOOL SetPixelAspectRatio(float a_fPixelAspectRatio); virtual TBOOL IsTextureFormatSupported(TTEXTURERESOURCEFORMAT a_eTextureFormat) { return TTRUE; } virtual TBOOL Supports32BitTextures() { return TFALSE; } - -protected: - + virtual TRenderContext* CreateRenderContext() = 0; + virtual TRenderCapture* CreateCapture() = 0; + virtual void DestroyCapture(TRenderCapture* a_pRenderCapture) = 0; + virtual void SetLightDirectionMatrix(const TMatrix44& a_rMatrix); + virtual void SetLightColourMatrix(const TMatrix44& a_rMatrix); + virtual void ConnectDefaultViewportHandelrs(TViewport& a_pViewport); + virtual TModel* CreateModel(TPCCHAR a_szName, TINT a_iUnk1); virtual TBOOL CreateSystemResources(); + virtual void DestroySystemResources(); + public: @@ -84,8 +120,6 @@ class TRENDERINTERFACE_EXPORTS TRenderInterface : public TObject return pLastRenderContext; } - void DumpStats(); - TBOOL IsCreated() { return m_bIsCreated; } TNodeList* GetAdapterList() { return &m_pAdapterList; }; diff --git a/Toshi/Include/TRender/TSceneObject.h b/Toshi/Include/TRender/TSceneObject.h new file mode 100644 index 0000000..4a369b8 --- /dev/null +++ b/Toshi/Include/TRender/TSceneObject.h @@ -0,0 +1,12 @@ +#pragma once +#include "TRender/TResource.h" +#include "Defines.h" + +TOSHI_NAMESPACE_BEGIN + +class TRENDERINTERFACE_EXPORTS TSceneObject : public TResource +{ + DECLARE_DYNAMIC(TSceneObject) +}; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Include/TRender/TViewport.h b/Toshi/Include/TRender/TViewport.h new file mode 100644 index 0000000..2b24048 --- /dev/null +++ b/Toshi/Include/TRender/TViewport.h @@ -0,0 +1,12 @@ +#pragma once +#include "TSceneObject.h" +#include "Defines.h" + +TOSHI_NAMESPACE_BEGIN + +class TRENDERINTERFACE_EXPORTS TViewport : public TSceneObject +{ + DECLARE_DYNAMIC(TViewport) +}; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Include/TRenderD3D/TRenderD3DInterface.h b/Toshi/Include/TRenderD3D/TRenderD3DInterface.h index b4da0a9..ec42945 100644 --- a/Toshi/Include/TRenderD3D/TRenderD3DInterface.h +++ b/Toshi/Include/TRenderD3D/TRenderD3DInterface.h @@ -22,9 +22,25 @@ class TRENDERINTERFACED3D_EXPORTS TRenderD3DInterface : public TRenderInterface static void TOSHI_API TD3DAssert(HRESULT a_hr, TPCCHAR a_pError); - virtual TBOOL Create(TKernelInterface* a_pKernel) override; + virtual TBOOL CreateDisplay(const TRenderInterface::DisplayParams& a_rParams) override; + virtual TBOOL DestroyDisplay() override; + virtual TBOOL Update(float a_fDeltaTime) override; + virtual TBOOL BeginScene() override; + virtual TBOOL EndScene() override; + virtual TRenderAdapter::Mode::Device* GetCurrentDevice() override; + virtual TRenderInterface::DisplayParams* GetCurrentDisplayParams() override; + virtual TBOOL Create(TKernelInterface* pKernelInterface) override; + virtual TBOOL Destroy() override; + virtual void RenderIndexPrimitive(int param_2, int param_3, int param_4, int param_5, int param_6, int param_7) override; + virtual TFLOAT GetPixelAspectRatio() override; + virtual TBOOL SetPixelAspectRatio(float a_fPixelAspectRatio) override; virtual TBOOL IsTextureFormatSupported(TTEXTURERESOURCEFORMAT a_eTextureFormat) override; virtual TBOOL Supports32BitTextures() override; + virtual TRenderContext* CreateRenderContext() override; + virtual TRenderCapture* CreateCapture() override; + virtual void DestroyCapture(TRenderCapture* a_pRenderCapture) override; + virtual void ConnectDefaultViewportHandelrs(TViewport& a_pViewport) override; + virtual TModel* CreateModel(TPCCHAR a_szName, TINT a_iUnk1) override; TBOOL IsTextureFormatSupported(D3DFORMAT a_eFormat); void Exit() { m_bIsExited = TTRUE; } @@ -44,7 +60,6 @@ class TRENDERINTERFACED3D_EXPORTS TRenderD3DInterface : public TRenderInterface IDirect3DDevice8* GetD3DDevice() { return m_pD3DDevice; } IDirect3D8* GetD3DInterface() { return m_pD3DInterface; } TMSWindow* GetMSWindow() { return &m_pMSWindow; } - TD3DAdapter::Mode::Device* GetCurrentDevice() { return m_pCurrentDevice; } private: IDirect3D8* m_pD3DInterface; // 0x17C diff --git a/Toshi/Source/TKernel/TMatrix44.cpp b/Toshi/Source/TKernel/TMatrix44.cpp new file mode 100644 index 0000000..53a6b1a --- /dev/null +++ b/Toshi/Source/TKernel/TMatrix44.cpp @@ -0,0 +1 @@ +#include "TMatrix44.h" \ No newline at end of file diff --git a/Toshi/Source/TRender/TModel.cpp b/Toshi/Source/TRender/TModel.cpp new file mode 100644 index 0000000..d417362 --- /dev/null +++ b/Toshi/Source/TRender/TModel.cpp @@ -0,0 +1 @@ +#include "TModel.h" \ No newline at end of file diff --git a/Toshi/Source/TRender/TRenderCapture.cpp b/Toshi/Source/TRender/TRenderCapture.cpp new file mode 100644 index 0000000..21cc33a --- /dev/null +++ b/Toshi/Source/TRender/TRenderCapture.cpp @@ -0,0 +1 @@ +#include "TRender/TRenderCapture.h" \ No newline at end of file diff --git a/Toshi/Source/TRender/TRenderInterface.cpp b/Toshi/Source/TRender/TRenderInterface.cpp index 21d22ea..ca6c4fe 100644 --- a/Toshi/Source/TRender/TRenderInterface.cpp +++ b/Toshi/Source/TRender/TRenderInterface.cpp @@ -16,9 +16,46 @@ TRenderInterface::TRenderInterface() m_pCurrentRenderContext = TNULL; m_pKernel = TNULL; m_iResourceCount = 1; + TCString("Creating TRenderInterface\n").Print(); TASSERT(s_Interface == TNULL); s_Interface = this; TSystem::MemSet(m_aSysResources, 0, sizeof(m_aSysResources)); + TCString("Created TRenderInterface\n").Print(); +} + +TBOOL TRenderInterface::CreateDisplay(const DisplayParams& a_rParams) +{ + return TBOOL(); +} + +TBOOL TRenderInterface::DestroyDisplay() +{ + return TBOOL(); +} + +TBOOL TRenderInterface::Update(float a_fDeltaTime) +{ + return TBOOL(); +} + +TBOOL TRenderInterface::BeginScene() +{ + return TBOOL(); +} + +TBOOL TRenderInterface::EndScene() +{ + return TBOOL(); +} + +TRenderAdapter::Mode::Device* TRenderInterface::GetCurrentDevice() +{ + return TNULL; +} + +TRenderInterface::DisplayParams* TRenderInterface::GetCurrentDisplayParams() +{ + return nullptr; } @@ -65,6 +102,10 @@ TBOOL TRenderInterface::CreateSystemResources() return TTRUE; } +void TRenderInterface::DestroySystemResources() +{ +} + TResource* TRenderInterface::CreateResource(const TClass* a_pClass, TPCCHAR a_szResName, TResource* a_pParent) { TASSERT(TNULL != a_pClass); @@ -92,6 +133,69 @@ TResource* TRenderInterface::CreateResource(const TClass* a_pClass, TPCCHAR a_sz return pResource; } +TBOOL TRenderInterface::Destroy() +{ + return TBOOL(); +} + +void TRenderInterface::RenderIndexPrimitive(int param_2, int param_3, int param_4, int param_5, int param_6, int param_7) +{ +} + void TRenderInterface::DumpStats() { } + +void TRenderInterface::GetScreenOffset(TVector2& a_rVec) +{ +} + +void TRenderInterface::SetScreenOffset(const TVector2& a_rVec) +{ +} + +float TRenderInterface::GetScreenAspectRatio() +{ + return 0.0f; +} + +float TRenderInterface::GetPixelAspectRatio() +{ + return 0.0f; +} + +TBOOL TRenderInterface::SetPixelAspectRatio(float a_fPixelAspectRatio) +{ + return TBOOL(); +} + +TRenderContext* TRenderInterface::CreateRenderContext() +{ + return nullptr; +} + +TRenderCapture* TRenderInterface::CreateCapture() +{ + return nullptr; +} + +void TRenderInterface::DestroyCapture(TRenderCapture* a_pRenderCapture) +{ +} + +void TRenderInterface::SetLightDirectionMatrix(const TMatrix44& a_rMatrix) +{ +} + +void TRenderInterface::SetLightColourMatrix(const TMatrix44& a_rMatrix) +{ +} + +void TRenderInterface::ConnectDefaultViewportHandelrs(TViewport& a_pViewport) +{ +} + +TModel* TRenderInterface::CreateModel(TPCCHAR a_szName, TINT a_iUnk1) +{ + return nullptr; +} diff --git a/Toshi/Source/TRender/TSceneObject.cpp b/Toshi/Source/TRender/TSceneObject.cpp new file mode 100644 index 0000000..92dbfd0 --- /dev/null +++ b/Toshi/Source/TRender/TSceneObject.cpp @@ -0,0 +1,5 @@ +#include "TSceneObject.h" + +TOSHI_NAMESPACE_USING + +IMPLEMENT_DYNCREATE(TSceneObject, TResource) \ No newline at end of file diff --git a/Toshi/Source/TRender/TViewport.cpp b/Toshi/Source/TRender/TViewport.cpp new file mode 100644 index 0000000..ad1d3c9 --- /dev/null +++ b/Toshi/Source/TRender/TViewport.cpp @@ -0,0 +1,5 @@ +#include "TViewport.h" + +TOSHI_NAMESPACE_USING + +IMPLEMENT_DYNCREATE(TViewport, TSceneObject) \ No newline at end of file diff --git a/Toshi/Source/TRenderD3D/TRenderD3DInterface.cpp b/Toshi/Source/TRenderD3D/TRenderD3DInterface.cpp index 2bed026..8f86db6 100644 --- a/Toshi/Source/TRenderD3D/TRenderD3DInterface.cpp +++ b/Toshi/Source/TRenderD3D/TRenderD3DInterface.cpp @@ -28,6 +28,41 @@ void TOSHI_API TRenderD3DInterface::TD3DAssert(HRESULT a_hr, TPCCHAR a_pError) } } +TBOOL TRenderD3DInterface::CreateDisplay(const TRenderInterface::DisplayParams& a_rParams) +{ + return TBOOL(); +} + +TBOOL TRenderD3DInterface::DestroyDisplay() +{ + return TBOOL(); +} + +TBOOL TRenderD3DInterface::Update(float a_fDeltaTime) +{ + return TBOOL(); +} + +TBOOL TRenderD3DInterface::BeginScene() +{ + return TBOOL(); +} + +TBOOL TRenderD3DInterface::EndScene() +{ + return TBOOL(); +} + +TRenderAdapter::Mode::Device* TRenderD3DInterface::GetCurrentDevice() +{ + return nullptr; +} + +TRenderInterface::DisplayParams* TRenderD3DInterface::GetCurrentDisplayParams() +{ + return nullptr; +} + TBOOL TRenderD3DInterface::Create(TKernelInterface* a_pKernel) { TASSERT(TFALSE==IsCreated()); @@ -58,6 +93,48 @@ TBOOL TRenderD3DInterface::Create(TKernelInterface* a_pKernel) return TTRUE; } +TBOOL TRenderD3DInterface::Destroy() +{ + return TBOOL(); +} + +void TRenderD3DInterface::RenderIndexPrimitive(int param_2, int param_3, int param_4, int param_5, int param_6, int param_7) +{ +} + +float TRenderD3DInterface::GetPixelAspectRatio() +{ + return 0.0f; +} + +TBOOL TRenderD3DInterface::SetPixelAspectRatio(float a_fPixelAspectRatio) +{ + return TBOOL(); +} + +TRenderContext* TRenderD3DInterface::CreateRenderContext() +{ + return nullptr; +} + +TRenderCapture* TRenderD3DInterface::CreateCapture() +{ + return nullptr; +} + +void TRenderD3DInterface::DestroyCapture(TRenderCapture* a_pRenderCapture) +{ +} + +void TRenderD3DInterface::ConnectDefaultViewportHandelrs(TViewport& a_pViewport) +{ +} + +TModel* TRenderD3DInterface::CreateModel(TPCCHAR a_szName, TINT a_iUnk1) +{ + return nullptr; +} + TBOOL TRenderD3DInterface::IsTextureFormatSupported(TTEXTURERESOURCEFORMAT a_eTextureFormat) { switch (a_eTextureFormat) {