code review changes and fixes
This commit is contained in:
@@ -18,11 +18,13 @@
|
||||
#include "Input/InputManager.hpp"
|
||||
#include "Host/GraphicsAppManager.hpp"
|
||||
#include "Host/GLFW/WindowGLFW.hpp"
|
||||
#include "Host/ResourceLoader.hpp"
|
||||
#include "Math/Math.hpp"
|
||||
#include "Base/EngineConfiguration.hpp"
|
||||
#include "Controller/FreeCamCameraController.hpp"
|
||||
#include "Image/ImageLoaderPng.hpp"
|
||||
#include "Scene/FontAtlasGenerator.hpp"
|
||||
#include <filesystem>
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef TRANSPARENT
|
||||
@@ -33,6 +35,7 @@ namespace OpenVulkano
|
||||
using namespace Scene;
|
||||
using namespace Input;
|
||||
using namespace Math;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class TextExampleAppImpl final : public TextExampleApp
|
||||
{
|
||||
@@ -49,14 +52,26 @@ namespace OpenVulkano
|
||||
m_cam.Init(70, 16, 9, 0.1f, 100);
|
||||
m_scene.SetCamera(&m_cam);
|
||||
|
||||
m_cfg.applyBorder = true;
|
||||
static std::vector<std::pair<std::string, TextConfig>> texts;
|
||||
texts.push_back(std::make_pair("ABab?.^{}_cdFGETG123)(", TextConfig()));
|
||||
texts.push_back(std::make_pair("Hello, World!", TextConfig()));
|
||||
texts[0].second.applyBorder = true;
|
||||
texts[1].second.backgroundColor.a = 1;
|
||||
|
||||
const std::array texts = { "ABab?.^{}_cdFGETG123)(", "Hello, World!" };
|
||||
const int N = texts.size();
|
||||
const std::string font = (OpenVulkano::Utils::GetFontsDirectory() / "Roboto-Regular.ttf").string();
|
||||
m_uniBuffer.Init(sizeof(TextConfig), &m_cfg, 3);
|
||||
std::string fontPath;
|
||||
auto& resourceLoader = ResourceLoader::GetInstance();
|
||||
resourceLoader.GetResource("Roboto-Regular.ttf", fontPath);
|
||||
const std::string atlasPath = (fs::path(fontPath).parent_path() / "roboto-regular-atlas.png").string();
|
||||
|
||||
m_nodesPool.resize(N);
|
||||
m_drawablesPool.resize(N);
|
||||
m_uniBuffers.resize(N);
|
||||
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
m_uniBuffers[i].Init(sizeof(TextConfig), &texts[i].second, 3);
|
||||
}
|
||||
|
||||
m_shader.AddShaderProgram(OpenVulkano::ShaderProgramType::VERTEX, "Shader/text");
|
||||
m_shader.AddShaderProgram(OpenVulkano::ShaderProgramType::FRAGMENT, "Shader/text");
|
||||
@@ -66,16 +81,16 @@ namespace OpenVulkano
|
||||
m_shader.alphaBlend = true;
|
||||
m_shader.cullMode = CullMode::NONE;
|
||||
|
||||
m_atlasGenerator.GenerateAtlas(font, (OpenVulkano::Utils::GetBuildDirectory() / "atlas.png").string());
|
||||
|
||||
m_atlasGenerator.GenerateAtlas(fontPath, atlasPath);
|
||||
|
||||
for (int i = 0; i < texts.size(); i++)
|
||||
{
|
||||
Text* t = new Text();
|
||||
t->SetFontAtlasGenerator(&m_atlasGenerator);
|
||||
t->SetConfig(m_cfg);
|
||||
t->SetUniformBuffer(&m_uniBuffer);
|
||||
t->SetConfig(texts[i].second);
|
||||
t->SetUniformBuffer(&m_uniBuffers[i]);
|
||||
t->SetShader(&m_shader);
|
||||
t->GenerateText(texts[i]);
|
||||
t->GenerateText(texts[i].first);
|
||||
m_drawablesPool[i] = t;
|
||||
m_nodesPool[i].Init();
|
||||
m_nodesPool[i].SetMatrix(
|
||||
@@ -111,10 +126,9 @@ namespace OpenVulkano
|
||||
private:
|
||||
OpenVulkano::Scene::Scene m_scene;
|
||||
PerspectiveCamera m_cam;
|
||||
UniformBuffer m_uniBuffer;
|
||||
std::vector<UniformBuffer> m_uniBuffers;
|
||||
OpenVulkano::FreeCamCameraController m_camController;
|
||||
Shader m_shader;
|
||||
TextConfig m_cfg;
|
||||
FontAtlasGenerator m_atlasGenerator;
|
||||
std::vector<SimpleDrawable*> m_drawablesPool;
|
||||
std::vector<Node> m_nodesPool;
|
||||
|
||||
Reference in New Issue
Block a user