Skip to main content
GameDev.net gamedev.net
🔒 Locked

MFC + DirectX

Started by Xelot Nov 23, 2001 at 3:47 PM 2 replies 300+ views
Original Post
Xelot
Xelot
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.
PaladinGLT
PaladinGLT
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
PaladinGLT
JimboC
JimboC
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.
Shannon Barber
Shannon Barber
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
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.