Advertisement

Rendering Direct3D11 into a win32 child window

Started by January 01, 2018 05:59 AM
1 comment, last by Tordin 7 years, 1 month ago

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.

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!

"There will be major features. none to be thought of yet"

This topic is closed to new replies.

Advertisement