Skip to content

Commit

Permalink
First window yay
Browse files Browse the repository at this point in the history
  • Loading branch information
AdventureT committed Jan 6, 2024
1 parent 2d10659 commit c7f0e69
Show file tree
Hide file tree
Showing 9 changed files with 488 additions and 21 deletions.
84 changes: 84 additions & 0 deletions OpenJPOG/Source/Tasks/ARootTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ ARootTask::ARootTask()
TBOOL ARootTask::OnCreate()
{
m_pMoviePlayer = new ABINKMoviePlayer();
if (!CreateRenderInterface()) {
return TFALSE;
}
return TTask::OnCreate();
}

Expand All @@ -42,3 +45,84 @@ void ARootTask::AllocateInputSystem()
m_pInputTask = pScheduler->CreateTask(TGetClass(ADummyTask), pInputTask);
m_pVibrationTask = (AVibrationManager*)pScheduler->CreateTask(TGetClass(AVibrationManager), pInputTask);
}

TBOOL ARootTask::CreateRenderInterface()
{
TRenderInterface::DisplayParams displayParams;
displayParams.uiWidth = 640;
displayParams.uiHeight = 480;
displayParams.bWindowed = TTRUE;
displayParams.uiColourDepth = 32;
displayParams.eDepthStencilFormat = 0;
CreateDisplayDevice(displayParams, TFALSE);
m_pRenderInterface->CreateDisplay(displayParams);
return TTRUE;
}

const TRenderAdapter::Mode::Device* ARootTask::CreateDisplayDevice(TRenderInterface::DisplayParams& a_rDisplayParams, bool a_bReverseOrder)
{
TRenderInterface* pRenderer = TRenderInterface::GetRenderer();
const TRenderAdapter::Mode::Device* pDevice = TNULL;

if (a_bReverseOrder)
{
a_rDisplayParams.eDepthStencilFormat = 4;
pDevice = pRenderer->FindDevice(&a_rDisplayParams);

if (!pDevice)
{
a_rDisplayParams.eDepthStencilFormat = 2;
pDevice = pRenderer->FindDevice(&a_rDisplayParams);

if (!pDevice)
{
a_rDisplayParams.eDepthStencilFormat = 3;
pDevice = pRenderer->FindDevice(&a_rDisplayParams);

if (!pDevice)
{
a_rDisplayParams.eDepthStencilFormat = 0;
pDevice = pRenderer->FindDevice(&a_rDisplayParams);

if (!pDevice)
{
a_rDisplayParams.eDepthStencilFormat = 1;
pDevice = pRenderer->FindDevice(&a_rDisplayParams);
}
}
}
}
}
else
{
pDevice = pRenderer->FindDevice(&a_rDisplayParams);
a_rDisplayParams.eDepthStencilFormat = 0;

if (!pDevice)
{
a_rDisplayParams.eDepthStencilFormat = 1;
pDevice = pRenderer->FindDevice(&a_rDisplayParams);

if (!pRenderer->FindDevice(&a_rDisplayParams))
{
a_rDisplayParams.eDepthStencilFormat = 2;
pDevice = pRenderer->FindDevice(&a_rDisplayParams);

if (!pRenderer->FindDevice(&a_rDisplayParams))
{
a_rDisplayParams.eDepthStencilFormat = 4;
pDevice = pRenderer->FindDevice(&a_rDisplayParams);

if (!pRenderer->FindDevice(&a_rDisplayParams))
{
a_rDisplayParams.eDepthStencilFormat = 3;
pDevice = pRenderer->FindDevice(&a_rDisplayParams);
}
}
}
}
}

return pDevice;

}
4 changes: 4 additions & 0 deletions OpenJPOG/Source/Tasks/ARootTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "GUI/AGUISystem.h"
#include "ARootStateController.h"


