int main(int argc, char **argv) { View * v = new View(&argc, argv); v->createWindow("q3bsp", 640, 480); //init variables etc, then GL if (!DemoInit()) { Util::log("Demo Initiation failed"); return 0; } else Util::log("Demo Initiation Successful"); if (!GLInit()) { Util::log("OpenGL Initiation failed"); return 0; } else Util::log("OpenGL Initiation Successful"); // Register the callback function to do the drawing. v->onDraw(&RenderFrame); // If there's nothing to do, draw. // v->onIdle(&RenderFrame); v->onKeyboard(&UpdateFrame); v->setSpecialHandler(&cbSpecial); v->onMouse(&OnMouse); v->onMouseMove(&OnMouseMove); v->start(); DemoShutdown(); Util::log("Exiting..."); return 0; //Exit The Program }
//ENTRY POINT FOR APPLICATION //CALL WINDOW CREATION ROUTINE, DEAL WITH MESSAGES, WATCH FOR INTERACTION int main(int argc, char **argv) { Util::log("%s" , "TEST"); View * v = new View(&argc, argv); // Open a window v->createWindow("bumpmapping", 640, 480); //init variables etc, then GL if(!DemoInit()) { Util::log("Demo Initiation failed"); return 0; } else Util::log("Demo Initiation Successful"); if(!GLInit()) { Util::log("OpenGL Initiation failed"); return 0; } else Util::log("OpenGL Initiation Successful"); v->onKeyboard(&UpdateFrame); v->onDraw(&RenderFrame); v->start(); DemoShutdown(); Util::log("Exiting..."); return 0; //Exit The Program }
//-------------------------------------------------------------- // Name: WinMain - global // Description: The equivalant to Main( ) in console apps // Arguments: Just some default arguments that windows requires // Return Value: An integer variable //-------------------------------------------------------------- int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { char szBuffer[256]; //Do all of the Initiation stuff if( !DemoInit( ) ) return false; while( true ) { if( !g_glApp.HandleMessages( ) ) break; if( g_glApp.MenuDown( ID_DEMO_EXIT ) ) PostQuitMessage( 0 ); //save the current height map else if( g_glApp.MenuDown( ID_DEMO_SAVEMAP ) ) { sprintf( szBuffer, "height%d_%d.RAW", g_bruteForce.m_iSize, g_iCurrentHeightmap ); g_bruteForce.SaveHeightMap( szBuffer ); g_iCurrentHeightmap++; } //generate a new height map using fault formation else if( g_glApp.MenuDown( ID_DEMO_FF ) ) { g_iFractalAlgo= FAULT_FORMATION; g_glApp.CreateDialogBox( IDD_ROUGHNESS, IDD_ROUGHNESSProc ); } //generate a new height map using midpoint displacement else if( g_glApp.MenuDown( ID_DEMO_MD ) ) { g_iFractalAlgo= MIDPOINT_DISPLACEMENT; g_glApp.CreateDialogBox( IDD_ROUGHNESS, IDD_ROUGHNESSProc ); } if( g_glApp.IsActive( )==APP_ACTIVE ) { //check input if( !DemoInput( ) ) break; //rendering loop DemoRender( ); } } //Shut the game down DemoShutdown( ); return false; }
//WinMain int WINAPI WinMain( HINSTANCE hInstance, //Instance HINSTANCE hPrevInstance, //Previous Instance LPSTR lpCmdLine, //Command line params int nShowCmd) //Window show state { //Save hInstance WINDOW::Instance()->hInstance=hInstance; //Init GL and variables if(!GLInit()) { LOG::Instance()->OutputError("OpenGL Initiation Failed"); return false; } else LOG::Instance()->OutputSuccess("OpenGL Initiation Successful"); if(!DemoInit()) { LOG::Instance()->OutputError("Demo Initiation Failed"); return false; } else LOG::Instance()->OutputSuccess("Demo Initiation Successful"); //Main Loop for(;;) { if(!(WINDOW::Instance()->HandleMessages())) //quit if HandleMessages returns false break; UpdateFrame(); } //Shutdown DemoShutdown(); //Exit program LOG::Instance()->OutputSuccess("Exiting..."); return 0; }
//ENTRY POINT FOR APPLICATION //CALL WINDOW CREATION ROUTINE, DEAL WITH MESSAGES, WATCH FOR INTERACTION int WINAPI WinMain( HINSTANCE hInstance, //instance HINSTANCE hPrevInstance, //Previous Instance LPSTR lpCmdLine, //command line parameters int nCmdShow) //Window show state { //Initiation errorLog.Init("Error Log.txt"); //init variables etc, then GL if(!DemoInit()) { errorLog.OutputError("Demo Initiation failed"); return 0; } else errorLog.OutputSuccess("Demo Initiation Successful"); if(!GLInit()) { errorLog.OutputError("OpenGL Initiation failed"); return 0; } else errorLog.OutputSuccess("OpenGL Initiation Successful"); //Main Loop for(;;) { if(!(window.HandleMessages())) break;//handle windows messages, quit if returns false UpdateFrame(); RenderFrame(); } DemoShutdown(); errorLog.OutputSuccess("Exiting..."); return (window.msg.wParam); //Exit The Program }
//-------------------------------------------------------------- // Name: WinMain - global // Description: The equivalant to Main( ) in console apps // Arguments: Just some default arguments that windows requires // Return Value: An integer variable //-------------------------------------------------------------- int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { //Do all of the Initiation stuff if( !DemoInit( ) ) return false; while( true ) { if( !g_glApp.HandleMessages( ) ) break; //exit the demo if( g_glApp.MenuDown( ID_DEMO_EXIT ) ) PostQuitMessage( 0 ); //take a screenshot else if( g_glApp.MenuDown( ID_DEMO_SCREENSHOT ) ) g_glApp.TakeScreenshot( "screenshot.bmp" ); if( g_glApp.IsActive( )==APP_ACTIVE ) { //check input if( !DemoInput( ) ) break; //rendering loop DemoRender( ); } } //Shut the game down DemoShutdown( ); return false; }
//-------------------------------------------------------------- // Name: WinMain - global // Description: The equivalant to Main( ) in console apps // Arguments: Just some default arguments that windows requires // Return Value: An integer variable //-------------------------------------------------------------- int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { char szBuffer[256]; //Do all of the Initiation stuff if( !DemoInit( ) ) return false; while( true ) { if( !g_glApp.HandleMessages( ) ) break; //exit the demo if( g_glApp.MenuDown( ID_DEMO_EXIT ) ) PostQuitMessage( 0 ); //take a screenshot else if( g_glApp.MenuDown( ID_DEMO_SCREENSHOT ) ) g_glApp.TakeScreenshot( "screenshot.bmp" ); //save the current height map else if( g_glApp.MenuDown( ID_DEMO_SAVEMAP ) ) { sprintf( szBuffer, "height%d_%d.RAW", g_bruteForce.m_iSize, g_iCurrentHeightmap ); g_bruteForce.SaveHeightMap( szBuffer ); g_iCurrentHeightmap++; } //save the current texture map else if( g_glApp.MenuDown( ID_DEMO_SAVE_TEXTUREMAP ) ) g_bruteForce.SaveTextureMap( "texturemap.bmp" ); //generate a texture map (with the size provided) else if( g_glApp.MenuDown( ID_DEMO_GENERATE_TEXTURE_MAP ) ) g_glApp.CreateDialogBox( IDD_TEXTURESIZE, IDD_TEXTUREProc ); //generate a new height map using fault formation else if( g_glApp.MenuDown( ID_DEMO_FF ) ) { g_iFractalAlgo= FAULT_FORMATION; g_glApp.CreateDialogBox( IDD_ROUGHNESS, IDD_ROUGHNESSProc ); } //generate a new height map using midpoint displacement else if( g_glApp.MenuDown( ID_DEMO_MD ) ) { g_iFractalAlgo= MIDPOINT_DISPLACEMENT; g_glApp.CreateDialogBox( IDD_ROUGHNESS, IDD_ROUGHNESSProc ); } //save the current light map to a file else if( g_glApp.MenuDown( ID_DEMO_SAVELIGHTMAP ) ) g_bruteForce.SaveLightMap( "lightmap.raw" ); //customize slope lighting parameters using a dialog box else if( g_glApp.MenuDown( ID_DEMO_CUSTOMIZE_SLOPE ) ) g_glApp.CreateDialogBox( IDD_CUSTOMIZE_SLOPE, IDD_CUSTOMIZE_SLOPEProc ); if( g_glApp.IsActive( )==APP_ACTIVE ) { //check input if( !DemoInput( ) ) break; //rendering loop DemoRender( ); } } //Shut the game down DemoShutdown( ); return false; }
int main(int argc, char *argv[]) #endif { UNUSED(argc); UNUSED(argv); TUpdate lUpdate = {0,}; TConfig lConfig = { 800 /* width */, 600 /* height */, 16 /* bpp */, false /* fullscreen */, "LDPrototype", /* title */ 16, /* Hz */ 1, /* VSync */ 0, /* Multisampling (0 == disabled) */ false, /* Grab Input */ false, /* Hide Cursor */ false, /* Center Cursor */ false /* Audio */ }; DemoConfig(&lConfig); if(SDL_Init(SDL_INIT_EVERYTHING)<0) { printf("SDL_init: %s\n", SDL_GetError()); return -1; } /*! Initialize random seed */ srand(time(NULL)); if(lConfig.mAudio) { if(Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 1024) < 0) { printf("Mix_OpenAudio: %s\n", Mix_GetError()); return -2; } } /* Input */ uint32 lCenterX = lConfig.mWidth / 2; uint32 lCenterY = lConfig.mHeight/ 2; if(lConfig.mGrabInput) SDL_WM_GrabInput(SDL_GRAB_ON); if(lConfig.mHideCursor) SDL_ShowCursor(SDL_DISABLE); SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL ); /* OpenGL */ SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, lConfig.mVSync ); if(lConfig.mMultiSampling) { SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, lConfig.mMultiSampling); } /* Window */ uint32 lFlags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_OPENGL; if(lConfig.mFullScreen) lFlags |= SDL_FULLSCREEN; SDL_Surface *lScreen = SDL_SetVideoMode(lConfig.mWidth, lConfig.mHeight, lConfig.mBpp, lFlags); if(lScreen == NULL) { printf("SDL_SetVideoMode: %s\n", SDL_GetError()); return -3; } if(lConfig.mTitle!=NULL) SDL_WM_SetCaption(lConfig.mTitle, lConfig.mTitle); /* OpenGL Again */ uint32 lError = 0; if((lError=glewInit()) != GLEW_OK) { printf("glewInit: %s\n", glewGetErrorString(lError)); goto exit; } if(!GLEW_VERSION_2_0) { printf("OpenGL 2.0 is not available.\n"); goto exit; } { int lTexImageUnits = 0; int lTexUnits = 0; glGetIntegerv(GL_MAX_TEXTURE_UNITS,&lTexUnits); glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,&lTexImageUnits); printf("%d Texture and %d Image Units ...\n",lTexUnits, lTexImageUnits); if(lTexUnits<4) { printf(" => WARNING: You don't seem to have at least 4 Texture Units ...\n"); goto exit; } } if(!GLEW_EXT_framebuffer_object) { printf(" => WARNING: GL_EXT_framebuffer_object is not supported ...\n"); goto exit; } if(!GLEW_EXT_framebuffer_multisample) { printf(" => WARNING: GL_EXT_framebuffer_multisample is not supported ...\n"); goto exit; } if(!GLEW_EXT_framebuffer_blit) { printf(" => WARNING: GL_EXT_framebuffer_blit is not supported ...\n"); goto exit; } printf("Non Power Of Two Textures: %s\n", (GLEW_ARB_texture_non_power_of_two)?"yes":"no"); /* Init the demo */ if(!DemoInit(&lConfig)) goto demo_exit; lUpdate.mStartTime = SDL_GetTicks(); /* Event Loop */ while(1) { SDL_Event lEvent; while (SDL_PollEvent(&lEvent)) { switch(lEvent.type) { case SDL_QUIT: { lUpdate.mKeys[SDLK_ESCAPE] = true; } break; case SDL_KEYDOWN: { lUpdate.mKeys[lEvent.key.keysym.sym] = true; } break; case SDL_KEYUP: { lUpdate.mKeys[lEvent.key.keysym.sym] = false; } break; case SDL_MOUSEMOTION: { lUpdate.mMouseX = lEvent.motion.x; lUpdate.mMouseY = lEvent.motion.y; lUpdate.mMouseDeltaX = lEvent.motion.xrel; lUpdate.mMouseDeltaY = lEvent.motion.yrel; } break; } } if(lUpdate.mKeys[SDLK_ESCAPE]) { lUpdate.mKeys[SDLK_ESCAPE] = false; goto demo_exit; } if(lConfig.mCenterCursor) SDL_WarpMouse( lCenterX, lCenterY ); if(!DemoUpdate(&lConfig, &lUpdate)) break; DemoRender(&lConfig, &lUpdate); lUpdate.mLastTime = lUpdate.mTime; lUpdate.mTime = SDL_GetTicks(); lUpdate.mElapsedTime = lUpdate.mTime - lUpdate.mStartTime; lUpdate.mDeltaTime = (lUpdate.mTime - lUpdate.mLastTime); if(lUpdate.mDeltaTime < lConfig.mHz) SDL_Delay( lConfig.mHz - lUpdate.mDeltaTime ); } demo_exit: DemoShutdown(); exit: if(lConfig.mAudio) { Mix_CloseAudio(); } SDL_Quit(); printf("Sayonara ...\n"); return 0; }