Commit ae3a6b71 authored by Johannes Braun's avatar Johannes Braun
Browse files

Aaand again, further cleanup. Seems okay now.

parent 89eb2e9f
...@@ -12,12 +12,21 @@ set fileNameUpperH=%className%.h ...@@ -12,12 +12,21 @@ set fileNameUpperH=%className%.h
for %%b in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ( for %%b in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
set "fileNameUpperH=!fileNameUpperH:%%b=%%b!" set "fileNameUpperH=!fileNameUpperH:%%b=%%b!"
) )
set fileNameUpperH=__%fileNameUpperH:.=_% set fileNameUpperH=INCLUDE_%fileNameUpperH:.=_%
if not exist src/%path%/%fileNameH% ( if not exist src/%path%/%fileNameH% (
echo #ifndef %fileNameUpperH%>> src/%path%/%fileNameH% echo #ifndef %fileNameUpperH%>> src/%path%/%fileNameH%
echo #define %fileNameUpperH%>> src/%path%/%fileNameH% echo #define %fileNameUpperH%>> src/%path%/%fileNameH%
echo.>> src/%path%/%fileNameH% echo.>> src/%path%/%fileNameH%
echo // --------------- STDLIB --------------->> src/%path%/%fileNameH%
echo.>> src/%path%/%fileNameH%
echo.>> src/%path%/%fileNameH%
echo // --------------- EXTERN --------------->> src/%path%/%fileNameH%
echo.>> src/%path%/%fileNameH%
echo.>> src/%path%/%fileNameH%
echo // --------------- INTERN --------------->> src/%path%/%fileNameH%
echo.>> src/%path%/%fileNameH%
echo.>> src/%path%/%fileNameH%
echo namespace glare>> src/%path%/%fileNameH% echo namespace glare>> src/%path%/%fileNameH%
echo {>> src/%path%/%fileNameH% echo {>> src/%path%/%fileNameH%
echo namespace %subNamespace%>> src/%path%/%fileNameH% echo namespace %subNamespace%>> src/%path%/%fileNameH%
...@@ -25,6 +34,12 @@ if not exist src/%path%/%fileNameH% ( ...@@ -25,6 +34,12 @@ if not exist src/%path%/%fileNameH% (
echo class %className%>> src/%path%/%fileNameH% echo class %className%>> src/%path%/%fileNameH%
echo {>> src/%path%/%fileNameH% echo {>> src/%path%/%fileNameH%
echo public:>> src/%path%/%fileNameH% echo public:>> src/%path%/%fileNameH%
echo %className%^(^)^; >> src/%path%/%fileNameH%
echo %className%^(%className%^& other^) ^= default^; >> src/%path%/%fileNameH%
echo %className%^(%className%^&^& other^) ^= default^; >> src/%path%/%fileNameH%
echo %className%^& operator^=^(%className%^& other^) ^= default^; >> src/%path%/%fileNameH%
echo %className%^& operator^=^(%className%^&^& other^) ^= default^; >> src/%path%/%fileNameH%
echo.>> src/%path%/%fileNameH%
echo };>> src/%path%/%fileNameH% echo };>> src/%path%/%fileNameH%
echo }>> src/%path%/%fileNameH% echo }>> src/%path%/%fileNameH%
echo }>> src/%path%/%fileNameH% echo }>> src/%path%/%fileNameH%
...@@ -32,15 +47,26 @@ if not exist src/%path%/%fileNameH% ( ...@@ -32,15 +47,26 @@ if not exist src/%path%/%fileNameH% (
echo #endif //%fileNameUpperH%>> src/%path%/%fileNameH% echo #endif //%fileNameUpperH%>> src/%path%/%fileNameH%
echo #include "%fileNameH%">> src/%path%/%fileNameCPP% echo #include "%fileNameH%">> src/%path%/%fileNameCPP%
echo.>> src/%path%/%fileNameCPP%
echo // --------------- STDLIB --------------->> src/%path%/%fileNameCPP%
echo.>> src/%path%/%fileNameCPP%
echo.>> src/%path%/%fileNameCPP%
echo // --------------- EXTERN --------------->> src/%path%/%fileNameCPP%
echo.>> src/%path%/%fileNameCPP%
echo.>> src/%path%/%fileNameCPP%
echo // --------------- INTERN --------------->> src/%path%/%fileNameCPP%
echo.>> src/%path%/%fileNameCPP%
echo.>> src/%path%/%fileNameCPP%
echo namespace glare>> src/%path%/%fileNameCPP% echo namespace glare>> src/%path%/%fileNameCPP%
echo {>> src/%path%/%fileNameCPP% echo {>> src/%path%/%fileNameCPP%
echo namespace %subNamespace%>> src/%path%/%fileNameCPP% echo namespace %subNamespace%>> src/%path%/%fileNameCPP%
echo {>> src/%path%/%fileNameCPP% echo {>> src/%path%/%fileNameCPP%
echo.>> src/%path%/%fileNameCPP% echo %className%::%className%^(^) >> src/%path%/%fileNameCPP%
echo { >> src/%path%/%fileNameCPP%
echo } >> src/%path%/%fileNameCPP%
echo }>> src/%path%/%fileNameCPP% echo }>> src/%path%/%fileNameCPP%
echo }>> src/%path%/%fileNameCPP% echo }>> src/%path%/%fileNameCPP%
) else ( ) else (
echo File %path%/%fileNameH% already exists! echo File %path%/%fileNameH% already exists!
) )
call build
\ No newline at end of file
...@@ -7,5 +7,5 @@ ...@@ -7,5 +7,5 @@
<color value="#0277BD"/> <color value="#0277BD"/>
<!--<texture src="/textures/LS_Field.png" scale="100"/>--> <!--<texture src="/textures/LS_Field.png" scale="100"/>-->
</item> </item>
<item name="duration" value="200"/> <item name="duration" value="300"/>
</splash> </splash>
\ No newline at end of file
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <engine/ComponentContainer.h> #include <engine/ComponentContainer.h>
//Core Animation //Core Animation
#include <engine/animation/Animation.h>
#include <engine/animation/AnimationManager.h> #include <engine/animation/AnimationManager.h>
//Core Graphics //Core Graphics
......
#include "RayGenerator.h" #include "RayGenerator.h"
#include "Raytracer.h" #include "Raytracer.h"
#include <engine/rendering/OpenGLState.h> #include <engine/rendering/OpenGLState.h>
#include <util/files.h>
namespace glare namespace glare
{ {
...@@ -27,7 +28,7 @@ namespace glare ...@@ -27,7 +28,7 @@ namespace glare
RayGeneratorDefault::RayGeneratorDefault() RayGeneratorDefault::RayGeneratorDefault()
{ {
m_generator_shader_default = core::ShaderProgram::makeUnique(core::shader("/raytracer/generators/bvh/bvh_raygenerator.compute").string()); m_generator_shader_default = core::ShaderProgram::makeUnique(files::shader("/raytracer/generators/bvh/bvh_raygenerator.compute").string());
} }
void RayGeneratorDefault::generate(Raytracer &raytracer) void RayGeneratorDefault::generate(Raytracer &raytracer)
...@@ -54,12 +55,12 @@ namespace glare ...@@ -54,12 +55,12 @@ namespace glare
RayGeneratorGBuffer::RayGeneratorGBuffer() RayGeneratorGBuffer::RayGeneratorGBuffer()
{ {
std::vector<std::shared_ptr<glare::core::Shader>> shaders = { std::vector<std::shared_ptr<glare::core::Shader>> shaders = {
std::make_shared<glare::core::Shader>(gl::ShaderType::eVertex, core::shader("raytracer/generators/gbuffer/gbuffer.vert")), std::make_shared<glare::core::Shader>(gl::ShaderType::eVertex, files::shader("raytracer/generators/gbuffer/gbuffer.vert")),
std::make_shared<glare::core::Shader>(gl::ShaderType::eGeometry, core::shader("raytracer/generators/gbuffer/gbuffer.geom")), std::make_shared<glare::core::Shader>(gl::ShaderType::eGeometry, files::shader("raytracer/generators/gbuffer/gbuffer.geom")),
std::make_shared<glare::core::Shader>(gl::ShaderType::eFragment, core::shader("raytracer/generators/gbuffer/gbuffer.frag")) std::make_shared<glare::core::Shader>(gl::ShaderType::eFragment, files::shader("raytracer/generators/gbuffer/gbuffer.frag"))
}; };
m_generator_shader_gbuffer = std::make_unique<core::ShaderProgram>(shaders); m_generator_shader_gbuffer = std::make_unique<core::ShaderProgram>(shaders);
m_buffer_depthtest = core::ShaderProgram::makeUnique(core::shader("raytracer/generators/gbuffer/depthtest.compute").string()); m_buffer_depthtest = core::ShaderProgram::makeUnique(files::shader("raytracer/generators/gbuffer/depthtest.compute").string());
m_vertex_array = std::make_unique<core::VertexArray>(); m_vertex_array = std::make_unique<core::VertexArray>();
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <engine/Time.h> #include <engine/Time.h>
#include <random> #include <random>
#include <pugixml/pugixml.hpp> #include <pugixml/pugixml.hpp>
#include <util/files.h>
namespace glare namespace glare
{ {
...@@ -42,7 +43,7 @@ namespace glare ...@@ -42,7 +43,7 @@ namespace glare
m_linespace_config.distance_threshold = 8.f; m_linespace_config.distance_threshold = 8.f;
m_render_config.bounces = 16; m_render_config.bounces = 16;
m_render_shader = core::ShaderProgram::makeUnique(core::shader("/raytracer/pathtracer.compute").string()); m_render_shader = core::ShaderProgram::makeUnique(files::shader("/raytracer/pathtracer.compute").string());
m_ray_generator = ray_generator; m_ray_generator = ray_generator;
m_trace_buffer = std::make_unique<core::Buffer<gl::BufferType::eShaderStorage>>(); m_trace_buffer = std::make_unique<core::Buffer<gl::BufferType::eShaderStorage>>();
core::MessageHandler::getInstance().registerReceiver(core::GlobalMessages::c_scene_changed, *this); core::MessageHandler::getInstance().registerReceiver(core::GlobalMessages::c_scene_changed, *this);
......
...@@ -299,35 +299,6 @@ namespace glare ...@@ -299,35 +299,6 @@ namespace glare
return max - min + 1; return max - min + 1;
} }
}; };
/**
* A SkewedSemiAligned is a kind of convex 6-sided polyhedra that has two opposite sides of equal size aligned to any two axises (those can be different for both sides)
* It is defined by 4 points and a size of the opposite sides.
*/
struct SkewedSemiAligned
{
Range<Range<glm::vec4>> corners;
glm::vec2 sizes;
};
//template<size_t BaseSize> constexpr unsigned padding_size = (4 * sizeof(float) - sizeof(T)) & ((sizeof(float) << 2) - 1);
template<bool P, typename T>
struct Padded_If
{
T base;
};
template<typename T>
struct Padded_If<true, T>
{
T base;
private:
char __p[(4 * sizeof(float) - sizeof(T)) & ((sizeof(float) << 2) - 1)];
};
// Rounds up the size of the template parameter type to the next multiple of vec4 (4x4 bytes) by adding a padding if necessary.
template<typename T> using Padded = Padded_If<(sizeof(T) & (2 << 3) - 1) != 0, T>;
struct Toggle struct Toggle
{ {
......
#include "TextUtilities.h"
namespace glare
{
namespace core
{
std::wstring TextUtilities::toWString(const std::string& input)
{
//make text unsigned (const char* to const unsigned char*) as it's needed for conversion.
const unsigned char* ch_text = reinterpret_cast<const unsigned char*>(input.data());
return std::wstring(&ch_text[0], &ch_text[input.size()]);
}
bool TextUtilities::isLineBreakable(wchar_t character)
{
return (character == ' ' || character == '-' || character == '+' || character == '*' || character == '/');
}
}
}
#ifndef __TEXTUTILITIES_H
#define __TEXTUTILITIES_H
#include <string>
namespace glare
{
namespace core
{
namespace TextUtilities
{
std::wstring toWString(const std::string &input);
bool isLineBreakable(wchar_t character);
}
}
}
#endif //__TEXTUTILITIES_H
#include "Animation.h"
namespace glare
{
namespace core
{
}
}
#ifndef __ANIMATION_H
#define __ANIMATION_H
#include <functional>
namespace glare
{
namespace core
{
class AnimationManager;
struct Animation
{
friend class AnimationManager;
double duration;
double start_delay = 0;
std::function<void(double, double)> on_update;
std::function<void()> on_start;
std::function<void()> on_finish;
std::function<void()> on_cancel;
private:
//From 0..1
double current_time = 0;
double current_value = 0;
bool has_started = false;
bool mark_finished = false;
};
}
}
#include "AnimationManager.h"
#endif //__ANIMATION_H
#include "AnimationManager.h" #include "AnimationManager.h"
// --------------- STDLIB ---------------
// --------------- EXTERN ---------------
// --------------- INTERN ---------------
#include <engine/Time.h> #include <engine/Time.h>
namespace glare namespace glare
...@@ -106,7 +110,7 @@ namespace glare ...@@ -106,7 +110,7 @@ namespace glare
{ {
animation.current_value = from_delay / animation.duration; animation.current_value = from_delay / animation.duration;
if (animation.on_update) if (animation.on_update)
animation.on_update(from_delay, animation.current_value); animation.on_update(from_delay, animation.interpolator(animation.current_value));
} }
} }
} }
......
#ifndef __ANIMATIONMANAGER_H #ifndef __ANIMATIONMANAGER_H
#define __ANIMATIONMANAGER_H #define __ANIMATIONMANAGER_H
#include <vector> // --------------- STDLIB ---------------
#include <memory>
#include <algorithm> #include <algorithm>
#include "Animation.h" #include <functional>
#include <memory>
#include <vector>
// --------------- EXTERN ---------------
// --------------- INTERN ---------------
namespace glare namespace glare
{ {
namespace core namespace core
{ {
class AnimationManager;
struct Animation
{
friend class AnimationManager;
double duration;
double start_delay = 0;
std::function<void(double, double)> on_update;
std::function<void()> on_start;
std::function<void()> on_finish;
std::function<void()> on_cancel;
std::function<double(double)> interpolator = [](double value) { return value; };
private:
//From 0..1
double current_time = 0;
double current_value = 0;
bool has_started = false;
bool mark_finished = false;
};
class AnimationManager class AnimationManager
{ {
public: public:
......
...@@ -14,7 +14,7 @@ namespace glare ...@@ -14,7 +14,7 @@ namespace glare
AudioBuffer::AudioBuffer(const fs::path &from_file) AudioBuffer::AudioBuffer(const fs::path &from_file)
{ {
m_data = io::AudioUtilities::loadWAV(from_file); m_data = audio::loadWAV(from_file);
m_format = format(m_data.bits_per_sample, m_data.channels); m_format = format(m_data.bits_per_sample, m_data.channels);
al::bufferData(m_handle, m_format, unsigned(m_data.data.size()), m_data.sample_rate, m_data.data.data()); al::bufferData(m_handle, m_format, unsigned(m_data.data.size()), m_data.sample_rate, m_data.data.data());
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define __AUDIOBUFFER_H #define __AUDIOBUFFER_H
#include <openal/OpenAL.h> #include <openal/OpenAL.h>
#include <io/AudioUtilities.h> #include <util/audio.h>
namespace glare namespace glare
{ {
...@@ -21,7 +21,7 @@ namespace glare ...@@ -21,7 +21,7 @@ namespace glare
private: private:
al::BufferFormat m_format; al::BufferFormat m_format;
al::handle::buffer m_handle; al::handle::buffer m_handle;
io::AudioUtilities::wav_data_t m_data; audio::wave_t m_data;
}; };
} }
} }
......
...@@ -121,7 +121,7 @@ namespace glare ...@@ -121,7 +121,7 @@ namespace glare
size_at_last_break = 0; size_at_last_break = 0;
continue; continue;
} }
else if (TextUtilities::isLineBreakable(character)) else if (text::isLineBreakable(character))
{ {
size_at_last_break = position_x; size_at_last_break = position_x;
size_from_last_break = 0; size_from_last_break = 0;
...@@ -249,7 +249,7 @@ namespace glare ...@@ -249,7 +249,7 @@ namespace glare
line_offsets.push_back(0); line_offsets.push_back(0);
continue; continue;
} }
else if (TextUtilities::isLineBreakable(character)) else if (text::isLineBreakable(character))
{ {
if (character == ' ') if (character == ' ')
{ {
...@@ -359,7 +359,7 @@ namespace glare ...@@ -359,7 +359,7 @@ namespace glare
position_y -= m_font_face->size->metrics.height >> 6; position_y -= m_font_face->size->metrics.height >> 6;
continue; continue;
} }
else if (TextUtilities::isLineBreakable(norm_character)) else if (text::isLineBreakable(norm_character))
{ {
last_line_break_position = c; last_line_break_position = c;
} }
...@@ -482,7 +482,7 @@ namespace glare ...@@ -482,7 +482,7 @@ namespace glare
std::wstring& Text::operator+=(std::string& text) std::wstring& Text::operator+=(std::string& text)
{ {
return m_text += TextUtilities::toWString(text); return m_text += text::to_wstring(text);
} }
glm::ivec2 Text::measure(glm::vec2 max_dimensions) glm::ivec2 Text::measure(glm::vec2 max_dimensions)
...@@ -517,7 +517,7 @@ namespace glare ...@@ -517,7 +517,7 @@ namespace glare
void Text::set(const std::string text, glm::vec2 max_dimensions) void Text::set(const std::string text, glm::vec2 max_dimensions)
{ {
const auto txt = TextUtilities::toWString(text); const auto txt = text::to_wstring(text);
set(txt, max_dimensions); set(txt, max_dimensions);
} }
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include "engine/Math.h" #include "engine/Math.h"
#include "ImageTexture2D.h" #include "ImageTexture2D.h"
#include "engine/rendering/ShaderProgram.h" #include "engine/rendering/ShaderProgram.h"
#include <engine/TextUtilities.h>
#include <util/color.h> #include <util/color.h>
#include <util/text.h>
namespace glare namespace glare
{ {
......
#include "Material.h" #include "Material.h"
#include "engine/EngineState.h" #include "engine/EngineState.h"
#include <util/files.h>
namespace glare namespace glare
{ {
...@@ -9,8 +10,8 @@ namespace glare ...@@ -9,8 +10,8 @@ namespace glare
Material::Material(std::string name) Material::Material(std::string name)
: Material(name, std::make_shared<ShaderProgram>(std::vector<std::shared_ptr<Shader>>{ : Material(name, std::make_shared<ShaderProgram>(std::vector<std::shared_ptr<Shader>>{
std::make_shared<Shader>(gl::ShaderType::eVertex, shader("simple/simple.vert")), std::make_shared<Shader>(gl::ShaderType::eVertex, files::shader("simple/simple.vert")),
std::make_shared<Shader>(gl::ShaderType::eFragment, shader("simple/simple.frag")) std::make_shared<Shader>(gl::ShaderType::eFragment, files::shader("simple/simple.frag"))
})) }))
{ } { }
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "ImageTexture2D.h" #include "ImageTexture2D.h"
#include <util/files.h>
namespace glare namespace glare
{ {
namespace core namespace core
...@@ -59,8 +61,8 @@ namespace glare ...@@ -59,8 +61,8 @@ namespace glare
inline static std::shared_ptr<Material> makeDepthMaterial() inline static std::shared_ptr<Material> makeDepthMaterial()
{ {
return std::make_shared<Material>("only_depth", std::make_shared<ShaderProgram>(std::vector<std::shared_ptr<Shader>>{ return std::make_shared<Material>("only_depth", std::make_shared<ShaderProgram>(std::vector<std::shared_ptr<Shader>>{
std::make_shared<Shader>(gl::ShaderType::eVertex, shader("simple/simple.vert")), std::make_shared<Shader>(gl::ShaderType::eVertex, files::shader("simple/simple.vert")),
std::make_shared<Shader>(gl::ShaderType::eFragment, shader("simple/no_color.frag")) std::make_shared<Shader>(gl::ShaderType::eFragment, files::shader("simple/no_color.frag"))
})); }));
} }
} }
......
...@@ -49,8 +49,8 @@ namespace glare ...@@ -49,8 +49,8 @@ namespace glare
m_triangle_mesh = std::make_shared<Mesh>(triangle_vertices, indices); m_triangle_mesh = std::make_shared<Mesh>(triangle_vertices, indices);
const auto vert = std::make_shared<Shader>(gl::ShaderType::eVertex, shader("/cubemap/triangle_skybox.vert")); const auto vert = std::make_shared<Shader>(gl::ShaderType::eVertex, files::shader("/cubemap/triangle_skybox.vert"));
const auto frag = std::make_shared<Shader>(gl::ShaderType::eFragment, shader("/cubemap/triangle_skybox.frag")); const auto frag = std::make_shared<Shader>(gl::ShaderType::eFragment, files::shader("/cubemap/triangle_skybox.frag"));
m_cubemap_shader = std::make_shared<ShaderProgram>(std::vector<std::shared_ptr<Shader>>{ frag, vert }); m_cubemap_shader = std::make_shared<ShaderProgram>(std::vector<std::shared_ptr<Shader>>{ frag, vert });
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!