Direct3D and MFC Doc/View Editer...

Started by
1 comment, last by Dirge 21 years, 7 months ago
OK, so I''m working on just a little (MDI based) MFC model viewer and I''m having some... difficulty. I''ve decided to use Direct3D for it (maybe a bad choice) and I''m loading 3ds files. Well, I can get the 3ds file to load and Render in a single view window, BUT I''m having trouble finding a good place to load/contain the model because every time I load a new view, the previous view disappears (am I going to have to change the Render Target???). Also, should the initialization code for Direct3D be in the View area? So basically I do a create for every View? I''ve had no trouble getting something similar going in OpenGL before but Direct3D is so much more of a hassle (but I''m not switching). Does anyone that has perhaps done something similar have some advice? Maybe even demonstrative code? Thanks for any help! "Love all, trust a few. Do wrong to none." - Shakespeare Dirge - Aurelio Reis www.CodeFortress.com Current Causes: Nissan sues Nissan
"Artificial Intelligence: the art of making computers that behave like the ones in movies."www.CodeFortress.com
Advertisement
I would take the object orientated approach using singletons patterns to solve you problem.

Create a singleton class that enumerates and loads all of the DirectX objects needed to create a D3DDevice. Make that class singleton so all of the views and the documents can get a handle to it.

Then use the view classes to create seperate D3DDevices for themselves and let the viewclass manage the camera and rendering modes (like textured, lines, points, alpha, etc..). You could probably use one class and multiple spawns of it.

Use the document class(es) to load and store the 3ds files. The document class should also load the mesh into a vertex buffer that can be read by the view classes. The document class should already be a (makeshift) singleton pattern.

Then when the data changes in the documents, all of the view classes draw the changes.
don''t use multiple devices for performance reasons. instead, create additional swap chains for every window on a single global device. i''d put device management code outside the view class, model data and loading code in the document and presentation code in the view.

This topic is closed to new replies.

Advertisement