代码之家  ›  专栏  ›  技术社区  ›  Himadri

我可以拥有IDirect3DVertexBuffer9的动态数组吗?

  •  0
  • Himadri  · 技术社区  · 16 年前

    我正在使用Delphi和DirectX。我想要IDirect3DVertexBuffer9的动态数组。有可能吗?如果是,那么如何?

    我已经为它写了一个代码。但是,这似乎是有问题的。我的代码如下所示-

    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;
    

    在这里,我面临的问题是,一旦它进入for循环,它就会继续,而不是在 cnt 值为4。如果我在for循环中写入静态值3,而不是totalBuffer,那么当值为4时,它将退出循环。

    1 回复  |  直到 16 年前
        1
  •  1
  •   SimaWB    16 年前

    你可以找到样品 here 剔除样品 他们使用了“IDirect3DVertexBuffer数组”。