Sign in to follow this  
Sfpiano

Split screen flashes pink to green

Recommended Posts

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);
	}

The above code gives me an error saying I'm drawing the viewport outside of the render target surface, and the entire screen flashes between pink and green. If I hardcode values for the viewports, a part part of the screen on the second viewport side is normal, and the rest flashes.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this