Split screen flashes pink to green

Started by
7 comments, last by Namethatnobodyelsetook 19 years, 8 months ago

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.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
Advertisement
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.
Ok, but I'm still confused as to how to get it to stop flashing green and pink.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
Quote:Original post by Namethatnobodyelsetook
you should draw to the entire screen.

Niko Suni

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;
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
That looks fine. Are you sure your d3dpp values are accurate? If you put a breakpoint in, do the values look right?
Ok, I rebooted and got it working now, thanks everyone.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
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?
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
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.

This topic is closed to new replies.

Advertisement