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


Incredibly slow drawprimitive?

Recommended Posts

I am trying to rotate a simple triangle, and it works quite well. Then, just to see how much it can handle, I put a simple for loop around the drawprimitive, like so: //^ initialize vertex[3] before ^ d3dvb->Lock(0,sizeof(CUSTOMVERTEX)*3,&pBuffer,0); memcpy(pBuffer,vert,sizeof(CUSTOMVERTEX)*3); d3dvb->Unlock(); for(int i=0; i<500; i++) {  d3ddev->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 ); } This sticks my framerate to below 2fps on an ATI Radeon VE (32mb ddr) I am sure my card can handle more than 1000 triangles/sec, so what gives?

Share this post

Link to post
Share on other sites
i think you are getting slow frame rate because everytime you enter your drawing loop, you are drawing it 500 times. You should apply your rotation outside of the drawing loop and draw the triangle once for each added rotation. I may be wrong, i am just assuming from that piece of code. later-

what we do in life... echoes in eternity...

Share this post

Link to post
Share on other sites
Well, yeah, the code works fine without that 500 loop. What I was trying to simulate was a case where I have a much more complicated scene, with (in this case) 500 triangles. The actual number will probably be closer to 1000 or above, so I really need a faster way of doing this. I''ll post my entire rendering code, just for kicks:

(please excuse the indentation, but I don''t know how to format text in these forums, and I''m not going to put nbsp''s everywhere)

void Prog_Loop()
BYTE* pBuffer;


//start the scene
//set up the vertex positions

//I realize that this for loop is completely useless.
//I have it in here only to simulate a more complex scene.
for(int i=0; i<500; i++) {
d3ddev->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );

//end the scene

//add to the angle for next time
if(angle>=2*PI) angle=angle-2*PI;
d3ddev->Present(NULL, NULL, NULL, NULL);

}//End Prog_Loop

Share this post

Link to post
Share on other sites

You are not making the best use of the DrawPrimitive call in this case (or so it would appear). It looks like your buffer is only large enough for a single triangle at a time and, as a result, your DrawPrimitive call is only rendering one triangle at a time. I would suggest creating a larger vertex buffer (in this case create a buffer large enough to hold 500 triangles) and copy all your vertex data into it. Then call the DrawPrimitive function with the parameters DrawPrimitive(D3DPT_TRIANGLELIST,0,500). This will render all 500 triangles in one chunk rather than rendering one at a time.

Share this post

Link to post
Share on other sites