CRect cr;
GetWindowRect(&cr);
vpPersp.X = 0;
vpPersp.Y = 0;
vpPersp.Height = cr.Height();
vpPersp.Width = cr.Width()/2;
vpPersp.minZ = 0;
vpPersp.maxZ = 1;
vpTop = vpPersp;
vpTop.X = vpPersp.X + vpPersp.Width;
...
if(_device){
_device->Clear(0, 0, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE(0.35f, 0.53f, 0.7, 1.0f), 1.0f, 0);
_device->BeginScene();
if(FAILED(_device->SetViewport(&vpPersp)))
int t=0;
render();
if(FAILED(_device->SetViewport(&vpTop)))
int y=0;
render();
_device->EndScene();
_device->Present(NULL, NULL, NULL, NULL);
}
Split screen flashes pink to green
The pink/green happens to your backbuffer after a present when using SWAPEFFECT_DISCARD, and debug drivers. This emphasises the fact that you've said "discard". Any pixel you don't draw to will flash. This indicates a bug in your code... you should draw to the entire screen. (Midnight Club 2's loading screens do this flashing!)
If your viewport extends past the backbuffer / rendertarget sizes, you'll have problems. Apparently it just warns you now. It used to crash your computer.
When doing your split screen, ensure X+Width and Y+Height do not exceed the backbuffer(or render target) dimensions.
Also note, when you set a new rendertarget, the viewport magically defaults to the entire surface.
If your viewport extends past the backbuffer / rendertarget sizes, you'll have problems. Apparently it just warns you now. It used to crash your computer.
When doing your split screen, ensure X+Width and Y+Height do not exceed the backbuffer(or render target) dimensions.
Also note, when you set a new rendertarget, the viewport magically defaults to the entire surface.
Well how can do that, because when I use the screen width and height from the back buffer, it still flashes?
screenW = d3dpp.BackBufferWidth;screenH = d3dpp.BackBufferHeight;vpPersp.X = 0;vpPersp.Y = 0;vpPersp.Height = screenH;vpPersp.Width = screenW/2;vpPersp.MinZ = 0;vpPersp.MaxZ = 1;vpTop = vpPersp;vpTop.X = vpPersp.X + vpPersp.Width;
That looks fine. Are you sure your d3dpp values are accurate? If you put a breakpoint in, do the values look right?
Actually, the reason it worked was because I first set a viewport which contained the entire drawing area, then I applied the two split ones. Why did I have to pass the whole one first?
Perhaps you set the whole one, did a clear (writing to each pixel), then set the new one (and drew to half the screen).
Previously you might have always been doing a clear with the viewport set to half-screen... clearing half the screen, leaving the debug flashing on the other half.
Previously you might have always been doing a clear with the viewport set to half-screen... clearing half the screen, leaving the debug flashing on the other half.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement