Original Post
http://www.nut-shell.com/~josh/Upload/files/ModelTest.zip
this is a small (only 53KB) app, that should explain you my problem while rendering x files...
This is my global model pointer
CD3DFile * enemy;
during the initialisation I use the following code:
enemy = new CD3DFile();
enemy->Load("helicopter.x");
This is my main loop
This is the code for clearing the BackBuffer Surface
This is the code for initialising the d3d device. I know its kind of dirty still but I''ll include a graphic board device enumeration later. Anyhow this should not be the problem...
Thats all. So what could be the problem?
Thx in advance...
Tobias Nöll / Germany
while(!done)
{
//dd is the DirectDraw interface
if(FAILED(dd.ClearBuffer(BK_COLOR)))
done = true;
D3DMATRIX matWorld;
matWorld._11 = matWorld._22 = matWorld._33 = matWorld._44 = 1.0f;
matWorld._12 = matWorld._13 = matWorld._14 = matWorld._41 = 0.0f;
matWorld._21 = matWorld._23 = matWorld._24 = matWorld._42 = 0.0f;
matWorld._31 = matWorld._32 = matWorld._34 = matWorld._43 = 0.0f;
matWorld._22 = cosf(i);
matWorld._23 = sinf(i);
matWorld._32 = -sinf(i);
matWorld._33 = cosf(i);
matWorld._44 = 20.0f;
i += 0.005;
d3ddev->SetRenderState(D3DRENDERSTATE_CULLMODE, TRUE);
d3ddev->SetRenderState(D3DRENDERSTATE_FILLMODE, D3DFILL_WIREFRAME);
d3ddev->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld);
d3ddev->BeginScene();
enemy->Render(d3ddev);
d3ddev->EndScene();
d3ddev->SetRenderState(D3DRENDERSTATE_FILLMODE, D3DFILL_SOLID);
}
HRESULT CRat_DirectDraw::ClearBuffer(DWORD Color)
{
HRESULT ddrval;
DDBLTFX ddBltFx;
ZeroMemory(&ddBltFx, sizeof(DDBLTFX));
ddBltFx.dwSize = sizeof(DDBLTFX);
ddBltFx.dwFillColor = Color;
ddrval = m_lpDDSBack->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddBltFx);
return ddrval;
}
HRESULT CRat_Direct3D::Init(CRat_DirectDraw *pDDrawDevice)
{
HRESULT d3drval;
LOG("CRat_Direct3D::Init() called -> ");
if((!pDDrawDevice) || (!pDDrawDevice->IsInitialised()))
{
LOG("Error, No valid CRat_DirectDraw pointer given\n");
return D3DERR_INVALID_DEVICE;
}
DWORD dwScreenX = pDDrawDevice->GetScreenX();
DWORD dwScreenY = pDDrawDevice->GetScreenY();
LPDIRECTDRAW7 lpDD = pDDrawDevice->GetDirectDrawDevice();
LPDIRECTDRAWSURFACE7 lpDDSBack = pDDrawDevice->GetBackBuffer();
if(lpDD == NULL)
{
LOG("Error, No valid DirectDraw Device pointer in CRat_DirectDraw Object\n");
return D3DERR_INVALID_DEVICE;
}
m_pDDraw = pDDrawDevice;
if(lpDDSBack == NULL)
{
LOG("Error, No valid Backbuffer pointer in CRat_DirectDraw Object\n");
return D3DERR_INVALID_DEVICE;
}
d3drval = lpDD->QueryInterface(IID_IDirect3D7, (LPVOID *)&m_lpD3D);
if(FAILED(d3drval))
{
m_lpD3D = NULL;
LOG("Error, in QueryInterface() for Direct3D Object\n");
return d3drval;
}
initialised = true;
d3drval = m_lpD3D->CreateDevice(IID_IDirect3DTnLHalDevice, lpDDSBack, &m_lpD3DDevice);
if(FAILED(d3drval))
{
LOG("Initialisation with IID_IDirect3DTnLHalDevice failed, trying IID_IDirect3DHALDevice\n");
LOG("CRat_Direct3D::Init() called -> ");
d3drval = m_lpD3D->CreateDevice(IID_IDirect3DHALDevice, lpDDSBack, &m_lpD3DDevice);
if(FAILED(d3drval))
{
LOG("Initialisation with IID_IDirect3DHALDevice failed, trying IID_IDirect3DMMXDevice\n");
LOG("CRat_Direct3D::Init() called -> ");
d3drval = m_lpD3D->CreateDevice(IID_IDirect3DMMXDevice, lpDDSBack, &m_lpD3DDevice);
if(FAILED(d3drval))
{
LOG("Initialisation with IID_IDirect3DMMXDevice failed, trying IID_IDirect3DRGBDevice\n");
LOG("CRat_Direct3D::Init() called -> ");
d3drval = m_lpD3D->CreateDevice(IID_IDirect3DRGBDevice, lpDDSBack, &m_lpD3DDevice);
if(FAILED(d3drval))
{
LOG("Error, Initialisation with IID_IDirect3DRGBDevice failed, no valid D3D Device detected\n");
UnInit();
return d3drval;
}
else
LOG("IID_IDirect3DRGBDevice found");
}
else
LOG("IID_IDirect3DMMXDevice found");
}
else
LOG("IID_IDirect3DHALDevice found");
}
else
LOG("IID_IDirect3DTnLHalDevice found");
D3DVIEWPORT7 D3DViewport;
D3DViewport.dwX = 0;
D3DViewport.dwY = 0;
D3DViewport.dwWidth = dwScreenX;
D3DViewport.dwHeight = dwScreenY;
D3DViewport.dvMinZ = 0.0f;
D3DViewport.dvMaxZ = 1.0f;
d3drval = m_lpD3DDevice->SetViewport(&D3DViewport);
if(FAILED(d3drval))
{
LOG("... Error, in SetViewport() for D3DDevice\n");
UnInit();
return d3drval;
}
LOG("... OK\n");
return D3D_OK;
}