Someone help! The DrawPrimitive-Method fails within the DirectX-Framework!

Started by
5 comments, last by Santharn 21 years, 9 months ago
I am familiar with the simple tutorials included with DirectX 8.1-everything i tested out with that had worked well so far. Now i want to use the DirectX-Framework (d3dapp) to write an independent application When i am using the "DrawPrimitive"-Method in my Render-Method of the application the Debug-Output of the DrawPrimitive-Method says: "... Direct3d8: (ERROR) :Cannot invert view matrix" - i have no idea at all what this error-message means. Consequently nothing is drawn. I have not modified the camera, world or projection-matrices at all - i have left in the same status as they were before in my chosen sample (my code was adopt by the sample "text3d";i have simply commendet out the parts that i have not needed). In the renderstate-settings i have disabled light, since in my FVF i am using only RGB and Diffuse color. I simply want the sample-framework to draw a stupid triangle like in the tutorial too. With that i could build my own application. I would be glad if someone could help me!
Advertisement
I also had the same problem. I just rewrote my code and it went away. *shrugs*
quote:Original post by Santharn
all - i have left in the same status as they were before in my chosen sample (my code was adopt by the sample "text3d";i have simply commendet out the parts that i have not needed).

You need to set the matrices to something. You can use identity for world and view and either perspective or ortho for projection.
---visit #directxdev on afternet <- not just for directx, despite the name
Hey thanks Sheep and IndirectX for your promt help!

To IndirectX:
Here is the code that sets up the matrices:

Part of: HRESULT CMyD3DApplication::RestoreDeviceObjects()
codeBegin----------------------------------------------------
...
// Set the transform matrices
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f,-5.0f, 0.0f );
D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXMATRIX matWorld, matView, matProj;

D3DXMatrixIdentity( &matWorld );
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)
m_d3dsdBackBuffer.Height;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect,
1.0f, 100.0f );

m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
...
codeEnd------------------------------------------------------

Hmmm...try posting your drawing code.
ok, here is the Rendering Code:


//--------------
//Method Render
//--------------
HRESULT CTriangle::Render() {
HRESULT hr;

m_pd3dDevice->SetVertexShader( CFUNCTION_VERTEX_FORMAT );
BYTE* pData = 0;

//Lock the vertex buffer
hr = m_pVB->Lock( 0, 0, &pData, 0 );
if( FAILED( hr ) )
{
SAFE_RELEASE( m_pVB );
return E_FAIL;
}

//Copy the face vertices into the buffer
CopyMemory( pData, (void*)m_pVertices, sizeof(
CFunctionVertex ) * 3 );

//Unlock the Vertex Buffer:
m_pVB->Unlock();

//Connect the vertex buffer to a rendering steam
m_pd3dDevice->SetStreamSource( 0, m_pVB, sizeof(
CFunctionVertex ) );


m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );

return( S_OK );
} //Render


I hope this helps analysing my problem.
If nothing doesn´t work i will write the whole code again, just like you, Sheep
Are your drivers up to date? Also try copying tutorials'' code for the matrices into your app and see if it makes any difference.

You shouldn''t lock buffers each frame, do it on init.
---visit #directxdev on afternet <- not just for directx, despite the name

This topic is closed to new replies.

Advertisement