• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Buckeye

Does swapchain->Present always stretch to the target?

8 posts in this topic

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
0

Share this post


Link to post
Share on other sites

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?

1

Share this post


Link to post
Share on other sites

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.

 

[attachment=21377:animeditor05.png]

 

[attachment=21378:client_area_text.png]

Edited by Buckeye
0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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

 

 

0

Share this post


Link to post
Share on other sites


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.

0

Share this post


Link to post
Share on other sites

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.

1

Share this post


Link to post
Share on other sites


..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.

0

Share this post


Link to post
Share on other sites

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.

 

[attachment=21411:capture.png]

Edited by Buckeye
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0