Exemplo n.º 1
0
	void initializeEngine(int argc, char* argv[])
	{
		// timer
		QueryPerformanceFrequency (&uFreq);

		glutInit(&argc,argv);
		glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
		glutInitWindowSize(WIDTH,HEIGHT);
		glutInitContextVersion(2, 1);
		glutCreateWindow("Research Engine");

		initializeGlew();
		initializeDevIL();
	}
Exemplo n.º 2
0
int Game::run() {
  // Initialize
  if (!initializeGlfw()) {
    return 1;
  }
  if (GLEW_OK != initializeGlew()) {
    return 2;
  }
  initializeGl();
  tileManager_->initialize(currentPos_);
  options_ = tileManager_->getOptions();
  ImGui_ImplGlfwGL3_Init(window_, true);

  deltaTime_ = 0.0f; // Time between current and last frame
  lastFrame_ = 0.0f; // Time at last frame
  lastTime_ = 0.0f;  // Time since last fps-"second"
  frameCount_ = 0;

  // Game loop
  while (!glfwWindowShouldClose(window_)) {
    // Calculate deltatime of current frame
    GLfloat currentTime = glfwGetTime();
    deltaTime_ = currentTime - lastFrame_;
    lastFrame_ = currentTime;

    // Check for events
    glfwPollEvents();

    // GUI
    showGui();

    // Move
    do_movement(deltaTime_);

    // Get current camera position
    getCurrentPosition();

    // Clear color- and depth buffer
    glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Update and render tiles
    tileManager_->update(currentPos_);
    tileManager_->renderAll(deltaTime_, camera_.getViewMatrix());

    // Render GUI
    if (!guiClosed_) {
      // ignore wireframe setting for gui
      glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
      ImGui::Render();
      glPolygonMode(GL_FRONT_AND_BACK, fillmode_);
    }

    // Swap the screen buffers
    glfwSwapBuffers(window_);
  }

  // Clean up imgui
  ImGui_ImplGlfwGL3_Shutdown();

  // Clean up tiles
  tileManager_->cleanUp();

  // Terminate GLFW, clearing any resources allocated by GLFW.
  glfwDestroyWindow(window_);
  glfwTerminate();
  return 0;
}
Exemplo n.º 3
0
void Setup::init(){
    initializeGlfw();
    createWindow();
    initializeGlew();
    
}