Skip to content

Commit

Permalink
Added vtable to TRenderInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
AdventureT committed Jan 6, 2024
1 parent 5788d00 commit 2d10659
Show file tree
Hide file tree
Showing 14 changed files with 326 additions and 7 deletions.
11 changes: 11 additions & 0 deletions Toshi/Include/TKernel/TMatrix44.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include "TDebug.h"

TOSHI_NAMESPACE_BEGIN

class TKERNELINTERFACE_EXPORTS TMatrix44
{

};

TOSHI_NAMESPACE_END
11 changes: 11 additions & 0 deletions Toshi/Include/TRender/TModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include "Defines.h"

TOSHI_NAMESPACE_BEGIN

class TRENDERINTERFACE_EXPORTS TModel
{

};

TOSHI_NAMESPACE_END
30 changes: 30 additions & 0 deletions Toshi/Include/TRender/TRenderCapture.h
Original file line number Diff line number Diff line change
@@ -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
44 changes: 39 additions & 5 deletions Toshi/Include/TRender/TRenderInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:

Expand All @@ -84,8 +120,6 @@ class TRENDERINTERFACE_EXPORTS TRenderInterface : public TObject
return pLastRenderContext;
}

void DumpStats();

TBOOL IsCreated() { return m_bIsCreated; }
TNodeList<TRenderAdapter>* GetAdapterList() { return &m_pAdapterList; };

Expand Down
12 changes: 12 additions & 0 deletions Toshi/Include/TRender/TSceneObject.h
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions Toshi/Include/TRender/TViewport.h
Original file line number Diff line number Diff line change
@@ -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
19 changes: 17 additions & 2 deletions Toshi/Include/TRenderD3D/TRenderD3DInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions Toshi/Source/TKernel/TMatrix44.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "TMatrix44.h"
1 change: 1 addition & 0 deletions Toshi/Source/TRender/TModel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "TModel.h"
1 change: 1 addition & 0 deletions Toshi/Source/TRender/TRenderCapture.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "TRender/TRenderCapture.h"
104 changes: 104 additions & 0 deletions Toshi/Source/TRender/TRenderInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
5 changes: 5 additions & 0 deletions Toshi/Source/TRender/TSceneObject.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "TSceneObject.h"

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(TSceneObject, TResource)
5 changes: 5 additions & 0 deletions Toshi/Source/TRender/TViewport.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "TViewport.h"

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(TViewport, TSceneObject)
Loading

0 comments on commit 2d10659

Please sign in to comment.