Skip to main content
gamedev.net
🔒 Locked

DrawPrimitive crashes the system.

Started by Valles Mariner Jun 18, 2002 at 11:35 PM 2 replies 350+ views
Original Post
Valles Mariner
Valles Mariner
I use DrawPrimitive in a loop several times before I EndScene and Present. This causes the program to slow, begin to skip and eventually stop brining up the debugger which leaves a yellow arrow pointing at the Lock. I''ll post the code snippet in the follow-up message. The only examples I''ve seen have used DrawPrimitiveUP multiple times in the water demo, and DrawSubset in donuts 3d. Is putting all of my triangles in a single array my only solution?
Valles Marineris
Valles Mariner
Valles Mariner
while ( i <= 2)
{
g_Vertices[0].x = -1.0f + i;
g_Vertices[0].y = -1.0f;
g_Vertices[0].z = 0.0f;
g_Vertices[0].color = 0xffff0000;
g_Vertices[1].x = 1.0f + i;
g_Vertices[1].y = -1.0f;
g_Vertices[1].z = 0.0f;
g_Vertices[1].color = 0xffff0000;
g_Vertices[2].x = 0.0f + i;
g_Vertices[2].y = 1.0f;
g_Vertices[2].z = 0.0f;
g_Vertices[2].color = 0xff0000ff;

if( FAILED( g_pVB->Lock( 0, sizeof(g_Vertices), (BYTE** &pVertices, 0 ) ) )
return E_FAIL;

memcpy( pVertices, g_Vertices, sizeof(g_Vertices) ); g_pVB->Unlock();

g_pd3dDevice->SetStreamSource( 0, g_pVB, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 );

i++;
}
Valles Marineris
Valles Mariner
Valles Mariner
Problem solved. Running CreateVertexBuffer in the loop causes the crunch. Simple solution is to place it outside. YAY!
Valles Marineris
Ecko
Ecko
a little suggestion for you would be to head over to nvidia.com and look at some of their programming examples. They have a lot of good resources.
-----------------------------------------------------------"People who usualy use the word pedantic usualy are pedantic!"-me

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.