Archived

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

krad7

MFC or Win32 SDK ???

Recommended Posts

hi i have a Q for all the game developers out there.. what do you guys use to program games.. MFC or Win32 SDK ??? i personally prefer Win32 SDK, i know MFC makes your life kinda simpler cause it has a lot of classes and stuff.. but when it comes to performance i think win32 sdk is better, am i right or wrong? i use win32 sdk for programming my games and apps, is it better to shift to mfc??? Slow and steady wins the race.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You have a Q eh? Is it for free?

I myself use Win32 SDK. MFC is nice and easy, but it''s design was not made for games.

Share this post


Link to post
Share on other sites
Q i mean question not Queue or something else..
hey can you guys think of a work that starts with Q but not U following it? please dont make up any words.. only english words.. anywayz personall SDK rox !! i like it far better than mfc..

Slow and steady wins the race.

Share this post


Link to post
Share on other sites
A word beginning with Q but without U as a second letter, easy:

-Qwerty

It is a real word. A qwerty keyboard is the standard english typewriter or computer keyboard, with the characters Q,W,E,R,T and Y at the top of the keyboard!

Hehe, I'm good.

-Weasalmongler (it is in the dictionary, I checked!)

P.S. - Win32 SDK is the way to go, I have always used it and I always will use it, until Microsoft Windows ceases to be the main computer OS.

(P.P.S - Did I get the answer right? And if so, do I win a pretty gold star?)

[edited by - weasalmongler on March 23, 2002 7:36:22 AM]

[edited by - weasalmongler on March 23, 2002 10:04:10 AM]

Share this post


Link to post
Share on other sites
I use them both. With MFC it''s easy to create simple windowed applications that don''t need to be fast (like map-editors & model viewers) Win32 API seems to be better for anything else.

Share this post


Link to post
Share on other sites
He asked about games. For anything that has to be real-time (like most games), use the raw API. Otherwise, wrappers such as MFC are just fine.

Share this post


Link to post
Share on other sites
I don''t really see much that could be done with Win32 API for a game, which use DirectX or OpenGL API, so use MFC for all your windows stuff, unleas you really want to optimize your scroll-bar .

I think he meant QP = Quarter Pound

Share this post


Link to post
Share on other sites
Hi there!

Correct me if I''m wrong. Your program is structured in this way isn''t it:

WinMain()
{
// Init stuff
...

if (PeekMessage(...))
{
// Handle it
...
}
else
{
// Do useful stuff
GameLoop();
}
}

Your game loop updates the world and renders it, supposedly with D3D or OGL. You most likely use DINPUT and not windows messages for input.

Now how exactly does MFC slow your game down? >99% of the time your game will execute the GameLoop() function, which has no relation to windowing code. Regardless of whether your WndProc is written by you in plain Win32 or it''s hidden in MFC42.DLL, it doesn''t get called!

Don''t forget that MFC provides you with a load of debugging tools. Sure you can use STL, but does your STL ASSERT when you pass -1 to vector''s operator []?

Unless you are writing a 64K demo, I have yet to see a good reason not to use MFC in every program that creates a window.

Share this post


Link to post
Share on other sites
MFC most certainly does have a window procedure. But, yes, it's hidden. And it's also generalized. MFC uses a map to retrieve the CWnd object for the received window handle every time the window receives a message. Make no mistake: no matter what kind of application you make, it gets lots of messages. Now, yes, that still doesn't add up to a serious degradation. But why suffer it when you don't need to?

Of course, you can use MFC without its window and message functionality, and that's a fine option. What's so special about MFC's debugging features? Nothing. They just wrap things that are in the Windows API or C runtime library. Just use them directly or wrap yourself, freeing your application from a binding to the dreaded MFC DLL's, which are some of the main culprits in DLL Hell.

[edited by - merlin9x9 on March 23, 2002 6:27:06 PM]

Share this post


Link to post
Share on other sites
If making games, it is better not using MFC just to create 1 window, however it would make sence to use it for creating External Options or Graphics Adapter dialogs, that are separate windows from your game and don''t show while your game is playing. To create one main game window where other API will draw everything to, it probably would be better to use pure API. Even better use pure Assembly... now that I think about it, Assembly is too slow, so use pure machine code. Machine code is the easiest thing in the world!

Share this post


