Archived

This topic is now archived and is closed to further replies.

Direct3D and MFC Doc/View Editer...

This topic is 5582 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites