Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dxDrawPrimitive3D and dxDrawMaterialPrimitive3D #760

Merged
merged 10 commits into from Sep 2, 2019
@@ -1894,6 +1894,10 @@ void CCore::OnDeviceRestore(void)
void CCore::OnPreFxRender(void)
{
// Don't do nothing if nothing won't be drawn

if (CGraphics::GetSingleton().HasPrimitive3DPreGUIQueueItems())
CGraphics::GetSingleton().DrawPrimitive3DPreGUIQueue();

if (!CGraphics::GetSingleton().HasLine3DPreGUIQueueItems())
return;

@@ -15,6 +15,8 @@
#include "CMaterialLine3DBatcher.h"
#include "CPrimitiveBatcher.h"
#include "CPrimitiveMaterialBatcher.h"
#include "CPrimitive3DBatcher.h"
#include "CMaterialPrimitive3DBatcher.h"
#include "CAspectRatioConverter.h"
extern CCore* g_pCore;
extern bool g_bInGTAScene;
@@ -58,6 +60,10 @@ CGraphics::CGraphics(CLocalGUI* pGUI)
m_pLine3DBatcherPostGUI = new CLine3DBatcher(false);
m_pMaterialLine3DBatcherPreGUI = new CMaterialLine3DBatcher(true);
m_pMaterialLine3DBatcherPostGUI = new CMaterialLine3DBatcher(false);
m_pPrimitive3DBatcherPreGUI = new CPrimitive3DBatcher(true);
m_pPrimitive3DBatcherPostGUI = new CPrimitive3DBatcher(false);
m_pMaterialPrimitive3DBatcherPreGUI = new CMaterialPrimitive3DBatcher(true, this);
m_pMaterialPrimitive3DBatcherPostGUI = new CMaterialPrimitive3DBatcher(false, this);
m_pPrimitiveBatcher = new CPrimitiveBatcher();
m_pPrimitiveMaterialBatcher = new CPrimitiveMaterialBatcher(this);

@@ -84,6 +90,10 @@ CGraphics::~CGraphics(void)
SAFE_DELETE(m_pMaterialLine3DBatcherPostGUI);
SAFE_DELETE(m_pPrimitiveBatcher);
SAFE_DELETE(m_pPrimitiveMaterialBatcher);
SAFE_DELETE(m_pPrimitive3DBatcherPreGUI);
SAFE_DELETE(m_pPrimitive3DBatcherPostGUI);
SAFE_DELETE(m_pMaterialPrimitive3DBatcherPreGUI);
SAFE_DELETE(m_pMaterialPrimitive3DBatcherPostGUI);
SAFE_DELETE(m_pScreenGrabber);
SAFE_DELETE(m_pPixelsManager);
SAFE_DELETE(m_pAspectRatioConverter);
@@ -875,6 +885,44 @@ void CGraphics::DrawPrimitiveQueued(std::vector<PrimitiveVertice>* pVecVertices,
AddQueueItem (Item, bPostGUI);
}

void CGraphics::DrawPrimitive3DQueued(std::vector<PrimitiveVertice>* pVecVertices, D3DPRIMITIVETYPE eType, bool bPostGUI)
{
// Prevent queuing when minimized
if (g_pCore->IsWindowMinimized())
{
delete pVecVertices;
return;
}

// Add it to the queue
if (bPostGUI && !CCore::GetSingleton().IsMenuVisible())
m_pPrimitive3DBatcherPostGUI->AddPrimitive(eType, pVecVertices);
else
m_pPrimitive3DBatcherPreGUI->AddPrimitive(eType, pVecVertices);
}

void CGraphics::DrawMaterialPrimitive3DQueued(std::vector<PrimitiveMaterialVertice>* pVecVertices, D3DPRIMITIVETYPE eType, CMaterialItem* pMaterial, bool bPostGUI)
{
// Prevent queuing when minimized
if (g_pCore->IsWindowMinimized())
{
delete pVecVertices;
return;
}

if (CShaderItem* pShaderItem = DynamicCast<CShaderItem>(pMaterial))
{
// If material is a shader, use its current instance
pMaterial = pShaderItem->m_pShaderInstance;
}

// Add it to the queue
if (bPostGUI && !CCore::GetSingleton().IsMenuVisible())
m_pMaterialPrimitive3DBatcherPostGUI->AddPrimitive(eType, pMaterial, pVecVertices);
else
m_pMaterialPrimitive3DBatcherPreGUI->AddPrimitive(eType, pMaterial, pVecVertices);
}

void CGraphics::DrawMaterialPrimitiveQueued(std::vector<PrimitiveMaterialVertice>* pVecVertices, D3DPRIMITIVETYPE eType, CMaterialItem* pMaterial,
bool bPostGUI)
{
@@ -1408,7 +1456,10 @@ void CGraphics::OnDeviceCreate(IDirect3DDevice9* pDevice)
m_pMaterialLine3DBatcherPreGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
m_pMaterialLine3DBatcherPostGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
m_pPrimitiveBatcher->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
m_pPrimitiveMaterialBatcher->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
m_pPrimitive3DBatcherPreGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
m_pPrimitive3DBatcherPostGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
m_pMaterialPrimitive3DBatcherPreGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
m_pMaterialPrimitive3DBatcherPostGUI->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
m_pRenderItemManager->OnDeviceCreate(pDevice, GetViewportWidth(), GetViewportHeight());
m_pScreenGrabber->OnDeviceCreate(pDevice);
m_pPixelsManager->OnDeviceCreate(pDevice);
@@ -1484,6 +1535,8 @@ void CGraphics::DrawPostGUIQueue(void)
DrawQueue(m_PostGUIQueue);
m_pLine3DBatcherPostGUI->Flush();
m_pMaterialLine3DBatcherPostGUI->Flush();
m_pPrimitive3DBatcherPostGUI->Flush();
m_pMaterialPrimitive3DBatcherPostGUI->Flush();

// Both queues should be empty now, and there should be no outstanding refs
assert(m_PreGUIQueue.empty() && m_iDebugQueueRefs == 0);
@@ -1495,11 +1548,22 @@ void CGraphics::DrawLine3DPreGUIQueue(void)
m_pMaterialLine3DBatcherPreGUI->Flush();
}

void CGraphics::DrawPrimitive3DPreGUIQueue(void)
This conversation was marked as resolved by patrikjuvonen

This comment has been minimized.

Copy link
@botder

botder Jan 12, 2019

Member

Replace (void) with ().

{
m_pPrimitive3DBatcherPreGUI->Flush();
m_pMaterialPrimitive3DBatcherPreGUI->Flush();
}

bool CGraphics::HasLine3DPreGUIQueueItems(void)
{
return m_pLine3DBatcherPreGUI->HasItems() || m_pMaterialLine3DBatcherPreGUI->HasItems();
}

bool CGraphics::HasPrimitive3DPreGUIQueueItems(void)
This conversation was marked as resolved by patrikjuvonen

This comment has been minimized.

Copy link
@botder

botder Jan 12, 2019

Member

Replace (void) with ().

{
return m_pMaterialPrimitive3DBatcherPreGUI->HasItems() || m_pPrimitive3DBatcherPreGUI->HasItems();
}

void CGraphics::DrawQueue(std::vector<sDrawQueueItem>& Queue)
{
BeginDrawBatch();
@@ -28,6 +28,8 @@ class CLine3DBatcher;
class CMaterialLine3DBatcher;
class CPrimitiveBatcher;
class CPrimitiveMaterialBatcher;
class CPrimitive3DBatcher;
class CMaterialPrimitive3DBatcher;
class CAspectRatioConverter;
struct IDirect3DDevice9;
struct IDirect3DSurface9;
@@ -65,6 +67,7 @@ class CGraphics : public CGraphicsInterface, public CSingleton<CGraphics>
{
friend class CDirect3DEvents9;
friend CPrimitiveMaterialBatcher;
friend CMaterialPrimitive3DBatcher;

public:
ZERO_ON_NEW
@@ -147,6 +150,10 @@ class CGraphics : public CGraphicsInterface, public CSingleton<CGraphics>

void DrawPrimitiveQueued(std::vector<PrimitiveVertice>* pVecVertices, D3DPRIMITIVETYPE eType, bool bPostGUI = false);
void DrawMaterialPrimitiveQueued(std::vector<PrimitiveMaterialVertice>* vertices, D3DPRIMITIVETYPE type, CMaterialItem* pMaterial, bool bPostGUI);

void DrawPrimitive3DQueued(std::vector<PrimitiveVertice>* pVecVertices, D3DPRIMITIVETYPE eType, bool bPostGUI);
void DrawMaterialPrimitive3DQueued(std::vector<PrimitiveMaterialVertice>* pVecVertices, D3DPRIMITIVETYPE eType, CMaterialItem* pMaterial, bool bPostGUI);

void DrawCircleQueued(float fX, float fY, float fRadius, float fStartAngle, float fStopAngle, unsigned long ulColor, unsigned long ulColorCenter,
short siSegments, float fRatio, bool bPostGUI);

@@ -178,6 +185,8 @@ class CGraphics : public CGraphicsInterface, public CSingleton<CGraphics>
void DrawPostGUIQueue(void);
void DrawLine3DPreGUIQueue(void);
bool HasLine3DPreGUIQueueItems(void);
void DrawPrimitive3DPreGUIQueue(void);
This conversation was marked as resolved by patrikjuvonen

This comment has been minimized.

Copy link
@botder

botder Jan 12, 2019

Member

Replace (void) with ().

bool HasPrimitive3DPreGUIQueueItems(void);
This conversation was marked as resolved by patrikjuvonen

This comment has been minimized.

Copy link
@botder

botder Jan 12, 2019

Member

Replace (void) with ().


void DidRenderScene(void);
void SetProgressMessage(const SString& strMessage);
@@ -207,17 +216,21 @@ class CGraphics : public CGraphicsInterface, public CSingleton<CGraphics>

IDirect3DDevice9* m_pDevice;

CRenderItemManager* m_pRenderItemManager;
CScreenGrabberInterface* m_pScreenGrabber;
CPixelsManagerInterface* m_pPixelsManager;
CTileBatcher* m_pTileBatcher;
CLine3DBatcher* m_pLine3DBatcherPreGUI;
CLine3DBatcher* m_pLine3DBatcherPostGUI;
CMaterialLine3DBatcher* m_pMaterialLine3DBatcherPreGUI;
CMaterialLine3DBatcher* m_pMaterialLine3DBatcherPostGUI;
CPrimitiveBatcher* m_pPrimitiveBatcher;
CPrimitiveMaterialBatcher* m_pPrimitiveMaterialBatcher;
CAspectRatioConverter* m_pAspectRatioConverter;
CRenderItemManager* m_pRenderItemManager;
CScreenGrabberInterface* m_pScreenGrabber;
CPixelsManagerInterface* m_pPixelsManager;
CTileBatcher* m_pTileBatcher;
CLine3DBatcher* m_pLine3DBatcherPreGUI;
CLine3DBatcher* m_pLine3DBatcherPostGUI;
CMaterialLine3DBatcher* m_pMaterialLine3DBatcherPreGUI;
CMaterialLine3DBatcher* m_pMaterialLine3DBatcherPostGUI;
CPrimitiveBatcher* m_pPrimitiveBatcher;
CPrimitiveMaterialBatcher* m_pPrimitiveMaterialBatcher;
CPrimitive3DBatcher* m_pPrimitive3DBatcherPreGUI;
CPrimitive3DBatcher* m_pPrimitive3DBatcherPostGUI;
CMaterialPrimitive3DBatcher* m_pMaterialPrimitive3DBatcherPreGUI;
CMaterialPrimitive3DBatcher* m_pMaterialPrimitive3DBatcherPostGUI;
CAspectRatioConverter* m_pAspectRatioConverter;

// Fonts
ID3DXFont* m_pDXFonts[NUM_FONTS];
ProTip! Use n and p to navigate between commits in a pull request.
You can鈥檛 perform that action at this time.