Jump to content
  • Advertisement
jonwil

DX11 Rendering Direct3D11 into a win32 child window

Recommended Posts

I am writing a level editor using Visual C++ and the win32 API. I have the game engine going working fine with Direct3D 11 (its not an off-the-shelf engine, its custom)

The plan for the editor is to have something like this:

editor.thumb.png.603fd75aeb7b749787b69d5f306cf194.png

The blue bit is going to be a standard win32 menu bar, the yellow bit will be a standard win32 status bar, the red bit will contain things like a list of objects to insert into the level (its contents will change depending on what the user is doing) and the purple bit will be a window that will be rendered into by the rendering code. I know how to do Direct3D11 rendering into a window that is the parent window and is the only thing the app is drawing (the engine runs a loop that lets the windows message loop run and process its messages before running the engine code and doing rendering) but I can't find anything out there on how you do Direct3D graphics (11 or otherwise) into a child window and how you handle things like resizing and painting and things. Its definitely possible since so many level editors and things do it but I dont know how they pull it off. (and Google isn't showing anything useful either)

Are there any examples out there of how you can create a win32 custom control/child window, set up a IDirect3D11Device to draw onto that window and then have that window play nice with all the other windows (the main parent window and the other child windows) whilst still triggering a once-per-frame render call to allow me to draw my stuff in there.

Share this post


Link to post
Share on other sites
Advertisement

Your child "window" will have a handle, you need to create your d3d device with the correct handle. thats litteraly all thats needed.

for resizing, you need to handle the windows messages for resizing. if i remember correctly its something like WM_SIZE or so. at that point you could delete your old d3d device, and recreate it. easier would even be to just resize your framebuffers and all the rendertargets needed. 

thees two things might sound like a hardthing to do, but they are infact pretty simple if you keep your code simple.

good luck!

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

  • 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!