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

Naming conventions standardized, FINAL REFACTORINGgit add -A! Kind of... I...

Naming conventions standardized, FINAL REFACTORINGgit add -A! Kind of... I guess... maybe... 95% sure...
parent 7c90d76f
build
build_VS
.vs
assets/screenshots/*
assets/meshes/*
!assets/meshes/Spheres.dae
assets/textures/*
!assets/textures/ryfjallet
assets/screenshots/*
!assets/screenshots/Readme.md
*.bmf
*.bsmf
build_VS
*.hdr
!assets/textures/ryfjallet
!assets/textures/splash.png
*.hdr
\ No newline at end of file
<scene version="1.0">
<!--
any "source" tag will work as a replacement for all inner parameters.
Therefore, you can put item-sub-tags (for example all "property" tags) into a dedicated file.
All properties which are not given will be set to their according default value.
-->
<textures>
<item id="mat_001_spec" source="file::textures/mat_001_spec.png"/>
<item id="posx" source="file::textures/cm/posx.png"/>
<item id="posy" source="file::textures/cm/posy.png"/>
<item id="posz" source="file::textures/cm/posz.png"/>
<item id="negx" source="file::textures/cm/negx.png"/>
<item id="negy" source="file::textures/cm/negy.png"/>
<item id="negz" source="file::textures/cm/negz.png"/>
</textures>
<materials>
<item id="material.001">
<property name="diffuse" type="color" value="0 0.5 0.8 1"/>
<property name="specular" type="texture" value="textures::mat_001_spec"/>
<property name="shininess" type="uint" value="100"/>
</item>
<!-- Load file containing the properties -->
<item id="material.002" source="file::materials/material.prop">
</materials>
<geometries>
<!-- Use an external binary mesh file format -->
<item id="cube" source="file::meshes/cubemesh.mesh">
</geometries>
<cameras>
<item id="cam_node.camera">
<property name="fov" type="float" value="60"/>
<property name="projection" type="string" value="ortho"/>
</item>
</cameras>
<lights>
<item id="some_light">
<property name="color" type="color" value="5 5 5 5"/>
<property name="type" type="string" value="point"/>
</item>
</lights>
<!--
Objects shall be initialized by themselves by giving them their according data.
That means that they could even have multiple definitions.
-->
<cubemaps>
<item id="my_cubemap">
<property name="type" type="string" value="collection"/>
<property name="collection_source" type="source" value="file::cubemaps/cubemap01"/>
</item>
<item id="my_other_cubemap">
<property name="type" type="string" value="items"/>
<property name="posx" type="source" value="textures::posx"/>
<property name="posy" type="source" value="textures::posy"/>
<property name="posz" type="source" value="textures::posz"/>
<property name="negx" type="source" value="textures::negx"/>
<property name="negy" type="source" value="textures::negy"/>
<property name="negz" type="source" value="textures::negz"/>
</item>
</cubemaps>
<!-- Add your very own component types to be attached to the objects -->
<your_very_own_component_type>
<item id="my_own_component">
<property name="my_property" type="uint" value="5"/>
</item>
</your_very_own_component_type>
<environment>
<background type="cubemap" source="cubemaps::my_cubemap"/>
</environment>
<graph>
<node name="root_node">
<transform matrix="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1"/>
<children>
<node name="sub_node">
<transform matrix="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1"/>
<component type="MeshRenderer">
<mesh source="geometries::cube"/>
<material source="materials::material.001"/>
</component>
</node>
<node name="cam_node">
<transform matrix="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1"/>
<component type="Camera" source="cameras::cam_node.camera"/>
<component type="FramerateCounter" source="file::frc.prop"/>
<component type="PlayerController" source="file::pcont.prop"/>
<component type="MyComponent" source="your_very_own_component_type::my_own_component"/>
</node>
<node name="light_node">
<component type="Light" source="lights::some_light"/>
</node>
</children>
</node>
</graph>
</scene>
<!-- ###################### THIS IS A DIFFERENT FILE ########################## -->
<!-- Example of loading just a collada file -->
<scene>
<cubemaps>
<item id="my_cubemap">
<property name="type" type="string" value="collection"/>
<property name="collection_source" type="source" value="file::cubemaps/cubemap01"/>
</item>
</cubemaps>
<environment>
<background type="cubemap" source="cubemaps::my_cubemap"/>
</environment>
<collada>
<item id="my_scene" source="file::scenes/collada/scene.dae">
<!--Should actually default to true, adds playercontroller and frameratecounter-->
<property name="default_camera_components" type="bool" value="true"/>
</item>
</collada>
<graph source="collada::my_scene::scene01"/>
</scene>
......@@ -7,6 +7,7 @@
# GLFW3_LIBRARY
#
set(GLFW3_DIR ${LIBS_PATH}/glfw3)
if(SYS_WINDOWS)
......
set(LodePNG_DIR ${LIBS_PATH}/lodepng)
FIND_PATH(LodePNG_INCLUDE_PATH lodepng.cpp
${LodePNG_DIR})
include(${CMAKE_MODULE_PATH}/setup/library.cmake)
check_library_nolib(LodePNG)
\ No newline at end of file
......@@ -4,9 +4,6 @@ set(ROOT_PATH ${CMAKE_SOURCE_DIR})
#STRING(REGEX REPLACE "\\\\" "/" ROOT_PATH ${ROOT_PATH} )
#message(${ROOT_PATH})
add_definitions(-DPREFERENCES_PATH="${ROOT_PATH}/preferences/")
file(MAKE_DIRECTORY "${ROOT_PATH}/preferences")
#Assets
add_definitions(-DASSETS_PATH="${ROOT_PATH}/assets/")
file(MAKE_DIRECTORY "${ROOT_PATH}/assets")
......
......@@ -22,9 +22,6 @@ add_definitions(-DGL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED)
#Freetype
find_and_add_library(Freetype REQUIRED LIBRARIES)
#LodePNG
find_and_add_library(LodePNG REQUIRED LIBRARIES)
#STB
find_and_add_library(STB REQUIRED LIBRARIES)
......
......@@ -10,8 +10,8 @@ MACRO(collect_subdirectories result curdir)
ENDMACRO()
MACRO(make_executable result directory)
file(GLOB SOURCE ${directory}/*.cpp)
file(GLOB HEADERS ${directory}/*.h)
file(GLOB_RECURSE SOURCE ${directory}/*.cpp)
file(GLOB_RECURSE HEADERS ${directory}/*.h)
add_executable(${result} ${SOURCE} ${HEADERS})
ENDMACRO()
......
......@@ -3,5 +3,5 @@ project(GLARE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libcmt")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libcmt /ignore:4098,4099")
endif()
\ No newline at end of file
......@@ -2,35 +2,33 @@
#define __GLARE_INCLUDE_CORE
//Core Main
#include <engine/Time.h>
#include <engine/Node.h>
#include <engine/Math.h>
#include <engine/GLWrapper.h>
#include <engine/Console.h>
#include <engine/EngineState.h>
#include <engine/ComponentContainer.h>
#include <core/time.h>
#include <core/window.h>
#include <core/state.h>
#include <util/console.h>
//Core Animation
#include <engine/animation/AnimationManager.h>
#include <core/anim/animations.h>
//Core Graphics
#include <engine/graphics/Camera.h>
#include <engine/graphics/FontManager.h>
#include <engine/graphics/ImageTexture2D.h>
#include <engine/graphics/Light.h>
#include <engine/graphics/Material.h>
#include <engine/graphics/Mesh.h>
#include <engine/graphics/Skybox.h>
//Core Rendering
#include <engine/rendering/Framebuffer.h>
#include <engine/rendering/GBuffer.h>
#include <engine/rendering/GraphNode.h>
#include <engine/rendering/GraphNodeComponent.h>
#include <engine/rendering/LightManager.h>
#include <engine/rendering/MeshRenderer.h>
#include <engine/rendering/Shader.h>
#include <engine/rendering/ShaderProgram.h>
#include <engine/rendering/TextureRenderer.h>
#include <core/res/fonts.h>
#include <core/res/texture2d.h>
#include <core/base/framebuffer.h>
#include <core/base/program.h>
#include <core/base/shader.h>
#include <core/base/buffer.h>
#include <core/objects/camera.h>
#include <core/objects/light.h>
#include <core/objects/material.h>
#include <core/objects/mesh.h>
#include <core/objects/skybox.h>
#include <core/rendering/mesh_renderer.h>
#include <core/rendering/gbuffer.h>
#include <core/rendering/light_manager.h>
#include <core/rendering/texture_renderer.h>
#endif //!__GLARE_INCLUDE_CORE
\ No newline at end of file
#ifndef __GLARE_INCLUDE_IO
#define __GLARE_INCLUDE_IO
#include <io/Resources.h>
#include <io/ArgParser.h>
#endif //!__GLARE_INCLUDE_IO
\ No newline at end of file
#include <glm/glm.hpp>
#include <glm/ext.hpp>
constexpr unsigned radial_subdivision = 3;
glm::vec3 direction(unsigned id)
{
//start at the second row. The first one will be flat against the patch plane and won't hit anything anyways.
unsigned row = id / (4 * radial_subdivision) + 1;
float row_pi_2_subdiv = row * glm::pi<float>() / (2.f * radial_subdivision);
float up = glm::sin(row_pi_2_subdiv);
float plane_scale = glm::cos(row_pi_2_subdiv);
float id_pi_2_subdiv = id * glm::pi<float>() / (2.f * radial_subdivision);
float x = glm::sin(id_pi_2_subdiv);
float y = glm::cos(id_pi_2_subdiv);
glm::vec2 scaled(x, y);
scaled *= plane_scale;
glm::vec3 direction;
//this is "up"
direction[1] = up;
//this is "horizontal"
direction[0] = scaled.x;
//this is "vertical"
direction[2] = scaled.y;
return direction;
}
unsigned last()
{
return ;
}
unsigned id(glm::vec3 direction)
{
glm::vec3 normal(0, 1, 0);
glm::vec3 horz(1, 0, 0);
glm::vec3 vert(0, 0, 1);
float up = glm::dot(normal, direction);
unsigned row = unsigned(glm::round((2.f * radial_subdivision) * glm::asin(up) / glm::pi<float>())) - 1;
if (row >= radial_subdivision - 1) {
//I'll return here because there might be some issues with normalizing a near-zero planar direction later on.
return 4 * radial_subdivision * (radial_subdivision - 1);
}
glm::vec2 planar_direction = glm::normalize(glm::vec2(glm::dot(horz, direction), glm::dot(vert, direction)));
int id_x = unsigned(glm::round((2.f * radial_subdivision) * (glm::asin(planar_direction.x) / glm::pi<float>())));
//goes from 0->0 to r/2->r/2 and counts down afterwards.
int id_y = unsigned(glm::round((2.f * radial_subdivision) * (glm::acos(planar_direction.y) / glm::pi<float>())));
return 4 * radial_subdivision*row + (id_x >= 0 ? id_y : (4 * radial_subdivision - id_y));
}
int main(int argc, char* argv[])
{
auto dir0sdf = direction(0);
auto dir1553 = direction(1);
auto dirbggea = direction(2);
auto dir0ah = direction(3);
auto dir1htz53 = direction(4);
auto dirbu57 = direction(5);
auto dir0aag = direction(6);
auto dir1afg53 = direction(7);
auto dirb = direction(8);
auto dir0 = direction(9);
auto dir1gs53 = direction(10);
auto dirgsb = direction(11);
auto dir2sw35 = direction(16);
auto dir2ss35 = direction(22);
auto dir2s35 = direction(24);
auto aidi = id(dir0sdf);
auto aidi314 = id(dir1553);
auto aidi4214 = id(dirbggea);
auto aidi2903 = id(dir0ah);
auto atdiq = id(dir1htz53);
auto aidi3t3a414 = id(dirbu57);
auto aidi634afa214 = id(dir0aag);
auto aidiaaaaaf2903 = id(dir1afg53);
auto atdiasf = id(dirb);
auto aidi3t3ff414 = id(dir0);
auto aidi6342aa14 = id(dir1gs53);
auto aidiaaa290ayy3 = id(dirgsb);
auto aidiawwtwy3 = id(dir2sw35);
auto aidiaaappy3 = id(dir2ss35);
auto aidiaaasdyy3 = id(dir2s35);
return 0;
}
\ No newline at end of file
#include "Game.h"
#include "Map.h"
#include "game.h"
#include <array>
#include <util/files.h>
#include <pugixml/pugixml.hpp>
#include <core/res/resources.h>
#include "src/map.h"
Game::Game()
{
......@@ -19,16 +23,16 @@ void Game::onKeyDown(controls::Key key, controls::KeyMods mods)
switch (key)
{
case controls::Key::e0:
//core::EngineState::main_camera->setProjection(core::Camera::Projection::eOrthographic);
//core::state::camera->setProjection(core::Camera::Projection::eOrthographic);
mode = 0;
break;
case controls::Key::e1:
mode = 1;
//core::EngineState::main_camera->setProjection(core::Camera::Projection::ePerspective);
//core::state::camera->setProjection(core::Camera::Projection::ePerspective);
break;
case controls::Key::e2:
mode = 2;
//core::EngineState::main_camera->setProjection(core::Camera::Projection::ePerspective);
//core::state::camera->setProjection(core::Camera::Projection::ePerspective);
break;
default:
break;
......@@ -45,27 +49,27 @@ void Game::initialize()
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.vsync = VSync(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, m_config.window_title);
core::state::initialize(m_config.window_width, m_config.window_height, m_config.window_title);
m_skybox = std::make_shared<core::Skybox>(core::Skybox::collectFilesFrom(files::asset("/textures/sky/")));
std::vector<float> bla(2);
ImGui::glfw3::init(core::EngineState::opengl_core->getWindow(), false);
ImGui::glfw3::init(core::state::window->glfw(), false);
gl::setEnabled(gl::EnableParameter::eMultisample, true);
m_gbuffer = std::make_unique<core::GBuffer>(m_config.window_width, m_config.window_height, m_config.sample_count);
m_gbuffer->setSkybox(m_skybox);
core::EngineState::opengl_core->setVSync(VSyncMode::eOff);
core::state::window->setVSync(VSync::eOff);
core::Callbacks::addKeyDownCallback("main_application", std::bind(&Game::onKeyDown, this, std::placeholders::_1, std::placeholders::_2));
// Make Camera
auto cam_node = std::make_shared<core::GraphNode>("custom_camera");
cam_node->addComponent(core::EngineState::main_camera);
cam_node->addComponent(core::state::camera);
cam_node->makeComponent<component::PlayerController>();
cam_node->makeComponent<component::FramerateCounter>();
......@@ -90,12 +94,12 @@ void Game::initialize()
terrain_node->addComponent(map.getMesh());
//Initialize root node
core::EngineState::graph_root->attach(environment_node);
core::EngineState::graph_root->attach(terrain_node);
core::EngineState::graph_root->attach(cam_node);
core::state::graph_root->attach(environment_node);
core::state::graph_root->attach(terrain_node);
core::state::graph_root->attach(cam_node);
//Attach plane as child in front of the camera.
auto plane = io::Resources::getInstance().getColladaMesh(files::asset("meshes/scenery/plane.dae"), "Cube");
auto plane = core::Resources::getInstance().getColladaMesh(files::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 });
......@@ -104,11 +108,11 @@ void Game::initialize()
sun_node->transform()->rotate({ glm::radians(50.f), 0, 0 });
glare::core::EngineState::opengl_core->loop([&](double delta)
glare::core::state::window->loop([&](double delta)
{
// General state updates (camera and so on)
ImGui::glfw3::newFrame();
glare::core::EngineState::update();
glare::core::state::update();
//Simulate a sun for a day and night cycle.
......@@ -120,15 +124,15 @@ void Game::initialize()
}*/
//Build shadow map after setting the environment node position to the current camera one's as the shadow will be local.
environment_node->transform()->position = core::EngineState::main_camera->getOwner()->transform()->position;
//shadow_map_renderer.build(glare::core::EngineState::graph_root);
environment_node->transform()->position = core::state::camera->getOwner()->transform()->position;
//shadow_map_renderer.build(glare::core::state::graph_root);
switch (mode) {
case 0: {
//Record and render gbuffer
m_gbuffer->activate();
m_skybox->draw();
glare::core::EngineState::graph_root->draw();
glare::core::state::graph_root->draw();
m_gbuffer->deactivate();
m_gbuffer->draw(); //... with shadow map ;)
} break;
......@@ -136,15 +140,15 @@ void Game::initialize()
gl::viewport(0, 0, 1024, 1024);
texrend->draw(light_sun->shadowMapRenderer().framebuffer().colorAttachment(gl::Attachment::eColor0));
gl::viewport(0, 0, unsigned(core::EngineState::main_camera->getWidth()),
unsigned(core::EngineState::main_camera->getWidth() / core::EngineState::main_camera->getAspectRatio()));
gl::viewport(0, 0, unsigned(core::state::camera->getWidth()),
unsigned(core::state::camera->getWidth() / core::state::camera->getAspectRatio()));
} break;
case 2: {
gl::viewport(0, 0, 1024, 1024);
texrend->draw(light_sun->shadowMapRenderer().framebuffer().depthAttachment());
gl::viewport(0, 0, unsigned(core::EngineState::main_camera->getWidth()),
unsigned(core::EngineState::main_camera->getWidth() / core::EngineState::main_camera->getAspectRatio()));
gl::viewport(0, 0, unsigned(core::state::camera->getWidth()),
unsigned(core::state::camera->getWidth() / core::state::camera->getAspectRatio()));
} break;
}
ImGui::Render();
......
......@@ -2,7 +2,6 @@
#define __GAME_H
#include <glare_core>
#include <glare_io>
#include <glare_gui>
#include <util/singleton.h>
......@@ -27,7 +26,7 @@ private:
struct
{
VSyncMode vsync;
VSync vsync;
unsigned window_width;
unsigned window_height;
unsigned sample_count;
......
#include "Game.h"
#include "game.h"
int main(int argc, char* argv[])
{
......
#include "Map.h"
#include "map.h"
#include <pugixml/pugixml.hpp>
#include <io/Resources.h>
#include <core/res/resources.h>
#include <util/color.h>
#include <util/files.h>
#include <engine/graphics/ImageTexture2D.h>
#include <core/res/texture2d.h>
namespace glare
{
......@@ -255,10 +256,10 @@ namespace glare
material->color_diffuse = color::preset::white.rgb;
material->color_specular = 2 * color::preset::white.rgb;
material->specular_exponent = 80;
material->map_diffuse = io::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048.png"));
material->map_normal = io::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_n.png"));
material->map_displacement = io::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_h.png"));
material->map_specular = io::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_s.png"));
material->map_diffuse = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048.png"));
material->map_normal = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_n.png"));
material->map_displacement = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_h.png"));
material->map_specular = core::Resources::getInstance().getTexture(files::asset("meshes/scenery/gravel_medium2048_s.png"));
return material;
}
......
#ifndef __MAP_H
#define __MAP_H
#include <engine/rendering/MeshRenderer.h>
#include <filesystem>
#include <map>
#include <core/rendering/mesh_renderer.h>
namespace glare
{
namespace game
......
#include <core/numeric/flags.h>
enum class SomeEnum
{
eOne = 1 << 0,
eTwo = 1 << 1,
eThree = 1 << 2,
eFour = 1 << 3,
};
int main(int argc, char* argv[])
{
math::Flags flags;
struct bla
{
int i = 0;
float a = 4;
};
bla x;
bool set = flags & SomeEnum::eOne;
unsigned i = 0;
bool inv = ~flags;