PDA

View Full Version : dynamic arrays of Vertices?!?!?!



Extrawurst
11-11-2002, 08:28 PM
I want to create a VertexBuffer with a Size which is defined at runtime, so I have to use a dynamic array of vertices! After filling my array of Vertices with the correct Data, I have to move it to the VertexBuffer.
But when i render the Vertices, then I see that they are all wrong.
So i think my way of moving a dynamic array of vertices to a vertexbuffer is wrong...
Does someone know how to move it correctly ???

I'm thankful for every answer...

Clootie
15-11-2002, 07:00 AM
type
TMyVertices = packed record
pos, norm: TD3DVector;
end;
TVerticesArray = array of TMyVertices;

const
MyFVF = (D3DFVF_XYZ or D3DFVF_NORMAL);

function VertexBufferGenerator(Device: IDirect3DDevice9; const vertices: TVerticesArray): IDirect3DVertexBuffer9;
var
i: Integer;
Data: Pointer;
begin
i:= High(vertices)*SizeOf(TMyVertices);
Device.CreateVertexBuffer(i, D3DUSAGE_WRITEONLY, MyFVF, D3DPOOL_MANAGED, Result, nil);
Result.Lock(0, 0, Data, D3DLOCK_NOSYSLOCK);
try
Move(vertices[0], Data^, i);
finally
Result.Unlock;
end;
end; :D

Extrawurst
15-11-2002, 12:03 PM
Hey Clootie,
I don't know if I'm half asleep again(i've got insomnia the last days)
so I didn't realized DX9 coming out , but I thought it wouldn't be out!
So how do code with :

Device: IDirect3DDevice9;
???????????
But thanks for your help I think I'm able to implement this dynamic vertex_array in my game,although i use a IDirect3DDevice8 ;)

Clootie
15-11-2002, 01:57 PM
Device: IDirect3DDevice9;
???????????
It's a joke, but DX9 is coming!