Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Does swapchain->Present always stretch to the target?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Buckeye   Crossbones+   -  Reputation: 5698

Like
0Likes
Like

Posted 06 May 2014 - 07:13 PM

I would like to set the area in the window client area that the swapchain presents to. Is that possible, or does Present always stretch to the entire window client area?

 

For background, I'm moving from DX9 to D3D11 and I'm converting several apps, a couple of which have child windows of the main window used for GDI stuff. I also used GDI directly in the client. In DX9, device->Present allows for setting the target rectangle which was convenient for allowing child windows to share the client area, and I did GDI stuff also to the client. In D3D11, I've tried creating the buffers and resizing them, but they appear to always be stretched to the full client area.

 

Will I have to, perhaps, do the reverse? I.e., render to a target child window positioned appropriately in the client area, and use GDI directly in the main window client?

 

I've also looked into using GDI directly with the buffer texture, but there appear to be format restrictions - e.g., I multisample and (apparently) that makes the surface incompatible for GDI device contexts.


Edited by Buckeye, 06 May 2014 - 07:16 PM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5163

Like
1Likes
Like

Posted 06 May 2014 - 07:44 PM

Have you set the viewport to the area of the client window that you want to render into?  That should let  you choose exactly where you are rendering into - unless I am misinterpreting what you are trying to do...  If so, can you post an image to show what isn't working properly?



#3 Buckeye   Crossbones+   -  Reputation: 5698

Like
0Likes
Like

Posted 06 May 2014 - 07:49 PM


Have you set the viewport to the area of the client window that you want to render into?

Yes, I have. That (apparently) just sets the portion of the buffer which gets rendered, as it does in DX9. That works well to restrict the rendering area, but the entire buffer still gets stretched to the entire client. It's not the area of the buffer I want to restrict, but the area in the target window client area that I want to restrict.

 

 

 


If so, can you post an image to show what isn't working properly?

I could, but it would be an image of a window with the entire client area with the clear color. wink.png

 

As an example, in the DX9 app below, the device is created with the main window handle. The bottom GDI and right-side GDI stuff are in child windows, and the DX9 buffer gets presented to the window client area in (only) the rectangle with the character (in wireframe). EDIT: Maybe the second image below provides a better explanation of what I'd like to do. In that app, there are no child windows. The rendering is merely presented to a client rectangle smaller than the client.

 

animeditor05.png

 

client_area_text.png


Edited by Buckeye, 06 May 2014 - 08:06 PM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#4 Erik Rufelt   Crossbones+   -  Reputation: 3524

Like
0Likes
Like

Posted 06 May 2014 - 08:00 PM

I believe it always stretches, so you need a child-window for that.

Present1 has parameters for updated rectangles, but I think it's just for optimization and can still clear the entire area.



#5 Scott Bruno   Members   -  Reputation: 198

Like
0Likes
Like

Posted 06 May 2014 - 08:04 PM

If it were me I would just take the hwnd of a child window and give that to DirectX, then it "just works":

 

 



#6 Buckeye   Crossbones+   -  Reputation: 5698

Like
0Likes
Like

Posted 06 May 2014 - 08:15 PM


then it "just works":

Well, not quite. The child window must be managed - e.g., created, input redirected, resized, moved, etc. - rather than just adjusting the 4 parameters of a RECT.


Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#7 Burnt_Fyr   Members   -  Reputation: 1245

Like
1Likes
Like

Posted 07 May 2014 - 08:43 AM

I think Jason's solution should work, ie; present your back buffer, and draw GDI on top afterwards, although to be honest I feel like I'm and ant among giants in this thread. Have you tried rendering to your MSAA-able surface, and then biltting (if possible) or using that as a texture to draw a full screen quad on to a GDI compatible surface?

 

I tend to do what others have suggested and just use separate HWNDs and swapchains for child areas of the hwndmain client.



#8 Buckeye   Crossbones+   -  Reputation: 5698

Like
0Likes
Like

Posted 07 May 2014 - 09:06 AM


..present your back buffer, and draw GDI on top afterwards

I appreciate your input, but I tried that some time ago. In general, because of the rapid presenting by D3D11 (or DX9 for that matter) and the slower drawing by GDI, the GDI stuff blinks unacceptably.

 


Have you tried rendering to your MSAA-able surface, and then biltting (if possible) or using that as a texture to draw a full screen quad on to a GDI compatible surface?

Have to give that some thought, Burnt_Fyr. Thinking outside the box - do my own "presenting."  As you mention, blt (rather than present) the texture (if possible) to the client and go right into GDI. For me, that'll be something to explore a little later as I haven't gotten into part of D3D11 rendering yet.


Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#9 Buckeye   Crossbones+   -  Reputation: 5698

Like
0Likes
Like

Posted 08 May 2014 - 01:01 PM

If anyone is still curious, I came back to Jason Z's suggestion about setting the viewport to (at least) limit the rendering area, with my attempts to create a GDI compatible backbuffer surface. With some bookkeeping to track area sizes, I can reuse my GDI code to draw graphs, etc., (shown in one of my pictures above.) The entire backbuffer gets the clear color, but, by setting an appropriate viewport for the D3D11 rendering, and now having a GDI compatible backbuffer, I can render both D3D11 and GDI for presentation without any child windows, etc.

 

I've only just begun the conversion, but shown below is a frame capture (a "feature" of my app) showing a quick experiment with the D3D11 viewport to the upper-left, and a GDI DrawEdge call for a potential "window" along the bottom of the buffer.

 

capture.png


Edited by Buckeye, 08 May 2014 - 01:04 PM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS