You can get access to the Direct3D interface and device by using these functions:
IDirect3D9* dbGetDirect3D ( void );
IDirect3DDevice9* dbGetDirect3DDevice ( void );
Here's some source code showing how to make an object at runtime:
#include <DarkGDK.h>
bool CreateNewObject ( int iID, LPSTR pName, int iFrame );
bool SetupStandardVertex ( DWORD dwFVF, BYTE* pVertex, int iOffset, float x, float y, float z, float nx, float ny, float nz, DWORD dwDiffuseColour, float tu, float tv );
bool SetupMeshFVFData ( sMesh* pMesh, DWORD dwFVF, DWORD dwVertexCount, DWORD dwIndexCount );
bool SetNewObjectFinalProperties ( int iID, float fRadius );
void SetTexture ( int iID, int iImage );
void DarkGDK ( void )
{
CreateNewObject ( 1, "triangle", 1 );
sObject* pObject = dbGetObject ( 1 );
sFrame* pFrame = pObject->pFrame;
sMesh* pMesh = pObject->pFrame->pMesh;
SetupMeshFVFData ( pMesh, D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1, 3, 0 );
SetupStandardVertex (
pMesh->dwFVF,
pMesh->pVertexData,
0,
0.0f, 0.0f, 0.0f,
0.0f, 0.0f, -1.0f,
D3DCOLOR_ARGB ( 255, 255, 255, 255 ),
0.0f, 0.0f
);
SetupStandardVertex (
pMesh->dwFVF,
pMesh->pVertexData,
1,
1.0f, 1.0f, 0.0f,
0.0f, 0.0f, -1.0f,
D3DCOLOR_ARGB ( 255, 255, 255, 255 ),
0.0f, 0.0f
);
SetupStandardVertex (
pMesh->dwFVF,
pMesh->pVertexData,
2,
1.0f, 0.0f, 0.0f,
0.0f, 0.0f, -1.0f,
D3DCOLOR_ARGB ( 255, 255, 255, 255 ),
0.0f, 0.0f
);
pMesh->iPrimitiveType = D3DPT_TRIANGLELIST;
pMesh->iDrawVertexCount = 3;
pMesh->iDrawPrimitives = 1;
SetNewObjectFinalProperties ( 1, 0.0f );
SetTexture ( 1, 0 );
while ( LoopGDK ( ) )
{
if ( dbSpaceKey ( ) )
{
dbColorObject ( 1, dbRgb ( 0, 255, 0 ) );
dbSetObjectCull ( 1, 0 );
dbTurnObjectLeft ( 1, 1.0f );
}
dbSync ( );
}
}