Engine: Make it compile again
This commit is contained in:
@@ -7,14 +7,14 @@
|
||||
#include "inferno/event/event.h"
|
||||
#include "inferno/event/keyevent.h"
|
||||
#include "inferno/event/mouseevent.h"
|
||||
#include "inferno/io/gltffile.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/gltf.h"
|
||||
#include "inferno/render/renderer.h"
|
||||
#include "inferno/render/shader.h"
|
||||
#include "inferno/render/texture.h"
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "inferno/settings.h"
|
||||
#include "inferno/time.h"
|
||||
#include "inferno/window.h"
|
||||
#include <string>
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
@@ -65,7 +64,7 @@ namespace Inferno {
|
||||
// Gltf model = Gltf("assets/gltf/animatedmorphcube.glb");
|
||||
// Gltf model = Gltf("assets/gltf/reciprocatingsaw.glb");
|
||||
|
||||
Gltf model = Gltf("assets/gltf/triangle-without-indices.gltf");
|
||||
// Gltf model = Gltf("assets/gltf/triangle-without-indices.gltf");
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if 0
|
||||
#include <algorithm> // std::copy
|
||||
#include <utility> // std::move
|
||||
|
||||
@@ -337,3 +338,4 @@ namespace Inferno {
|
||||
}
|
||||
|
||||
} // namespace Inferno
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef GLTF_H
|
||||
#define GLTF_H
|
||||
|
||||
#if 0
|
||||
#include <cstdint> // uint32_t
|
||||
#include <memory> // std::shared_ptr
|
||||
#include <string> // std::string
|
||||
@@ -166,6 +167,6 @@ namespace Inferno {
|
||||
};
|
||||
|
||||
} // namespace Inferno
|
||||
|
||||
#endif
|
||||
|
||||
#endif // GLTF_H
|
||||
|
||||
+30
-21
@@ -1,10 +1,11 @@
|
||||
#include <cstdint> // uint32_t
|
||||
#include <string> // std::string
|
||||
|
||||
#include "ruc/json/json.h"
|
||||
|
||||
#include "inferno/io/file.h"
|
||||
#include "inferno/io/log.h"
|
||||
#include "inferno/settings.h"
|
||||
#include "inferno/util/json.h"
|
||||
#include "inferno/window.h"
|
||||
|
||||
namespace Inferno {
|
||||
@@ -27,24 +28,22 @@ namespace Inferno {
|
||||
|
||||
bool Settings::load()
|
||||
{
|
||||
json object;
|
||||
ruc::Json object;
|
||||
|
||||
if (!File::ioRead(&object, m_path)) {
|
||||
warn() << "Settings invalid formatting, using default values";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto settings = Json::getPropertyValue<SettingsProperties>(object, json::value_t::object);
|
||||
if (settings) {
|
||||
m_properties = settings.value();
|
||||
}
|
||||
m_properties = object.get<SettingsProperties>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Settings::save()
|
||||
{
|
||||
json object = m_properties;
|
||||
ruc::Json object = m_properties;
|
||||
|
||||
if (!File::ioWrite(&object, m_path)) {
|
||||
warn() << "Settings could not be saved";
|
||||
return false;
|
||||
@@ -54,23 +53,26 @@ namespace Inferno {
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
// -------------------------------------
|
||||
|
||||
void to_json(json& object, const SettingsProperties& settings)
|
||||
void toJson(ruc::Json& object, const SettingsProperties& settings)
|
||||
{
|
||||
object = json {
|
||||
object = ruc::Json {
|
||||
{ "window", settings.window }
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& object, SettingsProperties& settings)
|
||||
void fromJson(const ruc::Json& object, SettingsProperties& settings)
|
||||
{
|
||||
if (Json::hasProperty(object, "window")) object.at("window").get_to(settings.window);
|
||||
VERIFY(object.type() == ruc::Json::Type::Object);
|
||||
|
||||
if (object.exists("window"))
|
||||
object.at("window").getTo(settings.window);
|
||||
}
|
||||
|
||||
void to_json(json& object, const WindowProperties& window)
|
||||
void toJson(ruc::Json& object, const WindowProperties& window)
|
||||
{
|
||||
object = json {
|
||||
object = ruc::Json {
|
||||
{ "title", window.title },
|
||||
{ "width", window.width },
|
||||
{ "height", window.height },
|
||||
@@ -79,13 +81,20 @@ namespace Inferno {
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const json& object, WindowProperties& window)
|
||||
void fromJson(const ruc::Json& object, WindowProperties& window)
|
||||
{
|
||||
if (Json::hasProperty(object, "title")) object.at("title").get_to(window.title);
|
||||
if (Json::hasProperty(object, "width")) object.at("width").get_to(window.width);
|
||||
if (Json::hasProperty(object, "height")) object.at("height").get_to(window.height);
|
||||
if (Json::hasProperty(object, "fullscreen")) object.at("fullscreen").get_to(window.fullscreen);
|
||||
if (Json::hasProperty(object, "vsync")) object.at("vsync").get_to(window.vsync);
|
||||
VERIFY(object.type() == ruc::Json::Type::Object);
|
||||
|
||||
if (object.exists("title"))
|
||||
object.at("title").getTo(window.title);
|
||||
if (object.exists("width"))
|
||||
object.at("width").getTo(window.width);
|
||||
if (object.exists("height"))
|
||||
object.at("height").getTo(window.height);
|
||||
if (object.exists("fullscreen"))
|
||||
object.at("fullscreen").getTo(window.fullscreen);
|
||||
if (object.exists("vsync"))
|
||||
object.at("vsync").getTo(window.vsync);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
#include "inferno/util/json.h"
|
||||
#include "ruc/json/json.h"
|
||||
|
||||
#include "inferno/window.h"
|
||||
|
||||
namespace Inferno {
|
||||
@@ -27,14 +28,14 @@ namespace Inferno {
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
// nlohmann::json arbitrary type conversion functions
|
||||
// Json arbitrary type conversion functions
|
||||
|
||||
void to_json(json& object, const SettingsProperties& settings);
|
||||
void from_json(const json& object, SettingsProperties& settings);
|
||||
void toJson(ruc::Json& object, const SettingsProperties& settings);
|
||||
void fromJson(const ruc::Json& object, SettingsProperties& settings);
|
||||
|
||||
void to_json(json& object, const WindowProperties& window);
|
||||
void from_json(const json& object, WindowProperties& window);
|
||||
void toJson(ruc::Json& object, const WindowProperties& window);
|
||||
void fromJson(const ruc::Json& object, WindowProperties& window);
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef JSON_UTIL_H
|
||||
#define JSON_UTIL_H
|
||||
|
||||
#if 0
|
||||
#include <cstdint> // int32_t, uint32_t
|
||||
#include <optional> // std::optional
|
||||
#include <vector> // std::vector
|
||||
@@ -246,6 +247,7 @@ namespace Inferno {
|
||||
};
|
||||
|
||||
} // namespace Inferno
|
||||
#endif
|
||||
|
||||
#endif // JSON_UTIL_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user