• Advertisement

Archived

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

MFC + DirectX

This topic is 5905 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

Where can I get a tutorial or example code on initializing DirectDraw with MFC? Iv made a ''game'' before with DirectDraw and Win32 API. I just need to know how to set it up in MFC. Please dont tell me that MFC is not good for games, I have reasons to be using MFC.

Share this post


Link to post
Share on other sites
Advertisement
fiannly, someone else who's using mfc =) Using direct draw is really easy. I use the ddutil files. Simply make a basic window.

BEGIN_MESSAGE_MAP(CDDrawWindow, CFrameWnd)
ON_WM_PAINT()
ON_WM_TIMER()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()

CDDrawWindow()
{
Create(0,"");
}

void CDDrawWindow::OnPaint()
{
//Rendering code here
KillTimer(11);
SetTimer(11,20,NULL); //the 20 is the ms delay between updates
};

void CDDrawWindow::OnTimer(UINT nIDEvent)
{
Invalidate(FALSE);
}

void CDDrawWindow::OnEraseBkgnd()
{
return;
};

BOOL CApp::InitInstance()
{
MainWnd = new CDDrawWindow;
MainWnd->ShowWindow(SW_MAXIMIZE);
MainWnd->UpdateWindow();
MainWnd->Display.CreateFullScreenDisplay(MainWnd->GetSafeHwnd(),640,480,16);
m_pMainWnd = MainWnd;
};

That should set up a basic direct draw window.

PaladinGLT

Edited by - PaladinGLT on November 23, 2001 5:00:44 PM

Share this post


Link to post
Share on other sites
The DirectX 8.1 SDK adds all kinds of AppWizzards and the like that seem to give you full access to DirectX using MFC. The docs seem to be expanded pretty well in this area as well. Haven''t had a chance to play with it much myself since I can''t get the blasted SDK to my home system.

Share this post


Link to post
Share on other sites
There's an example called mfcfog in the multimedia directory that uses DirectX and MFC, there's a couple of other ones as well.

If you want simulated time rendering with MFC, you need to make a thread - otherwise the rendering will stall when they click on a menu item or move the window around.

Edited by - Magmai Kai Holmlor on November 23, 2001 11:26:28 PM

Share this post


Link to post
Share on other sites

  • Advertisement