Using Hieroglyph 3 (and D3D11) with MFC

Published December 28, 2011
Advertisement
I spent some of the Christmas vacation building a sample program for Hieroglyph 3 that shows how to use it within an MFC application. Several users of the library were asking for information about how to implement such an application, and I have worked with MFC a little before, so I dove into the task. I am also looking forward to developing some tools for my Kinect applications as well as Hieroglyph in general, so this is time well spent.

If you haven't used MFC before, or only use it occasionally, do yourself a favor and get a good book on it. Many people will tell you that MFC is too old and clunky to be useful, and they just might be right. There are lots of things that are not obvious in how they work until you are familiar with them. However, it has been around forever, there is lots of applications that have been built on it, and there are quite nice developer IDEs built right into Visual Studio for you to build dialogs with. Plus it doesn't cost anything, and there are lots of people that are familiar with it to boot.

I personally have the quite old Programming Windows with MFC book - but don't be fooled, even though it is old it is still very relevant. Understanding the basics of an application, a frame window, a document, and a view within the context of an SDI application can take a very long time if you are only using the raw documentation, and it is always handy to have a quick reference for the things you have forgotten...

Anyways, the basic concept for integrating a rendering library with MFC is to build a subclass of CView that will present a rendered scene to an HWND based window. The document is more or less just a scene in my sample application that consists of a single object. So a CView is responsible to take the document and render it into a window... This is precisely the same thing that a normal full screen application does, but you just have to package the various actions into an MFC class to allow it to work within the framework.

By creating such a class, the developer can then use it multiple times within an application to produce multiple rendered images of a given document. This is one of the things that MFC is really good at - once you have made the separation between data (as a document) and viewing (as a CView subclass) then there is lots of help to make multiple windows showing your data. The Hieroglyph 3 sample, appropriately named MFCwithD3D11, provides three resizable rendering windows in this fashion:

MFCwithD3D11.png



I haven't added mouse / keyboard interactivity to the views just yet, but that will be coming in the future. I would also like to add in some dialogs for configuring the various options of the rendered output, but that will take a bit more time to figure out what would make for a good example. If anyone out there has any interest in specific examples or features that they would like to see, please let me know and I'll add them into the queue :)
0 likes 2 comments

Comments

BenS1
You could add dialogs to toggle between Solid/Wireframe, Textured/Untextured, Render Device (e.g. Ref, WARP, H/W) etc.
December 29, 2011 11:44 AM
Jason Z
Those are good suggestions - and they cover two different general areas: per object properties (fill mode, texturing, etc...) and global properties (device type). The per-object properties would be challenging to get into a static dialog, since the material properties can allow for varying numbers and types of parameters depending on what it is implementing. However, it could be possible to dynamically generate a dialog with the various properties visible in them.

I have also thought about generating a tree view to visualize the current scene. That would allow for a way to directly see what is going on in the scene, and then I could populate that tree view with the appropriate sub-parameters used in rendering as you mentioned. That would be interesting and quite useful, so I'll check into that. Thanks for the suggestions!
December 29, 2011 10:29 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement