|
|
发表于 2005-7-23 15:26:00
|
显示全部楼层
其实就是WinMain,然后其他的函数加到消息循环里面去。这
/*
==================
WinMain
==================
*/
HINSTANCE global_hInstance;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
int time, oldtime, newtime;
char *cddir;
/* previous instances do not exist in Win32 */
if (hPrevInstance)
return 0;
global_hInstance = hInstance;
ParseCommandLine (lpCmdLine);
// if we find the CD, add a +set cddir xxx command line
cddir = Sys_ScanForCD ();
if (cddir && argc < MAX_NUM_ARGVS - 3)
{
int i;
// don't override a cddir on the command line
for (i=0 ; i<argc ; i++)
if (!strcmp(argv, "cddir"))
break;
if (i == argc)
{
argv[argc++] = "+set";
argv[argc++] = "cddir";
argv[argc++] = cddir;
}
}
Qcommon_Init (argc, argv);
//exit(0);
oldtime = Sys_Milliseconds ();
/* main window message loop */
while (1)
{
// if at a full screen console, don't update unless needed
if (Minimized || (dedicated && dedicated->value) )
{
Sleep (1);
}
while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!GetMessage (&msg, NULL, 0, 0))
Com_Quit ();
sys_msg_time = msg.time;
TranslateMessage (&msg);
DispatchMessage (&msg);
}
do
{
newtime = Sys_Milliseconds ();
time = newtime - oldtime;
} while (time < 1);
// Con_Printf ("time:%5.2f - %5.2f = %5.2f\n", newtime, oldtime, time);
// _controlfp( ~( _EM_ZERODIVIDE /*| _EM_INVALID*/ ), _MCW_EM );
_controlfp( _PC_24, _MCW_PC );
Qcommon_Frame (time);
oldtime = newtime;
}
// never gets here
return TRUE;
}
|
|