INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT){ WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"ClassName", NULL }; RegisterClassEx( &wc ); HWND hWnd = CreateWindow( L"ClassName", L"Z Test", WS_OVERLAPPEDWINDOW, 200, 100, 600, 480, GetDesktopWindow(), NULL, wc.hInstance, NULL ); if( SUCCEEDED( init3D( hWnd ) ) ){ //创建场景图形 if( SUCCEEDED( initGeometry() ) ){ //显示窗口 ShowWindow( hWnd, SW_SHOWDEFAULT ); UpdateWindow( hWnd ); //进入消息循环 MSG msg; ZeroMemory( &msg, sizeof(msg) ); while( msg.message!=WM_QUIT ){ if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ){ TranslateMessage( &msg ); DispatchMessage( &msg ); }else{ render(); //渲染场景 } } } } UnregisterClass( L"ClassName", wc.hInstance ); return 0; }
/* * BOUCLE D'AFFICHAGE */ bool SceneManager::execute(SDL_Window* window, unsigned int w, unsigned int h) { init3D(w,h); init2D(); initSounds(); unsigned int debut ,fin; /* VARIABLES DE GESTION DU TEMPS */ float period = 1.0 / FPS_LIMIT,fps,time; while(!m_input.terminer()) /* BOUCLE D'EXECUTION */ { debut = SDL_GetTicks(); /* ON RELEVE LE TEMPS DE DEBUT DE BOUCLE */ onPreRender(); /* ON MET À JOUR LES MODELES DYNAMIQUES */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* NETTOYAGE DE LA FENETRE */ m_input.update(); /* MISE A JOUR DES EVENEMENTS */ updateCameras(); /* MISE À JOUR DES CAMERAS */ if(m_input.getKey(SDL_SCANCODE_ESCAPE)) break; /* QUITTER EN APPUYANT SUR ESPACE */ if(m_input.getKeyRelease(SDL_SCANCODE_V)) changeCamera(); /* CHANGER DE CAMERA EN APPUYANT SUR ESPACE */ if(m_input.getKeyRelease(SDL_SCANCODE_SPACE)) m_soundMgr.playEffect("laser",127/2); drawAll(); /* AFFICHAGE DE TOUS LES MODELES DU MONDE 3D */ SDL_GL_SwapWindow(window); /* RAFRAICHISSEMENT DE LA FENETRE */ fin = SDL_GetTicks(); /* ON RELEVE LE TEMPS DE FIN DE BOUCLE */ time = (float)(fin - debut); /* ON CALCULE LE TEMPS D'EXECUTION DE LA BOUCLE */ fps = 1000.0/time; /* ON CALCULE LA FREQUENCE MAXIMALE */ std::ostringstream streamTitle; streamTitle << "fps: " << fps; SDL_SetWindowTitle(window,streamTitle.str().c_str()); /* ON AFFICHE LA FREQUENCE COMME TITRE DE LA FENETRE */ if(time < period) SDL_Delay((unsigned int)(period - time)); /* ON LIMITE LA FREQUENCE A 60 FPS */ } printf("toto\n"); return true; }
void initVideo(void) { /* We need access to DS hardware */ FeOS_DirectMode(); vramSetPrimaryBanks (VRAM_A_LCD, VRAM_B_LCD, VRAM_C_SUB_BG_0x06200000, VRAM_D_LCD); /* Init video engine for the SUB_SCREEN */ videoSetModeSub(MODE_5_2D); vramSetBankI(VRAM_I_SUB_SPRITE); oamEnable(states(SUB_SCREEN)); oamInit(states(SUB_SCREEN), SpriteMapping_1D_128, false); /* Init video engine for the MAIN_SCREEN */ init3D(); }
bool Mage::init() { Actor::init(); _useWeaponId = ReSkin.mage.weapon; _useArmourId = ReSkin.mage.armour; _useHelmetId = ReSkin.mage.helmet; //init data copyData_Mage(); //init bloodbar and avatar if (uiLayer != NULL) { _bloodBar = uiLayer->MageBlood; _bloodBarClone = uiLayer->MageBloodClone; _avatar = uiLayer->MagePng; } //init image init3D(); initActions(); _AIEnabled = true; scheduleUpdateWithPriority(0); auto specialAttack = [&]() { if (_specialAttackChance == 1) return; _specialAttackChance = 1; }; MessageDispatchCenter::getInstance()->registerMessage(MessageType::SPECIAL_MAGE, [](Actor* data) { if (data->getSpecialAttackChance() == 1) return; data->setSpecialAttackChance(1); }); return true; }
//------------------------------------------------------------ int main(int argc, char* argv[]) { int i; //attend to globals tileW = (wXMax - wXMin)/GRID; tileH = (wYMax - wYMin)/GRID; // initialize window glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(winW, winH); glutInitWindowPosition(100,150); glutCreateWindow("Look ma, tiles!"); // register callback functions glutDisplayFunc(display); //glutMouseFunc(mouseclick); glutKeyboardFunc(keyboard); glutSpecialFunc(specialkey); init3D(); //basic OpenGL initializations loadTextures(); //load textures from bitmaps //construct objects area = new Area(GRID*4, GRID*4); focusX=area->getShaker().x; focusY=area->getShaker().y; handler = new Handler(*area); glutMainLoop(); delete handler; delete area; return 0; }
// windows stuff.. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; WNDCLASS wc; HWND hWnd; // set up and register wndclass wc... windows stuff wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC) WinProc; wc.cbClsExtra = 0; wc.cbWndExtra = sizeof(DWORD); wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "D3D9PROG"; if (! RegisterClass(&wc)) { // error return false; } // create window hWnd = CreateWindow("D3D9PROG", "Direct3D 8 Program", // class and caption WS_VISIBLE | WS_POPUP, // style 0, // horizontal start.. 0, // vertical start.. 800, // horz end 600, // vertical end.. GetDesktopWindow(), // parent.. NULL, // menu.. hInstance, // instance NULL); // params.. if (! hWnd) return false; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); if (init3D(hWnd) != true) // error checking... { cleanup(); return false; } if (initData() != true) { cleanup(); return false; } do // control loop... life of the program { if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) // gets messages when they appear { TranslateMessage(&msg); // standard win message stuff.. DispatchMessage(&msg); } else // if no message.. render { // this is where you do stuff when there aren't messages.. mainly render.. // might rearrange and doMath and/or other stuff here... // depends what would be best in the future.. // for now just render render(); } } while (WM_QUIT != msg.message); cleanup(); // clean it up! return msg.wParam; // more win stuff.. }