Exemplo n.º 1
0
int main()
{
    int frameCnt = 0;
    struct timeval curTime;
    float dSecond = 0;
    float dSecondSum = 0; /* droped if more than 0.5 sec */

    timeval_diff_replace(&curTime);

    flags.pause = GL_FALSE;
    flags.vsync = GL_TRUE;

    scene = newScene(flags.vsync);

    setupGLFWCallbacks();
    glfwSetMousePos(scene->context->w / 2, scene->context->h / 2);

    while (running)
    {
        if (glfwGetWindowParam(GLFW_OPENED) == GL_FALSE)
        {
            running = GL_FALSE;
            break;
        }

        processKeyboardEvents(dSecond * BASE_FPS);
        processMouseEvents(dSecond * BASE_FPS);

        ++frameCnt;
        dSecond = timeval_diff_replace(&curTime);
        dSecondSum += dSecond;

        if (dSecondSum > 0.5f)
        {
            viewFps(frameCnt, dSecondSum);
            frameCnt = 0;
            dSecondSum = 0.0f;
        }

        if (!flags.pause)
        {
            modifyWaterMesh(scene->water, dSecond);
        }

        draw();
        glfwSwapBuffers();
    }

    freeScene(scene);

    return EXIT_SUCCESS;
}
Exemplo n.º 2
0
void Camera::update(float frameInt)
{
  Tuple3f temp = focus;
  temp -= position;
  
  strafe.crossProduct(temp, up);
  strafe.normalize();
  
  speed = frameInt*translationSpeed;
  
  setViewByMouse();
  processKeyboardEvents();
  
  viewMatrix.lookAt(position, focus, up);
  look();
}
Exemplo n.º 3
0
void HelmStandaloneEditor::getNextAudioBlock(const AudioSourceChannelInfo& buffer) {
  ScopedLock lock(getCriticalSection());

  int num_samples = buffer.buffer->getNumSamples();
  int synth_samples = std::min(num_samples, MAX_BUFFER_PROCESS);

  processControlChanges();
  processModulationChanges();
  MidiBuffer midi_messages;
  midi_manager_->removeNextBlockOfMessages(midi_messages, num_samples);
  processMidi(midi_messages);
  processKeyboardEvents(midi_messages, num_samples);

  for (int b = 0; b < num_samples; b += synth_samples) {
    int current_samples = std::min<int>(synth_samples, num_samples - b);

    processAudio(buffer.buffer, mopo::NUM_CHANNELS, current_samples, b);
  }
}