Everywhere: Update work in progress
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#include "glm/gtc/type_ptr.hpp" // glm::make_mat4
|
||||
|
||||
#include "inferno/application.h"
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/core.h"
|
||||
@@ -5,12 +7,14 @@
|
||||
#include "inferno/event/event.h"
|
||||
#include "inferno/event/keyevent.h"
|
||||
#include "inferno/event/mouseevent.h"
|
||||
#include "inferno/keycodes.h"
|
||||
#include "inferno/io/gltffile.h"
|
||||
#include "inferno/io/input.h"
|
||||
#include "inferno/io/log.h"
|
||||
#include "inferno/keycodes.h"
|
||||
#include "inferno/render/buffer.h"
|
||||
#include "inferno/render/context.h"
|
||||
#include "inferno/render/font.h"
|
||||
#include "inferno/render/gltf.h"
|
||||
#include "inferno/render/renderer.h"
|
||||
#include "inferno/render/shader.h"
|
||||
#include "inferno/render/texture.h"
|
||||
@@ -18,6 +22,7 @@
|
||||
#include "inferno/settings.h"
|
||||
#include "inferno/time.h"
|
||||
#include "inferno/window.h"
|
||||
#include <string>
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
@@ -47,6 +52,20 @@ namespace Inferno {
|
||||
// Load assets
|
||||
|
||||
m_font = FontManager::the().load("assets/fnt/dejavu-sans");
|
||||
|
||||
// auto bla = GlTFFile::read("assets/gltf/box.glb");
|
||||
// success() << "@" << bla.first.get() << "@";
|
||||
// auto bla2 = GlTFFile::read("assets/gltf/boxtextured.glb");
|
||||
// info() << "@" << bla2.first.get() << "@";
|
||||
// auto bla3 = GlTFFile::read("assets/gltf/guinea-pig-cage-fleece.glb");
|
||||
// warn() << "@" << bla3.first.get() << "@";
|
||||
|
||||
// Gltf model = Gltf("assets/gltf/box.glb");
|
||||
|
||||
// Gltf model = Gltf("assets/gltf/animatedmorphcube.glb");
|
||||
// Gltf model = Gltf("assets/gltf/reciprocatingsaw.glb");
|
||||
|
||||
Gltf model = Gltf("assets/gltf/triangle-without-indices.gltf");
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
@@ -138,7 +157,7 @@ namespace Inferno {
|
||||
RendererCharacter::the().beginScene();
|
||||
|
||||
m_scene->render();
|
||||
RendererCharacter::the().drawCharacter(character, f->texture());
|
||||
// RendererCharacter::the().drawCharacter(character, f->texture());
|
||||
|
||||
Renderer2D::the().endScene();
|
||||
RendererCharacter::the().endScene();
|
||||
@@ -167,6 +186,7 @@ namespace Inferno {
|
||||
(void)e;
|
||||
|
||||
info() << "WindowCloseEvent triggered";
|
||||
infoln("{}Event triggered", e.toString());
|
||||
|
||||
m_window->setShouldClose(true);
|
||||
|
||||
|
||||
+27
-16
@@ -53,37 +53,48 @@ namespace Inferno {
|
||||
#endif // APPLICATION_H
|
||||
|
||||
// C++17 features used:
|
||||
// - std::string:view, log.h
|
||||
// - std::shared_ptr array management, renderer.h
|
||||
// - std::string_view -> log.h
|
||||
// - std::shared_ptr array management -> renderer.h
|
||||
// - EnTT library
|
||||
// - structured binding -> render.cpp, camera.cpp
|
||||
// - std::optional -> textareasystem.cpp
|
||||
|
||||
// OpenGL 4.5 features used:
|
||||
// -
|
||||
|
||||
// Cmake 3.16 features used:
|
||||
// - Precompiled headers
|
||||
|
||||
// Gameplan
|
||||
// v Entrypoint
|
||||
// v Logging
|
||||
// v Events
|
||||
// v Window
|
||||
// v Settings loader (json)
|
||||
// v Input polling
|
||||
// v OpenGL context
|
||||
// - GPUDriver (?)
|
||||
// v Renderer
|
||||
// v Buffers
|
||||
// ~ Shader
|
||||
// - Schene (camera, lights, environment)
|
||||
// - Texture loading
|
||||
// - Model loading
|
||||
// - Entity Component System
|
||||
// - Serialization
|
||||
// - Level format
|
||||
// - Tools (Tiled?)
|
||||
// - Scripting (Lua)
|
||||
|
||||
// - Global object access can be done in 3 ways:
|
||||
// - Singleton, static, extern
|
||||
// - Global object access can be done in 4 ways:
|
||||
// - Singleton, static class, extern, regular global
|
||||
|
||||
// @Todo
|
||||
// - Settings should contain all file paths (ex: shaders)
|
||||
// - RefPtr<>
|
||||
// - Rename Application::get() to Application::the() for singleton
|
||||
// - keycodes.h stringify helper in code.h (util/types.h, util/defines.h)
|
||||
// https://github.com/SerenityOS/serenity/blob/master/Kernel/Assertions.h#L29
|
||||
// - Call delete on pointers that make the singletons, so valgrind will say "All heap blocks were freed -- no leaks are possible", in "HEAP SUMMARY"
|
||||
// - TagComponent, string -> char[]
|
||||
// - Move Gltf parsing and json helper to /parser directory
|
||||
|
||||
// - Initialize primitive types, raw pointers are uninitialized, so need to be explicitly initialized to nullptr
|
||||
// - Run clang-format on every file
|
||||
|
||||
// profiling: 1:33:08 - JS bytecode VM part 7
|
||||
// $ valgrind --tool=callgrind <executable>
|
||||
// $ kcachegrind callgrind.out.<number>
|
||||
|
||||
// GUI
|
||||
// Framebuffer on entire screen, manage every individual pixel
|
||||
// - classes: Window, Button, Label
|
||||
// - event loop: select based
|
||||
|
||||
+65
-13
@@ -3,6 +3,10 @@
|
||||
|
||||
#include <csignal> // raise
|
||||
#include <cstdint> // uint32_t
|
||||
#include <cstdio> // fflush
|
||||
#include <cstring> // strlen
|
||||
#include <fstream> // ifstream
|
||||
#include <string>
|
||||
|
||||
#include "inferno/core.h"
|
||||
#include "inferno/io/log.h"
|
||||
@@ -15,50 +19,98 @@
|
||||
#ifdef NF_ENABLE_ASSERTS
|
||||
// Check if SIGTRAP is available
|
||||
#ifdef SIGTRAP
|
||||
#define ABORT_SIGNAL SIGTRAP
|
||||
#define ABORT_SIGNAL SIGTRAP // POSIX
|
||||
#else
|
||||
#define ABORT_SIGNAL SIGABRT
|
||||
#define ABORT_SIGNAL SIGABRT // C99
|
||||
#endif
|
||||
|
||||
// Non-standard function macro
|
||||
#ifdef GCC
|
||||
#define FUNCTION_MACRO __PRETTY_FUNCTION__
|
||||
#define FUNCTION_MACRO __PRETTY_FUNCTION__ // GCC extension
|
||||
#elif MSVC
|
||||
#define FUNCTION_MACRO __FUNCSIG__
|
||||
#else
|
||||
#define FUNCTION_MACRO __func__
|
||||
#define FUNCTION_MACRO __func__ // C99
|
||||
#endif
|
||||
|
||||
// ##__VA_ARGS__ is a non-standard GCC extension, C++20 introduces __VA_OPT__
|
||||
// https://stackoverflow.com/questions/52891546/what-does-va-args-mean
|
||||
#define ASSERT(expr, ...) static_cast<bool>(expr) ? (void)0 : Inferno::__assert_fail(#expr, __FILE__, __LINE__, FUNCTION_MACRO, ##__VA_ARGS__)
|
||||
#define ASSERT(expr, ...) (static_cast<bool>(expr) ? (void)0 : Inferno::__assert_fail(#expr, __FILE__, __LINE__, FUNCTION_MACRO, ##__VA_ARGS__))
|
||||
#define ASSERT_NOT_REACHED() ASSERT(false)
|
||||
#else
|
||||
#define ASSERT(expr, ...)
|
||||
#define ASSERT(expr, ...) (static_cast<void>(0))
|
||||
#define ASSERT_NOT_REACHED() CRASH()
|
||||
#endif
|
||||
|
||||
#define CRASH() raise(SIGABRT)
|
||||
#define CRASH() Inferno::__crash();
|
||||
// https://stackoverflow.com/questions/1440570/likely-unlikely-equivalent-for-msvc
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
inline void __crash()
|
||||
{
|
||||
asm volatile("int $0x03");
|
||||
}
|
||||
|
||||
// FIXME: Doesnt print to stderr
|
||||
#ifdef NF_ENABLE_ASSERTS
|
||||
template<typename... P>
|
||||
inline void __assert_fail(const char* assertion, const char* file, uint32_t line, const char* function, P&&... parameters)
|
||||
{
|
||||
dangerln(false, "ASSERTION `{}' FAILED.", assertion);
|
||||
(void)function;
|
||||
|
||||
if (sizeof...(P) > 0) {
|
||||
dbg(false) << " ";
|
||||
dbgln(Log::Danger, false, std::forward<P>(parameters)...);
|
||||
// Get the line that caused the error
|
||||
std::ifstream source(file);
|
||||
std::string content;
|
||||
if (source.is_open()) {
|
||||
for (uint32_t i = 0; std::getline(source, content); ++i) {
|
||||
if (i == line - 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Replace tab indentation with spaces
|
||||
size_t tabs = content.find_first_not_of('\t');
|
||||
if (tabs > 0 && tabs < content.size()) {
|
||||
content = std::string(tabs * 4, ' ') + content.substr(tabs);
|
||||
}
|
||||
|
||||
danger() << "\n " << file << ":" << line << " in " << function;
|
||||
// Find the assertion in the line
|
||||
size_t column = content.find_first_of(assertion);
|
||||
size_t assertionLength = strlen(assertion);
|
||||
if (column == std::string::npos) {
|
||||
column = content.find_first_not_of(' ');
|
||||
assertionLength = content.length() - column;
|
||||
}
|
||||
|
||||
raise(ABORT_SIGNAL);
|
||||
// Error message
|
||||
dbgln(false, "\033[0;1m{}:{}:{}: ", file, line, column + 1);
|
||||
dangerln(false, "error: ");
|
||||
dbgln(false, "assertion failed");
|
||||
if (sizeof...(P) > 0) {
|
||||
dbgln(false, ": ");
|
||||
dbgln(Log::None, false, std::forward<P>(parameters)...);
|
||||
}
|
||||
|
||||
// Code line
|
||||
dbgln("\n {} | {}\033[31;1m{}\033[0m{}", line,
|
||||
content.substr(0, column), // Whitespace at front
|
||||
content.substr(column, assertionLength), // Error portion
|
||||
content.substr(column + assertionLength)); // Rest of the line
|
||||
|
||||
// Arrow pointer
|
||||
dbgln(" {} | {}\033[31;1m^{}\033[0m",
|
||||
std::string(std::to_string(line).length(), ' '), // Line number spacing
|
||||
std::string(column, ' '), // Content spacing
|
||||
std::string(assertionLength - 1, '~')); // Arrow pointer
|
||||
|
||||
fflush(stdout); // FIXME: stdout is buffered, strerr is not so wouldnt need this
|
||||
CRASH();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif // ASSERT_H
|
||||
|
||||
// https://github.com/scottt/debugbreak
|
||||
|
||||
+4
-1
@@ -1,10 +1,13 @@
|
||||
#ifndef CORE_H
|
||||
#define CORE_H
|
||||
|
||||
#include <functional> // std::bind
|
||||
#include <functional> // std::bind, std::placeholders
|
||||
|
||||
#define BIT(x) (1 << x)
|
||||
|
||||
// @Todo figure out lambda's and replace std::bind
|
||||
// https://github.com/TheCherno/Hazel/pull/277
|
||||
// variadic args in lambdas were added in C++17
|
||||
#define NF_BIND_EVENT(f) std::bind(&f, this, std::placeholders::_1)
|
||||
|
||||
// Compiler
|
||||
|
||||
+79
-76
@@ -7,105 +7,108 @@
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
enum class EventType {
|
||||
None = 0,
|
||||
enum class EventType {
|
||||
None = 0,
|
||||
|
||||
WindowClose,
|
||||
WindowResize,
|
||||
WindowClose,
|
||||
WindowResize,
|
||||
|
||||
KeyPress,
|
||||
KeyRelease,
|
||||
KeyRepeat,
|
||||
KeyPress,
|
||||
KeyRelease,
|
||||
KeyRepeat,
|
||||
|
||||
MouseButtonPress,
|
||||
MouseButtonRelease,
|
||||
MousePosition,
|
||||
MouseScroll,
|
||||
MouseButtonPress,
|
||||
MouseButtonRelease,
|
||||
MousePosition,
|
||||
MouseScroll,
|
||||
|
||||
JoystickConnected,
|
||||
JoystickDisconnected,
|
||||
};
|
||||
JoystickConnected,
|
||||
JoystickDisconnected,
|
||||
};
|
||||
|
||||
enum EventCategory {
|
||||
None = 0,
|
||||
ApplicationEventCategory = BIT(0),
|
||||
enum EventCategory {
|
||||
None = 0,
|
||||
ApplicationEventCategory = BIT(0),
|
||||
|
||||
InputEventCategory = BIT(1),
|
||||
InputEventCategory = BIT(1),
|
||||
|
||||
KeyEventCategory = BIT(2),
|
||||
KeyEventCategory = BIT(2),
|
||||
|
||||
MouseEventCategory = BIT(3),
|
||||
MouseButtonEventCategory = BIT(4),
|
||||
MouseEventCategory = BIT(3),
|
||||
MouseButtonEventCategory = BIT(4),
|
||||
|
||||
JoystickEventCatergory = BIT(5),
|
||||
};
|
||||
JoystickEventCatergory = BIT(5),
|
||||
};
|
||||
|
||||
class Event {
|
||||
// EventDispatcher is allowed to access Event private/protected members
|
||||
friend class EventDispatcher;
|
||||
class Event {
|
||||
// EventDispatcher is allowed to access Event private/protected members
|
||||
friend class EventDispatcher;
|
||||
|
||||
public:
|
||||
virtual ~Event() {}
|
||||
public:
|
||||
virtual ~Event() {}
|
||||
|
||||
virtual std::string toString() const { return getName(); }
|
||||
virtual std::string toString() const { return getName(); }
|
||||
|
||||
inline bool inCategory(EventCategory category)
|
||||
{
|
||||
return getCategoryFlags() & category;
|
||||
inline bool inCategory(EventCategory category)
|
||||
{
|
||||
return getCategoryFlags() & category;
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
// Getter function templates
|
||||
virtual char getCategoryFlags() const = 0;
|
||||
virtual const char* getName() const = 0;
|
||||
virtual EventType getType() const = 0;
|
||||
|
||||
private:
|
||||
bool handled = false;
|
||||
};
|
||||
|
||||
class EventDispatcher {
|
||||
public:
|
||||
EventDispatcher(Event& e)
|
||||
: m_event(e)
|
||||
{
|
||||
}
|
||||
|
||||
// Easily dispatch all type of Events, call with:
|
||||
// dispatch<T>(std::bind(&F, this, std::placeholders::_1));
|
||||
// T is the type of Event
|
||||
// F is the function to call, signature: bool name(T& e);
|
||||
template<typename T, typename F>
|
||||
bool dispatch(const F& function)
|
||||
{
|
||||
// If <constructed> type is same as member variable type
|
||||
if (T::getTypeStatic() == m_event.getType()) {
|
||||
// Call the function
|
||||
m_event.handled = function(static_cast<T&>(m_event));
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
return false;
|
||||
}
|
||||
|
||||
// Getter function templates
|
||||
virtual char getCategoryFlags() const = 0;
|
||||
virtual const char* getName() const = 0;
|
||||
virtual EventType getType() const = 0;
|
||||
private:
|
||||
Event& m_event;
|
||||
};
|
||||
|
||||
private:
|
||||
bool handled = false;
|
||||
};
|
||||
|
||||
class EventDispatcher {
|
||||
public:
|
||||
EventDispatcher(Event& e) : m_event(e) {}
|
||||
|
||||
// Easily dispatch all type of Events, call with:
|
||||
// dispatch<T>(std::bind(&F, this, std::placeholders::_1));
|
||||
// T is the type of Event
|
||||
// F is the function to call, signature: bool name(T& e);
|
||||
template<typename T, typename F>
|
||||
bool dispatch(const F& function)
|
||||
{
|
||||
// If <constructed> type is same as member variable type
|
||||
if (T::getTypeStatic() == m_event.getType()) {
|
||||
// Call the function
|
||||
m_event.handled = function(static_cast<T& >(m_event));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
Event& m_event;
|
||||
};
|
||||
|
||||
// Add class type functions macro
|
||||
#define EVENT_CLASS_TYPE(type) \
|
||||
virtual const char* getName() const override { return #type; } \
|
||||
// Add class type functions macro
|
||||
#define EVENT_CLASS_TYPE(type) \
|
||||
virtual const char* getName() const override { return #type; } \
|
||||
virtual EventType getType() const override { return getTypeStatic(); } \
|
||||
static inline EventType getTypeStatic() { return EventType::type; }
|
||||
|
||||
// Add class catergory function macro
|
||||
// Add class category function macro
|
||||
#define EVENT_CLASS_CATEGORY(category) \
|
||||
virtual char getCategoryFlags() const override { return category; }
|
||||
|
||||
// Make Events easily printable
|
||||
inline std::ostream& operator<<(std::ostream& os, const Event& e)
|
||||
{
|
||||
return os << e.toString();
|
||||
}
|
||||
|
||||
// Make Events easily printable
|
||||
inline std::ostream& operator<<(std::ostream& os, const Event& e)
|
||||
{
|
||||
return os << e.toString();
|
||||
}
|
||||
|
||||
} // namespace Inferno
|
||||
|
||||
#endif // EVENT_H
|
||||
|
||||
@@ -152,6 +152,7 @@ namespace Inferno {
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
// clang-format off
|
||||
template<typename... P> void dbgln(const char* format, P&&... parameters) { dbgln(Log::None, true, format, std::forward<P>(parameters)...); }
|
||||
template<typename... P> void infoln(const char* format, P&&... parameters) { dbgln(Log::Info, true, format, std::forward<P>(parameters)...); }
|
||||
template<typename... P> void warnln(const char* format, P&&... parameters) { dbgln(Log::Warn, true, format, std::forward<P>(parameters)...); }
|
||||
@@ -193,6 +194,7 @@ namespace Inferno {
|
||||
template<typename... P> void dangerln(bool newline, const std::string_view& format, P&&... parameters) { dbgln(Log::Danger, newline, format.data(), std::forward<P>(parameters)...); }
|
||||
template<typename... P> void successln(bool newline, const std::string_view& format, P&&... parameters) { dbgln(Log::Success, newline, format.data(), std::forward<P>(parameters)...); }
|
||||
template<typename... P> void commentln(bool newline, const std::string_view& format, P&&... parameters) { dbgln(Log::Comment, newline, format.data(), std::forward<P>(parameters)...); }
|
||||
// clang-format on
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
@@ -214,6 +216,7 @@ namespace Inferno {
|
||||
}
|
||||
}
|
||||
}
|
||||
// possible c++17 improvent https://riptutorial.com/cplusplus/example/3208/iterating-over-a-parameter-pack
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
|
||||
@@ -10,6 +10,25 @@
|
||||
#include "inferno/singleton.h"
|
||||
#include "inferno/util/json.h"
|
||||
|
||||
#define GLTF_TYPE_SCALAR 1
|
||||
#define GLTF_TYPE_VEC2 2
|
||||
#define GLTF_TYPE_VEC3 3
|
||||
#define GLTF_TYPE_VEC4 4
|
||||
#define GLTF_TYPE_MAT2 8
|
||||
#define GLTF_TYPE_MAT3 12
|
||||
#define GLTF_TYPE_MAT4 16
|
||||
|
||||
#define GLTF_COMPONENT_TYPE_BYTE 5120
|
||||
#define GLTF_COMPONENT_TYPE_UNSIGNED_BYTE 5121
|
||||
#define GLTF_COMPONENT_TYPE_SHORT 5122
|
||||
#define GLTF_COMPONENT_TYPE_UNSIGNED_SHORT 5123
|
||||
#define GLTF_COMPONENT_TYPE_INT 5124
|
||||
#define GLTF_COMPONENT_TYPE_UNSIGNED_INT 5125
|
||||
#define GLTF_COMPONENT_TYPE_FLOAT 5126
|
||||
|
||||
#define GLTF_TARGET_ARRAY_BUFFER 34962
|
||||
#define GLTF_TARGET_ELEMENT_ARRAY_BUFFER 34963
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
namespace glTF {
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
#include "inferno/component/nativescriptcomponent.h"
|
||||
#include "inferno/component/spritecomponent.h"
|
||||
#include "inferno/component/tagcomponent.h"
|
||||
#include "inferno/component/textareacomponent.h"
|
||||
#include "inferno/scene/scene.h"
|
||||
#include "inferno/script/cameracontroller.h"
|
||||
#include "inferno/script/nativescript.h"
|
||||
#include "inferno/system/camerasystem.h"
|
||||
#include "inferno/system/rendersystem.h"
|
||||
#include "inferno/system/scriptsystem.h"
|
||||
#include "inferno/system/textareasystem.h"
|
||||
#include "inferno/system/transformsystem.h"
|
||||
|
||||
namespace Inferno {
|
||||
@@ -33,6 +35,9 @@ namespace Inferno {
|
||||
ScriptSystem::initialize();
|
||||
ScriptSystem::the().setScene(this);
|
||||
|
||||
TextAreaSystem::initialize();
|
||||
TextAreaSystem::the().setScene(this);
|
||||
|
||||
// Load assets
|
||||
// ---------------------------------
|
||||
|
||||
@@ -44,6 +49,9 @@ namespace Inferno {
|
||||
|
||||
uint32_t camera = createEntity("Camera Entity");
|
||||
auto& cameraTransform = getComponent<TransformComponent>(camera);
|
||||
// cameraTransform.rotate.z = 0.0f;
|
||||
// cameraTransform.translate.z = -1.0f;
|
||||
// addComponent<CameraComponent>(camera, CameraType::Orthographic);
|
||||
cameraTransform.rotate.z = -1.0f;
|
||||
cameraTransform.translate.z = 1.0f;
|
||||
addComponent<CameraComponent>(camera, CameraType::Perspective);
|
||||
@@ -63,6 +71,10 @@ namespace Inferno {
|
||||
quad3Transform.translate.x = 2.2f;
|
||||
addComponent<SpriteComponent>(quad3, glm::vec4 { 1.0f, 1.0f, 1.0f, 1.0f }, m_texture2);
|
||||
|
||||
uint32_t text = createEntity("Text");
|
||||
addComponent<TextAreaComponent>(text, "HelloWorld!", "assets/fnt/dejavu-sans", 0, 150, 3);
|
||||
// addComponent<TextAreaComponent>(text, "@#$%^&*()qygij!", "assets/fnt/dejavu-sans-test", 0, 150, 3);
|
||||
|
||||
info() << "Scene initialized";
|
||||
}
|
||||
|
||||
@@ -77,6 +89,7 @@ namespace Inferno {
|
||||
void Scene::render()
|
||||
{
|
||||
RenderSystem::the().render();
|
||||
TextAreaSystem::the().render();
|
||||
}
|
||||
|
||||
void Scene::destroy()
|
||||
|
||||
@@ -82,3 +82,7 @@ namespace Inferno {
|
||||
}
|
||||
|
||||
#endif // SCENE_H
|
||||
|
||||
// @Todo
|
||||
// - Convert registry to stack variable
|
||||
// - Convert registry to scene pointer in systems
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef CAMERA_CONTROLLER_H
|
||||
#define CAMERA_CONTROLLER_H
|
||||
|
||||
#include "inferno/component/cameracomponent.h"
|
||||
#include "inferno/script/nativescript.h"
|
||||
|
||||
#define TRANSLATE_SPEED 2.5f
|
||||
|
||||
@@ -13,20 +13,20 @@ namespace Inferno {
|
||||
public:
|
||||
static inline void initialize()
|
||||
{
|
||||
ASSERT(!s_instance, "Singleton already exists!");
|
||||
ASSERT(!s_instance, "singleton already exists");
|
||||
s_instance = new T { s {} };
|
||||
}
|
||||
|
||||
static inline void destroy()
|
||||
{
|
||||
ASSERT(s_instance, "Singleton does not exist!");
|
||||
ASSERT(s_instance, "singleton does not exist");
|
||||
delete s_instance;
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
static inline T& the()
|
||||
{
|
||||
ASSERT(s_instance, "Singleton does not exist!");
|
||||
ASSERT(s_instance, "singleton does not exist");
|
||||
return *s_instance;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user