Esempio n. 1
0
int main(int argc, char *argv[]) {
    std::cout << "Initializing Effect Master 3000..." << std::endl;

    signal(SIGINT, SignalHandler);

    EffectManager *mgr = EffectManager::getInstance();
    Environment *env = mgr->getEnvironment();
    env->loadConfig("effectmaster.conf");

    if (!createWindow("Effect Master 3000", env->getScreenWidth(), env->getScreenHeight(), env->isFullscreen()) ||
            !initOpenGL(env->getScreenWidth(), env->getScreenHeight())) {
        std::cout << "Error creating window!" << std::endl;
        exit(1);
    }

    GLenum err = glewInit();
    if (GLEW_OK != err) {/* Problem: glewInit failed, something is seriously wrong. */
      std::cout << "Error initializing GLEW: " << glewGetErrorString(err)  << std::endl;
      exit(1);
    }

    int fps = env->getFps();
    int msPerFrame = 1000/fps;
    int passedMS = msPerFrame;
    unsigned int frameStart = 0;
    int rest = 0;

    std::cout << "Initialization done!" << std::endl;

    mgr->init();

    while(!done) {
        passedMS = SDL_GetTicks() - frameStart;
        frameStart = SDL_GetTicks();
        mgr->animate(passedMS);
        mgr->draw();
        SDL_GL_SwapBuffers();
        userInput();
        rest = msPerFrame - (SDL_GetTicks() - frameStart);
        if (rest < 0 )
            rest = 0;
        SDL_Delay(rest);
    }

    std::cout << "Shutting down Effect Master 3000..." << std::endl;
    delete env;
    delete mgr;

    return 0;
}
Esempio n. 2
0
EffectManager* EffectManager::create()
{
    EffectManager *pRet = new EffectManager();
    if (pRet!=nullptr)
    {
        pRet->init();
        pRet->autorelease();
        return pRet;
    }
    else
    {
        delete pRet;
        pRet = NULL;
        return NULL;
    }
}