If I want to create a D3D surface I do it like below. Similiarly if I want to create an array of D3D surfaces of type IDirect3DSurface9* how do I do in C++ ?
如果我想创建一个D3D曲面,我就像下面这样做。类似地,如果我想创建一个类型为IDirect3DSurface9的D3D曲面数组*在c++中该怎么做?
IDirect3DSurface9** ppdxsurface = NULL;
IDirect3DDevice9 * pdxDevice = getdevice(); // getdevice is a custom function which gives me //the d3d device.
pdxDevice->CreateOffscreenPlainSurface(720,480,
D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT,
pdxsurface,
NULL);
QUERY :: How do I create an array of D3D device in C++ ?
查询:如何在c++中创建D3D设备数组?
1 个解决方案
#1
5
ppdxsurface
is not declared correctly, you need to provide pointer to pointer object, not just pointer to pointer. It shall be IDirect3DSurface9*
, not IDirect3DSurface9**
:
ppdxsurface没有正确声明,您需要提供指向指针对象的指针,而不仅仅是指向指针的指针。它应该是IDirect3DSurface9*,而不是IDirect3DSurface9**:
IDirect3DSurface9* pdxsurface = NULL;
IDirect3DDevice9* pdxDevice = getdevice();
pdxDevice->CreateOffscreenPlainSurface(720, 480,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,
&pdxsurface, // Pass pointer to pointer
NULL);
// Usage:
HDC hDC = NULL;
pdxsurface->GetDC(hDC);
To create array of surfaces just call it in loop:
要创建曲面数组,只需在循环中调用它:
// Define array of 10 surfaces
const int maxSurfaces = 10;
IDirect3DSurface9* pdxsurface[maxSurfaces] = { 0 };
for(int i = 0; i < maxSurfaces; ++i)
{
pdxDevice->CreateOffscreenPlainSurface(720, 480,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,
&pdxsurface[i],
NULL);
}
Or using std::vector
if you prefer dynamic arrays:
或者使用std::vector如果你喜欢动态数组:
std::vector<IDirect3DSurface9*> surfVec;
for(int i = 0; i < maxSurfaces; ++i)
{
IDirect3DSurface9* pdxsurface = NULL;
pdxDevice->CreateOffscreenPlainSurface(720, 480,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,
&pdxsurface,
NULL);
surfVec.push_back(pdxsurface);
}
#1
5
ppdxsurface
is not declared correctly, you need to provide pointer to pointer object, not just pointer to pointer. It shall be IDirect3DSurface9*
, not IDirect3DSurface9**
:
ppdxsurface没有正确声明,您需要提供指向指针对象的指针,而不仅仅是指向指针的指针。它应该是IDirect3DSurface9*,而不是IDirect3DSurface9**:
IDirect3DSurface9* pdxsurface = NULL;
IDirect3DDevice9* pdxDevice = getdevice();
pdxDevice->CreateOffscreenPlainSurface(720, 480,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,
&pdxsurface, // Pass pointer to pointer
NULL);
// Usage:
HDC hDC = NULL;
pdxsurface->GetDC(hDC);
To create array of surfaces just call it in loop:
要创建曲面数组,只需在循环中调用它:
// Define array of 10 surfaces
const int maxSurfaces = 10;
IDirect3DSurface9* pdxsurface[maxSurfaces] = { 0 };
for(int i = 0; i < maxSurfaces; ++i)
{
pdxDevice->CreateOffscreenPlainSurface(720, 480,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,
&pdxsurface[i],
NULL);
}
Or using std::vector
if you prefer dynamic arrays:
或者使用std::vector如果你喜欢动态数组:
std::vector<IDirect3DSurface9*> surfVec;
for(int i = 0; i < maxSurfaces; ++i)
{
IDirect3DSurface9* pdxsurface = NULL;
pdxDevice->CreateOffscreenPlainSurface(720, 480,
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,
&pdxsurface,
NULL);
surfVec.push_back(pdxsurface);
}