class ARootTask : public Toshi::TTask
{
DECLARE_DYNAMIC(ARootTask);
Expand All @@ -35,6 +36,9 @@ class ARootTask : public Toshi::TTask
void AllocateRenderInterface();
void AllocateInputSystem();

TBOOL CreateRenderInterface();
const Toshi::TRenderAdapter::Mode::Device* CreateDisplayDevice(Toshi::TRenderInterface::DisplayParams& a_rDisplayParams, bool a_bReverseOrder);

private:
Toshi::TCString m_szName;
AGUISystem* m_pGUISystem; // 0x34
Expand Down
16 changes: 16 additions & 0 deletions Toshi/Include/TRender/TRenderInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class TRENDERINTERFACE_EXPORTS TRenderInterface : public TObject

TResource* CreateResource(const TClass* a_pClass, TPCCHAR a_szResName, TResource* a_pResource);

const TRenderAdapter::Mode::Device* FindDevice(const DisplayParams* a_pDisplayParams);

void FlushDyingResources();

TResource* GetSystemResource(SYSRESOURCES a_SystemResource)
{
TASSERT(a_SystemResource < TRenderInterface::SYSRESOURCES_NUMOF);
Expand All @@ -121,20 +125,32 @@ class TRENDERINTERFACE_EXPORTS TRenderInterface : public TObject
}

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

static TRenderInterface* TOSHI_API GetRenderer() { return s_Interface; }

private:

void DestroyDyingResources(TResource* a_pResource);
void DeleteResource(TResource* a_pResource);
void DeleteResourceRecurse(TResource* a_pResource);
void DeleteResourceAtomic(TResource* a_pResource);

static TRenderInterface* s_Interface;
protected:


TBOOL m_bIsCreated; // 0x9
TBOOL m_bIsDiplayCreated; // 0xA
TRenderContext* m_pCurrentRenderContext; // 0x1C
TRenderContext* m_pDefaultRenderContext; // 0x20
TKernelInterface* m_pKernel; // 0x24
TResource* m_aSysResources[SYSRESOURCES_NUMOF]; // 0x28
TNodeList<TRenderAdapter> m_pAdapterList; // 0xFC
TINT m_iResourceCount; // 0x124
TNodeTree<TResource> m_Resources; // 0x128
TBOOL m_bHasDyingResources; // 0x12C
};

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

TOSHI_NAMESPACE_BEGIN

class TRENDERINTERFACED3D_EXPORTS TRenderContextD3D : public TRenderContext
{

};

TOSHI_NAMESPACE_END
27 changes: 20 additions & 7 deletions Toshi/Include/TRenderD3D/TRenderD3DInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class TRENDERINTERFACED3D_EXPORTS TRenderD3DInterface : public TRenderInterface
virtual void ConnectDefaultViewportHandelrs(TViewport& a_pViewport) override;
virtual TModel* CreateModel(TPCCHAR a_szName, TINT a_iUnk1) override;

virtual TBOOL IsCapableColourCorrection();
virtual void EnableColourCorrection(TBOOL a_bEnable);

TBOOL IsTextureFormatSupported(D3DFORMAT a_eFormat);
void Exit() { m_bIsExited = TTRUE; }

Expand All @@ -51,24 +54,34 @@ class TRENDERINTERFACED3D_EXPORTS TRenderD3DInterface : public TRenderInterface
void CreateAcceleratorTableA();
void DestroyAcceleratorTable();


protected:

TBOOL LoadShaders();
void SetDefaultRenderStates();

public:

IDirect3DDevice8* GetD3DDevice() { return m_pD3DDevice; }
IDirect3D8* GetD3DInterface() { return m_pD3DInterface; }
TMSWindow* GetMSWindow() { return &m_pMSWindow; }
HACCEL GetAcceleratorTable() { return m_hAccel; }

private:
IDirect3D8* m_pD3DInterface; // 0x17C
IDirect3DDevice8* m_pD3DDevice; // 0x180
D3DPRESENT_PARAMETERS m_oPresentParams; // 0x18C
HACCEL m_hAccel; // 0x1DC
TD3DAdapter::Mode::Device* m_pCurrentDevice; // 0x1E0
TMSWindow m_pMSWindow; // 0x1F8
TBOOL m_bIsExited; // 0x208
TTextureResource* m_pInvalidTexture; // 0xF8
IDirect3D8* m_pD3DInterface; // 0x17C
IDirect3DDevice8* m_pD3DDevice; // 0x180
D3DPRESENT_PARAMETERS m_oPresentParams; // 0x18C
D3DSURFACE_DESC m_oSurfaceDesk; // 0x1B8
HACCEL m_hAccel; // 0x1DC
TD3DAdapter::Mode::Device* m_pCurrentDevice; // 0x1E0
TRenderInterface::DisplayParams m_oDisplayParams; // 0x1E4
TMSWindow m_pMSWindow; // 0x1F8
TBOOL m_bIsExited; // 0x208
TBOOL m_bUsingColorCorrection; // 0x21C
TBOOL m_bCheckedCapableColourCorrection; // 0x21D
TBOOL m_bCapableColourCorrection; // 0x21E
TBOOL m_bEnableColourCorrection; // 0x21F
};

TOSHI_NAMESPACE_END
Loading

0 comments on commit c7f0e69

Please sign in to comment.