|
|
@ -1,4 +1,5 @@ |
|
|
|
#include "glm/gtc/type_ptr.hpp" // glm::make_mat4 |
|
|
|
#include "glm/gtc/type_ptr.hpp" // glm::make_mat4 |
|
|
|
|
|
|
|
#include "ruc/format/log.h" |
|
|
|
#include "ruc/meta/assert.h" |
|
|
|
#include "ruc/meta/assert.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "inferno/application.h" |
|
|
|
#include "inferno/application.h" |
|
|
@ -9,7 +10,6 @@ |
|
|
|
#include "inferno/event/mouseevent.h" |
|
|
|
#include "inferno/event/mouseevent.h" |
|
|
|
// #include "inferno/io/gltffile.h"
|
|
|
|
// #include "inferno/io/gltffile.h"
|
|
|
|
#include "inferno/io/input.h" |
|
|
|
#include "inferno/io/input.h" |
|
|
|
#include "inferno/io/log.h" |
|
|
|
|
|
|
|
#include "inferno/keycodes.h" |
|
|
|
#include "inferno/keycodes.h" |
|
|
|
#include "inferno/render/buffer.h" |
|
|
|
#include "inferno/render/buffer.h" |
|
|
|
#include "inferno/render/context.h" |
|
|
|
#include "inferno/render/context.h" |
|
|
@ -45,11 +45,11 @@ Application::Application(s) |
|
|
|
m_font = FontManager::the().load("assets/fnt/dejavu-sans"); |
|
|
|
m_font = FontManager::the().load("assets/fnt/dejavu-sans"); |
|
|
|
|
|
|
|
|
|
|
|
// auto bla = GlTFFile::read("assets/gltf/box.glb");
|
|
|
|
// auto bla = GlTFFile::read("assets/gltf/box.glb");
|
|
|
|
// success() << "@" << bla.first.get() << "@";
|
|
|
|
// ruc::success("@{}@", bla.first.get());
|
|
|
|
// auto bla2 = GlTFFile::read("assets/gltf/boxtextured.glb");
|
|
|
|
// auto bla2 = GlTFFile::read("assets/gltf/boxtextured.glb");
|
|
|
|
// info() << "@" << bla2.first.get() << "@";
|
|
|
|
// ruc::info("@{}@", bla2.first.get());
|
|
|
|
// auto bla3 = GlTFFile::read("assets/gltf/guinea-pig-cage-fleece.glb");
|
|
|
|
// auto bla3 = GlTFFile::read("assets/gltf/guinea-pig-cage-fleece.glb");
|
|
|
|
// warn() << "@" << bla3.first.get() << "@";
|
|
|
|
// ruc::warn("@{}@", bla3.first.get());
|
|
|
|
|
|
|
|
|
|
|
|
// Gltf model = Gltf("assets/gltf/box.glb");
|
|
|
|
// Gltf model = Gltf("assets/gltf/box.glb");
|
|
|
|
|
|
|
|
|
|
|
@ -76,7 +76,7 @@ Application::~Application() |
|
|
|
|
|
|
|
|
|
|
|
int Application::run() |
|
|
|
int Application::run() |
|
|
|
{ |
|
|
|
{ |
|
|
|
dbg() << "Application startup"; |
|
|
|
ruc::debug("Application startup"); |
|
|
|
|
|
|
|
|
|
|
|
std::array<CharacterVertex, Renderer::vertexPerQuad> character; |
|
|
|
std::array<CharacterVertex, Renderer::vertexPerQuad> character; |
|
|
|
|
|
|
|
|
|
|
@ -87,7 +87,7 @@ int Application::run() |
|
|
|
|
|
|
|
|
|
|
|
auto f = FontManager::the().get("assets/fnt/dejavu-sans"); |
|
|
|
auto f = FontManager::the().get("assets/fnt/dejavu-sans"); |
|
|
|
auto c = f->get('5'); |
|
|
|
auto c = f->get('5'); |
|
|
|
// dbg() << c->position << " " << c->size;
|
|
|
|
// ruc::debug(c->position << " " << c->size);
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t textureWidth = f->texture()->width(); |
|
|
|
uint32_t textureWidth = f->texture()->width(); |
|
|
|
uint32_t textureHeight = f->texture()->height(); |
|
|
|
uint32_t textureHeight = f->texture()->height(); |
|
|
@ -109,7 +109,7 @@ int Application::run() |
|
|
|
(textureHeight - c->position.y - c->size.y) / (float)textureHeight, |
|
|
|
(textureHeight - c->position.y - c->size.y) / (float)textureHeight, |
|
|
|
(textureHeight - c->position.y) / (float)textureHeight |
|
|
|
(textureHeight - c->position.y) / (float)textureHeight |
|
|
|
}; |
|
|
|
}; |
|
|
|
// dbg() < y;
|
|
|
|
// ruc::debug(y);
|
|
|
|
|
|
|
|
|
|
|
|
character.at(0).quad.textureCoordinates = { x.x, y.x }; |
|
|
|
character.at(0).quad.textureCoordinates = { x.x, y.x }; |
|
|
|
character.at(1).quad.textureCoordinates = { x.y, y.x }; |
|
|
|
character.at(1).quad.textureCoordinates = { x.y, y.x }; |
|
|
@ -131,7 +131,7 @@ int Application::run() |
|
|
|
float time = Time::time(); |
|
|
|
float time = Time::time(); |
|
|
|
float deltaTime = time - m_lastFrameTime; |
|
|
|
float deltaTime = time - m_lastFrameTime; |
|
|
|
m_lastFrameTime = time; |
|
|
|
m_lastFrameTime = time; |
|
|
|
// dbg() << "Frametime " << deltaTime * 1000 << "ms";
|
|
|
|
// ruc::debug("Frametime " << deltaTime * 1000 << "ms");
|
|
|
|
|
|
|
|
|
|
|
|
// Update
|
|
|
|
// Update
|
|
|
|
|
|
|
|
|
|
|
@ -156,7 +156,7 @@ int Application::run() |
|
|
|
m_window->render(); |
|
|
|
m_window->render(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dbg() << "Application shutdown"; |
|
|
|
ruc::debug("Application shutdown"); |
|
|
|
|
|
|
|
|
|
|
|
return m_status; |
|
|
|
return m_status; |
|
|
|
} |
|
|
|
} |
|
|
@ -175,8 +175,7 @@ bool Application::onWindowClose(WindowCloseEvent& e) |
|
|
|
// Suppress unused warning
|
|
|
|
// Suppress unused warning
|
|
|
|
(void)e; |
|
|
|
(void)e; |
|
|
|
|
|
|
|
|
|
|
|
info() << "WindowCloseEvent triggered"; |
|
|
|
ruc::info("WindowCloseEvent"); |
|
|
|
infoln("{}Event triggered", e.toString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_window->setShouldClose(true); |
|
|
|
m_window->setShouldClose(true); |
|
|
|
|
|
|
|
|
|
|
@ -188,7 +187,7 @@ bool Application::onWindowResize(WindowResizeEvent& e) |
|
|
|
// Suppress unused warning
|
|
|
|
// Suppress unused warning
|
|
|
|
(void)e; |
|
|
|
(void)e; |
|
|
|
|
|
|
|
|
|
|
|
infoln("WindowResizeEvent {}x{} triggered", e.getWidth(), e.getHeight()); |
|
|
|
ruc::info("WindowResizeEvent {}x{}", e.getWidth(), e.getHeight()); |
|
|
|
|
|
|
|
|
|
|
|
RenderCommand::setViewport(0, 0, e.getWidth(), e.getHeight()); |
|
|
|
RenderCommand::setViewport(0, 0, e.getWidth(), e.getHeight()); |
|
|
|
|
|
|
|
|
|
|
@ -200,9 +199,7 @@ bool Application::onKeyPress(KeyPressEvent& e) |
|
|
|
// Suppress unused warning
|
|
|
|
// Suppress unused warning
|
|
|
|
(void)e; |
|
|
|
(void)e; |
|
|
|
|
|
|
|
|
|
|
|
infoln("KeyPressEvent {} ({}) triggered", |
|
|
|
ruc::info("KeyPressEvent {} ({})", Input::getKeyName(e.getKey()), e.getKey()); |
|
|
|
Input::getKeyName(e.getKey()), |
|
|
|
|
|
|
|
e.getKey()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Stop the main loop on 'Escape' keypress
|
|
|
|
// Stop the main loop on 'Escape' keypress
|
|
|
|
if (e.getKey() == keyCode("GLFW_KEY_ESCAPE")) { |
|
|
|
if (e.getKey() == keyCode("GLFW_KEY_ESCAPE")) { |
|
|
@ -214,6 +211,8 @@ bool Application::onKeyPress(KeyPressEvent& e) |
|
|
|
|
|
|
|
|
|
|
|
bool Application::onMousePosition(MousePositionEvent& e) |
|
|
|
bool Application::onMousePosition(MousePositionEvent& e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// ruc::info("MousePositionEvent {:.0}x{:.0}", e.getXPos(), e.getYPos());
|
|
|
|
|
|
|
|
|
|
|
|
return Input::onMousePosition(e); |
|
|
|
return Input::onMousePosition(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|