Engine: Switch to ASSERT macro to ruc's VERIFY
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#include "inferno/core.h"
|
||||
|
||||
#include "inferno/application.h"
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/io/log.h"
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "glm/gtc/type_ptr.hpp" // glm::make_mat4
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/application.h"
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/core.h"
|
||||
#include "inferno/event/applicationevent.h"
|
||||
#include "inferno/event/event.h"
|
||||
@@ -91,7 +91,7 @@ namespace Inferno {
|
||||
|
||||
uint32_t textureWidth = f->texture()->width();
|
||||
uint32_t textureHeight = f->texture()->height();
|
||||
ASSERT(textureWidth == textureHeight, "Invalid font texture!");
|
||||
VERIFY(textureWidth == textureHeight, "Invalid font texture!");
|
||||
|
||||
float quadWidth = (c->size.x / (float)textureWidth) - 0.04; // @Todo something wrong with the width
|
||||
float quadHeight = c->size.y / (float)textureHeight;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/script/nativescript.h"
|
||||
|
||||
namespace Inferno {
|
||||
@@ -16,12 +17,12 @@ namespace Inferno {
|
||||
template<typename T>
|
||||
void bind()
|
||||
{
|
||||
ASSERT(instance == nullptr, "NativeScript already bound");
|
||||
VERIFY(instance == nullptr, "NativeScript already bound");
|
||||
initialize = []() { return static_cast<NativeScript*>(new T()); };
|
||||
}
|
||||
|
||||
void destroy() {
|
||||
ASSERT(instance, "Attempting to destroy an uninitialized NativeScript");
|
||||
VERIFY(instance, "Attempting to destroy an uninitialized NativeScript");
|
||||
delete instance;
|
||||
instance = nullptr;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <ios> // std::ios
|
||||
#include <memory> // std::make_unique
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/io/file.h"
|
||||
|
||||
namespace Inferno {
|
||||
@@ -10,7 +11,7 @@ namespace Inferno {
|
||||
{
|
||||
// Create input stream object and open file
|
||||
std::ifstream file(path);
|
||||
ASSERT(file.is_open(), "File could not open '{}'", path);
|
||||
VERIFY(file.is_open(), "File could not open '{}'", path);
|
||||
|
||||
// Get length of the file
|
||||
int32_t length = File::length(path, file);
|
||||
@@ -39,9 +40,9 @@ namespace Inferno {
|
||||
file.seekg(0, std::ios::end);
|
||||
int32_t length = file.tellg();
|
||||
file.seekg(0, std::ios::beg);
|
||||
ASSERT(length != -1, "File could not determine length '{}'", path);
|
||||
VERIFY(length != -1, "File could not determine length '{}'", path);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#include <memory> // std::shared_ptr
|
||||
#include <string> // std::string
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/core.h"
|
||||
#include "inferno/io/log.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Inferno {
|
||||
static bool ioRead(T* t, const std::string& path)
|
||||
{
|
||||
std::ifstream file(path);
|
||||
ASSERT(file.is_open(), "File could not open '{}'", path);
|
||||
VERIFY(file.is_open(), "File could not open '{}'", path);
|
||||
|
||||
if (!file.is_open()) {
|
||||
return false;
|
||||
@@ -41,7 +41,7 @@ namespace Inferno {
|
||||
static bool ioWrite(T* t, const std::string& path)
|
||||
{
|
||||
std::ofstream file (path);
|
||||
ASSERT(file.is_open(), "File could not open! {}", path);
|
||||
VERIFY(file.is_open(), "File could not open! {}", path);
|
||||
|
||||
if (!file.is_open()) {
|
||||
return false;
|
||||
|
||||
+11
-10
@@ -2,12 +2,13 @@
|
||||
#include <fstream> // std::ifstream
|
||||
#include <ios> // std::ios
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/io/file.h"
|
||||
#include "inferno/io/gltffile.h"
|
||||
#include "inferno/io/log.h"
|
||||
#include "inferno/util/string.h"
|
||||
#include "inferno/util/json.h"
|
||||
#include "inferno/util/string.h"
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
@@ -22,7 +23,7 @@ namespace Inferno {
|
||||
return { File::raw(path), nullptr };
|
||||
}
|
||||
|
||||
ASSERT(false, "GltfFile unknown file extension!");
|
||||
VERIFY(false, "GltfFile unknown file extension!");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -30,7 +31,7 @@ namespace Inferno {
|
||||
{
|
||||
// Create input stream object and open file
|
||||
std::ifstream glb(path, std::ios::in | std::ios::binary);
|
||||
ASSERT(glb.is_open(), "GltfFile could not open '{}'", path);
|
||||
VERIFY(glb.is_open(), "GltfFile could not open '{}'", path);
|
||||
|
||||
constexpr uint32_t size = 4;
|
||||
constexpr uint32_t header = 12;
|
||||
@@ -38,7 +39,7 @@ namespace Inferno {
|
||||
|
||||
// Get the actual length of the file
|
||||
uint32_t length = static_cast<uint32_t>(File::length(path, glb));
|
||||
ASSERT(length > header + json, "GltfFile too small to be valid '{}'", path);
|
||||
VERIFY(length > header + json, "GltfFile too small to be valid '{}'", path);
|
||||
|
||||
// Read header
|
||||
|
||||
@@ -55,17 +56,17 @@ namespace Inferno {
|
||||
// Validate header
|
||||
|
||||
uint32_t magicInt = *reinterpret_cast<uint32_t*>(magic);
|
||||
ASSERT(magicInt == 0x46546c67, "Gltf invalid header magic '{}'", magic);
|
||||
VERIFY(magicInt == 0x46546c67, "Gltf invalid header magic '{}'", magic);
|
||||
|
||||
uint32_t versionInt = *reinterpret_cast<uint32_t*>(version);
|
||||
ASSERT(versionInt == 2, "Gltf unsupported version '{}'", versionInt);
|
||||
VERIFY(versionInt == 2, "Gltf unsupported version '{}'", versionInt);
|
||||
|
||||
uint32_t fileLengthInt = *reinterpret_cast<uint32_t*>(fileLength);
|
||||
ASSERT(fileLengthInt == length, "Gltf file and reported byte size mismatch '{}' '{}'", length, fileLengthInt);
|
||||
VERIFY(fileLengthInt == length, "Gltf file and reported byte size mismatch '{}' '{}'", length, fileLengthInt);
|
||||
|
||||
// Read JSON data
|
||||
auto jsonChunk = readChunk(glb, header, 0x4e4f534a);
|
||||
ASSERT(jsonChunk.second >= json, "Gltf file invalid JSON content length '{}'", jsonChunk.second);
|
||||
VERIFY(jsonChunk.second >= json, "Gltf file invalid JSON content length '{}'", jsonChunk.second);
|
||||
|
||||
// Read binary data
|
||||
auto binaryChunk = readChunk(glb, header + size * 2 + jsonChunk.second, 0x004e4942);
|
||||
@@ -88,7 +89,7 @@ namespace Inferno {
|
||||
ifstream.read(chunkType, size);
|
||||
|
||||
uint32_t chunkTypeInt = *reinterpret_cast<uint32_t*>(chunkType);
|
||||
ASSERT(chunkTypeInt == type, "Gltf invalid chunk type '{}' != '{}'", chunkType, intToHex(type));
|
||||
VERIFY(chunkTypeInt == type, "Gltf invalid chunk type '{}' != '{}'", chunkType, intToHex(type));
|
||||
|
||||
uint32_t chunkLengthInt = *reinterpret_cast<uint32_t*>(chunkLength);
|
||||
// Allocate memory filled with zeros
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/io/log.h"
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <cstdio> // fwrite, snprintf
|
||||
#include <cstdlib> // malloc, free
|
||||
@@ -8,6 +5,10 @@
|
||||
#include <string> // std::string
|
||||
#include <string_view> // std::string_view
|
||||
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/io/log.h"
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
BufferedLogStream::~BufferedLogStream()
|
||||
@@ -231,7 +232,7 @@ namespace Inferno {
|
||||
case Log::Comment:
|
||||
return stream << "Comment";
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
@@ -317,4 +318,4 @@ namespace Inferno {
|
||||
return StringLogStream(fill);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <unordered_map> // std::unordered_map
|
||||
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/keycodes.h"
|
||||
|
||||
namespace Inferno {
|
||||
@@ -136,8 +136,8 @@ namespace Inferno {
|
||||
|
||||
int keyCode(const char* name)
|
||||
{
|
||||
ASSERT(keys.find(name) != keys.end(), "keyCode could not find '{}'", name);
|
||||
VERIFY(keys.find(name) != keys.end(), "keyCode could not find '{}'", name);
|
||||
return keys.at(name);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "glad/glad.h"
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
#include "inferno/core.h"
|
||||
#include "inferno/io/log.h"
|
||||
#include "inferno/render/buffer.h"
|
||||
@@ -64,7 +64,7 @@ namespace Inferno {
|
||||
case BufferElementType::DoubleMat4: return sizeof(double) * 4 * 4;
|
||||
};
|
||||
|
||||
ASSERT(false, "BufferElement unknown BufferElementType size!");
|
||||
VERIFY(false, "BufferElement unknown BufferElementType size!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Inferno {
|
||||
case BufferElementType::DoubleMat4: return 4 * 4;
|
||||
};
|
||||
|
||||
ASSERT(false, "BufferElement unknown BufferElementType count!");
|
||||
VERIFY(false, "BufferElement unknown BufferElementType count!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Inferno {
|
||||
case BufferElementType::DoubleMat4: return GL_DOUBLE;
|
||||
};
|
||||
|
||||
ASSERT(false, "BufferElement unknown BufferElementType GL!");
|
||||
VERIFY(false, "BufferElement unknown BufferElementType GL!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace Inferno {
|
||||
void VertexArray::addVertexBuffer(std::shared_ptr<VertexBuffer> vertexBuffer)
|
||||
{
|
||||
const auto& layout = vertexBuffer->getLayout();
|
||||
ASSERT(layout.getElements().size(), "VertexBuffer has no layout");
|
||||
VERIFY(layout.getElements().size(), "VertexBuffer has no layout");
|
||||
|
||||
bind();
|
||||
vertexBuffer->bind();
|
||||
@@ -295,4 +295,4 @@ namespace Inferno {
|
||||
indexBuffer->unbind();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "glad/glad.h"
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/core.h"
|
||||
#include "inferno/io/log.h"
|
||||
#include "inferno/render/context.h"
|
||||
@@ -12,7 +12,7 @@ namespace Inferno {
|
||||
Context::Context(GLFWwindow* window) :
|
||||
m_window(window)
|
||||
{
|
||||
ASSERT(window, "Context window is nullptr!");
|
||||
VERIFY(window, "Context window is nullptr!");
|
||||
}
|
||||
|
||||
void Context::initialize()
|
||||
@@ -21,7 +21,7 @@ namespace Inferno {
|
||||
|
||||
// Initialize glad
|
||||
int glad = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
|
||||
ASSERT(glad, "Failed to initialize glad!");
|
||||
VERIFY(glad, "Failed to initialize glad!");
|
||||
|
||||
// Log OpenGL properties
|
||||
comment() << "OpenGL Info:";
|
||||
@@ -30,7 +30,7 @@ namespace Inferno {
|
||||
comment() << " Version: " << glGetString(GL_VERSION);
|
||||
|
||||
// Check OpenGL version
|
||||
ASSERT(GLVersion.major > 4 || (GLVersion.major == 4 && GLVersion.minor >= 5),
|
||||
VERIFY(GLVersion.major > 4 || (GLVersion.major == 4 && GLVersion.minor >= 5),
|
||||
"Inferno requires at least OpenGL version 4.5!");
|
||||
}
|
||||
|
||||
@@ -49,4 +49,4 @@ namespace Inferno {
|
||||
glfwMakeContextCurrent(m_window);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#include <string> // std::getline, std::stoi
|
||||
#include <utility> // std::move
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/io/file.h"
|
||||
#include "inferno/render/font.h"
|
||||
#include "inferno/render/texture.h"
|
||||
@@ -82,7 +83,7 @@ namespace Inferno {
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(!elements.empty(), "Font file did not find any columns");
|
||||
VERIFY(!elements.empty(), "Font file did not find any columns");
|
||||
return elements;
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ namespace Inferno {
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(false, "Font file did not contain key '{}'", key);
|
||||
VERIFY(false, "Font file did not contain key '{}'", key);
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -160,4 +161,4 @@ namespace Inferno {
|
||||
return stream << "{ " << value.x << ", " << value.y << " }";
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
+34
-34
@@ -3,8 +3,8 @@
|
||||
#include <utility> // std::move
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/io/file.h"
|
||||
#include "inferno/io/gltffile.h"
|
||||
#include "inferno/io/log.h"
|
||||
@@ -17,7 +17,7 @@ namespace Inferno {
|
||||
: m_path(std::move(path))
|
||||
{
|
||||
auto gltf = GltfFile::read(path);
|
||||
ASSERT(gltf.first, "Gltf model invalid JSON content '{}'", path);
|
||||
VERIFY(gltf.first, "Gltf model invalid JSON content '{}'", path);
|
||||
|
||||
json json = json::parse(gltf.first.get());
|
||||
|
||||
@@ -31,9 +31,9 @@ namespace Inferno {
|
||||
// Asset
|
||||
// ---------------------------------
|
||||
|
||||
ASSERT(Json::hasProperty(json, "asset"), "GlTF model missing required property 'asset'");
|
||||
VERIFY(Json::hasProperty(json, "asset"), "GlTF model missing required property 'asset'");
|
||||
auto asset = json["asset"];
|
||||
ASSERT(asset.is_object(), "Gltf model invalid property type 'asset'");
|
||||
VERIFY(asset.is_object(), "Gltf model invalid property type 'asset'");
|
||||
|
||||
parseAsset(&m_model.asset, asset);
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Inferno {
|
||||
if (Json::hasProperty(json, "scenes")) {
|
||||
|
||||
auto scenes = json["scenes"];
|
||||
ASSERT(scenes.is_array(), "Gltf model invalid property type 'scenes'");
|
||||
VERIFY(scenes.is_array(), "Gltf model invalid property type 'scenes'");
|
||||
|
||||
for (auto& [key, object] : scenes.items()) {
|
||||
glTF::Scene scene;
|
||||
@@ -58,7 +58,7 @@ namespace Inferno {
|
||||
if (Json::hasProperty(json, "nodes")) {
|
||||
|
||||
auto nodes = json["nodes"];
|
||||
ASSERT(nodes.is_array(), "Gltf model invalid property type 'nodes'");
|
||||
VERIFY(nodes.is_array(), "Gltf model invalid property type 'nodes'");
|
||||
|
||||
for (auto& [key, object] : nodes.items()) {
|
||||
glTF::Node node;
|
||||
@@ -73,7 +73,7 @@ namespace Inferno {
|
||||
if (Json::hasProperty(json, "meshes")) {
|
||||
|
||||
auto meshes = json["meshes"];
|
||||
ASSERT(meshes.is_array(), "Gltf model invalid property type 'meshes'");
|
||||
VERIFY(meshes.is_array(), "Gltf model invalid property type 'meshes'");
|
||||
|
||||
for (auto& [key, object] : meshes.items()) {
|
||||
glTF::Mesh mesh;
|
||||
@@ -88,7 +88,7 @@ namespace Inferno {
|
||||
if (Json::hasProperty(json, "accessors")) {
|
||||
|
||||
auto accessors = json["accessors"];
|
||||
ASSERT(accessors.is_array(), "Gltf model invalid property type 'accessors'");
|
||||
VERIFY(accessors.is_array(), "Gltf model invalid property type 'accessors'");
|
||||
|
||||
for (auto& [key, object] : accessors.items()) {
|
||||
glTF::Accessor accessor;
|
||||
@@ -103,7 +103,7 @@ namespace Inferno {
|
||||
if (Json::hasProperty(json, "bufferViews")) {
|
||||
|
||||
auto bufferViews = json["bufferViews"];
|
||||
ASSERT(bufferViews.is_array(), "Gltf model invalid property type 'bufferViews'");
|
||||
VERIFY(bufferViews.is_array(), "Gltf model invalid property type 'bufferViews'");
|
||||
|
||||
for (auto& [key, object] : bufferViews.items()) {
|
||||
glTF::BufferView bufferView;
|
||||
@@ -118,7 +118,7 @@ namespace Inferno {
|
||||
if (Json::hasProperty(json, "buffers")) {
|
||||
|
||||
auto buffers = json["buffers"];
|
||||
ASSERT(buffers.is_array(), "Gltf model invalid property type 'buffers'");
|
||||
VERIFY(buffers.is_array(), "Gltf model invalid property type 'buffers'");
|
||||
|
||||
for (auto& [key, object] : buffers.items()) {
|
||||
glTF::Buffer buffer;
|
||||
@@ -140,8 +140,8 @@ namespace Inferno {
|
||||
auto generator = Json::parseStringProperty(object, "generator", false);
|
||||
|
||||
auto version = Json::parseStringProperty(object, "version", true);
|
||||
ASSERT(version, "GlTF model missing required property 'version'");
|
||||
ASSERT(version.value().compare("2.0") == 0, "GlTF version unsupported '{}'", version.value());
|
||||
VERIFY(version, "GlTF model missing required property 'version'");
|
||||
VERIFY(version.value().compare("2.0") == 0, "GlTF version unsupported '{}'", version.value());
|
||||
|
||||
auto minVersion = Json::parseStringProperty(object, "minVersion", false);
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace Inferno {
|
||||
void Gltf::parseScene(glTF::Scene* scene, const std::string& key, const json& object)
|
||||
{
|
||||
auto nodes = Json::parseFloatArrayProperty(object, "nodes", false);
|
||||
ASSERT(!nodes || nodes.value().size() > 0, "Gltf scene '{}' empty 'nodes' property", key);
|
||||
VERIFY(!nodes || nodes.value().size() > 0, "Gltf scene '{}' empty 'nodes' property", key);
|
||||
|
||||
auto name = Json::parseStringProperty(object, "name", false);
|
||||
|
||||
@@ -166,26 +166,26 @@ namespace Inferno {
|
||||
auto camera = Json::parseUnsignedProperty(object, "camera", false);
|
||||
|
||||
auto children = Json::parseUnsignedArrayProperty(object, "children", false);
|
||||
ASSERT(!children || children.value().size() > 0, "Gltf node '{}' empty property 'children'", key);
|
||||
VERIFY(!children || children.value().size() > 0, "Gltf node '{}' empty property 'children'", key);
|
||||
|
||||
auto skin = Json::parseUnsignedProperty(object, "skin", false);
|
||||
|
||||
auto matrix = Json::parseFloatArrayProperty(object, "matrix", false);
|
||||
ASSERT(!matrix || matrix.value().size() == 16, "Gltf node '{}' property 'matrix' invalid size", key);
|
||||
VERIFY(!matrix || matrix.value().size() == 16, "Gltf node '{}' property 'matrix' invalid size", key);
|
||||
|
||||
auto mesh = Json::parseUnsignedProperty(object, "mesh", false);
|
||||
|
||||
auto rotation = Json::parseFloatArrayProperty(object, "rotation", false);
|
||||
ASSERT(!rotation || rotation.value().size() == 4, "Gltf node '{}' property 'rotation' invalid size", key);
|
||||
VERIFY(!rotation || rotation.value().size() == 4, "Gltf node '{}' property 'rotation' invalid size", key);
|
||||
|
||||
auto scale = Json::parseFloatArrayProperty(object, "scale", false);
|
||||
ASSERT(!scale || scale.value().size() == 3, "Gltf node '{}' property 'scale' invalid size", key);
|
||||
VERIFY(!scale || scale.value().size() == 3, "Gltf node '{}' property 'scale' invalid size", key);
|
||||
|
||||
auto translation = Json::parseFloatArrayProperty(object, "translation", false);
|
||||
ASSERT(!translation || translation.value().size() == 3, "Gltf node '{}' property 'translation' invalid size", key);
|
||||
VERIFY(!translation || translation.value().size() == 3, "Gltf node '{}' property 'translation' invalid size", key);
|
||||
|
||||
auto weights = Json::parseFloatArrayProperty(object, "weights", false);
|
||||
ASSERT(!weights || weights.value().size() > 0, "Gltf node '{}' empty property 'weights'", key);
|
||||
VERIFY(!weights || weights.value().size() > 0, "Gltf node '{}' empty property 'weights'", key);
|
||||
|
||||
auto name = Json::parseStringProperty(object, "name", false);
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace Inferno {
|
||||
void Gltf::parsePrimitive(glTF::Primitive* primitive, const std::string& key, const json& object)
|
||||
{
|
||||
auto attributes = Json::parseUnsignedObjectProperty(object, "attributes", true);
|
||||
ASSERT(attributes && attributes.value().size() > 0, "Gltf primitive '{}' empty property 'attributes'", key);
|
||||
VERIFY(attributes && attributes.value().size() > 0, "Gltf primitive '{}' empty property 'attributes'", key);
|
||||
|
||||
auto indices = Json::parseUnsignedProperty(object, "indices", false);
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace Inferno {
|
||||
if (Json::hasProperty(object, "targets")) {
|
||||
|
||||
auto targets = object["targets"];
|
||||
ASSERT(targets.is_array(), "Gltf primitive '{}' property 'targets' invalid type", key);
|
||||
VERIFY(targets.is_array(), "Gltf primitive '{}' property 'targets' invalid type", key);
|
||||
|
||||
for (auto& targetObject : targets) {
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace Inferno {
|
||||
if (value) target.emplace(std::move(key), value.value());
|
||||
}
|
||||
|
||||
ASSERT(target.size() > 0, "Gltf primitive '{}' empty 'target' object", key);
|
||||
VERIFY(target.size() > 0, "Gltf primitive '{}' empty 'target' object", key);
|
||||
primitive->targets.emplace_back(std::move(target));
|
||||
}
|
||||
}
|
||||
@@ -239,9 +239,9 @@ namespace Inferno {
|
||||
|
||||
void Gltf::parseMesh(glTF::Mesh* mesh, const std::string& key, const json& object)
|
||||
{
|
||||
ASSERT(Json::hasProperty(object, "primitives"), "Gltf mesh '{}' missing required property 'primitives'", key);
|
||||
VERIFY(Json::hasProperty(object, "primitives"), "Gltf mesh '{}' missing required property 'primitives'", key);
|
||||
auto primitives = object["primitives"];
|
||||
ASSERT(primitives.is_array(), "Gltf mesh '{}' property 'primitives' invalid type", key);
|
||||
VERIFY(primitives.is_array(), "Gltf mesh '{}' property 'primitives' invalid type", key);
|
||||
|
||||
for (auto& primitiveObject : primitives) {
|
||||
glTF::Primitive primitive;
|
||||
@@ -250,7 +250,7 @@ namespace Inferno {
|
||||
}
|
||||
|
||||
auto weights = Json::parseFloatArrayProperty(object, "weights", false);
|
||||
ASSERT(!weights || weights.value().size() > 0, "Gltf mesh '{}' empty property 'weights'", key);
|
||||
VERIFY(!weights || weights.value().size() > 0, "Gltf mesh '{}' empty property 'weights'", key);
|
||||
|
||||
auto name = Json::parseStringProperty(object, "name", false);
|
||||
|
||||
@@ -265,21 +265,21 @@ namespace Inferno {
|
||||
auto byteOffset = Json::parseUnsignedProperty(object, "byteOffset", false);
|
||||
|
||||
auto componentType = Json::parseUnsignedProperty(object, "componentType", true);
|
||||
ASSERT(componentType, "Gltf accessor '{}' missing required property 'componentType'", key);
|
||||
VERIFY(componentType, "Gltf accessor '{}' missing required property 'componentType'", key);
|
||||
|
||||
auto normalized = Json::parseBoolProperty(object, "normalized", false);
|
||||
|
||||
auto count = Json::parseUnsignedProperty(object, "count", true);
|
||||
ASSERT(count, "Gltf accessor '{}' missing required property 'count'", key);
|
||||
VERIFY(count, "Gltf accessor '{}' missing required property 'count'", key);
|
||||
|
||||
auto type = Json::parseStringProperty(object, "type", true);
|
||||
ASSERT(type, "Gltf accessor '{}' missing required property 'type'", key);
|
||||
VERIFY(type, "Gltf accessor '{}' missing required property 'type'", key);
|
||||
|
||||
auto max = Json::parseFloatArrayProperty(object, "max", false);
|
||||
ASSERT(!max || max.value().size() > 0, "Gltf accessor '{}' empty property 'max'", key);
|
||||
VERIFY(!max || max.value().size() > 0, "Gltf accessor '{}' empty property 'max'", key);
|
||||
|
||||
auto min = Json::parseFloatArrayProperty(object, "min", false);
|
||||
ASSERT(!min || min.value().size() > 0, "Gltf accessor '{}' empty property 'min'", key);
|
||||
VERIFY(!min || min.value().size() > 0, "Gltf accessor '{}' empty property 'min'", key);
|
||||
|
||||
auto name = Json::parseStringProperty(object, "name", false);
|
||||
|
||||
@@ -296,12 +296,12 @@ namespace Inferno {
|
||||
void Gltf::parseBufferView(glTF::BufferView* bufferView, const std::string& key, const json& object)
|
||||
{
|
||||
auto buffer = Json::parseUnsignedProperty(object, "buffer", false);
|
||||
ASSERT(buffer, "Gltf bufferView '{}' missing required property 'buffer'", key);
|
||||
VERIFY(buffer, "Gltf bufferView '{}' missing required property 'buffer'", key);
|
||||
|
||||
auto byteOffset = Json::parseUnsignedProperty(object, "byteOffset", false);
|
||||
|
||||
auto byteLength = Json::parseUnsignedProperty(object, "byteLength", true);
|
||||
ASSERT(byteLength, "Gltf bufferView '{}' missing required property 'byteLength'", key);
|
||||
VERIFY(byteLength, "Gltf bufferView '{}' missing required property 'byteLength'", key);
|
||||
|
||||
auto byteStride = Json::parseUnsignedProperty(object, "byteStride", false);
|
||||
|
||||
@@ -323,12 +323,12 @@ namespace Inferno {
|
||||
|
||||
// Load external binary data
|
||||
if (uri) {
|
||||
ASSERT(uri.value().find("data:", 0) == std::string::npos, "GltfFile embedded binary data is unsupported");
|
||||
VERIFY(uri.value().find("data:", 0) == std::string::npos, "GltfFile embedded binary data is unsupported");
|
||||
data->emplace(std::stou(key), File::raw("assets/gltf/" + uri.value()));
|
||||
}
|
||||
|
||||
auto byteLength = Json::parseUnsignedProperty(object, "byteLength", true);
|
||||
ASSERT(byteLength, "Gltf buffer '{}' missing required property 'byteLength'", key);
|
||||
VERIFY(byteLength, "Gltf buffer '{}' missing required property 'byteLength'", key);
|
||||
|
||||
auto name = Json::parseStringProperty(object, "name", false);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "glad/glad.h"
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/render/buffer.h"
|
||||
#include "inferno/render/renderer.h"
|
||||
#include "inferno/render/shader.h"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "glm/gtc/type_ptr.hpp" // glm::value_ptr
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/core.h"
|
||||
#include "inferno/io/file.h"
|
||||
#include "inferno/io/log.h"
|
||||
@@ -44,7 +44,7 @@ namespace Inferno {
|
||||
int32_t Shader::findUniform(const std::string& name) const
|
||||
{
|
||||
int32_t location = glGetUniformLocation(m_id, name.c_str());
|
||||
ASSERT(location != -1, "Shader could not find uniform '{}'", name);
|
||||
VERIFY(location != -1, "Shader could not find uniform '{}'", name);
|
||||
return location;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace Inferno {
|
||||
warn() << "Shader " << infoLog.data();
|
||||
}
|
||||
|
||||
ASSERT(success == GL_TRUE, "Shader program creation failed!");
|
||||
VERIFY(success == GL_TRUE, "Shader program creation failed!");
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -256,15 +256,15 @@ namespace Inferno {
|
||||
auto vertexPos = vertexSource.find_last_of('.');
|
||||
auto fragmentPos = fragmentSource.find_last_of('.');
|
||||
|
||||
ASSERT(vertexPos != std::string::npos, "Shader did not have file extension: '{}'", vertexSource);
|
||||
ASSERT(fragmentPos != std::string::npos, "Shader did not have file extension: '{}'", fragmentSource);
|
||||
VERIFY(vertexPos != std::string::npos, "Shader did not have file extension: '{}'", vertexSource);
|
||||
VERIFY(fragmentPos != std::string::npos, "Shader did not have file extension: '{}'", fragmentSource);
|
||||
|
||||
auto vertexName = vertexSource.substr(0, vertexPos);
|
||||
auto fragmentName = vertexSource.substr(0, fragmentPos);
|
||||
|
||||
ASSERT(vertexName == fragmentName, "Shader names did not match: {} {}", vertexSource, fragmentSource);
|
||||
VERIFY(vertexName == fragmentName, "Shader names did not match: {} {}", vertexSource, fragmentSource);
|
||||
|
||||
return vertexName;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
#include <utility> // std::move
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb/stb_image.h"
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/io/log.h"
|
||||
#include "inferno/render/texture.h"
|
||||
|
||||
namespace Inferno {
|
||||
@@ -22,7 +23,7 @@ namespace Inferno {
|
||||
stbi_set_flip_vertically_on_load(1);
|
||||
unsigned char* data = stbi_load(path.c_str(), &width, &height, &channels, STBI_default);
|
||||
|
||||
ASSERT(data, "Failed to load image: '{}'", path);
|
||||
VERIFY(data, "Failed to load image: '{}'", path);
|
||||
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
@@ -153,4 +154,4 @@ namespace Inferno {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#include "inferno/scene/scene.h"
|
||||
#include "inferno/assert.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/component/cameracomponent.h"
|
||||
#include "inferno/component/luascriptcomponent.h"
|
||||
#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"
|
||||
@@ -113,7 +114,7 @@ namespace Inferno {
|
||||
|
||||
void Scene::validEntity(uint32_t entity) const
|
||||
{
|
||||
ASSERT(m_registry->valid(entt::entity { entity }), "Entity is not valid");
|
||||
VERIFY(m_registry->valid(entt::entity { entity }), "Entity is not valid");
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
@@ -66,14 +66,14 @@ namespace Inferno {
|
||||
std::string script = File::read(m_path);
|
||||
auto result = m_state.script(script.c_str(),
|
||||
[](lua_State*, sol::protected_function_result pfr) { return pfr; });
|
||||
ASSERT(result.valid(), "LuaScript {}", ((sol::error)result).what());
|
||||
VERIFY(result.valid(), "LuaScript {}", ((sol::error)result).what());
|
||||
}
|
||||
|
||||
sol::table LuaScript::getTable(const char* name)
|
||||
{
|
||||
sol::table table = m_state[name];
|
||||
ASSERT(table.valid(), "LuaScript table does not exist");
|
||||
VERIFY(table.valid(), "LuaScript table does not exist");
|
||||
return table;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
#include <cstdint> // uint32_t
|
||||
#include <string> // std::string
|
||||
|
||||
#include "ruc/meta/assert.h"
|
||||
#define SOL_ALL_SAFETIES_ON 1
|
||||
#include "sol/protected_function.hpp"
|
||||
#include "sol/protected_function_result.hpp"
|
||||
#include "sol/state.hpp"
|
||||
#include "sol/table.hpp"
|
||||
|
||||
#include "inferno/assert.h"
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
struct TransformComponent;
|
||||
@@ -37,7 +36,7 @@ namespace Inferno {
|
||||
// Only call function if it exists
|
||||
if (solFunction.valid()) {
|
||||
sol::protected_function_result result = solFunction(solTable, parameters...);
|
||||
ASSERT(result.valid(), "Lua function {}", ((sol::error)result).what());
|
||||
VERIFY(result.valid(), "Lua function {}", ((sol::error)result).what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
@@ -12,20 +12,20 @@ namespace Inferno {
|
||||
public:
|
||||
static inline void initialize()
|
||||
{
|
||||
ASSERT(!s_instance, "singleton already exists");
|
||||
VERIFY(!s_instance, "singleton already exists");
|
||||
s_instance = new T { s {} };
|
||||
}
|
||||
|
||||
static inline void destroy()
|
||||
{
|
||||
ASSERT(s_instance, "singleton does not exist");
|
||||
VERIFY(s_instance, "singleton does not exist");
|
||||
delete s_instance;
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
static inline T& the()
|
||||
{
|
||||
ASSERT(s_instance, "singleton does not exist");
|
||||
VERIFY(s_instance, "singleton does not exist");
|
||||
return *s_instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "glm/ext/matrix_clip_space.hpp" // glm::perspective, glm::ortho
|
||||
#include "glm/ext/matrix_transform.hpp" // glm::radians, glm::lookAt
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/application.h"
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/component/cameracomponent.h"
|
||||
#include "inferno/component/transformcomponent.h"
|
||||
#include "inferno/io/input.h"
|
||||
@@ -44,7 +44,7 @@ namespace Inferno {
|
||||
return camera.projection * transform.transform;
|
||||
}
|
||||
|
||||
ASSERT_NOT_REACHED();
|
||||
VERIFY_NOT_REACHED();
|
||||
|
||||
return glm::mat4 { 1.0f };
|
||||
}
|
||||
@@ -94,4 +94,4 @@ namespace Inferno {
|
||||
// Souce: https://learnopengl.com/img/getting-started/coordinate_systems.png
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "glm/ext/matrix_transform.hpp" // glm::translate, glm::rotate, glm::scale, glm::radians
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/component/spritecomponent.h"
|
||||
#include "inferno/component/transformcomponent.h"
|
||||
#include "inferno/io/log.h"
|
||||
@@ -27,4 +26,4 @@ namespace Inferno {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "entt/entity/registry.hpp" // entt::entity, entt::registry
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/component/luascriptcomponent.h"
|
||||
#include "inferno/component/nativescriptcomponent.h"
|
||||
#include "inferno/component/transformcomponent.h"
|
||||
@@ -68,7 +67,6 @@ namespace Inferno {
|
||||
|
||||
luaScript.instance->update(deltaTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ScriptSystem::cleanup(uint32_t entity)
|
||||
@@ -100,4 +98,4 @@ namespace Inferno {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/application.h"
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/component/textareacomponent.h"
|
||||
#include "inferno/render/font.h"
|
||||
#include "inferno/render/renderer.h"
|
||||
@@ -60,7 +61,7 @@ namespace Inferno {
|
||||
|
||||
float textureWidth = static_cast<float>(font->texture()->width());
|
||||
float textureHeight = static_cast<float>(font->texture()->height());
|
||||
ASSERT(textureWidth == textureHeight, "TextAreaSystem read invalid font texture");
|
||||
VERIFY(textureWidth == textureHeight, "TextAreaSystem read invalid font texture");
|
||||
|
||||
// Skip empty characters
|
||||
if (c->size.x == 0 || c->size.y == 0) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "glm/ext/matrix_transform.hpp" // glm::translate, glm::rotate, glm::scale, glm::radians
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/component/transformcomponent.h"
|
||||
#include "inferno/io/log.h"
|
||||
#include "inferno/system/transformsystem.h"
|
||||
@@ -40,4 +39,4 @@ namespace Inferno {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Inferno
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <limits> // std::numeric_limits
|
||||
#include <string> // std::string, std::stoul
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
namespace std {
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace std {
|
||||
inline uint32_t stou(const std::string& string)
|
||||
{
|
||||
unsigned long size = std::stoul(string);
|
||||
ASSERT(size <= std::numeric_limits<uint32_t>::max(), "String util not in uint32_t range '{}'", string);
|
||||
VERIFY(size <= std::numeric_limits<uint32_t>::max(), "String util not in uint32_t range '{}'", string);
|
||||
return static_cast<uint32_t>(size);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#include <vector> // std::vector
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#include "inferno/assert.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
namespace Inferno {
|
||||
|
||||
@@ -81,7 +80,7 @@ namespace Inferno {
|
||||
|
||||
// Has property
|
||||
exists = hasProperty(json, it, property);
|
||||
ASSERT(!required || (required && exists), "Json could not find required property '{}'", property);
|
||||
VERIFY(!required || (required && exists), "Json could not find required property '{}'", property);
|
||||
|
||||
if (!exists) {
|
||||
return {};
|
||||
@@ -105,14 +104,14 @@ namespace Inferno {
|
||||
|
||||
// Has property
|
||||
exists = hasProperty(json, it, property);
|
||||
ASSERT(!required || (required && exists), "Json could not find required property '{}'", property);
|
||||
VERIFY(!required || (required && exists), "Json could not find required property '{}'", property);
|
||||
|
||||
if (!exists) {
|
||||
return {};
|
||||
}
|
||||
|
||||
// Check if property is array []
|
||||
ASSERT(getValue(it).is_array(), "Json property is not an array '{}'", property);
|
||||
VERIFY(getValue(it).is_array(), "Json property is not an array '{}'", property);
|
||||
|
||||
// Fill array with values
|
||||
std::vector<T> values;
|
||||
@@ -145,14 +144,14 @@ namespace Inferno {
|
||||
|
||||
// Has property
|
||||
exists = hasProperty(json, it, property);
|
||||
ASSERT(!required || (required && exists), "Json could not find required property '{}'", property);
|
||||
VERIFY(!required || (required && exists), "Json could not find required property '{}'", property);
|
||||
|
||||
if (!exists) {
|
||||
return {};
|
||||
}
|
||||
|
||||
// Check if property is an object {}
|
||||
ASSERT(getValue(it).is_object(), "Json property is not an array '{}'", property);
|
||||
VERIFY(getValue(it).is_object(), "Json property is not an array '{}'", property);
|
||||
|
||||
std::map<std::string, T> values;
|
||||
for (auto& [key, value] : getValue(it).items()) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <csignal> // signal
|
||||
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "ruc/meta/assert.h"
|
||||
|
||||
#include "inferno/application.h"
|
||||
#include "inferno/assert.h"
|
||||
#include "inferno/core.h"
|
||||
#include "inferno/event/applicationevent.h"
|
||||
#include "inferno/event/keyevent.h"
|
||||
@@ -61,7 +61,7 @@ namespace Inferno {
|
||||
// Create GLFW window
|
||||
m_window = glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr);
|
||||
s_windowCount++;
|
||||
ASSERT(m_window, "Failed to create GLFW window!");
|
||||
VERIFY(m_window, "Failed to create GLFW window!");
|
||||
|
||||
// Set windowed/fullscreen/borderless
|
||||
this->setWindowMonitor();
|
||||
|
||||
Reference in New Issue
Block a user