Commit 49c3eb56 authored by Johannes Braun's avatar Johannes Braun
Browse files

Big cleanup, removal of old classes (xml, prefs, obj, mtl etc.) and warning removal in lodepng

parent 32b43c1c
......@@ -7,9 +7,9 @@
</sector-style>
<possession src="possession.png">
<team id="0" mapto="0x0000ffff"/>
<team id="1" mapto="0xff0000ff"/>
<team id="2" mapto="0xffff00ff"/>
<team id="3" mapto="0xffffffff"/>
<team id="0" mapto="#00f"/>
<team id="1" mapto="#f00"/>
<team id="2" mapto="#ff0"/>
<team id="3" mapto="#fff"/>
</possession>
</map>
\ No newline at end of file
assets/screenshots/render.png

1.1 MB | W: | H:

assets/screenshots/render.png

1.64 MB | W: | H:

assets/screenshots/render.png
assets/screenshots/render.png
assets/screenshots/render.png
assets/screenshots/render.png
  • 2-up
  • Swipe
  • Onion skin
#ifndef __GLARE_INCLUDE_IO
#define __GLARE_INCLUDE_IO
#include <io/ColladaLoader.h>
#include <io/ImageUtilities.h>
#include <io/MTLLoader.h>
#include <io/OBJLoader.h>
#include <io/Resources.h>
#include <io/XMLParser.h>
#include <io/ArgParser.h>
#endif //!__GLARE_INCLUDE_IO
\ No newline at end of file
#ifndef __GLARE_INCLUDE_PREFERENCES
#define __GLARE_INCLUDE_PREFERENCES
#include <preference/Preferences.h>
#endif //!__GLARE_INCLUDE_PREFERENCES
\ No newline at end of file
<settings>
<!-- Splash screen settings -->
<item name="splash_image">/textures/splash.png</item>
<item name="splash_sound">/audio/swoosh.wav</item>
<item name="splash_background">#0277BD</item>
<item name="splash_duration">200</item>
<!-- General settings -->
<item name="settings_window_title">GLARE Window</item>
<item name="settings_window_size_x">1280</item>
<item name="settings_window_size_y">720</item>
<item name="settings_vsync_mode">0</item>
<item name="settings_msaa_samples">4</item>
<!-- Pathtracer settings -->
<item name="pathtrace_quality">0.4</item>
<item name="pathtrace_shadow_quality">0.04</item>
<item name="pathtrace_clamp_direct">8</item>
<item name="pathtrace_clamp_indirect">8</item>
<!-- Bounce limits -->
<item name="pathtrace_bounces_diffuse">4</item>
<item name="pathtrace_bounces_translucent">4</item>
<item name="pathtrace_bounces_reflect">4</item>
<item name="pathtrace_bounces_refract">8</item>
<item name="pathtrace_bounces_transparent">8</item>
<item name="pathtrace_bounces_emissive">1</item>
<!-- Line space bounce count thresholds -->
<item name="pathtrace_ls_thresh_bounces_diffuse">3</item>
<item name="pathtrace_ls_thresh_bounces_translucent">2</item>
<item name="pathtrace_ls_thresh_bounces_reflect">3</item>
<item name="pathtrace_ls_thresh_bounces_refract">5</item>
<item name="pathtrace_ls_thresh_bounces_transparent">7</item>
<item name="pathtrace_ls_thresh_bounces_emissive">1</item>
<!-- Line Space settings -->
<item name="linespace_max_resolution">16</item>
</settings>
\ No newline at end of file
#include <types/color.h>
#include <types/string_parse.h>
#include <random>
using namespace glare;
......@@ -16,6 +17,12 @@ int main(int argc, char* argv[])
color::rgb32f my_color = color::hex<color::rgb32f>(0xff00ff);
color::rgb8u random = color::random<color::rgb8u>();
auto vec = string_parse::as_vector<float>("0 1 0.3 13.4 11.1");
auto vec2 = string_parse::as_vector<float>("0,9,1.2,0.3,11.2,-4.3", ',');
auto arr = string_parse::as_array<float, 4>("11 3.2 1.3 8.4");
auto arr2 = string_parse::as_array<float, 16>("11 3.2 1.3 8.4 9.2 41.4 -4");
uint32_t hex = color::toHex<color::rgba8u>(hex_color);
return 0;
......
......@@ -99,10 +99,10 @@ namespace glare
//initializeScene(m_current_scene_root / "benchmark_single_quad_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_single_cube_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_suzanne_x1_diff.dae", 1.f);
initializeScene(m_current_scene_root / "benchmark_suzanne_x2_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_suzanne_x2_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_teapot_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_stfd_bunny_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_stfd_armadillo_diff.dae", 1.f);
initializeScene(m_current_scene_root / "benchmark_stfd_armadillo_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_stfd_dragon_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_stfd_asian_dragon_diff.dae", 1.f);
......@@ -211,22 +211,23 @@ namespace glare
void Application::initializeScene(fs::path path, float scale)
{
//Initialize some scene graph from an obj file
m_scene_data = io::Resources::getInstance().getColladaData(path, scale);
core::EngineState::graph_root = io::Resources::getInstance().getColladaFile(path, scale);
if (!m_scene_data)
if (!core::EngineState::graph_root)
{
core::EngineState::quit();
glfwTerminate();
quitPromptDefault(1);
}
core::EngineState::graph_root = m_scene_data->scenes.begin()->second;
std::shared_ptr<core::GraphNode> cam_node;
if (!m_scene_data->cameras.empty())
std::shared_ptr<core::GraphNode> cam_node = core::EngineState::graph_root->findFirst([](const core::GraphNode &node) {
return bool(node.getComponent<core::Camera>());
});
if (cam_node)
{
//If there are any cameras in the collada file, take the first one.
core::EngineState::main_camera = m_scene_data->cameras.begin()->second;
cam_node = core::EngineState::main_camera->getOwner();
core::EngineState::main_camera = cam_node->getComponent<core::Camera>();
}
else {
//Add a camera to render from
......@@ -413,7 +414,7 @@ namespace glare
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth()/2 );
if (ImGui::Button("32bit HDR"))
{
m_raytracer->saveRenderHDR(core::asset("/screenshots/render.hdr"));
m_raytracer->saveRender(core::asset("/screenshots/render.hdr"));
}
ImGui::SameLine();
......
......@@ -2,7 +2,6 @@
#define __APPLICATION_H
#include <glare_core>
#include <glare_preferences>
#include <glare_io>
#include <glare_gui>
#include <glare_advanced>
......@@ -53,7 +52,6 @@ namespace glare
fs::path m_current_scene_root;
float m_import_scale = 1;
std::unique_ptr<io::Arguments> m_arguments;
std::shared_ptr<io::ColladaData> m_scene_data;
std::shared_ptr<core::Skybox> m_skybox;
//Render requirements
......
......@@ -35,15 +35,19 @@ void Game::onKeyDown(controls::Key key, controls::KeyMods mods)
}
void Game::initialize()
{
m_default_preferences = io::Resources::getInstance().getPreferences("default");
m_config.use_fxaa = m_default_preferences->get("fxaa", false);
m_config.vsync = VSyncMode(m_default_preferences->get("vsync", 0));
m_config.window_width = m_default_preferences->get("window_size_x", 1280u);
m_config.window_height = m_default_preferences->get("window_size_y", 720u);
m_config.sample_count = m_default_preferences->get("msaa_samples", 4);
{
pugi::xml_document preferences_file;
preferences_file.load_file(core::asset("/preferences/default.xml").c_str());
// BASIC CONFIG
const auto config_child = preferences_file.child("settings").find_child_by_attribute("group", "name", "config");
m_config.window_width = config_child.find_child_by_attribute("item", "name", "window_size_x").attribute("value").as_uint(1280);
m_config.window_height = config_child.find_child_by_attribute("item", "name", "window_size_y").attribute("value").as_uint(720);
m_config.window_title = config_child.find_child_by_attribute("item", "name", "window_title").attribute("value").as_string("GLARE");
m_config.vsync = VSyncMode(config_child.find_child_by_attribute("item", "name", "vsync").attribute("value").as_uint(0));
m_config.sample_count = config_child.find_child_by_attribute("item", "name", "msaa").attribute("value").as_uint(4);
core::EngineState::initialize(m_config.window_width, m_config.window_height, "GLARE Window", core::asset("/controls/control_scheme.ctrl"));
core::EngineState::initialize(m_config.window_width, m_config.window_height, m_config.window_title);
m_skybox = std::make_shared<core::Skybox>(core::Skybox::collectFilesFrom(core::asset("/textures/sky/")));
......@@ -88,7 +92,7 @@ void Game::initialize()
core::EngineState::graph_root->attach(cam_node);
//Attach plane as child in front of the camera.
auto plane = io::Resources::getInstance().getColladaSceneMeshNode("", core::asset("meshes/scenery/plane.dae"), "Cube");
auto plane = io::Resources::getInstance().getColladaMesh(core::asset("meshes/scenery/plane.dae"), "Cube");
cam_node->attach(plane);
plane->transform()->position = { 0, -2.f, -15 };
plane->transform()->rotate({ glm::radians(-90.f), glm::radians(90.f), 0.f });
......
......@@ -2,7 +2,6 @@
#define __GAME_H
#include <glare_core>
#include <glare_preferences>
#include <glare_io>
#include <glare_gui>
......@@ -22,24 +21,20 @@ public:
private:
std::shared_ptr<core::Mesh> makeMesh();
void onKeyDown(controls::Key key, controls::KeyMods mods);
struct
{
bool use_fxaa;
VSyncMode vsync;
unsigned window_width;
unsigned window_height;
unsigned sample_count;
std::string window_title;
} m_config;
fs::path m_current_scene_root;
std::shared_ptr<preferences::Preferences> m_default_preferences;
std::shared_ptr<core::Skybox> m_skybox;
std::shared_ptr<io::ColladaData> m_scene_data;
std::unique_ptr<core::GBuffer> m_gbuffer;
};
......
......@@ -34,7 +34,7 @@ namespace glare
m_team_to_pcolor.emplace(team_id, mapto_color);
}
auto data = io::ImageUtilities::loadData<core::TextureDataRGBA_32F>(m_heightmap_path);
auto data = io::image::loadData<core::TextureDataRGBA_32F>(m_heightmap_path);
m_width = unsigned(data->width());
m_height = unsigned(data->height());
......
......@@ -86,7 +86,7 @@ namespace glare
for (auto &&pair : raytracer.collector()->meshCollectors()) {
auto id = raytracer.collector()->getIdMapping().at(pair.first);
m_generator_shader_gbuffer->updateUniformUInt("u_mesh_id", id);
m_generator_shader_gbuffer->updateUniformUInt("u_mesh_id", unsigned(id));
m_generator_shader_gbuffer->updateUniformMatrix("u_mvp", core::EngineState::main_camera->getViewProjection() * pair.second->m_transform);
m_vertex_array->draw(gl::PrimitiveType::ePoints, pair.second->triangles().size());
}
......
......@@ -172,14 +172,9 @@ namespace glare
return *m_render_target;
}
void Raytracer::saveRenderHDR(fs::path target) const
{
io::ImageUtilities::saveTexture(target, *m_render_target);
}
void Raytracer::saveRender(fs::path target) const
{
io::ImageUtilities::saveTextureForceUChar(target, *m_render_target);
io::image::saveTexture(target, *m_render_target);
}
void Raytracer::setGenerator(std::shared_ptr<RayGeneratorBase> generator)
......
......@@ -37,7 +37,6 @@ namespace glare
~Raytracer();
const core::TextureRGBA_32F &render(uint32_t width, uint32_t height);
void saveRenderHDR(fs::path target) const;
void saveRender(fs::path target) const;
void setEffectBounces(EffectType type, uint8_t bounces);
......
......@@ -23,6 +23,9 @@ namespace glare
template<typename T>
std::shared_ptr<T> getComponent();
template<typename T>
std::shared_ptr<T> getComponent() const;
protected:
std::map<size_t, std::shared_ptr<ComponentType>> m_components;
};
......@@ -57,6 +60,20 @@ namespace glare
return std::static_pointer_cast<T>(m_components.at(typeid(T).hash_code()));
}
}
template <typename NodeType, typename ComponentType>
template<typename T>
std::shared_ptr<T> ComponentContainer<NodeType, ComponentType>::getComponent() const
{
if (m_components.count(typeid(T).hash_code()) == 0)
{
return std::shared_ptr<T>(nullptr);
}
else
{
return std::static_pointer_cast<T>(m_components.at(typeid(T).hash_code()));
}
}
}
}
......
......@@ -136,25 +136,19 @@ namespace glare
//Float textures
using TextureRGBA_32F = Texture_Float<gl::TextureFormat::eRGBA, gl::TextureInternalFormat::eRGBA32Float>;
using TextureRGBA_16F = Texture_Float<gl::TextureFormat::eRGBA, gl::TextureInternalFormat::eRGBA16Float>;
using TextureRGBA_UB = Texture_UByte<gl::TextureFormat::eRGBA, gl::TextureInternalFormat::eRGBA8>;
using TextureRGB_32F = Texture_Float<gl::TextureFormat::eRGB, gl::TextureInternalFormat::eRGB32Float>;
using TextureRGB_16F = Texture_Float<gl::TextureFormat::eRGB, gl::TextureInternalFormat::eRGB16Float>;
using TextureRGB_UB = Texture_UByte<gl::TextureFormat::eRGB, gl::TextureInternalFormat::eRGB>;
using TextureR_32F = Texture_Float<gl::TextureFormat::eRed, gl::TextureInternalFormat::eR32Float>;
using TextureR_16F = Texture_Float<gl::TextureFormat::eRed, gl::TextureInternalFormat::eR16Float>;
using TextureR_UB = Texture_UByte<gl::TextureFormat::eRed, gl::TextureInternalFormat::eRed>;
using TextureDepth_32F = Texture_Float<gl::TextureFormat::eDepthComponent, gl::TextureInternalFormat::eDepthComponent32Float>;
//Unsigned byte textures
using TextureDataRGBA_32F = TextureData_Float<gl::TextureFormat::eRGBA, gl::TextureInternalFormat::eRGBA32Float>;
using TextureDataRGBA_16F = TextureData_Float<gl::TextureFormat::eRGBA, gl::TextureInternalFormat::eRGBA16Float>;
using TextureDataRGBA_UB = TextureData_UByte<gl::TextureFormat::eRGBA, gl::TextureInternalFormat::eRGBA8>;
using TextureDataRGB_32F = TextureData_Float<gl::TextureFormat::eRGB, gl::TextureInternalFormat::eRGB32Float>;
using TextureDataRGB_16F = TextureData_Float<gl::TextureFormat::eRGB, gl::TextureInternalFormat::eRGB16Float>;
using TextureDataRGB_UB = TextureData_UByte<gl::TextureFormat::eRGB, gl::TextureInternalFormat::eRGB>;
using TextureDataR_32F = TextureData_Float<gl::TextureFormat::eRed, gl::TextureInternalFormat::eR32Float>;
using TextureDataR_16F = TextureData_Float<gl::TextureFormat::eRed, gl::TextureInternalFormat::eR16Float>;
using TextureDataR_UB = TextureData_UByte<gl::TextureFormat::eRed, gl::TextureInternalFormat::eRed>;
using TextureDataDepth_32F = TextureData_Float<gl::TextureFormat::eDepthComponent, gl::TextureInternalFormat::eDepthComponent32Float>;
......
......@@ -24,8 +24,8 @@ namespace glare
for (GLuint face = 0; face < faces.size(); face++)
{
Log_Debug << "Face No " << face;
auto vec = io::ImageUtilities::loadRawImage<unsigned char>(faces[face], width, height, 3);
io::ImageUtilities::flipImage(width, height, 3, vec.data());
auto vec = io::image::load<unsigned char>(faces[face], width, height, 3);
io::image::flip(width, height, 3, vec.data());
gl::textureImage2D(gl::TextureImageTarget2D(int(gl::TextureImageTarget2D::eCubeMapPosX) + face), 0, gl::TextureInternalFormat::eRGB, width, height, 0, gl::TextureFormat::eRGB, gl::Type::eUByte, vec.data());
}
......
......@@ -7,8 +7,7 @@
#include <types/color.h>
#include <engine/graphics/Light.h>
#include <filesystem>
#include "XMLParser.h"
#include <pugixml/pugixml.hpp>
namespace glare
{
......@@ -63,63 +62,48 @@ namespace glare
float falloff_exponent;
};
struct ColladaData
{
PointerStringMap<core::Camera> cameras;
std::map<std::string, std::shared_ptr<TempLight>> lights;
PointerStringMap<core::TextureRGBA_UB> images;
PointerStringMap<MaterialEffect> material_effects;
PointerStringMap<core::Material> materials;
StringMap<std::vector<MeshMaterial>> mesh_material_symbols;
StringMap<std::string> controller_geometries;
StringMap<MeshVertices> mesh_vertices;
PointerStringMap<core::GraphNode> scenes;
};
enum Axis
{
X = 0,
Y = 1,
Z = 2
};
class ColladaLoader
class Collada
{
public:
std::shared_ptr<ColladaData> loadFile(const fs::path &path, float scale = 1);
void decodeCameraNode(std::shared_ptr<TagTreeNode> cam_node) const;
void decodeLightsNode(std::shared_ptr<TagTreeNode> light_node) const;
void decodeImagesNode(const std::string &directory, std::shared_ptr<TagTreeNode> img_node) const;
void decodeMaterialEffectsNode(std::shared_ptr<TagTreeNode> mat_effects_node) const;
void decodeMaterialsNode(std::shared_ptr<TagTreeNode> mat_node) const;
void decodeGeometriesNode(std::shared_ptr<TagTreeNode> geom_node) const;
void decodeControllersNode(std::shared_ptr<TagTreeNode> controller_node) const;
void decodeNodes(std::shared_ptr<TagTreeNode> node) const;
void addScene(std::shared_ptr<TagTreeNode> scene_node) const;
std::shared_ptr<core::GraphNode> extractNode(std::shared_ptr<TagTreeNode> node, bool is_root) const;
std::shared_ptr<core::GraphNode> load(const fs::path &path, float scale = 1);
void decodeCameraNode(const pugi::xml_node& cam_node) const;
void decodeLightsNode(const pugi::xml_node& light_node) const;
void decodeImagesNode(const std::string &directory, const pugi::xml_node& img_node) const;
void decodeMaterialEffectsNode(const pugi::xml_node& mat_effects_node) const;
void decodeMaterialsNode(const pugi::xml_node& mat_node) const;
void decodeGeometriesNode(const pugi::xml_node& geom_node) const;
void decodeControllersNode(const pugi::xml_node& controller_node) const;
void decodeNodes(const pugi::xml_node& node) const;
void addScene(const pugi::xml_node& scene_node) const;
std::shared_ptr<core::GraphNode> extractNode(const pugi::xml_node& node, bool is_root) const;
static color::rgba32f decodeColor(const std::string &value);
static std::string decodeTextureSampler(std::shared_ptr<TagTreeNode> effect_node, const std::string &sampler);
static std::vector<float> decodeFloatList(const std::string &value);
static std::vector<unsigned> decodeUIntList(const std::string &value);
static glm::mat4 decodeMatrix(const std::string &value);
static std::string decodeTextureSampler(const pugi::xml_node& effect_node, const std::string &sampler);
static glm::vec3 decodeVec3(const std::string &value);
static glm::quat decodeQuat(const std::string &value);
private:
struct ColladaMemory
{
PointerStringMap<core::Camera> cameras;
std::map<std::string, std::shared_ptr<TempLight>> lights;
PointerStringMap<core::TextureRGBA_UB> images;
PointerStringMap<MaterialEffect> material_effects;
StringMap<std::string> controller_geometries;
StringMap<MeshVertices> mesh_vertices;
PointerStringMap<core::Material> materials;
StringMap<std::vector<MeshMaterial>> mesh_material_symbols;
PointerStringMap<core::GraphNode> scenes;
};
static void transformZupToYup(glm::mat4 &matrix);
std::shared_ptr<ColladaData> data;
std::shared_ptr<ColladaMemory> data;
float m_scale = 1;
int m_up_axis = 1;
std::shared_ptr<core::GraphNode> current_root;
std::shared_ptr<core::Camera> m_current_camera;
unsigned collada_flags = 0;
};
}
}
......
......@@ -6,7 +6,7 @@ namespace glare
{
namespace io
{
int ImageUtilities::getFormatChannels(gl::TextureFormat format)
int image::channels(gl::TextureFormat format)
{
switch (format)
{
......@@ -23,7 +23,7 @@ namespace glare
}
}
void ImageUtilities::freeTextureData(void* data)
void image::free(void* data)
{
stb::stbi_image_free(data);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment