//----------------------------------------------------------// // WinSys_Main //----------------------------------------------------------// //-- Description // The main function. //----------------------------------------------------------// int WinSys_Main(LPSTR lpCmdLine) { if (WINSYS_OK != WinSys_Initialise()) { WinSys_Shutdown(); return 0; } //-- Attempt to Initialise the game if (IS_FALSE(Game_Initialise())) { //-- Initialise failed, so shut down nicely Game_Shutdown(); WinSys_Shutdown(); return 0; } //-- Main game loop while (true) { if (WINSYS_OK != WinSys_Update()) { //-- Loop until the message handler returns something not OK break; } Game_Main(); gWinSysGLWindow.SwapBuffers(); // while (IS_FALSE(m_FrameTimer.LockFrameRate(60.0f))) // { // //-- Todo more stuff while waiting for VSync. // gMemMgr.Update(); // gFileMgr.Update(); // } } //-- Shut down Game_Shutdown(); WinSys_Shutdown(); return 0; }
int main( int argc, char *argv[] ) { printf( APP_NAME"\n" ); common.running = true; common.path = argv[0]; {//Strip the file name + extension to get the current working directory int i = strlen( common.path )-1; while ( common.path[i] && i > 0 ) { if ( common.path[i] == '/' || common.path[i] == '\\' ) { common.path[i] = '\0'; break; } i--; } } printf( "Path is %s\n\n", common.path ); srand( (unsigned int)time( NULL ) ); R_Initialise(); Game_Initialise(); Input_Initialise(); while ( common.running ) { Input_Poll(); if ( common.running ) {//If the input handler picked up an exit, don't bother with the game R_ClearScreen(); Game_Render(); SDL_GL_SwapBuffers(); } } R_Shutdown(); Game_Shutdown(); printf( "Thanks for playing!\n" ); return 0; }
int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { // this is the winmain function WNDCLASS winclass; // this will hold the class we create HWND hwnd; // generic window handle MSG msg; // generic message HDC hdc; // generic dc PAINTSTRUCT ps; // generic paintstruct // first fill in the window class stucture winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; // register the window class if (!RegisterClass(&winclass)) return(0); // create the window, note the test to see if WINDOWED_APP is // true to select the appropriate window flags if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, // class WINDOW_TITLE, // title (WINDOWED_APP ? (WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION) : (WS_POPUP | WS_VISIBLE)), 0,0, // x,y WINDOW_WIDTH, // width WINDOW_HEIGHT, // height NULL, // handle to parent NULL, // handle to menu hinstance,// instance NULL))) // creation parms return(0); // save the window handle and instance in a global main_window_handle = hwnd; main_instance = hinstance; // resize the window so that client is really width x height if (WINDOWED_APP) { // now resize the window, so the client area is the actual size requested // since there may be borders and controls if this is going to be a windowed app // if the app is not windowed then it won't matter RECT window_rect = {0,0,WINDOW_WIDTH-1,WINDOW_HEIGHT-1}; // make the call to adjust window_rect AdjustWindowRectEx(&window_rect, GetWindowStyle(main_window_handle), GetMenu(main_window_handle) != NULL, GetWindowExStyle(main_window_handle)); // save the global client offsets, they are needed in DDraw_Flip() window_client_x0 = -window_rect.left; window_client_y0 = -window_rect.top; // now resize the window with a call to MoveWindow() MoveWindow(main_window_handle, 0, // x position 0, // y position window_rect.right - window_rect.left, // width window_rect.bottom - window_rect.top, // height FALSE); // show the window, so there's no garbage on first render ShowWindow(main_window_handle, SW_SHOW); } // end if windowed // perform all game console specific initialization Game_Init(); // disable CTRL-ALT_DEL, ALT_TAB, comment this line out // if it causes your system to crash SystemParametersInfo(SPI_SCREENSAVERRUNNING, TRUE, NULL, 0); // enter main event loop while(1) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if // main game processing goes here Game_Main(); } // end while // shutdown game and release all resources Game_Shutdown(); // enable CTRL-ALT_DEL, ALT_TAB, comment this line out // if it causes your system to crash SystemParametersInfo(SPI_SCREENSAVERRUNNING, FALSE, NULL, 0); // return to Windows like this return(msg.wParam); } // end WinMain
// WINMAIN //////////////////////////////////////////////// int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX winclass; // this will hold the class we create HWND hwnd; // generic window handle MSG msg; // generic message // first fill in the window class stucture winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // save hinstance in global ghInstance = hinstance; // register the window class if (!RegisterClassEx(&winclass)) return(0); // create the window if (!(hwnd = CreateWindowEx(NULL, // extended style WINDOW_CLASS_NAME, // class WINDOW_TITLE, // title WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0,0, // initial x,y WIDTH,HEIGHT, // initial width, height NULL, // handle to parent NULL, // handle to menu hinstance,// instance of this application NULL))) // extra creation parms return(0); // save main window handle ghWnd = hwnd; // initialize game here Game_Init(); // enter main event loop while(TRUE) { // test if there is a message in queue, if so get it if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if // main game processing goes here Game_Main(); } // end while // closedown game here Game_Shutdown(); // return to Windows like this return(msg.wParam); } // end WinMain
int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASS winclass; // this will hold the class we create HWND hwnd; // generic window handle MSG msg; // generic message HDC hdc; // generic dc PAINTSTRUCT ps; // generic paintstruct // first fill in the window class stucture winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; // register the window class if (!RegisterClass(&winclass)) return(0); // create the window, note the use of WS_POPUP if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, // class "DirectSound 100hz Tone Demo", // title WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0,0, // x,y WINDOW_WIDTH, // width WINDOW_HEIGHT, // height NULL, // handle to parent NULL, // handle to menu hinstance,// instance NULL))) // creation parms return(0); // save the window handle and instance in a global main_window_handle = hwnd; main_instance = hinstance; // perform all game console specific initialization // start up the directsound sound Game_Init(); // enter main event loop while(1) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if // main game processing goes here Game_Main(); } // end while // shutdown game and release all resources Game_Shutdown(); // return to Windows like this return(msg.wParam); } // end WinMain
int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX winclass; // this will hold the class we create HWND hwnd; // generic window handle MSG msg; // generic message HDC hdc; // graphics device context // first fill in the window class stucture winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // save hinstance in global main_instance = hinstance; // register the window class if (!RegisterClassEx(&winclass)) return(0); // create the window if (!(hwnd = CreateWindowEx(NULL, // extended style WINDOW_CLASS_NAME, // class "DirectInput Keyboard Demo", // title (WINDOWED_APP ? (WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION) : (WS_POPUP | WS_VISIBLE)), 0,0, // initial x,y SCREEN_WIDTH,SCREEN_HEIGHT, // initial width, height NULL, // handle to parent NULL, // handle to menu hinstance,// instance of this application NULL))) // extra creation parms return(0); // save main window handle main_window_handle = hwnd; // resize the window so that client is really width x height if (WINDOWED_APP) { // now resize the window, so the client area is the actual size requested // since there may be borders and controls if this is going to be a windowed app // if the app is not windowed then it won't matter RECT window_rect = { 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 }; // make the call to adjust window_rect AdjustWindowRectEx(&window_rect, GetWindowStyle(main_window_handle), GetMenu(main_window_handle) != NULL, GetWindowExStyle(main_window_handle)); // save the global client offsets, they are needed in DDraw_Flip() window_client_x0 = -window_rect.left; window_client_y0 = -window_rect.top; // now resize the window with a call to MoveWindow() MoveWindow(main_window_handle, 0, // x position 0, // y position window_rect.right - window_rect.left, // width window_rect.bottom - window_rect.top, // height FALSE); // show the window, so there's no garbage on first render ShowWindow(main_window_handle, SW_SHOW); } // end if windowed // initialize game here Game_Init(); // enter main event loop while(TRUE) { // test if there is a message in queue, if so get it if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if // main game processing goes here Game_Main(); } // end while // closedown game here Game_Shutdown(); // return to Windows like this return(msg.wParam); } // end WinMain
// // 函数: InitInstance(HINSTANCE, int) // // 目的: 保存实例句柄并创建主窗口 // // 注释: // // 在此函数中,我们在全局变量中保存实例句柄并 // 创建和显示主程序窗口。 // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; MSG msg; // generic message hInst = hInstance; // 将实例句柄存储在全局变量中 hWnd = CreateWindow(szWindowClass, szTitle, (WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION),//WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } main_window_handle = hWnd; // now resize the window, so the client area is the actual size requested // since there may be borders and controls if this is going to be a windowed app // if the app is not windowed then it won't matter RECT window_rect = { 0, 0, WINDOW_WIDTH - 1, WINDOW_HEIGHT - 1 }; // make the call to adjust window_rect AdjustWindowRectEx(&window_rect, GetWindowStyle(main_window_handle), GetMenu(main_window_handle) != NULL, GetWindowExStyle(main_window_handle)); // save the global client offsets, they are needed in DDraw_Flip() //window_client_x0 = -window_rect.left; //window_client_y0 = -window_rect.top; // now resize the window with a call to MoveWindow() MoveWindow(main_window_handle, 0, // x position 0, // y position window_rect.right - window_rect.left, // width window_rect.bottom - window_rect.top, // height FALSE); // show the window, so there's no garbage on first render ShowWindow(hWnd, nCmdShow); Game_Init(); while (1) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if // main game processing goes here Game_Main(); } // end while //UpdateWindow(hWnd); Game_Shutdown(); return msg.wParam; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow){ int iRetCode = CWOOD_OLOG->Init("WoodFree","C:\\CWLOG",true); if( iRetCode != 0 ){ //W_PRINT_ERROR_MSG_CHAR_INFO(iRetCode,"CWOOD_OLOG->Init Failed ErrMsg:%s",CWOOD_OLOG->GetLastErrMsg()); W_BOX_ALERT_CHAR_INFO(iRetCode,"CWOOD_OLOG->Init Failed ErrMsg:%s",CWOOD_OLOG->GetLastErrMsg()); return iRetCode; } CWOOD_LOG_DEBUG(" "); CWOOD_LOG_DEBUG(" ==================================== Compile Time:%s %s",__DATE__,__TIME__); WNDCLASS stWinclass; // this will hold the class we create HWND hWnd; // generic window handle MSG stMsg; // generic message HDC hDc; // generic dc PAINTSTRUCT stPaint; // generic paintstruct // first fill in the window class stucture stWinclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; stWinclass.lpfnWndProc = WindowProc; stWinclass.cbClsExtra = 0; stWinclass.cbWndExtra = 0; stWinclass.hInstance = hInstance; stWinclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); stWinclass.hCursor = LoadCursor(NULL, IDC_ARROW); stWinclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); stWinclass.lpszMenuName = NULL; stWinclass.lpszClassName = W_WINDOW_CLASS_NAME; // register the window class iRetCode = RegisterClass(&stWinclass); if ( iRetCode == 0 ){ //0 means error. NULL CWOOD_LOG_ERR(iRetCode,"%s","RegisterClass Failed!!"); return iRetCode; } // create the window, note the test to see if WINDOWED_APP is // true to select the appropriate window flags hWnd = CreateWindow(W_WINDOW_CLASS_NAME, // class W_WINDOW_TITLE, // title WS_POPUP | WS_VISIBLE, 0,0, // x,y W_WINDOW_WIDTH, // width W_WINDOW_HEIGHT, // height NULL, // handle to parent NULL, // handle to menu hInstance,// instance from outside. NULL); if( hWnd == NULL ){ iRetCode = -1; CWOOD_LOG_ERR(iRetCode,"%s %d","CreateWindow Failed!!"); return iRetCode; } /* RECT stWindowsRect = {0,0,W_WINDOW_WIDTH-1,W_WINDOW_HEIGHT-1}; // make the call to adjust window_rect AdjustWindowRectEx(&stWindowsRect, GetWindowLong(hWnd, GWL_STYLE), GetMenu( hWnd ) != NULL, GetWindowLong(hWnd, GWL_EXSTYLE)); // save the global client offsets, they are needed in DDraw_Flip() int window_client_x0 = -stWindowsRect.left; int window_client_y0 = -stWindowsRect.top; // now resize the window with a call to MoveWindow() MoveWindow(hWnd, 0, // x position 0, // y position stWindowsRect.right - stWindowsRect.left, // width stWindowsRect.bottom - stWindowsRect.top, // height FALSE); ShowWindow(hWnd, SW_SHOW); */ IDirect3DDevice9* pD3D9Device = NULL; iRetCode = Game_Init(hWnd,&pD3D9Device); if ( iRetCode != 0 ){ CWOOD_LOG_ERR(iRetCode,"%s","Game_Init Failed!!"); return iRetCode; } //============================================================================================ //============================================================================================ while(TRUE) { // test if there is a message in queue, if so get it if (PeekMessage(&stMsg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (stMsg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&stMsg); // send the message to the window proc DispatchMessage(&stMsg); } // end if if (KEYDOWN(VK_ESCAPE)){ SendMessage(hWnd,WM_CLOSE,0,0); } // main game processing goes here Game_Main(hWnd,pD3D9Device); } // end while Game_Shutdown(); return(stMsg.wParam); }