~sircmpwn/xrgears

baefda00b2d8d19eaa1b37acc1d4721dbfdcdea9 — Lubosz Sarnecki 4 years ago 6dac09b
vks: store title member in text overlay renderer. use same string for title and name.
M examples/triangle/triangle.cpp => examples/triangle/triangle.cpp +1 -1
@@ 108,7 108,7 @@ public:

  Triangle(int argc, char *argv[]) : ApplicationVks(argc, argv) {
    zoom = -2.5f;
    title = "Vulkan Example - Basic indexed triangle";
    name = "Triangle";
    // Values not set here are initialized in the base class constructor
  }


M examples/xrgears/xrgears.cpp => examples/xrgears/xrgears.cpp +1 -1
@@ 92,7 92,7 @@ public:
  VkSemaphore offscreenSemaphore = VK_NULL_HANDLE;

  XRGears(int argc, char *argv[]) : ApplicationVks(argc, argv) {
    title = "XR Gears";
    name = "XR Gears";
    camera.type = vik::CameraBase::CameraType::firstperson;
    camera.setRotation(glm::vec3(0.0f, 0.0f, 0.0f));
    camera.setTranslation(glm::vec3(2.2f, 3.2f, -7.6));

M vitamin-k/render/vikRendererTextOverlay.hpp => vitamin-k/render/vikRendererTextOverlay.hpp +13 -9
@@ 1,5 1,7 @@
#pragma once

#include <string>

#include "vikRendererVks.hpp"

namespace vik {


@@ 11,6 13,8 @@ public:

  VkSemaphore text_overlay_complete;

  std::string name;

  RendererTextOverlay(Settings *s, Window *w) : RendererVks(s, w) {}
  ~RendererTextOverlay() {
    vkDestroySemaphore(device, text_overlay_complete, nullptr);


@@ 18,11 22,12 @@ public:
      delete textOverlay;
  }

  void init(const std::string &name, const std::string &title) {
    RendererVks::init(name, title);
  void init(const std::string &n) {
    RendererVks::init(n);
    name = n;
    if (settings->enable_text_overlay) {
      init_text_overlay();
      update_text_overlay(title);
      update_text_overlay();
    }
  }



@@ 57,7 62,7 @@ public:
    return submit_info;
  }

  void update_text_overlay(const std::string& title) {
  void update_text_overlay() {
    if (!settings->enable_text_overlay)
      return;



@@ 69,7 74,7 @@ public:
       << " fps)";
    std::string deviceName(deviceProperties.deviceName);

    textOverlay->update(title, ss.str(), deviceName);
    textOverlay->update(name, ss.str(), deviceName);
  }

  VkSubmitInfo submit_text_overlay() {


@@ 78,11 83,11 @@ public:
    vik_log_check(vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE));
  }

  void check_tick_finnished(const std::string& title) {
  void check_tick_finnished() {
    if (timer.tick_finnished()) {
      timer.update_fps();
      if (settings->enable_text_overlay)
        update_text_overlay(title);
        update_text_overlay();
      timer.reset();
    }
  }


@@ 91,8 96,7 @@ public:
    RendererVks::resize();
    if (settings->enable_text_overlay) {
      textOverlay->reallocateCommandBuffers();
      std::string title = "Foo.";
      update_text_overlay(title);
      update_text_overlay();
    }
  }


M vitamin-k/render/vikRendererVks.hpp => vitamin-k/render/vikRendererVks.hpp +4 -4
@@ 108,11 108,11 @@ public:
    vkDestroyInstance(instance, nullptr);
  }

  void init(const std::string &name, const std::string &title) {
    init_vulkan(title, window->required_extensions());
  void init(const std::string &name) {
    init_vulkan(name, window->required_extensions());
    window->init(width, height);

    window->update_window_title(make_title_string(title));
    window->update_window_title(make_title_string(name));
    window->get_swap_chain()->set_context(instance, physical_device, device);
    window->init_swap_chain(width, height);



@@ 208,7 208,7 @@ public:
    vik_log_check(vkCreatePipelineCache(device, &pipelineCacheCreateInfo, nullptr, &pipelineCache));
  }

  virtual void check_tick_finnished(const std::string& title) {
  virtual void check_tick_finnished() {
    if (timer.tick_finnished()) {
      timer.update_fps();
      timer.reset();

M vitamin-k/system/vikApplicationVks.hpp => vitamin-k/system/vikApplicationVks.hpp +3 -7
@@ 52,8 52,7 @@ public:
  glm::vec3 cameraPos = glm::vec3();
  glm::vec2 mousePos;

  std::string title = "Vulkan Example";
  std::string name = "vulkanExample";
  std::string name = "vitamin-k Example";

  struct {
    bool left = false;


@@ 196,7 195,7 @@ public:
  }

  virtual void init() {
    renderer->init(name, title);
    renderer->init(name);
  }

  void loop() {


@@ 211,7 210,7 @@ public:
      float frame_time = renderer->timer.update_frame_time();
      update_camera(frame_time);
      renderer->timer.update_animation_timer();
      renderer->check_tick_finnished(title);
      renderer->check_tick_finnished();
    }

    renderer->wait_idle();


@@ 226,13 225,10 @@ public:
  void resize() {
    renderer->resize();


    build_command_buffers();

    vkDeviceWaitIdle(renderer->device);



    camera.update_aspect_ratio(renderer->get_aspect_ratio());

    // Notify derived class