Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


DrawPrimitive() problem

This topic is 6451 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
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
DWORD color;
FLOAT tu, tv;


if( FAILED( g_pd3dDevice->CreateVertexBuffer(
return E_FAIL;

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

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

file >> temp;
while (strcmp(temp, "VERTEX") != 0)
file >> temp;
file >> i_temp;
if(i_temp == i)
v.p = D3DXVECTOR3( mesh_Vertices[i][0],
mesh_Vertices[i][2] );

v[i].n = D3DXVECTOR3( mesh_Normal[i][0],
mesh_Normal[i][2] );

v[i].tu = mesh_tcoord[i][0];
v[i].tv = mesh_tcoord[i][1];
v[i].color = 0xffffffff;

ZeroMemory( &mtrl, sizeof(D3DMATERIAL8) );
mtrl.Diffuse.r = mesh_Material[0].diffuse.x;
mtrl.Ambient.r = mesh_Material[0].ambient.x;
mtrl.Diffuse.g = mesh_Material[0].diffuse.y;
mtrl.Ambient.g = mesh_Material[0].ambient.y;
mtrl.Diffuse.b = mesh_Material[0].diffuse.z;
mtrl.Ambient.b = mesh_Material[0].ambient.z;
mtrl.Diffuse.a = 1.0f;
mtrl.Ambient.a = 1.0f;
g_pd3dDevice->SetMaterial( &mtrl );

//the standard light
SetupDirectionalLight(g_pd3dDevice, 0 , 1.0f,1.0f,1.0f,
D3DXVECTOR3( 0.0f,-1.0f, 0.0f), TRUE);

g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );

//in the render function
if(FAILED(hr = g_pd3dDevice->BeginScene()))
return hr;

// Render the object
g_pd3dDevice->SetStreamSource( 0, g_pVB, sizeof(VERTEX) );
g_pd3dDevice->SetVertexShader( D3DFVF_VERTEX );
g_pd3dDevice->SetTexture( 0, g_pTex );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, m_dwNumObjFaces );

if(FAILED(hr = g_pd3dDevice->EndScene()))
return hr;

I hope u will find a mistake in that code!!

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!