Hi, I'm stuck on something and I know its a simple mistake that when somebody tells me the answer I'm going to think Embarassed whooooppsss, but for the life of me I can't see what I'm doing wrong at the moment.
I have a class (with key code extracted below from the .h and .cpp file) and I want to get and set the render targets (set is always called before get). The compiler says its ok but i get run time errors with access violations. Problem happens with set, but I thought I'd put get down because errors will probably come up there too. I've gone through with a debugger but I can't figure out what is wrong with it.
Thanks
cclass {
// Vars
LPD3DXRENDERTOSURFACE renderSurface[5];
LPDIRECT3DTEXTURE9 dynamicTexture[5];
LPDIRECT3DSURFACE9 textureSurface[5];
...
}
void cclass::getRenderSurface(LPD3DXRENDERTOSURFACE* _a, LPDIRECT3DTEXTURE9* _b, LPDIRECT3DSURFACE9* _c, int _index)
{
_a = &renderSurface[_index];
_b = &dynamicTexture[_index];
_c = &textureSurface[_index];
}
void cclass::setRenderSurface(LPD3DXRENDERTOSURFACE* _a, LPDIRECT3DTEXTURE9* _b, LPDIRECT3DSURFACE9* _c, int _index)
{
renderSurface[_index] = *_a;
dynamicTexture[_index] = *_b;
textureSurface[_index] = *_c;
}
and the thingy that uses it goes like this
.
.
.
LPD3DXRENDERTOSURFACE renderSurface = NULL;
LPDIRECT3DTEXTURE9 dynamicTexture = NULL;
LPDIRECT3DSURFACE9 textureSurface = NULL;
for(int i=0; i<5; i++)
{
HRESULT hr;
hr = D3DXCreateTexture( Device,
Pixels,
Pixels,
1,
D3DUSAGE_RENDERTARGET,
D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT,
&dynamicTexture );
if( FAILED(hr) )
{
MessageBox(NULL,"Failed to create a texture with the D3DUSAGE_RENDERTARGET usage flag set!",
"ERROR",MB_OK|MB_ICONEXCLAMATION);
exit(-1);
}
// Create an off-screen "render to" surface...
D3DSURFACE_DESC desc;
dynamicTexture->GetSurfaceLevel( 0, &textureSurface );
textureSurface->GetDesc( &desc );
hr = D3DXCreateRenderToSurface( Device,
desc.Width,
desc.Height,
desc.Format,
TRUE,
D3DFMT_D16,
&renderSurface );
if( FAILED(hr) )
{
MessageBox(NULL,"Failed to create the off-screen render surface!",
"ERROR",MB_OK|MB_ICONEXCLAMATION);
exit(-1);
}
h->setRenderSurface(&renderSurface, &dynamicTexture, &textureSurface, i);
}
.
.
.
[Edited by - flip_mo_kid on March 29, 2005 1:38:09 PM]