Archived

This topic is now archived and is closed to further replies.

Erzengeldeslichtes

SetRenderTarget in Windowed mode...

Recommended Posts

How would I go about reverting from a SetRenderTarget to a texture in windowed mode? In fullscreen mode I simply grab the backbuffer or use GetRenderTarget(&SomeSurface), but in windowed mode when I do the same thing the entire screen (minus the task bar) is rendered to instead of the window. Am I just going to have to render to a seperate surface of the same size & format, etc, and StretchRects to the backbuffer, or is there another (easier) way?

Share this post


Link to post
Share on other sites
Nope, I wasn't even aware of the viewport. However, I just tried it, and it's still taking the whole screen (minus anything in front of it) even though I specifically only clear the window's rectangle, and set the viewport to the window's rectangle.


m_Device->SetRenderTarget(0, m_RenderSurface);
//Right here is my either set stencil depth or create a stencil depth and set. It's unnecessary.

D3DVIEWPORT9 view;
view.X = m_Viewport.left;
view.Y = m_Viewport.top;
view.Width = m_Viewport.right;//This and the next are just temporary until I create a RECT that looks correct.

view.Height = m_Viewport.bottom;//As it stands, bottom isn't the bottom of the 'port, it's the bottom - top, ie, the height.

view.MinZ = 0.0f;
view.MaxZ = 1.0f;
m_Device->SetViewport(&view);
D3DRECT viewrect;
viewrect.x1 = m_Viewport.left;
viewrect.x2 = m_Viewport.left + m_Viewport.right;
viewrect.y1 = m_Viewport.top;
viewrect.y2 = m_Viewport.top + m_Viewport.bottom;
m_Device->Clear(1, &viewrect, D3DCLEAR_STENCIL | D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET, GRAPHICS_COLOR_BACKGROUND, 1.0f, 0);
m_Device->BeginScene();
RenderPass(Options);
m_Device->EndScene();


Anyone see anything wrong with the above?
Edit: Oh, and just for the record, I've stepped through the debugger and m_Viewport is set correctly when it goes through this segment of code.

[edited by - Erzengeldeslichtes on April 5, 2004 7:41:59 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
in DirectX8 Window modes can use this

m_pD3DDevice->CreateAdditionalSwapChain(&d3dpp, &m_pSwapChain);

m_pSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &m_pBackBuffer);

m_pD3DDevice->SetRenderTarget(m_pBackBuffer, NULL);

m_pSwapChain->Present(NULL, NULL, m_hWnd, NULL);


Made In Taiwan

Share this post


Link to post
Share on other sites
That didn''t work... In fullscreen mode it simply dies, and in windowed mode it renders the same as before. I''ve noticed that it seems to center the scene around the center of the viewport, but even so renders well outside the viewport...

Share this post


Link to post
Share on other sites