VBGamer |
|||||||||||||||||||||||||||
RE: DrawIndexedPrimitive Corre (1 reply, 0 views) (2000-Jun-28) Am I right if I assume that the loop statements take place before and after the code block you posted? In that case, I'm pretty sure what the problem is.
DrawIndexedPrimitive is not faster when just rendering one or to surfaces. The speed increase you can get out of it comes when you render many surfaces with only one call.
So, if I understand what you want to do, your code should look something like this instead:
'*** This block is only executed once, when the program is started ***
vertIdx(0) = (i - 1) + (j - 1) * 64
vertIdx(1) = (i - 1) + (j - 1 + MapStep) * 64
vertIdx(2) = (i - 1 + MapStep) + (j - 1) * 64
vertIdx(3) = (i - 1 + MapStep) + (j - 1 + MapStep) * 64
.
. '*** More vertIdx stuff here.. you might want to loop this ;-) ***
.
vertIdx(2000) = ... '*** Last vertIdx, don't know if it's 2000 ***
''*** This is executed every frame, to draw the map ***
d3ddev.DrawIndexedPrimitive D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, MapVerts(0), 4096, vertIdx, 2000, D3DDP_DEFAULT
The point is: you set up all vertices and all indexes once and for all before the main loop is entered. Then you call DrawIndexedPrimitive ONCE each fram, to draw all surfaces that are defined. This way, Direct3D can take advantage of the fact that all the surfaces in your map share vertices with other surfaces, and hence reduce the necessery calculations.
hope this helps... Btw, if you haven't seen it, I have posted a sample using DrawIndexedPrimitive, you might want to check it out
/Corre, MiCo Games
http://www.micogames.com
|