Ghettomerge

This commit is contained in:
Tobias Dahl
2014-03-11 22:32:49 +01:00
parent 33dbcc10a1
commit bb6cc1a23e
41 changed files with 892 additions and 648 deletions
-15
View File
@@ -3,13 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Escape-the-Dawn", "Escape-the-Dawn\Escape-the-Dawn.vcxproj", "{FE405CFA-8FCE-4867-92CF-797E73B36482}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tests", "Tests\Tests.vcxproj", "{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}"
ProjectSection(ProjectDependencies) = postProject
{A9755CAA-62DC-442D-B82C-F548546CFD38} = {A9755CAA-62DC-442D-B82C-F548546CFD38}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Executable", "Executable\Executable.vcxproj", "{A9755CAA-62DC-442D-B82C-F548546CFD38}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -20,14 +13,6 @@ Global
{FE405CFA-8FCE-4867-92CF-797E73B36482}.Debug|Win32.Build.0 = Debug|Win32
{FE405CFA-8FCE-4867-92CF-797E73B36482}.Release|Win32.ActiveCfg = Release|Win32
{FE405CFA-8FCE-4867-92CF-797E73B36482}.Release|Win32.Build.0 = Release|Win32
{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}.Debug|Win32.ActiveCfg = Debug|Win32
{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}.Debug|Win32.Build.0 = Debug|Win32
{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}.Release|Win32.ActiveCfg = Release|Win32
{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}.Release|Win32.Build.0 = Release|Win32
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Debug|Win32.ActiveCfg = Debug|Win32
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Debug|Win32.Build.0 = Debug|Win32
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Release|Win32.ActiveCfg = Release|Win32
{A9755CAA-62DC-442D-B82C-F548546CFD38}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+2 -7
View File
@@ -1,17 +1,12 @@
#include <string>
#include <sstream>
#include <GL/glew.h>
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include <glext.h>
#include "Renderer.h"
#include "GameWorld.h"
#include "logging.h"
#include "glerror.h"
#include "Renderer.h"
#include "GameWorld.h"
class Engine
{
public:
+11 -6
View File
@@ -16,13 +16,13 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
@@ -40,7 +40,7 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LibraryPath>$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Debug;$(SolutionDir)\Libraries\SOIL\lib\Debug;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath)</LibraryPath>
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Debug;$(SolutionDir)\Libraries\SOIL\lib\Debug;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)bin\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
@@ -50,7 +50,7 @@
<IncludePath>$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LibraryPath>$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Release;$(SolutionDir)\Libraries\SOIL\lib\Release;$(SolutionDir)\Libraries\glew-1.10.0\lib\Release\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Release;$(LibraryPath)</LibraryPath>
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32\Release;$(SolutionDir)\Libraries\SOIL\lib\Release;$(SolutionDir)\Libraries\glew-1.10.0\lib\Release\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Release;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)bin\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
<TargetName>$(ProjectName)-$(Configuration)</TargetName>
@@ -65,7 +65,7 @@
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>opengl32.lib;glu32.lib;glew32sd.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OpenAL32.lib;opengl32.lib;glu32.lib;SOIL.lib;glew32sd.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent />
<PostBuildEvent />
@@ -90,7 +90,7 @@
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>opengl32.lib;glu32.lib;glew32s.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>OpenAL32.lib;opengl32.lib;glu32.lib;SOIL.lib;glew32s.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Lib>
<AdditionalDependencies>OpenAL32.lib;opengl32.lib;glu32.lib;SOIL.lib;glew32s.lib;glfw3.lib;</AdditionalDependencies>
@@ -101,7 +101,9 @@
<ClCompile Include="Engine.h" />
<ClCompile Include="Frame.cpp" />
<ClCompile Include="GameFrame.cpp" />
<ClCompile Include="GameWorld.cpp" />
<ClCompile Include="GUIManager.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="MenuFrame.cpp" />
<ClCompile Include="Model.cpp" />
<ClCompile Include="OBJ.cpp" />
@@ -147,6 +149,7 @@
<ClInclude Include="MenuFrame.h" />
<ClInclude Include="Model.h" />
<ClInclude Include="OBJ.h" />
<ClInclude Include="OpenGL.h" />
<ClInclude Include="Renderer.h" />
<ClInclude Include="ShaderProgram.h" />
<ClInclude Include="Systems\InputSystem.h" />
@@ -164,6 +167,8 @@
<ItemGroup>
<None Include="Fragment2.glsl" />
<None Include="Shaders\Fragment.glsl" />
<None Include="Shaders\Normals.frag.glsl" />
<None Include="Shaders\Normals.geo.glsl" />
<None Include="Shaders\Vertex.glsl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
@@ -45,6 +45,8 @@
</ClCompile>
<ClCompile Include="Camera.cpp" />
<ClCompile Include="OBJ.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="GameWorld.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Component.h" />
@@ -144,6 +146,7 @@
<ClInclude Include="GameWorld.h" />
<ClInclude Include="Camera.h" />
<ClInclude Include="OBJ.h" />
<ClInclude Include="OpenGL.h" />
</ItemGroup>
<ItemGroup>
<None Include="Shaders\Fragment.glsl">
@@ -152,6 +155,12 @@
<None Include="Shaders\Vertex.glsl">
<Filter>Shaders</Filter>
</None>
<None Include="Shaders\Normals.geo.glsl">
<Filter>Shaders</Filter>
</None>
<None Include="Shaders\Normals.frag.glsl">
<Filter>Shaders</Filter>
</None>
<None Include="Fragment2.glsl">
<Filter>Shaders</Filter>
</None>
@@ -0,0 +1,186 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="World.cpp" />
<ClCompile Include="Systems\CollisionSystem.cpp">
<Filter>Systems</Filter>
</ClCompile>
<ClCompile Include="Systems\LevelGenerationSystem.cpp">
<Filter>Systems</Filter>
</ClCompile>
<ClCompile Include="Systems\InputSystem.cpp">
<Filter>Systems</Filter>
</ClCompile>
<ClCompile Include="Systems\ParticleSystem.cpp">
<Filter>Systems</Filter>
</ClCompile>
<ClCompile Include="Systems\PlayerSystem.cpp">
<Filter>Systems</Filter>
</ClCompile>
<ClCompile Include="Systems\RenderSystem.cpp">
<Filter>Systems</Filter>
</ClCompile>
<ClCompile Include="Systems\SoundsSystem.cpp">
<Filter>Systems</Filter>
</ClCompile>
<ClCompile Include="Model.cpp" />
<ClCompile Include="Engine.h" />
<ClCompile Include="Texture.cpp" />
<ClCompile Include="GUIManager.cpp">
<Filter>GUI</Filter>
</ClCompile>
<ClCompile Include="Renderer.cpp" />
<ClCompile Include="ShaderProgram.cpp" />
<ClCompile Include="Frame.cpp">
<Filter>GUI</Filter>
</ClCompile>
<ClCompile Include="TextFrame.cpp">
<Filter>GUI</Filter>
</ClCompile>
<ClCompile Include="MenuFrame.cpp">
<Filter>GUI</Filter>
</ClCompile>
<ClCompile Include="GameFrame.cpp">
<Filter>GUI</Filter>
</ClCompile>
<ClCompile Include="Camera.cpp" />
<ClCompile Include="OBJ.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="GameWorld.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Component.h" />
<ClInclude Include="Entity.h" />
<ClInclude Include="System.h" />
<ClInclude Include="World.h" />
<ClInclude Include="Systems\CollisionSystem.h">
<Filter>Systems</Filter>
</ClInclude>
<ClInclude Include="Systems\LevelGenerationSystem.h">
<Filter>Systems</Filter>
</ClInclude>
<ClInclude Include="Systems\InputSystem.h">
<Filter>Systems</Filter>
</ClInclude>
<ClInclude Include="Systems\ParticleSystem.h">
<Filter>Systems</Filter>
</ClInclude>
<ClInclude Include="Systems\PlayerSystem.h">
<Filter>Systems</Filter>
</ClInclude>
<ClInclude Include="Systems\RenderSystem.h">
<Filter>Systems</Filter>
</ClInclude>
<ClInclude Include="Systems\SoundSystem.h">
<Filter>Systems</Filter>
</ClInclude>
<ClInclude Include="Model.h" />
<ClInclude Include="Components\Transform.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="ShaderProgram.h" />
<ClInclude Include="Components\Input.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Components\Model.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Components\ParticleEmitter.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Components\PointLight.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Components\PowerUp.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Components\Sprite.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Components\Stat.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Components\Template.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Components\SoundEmitter.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Color.h" />
<ClInclude Include="Factory.h" />
<ClInclude Include="Components\DirectionalLight.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Components\Collision.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Components\Camera.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="Components\Bounds.h">
<Filter>Components</Filter>
</ClInclude>
<ClInclude Include="glerror.h">
<Filter>Util</Filter>
</ClInclude>
<ClInclude Include="logging.h">
<Filter>Util</Filter>
</ClInclude>
<ClInclude Include="Renderer.h" />
<ClInclude Include="Texture.h" />
<ClInclude Include="GUIManager.h">
<Filter>GUI</Filter>
</ClInclude>
<ClInclude Include="Frame.h">
<Filter>GUI</Filter>
</ClInclude>
<ClInclude Include="TextFrame.h">
<Filter>GUI</Filter>
</ClInclude>
<ClInclude Include="MenuFrame.h">
<Filter>GUI</Filter>
</ClInclude>
<ClInclude Include="GameFrame.h">
<Filter>GUI</Filter>
</ClInclude>
<ClInclude Include="GameWorld.h" />
<ClInclude Include="Camera.h" />
<ClInclude Include="OBJ.h" />
<ClInclude Include="OpenGL.h" />
</ItemGroup>
<ItemGroup>
<None Include="Shaders\Fragment.glsl">
<Filter>Shaders</Filter>
</None>
<None Include="Shaders\Vertex.glsl">
<Filter>Shaders</Filter>
</None>
<<<<<<< HEAD
<None Include="Fragment2.glsl">
=======
<None Include="Shaders\Normals.geo.glsl">
<Filter>Shaders</Filter>
</None>
<None Include="Shaders\Normals.frag.glsl">
>>>>>>> origin/master
<Filter>Shaders</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Filter Include="Systems">
<UniqueIdentifier>{657e11f4-52e7-4336-b77f-80f00b85c33f}</UniqueIdentifier>
</Filter>
<Filter Include="Components">
<UniqueIdentifier>{59929465-a139-43b9-9c75-48121d156e78}</UniqueIdentifier>
</Filter>
<Filter Include="Shaders">
<UniqueIdentifier>{54f1eb6f-dc00-4e97-a3ef-ac255d755e2e}</UniqueIdentifier>
</Filter>
<Filter Include="Util">
<UniqueIdentifier>{d985d7a7-c041-46fe-ae03-aa40295a7aad}</UniqueIdentifier>
</Filter>
<Filter Include="GUI">
<UniqueIdentifier>{7bdb0f69-049e-4f16-b271-2495e02e4b28}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
+114
View File
@@ -0,0 +1,114 @@
#include "GameWorld.h"
void GameWorld::Initialize()
{
World::Initialize();
//AddSystem("LevelGenerationSystem");
AddSystem("InputSystem");
//AddSystem("CollisionSystem");
//AddSystem("ParticleSystem");
AddSystem("PlayerSystem");
AddSystem("SoundSystem");
AddSystem("RenderSystem");
std::shared_ptr<Components::Transform> transform;
std::shared_ptr<Components::Model> model;
std::shared_ptr<Components::PointLight> pointLight;
std::shared_ptr<Components::Camera> camera;
EntityID ent;
// Camera
ent = CreateEntity();
SetProperty(ent, "Name", std::string("Camera"));
transform = AddComponent<Components::Transform>(ent, "Transform");
AddComponent<Components::Input>(ent, "Input");
transform->Position = glm::vec3(0.f, 2.f, 10.f);
camera = AddComponent<Components::Camera>(ent, "Camera");
camera->FOV = 45.f;
camera->FarClip = 1000.f;
camera->NearClip = 0.01f;
transform->Orientation = glm::angleAxis<float>(glm::radians(25.0f),glm::vec3(1,0,0));
// Fucking lights
ent = CreateEntity();
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(0.f, 4.f, 0.f);
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 1.f;
pointLight->quadraticAttenuation = 0.f;
pointLight->spotExponent = 0.0f;
ent = CreateEntity();
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(10.f, 4.f, 0.f);
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 1.f;
pointLight->quadraticAttenuation = 0.f;
pointLight->spotExponent = 0.0f;
ent = CreateEntity();
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(0.f, -4.f, 0.f);
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 1.f;
pointLight->quadraticAttenuation = 0.f;
pointLight->spotExponent = 0.0f;
// Player
ent = CreateEntity();
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(10.f, 0.f, 0.f);
model = AddComponent<Components::Model>(ent, "Model");
model->ModelFile = "ship.obj";
auto soundEmitter = AddComponent<Components::SoundEmitter>(ent, "SoundEmitter");
soundEmitter->Gain = 0.1f;
soundEmitter->MaxDistance = FLT_MAX;
soundEmitter->ReferenceDistance = 10;
soundEmitter->Loop = true;
soundEmitter->Pitch = 0;
//GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(soundEmitter, "Sounds/hallelujah.wav");
}
void GameWorld::Update(double dt)
{
World::Update(dt);
}
void GameWorld::RegisterComponents()
{
m_ComponentFactory.Register("Bounds", []() { return new Components::Bounds(); });
m_ComponentFactory.Register("Camera", []() { return new Components::Camera(); });
m_ComponentFactory.Register("Collision", []() { return new Components::Collision(); });
m_ComponentFactory.Register("DirectionalLight", []() { return new Components::DirectionalLight(); });
m_ComponentFactory.Register("Input", []() { return new Components::Input(); });
m_ComponentFactory.Register("Model", []() { return new Components::Model(); });
m_ComponentFactory.Register("ParticleEmitter", []() { return new Components::ParticleEmitter(); });
m_ComponentFactory.Register("PointLight", []() { return new Components::PointLight(); });
m_ComponentFactory.Register("PowerUp", []() { return new Components::PowerUp(); });
m_ComponentFactory.Register("SoundEmitter", []() { return new Components::SoundEmitter(); });
m_ComponentFactory.Register("Sprite", []() { return new Components::Sprite(); });
m_ComponentFactory.Register("Stat", []() { return new Components::Stat(); });
m_ComponentFactory.Register("Template", []() { return new Components::Template(); });
m_ComponentFactory.Register("Transform", []() { return new Components::Transform(); });
}
void GameWorld::RegisterSystems()
{
//m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); });
m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_Renderer); });
//m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
//m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); });
m_SystemFactory.Register("PlayerSystem", [this]() { return new Systems::PlayerSystem(this); });
m_SystemFactory.Register("SoundSystem", [this]() { return new Systems::SoundSystem(this); });
m_SystemFactory.Register("RenderSystem", [this]() { return new Systems::RenderSystem(this, m_Renderer); });
}
+2 -124
View File
@@ -30,7 +30,8 @@
class GameWorld : public World
{
public:
GameWorld(std::shared_ptr<Renderer> renderer);
GameWorld(std::shared_ptr<Renderer> renderer)
: m_Renderer(renderer), World() { }
void Initialize() override;
void RegisterSystems() override;
@@ -42,127 +43,4 @@ private:
std::shared_ptr<Renderer> m_Renderer;
};
GameWorld::GameWorld(std::shared_ptr<Renderer> renderer)
: m_Renderer(renderer), World()
{
}
void GameWorld::Initialize()
{
World::Initialize();
//AddSystem("LevelGenerationSystem");
AddSystem("InputSystem");
//AddSystem("CollisionSystem");
//AddSystem("ParticleSystem");
AddSystem("PlayerSystem");
AddSystem("SoundSystem");
AddSystem("RenderSystem");
std::shared_ptr<Components::Transform> transform;
std::shared_ptr<Components::Model> model;
std::shared_ptr<Components::PointLight> pointLight;
std::shared_ptr<Components::Camera> camera;
EntityID ent;
ent = CreateEntity();
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(0.f, 4.f, 0.f);
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 1.f;
pointLight->quadraticAttenuation = 0.f;
pointLight->spotExponent = 0.0f;
ent = CreateEntity();
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(10.f, 4.f, 0.f);
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 1.f;
pointLight->quadraticAttenuation = 0.f;
pointLight->spotExponent = 0.0f;
ent = CreateEntity();
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(0.f, -4.f, 0.f);
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 1.f;
pointLight->quadraticAttenuation = 0.f;
pointLight->spotExponent = 0.0f;
ent = CreateEntity();
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(10.f, 0.f, 0.f);
model = AddComponent<Components::Model>(ent, "Model");
model->ModelFile = "ship.obj";
ent = CreateEntity();
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(0.f, 0.f, 0.f);
model = AddComponent<Components::Model>(ent, "Model");
model->ModelFile = "ship.obj";
// auto soundEmitter = AddComponent<Components::SoundEmitter>(ent, "SoundEmitter");
// soundEmitter->Gain = 1;
// soundEmitter->MaxDistance = FLT_MAX;
// soundEmitter->ReferenceDistance = 10;
// soundEmitter->Loop = true;
// soundEmitter->ReferenceDistance = 0.1;
// soundEmitter->Pitch = 1;
// GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(soundEmitter, "Sounds/hallelujah.wav");
ent = CreateEntity();
SetProperty(ent, "Name", std::string("Camera"));
transform = AddComponent<Components::Transform>(ent, "Transform");
AddComponent<Components::Input>(ent, "Input");
transform->Position = glm::vec3(0.f, 2.f, 10.f);
camera = AddComponent<Components::Camera>(ent, "Camera");
camera->FOV = 45.f;
camera->FarClip = 1000.f;
camera->NearClip = 0.01f;
transform->Orientation = glm::angleAxis<float>(glm::radians(25.0f),glm::vec3(1,0,0));
}
void GameWorld::RegisterSystems()
{
//m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); });
m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_Renderer); });
//m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
//m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); });
m_SystemFactory.Register("PlayerSystem", [this]() { return new Systems::PlayerSystem(this); });
m_SystemFactory.Register("SoundSystem", [this]() { return new Systems::SoundSystem(this); });
m_SystemFactory.Register("RenderSystem", [this]() { return new Systems::RenderSystem(this, m_Renderer); });
}
void GameWorld::RegisterComponents()
{
m_ComponentFactory.Register("Bounds", []() { return new Components::Bounds(); });
m_ComponentFactory.Register("Camera", []() { return new Components::Camera(); });
m_ComponentFactory.Register("Collision", []() { return new Components::Collision(); });
m_ComponentFactory.Register("DirectionalLight", []() { return new Components::DirectionalLight(); });
m_ComponentFactory.Register("Input", []() { return new Components::Input(); });
m_ComponentFactory.Register("Model", []() { return new Components::Model(); });
m_ComponentFactory.Register("ParticleEmitter", []() { return new Components::ParticleEmitter(); });
m_ComponentFactory.Register("PointLight", []() { return new Components::PointLight(); });
m_ComponentFactory.Register("PowerUp", []() { return new Components::PowerUp(); });
m_ComponentFactory.Register("SoundEmitter", []() { return new Components::SoundEmitter(); });
m_ComponentFactory.Register("Sprite", []() { return new Components::Sprite(); });
m_ComponentFactory.Register("Stat", []() { return new Components::Stat(); });
m_ComponentFactory.Register("Template", []() { return new Components::Template(); });
m_ComponentFactory.Register("Transform", []() { return new Components::Transform(); });
}
void GameWorld::Update(double dt)
{
World::Update(dt);
}
#endif // GameWorld_h__
+16 -12
View File
@@ -42,6 +42,7 @@ private:
std::shared_ptr<Renderer> m_Renderer;
};
<<<<<<< HEAD
GameWorld::GameWorld(std::shared_ptr<Renderer> renderer)
: m_Renderer(renderer), World()
{
@@ -88,6 +89,17 @@ void GameWorld::Initialize()
pointLight->quadraticAttenuation = 0.f;
pointLight->spotExponent = 0.0f;
ent = CreateEntity();
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(0.f, -4.f, 0.f);
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 1.f;
pointLight->quadraticAttenuation = 0.f;
pointLight->spotExponent = 0.0f;
ent = CreateEntity();
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(10.f, 0.f, 0.f);
@@ -99,24 +111,14 @@ void GameWorld::Initialize()
transform->Position = glm::vec3(0.f, 0.f, 0.f);
model = AddComponent<Components::Model>(ent, "Model");
model->ModelFile = "ship.obj";
<<<<<<< HEAD
// auto soundEmitter = AddComponent<Components::SoundEmitter>(ent, "SoundEmitter");
// soundEmitter->Gain = 1;
// soundEmitter->MaxDistance = 10;
// soundEmitter->MaxDistance = FLT_MAX;
// soundEmitter->ReferenceDistance = 10;
// soundEmitter->Loop = true;
// soundEmitter->ReferenceDistance = 0.1;
// soundEmitter->Pitch = 1;
// GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(soundEmitter, "Sounds/hallelujah.wav");
=======
auto soundEmitter = AddComponent<Components::SoundEmitter>(ent, "SoundEmitter");
soundEmitter->Gain = 1;
soundEmitter->MaxDistance = FLT_MAX;
soundEmitter->ReferenceDistance = 10;
soundEmitter->Loop = true;
soundEmitter->Pitch = 1;
GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(soundEmitter, "Sounds/hallelujah.wav");
>>>>>>> 2c4d8fde9951da98e1e8527bba48ce3cd16d309c
ent = CreateEntity();
SetProperty(ent, "Name", std::string("Camera"));
@@ -164,4 +166,6 @@ void GameWorld::Update(double dt)
World::Update(dt);
}
=======
>>>>>>> origin/master
#endif // GameWorld_h__
+45 -2
View File
@@ -3,12 +3,55 @@
Model::Model(const char* path)
{
Loadobj(path, Vertices, Normals, TextureCoords);
CreateBuffers(Vertices, Normals, TextureCoords);
}
Model::Model(OBJ &obj)
{
OBJ::MaterialInfo* currentMaterial = nullptr;
TextureGroup* currentTexGroup = nullptr;
int index = 0;
for (auto face : obj.Faces) {
// New material
if (face.Material != currentMaterial) {
currentMaterial = face.Material;
// Load texture
std::shared_ptr<Texture> texture = std::make_shared<Texture>(currentMaterial->TextureFile);
// TODO: Load material parameters
// Create new texture group (start index of new group is upcoming index)
TextureGroup texGroup = { texture, index, index };
TextureGroups.push_back(texGroup);
currentTexGroup = &TextureGroups.back();
}
// Face definitions
for (auto faceDef : face.Definitions) {
glm::vec3 vertex;
std::tie(vertex.x, vertex.y, vertex.z) = obj.Vertices.at(faceDef.VertexIndex - 1);
Vertices.push_back(vertex);
if (faceDef.NormalIndex != 0) {
glm::vec3 normal;
std::tie(normal.x, normal.y, normal.z) = obj.Normals.at(faceDef.NormalIndex - 1);
Normals.push_back(normal);
}
if (faceDef.TextureCoordIndex != 0) {
glm::vec2 texCoord;
// TODO: W-coord?
std::tie(texCoord.x, texCoord.y, std::ignore) = obj.TextureCoords.at(faceDef.TextureCoordIndex - 1);
TextureCoords.push_back(texCoord);
}
currentTexGroup->EndIndex = index;
index++;
}
}
CreateBuffers(Vertices, Normals, TextureCoords);
}
bool Model::Loadobj(const char* path, std::vector <glm::vec3> & out_vertices, std::vector <glm::vec3> &out_normals, std::vector <glm::vec2> & out_TextureCoords)
{
std::vector< unsigned int > vertexIndices, TextureCoordIndices, normalIndices;
+23 -14
View File
@@ -8,37 +8,48 @@
#include <vector>
#include <memory>
#define _CRT_SECURE_NO_WARNINGS
#include <GL/glew.h>
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include <glext.h>
#define GLM_FORCE_RADIANS
#include "OpenGL.h"
#include <glm/glm.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "glerror.h"
#include <cstdlib>
#include <stack>
#include "glerror.h"
#include "Texture.h"
#include "OBJ.h"
class Model
{
public:
Model(OBJ &obj);
Model(const char* path);
struct TextureGroup
{
std::shared_ptr<Texture> Texture;
unsigned int StartIndex;
unsigned int EndIndex;
};
GLuint VAO;
std::vector<TextureGroup> TextureGroups;
std::vector<std::shared_ptr<Texture>> texture;
glm::mat4 GetMatrix();
std::vector<glm::vec3> Vertices;
private:
std::vector<glm::vec3> Normals;
std::vector<glm::vec2> TextureCoords;
GLuint VertexBuffer;
GLuint NormalBuffer;
GLuint TextureCoordBuffer;
GLuint VAO;
std::vector<std::shared_ptr<Texture>> texture;
Model(const char* path);
bool Loadobj(
const char* path,
@@ -47,8 +58,6 @@ public:
std::vector <glm::vec2> & out_TextureCoords
);
glm::mat4 GetMatrix();
void CreateBuffers(
std::vector<glm::vec3> _Vertices,
std::vector<glm::vec3> _Normals,
+17 -4
View File
@@ -5,13 +5,18 @@ OBJ::OBJ()
m_CurrentMaterial = nullptr;
}
void OBJ::LoadFromFile(std::string filename)
bool OBJ::LoadFromFile(std::string filename)
{
m_Path = boost::filesystem::path(filename);
LOG_INFO("Parsing .obj \"%s\"", m_Path.c_str());
// http://paulbourke.net/dataformats/obj/
std::ifstream file(m_Path.string());
if (!file.is_open()) {
LOG_ERROR("Failed to open .obj \"%s\"", m_Path.string().c_str());
return false;
}
LOG_INFO("Parsing .obj \"%s\"", m_Path.string().c_str());
std::string line;
while (std::getline(file, line)) {
@@ -74,7 +79,7 @@ void OBJ::LoadFromFile(std::string filename)
std::string faceDefString;
while (ss >> faceDefString) {
std::stringstream ss2(faceDefString);
FaceDefinition faceDef = { -1, -1, -1 };
FaceDefinition faceDef = { 0, 0, 0 };
ss2 >> faceDef.VertexIndex;
ss2.ignore(); // Ignore first delimiter
@@ -94,12 +99,20 @@ void OBJ::LoadFromFile(std::string filename)
Faces.push_back(face);
}
}
return true;
}
void OBJ::ParseMaterial()
{
// http://paulbourke.net/dataformats/mtl/
std::ifstream file(m_MaterialPath.string());
if (!file.is_open()) {
LOG_ERROR("Failed to open .mtl \"%s\"", m_MaterialPath.string().c_str());
return;
}
LOG_INFO("Parsing .mtl \"%s\"", m_MaterialPath.string().c_str());
std::string currentMaterialName;
MaterialInfo* currentMaterial = nullptr;
@@ -130,7 +143,7 @@ void OBJ::ParseMaterial()
};
ss >> currentMaterialName;
LOG_INFO("Parsing material %s", currentMaterialName);
LOG_INFO("Parsing material %s", currentMaterialName.c_str());
Materials[currentMaterialName] = mat;
currentMaterial = &Materials[currentMaterialName];
continue;
+1 -1
View File
@@ -51,7 +51,7 @@ public:
std::vector<Face> Faces;
std::map<std::string, MaterialInfo> Materials;
void LoadFromFile(std::string filename);
bool LoadFromFile(std::string filename);
private:
boost::filesystem::path m_Path;
+5
View File
@@ -0,0 +1,5 @@
#include <GL/glew.h>
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include <glext.h>
#define GLM_FORCE_RADIANS
+63 -16
View File
@@ -2,6 +2,9 @@
Renderer::Renderer()
{
m_VSync = false;
m_DrawNormals = false;
m_DrawWireframe = false;
}
void Renderer::Initialize()
@@ -39,33 +42,63 @@ void Renderer::Initialize()
LOG_ERROR("GLEW: Initialization failed");
exit(EXIT_FAILURE);
}
glEnable(GL_DEPTH_TEST);
// Create Camera
m_Camera = std::make_shared<Camera>(45.f, (float)WIDTH / HEIGHT, 0.01f, 1000.f);
m_Camera->Position(glm::vec3(0.0f, 0.0f, 2.f));
glfwSwapInterval(m_VSync);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
LoadContent();
}
void Renderer::Draw(double _dt)
void Renderer::Draw(double dt)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
m_ShaderProgram.Bind();
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
#ifdef DEBUG
glDisable(GL_CULL_FACE);
glPolygonMode(GL_BACK, GL_LINE);
#endif
// Draw models
m_ShaderProgram.Bind();
glPolygonMode(GL_FRONT_AND_BACK, m_DrawWireframe ? GL_LINE : GL_FILL);
DrawModels();
#ifdef DEBUG
// Debug draw normals
if (m_DrawNormals) {
m_ShaderProgramNormals.Bind();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
DrawModels();
}
#endif
ModelsToRender.clear();
glfwSwapBuffers(m_Window);
}
void Renderer::DrawModels()
{
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix();
glm::mat4 MVP;
for (int i = 0; i < ModelsToRender.size(); i++)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, ModelsToRender[i]->model->texture[0]->texture);
MVP = cameraMatrix * ModelsToRender[i]->ModelMatrix;
ModelData* modelData = ModelsToRender.at(i);
auto model = modelData->model;
MVP = cameraMatrix * modelData->ModelMatrix;
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "model"), 1, GL_FALSE, glm::value_ptr(ModelsToRender[i]->ModelMatrix));
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "model"), 1, GL_FALSE, glm::value_ptr(modelData->ModelMatrix));
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "view"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "position"), 3, Light_position.data());
glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "specular"), 3, Light_specular.data());
@@ -74,13 +107,15 @@ void Renderer::Draw(double _dt)
glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "linearAttenuation"), 3, Light_linearAttenuation.data());
glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "quadraticAttenuation"), 3, Light_quadraticAttenuation.data());
glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "spotExponent"), 3, Light_spotExponent.data());
glBindVertexArray(ModelsToRender[i]->model->VAO);
glDrawArrays(GL_TRIANGLES, 0, ModelsToRender[i]->model->Vertices.size());
glBindVertexArray(model->VAO);
for (auto texGroup : model->TextureGroups) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texGroup.Texture->texture);
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
}
}
ModelsToRender.clear();
glfwSwapBuffers(m_Window);
}
void Renderer::DrawText()
@@ -93,7 +128,7 @@ void Renderer::AddTextToDraw()
//Add to draw shit vector
}
void Renderer::AddModelToDraw(Model* _model, glm::vec3 _position, glm::quat _orientation)
void Renderer::AddModelToDraw(std::shared_ptr<Model> _model, glm::vec3 _position, glm::quat _orientation)
{
glm::mat4 RotationMatrix = glm::toMat4(_orientation);
glm::mat4 ModelMatrix = glm::translate(glm::mat4(), _position) * RotationMatrix ;
@@ -130,8 +165,20 @@ void Renderer::AddPointLightToDraw(
void Renderer::LoadContent()
{
m_ShaderProgram.AddShader(std::unique_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl")));
m_ShaderProgram.AddShader(std::unique_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl")));
auto standardVS = std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl"));
auto standardFS = std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl"));
auto normalsGS = std::shared_ptr<Shader>(new GeometryShader("Shaders/Normals.geo.glsl"));
auto normalsFS = std::shared_ptr<Shader>(new FragmentShader("Shaders/Normals.frag.glsl"));
m_ShaderProgram.AddShader(standardVS);
m_ShaderProgram.AddShader(standardFS);
m_ShaderProgram.Compile();
m_ShaderProgram.Link();
m_ShaderProgramNormals.AddShader(normalsGS);
m_ShaderProgramNormals.AddShader(standardVS);
m_ShaderProgramNormals.AddShader(normalsFS);
m_ShaderProgramNormals.Compile();
m_ShaderProgramNormals.Link();
}
+193
View File
@@ -0,0 +1,193 @@
#include "Renderer.h"
Renderer::Renderer()
{
m_VSync = false;
m_DrawNormals = false;
m_DrawWireframe = false;
}
void Renderer::Initialize()
{
// Initialize GLFW
if (!glfwInit()) {
LOG_ERROR("GLFW: Initialization failed");
exit(EXIT_FAILURE);
}
// Create a window
WIDTH = 1280;
HEIGHT = 720;
m_Window = glfwCreateWindow(WIDTH, HEIGHT, "OpenGL", nullptr, nullptr);
if (!m_Window) {
LOG_ERROR("GLFW: Failed to create window");
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(m_Window);
// GL version info
glGetIntegerv(GL_MAJOR_VERSION, &m_glVersion[0]);
glGetIntegerv(GL_MINOR_VERSION, &m_glVersion[1]);
m_glVendor = (GLchar*)glGetString(GL_VENDOR);
std::stringstream ss;
ss << m_glVendor << " OpenGL " << m_glVersion[0] << "." << m_glVersion[1];
#ifdef DEBUG
ss << " DEBUG";
#endif
LOG_INFO(ss.str().c_str());
glfwSetWindowTitle(m_Window, ss.str().c_str());
// Initialize GLEW
if (glewInit() != GLEW_OK) {
LOG_ERROR("GLEW: Initialization failed");
exit(EXIT_FAILURE);
}
// Create Camera
m_Camera = std::make_shared<Camera>(45.f, (float)WIDTH / HEIGHT, 0.01f, 1000.f);
m_Camera->Position(glm::vec3(0.0f, 0.0f, 2.f));
glfwSwapInterval(m_VSync);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
LoadContent();
}
void Renderer::Draw(double dt)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
#ifdef DEBUG
glDisable(GL_CULL_FACE);
glPolygonMode(GL_BACK, GL_LINE);
#endif
// Draw models
m_ShaderProgram.Bind();
glPolygonMode(GL_FRONT_AND_BACK, m_DrawWireframe ? GL_LINE : GL_FILL);
DrawModels();
#ifdef DEBUG
// Debug draw normals
if (m_DrawNormals) {
m_ShaderProgramNormals.Bind();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
DrawModels();
}
#endif
ModelsToRender.clear();
glfwSwapBuffers(m_Window);
}
void Renderer::DrawModels()
{
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix();
glm::mat4 MVP;
for (int i = 0; i < ModelsToRender.size(); i++)
{
ModelData* modelData = ModelsToRender.at(i);
auto model = modelData->model;
MVP = cameraMatrix * modelData->ModelMatrix;
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "model"), 1, GL_FALSE, glm::value_ptr(modelData->ModelMatrix));
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "view"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
<<<<<<< HEAD
glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "position"), 3, Light_position.data());
glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "specular"), 3, Light_specular.data());
glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "diffuse"), 3, Light_diffuse.data());
glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "constantAttenuation"), 3, Light_constantAttenuation.data());
glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "linearAttenuation"), 3, Light_linearAttenuation.data());
glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "quadraticAttenuation"), 3, Light_quadraticAttenuation.data());
glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "spotExponent"), 3, Light_spotExponent.data());
glBindVertexArray(ModelsToRender[i]->model->VAO);
glDrawArrays(GL_TRIANGLES, 0, ModelsToRender[i]->model->Vertices.size());
=======
glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "lightPosition"), 1, glm::value_ptr(glm::vec3(2.0f, 4.0f, 1.0f)));
glUniform1f(glGetUniformLocation(m_ShaderProgram.GetHandle(), "constantAttenuation"), 1.5f);
glUniform1f(glGetUniformLocation(m_ShaderProgram.GetHandle(), "linearAttenuation"), 0.0f);
glUniform1f(glGetUniformLocation(m_ShaderProgram.GetHandle(), "quadraticAttenuation"), 0.0f);
>>>>>>> origin/master
glBindVertexArray(model->VAO);
for (auto texGroup : model->TextureGroups) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texGroup.Texture->texture);
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, (texGroup.EndIndex - texGroup.StartIndex + 1) * abs(sin(glfwGetTime())));
}
}
}
void Renderer::DrawText()
{
//DrawShitInTextForm
}
void Renderer::AddTextToDraw()
{
//Add to draw shit vector
}
void Renderer::AddModelToDraw(std::shared_ptr<Model> _model, glm::vec3 _position, glm::quat _orientation)
{
glm::mat4 RotationMatrix = glm::toMat4(_orientation);
glm::mat4 ModelMatrix = glm::translate(glm::mat4(), _position) * RotationMatrix ;
// You can now use ModelMatrix to build the MVP matrix
ModelsToRender.push_back(new ModelData(_model, ModelMatrix));
}
void Renderer::AddPointLightToDraw(
glm::vec3 _position,
glm::vec3 _specular,
glm::vec3 _diffuse,
float _constantAttenuation,
float _linearAttenuation,
float _quadraticAttenuation,
float _spotExponent
)
{
Light_position.push_back(_position.x);
Light_position.push_back(_position.y);
Light_position.push_back(_position.z);
Light_specular.push_back(_specular.x);
Light_specular.push_back(_specular.y);
Light_specular.push_back(_specular.z);
Light_diffuse.push_back(_diffuse.x);
Light_diffuse.push_back(_diffuse.y);
Light_diffuse.push_back(_diffuse.z);
Light_constantAttenuation.push_back(_constantAttenuation);
Light_linearAttenuation.push_back(_linearAttenuation);
Light_quadraticAttenuation.push_back(_quadraticAttenuation);
Light_spotExponent.push_back(_spotExponent);
}
void Renderer::LoadContent()
{
auto standardVS = std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl"));
auto standardFS = std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl"));
auto normalsGS = std::shared_ptr<Shader>(new GeometryShader("Shaders/Normals.geo.glsl"));
auto normalsFS = std::shared_ptr<Shader>(new FragmentShader("Shaders/Normals.frag.glsl"));
m_ShaderProgram.AddShader(standardVS);
m_ShaderProgram.AddShader(standardFS);
m_ShaderProgram.Compile();
m_ShaderProgram.Link();
m_ShaderProgramNormals.AddShader(normalsGS);
m_ShaderProgramNormals.AddShader(standardVS);
m_ShaderProgramNormals.AddShader(normalsFS);
m_ShaderProgramNormals.Compile();
m_ShaderProgramNormals.Link();
}
+19 -12
View File
@@ -7,12 +7,7 @@
#include <sstream>
#include <vector>
#define _CRT_SECURE_NO_WARNINGS
#include <GL/glew.h>
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include <glext.h>
#define GLM_FORCE_RADIANS
#include "OpenGL.h"
#include <glm/glm.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/gtc/matrix_transform.hpp>
@@ -29,7 +24,7 @@
class Renderer
{
public:
ShaderProgram m_ShaderProgram;
glm::mat4 viewMatrix;
glm::mat4 projectionMatrix;
@@ -37,10 +32,10 @@ public:
struct ModelData
{
Model* model;
std::shared_ptr<Model> model;
glm::mat4 ModelMatrix;
ModelData(Model* _model, glm::mat4 _modelMatrix) : model(_model), ModelMatrix(_modelMatrix)
{}
ModelData(std::shared_ptr<Model> _model, glm::mat4 _modelMatrix)
: model(_model), ModelMatrix(_modelMatrix) {}
};
std::vector<ModelData*> ModelsToRender;
@@ -58,7 +53,7 @@ public:
void Draw(double dt);
void DrawText();
void AddModelToDraw(Model*, glm::vec3, glm::quat);
void AddModelToDraw(std::shared_ptr<Model> model, glm::vec3 position, glm::quat orientation);
void AddTextToDraw();
void AddPointLightToDraw(
glm::vec3 _position,
@@ -75,14 +70,26 @@ public:
GLFWwindow* GetWindow() const { return m_Window; }
std::shared_ptr<Camera> GetCamera() const { return m_Camera; }
bool DrawNormals() const { return m_DrawNormals; }
void DrawNormals(bool val) { m_DrawNormals = val; }
bool DrawWireframe() const { return m_DrawWireframe; }
void DrawWireframe(bool val) { m_DrawWireframe = val; }
private:
GLFWwindow* m_Window;
GLint m_glVersion[2];
GLchar* m_glVendor;
bool m_VSync;
bool m_DrawNormals;
bool m_DrawWireframe;
std::shared_ptr<Camera> m_Camera;
GLuint vertexArrayObject;
ShaderProgram m_ShaderProgram;
ShaderProgram m_ShaderProgramNormals;
void DrawModels();
};
#endif // Renderer_h__
+9 -17
View File
@@ -84,20 +84,16 @@ bool Shader::IsCompiled() const
return m_ShaderHandle != 0;
}
ShaderProgram::ShaderProgram()
{
Initialize();
}
ShaderProgram::~ShaderProgram()
{
Unbind();
if (m_ShaderProgramHandle != 0) {
glDeleteProgram(m_ShaderProgramHandle);
}
}
void ShaderProgram::AddShader(std::unique_ptr<Shader> shader)
void ShaderProgram::AddShader(std::shared_ptr<Shader> shader)
{
m_Shaders.push_back(std::move(shader));
m_Shaders.push_back(shader);
}
void ShaderProgram::Compile()
@@ -111,6 +107,11 @@ void ShaderProgram::Compile()
GLuint ShaderProgram::Link()
{
if (m_Shaders.size() == 0) {
LOG_ERROR("Failed to link shader program: No shaders bound");
return 0;
}
LOG_INFO("Linking shader program");
m_ShaderProgramHandle = glCreateProgram();
for (auto &shader : m_Shaders) {
@@ -119,10 +120,6 @@ GLuint ShaderProgram::Link()
glLinkProgram(m_ShaderProgramHandle);
if (GLERROR("glLinkProgram"))
return 0;
for (auto &shader : m_Shaders) {
shader.release();
}
m_Shaders.clear();
return m_ShaderProgramHandle;
@@ -145,8 +142,3 @@ void ShaderProgram::Unbind()
{
glActiveShaderProgram(0, 0);
}
void ShaderProgram::Initialize()
{
m_ShaderProgramHandle = 0;
}
+5 -14
View File
@@ -6,11 +6,7 @@
#include <fstream>
#include <vector>
#define _CRT_SECURE_NO_WARNINGS
#include <GL/glew.h>
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include <glext.h>
#include "OpenGL.h"
#include "glerror.h"
@@ -68,25 +64,20 @@ public:
class ShaderProgram
{
public:
ShaderProgram();
ShaderProgram()
: m_ShaderProgramHandle(0) { }
~ShaderProgram();
void AddShader(std::unique_ptr<Shader> shader);
void AddShader(std::shared_ptr<Shader> shader);
void Compile();
GLuint Link();
GLuint GetHandle();
void Bind();
void Unbind();
private:
GLuint m_ShaderProgramHandle;
std::vector<std::unique_ptr<Shader>> m_Shaders;
void Initialize();
std::vector<std::shared_ptr<Shader>> m_Shaders;
};
#endif // ShaderProgram_h__
@@ -0,0 +1,9 @@
#version 430
uniform mat4 MVP;
out vec4 FragmentColor;
void main() {
FragmentColor = vec4(1.0, 1.0, 1.0, 1.0);
}
+34
View File
@@ -0,0 +1,34 @@
#version 430
uniform mat4 MVP;
layout(triangles) in;
layout(line_strip, max_vertices = 6) out;
in VertexData {
vec3 Position;
vec3 Normal;
vec2 TextureCoord;
} Input[3];
out VertexData {
vec3 Position;
vec3 Normal;
vec2 TextureCoord;
} Output;
void main()
{
for (int i = 0; i < gl_in.length(); i++)
{
gl_Position = MVP * vec4(Input[i].Position, 1.0);
EmitVertex();
gl_Position = MVP * vec4(Input[i].Position + Input[i].Normal, 1.0);
EmitVertex();
EndPrimitive();
Output.Position = Input[i].Position;
Output.Normal = Input[i].Normal;
Output.TextureCoord = Input[i].TextureCoord;
}
}
Binary file not shown.
+27
View File
@@ -21,10 +21,34 @@ void Systems::InputSystem::Update(double dt)
glfwGetCursorPos(m_Renderer->GetWindow(), &xpos, &ypos);
m_CurrentMouseDeltaX = xpos - m_LastMouseX;
m_CurrentMouseDeltaY = ypos - m_LastMouseY;
m_LastMouseX = xpos;
m_LastMouseY = ypos;
// Lock mouse while holding LMB
if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT]) {
m_LastMouseX = m_Renderer->WIDTH / 2.f; // xpos;
m_LastMouseY = m_Renderer->HEIGHT / 2.f; // ypos;
glfwSetCursorPos(m_Renderer->GetWindow(), m_LastMouseX, m_LastMouseY);
}
// Hide/show cursor with LMB
if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT] && !m_LastMouseState[GLFW_MOUSE_BUTTON_LEFT]) {
glfwSetInputMode(m_Renderer->GetWindow(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
}
if (!m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT] && m_LastMouseState[GLFW_MOUSE_BUTTON_LEFT]) {
glfwSetInputMode(m_Renderer->GetWindow(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
}
#ifdef DEBUG
// Wireframe
if (m_CurrentKeyState[GLFW_KEY_F1] && !m_LastKeyState[GLFW_KEY_F1]) {
m_Renderer->DrawWireframe(!m_Renderer->DrawWireframe());
}
// Normals
if (m_CurrentKeyState[GLFW_KEY_F2] && !m_LastKeyState[GLFW_KEY_F2]) {
m_Renderer->DrawNormals(!m_Renderer->DrawNormals());
}
#endif
}
void Systems::InputSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
{
@@ -39,3 +63,6 @@ void Systems::InputSystem::UpdateEntity(double dt, EntityID entity, EntityID par
input->dX = m_CurrentMouseDeltaX;
input->dY = m_CurrentMouseDeltaY;
}
std::array<int, GLFW_KEY_LAST+1> Systems::InputSystem::m_CurrentKeyState;
std::array<int, GLFW_KEY_LAST+1> Systems::InputSystem::m_LastKeyState;
+3 -3
View File
@@ -21,13 +21,13 @@ public:
private:
std::shared_ptr<Renderer> m_Renderer;
std::array<int, GLFW_KEY_LAST+1> m_CurrentKeyState;
std::array<int, GLFW_KEY_LAST+1> m_LastKeyState;
static std::array<int, GLFW_KEY_LAST+1> m_CurrentKeyState;
static std::array<int, GLFW_KEY_LAST+1> m_LastKeyState;
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_CurrentMouseState;
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_LastMouseState;
float m_CurrentMouseDeltaX, m_CurrentMouseDeltaY;
float m_LastMouseX, m_LastMouseY;
};
}
+22 -19
View File
@@ -19,31 +19,34 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
auto name = m_World->GetProperty<std::string>(entity, "Name");
if (name == "Camera") {
if (input->MouseState[GLFW_MOUSE_BUTTON_LEFT]) {
glm::vec3 Camera_Right = glm::vec3(glm::vec4(1, 0, 0, 0) * transform->Orientation);
glm::vec3 Camera_Forward = glm::vec3(glm::vec4(0, 0, 1, 0) * transform->Orientation);
float speed = 4.0f;
if(input->KeyState[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS)
{
speed = 1.0f;
float speed = 8.0f;
if(input->KeyState[GLFW_KEY_LEFT_SHIFT]) {
speed *= 2.0f;
}
if(input->KeyState[GLFW_KEY_A] == GLFW_PRESS)
{
transform->Position -= Camera_Right * (float)dt*2.f * speed;
if(input->KeyState[GLFW_KEY_LEFT_ALT]) {
speed /= 2.0f;
}
if(input->KeyState[GLFW_KEY_D] == GLFW_PRESS)
{
transform->Position += Camera_Right * (float)dt*2.f * speed;
if(input->KeyState[GLFW_KEY_A]) {
transform->Position -= Camera_Right * (float)dt * speed;
}
if(input->KeyState[GLFW_KEY_W] == GLFW_PRESS)
{
transform->Position -= Camera_Forward * (float)dt*2.f * speed;
if(input->KeyState[GLFW_KEY_D]) {
transform->Position += Camera_Right * (float)dt * speed;
}
if(input->KeyState[GLFW_KEY_S] == GLFW_PRESS)
{
transform->Position += Camera_Forward * (float)dt*2.f * speed;
if(input->KeyState[GLFW_KEY_W]) {
transform->Position -= Camera_Forward * (float)dt * speed;
}
if(input->KeyState[GLFW_KEY_S]) {
transform->Position += Camera_Forward * (float)dt * speed;
}
if(input->KeyState[GLFW_KEY_SPACE]) {
transform->Position += glm::vec3(0, 1, 0) * (float)dt * speed;
}
if(input->KeyState[GLFW_KEY_LEFT_CONTROL]) {
transform->Position -= glm::vec3(0, 1, 0) * (float)dt * speed;
}
// TOUCHING THIS CODE MIGHT COUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
@@ -53,7 +56,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
transform->Orientation = transform->Orientation * glm::angleAxis<float>(input->dX/300.f,glm::vec3(0,1,0));
//---------------------------------------------------------------------
// TOUCHING THIS CODE MIGHT COUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
}
}
}
-1
View File
@@ -4,7 +4,6 @@
#include <array>
#include "System.h"
#include "Renderer.h"
#include "Components/Transform.h"
#include "Components/Input.h"
#include "logging.h"
+4 -4
View File
@@ -15,14 +15,16 @@ void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID p
auto transformComponent = m_World->GetComponent<Components::Transform>(entity, "Transform");
if (transformComponent == nullptr)
return;
// Draw models
auto modelComponent = m_World->GetComponent<Components::Model>(entity, "Model");
if (modelComponent != nullptr)
{
if (m_CachedModels.find(modelComponent->ModelFile) == m_CachedModels.end()){
m_CachedModels[modelComponent->ModelFile] = new Model(modelComponent->ModelFile);
m_CachedModels[modelComponent->ModelFile] = std::make_shared<Model>(OBJ(modelComponent->ModelFile));
}
Model* model = m_CachedModels[modelComponent->ModelFile];
auto model = m_CachedModels[modelComponent->ModelFile];
m_Renderer->AddModelToDraw(model, transformComponent->Position, transformComponent->Orientation);
}
auto pointLightComponent = m_World->GetComponent<Components::PointLight>(entity, "PointLight");
@@ -48,8 +50,6 @@ void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID p
m_Renderer->GetCamera()->NearClip(cameraComponent->NearClip);
m_Renderer->GetCamera()->FarClip(cameraComponent->FarClip);
}
}
+36 -11
View File
@@ -7,30 +7,55 @@ void Systems::RenderSystem::OnComponentCreated( std::string type, std:: shared_p
{
auto modelComponent = std::static_pointer_cast<Components::Model>(component);
<<<<<<< HEAD
if (m_CachedModels.find(modelComponent->ModelFile) != m_CachedModels.end()) {
m_CachedModels[modelComponent->ModelFile] = new Model(modelComponent->ModelFile);
}
=======
>>>>>>> ce6b570520794087eb98447a571578585a705ded
}
}
void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID parent )
{
auto modelComponent = m_World->GetComponent<Components::Model>(entity, "Model");
if (modelComponent == nullptr)
return;
auto transformComponent = m_World->GetComponent<Components::Transform>(entity, "Transform");
if (transformComponent == nullptr)
return;
// Draw models
auto modelComponent = m_World->GetComponent<Components::Model>(entity, "Model");
if (modelComponent != nullptr)
{
if (m_CachedModels.find(modelComponent->ModelFile) == m_CachedModels.end()){
m_CachedModels[modelComponent->ModelFile] = new Model(modelComponent->ModelFile);
m_CachedModels[modelComponent->ModelFile] = std::make_shared<Model>(OBJ(modelComponent->ModelFile));
}
Model* model = m_CachedModels[modelComponent->ModelFile];
auto model = m_CachedModels[modelComponent->ModelFile];
m_Renderer->AddModelToDraw(model, transformComponent->Position, transformComponent->Orientation);
}
<<<<<<< HEAD
auto pointLightComponent = m_World->GetComponent<Components::PointLight>(entity, "PointLight");
if (pointLightComponent != nullptr)
{
m_Renderer->AddPointLightToDraw(
transformComponent->Position,
pointLightComponent->Specular,
pointLightComponent->Diffuse,
pointLightComponent->constantAttenuation,
pointLightComponent->linearAttenuation,
pointLightComponent->quadraticAttenuation,
pointLightComponent->spotExponent);
}
=======
// Update camera
>>>>>>> origin/master
auto cameraComponent = m_World->GetComponent<Components::Camera>(entity, "Camera");
if (cameraComponent != nullptr)
{
m_Renderer->GetCamera()->Position(transformComponent->Position);
m_Renderer->GetCamera()->Orientation(transformComponent->Orientation);
m_Renderer->GetCamera()->FOV(cameraComponent->FOV);
m_Renderer->GetCamera()->NearClip(cameraComponent->NearClip);
m_Renderer->GetCamera()->FarClip(cameraComponent->FarClip);
}
}
+3 -2
View File
@@ -1,6 +1,8 @@
#ifndef RenderSystem_h__
#define RenderSystem_h__
#include <unordered_map>
#include "System.h"
#include "Model.h"
#include "Texture.h"
@@ -8,7 +10,6 @@
#include "Components/Transform.h"
#include "Components/Camera.h"
#include "Renderer.h"
#include <unordered_map>
namespace Systems
{
@@ -19,7 +20,7 @@ namespace Systems
RenderSystem(World* world, std::shared_ptr<Renderer> renderer)
: System(world), m_Renderer(renderer) {}
std::unordered_map<std::string, Model*> m_CachedModels;
std::unordered_map<std::string, std::shared_ptr<Model>> m_CachedModels;
void OnComponentCreated(std::string type, std:: shared_ptr<Component> component) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
+3 -3
View File
@@ -1,14 +1,14 @@
#include "Texture.h"
Texture::Texture( const char* path )
Texture::Texture(std::string path)
{
Load(path);
}
void Texture::Load( const char* path )
void Texture::Load(std::string path)
{
texture = SOIL_load_OGL_texture(path, 0, 0, SOIL_FLAG_INVERT_Y);
texture = SOIL_load_OGL_texture(path.c_str(), 0, 0, SOIL_FLAG_INVERT_Y);
}
void Texture::Bind()
+5 -6
View File
@@ -1,22 +1,21 @@
#ifndef Texture_h__
#define Texture_h__
#include <GL/glew.h>
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include <glext.h>
#include <string>
#include "OpenGL.h"
#include <SOIL.h>
class Texture
{
public:
Texture(const char* path);
Texture(std::string path);
~Texture();
GLuint texture;
void Load(const char* path);
void Load(std::string path);
void Bind();
};
+1
View File
@@ -6,6 +6,7 @@
#include <unordered_map>
#include <vector>
#include <string>
#include <queue>
#include <boost/any.hpp>
-2
View File
@@ -1,8 +1,6 @@
#ifndef _GLERROR_H
#define _GLERROR_H
#define GLFW_INCLUDE_GLU
#include <GLFW\glfw3.h>
#include <iostream>
#include "logging.h"
-93
View File
@@ -1,93 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A9755CAA-62DC-442D-B82C-F548546CFD38}</ProjectGuid>
<RootNamespace>Executable</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\</OutDir>
<TargetName>$(SolutionName)-$(Configuration)</TargetName>
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSDK_LibraryPath_x86);</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)bin\</OutDir>
<TargetName>$(SolutionName)-$(Configuration)</TargetName>
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSDK_LibraryPath_x86);</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>GLEW_STATIC;_CRT_SECURE_NO_WARNINGS;DEBUG;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>GLEW_STATIC;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Escape-the-Dawn\Escape-the-Dawn.vcxproj">
<Project>{fe405cfa-8fce-4867-92cf-797e73b36482}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
-22
View File
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
Binary file not shown.
-107
View File
@@ -1,107 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B9A8F4AA-BE85-45EA-84DD-652D13DD22BE}</ProjectGuid>
<RootNamespace>Tests</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(LibraryPath)</LibraryPath>
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath)</IncludePath>
<LibraryPath>$(BOOST_ROOT)\lib32-msvc-11.0;$(LibraryPath)</LibraryPath>
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>boost_unit_test_framework-vc110-gd-1_55.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent />
<PostBuildEvent />
<PreBuildEvent />
<PostBuildEvent>
<Command>"$(OutDir)$(TargetName)$(TargetExt)" --log_level=test_suite</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Running tests</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>boost_unit_test_framework-vc110-1_55.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent />
<PostBuildEvent>
<Command>"$(OutDir)$(TargetName)$(TargetExt)" --log_level=test_suite</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Running tests</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Escape-the-Dawn\Escape-the-Dawn.vcxproj">
<Project>{fe405cfa-8fce-4867-92cf-797e73b36482}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
-22
View File
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
-84
View File
@@ -1,84 +0,0 @@
#include "logging.h"
#include "World.h"
#include "GameWorld.h"
#include "Components/Transform.h"
#define BOOST_TEST_MODULE World
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(Parenting)
{
World world;
// Parenting
EntityID ent1 = world.CreateEntity();
BOOST_CHECK(ent1 != 0); // 0 is reserved for world
BOOST_CHECK(ent1 == 1);
BOOST_CHECK(world.GetEntityParent(ent1) == 0);
EntityID ent2 = world.CreateEntity(ent1);
BOOST_CHECK(ent2 != 0);
BOOST_CHECK(ent2 == ent1 + 1);
BOOST_CHECK(world.GetEntityParent(ent2) == ent1);
}
BOOST_AUTO_TEST_CASE(SceneGraphTraversal)
{
std::shared_ptr<Renderer> renderer(new Renderer());
renderer->Initialize();
GameWorld world(renderer);
EntityID ent1 = world.CreateEntity();
auto t1 = world.AddComponent<Components::Transform>(ent1, "Transform");
BOOST_REQUIRE(t1 != nullptr);
t1->Position[0] = 1.0f;
t1->Position[1] = 1.0f;
t1->Position[2] = 1.0f;
EntityID ent2 = world.CreateEntity(ent1);
auto t2 = world.AddComponent<Components::Transform>(ent2, "Transform");
BOOST_REQUIRE(t2 != nullptr);
t2->Position[0] = 1.0f;
t2->Position[1] = 1.0f;
t2->Position[2] = 1.0f;
world.Update(0.0);
LOG_INFO("ent1: %f %f %f", t1->Position[0], t1->Position[1], t1->Position[2]);
LOG_INFO("ent2: %f %f %f", t2->Position[0], t2->Position[1], t2->Position[2]);
}
BOOST_AUTO_TEST_CASE(Recycling)
{
World world;
// EntityID recycling
EntityID ent11 = world.CreateEntity(); // 1
world.RemoveEntity(ent11);
EntityID ent12 = world.CreateEntity(); // 1
BOOST_REQUIRE(ent11 == ent12);
}
BOOST_AUTO_TEST_CASE(ComponentCreation)
{
World world;
EntityID ent = world.CreateEntity();
BOOST_CHECK(world.AddComponent(ent, "Transform") != nullptr);
BOOST_CHECK(world.AddComponent(ent, "Input") != nullptr);
}
BOOST_AUTO_TEST_CASE(Properties)
{
World world;
EntityID ent = world.CreateEntity();
world.SetProperty(ent, "String", std::string("derpfish"));
world.SetProperty(ent, "Integer", 123);
world.SetProperty(ent, "Float", 0.04f);
BOOST_CHECK(world.GetProperty<std::string>(ent, "String") == "derpfish");
BOOST_CHECK(world.GetProperty<int>(ent, "Integer") == 123);
BOOST_CHECK(world.GetProperty<float>(ent, "Float") == 0.04f);
}