Click here to Skip to main content
15,886,422 members
Articles / Desktop Programming / MFC
Article

A CStatic derived class using Direct3D Retained Mode

Rate me:
Please Sign up or sign in to vote.
3.90/5 (11 votes)
2 Apr 2001 90.8K   2K   36   8
A CStatic derived class that can be dropped into an application to provide the ability to load and display 3D objects
Image 1

Overview

The C3DPortal class is a CStatic derived class that I wrote to allow a programmer to drop it into a project and have the ability to load and display 3D objects using Direct3D Retained Mode. I also started toying with manual construction of an object as illustrated in the Test() function. Just be aware if you want to try this function out, that you must first load a valid object. I could have worked on it and enhanced it, etc, but I'm moving onto Immediate Mode stuff and don't want to get any more involved in RM.

C3DPortal Class Outline

Public Methods

The functions typically used by the host application are documented below.

void BrowseForTexture()

Prompts user to browse for a bitmap for use as a texture (which will subsequently be applied to the loaded object)

bool LoadMesh(LPTSTR lpszMeshName=    "")

If lpszMeshName is empty, then the user will be prompted to browse for a X file to be displayed in the control. returns true if load was successful.

void SetColourBackground(COLORREF cr)

Sets the background colour according to the COLORREF parameter supplied.

Example use of C3DPortal

In your header file:

#include "3DPortal.h"
...

class CPortalDemoDlg : public CDialog
{
// Construction
public:
    C3DPortal m_stcPortal; // This member variable is <BR>                           // associated with a CStatic
                            // resource whose ID is IDC_STATIC_PORTAL
    ...

In your implementation file:

BOOL CPortalDemoDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    
    m_stcPortal.Create("", WS_VISIBLE|SS_NOTIFY|SS_SUNKEN, 
                C3DPortal::GetRect(IDC_STATIC_PORTAL, this),(CWnd*)this);
    m_stcPortal.LoadMesh();

    return TRUE;  // return TRUE  unless you set the focus to a control
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalcant find d3drm.lib Pin
kob-kob20-Dec-06 23:51
kob-kob20-Dec-06 23:51 
GeneralRe: cant find d3drm.lib Pin
Member 1382902110-Aug-18 1:58
Member 1382902110-Aug-18 1:58 
Generalx files Pin
dagan_os25-Jan-05 21:50
dagan_os25-Jan-05 21:50 
General3D Test function Pin
Georgi Petrov16-Jan-05 23:33
Georgi Petrov16-Jan-05 23:33 
Questionhow to load other .x files, the one that are not attached with sample??? Pin
Ejaz28-Dec-03 21:59
Ejaz28-Dec-03 21:59 
AnswerRe: how to load other .x files, the one that are not attached with sample??? Pin
HughJampton11-Feb-05 6:30
HughJampton11-Feb-05 6:30 
GeneralRe: how to load other .x files, the one that are not attached with sample??? Pin
Zhelezov16-Apr-05 9:00
Zhelezov16-Apr-05 9:00 
QuestionHow can I collect X files? Pin
ICE_WIZARD27-Jul-03 8:47
ICE_WIZARD27-Jul-03 8:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.