ported to DX9

This commit is contained in:
d1str4ught
2025-08-19 03:18:56 +02:00
parent 97a82baa4a
commit e87b6fc67b
130 changed files with 19303 additions and 10435 deletions

View File

@@ -3,24 +3,27 @@
#include "GrpIndexBuffer.h"
#include "StateManager.h"
LPDIRECT3DINDEXBUFFER8 CGraphicIndexBuffer::GetD3DIndexBuffer() const
LPDIRECT3DINDEXBUFFER9 CGraphicIndexBuffer::GetD3DIndexBuffer() const
{
assert(m_lpd3dIdxBuf!=NULL);
assert(m_lpd3dIdxBuf != NULL);
return m_lpd3dIdxBuf;
}
void CGraphicIndexBuffer::SetIndices(int startIndex) const
{
assert(ms_lpd3dDevice!=NULL);
STATEMANAGER.SetIndices(m_lpd3dIdxBuf, startIndex);
assert(ms_lpd3dDevice != NULL);
STATEMANAGER.SetIndices(m_lpd3dIdxBuf, startIndex);
}
bool CGraphicIndexBuffer::Lock(void** pretIndices) const
{
assert(m_lpd3dIdxBuf!=NULL);
assert(m_lpd3dIdxBuf != NULL);
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, (BYTE**)pretIndices, 0)))
if (!m_lpd3dIdxBuf)
return false;
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, pretIndices, 0)))
return false;
return true;
@@ -28,16 +31,22 @@ bool CGraphicIndexBuffer::Lock(void** pretIndices) const
void CGraphicIndexBuffer::Unlock() const
{
assert(m_lpd3dIdxBuf!=NULL);
assert(m_lpd3dIdxBuf != NULL);
if (!m_lpd3dIdxBuf)
return;
m_lpd3dIdxBuf->Unlock();
}
bool CGraphicIndexBuffer::Lock(void** pretIndices)
{
assert(m_lpd3dIdxBuf!=NULL);
assert(m_lpd3dIdxBuf != NULL);
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, (BYTE**)pretIndices, 0)))
if (!m_lpd3dIdxBuf)
return false;
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, pretIndices, 0)))
return false;
return true;
@@ -45,17 +54,20 @@ bool CGraphicIndexBuffer::Lock(void** pretIndices)
void CGraphicIndexBuffer::Unlock()
{
assert(m_lpd3dIdxBuf!=NULL);
assert(m_lpd3dIdxBuf != NULL);
if (!m_lpd3dIdxBuf)
return;
m_lpd3dIdxBuf->Unlock();
}
bool CGraphicIndexBuffer::Copy(int bufSize, const void* srcIndices)
{
assert(m_lpd3dIdxBuf!=NULL);
assert(m_lpd3dIdxBuf != NULL);
BYTE* dstIndices;
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, &dstIndices, 0)))
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, (void**)&dstIndices, 0)))
return false;
memcpy(dstIndices, srcIndices, bufSize);
@@ -73,15 +85,15 @@ bool CGraphicIndexBuffer::Create(int faceCount, TFace* faces)
return false;
WORD* dstIndices;
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, (BYTE**)&dstIndices, 0)))
if (FAILED(m_lpd3dIdxBuf->Lock(0, 0, (void**)&dstIndices, 0)))
return false;
for (int i = 0; i<faceCount; ++i, dstIndices+=3)
{
TFace * curFace=faces+i;
dstIndices[0]=curFace->indices[0];
dstIndices[1]=curFace->indices[1];
dstIndices[2]=curFace->indices[2];
for (int i = 0; i < faceCount; ++i, dstIndices += 3)
{
TFace* curFace = faces + i;
dstIndices[0] = curFace->indices[0];
dstIndices[1] = curFace->indices[1];
dstIndices[2] = curFace->indices[2];
}
m_lpd3dIdxBuf->Unlock();
@@ -91,12 +103,13 @@ bool CGraphicIndexBuffer::Create(int faceCount, TFace* faces)
bool CGraphicIndexBuffer::CreateDeviceObjects()
{
if (FAILED(ms_lpd3dDevice->CreateIndexBuffer(
m_dwBufferSize,
D3DUSAGE_WRITEONLY,
m_dwBufferSize,
D3DUSAGE_WRITEONLY,
m_d3dFmt,
D3DPOOL_MANAGED,
&m_lpd3dIdxBuf)
))
D3DPOOL_MANAGED,
&m_lpd3dIdxBuf,
NULL)
))
return false;
return true;
@@ -108,9 +121,9 @@ void CGraphicIndexBuffer::DestroyDeviceObjects()
}
bool CGraphicIndexBuffer::Create(int idxCount, D3DFORMAT d3dFmt)
{
{
Destroy();
m_iidxCount = idxCount;
m_dwBufferSize = sizeof(WORD) * idxCount;
m_d3dFmt = d3dFmt;
@@ -125,7 +138,7 @@ void CGraphicIndexBuffer::Destroy()
void CGraphicIndexBuffer::Initialize()
{
m_lpd3dIdxBuf=NULL;
m_lpd3dIdxBuf = NULL;
}
CGraphicIndexBuffer::CGraphicIndexBuffer()