void CrossDelegate::run(int width, int height, int aaSamples, int depthBits)
  {
    initInfo.windowInfo = WindowInfo(width, height, aaSamples, depthBits);

    performInit(); // TODO: HANDLE FAILURES
    performSetup();
    performResize(setupInfo.windowInfo.size);

    sketch->performStart(CrossSketch::START_REASON_VIEW_SHOWN);

    while (!glfwWindowShouldClose(window))
    {
      intern::instance->processMouseEvents();
      intern::instance->processKeyEvents();
      intern::instance->processWheelEvents();

      performUpdate();
      performDraw();

      glfwSwapBuffers(window);

      intern::instance->clearMouseEvents();
      intern::instance->clearKeyEvents();
      intern::instance->clearWheelEvents();
      glfwPollEvents();
    }

    sketch->performStop(CrossSketch::STOP_REASON_VIEW_HIDDEN);

    performShutdown();
    performUninit();
  }
Exemple #2
0
void ATM::run(){
    while(true){
        switch(state_){
            case OFF_STATE:
                std::cout << "Not current available: input \"on\"" << std::endl;
                 /* Hack: waite until turn on switch*/
                for(string command; std::cin >> command && command != "on";);
                    switch_on_ = true;

                if(switch_on_){
                    performStartup();
                    state_ = IDLE_STATE;
                }
                break;
            case IDLE_STATE:
                std::cout << "Please insert your card: input \"insert\"" << std::endl;
                 /* Hack: waite until insert card */
                /* In real code will use sensor and interrupt to detect*/
                for(string command; std::cin >> command && command != "insert";);

                isCardInserted_ = true;

                if(isCardInserted_){
                    /*Start new session and update state*/
                    state_ = SERVING_CUSTOMER_STATE;
                }

                if(!switch_on_){
                    performShutdown();
                    state_ = OFF_STATE;
                }
                break;
            case SERVING_CUSTOMER_STATE:
                /* Create session and perform session!*/
                Session* current_session = new Session(this);
                current_session->performSession();
                state_ = IDLE_STATE;
                break;
        }