Original Post
First, thanks to all who answered my vertex buffer questions and gave useful advice and guidance! I''ve now moved my project deom DX7 to 8 and from simply using indexed vertices to using indexbuffers and vertexbuffers.
The problem is, using the vertexbuffer under DX8, my code is now actually slower! I know I am doing something wrong, as vertexbuffers work wonderfully for others, so any help figuring out the problem would be much appreciated!
I''m rendering a grid of rectangles (each made of two triangles) for terrain purposes. Under DX7 with a 10x10 grid (200 triangles), it was blazing along at 400 FPS..now it''s down to 35 or so and if I up the number of triangles, it crawls to a stillstand.
What I am doing is this:
CreateVertexBuffer and IndexBuffer. These have set sizes (4000 vertices and 6000 indices) and are reused. this is done prior to rendering.
In my render :
{
Create empty arrays for my vertices and indexs
Loop through all my objects until my arrays are full.
(the following is done for both the index and the vertex buffers)
lock buffer
memcpy the array into the buffer
unlock
drawIndexedPrimitive.
repeat as necessary until all objects have been rendered (when 10x10, no repeating necessary, only called once)
}
Basically, this renders up to 1000 objects (2000 triangles) per call of drawIndexedPrimitive. This puts me at 4000 vertices (6000 indices) per call, which is within the realms of what I''ve seen recommended.
Anyone see any obvious problems that would be causing this huge slowdown?
Another strange thing I''ve noticed after switching to DX8: my framerate is no longer constant depending on what is onscreen. Under DX7, I''d get the framerate no matter what was on screen (empty screen or my terrain), but now I get a drastic slowdown when my squares are on screen. The only addition thing is that my squares are now textured (all sharing the same texture for now).
Would this cause the slowdown when displaying the squares vs. empty space? Might it also explain my drastic slowdown?
Finally, what parameters are recommended for initializing index and vertex buffers? Managed, write only, etc...?
Thanks as always for the great advice this board always gives!
Onnel