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.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!






Using Hieroglyph 3 (and D3D11) with MFC

Posted by Jason Z, 28 December 2011 · 1,084 views


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:

Attached Image


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 :)




You could add dialogs to toggle between Solid/Wireframe, Textured/Untextured, Render Device (e.g. Ref, WARP, H/W) etc.
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!

November 2014 »

S M T W T F S
      1
2345678
9101112131415
16171819202122
2324 25 26272829
30      

Recent Comments

Recent Comments

PARTNERS