Jump to content
  • Advertisement
Sign in to follow this  

DX11 DX11-Window Rect vs render target buffer size.

This topic is 3048 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just realize that doesnt matter the size I specifie on the swap chain desc buffer, it always paints the entire window rect? Why this happens? I mean, Lets say I set everything to 640x480( swapchain`s backbuffer/rendertarget), if my window is 700x800 it will all be cleared by my clear color, why? What is the size of the swapchain desc for?

Share this post

Link to post
Share on other sites
What size is your viewport? If you are rendering to a 700x800 viewport it will fill it with the 640x480 rendertarget... I believe.

Share this post

Link to post
Share on other sites
The viewport have the same size of the back buffer specified on the swap chain desc.

Doesnt matter what value I put on the viewport or in the buffer description, notting changes, but Im not rendering anything, just clearing the render target with a color and presenting..

Share this post

Link to post
Share on other sites
The size you give for the swap chain will specify the size of the backbuffer. No matter what size you choose, the backbuffer is scaled to the size of the window's client area. If you don't want this behavior, you'll have to implement it manually either by adjusting your viewport or through some other means.

Share this post

Link to post
Share on other sites
But adjusting the viewport dont works either!

What I want specifialy is let a space for the status bar that my app have( The status bar is drawed at the window client area)

some code:

//here I change the original size of the window, so lets say it have height 480+20=500

MoveWindow( hWnd_p, wndrect_p.left, wndrect_p.top, wndrect_p.right, wndrect_p.bottom+sbHeight, TRUE );

//the swap chain description is filled with the original wndrect values(640x480)
sw.BufferCount = 2;
sw.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sw.BufferDesc.RefreshRate.Numerator = 60;
sw.BufferDesc.RefreshRate.Denominator = 1;
sw.BufferDesc.Width = wndrect_p.right;
sw.BufferDesc.Height = wndrect_p.bottom;
sw.Flags = NULL;
sw.OutputWindow = hWnd_p;
sw.SampleDesc.Count = 1;
sw.SampleDesc.Quality = 0;
sw.Windowed = TRUE;

//and so is the view port:
//note that I alredy tried a lot of values here, like toplefx/y = 0 and width/height=100, notting changes.

D3D11_VIEWPORT vp = {0};
vp.Width = (FLOAT)wndrect_p.right;
vp.Height = (FLOAT)wndrect_p.bottom;
vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f;
vp.TopLeftX = (FLOAT)wndrect_p.left; vp.TopLeftY = (FLOAT)wndrect_p.top;

pDIContext_p->RSSetViewports( 1, &vp );//Render Stage

//here is how Im setting the rendertarget view:
ID3D11Texture2D *pTex2DBBuff = NULL;//resource to get the back buffer

if( pSC_p->GetBuffer( 0, __uuidof(ID3D11Texture2D), (VOID**)&pTex2DBBuff ) != S_OK ) return E_FAIL;

if( pDevice_p->CreateRenderTargetView( pTex2DBBuff, NULL, &pRTV_p ) != S_OK ) return E_FAIL;

g_pDIContext->OMSetRenderTargets( 1, &g_pRTV, NULL);//Output Merger Stage

How can I make it render just on a part of the client area? Am Im doing something wrong?
When I create the render target view Im specifiing NULL as description, on the sdk it says "Set this parameter to NULL to create a view that accesses all of the subresources in mipmap level 0." My subresource is the backbuffer specified at the swap chain desc and have the righ size. Checking this struct at the SDK dont help much, I cant find a member data that would have something to do with this, but Im a moron, maybe it do...It have a member View Dimensions(enum), but the values possible are weird, I cant understand:

Its problay simple stuff..Render to just a part of client area is commom, someones alredy figured it out..o.o

Share this post

Link to post
Share on other sites
Someone could also explain me the D3D11_BUFFER_RTV struct please...On the SDK it have 2 members, but it have 4 members:
What is a buffer element?

Share this post

Link to post
Share on other sites
When you give the swap chain a handle to the window, it pretty much "owns" the entire client area. There's not really a good way to make it play nice with other child windows in the same client area.

What might be an easier approach for you would be to create the status bar as a child window, and then make another borderless child window that fills up the rest of the main window's client area. Then you can just present to that child window.

Share this post

Link to post
Share on other sites
I just figure out that the view port works, the stuff is rendered and clipped just on the view port part of the client area, but the entire client area is cleared(painted) with the clear color... Im sure must be some detail that I didnt find yet..

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!