Link to post
Share on other sites
Okay, here it goes. I overrode WindowProc in my only window and let my program run for 20 seconds. Each time a message was received, I TRACEd the message number, timestamp, message, wParam and lParam. The results are:

  
Loaded symbols for ''e:\cpp\lonestar\string\debug\lsstring.dll''
Loaded symbols for ''e:\cpp\lonestar\ark3d\debug\lsark3d.dll''
Loaded symbols for ''e:\cpp\lonestar\glfonttest\debug\lsglfonttest.dll''
Loaded ''ntdll.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\kernel32.dll'', no matching symbolic information found.
Loaded symbols for ''D:\WINDOWS\system32\dxfcd.dll''
Loaded symbols for ''D:\WINDOWS\system32\MFC42D.DLL''
Loaded symbols for ''D:\WINDOWS\system32\MSVCRTD.DLL''
Loaded ''D:\WINDOWS\system32\gdi32.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\user32.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\advapi32.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\rpcrt4.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\ole32.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\oleaut32.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\msvcrt.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\nvdesk32.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\MSCTF.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\clbcatq.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\comres.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\version.dll'', no matching symbolic information found.
Loaded symbols for ''D:\WINDOWS\system32\GLBMPd.dll''
Loaded ''D:\WINDOWS\system32\opengl32.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\glu32.dll'', no matching symbolic information found.
Loaded symbols for ''D:\WINDOWS\system32\ddraw.dll''
Loaded ''D:\WINDOWS\system32\dciman32.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\d3dx8d.dll'', no matching symbolic information found.
Direct3D8: (INFO) : ModeXOnly: 0
Direct3D8: (INFO) : EmulationOnly: 0
Direct3D8: (INFO) : ShowFrameRate: 0
Direct3D8: (INFO) : EnablePrintScreen: 0
Direct3D8: (INFO) : DisableAGPSupport: 0
Direct3D8: (INFO) : DisableMMX: 0
Direct3D8: (INFO) : DisableWiderSurfaces:0
Direct3D8: (INFO) : DisableNoSysLock:0
Direct3D8: (INFO) : ForceNoSysLock:0
Direct3D8: (INFO) : DisableInactivate:0
Direct3D8: (INFO) :NOT Setting DDCAPS_BANKSWITCHED
Direct3D8: (WARN) :Checking Processor for MMX support (Benign first-chance exception possible)
Direct3D8: (INFO) :This is an MMX machine.
Direct3D8: (INFO) :*********** NOT!! ALLOWING MODE X AND VGA MODES
Direct3D8: : CreateSurface returns 00000000 (0)
Loaded ''D:\WINDOWS\system32\ijl15.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\comctl32.dll'', no matching symbolic information found.
Loaded ''D:\Program Files\Microsoft Hardware\Mouse\point32.dll'', no matching symbolic information found.
--Tunnel Effect plugin initialized
Message 1 at 0.00: 0x81, 0, 1242448
Message 2 at 0.00: 0x83, 0, 1242520
Message 3 at 0.00: 0x1, 0, 1242428
Loaded ''D:\WINDOWS\system32\dinput8.dll'', no matching symbolic information found.
Loaded symbols for ''D:\WINDOWS\system32\dinput8d.dll''
Loaded ''D:\WINDOWS\system32\hid.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\setupapi.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\winmm.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\ctwdm32.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\ctwdm32.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\ctwdm32.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\nvoglnt.dll'', no matching symbolic information found.
Loaded ''D:\WINDOWS\system32\mcd32.dll'', no matching symbolic information found.
--Tunnel Effect plugin: loading graphics...
D3DX: (INFO) Using 3DNow Instructions
--Tunnel Effect plugin: graphics loading finished
Message 4 at 0.21: 0x5, 0, 65537400
LS Driver: Update resize code
Message 5 at 0.21: 0x3, 0, 6553700
Message 6 at 0.21: 0x1c, 0, 128
Message 7 at 0.23: 0x18, 1, 0
Message 8 at 0.23: 0x46, 0, 1244212
Message 9 at 0.23: 0x46, 0, 1244212
Message 10 at 0.24: 0x1c, 1, 128
Message 11 at 0.24: 0x86, 1, 0
Message 12 at 0.25: 0x6, 1, 0
Message 13 at 0.25: 0x36e, 1, 1243032
Message 14 at 0.25: 0x7, 0, 0
Message 15 at 0.25: 0x86, 0, 0
Message 16 at 0.25: 0x36d, 4, 0
Message 17 at 0.25: 0x0, 0, 0
Message 18 at 0.25: 0x85, 1, 0
Message 19 at 0.25: 0x14, 1761678333, 0
Message 20 at 0.25: 0x47, 0, 1244212
Message 21 at 0.25: 0x88, 4, 0
Message 22 at 0.25: 0x7f, 2, 0
Message 23 at 0.25: 0x7f, 0, 0
Message 24 at 0.25: 0x7f, 1, 0
Loaded ''D:\Program Files\Microsoft Hardware\Mouse\Msh_zwf.dll'', no matching symbolic information found.
Message 25 at 0.26: 0x362, 57345, 0
Message 26 at 0.26: 0xc288, 2, 0
Message 27 at 0.26: 0xf, 0, 0
Message 28 at 0.26: 0x363, 1, 0
Loaded ''D:\WINDOWS\system32\mslbui.dll'', no matching symbolic information found.
Message 29 at 0.89: 0x363, 1, 0
Message 30 at 0.89: 0x363, 1, 0
Message 31 at 0.90: 0x363, 1, 0
Message 32 at 0.90: 0x363, 1, 0
Message 33 at 0.91: 0x363, 1, 0
Message 34 at 1.09: 0x363, 1, 0
Message 35 at 1.10: 0x363, 1, 0
Message 36 at 1.12: 0x363, 1, 0
Message 37 at 1.13: 0x363, 1, 0
Message 38 at 1.13: 0x363, 1, 0
Message 39 at 1.14: 0x363, 1, 0
Message 40 at 1.15: 0x363, 1, 0
Message 41 at 1.16: 0x363, 1, 0
Message 42 at 1.22: 0x363, 1, 0
Message 43 at 1.23: 0x363, 1, 0
Message 44 at 1.23: 0x363, 1, 0
Message 45 at 1.25: 0x363, 1, 0
Message 46 at 1.25: 0x363, 1, 0
Message 47 at 1.27: 0x363, 1, 0
Message 48 at 1.27: 0x363, 1, 0
Message 49 at 1.28: 0x363, 1, 0
Message 50 at 1.29: 0x363, 1, 0
Message 51 at 1.48: 0x363, 1, 0
Message 52 at 20.56: 0x104, 18, 540540929
Message 53 at 20.56: 0x363, 1, 0
Message 54 at 20.59: 0x104, 115, 540934145
Message 55 at 20.59: 0x215, 0, 0
Message 56 at 20.59: 0x0, 0, 0
Message 57 at 20.59: 0x112, 61536, 0
Message 58 at 20.59: 0x10, 0, 0
Message 59 at 20.59: 0x18, 0, 0
Message 60 at 20.59: 0x46, 0, 1240976
Message 61 at 20.60: 0x47, 0, 1240976
Message 62 at 20.61: 0x86, 0, 0
Message 63 at 20.61: 0x6, 0, 0
Message 64 at 20.61: 0x36e, 0, 1239428
Message 65 at 20.61: 0x86, 0, 0
Message 66 at 20.61: 0x36d, 8, 0
Message 67 at 20.61: 0x1c, 0, 128
Message 68 at 20.62: 0x8, 0, 0
Message 69 at 20.62: 0x46, 0, 1240936
Message 70 at 20.62: 0x47, 0, 1240936
Message 71 at 20.63: 0x2, 0, 0
LS Driver: Update destroy code
Message 72 at 20.64: 0x82, 0, 0
--Tunnel Effect plugin shut down (0x00000000)
The thread 0x990 has exited with code -1073741749 (0xC000004B).
Direct3D8: (INFO) :Resetting primary surface
Direct3D8: (INFO) :Mode was never changed by this app
Direct3D8: (INFO) :MemFini!
The thread 0xD08 has exited with code 0 (0x0).
The program ''E:\cpp\LoneStar\Driver\Debug\Driver.exe'' has exited with code 0 (0x0).

As you can see, there were NO messages received between 2 and 20 seconds. Now, to my question: how does MFC slow you down if its code isn''t executed?

Share this post


Link to post
Share on other sites
*shrugs*
Use Spy++, and you should see a few more. Even if not, whatever messages received will result in some overhead. Maybe negligable, but it''s so pointless to accept that overhead when using the raw API in a game is more than easy.

Share this post


Link to post
Share on other sites
quote:
Original post by IndirectX
Don''t forget that MFC provides you with a load of debugging tools.

Wrappers around CRT debugging tools, and MFC-specific.

quote:

Sure you can use STL, but does your STL ASSERT when you pass -1 to vector''s operator []?

No. But it throws an exception on certain illegal operations, which are more useful (since they''re portable, unwind the stack, etc etc).

quote:

Unless you are writing a 64K demo, I have yet to see a good reason not to use MFC in every program that creates a window.

It''s called the WTL. Leaner, more modern (which results in cleaner design) and generic.

I''m not supporting either side of the argument; I''m introducing a third. While the WTL is still completely undocumented, there are efforts at remedying that based on perusing the sources (most notably at The Code Project). It''s a much leaner toolkit, designed as the GUI complement to the ATL (which rocks for COM!) Thought some might like to know.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites