DrawPrimitive() problem

Started by
2 comments, last by TheUnreal 23 years, 2 months ago
If I am using the DrawPrimitive function (only VertexBuffer) with a Triangle_List, my app can´t show the 3D model. Then I changed to DrawIndexPrimitive (Vertex/IndexBuffer) and my model was drawn correctly. So I have a question: Is it not possible to use Triangle_List with DrawPrimitive? In the DX8SDK documentation there is always used Triangle_Strip. My 3d model was just a cube with diffuse colors. I imported it from a .ase file. With the DrawPrimitive function there was nothing to see in my app. But why???? Thx for help!
Advertisement
it is b/c you put the wrong parameter in that function.....no not that one the next one....yeah right there......
.
.
.
why dont you post some code so we can see what you are doing ?


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
The code is coming here. There must be an error cause my screen is black. This are just some important code pices:
(The vertex data is loaded out of my own file format)

typedef struct VERTEX
{
D3DXVECTOR3 p;
D3DXVECTOR3 n;
DWORD color;
FLOAT tu, tv;
} VERTEX;

#define D3DFVF_VERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1)



if( FAILED( g_pd3dDevice->CreateVertexBuffer(
(m_dwNumObjFaces*3)*sizeof(VERTEX),
0, D3DFVF_VERTEX,
D3DPOOL_DEFAULT, &g_pVB ) ) )
return E_FAIL;


if( FAILED( D3DXCreateTextureFromFile( g_pd3dDevice,
"pics/metall2.jpg", &g_pTex ) ) )
return E_FAIL;

// Initialize the vertices
VERTEX* v;
g_pVB->Lock( 0, 0, (BYTE**)&v, 0 );

for(i=0;i<(m_dwNumObjFaces*3);i++)
{
file >> temp;
while (strcmp(temp, "VERTEX") != 0)
{
file >> temp;
}
file >> i_temp;
if(i_temp == i)
{
v.p = D3DXVECTOR3( mesh_Vertices[0],<br> mesh_Vertices[1],<br> mesh_Vertices[2] );<br><br><br> v.n = D3DXVECTOR3( mesh_Normal[0],<br> mesh_Normal[1],<br> mesh_Normal[2] );<br><br><br> v.tu = mesh_tcoord[0];<br> v.tv = mesh_tcoord[1];<br> v.color = 0xffffffff;<br> }<br>}<br>g_pVB->Unlock();<br><br><br><br><br>D3DMATERIAL8 mtrl;<br>ZeroMemory( &mtrl, sizeof(D3DMATERIAL8) );<br>mtrl.Diffuse.r = mesh_Material[0].diffuse.x;<br>mtrl.Ambient.r = mesh_Material[0].ambient.x;<br>mtrl.Diffuse.g = mesh_Material[0].diffuse.y;<br>mtrl.Ambient.g = mesh_Material[0].ambient.y;<br>mtrl.Diffuse.b = mesh_Material[0].diffuse.z;<br>mtrl.Ambient.b = mesh_Material[0].ambient.z;<br>mtrl.Diffuse.a = 1.0f;<br>mtrl.Ambient.a = 1.0f;<br>g_pd3dDevice->SetMaterial( &mtrl );<br><br>//the standard light<br>SetupDirectionalLight(g_pd3dDevice, 0 , 1.0f,1.0f,1.0f,<br> D3DXVECTOR3( 0.0f,-1.0f, 0.0f), TRUE);<br> <br>g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );<br><br><br><br><br>//in the render function<br>if(FAILED(hr = g_pd3dDevice->BeginScene()))<br> return hr;<br><br>// Render the object<br>g_pd3dDevice->SetStreamSource( 0, g_pVB, sizeof(VERTEX) );<br>g_pd3dDevice->SetVertexShader( D3DFVF_VERTEX );<br>g_pd3dDevice->SetTexture( 0, g_pTex );<br>g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, m_dwNumObjFaces );<br><br>if(FAILED(hr = g_pd3dDevice->EndScene()))<br> return hr;<br><br>I hope u will find a mistake in that code!!<br>Thx<br>TheUnreal </i>
The anonymous poster was me... forgot to enter my password. Well, where is my mistake?????? Help me!!!!

This topic is closed to new replies.

Advertisement