How can I reset a render target? I am trying to toggle between fullscreen mode and windowed mode but without success. I've tried all the possible combinations in the code below. I am rendering to a surface and then stretching that surface to the size of the backbuffer. When I was rendering directly to the screen, the code below worked:
HRESULT result; initD3Dpp(); sprite->OnLostDevice(); //SAFE_RELEASE(surface); result = device3d->Reset(&d3dpp); device3d->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); device3d->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); device3d->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); //device3d->CreateRenderTarget(GAME_WIDTH, GAME_HEIGHT, d3dpp.BackBufferFormat, d3dpp.MultiSampleType, d3dpp.MultiSampleQuality, false, &surface, NULL); //device3d->SetRenderTarget(0, surface); sprite->OnResetDevice(); return result;
This is the reset() method that I use to reset the device after I switch a variable called fullscreen to !fullscreen. Can someone please tell me how can I handle that surface when the device is lost? The commented code is how I tried to do it. The code from the last two commented lines is what I use to set the render target. I hope I don't do some stupid things here. I am a beginner.