MainGame::MainGame() { ConfigurationManager configManager(resourcePath() + "configuration.txt"); //if SDL fails, close program if (SDL_Init(SDL_INIT_VIDEO)) throw std::logic_error("Failed to initialize SDL! " + std::string(SDL_GetError())); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); if (configManager.GetItem<bool>("Multisampling")) { SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, configManager.GetItem<int>("MultisampleBuffers")); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, configManager.GetItem<int>("MultisampleSamples")); } SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); SDL_DisplayMode mode; SDL_GetCurrentDisplayMode(0, &mode); Uint32 windowFlags = SDL_WINDOW_OPENGL; size_t width = configManager.GetItem<float>("WindowWidth"), height = configManager.GetItem<float>("WindowHeight"); if (configManager.GetItem<bool>("Fullscreen")) { // width = mode.w; height = mode.h; windowFlags|=SDL_WINDOW_FULLSCREEN_DESKTOP; } window = SDL_CreateWindow("Genetic Algorithm", 0, 0, width, height, windowFlags); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetSwapInterval(1); SDL_SetRelativeMouseMode(SDL_TRUE); if (window==nullptr) throw std::logic_error("Window failed to be initialized"); SDL_GLContext context = SDL_GL_CreateContext(window); if (context==nullptr) throw std::logic_error("SDL_GL could not be initialized!"); int cpuCount = SDL_GetCPUCount(); GLManager glManager(resourcePath() + "fragmentShader.glsl", resourcePath() + "vertexShader.glsl", configManager); std::string fileLoc =resourcePath() + "performance.csv"; EvolutionSystem evolutionSystem(fileLoc, configManager, cpuCount); Camera camera(configManager.GetItem<float>("WindowWidth"), configManager.GetItem<float>("WindowHeight"), configManager); while (GameState!=GameState::EXIT) { Update(evolutionSystem); camera.Update(); glManager.Programs[0].SetMatrix4("transformMatrix", glm::value_ptr(camera.GetTransformMatrix())); Draw(evolutionSystem); SDL_GL_SwapWindow(window); HandleEvents(evolutionSystem,camera); } }
int main(int argc, char* argv[]) { // Setup and initialise the Logger Logger& logger(Logger::instance()); //logger.setFile(".html", Logger::LOG_FILE_HTML); //logger.setOutput(Logger::LOG_OUTPUT_FILE_AND_TERMINAL); logger.setOutput(Logger::LOG_OUTPUT_SILENT); //logger.setType(Logger::LOG_TYPE_INFO); // Check the Config Manager and get it to parse the configuration files. ConfigManager& configManager(ConfigManager::instance()); configManager.loadConfig(); // Start up the Graphics System. GraphicsSystem& graphicsSystem(GraphicsSystem::instance()); graphicsSystem.initialise(640U, 480U, 32U); // Start and setup the Entity System with some lists. EntitySystem& entitySystem(EntitySystem::instance()); entitySystem.createList("Player"); entitySystem.createList("Enemy"); entitySystem.createList("Renderable"); entitySystem.createList("Movable"); entitySystem.createList("Collidable"); entitySystem.createList("Grapple"); entitySystem.createList("Ship"); // Start up the State Manager, and feed it the Main States. StateManager& stateManager(StateManager::instance()); stateManager.add<MenuState>("MenuState"); stateManager.add<GameState>("GameState"); stateManager.launch("GameState"); // Tick over the State Manager while we have any States. Timer mainTimer; while (true == stateManager.hasStates()) { stateManager.update(mainTimer.processDelta()); } // Cleanup configManager.saveConfig(); // Goodbye World return 0; }
// // Get Http authentication handler // Authenticator* AuthenticationManager::_getHttpAuthHandler() { PEG_METHOD_ENTER( TRC_AUTHENTICATION, "AuthenticationManager::_getHttpAuthHandler()"); AutoPtr<Authenticator> handler; // // get the configured authentication type // AutoPtr<ConfigManager> configManager(ConfigManager::getInstance()); _httpAuthType = configManager->getCurrentValue("httpAuthType"); configManager.release(); // // create a authentication handler. // if ( String::equal(_httpAuthType, "Basic") ) { handler.reset((Authenticator* ) new BasicAuthenticationHandler( )); } #ifdef PEGASUS_NEGOTIATE_AUTHENTICATION if ( String::equal(_httpAuthType, "Negotiate") ) { handler.reset((Authenticator* ) new NegotiateAuthenticationHandler( )); } #endif // FUTURE: uncomment these line when Digest authentication // is implemented. // //else if (String::equal(_httpAuthType, "Digest")) //{ // handler = (Authenticator* ) new DigestAuthenticationHandler( ); //} else { // // This should never happen. Gets here only if Security Config // property owner has not validated the configured http auth type. // PEGASUS_UNREACHABLE(PEGASUS_ASSERT(0);) } PEG_METHOD_EXIT(); return handler.release(); }
// // Get Http authentication handler // Authenticator* AuthenticationManager::_getHttpAuthHandler() { PEG_METHOD_ENTER( TRC_AUTHENTICATION, "AuthenticationManager::_getHttpAuthHandler()"); AutoPtr<Authenticator> handler; // // get the configured authentication type // AutoPtr<ConfigManager> configManager(ConfigManager::getInstance()); _httpAuthType = configManager->getCurrentValue("httpAuthType"); configManager.release(); // // create a authentication handler. // if ( String::equal(_httpAuthType, "Basic") ) { handler.reset((Authenticator* ) new BasicAuthenticationHandler( )); } #ifdef PEGASUS_KERBEROS_AUTHENTICATION else if ( String::equal(_httpAuthType, "Kerberos") ) { handler.reset((Authenticator*) new KerberosAuthenticationHandler()); AutoPtr<KerberosAuthenticationHandler> kerberosHandler( (KerberosAuthenticationHandler *)handler.get()); int itFailed = kerberosHandler->initialize(); kerberosHandler.release(); if (itFailed) { if (handler.get()) { handler.reset(0); } MessageLoaderParms parms( "Security.Authentication.AuthenticationManager." "AUTHENTICATION_HANDLER_KERBEROS_FAILED_TO_INITIALIZE", "CIMOM server authentication handler for Kerberos failed to " "initialize properly."); Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, parms); throw Exception(parms); } } #endif // FUTURE: uncomment these line when Digest authentication // is implemented. // //else if (String::equal(_httpAuthType, "Digest")) //{ // handler = (Authenticator* ) new DigestAuthenticationHandler( ); //} else { // // This should never happen. Gets here only if Security Config // property owner has not validated the configured http auth type. // PEGASUS_UNREACHABLE(PEGASUS_ASSERT(0);) } PEG_METHOD_EXIT(); return handler.release(); }