tags:

views:

68

answers:

1

Hello,

I am working with Delphi and DirectX. I want an dynamic array of IDirect3DVertexBuffer9. Is it possible? If yes then how?

I have written a code for it. But, it seems to be problematic. My code is shown below -

totalBuffer := 4;
SetLength(g_pVB,totalBuffer);
for cnt := 0 to totalBuffer - 1 do begin
      if FAILED(g_pd3dDevice.CreateVertexBuffer(1 * SizeOf(TD3DXVector3),
                                                0, D3DFVF_XYZ,
                                                D3DPOOL_DEFAULT, g_pVB[cnt], nil)) then begin
         Result := E_FAIL;
         Exit;
      end;
      if FAILED(g_pVB[cnt].Lock(0, 0, Pointer(pVert[cnt]), 0)) then begin
         Result := E_FAIL;
         Exit;
      end;
      pVert[cnt] := 0;
end;

here, the problem I am facing is that, once it enter in for loop it continues and not exit the loop when cnt value is 4. And if I write static value 3 in for loop instead of totalBuffer it will exit the loop when value is 4.

+1  A: 

You can find samples here. At Cull sample they used "array of IDirect3DVertexBuffer".

SimaWB