Problem with LPD3DXSPRITE
I'm having a problem when I try and go full screen. The game crashes and dumps me in my sprite class.
//draw Sprites2D
void Graphics_Engine::Draw2DObjects()
{
D3DXVECTOR3 position(0.0f, 0.0f, 0.0f); // position at 50, 50 with no depth
D3DXVECTOR3 center(0.0f, 0.0f, 0.0f); // center at the upper-left corner
mSprite->Begin(NULL);
mSprite->Draw(sprite, 0, ¢er, &position, D3DCOLOR_XRGB(255,255,255));
mSprite->End();
}
void Graphics_Engine::drawScene()
{
// Clear the backbuffer and depth buffer.
gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
gd3dDevice->BeginScene();
//sprite
Draw2DObjects();
mFX->SetValue(mhLight, &mLight, sizeof(DirLight));
mFX->SetMatrix(mhWVP, &(mWorld*gCamera->getViewMatrix()*gCamera->getProjectionMatrix()));
D3DXMATRIX worldInvTrans;
D3DXMatrixInverse(&worldInvTrans, 0, &mWorld);
D3DXMatrixTranspose(&worldInvTrans, &worldInvTrans);
mFX->SetMatrix(mhWorldInvTrans, &worldInvTrans);
mFX->SetMatrix(mhWorld, &mWorld);
// Setup the rendering FX
//mFX->SetValue(mhAmbientLight, &mAmbientLight, sizeof(D3DXCOLOR));
//mFX->SetValue(mhDiffuseLight, &mDiffuseLight, sizeof(D3DXCOLOR));
// HR(mFX->SetValue(mhSpecLight, &mSpecLight, sizeof(D3DXCOLOR)));
// HR(mFX->SetValue(mhLightVecW, &mLightVecW, sizeof(D3DXVECTOR3)));
mFX->SetTechnique(mhTech);
UINT numPasses = 0;
mFX->Begin(&numPasses, 0);
mFX->BeginPass(0);
mFX->EndPass();
for(UINT i = 0; i < numPasses; ++i)
{
mFX->BeginPass(i);
// drawGrid();
// drawCylinders();
//drawSpheres();
std::list<Model*>::iterator it = modelList_.begin();
while( it != modelList_.end() )
{
drawObject(*it);
++it;
}
mFX->EndPass();
}
mFX->End();
// mGfxStats->display();
gd3dDevice->EndScene();
// Present the backbuffer.
gd3dDevice->Present(0, 0, 0, 0);
}
D3DXSPRITE_OBJECTSPACE seems like it would make more sense but that just fills a quarter of my screen with a black square. I think i might be calling something out of order or I need some sort of check when i go fullscreen to prevent this crash.
Any help would be much appreciated.
Thanks,
Screamer
I don't want the fx to effect the sprites. It shouldn't since the call is outside of the passes.
Quote:Original post by ScreamerWhere in your sprite class exactly?
I'm having a problem when I try and go full screen. The game crashes and dumps me in my sprite class.
If you're resetting the device, are you calling ID3DXSprite's OnLostDevice() and OnResetDevice() functions? I suspect you're trying to render with the sprite after calling OnLostDevice() but before OnResetDevice(), during which time the sprite is probably in an invalid state.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement