Rendering to multiple windows SDK

Posted By: sheefo

Rendering to multiple windows SDK - 05/31/17 21:12

I have tried everywhere and found that this is the only place to find results.
I am trying to create a second window using the C++ SDK, but I am having trouble rendering to the second window. I have created a new window and Swap Chain (following the Microsoft documentation), but I don't know how else to proceed. IDirect3DDevice9::Begin and IDirect3DDevice9::End calls cause strange results.

Can someone advise me on how to correctly setup a second window in which to render another scene. It is intended to debug render targets at runtime.
Thanks.
Posted By: jcl

Re: Rendering to multiple windows SDK - 06/12/17 07:53

Do you mean multiple viewports inside the same window, or really multiple windows? In the latter case the simplest way probably would be running several engine instances.
Posted By: sheefo

Re: Rendering to multiple windows SDK - 06/18/17 22:25

I intended to have multiple windows with shared resources. I attempted to implement it [blindly] by creating a second HWND and using IDirect3DDevice9::CreateAdditionalSwapChain(). Is this is correct method of implementation?

I have two windows, but I don't know how to differentiate rendering between them. The engine window is GREEN from the call to draw_quad(), but RED when I uncomment IDirect3DDevice9::BeginScene() and IDirect3DDevice9::EndScene(). The second window remains black.

Code:
do {
	if (v(key_esc)) {
		break;
	}

	IDirect3DDevice9* pExtraDevice;
	g_pSwapChain->GetDevice(&pExtraDevice);
	//pExtraDevice->BeginScene();
	pExtraDevice->Clear(0, nullptr, D3DCLEAR_TARGET, D3DCOLOR_RGBA(255, 0, 0, 255), 1.0f, 0x00000000);
	//pExtraDevice->EndScene();
	g_pSwapChain->Present(0, 0, 0, 0, 0);
	pExtraDevice->Release();

	draw_quad(nullptr, _vec(0.0f, 0.0f, 0.0f), nullptr, &v(screen_size), nullptr, (COLOR*)_vec(0.0f, 255.0f, 0.0f), _VAR(100), _VAR(0));
} while (engine_frame());

Posted By: jcl

Re: Rendering to multiple windows SDK - 06/19/17 08:23

I'm not so deep in DirectX that I can directly answer that question. I would normally suppose that BeginScene() and EndScene() switches rendering to the extra device, and EndScene() and SwapChain->Present() must be called _after_ draw_quad. But maybe you can get better information on a DirectX forum.
© 2024 lite-C Forums