Merge remote-tracking branch 'origin/master' into Sound

This commit is contained in:
Stiffly
2015-10-21 13:18:42 +02:00
121 changed files with 11835 additions and 4246 deletions
-102
View File
@@ -1,102 +0,0 @@
#ifndef BGFXRenderer_h__
#define BGFXRenderer_h__
#include <bgfx.h>
#include <bgfxplatform.h>
#include "Util/Rectangle.h"
#include "Core/Camera.h"
#include "Core/RenderQueue.h"
namespace dd
{
class BGFXRenderer
{
public:
GLFWwindow* Window() const { return m_Window; }
Rectangle Resolution() const { return m_Resolution; }
void SetResolution(const Rectangle& resolution) { m_Resolution = resolution; }
bool Fullscreen() { return m_Fullscreen; }
void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; }
bool VSYNC() const { return m_VSYNC; }
void SetVSYNC(bool vsync) { m_VSYNC = vsync; }
//void SetViewport(const Rectangle& viewport) { m_Viewport = viewport; }
//void SetScissor(const Rectangle& scissor) { m_Scissor = scissor; }
const dd::Camera* Camera() const { return m_Camera; }
void SetCamera(const dd::Camera* camera)
{
if (camera == nullptr) {
m_Camera = m_DefaultCamera.get();
} else {
m_Camera = camera;
}
}
void Initialize()
{
// Initialize GLFW
if (!glfwInit()) {
LOG_ERROR("GLFW: Initialization failed");
exit(EXIT_FAILURE);
}
// Create a window
GLFWmonitor* monitor = nullptr;
if (m_Fullscreen) {
monitor = glfwGetPrimaryMonitor();
}
glfwWindowHint(GLFW_SAMPLES, 8);
m_Window = glfwCreateWindow(m_Resolution.Width, m_Resolution.Height, "daydream", monitor, nullptr);
if (!m_Window) {
LOG_ERROR("GLFW: Failed to create window");
exit(EXIT_FAILURE);
}
//glfwMakeContextCurrent(m_Window);
// Initialize GLEW
// if (glewInit() != GLEW_OK) {
// LOG_ERROR("GLEW: Initialization failed");
// exit(EXIT_FAILURE);
// }
//LOG_ERROR("STUFF");
// Initialize bgfx
bgfx::glfwSetWindow(m_Window);
bgfx::init(bgfx::RendererType::OpenGL, BGFX_PCI_ID_NONE, 0, nullptr, nullptr);
bgfx::reset(m_Resolution.Width, m_Resolution.Height, BGFX_RESET_NONE);
bgfx::setDebug(BGFX_DEBUG_TEXT);
bgfx::setViewClear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x303030ff, 1.0f, 0);
std::stringstream ss;
ss << bgfx::getRendererName(bgfx::getRendererType());
#ifdef DEBUG
ss << " DEBUG";
#endif
LOG_INFO(ss.str().c_str());
glfwSetWindowTitle(m_Window, ss.str().c_str());
}
void Draw(RenderQueueCollection& rq)
{
bgfx::touch(0);
bgfx::dbgTextClear();
bgfx::dbgTextPrintf(0, 1, 0x4f, "daydream");
bgfx::frame();
}
private:
Rectangle m_Resolution = Rectangle(1280, 720);
bool m_Fullscreen = false;
bool m_VSYNC = false;
std::unique_ptr<dd::Camera> m_DefaultCamera = nullptr;
const dd::Camera* m_Camera = nullptr;
GLFWwindow* m_Window = nullptr;
};
}
#endif
+17 -15
View File
@@ -21,12 +21,12 @@
#include <Sound/CCollisionSound.h>
#include "ResourceManager.h"
#include "OBJ.h"
#include "Model.h"
#include "Texture.h"
#include "Rendering/OBJ.h"
#include "Rendering/Model.h"
#include "Rendering/Texture.h"
#include "EventBroker.h"
#include "RenderQueue.h"
#include "Renderer.h"
#include "Rendering/RenderQueue.h"
#include "Rendering/Renderer.h"
#include "InputManager.h"
//TODO: Remove includes that are only here for the temporary draw solution.
#include "World.h"
@@ -59,6 +59,7 @@
#include "Game/LifebuoySystem.h"
#include "Game/ProjectileSystem.h"
#include "Game/KrakenSystem.h"
#include "Game/WaterSystem.h"
#include "Game/Bricks/CPowerUpBrick.h"
#include "Game/BrickComponents.h"
@@ -164,7 +165,7 @@ public:
m_World->ComponentFactory.Register<Components::KrakenAttackBrick>();
m_World->SystemFactory.Register<Systems::LevelSystem>(
[this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); });
[this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::LevelSystem>();
m_World->SystemFactory.Register<Systems::PadSystem>(
[this]() { return new Systems::PadSystem(m_World.get(), m_EventBroker); });
@@ -193,6 +194,9 @@ public:
m_World->SystemFactory.Register<Systems::KrakenSystem>(
[this]() { return new Systems::KrakenSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::KrakenSystem>();
m_World->SystemFactory.Register<Systems::WaterSystem>(
[this]() { return new Systems::WaterSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::WaterSystem>();
m_World->ComponentFactory.Register<Components::Model>();
m_World->ComponentFactory.Register<Components::Template>();
@@ -348,11 +352,10 @@ public:
{
ModelJob job;
job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0;
job.DiffuseTexture = (texGroup.Texture) ? *texGroup.Texture : 0;
job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0;
job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0;
job.VAO = model->VAO;
job.ElementBuffer = model->ElementBuffer;
job.DiffuseTexture = texGroup.Texture.get();
job.NormalTexture = texGroup.NormalMap.get();
job.SpecularTexture = texGroup.SpecularMap.get();
job.Model = model;
job.StartIndex = texGroup.StartIndex;
job.EndIndex = texGroup.EndIndex;
job.ModelMatrix = modelMatrix * model->m_Matrix;
@@ -376,14 +379,13 @@ public:
{
SpriteJob job;
job.TextureID = texture->ResourceID;
job.DiffuseTexture = *texture;
job.NormalTexture = *normalTexture;
job.SpecularTexture = *specularTexture;
job.DiffuseTexture = texture;
job.NormalTexture = normalTexture;
job.SpecularTexture = specularTexture;
job.ModelMatrix = modelMatrix;
job.Color = color;
job.Depth = depth;
m_RendererQueue.Forward.Add(job);
}
+2 -16
View File
@@ -23,8 +23,8 @@
#include <forward_list>
#include "Core/Util/Rectangle.h"
#include "Core/Texture.h"
#include "Core/Model.h"
#include "Rendering/Texture.h"
#include "Rendering/Model.h"
namespace dd
{
@@ -78,20 +78,6 @@ struct ModelJob : RenderJob
}
};
struct BlendMapModelJob : ModelJob
{
GLuint BlendMapTextureRed;
GLuint BlendMapTextureRedNormal;
GLuint BlendMapTextureRedSpecular;
GLuint BlendMapTextureGreen;
GLuint BlendMapTextureGreenNormal;
GLuint BlendMapTextureGreenSpecular;
GLuint BlendMapTextureBlue;
GLuint BlendMapTextureBlueNormal;
GLuint BlendMapTextureBlueSpecular;
float TextureRepeat;
};
struct SpriteJob : RenderJob
{
unsigned int ShaderID;
+34
View File
@@ -0,0 +1,34 @@
#ifndef DD_STATICSYSTEM_H__
#define DD_STATICSYSTEM_H__
#include <unordered_map>
namespace dd
{
class StaticSystem
{
private:
StaticSystem();
public:
template <typename T>
static T* Get()
{
return static_cast<T*>(Instances.at(typeid(T).hash_code()));
}
template <typename T>
static void Set(T* ptr)
{
Instances[typeid(T).hash_code()] = static_cast<void*>(ptr);
}
private:
static std::unordered_map<size_t, void*> Instances;
};
}
#endif
+3 -3
View File
@@ -9,9 +9,9 @@
#include "Core/EKeyDown.h"
#include "Core/EKeyUp.h"
#include "Core/ResourceManager.h"
#include "Core/Renderer.h"
#include "Core/RenderQueue.h"
#include "Core/Texture.h"
#include "Rendering/Renderer.h"
#include "Rendering/RenderQueue.h"
#include "Rendering/Texture.h"
#include "Input/EInputCommand.h"
namespace dd
+3 -3
View File
@@ -2,7 +2,7 @@
#define GUI_TextureFrame_h__
#include "GUI/Frame.h"
#include "Core/Texture.h"
#include "Rendering/Texture.h"
namespace dd
{
@@ -29,7 +29,7 @@ public:
job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle();
job.Viewport = Rectangle(Left(), Top(), Width, Height);
job.TextureID = m_FadeTexture->ResourceID;
job.DiffuseTexture = *m_FadeTexture;
job.DiffuseTexture = m_FadeTexture;
job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a);
job.Name = Name();
rq.GUI.Add(job);
@@ -41,7 +41,7 @@ public:
job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle();
job.Viewport = Rectangle(Left(), Top(), Width, Height);
job.TextureID = m_Texture->ResourceID;
job.DiffuseTexture = *m_Texture;
job.DiffuseTexture = m_Texture;
job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a * m_CurrentFade);
job.Name = Name();
rq.GUI.Add(job);
+3
View File
@@ -6,6 +6,8 @@
#include "Core/EventBroker.h"
#include "Core/CTransform.h"
#include "Core/CTemplate.h"
#include "Core/ResourceManager.h"
#include "Core/ConfigFile.h"
#include "Physics/CPhysics.h"
#include "Physics/CCircleShape.h"
#include "Physics/CRectangleShape.h"
@@ -110,6 +112,7 @@ private:
bool m_InkBlockedWaiting = false;
bool m_Restarting = false;
int m_StickyCounter = 3;
bool m_GodMode = false;
bool m_StageBlockedWaiting = false;
+1 -1
View File
@@ -19,7 +19,7 @@ struct Brick : Component
//0 = empty, 1 = normal, 2 = multi-brick, 3 = lifebuoy, 4 = sticky, 5 = blaster, 6 = kraken
int Type = 0;
bool Removed = false;
int Number = 0; // For the Kraken to keep track of which bricks needs replacing.
int Number = 100; // For the Kraken to keep track of which bricks needs replacing.
//What number of types each is.
const int EmptyBrickSpace = 0;
+2 -1
View File
@@ -15,7 +15,8 @@ namespace Components
struct Kraken : Component {
int Health = 10;
int MaxHealth = 30;
int Health = MaxHealth;
int CurrentAction = 1;
const int Idle = 1;
+1 -1
View File
@@ -15,7 +15,7 @@ namespace Components
struct Projectile : Component
{
float Speed = 5;
};
}
+2 -1
View File
@@ -15,7 +15,8 @@ namespace Events
struct BrickGenerating : Event
{
glm::vec3 Origin;
glm::vec3 Origin1;
glm::vec3 Origin2;
int TargetLine;
int Set;
};
+1 -1
View File
@@ -12,7 +12,7 @@ namespace Events
struct ClusterClear : Event
{
int ClusterCleared;
};
}
+1
View File
@@ -17,6 +17,7 @@ struct InkBlaster : Event
{
Components::Transform* Transform;
int Shots;
float Speed = 5;
};
}
+26
View File
@@ -0,0 +1,26 @@
//
// Created by Adniklastrator on 2015-10-19.
//
#ifndef DAYDREAM_EKRAKENDEFEATED_H
#define DAYDREAM_EKRAKENDEFEATED_H
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct KrakenDefeated : Event
{
EntityID Kraken;
EntityID Hitter;
};
}
}
#endif //DAYDREAM_EKRAKENDEFEATED_H
+29
View File
@@ -0,0 +1,29 @@
//
// Created by Adniklastrator on 2015-10-19.
//
#ifndef DAYDREAM_EKRAKENHIT_H
#define DAYDREAM_EKRAKENHIT_H
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct KrakenHit : Event
{
EntityID Kraken;
EntityID Hitter;
int MaxHealth;
int CurrentHealth;
int NewHealth;
};
}
}
#endif //DAYDREAM_EKRAKENHIT_H
+1
View File
@@ -16,6 +16,7 @@ namespace Events
struct RaiseWater : Event
{
float Amount;
float Speed;
};
}
+26
View File
@@ -0,0 +1,26 @@
//
// Created by Administrator on 2015-10-20.
//
#ifndef DAYDREAM_ERAISEWATERWALL_H
#define DAYDREAM_ERAISEWATERWALL_H
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct RaiseWaterWall : Event
{
float Amount;
float Speed;
};
}
}
#endif //DAYDREAM_ERAISEWATERWALL_H
+27
View File
@@ -0,0 +1,27 @@
//
// Created by Administrator on 2015-10-20.
//
#ifndef DAYDREAM_ERELEVANTOBJECTCREATED_H
#define DAYDREAM_ERELEVANTOBJECTCREATED_H
#include "Core/EventBroker.h"
#include "Core/Entity.h"
namespace dd
{
namespace Events
{
struct RelevantObjectCreated : Event
{
std::string ObjectName;
EntityID ObjectID;
};
}
}
#endif //DAYDREAM_ERELEVANTOBJECTCREATED_H
+1
View File
@@ -17,6 +17,7 @@ struct StageCleared : Event
{
int ClearedStage = 0;
int StageCluster = 0;
int StagesInCluster = 6;
};
}
+22
View File
@@ -0,0 +1,22 @@
//
// Created by Administrator on 2015-10-19.
//
#ifndef DAYDREAM_ESTARTEDNEWLEVEL_H
#define DAYDREAM_ESTARTEDNEWLEVEL_H
#include "Core/EventBroker.h"
#include "Core/Entity.h"
namespace dd
{
namespace Events
{
struct StartedNewLevel : Event
{
};
}
}
#endif //DAYDREAM_ESTARTEDNEWLEVEL_H
+5 -5
View File
@@ -76,17 +76,17 @@ private:
{
m_ScoreNumberFrame->SetLeft(Width / 2.f - m_ScoreNumberFrame->Width / 2.f);
m_ScoreBackMid->SetLeft(m_ScoreNumberFrame->Left());
m_ScoreBackMid->Width = m_ScoreNumberFrame->Width;
m_ScoreBackMid->Height = m_ScoreNumberFrame->Height + 35;
m_ScoreBackMid->SetLeft(m_ScoreNumberFrame->Left() + 4);
m_ScoreBackLeft->SetRight(m_ScoreBackMid->Left());
m_ScoreBackLeft->Width = 40;
//m_ScoreBackLeft->Width = 40;
m_ScoreBackLeft->Height = m_ScoreBackMid->Height;
m_ScoreBackLeft->SetRight(m_ScoreBackMid->Left());
m_ScoreBackRight->SetLeft(m_ScoreBackMid->Right());
m_ScoreBackRight->Width = 40;
//m_ScoreBackRight->Width = 40;
m_ScoreBackRight->Height = m_ScoreBackMid->Height;
m_ScoreBackRight->SetLeft(m_ScoreBackMid->Right());
}
bool OnScore(const Events::ScoreEvent& event)
+13 -3
View File
@@ -17,13 +17,18 @@
#include "Physics/CCircleShape.h"
#include "Physics/CPhysics.h"
#include "Physics/EContact.h"
#include "Physics/ESetImpulse.h"
#include "Physics/ECreateParticleSequence.h"
#include "Game/EPause.h"
#include "Game/EResume.h"
#include "Game/EKrakenAppear.h"
#include "Game/EKrakenAttack.h"
#include "Game/EKrakenHit.h"
#include "Game/EKrakenDefeated.h"
#include "Game/EBrickGenerating.h"
#include "Game/CTravels.h"
#include "Game/CKraken.h"
#include "Game/CBall.h"
#include "Sound/CCollisionSound.h"
//#include "Core/Camera.h" Camera Component
@@ -57,24 +62,29 @@ private:
bool m_ReturnToIdle = false;
EntityID m_KrakenTemplate;
std::string m_Action = "Idle";
int m_NumberOfActions;
float m_KrakenTimer = 0;
float m_KrakenSecondsToAction = 1;
float m_KrakenSecondsToAction = 10;
const int Idle = 1;
std::array<int, 14> m_Bricks;
std::array<int, 14> m_Colors;
std::array<int, 42> m_Bricks;
std::array<int, 42> m_Colors;
dd::EventRelay<KrakenSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<KrakenSystem, dd::Events::Resume> m_EResume;
dd::EventRelay<KrakenSystem, dd::Events::Contact> m_EContact;
dd::EventRelay<KrakenSystem, dd::Events::KrakenAppear> m_EKrakenAppear;
dd::EventRelay<KrakenSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
dd::EventRelay<KrakenSystem, dd::Events::KrakenHit> m_EKrakenHit;
dd::EventRelay<KrakenSystem, dd::Events::KrakenDefeated> m_EKrakenDefeated;
dd::EventRelay<KrakenSystem, dd::Events::BrickGenerating> m_EBrickGenerating;
bool OnPause(const dd::Events::Pause &event);
bool OnResume(const dd::Events::Resume &event);
bool OnContact(const dd::Events::Contact &event);
bool OnKrakenAppear(const dd::Events::KrakenAppear &event);
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
bool OnKrakenHit(const dd::Events::KrakenHit &event);
bool OnKrakenDefeated(const dd::Events::KrakenDefeated &event);
bool OnBrickGenerating(const dd::Events::BrickGenerating &event);
void GetBrickSet();
};
+19 -2
View File
@@ -14,6 +14,8 @@
#include "Core/CTemplate.h"
#include "Core/EventBroker.h"
#include "Core/World.h"
#include "Core/ResourceManager.h"
#include "Core/ConfigFile.h"
#include "Rendering/CSprite.h"
#include "Rendering/CModel.h"
#include "Rendering/CPointLight.h"
@@ -31,7 +33,9 @@
#include "Game/BrickComponents.h"
#include "Game/ERelevantObjectCreated.h"
#include "Game/EStageCleared.h"
#include "Game/EArrivedAtNewStage.h"
#include "Game/ELifeLost.h"
#include "Game/EResetBall.h"
#include "Game/EScoreEvent.h"
@@ -50,7 +54,9 @@
#include "Game/ECreatePowerUp.h"
#include "Game/EPowerUpTaken.h"
#include "Game/CKraken.h"
#include "Game/EKrakenAppear.h"
#include "Game/EKrakenDefeated.h"
#include "Game/EBrickGenerating.h"
#include "Physics/CPhysics.h"
@@ -145,9 +151,11 @@ private:
int m_NumberOfBricks;
int m_Rows = 6;
int m_Lines = 7;
int m_StagesInCluster = 6;
float m_SpaceToEdge = 0.25f;
glm::vec2 m_SpaceBetweenBricks = glm::vec2(1, 0.4);
float m_NotResettingTheStage = 5.f;
bool m_GodMode = false;
const int EmptyBrickSpace = 0;
const int StandardBrick = 1;
@@ -164,8 +172,12 @@ private:
std::array<int, 42> m_Bricks;
std::array<glm::vec4, 42> m_Colors;
std::array<int, 14> m_BrickSet;
std::array<glm::vec4, 14> m_ColorSet;
std::array<int, 42> m_BrickSet;
std::array<glm::vec4, 42> m_ColorSet;
std::array<bool, 42> m_KrakenBricks;
bool m_BrickGenerating = false;
dd::Events::BrickGenerating m_BrickGeneratingEvent;
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
dd::EventRelay<LevelSystem, dd::Events::ScoreEvent> m_EScoreEvent;
@@ -174,10 +186,12 @@ private:
dd::EventRelay<LevelSystem, dd::Events::CreatePowerUp> m_ECreatePowerUp;
dd::EventRelay<LevelSystem, dd::Events::PowerUpTaken> m_EPowerUpTaken;
dd::EventRelay<LevelSystem, dd::Events::StageCleared> m_EStageCleared;
dd::EventRelay<LevelSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
dd::EventRelay<LevelSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<LevelSystem, dd::Events::Resume> m_EResume;
dd::EventRelay<LevelSystem, dd::Events::HitPad> m_EHitPad;
dd::EventRelay<LevelSystem, dd::Events::BrickGenerating> m_EBrickGenerating;
dd::EventRelay<LevelSystem, dd::Events::KrakenDefeated> m_EKrakenDefeated;
bool OnContact(const dd::Events::Contact &event);
bool OnScoreEvent(const dd::Events::ScoreEvent &event);
@@ -186,11 +200,14 @@ private:
bool OnCreatePowerUp(const dd::Events::CreatePowerUp &event);
bool OnPowerUpTaken(const dd::Events::PowerUpTaken &event);
bool OnStageCleared(const dd::Events::StageCleared &event);
bool OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event);
bool OnPause(const dd::Events::Pause &event);
bool OnResume(const dd::Events::Resume &event);
bool OnHitPad(const dd::Events::HitPad &event);
bool OnBrickGenerating(const dd::Events::BrickGenerating &event);
bool BrickGenerating(const dd::Events::BrickGenerating &event);
void GetBrickSet(int Set);
bool OnKrakenDefeated(const dd::Events::KrakenDefeated &event);
void GetNextLevel();
void SetBrokenModel(EntityID entity);
+4
View File
@@ -36,6 +36,7 @@
#include "Game/EResetBall.h"
#include "Game/EResetAll.h"
#include "Game/ERaiseWater.h"
#include "Game/ERaiseWaterWall.h"
#include "Game/EMultiBall.h"
#include "Game/ELifebuoy.h"
#include "Game/EStickyPad.h"
@@ -118,6 +119,7 @@ private:
dd::EventRelay<PadSystem, dd::Events::ResetBall> m_EResetBall;
dd::EventRelay<PadSystem, dd::Events::ResetAll> m_EResetAll;
dd::EventRelay<PadSystem, dd::Events::RaiseWater> m_ERaiseWater;
dd::EventRelay<PadSystem, dd::Events::RaiseWaterWall> m_ERaiseWaterWall;
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<PadSystem, dd::Events::Resume> m_EResume;
dd::EventRelay<PadSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
@@ -133,6 +135,8 @@ private:
bool OnResetBall(const dd::Events::ResetBall &event);
bool OnResetAll(const dd::Events::ResetAll &event);
bool OnRaiseWater(const dd::Events::RaiseWater &event);
bool OnRaiseWaterWall(const dd::Events::RaiseWaterWall &event);
bool RaisePad(float amount, float speed);
bool OnPause(const dd::Events::Pause &event);
bool OnResume(const dd::Events::Resume &event);
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
+2
View File
@@ -23,6 +23,7 @@
#include "Game/EHitPad.h"
#include "Game/CProjectile.h"
#include "Game/CBall.h"
#include "Rendering/CSprite.h"
#include <fstream>
#include <iostream>
@@ -52,6 +53,7 @@ private:
bool m_InkBlaster = false;
bool m_SquidLoaded = false;
int m_Shots = 0;
float m_InkBlasterSpeed = 5;
EntityID m_InkBlastTemplate;
EntityID m_AttachedSquid;
+72
View File
@@ -0,0 +1,72 @@
//
// Created by Adniklastrator on 2015-10-20.
//
#ifndef DAYDREAM_WATERSYSTEM_H
#define DAYDREAM_WATERSYSTEM_H
#include "Core/System.h"
#include "Core/CTransform.h"
#include "Core/CTemplate.h"
#include "Core/EventBroker.h"
#include "Core/World.h"
#include "Transform/EMove.h"
#include "Physics/CWaterVolume.h"
#include "Physics/CRectangleShape.h"
#include "Game/EPause.h"
#include "Game/EResume.h"
#include "Game/ERelevantObjectCreated.h"
#include "Game/ERaiseWater.h"
#include "Game/ERaiseWaterWall.h"
#include "Game/EArrivedAtNewStage.h"
#include "Game/EStageCleared.h"
namespace dd
{
namespace Systems
{
class WaterSystem : public System
{
public:
WaterSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker)
{ }
void Initialize() override;
void Update(double dt) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
bool IsPaused() const { return m_Pause; }
void SetPause(const bool& pause) { m_Pause = pause; }
private:
bool m_Pause = false;
EntityID m_BottomWall = 0;
dd::EventRelay<WaterSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<WaterSystem, dd::Events::Resume> m_EResume;
dd::EventRelay<WaterSystem, dd::Events::RelevantObjectCreated> m_ERelevantObjectCreated;
dd::EventRelay<WaterSystem, dd::Events::StageCleared> m_EStageCleared;
dd::EventRelay<WaterSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
dd::EventRelay<WaterSystem, dd::Events::RaiseWater> m_ERaiseWater;
dd::EventRelay<WaterSystem, dd::Events::RaiseWaterWall> m_ERaiseWaterWall;
bool OnPause(const dd::Events::Pause &event);
bool OnResume(const dd::Events::Resume &event);
bool OnRelevantObjectCreated(const dd::Events::RelevantObjectCreated &event);
bool OnStageCleared(const dd::Events::StageCleared &event);
bool OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event);
bool OnRaiseWater(const dd::Events::RaiseWater &event);
bool OnRaiseWaterWall(const dd::Events::RaiseWaterWall &event);
};
}
}
#endif //DAYDREAM_WATERSYSTEM_H
+6
View File
@@ -27,7 +27,13 @@
// OpenGL
#include <GL/glew.h>
#define GLFW_INCLUDE_GLU
#define NOMINMAX
#include <GLFW/glfw3.h>
#ifdef BUILD_RENDERER_DIRECTX
#define GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WGL
#include <GLFW/glfw3native.h>
#endif
#include <glext.h>
#include "Core/Util/GLError.h"
+64
View File
@@ -0,0 +1,64 @@
/*
This file is part of Daydream Engine.
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
Daydream Engine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Daydream Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DD_BASERENDERER_H__
#define DD_BASERENDERER_H__
#include "Core/Util/Rectangle.h"
#include "Core/ResourceManager.h"
#include "Rendering/Camera.h"
#include "Rendering/RenderQueue.h"
namespace dd
{
class BaseRenderer
{
public:
GLFWwindow* Window() const { return m_Window; }
Rectangle Resolution() const { return m_Resolution; }
void SetResolution(const Rectangle& resolution) { m_Resolution = resolution; }
bool Fullscreen() { return m_Fullscreen; }
void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; }
bool VSYNC() const { return m_VSYNC; }
void SetVSYNC(bool vsync) { m_VSYNC = vsync; }
const dd::Camera* Camera() const { return m_Camera; }
void SetCamera(const dd::Camera* camera)
{
if (camera == nullptr) {
m_Camera = m_DefaultCamera.get();
} else {
m_Camera = camera;
}
}
virtual void Initialize() = 0;
virtual void Draw(RenderQueueCollection& rq) = 0;
protected:
Rectangle m_Resolution = Rectangle(1280, 720);
bool m_Fullscreen = false;
bool m_VSYNC = false;
std::unique_ptr<dd::Camera> m_DefaultCamera = nullptr;
const dd::Camera* m_Camera = nullptr;
GLFWwindow* m_Window = nullptr;
};
}
#endif // Renderer_h__
+45
View File
@@ -0,0 +1,45 @@
/*
This file is part of Daydream Engine.
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
Daydream Engine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Daydream Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BaseTexture_h__
#define BaseTexture_h__
#include <string>
#include <unordered_map>
#include <cstdio>
#include "Core/ResourceManager.h"
#include "Rendering/PNG.h"
namespace dd
{
class BaseTexture : public Resource
{
friend class ResourceManager;
public:
unsigned int Width = 0;
unsigned int Height = 0;
};
}
#endif
+1 -1
View File
@@ -20,7 +20,7 @@
#define Components_PointLight_h__
#include "Core/Component.h"
#include "Core/Color.h"
#include "Rendering/Color.h"
namespace dd
{
@@ -65,15 +65,15 @@ public:
float FarClip() const { return m_FarClip; }
void SetFarClip(float val);
private:
void UpdateViewMatrix();
void UpdateProjectionMatrix();
float m_AspectRatio;
float m_FOV;
float m_NearClip;
float m_FarClip;
private:
void UpdateViewMatrix();
void UpdateProjectionMatrix();
glm::vec3 m_Position;
glm::quat m_Orientation;
@@ -0,0 +1,32 @@
#ifndef Model_h__
#define Model_h__
#include <string>
#include <d3d11.h>
#include "Rendering/RawModel.h"
#include "Core/StaticSystem.h"
#include "Rendering/Renderer.h"
namespace dd
{
class Model : public RawModel
{
friend class ResourceManager;
private:
Model(std::string fileName);
public:
~Model();
ID3D11Buffer* VertexBuffer = nullptr;
ID3D11Buffer* IndexBuffer = nullptr;
unsigned int NumVertices;
};
}
#endif // Model_h__
@@ -0,0 +1,86 @@
/*
This file is part of Daydream Engine.
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
Daydream Engine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Daydream Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DD_RENDERER_H__
#define DD_RENDERER_H__
#include <d3d11.h>
#pragma comment (lib, "d3d11.lib")
#include <DirectXTK/SimpleMath.h>
using namespace DirectX::SimpleMath;
//#pragma comment (lib, "DirectXTK.lib")
#include "Rendering/BaseRenderer.h"
namespace dd
{
class Model;
class ShaderProgram;
class Renderer : public BaseRenderer
{
public:
~Renderer();
void Initialize() override;
void Draw(RenderQueueCollection& rq) override;
D3D11_RASTERIZER_DESC m_RasterDesc;
IDXGISwapChain* m_SwapChain = nullptr;
ID3D11Device* m_Device = nullptr;
ID3D11RasterizerState* m_RasterState = nullptr;
ID3D11DeviceContext* m_DeviceContext = nullptr;
ID3D11RenderTargetView* m_BackBuffer = nullptr;
ID3D11DepthStencilView* m_DepthBuffer = nullptr;
ID3D11SamplerState* m_SamplerState = nullptr;
private:
struct ConstantBufferStruct
{
Matrix MVP;
Matrix ModelMatrix;
Matrix ViewMatrix;
Matrix ProjectionMatrix;
Matrix InverseTransposeViewModel;
Vector4 Color;
Vector4 LightPositions[10];
Vector4 LightColors[10];
float LightRadii[10];
unsigned int NumLights;
float paddingBitch;
} constantBufferStruct;
ShaderProgram* m_ForwardShaderProgram = nullptr;
ShaderProgram* m_GUIShaderProgram = nullptr;
ID3D11Buffer* constantBuffer = nullptr;
Model* m_UnitQuad = nullptr;
Texture* m_WhiteSphereTexture = nullptr;
static DirectX::SimpleMath::Matrix GLMtoDXModelView(glm::mat4 m);
static DirectX::SimpleMath::Matrix GLMtoDXProjection(glm::mat4 m);
void setDefaultRasterState();
void setGUIRasterState();
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
};
}
#endif // Renderer_h__
@@ -0,0 +1,42 @@
#ifndef ShaderProgram_h__
#define ShaderProgram_h__
#include <string>
#include <d3d11.h>
#include <d3dcompiler.h>
#pragma comment (lib, "D3DCompiler.lib")
#include "Core/StaticSystem.h"
#include "Rendering/Renderer.h"
namespace dd
{
class ShaderProgram
{
public:
ShaderProgram();
~ShaderProgram();
void CompileVertexShader(std::wstring filename);
void CompilePixelShader(std::wstring filename);
HRESULT CreateInputLayout(D3D11_INPUT_ELEMENT_DESC* ied, UINT numElements);
ID3D11InputLayout* GetInputLayout() const { return m_InputLayout; }
void Bind();
void Unbind();
private:
ID3D10Blob* m_VertexShaderBlob;
ID3D11VertexShader* m_VertexShader;
ID3D10Blob* m_PixelShaderBlob;
ID3D11PixelShader* m_PixelShader;
ID3D11InputLayout* m_InputLayout;
};
}
#endif // ShaderProgram_h__
@@ -0,0 +1,50 @@
/*
This file is part of Daydream Engine.
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
Daydream Engine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Daydream Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef Texture_h__
#define Texture_h__
#include <d3d11.h>
#include "Rendering/BaseTexture.h"
#include "Core/StaticSystem.h"
#include "Rendering/Renderer.h"
namespace dd
{
class Texture : public BaseTexture
{
friend class ResourceManager;
private:
Texture(std::string path);
public:
~Texture();
operator ID3D11Texture2D*() { return m_Texture; }
ID3D11Texture2D* m_Texture = nullptr;
ID3D11ShaderResourceView* m_ShaderResourceView = nullptr;
private:
};
}
#endif
View File
@@ -30,7 +30,7 @@
#include <boost/filesystem/path.hpp>
#include <boost/program_options.hpp>
#include "ResourceManager.h"
#include "Core/ResourceManager.h"
namespace dd
{
@@ -0,0 +1,52 @@
/*
This file is part of Daydream Engine.
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
Daydream Engine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Daydream Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef Model_h__
#define Model_h__
#include "Rendering/RawModel.h"
namespace dd
{
class Model : public RawModel
{
friend class ResourceManager;
private:
Model(std::string fileName);
public:
~Model();
GLuint VAO;
GLuint ElementBuffer;
private:
GLuint VertexBuffer;
GLuint DiffuseVertexColorBuffer;
GLuint SpecularVertexColorBuffer;
GLuint NormalBuffer;
GLuint TangentNormalsBuffer;
GLuint BiTangentNormalsBuffer;
GLuint TextureCoordBuffer;
};
}
#endif // Model_h__
@@ -19,7 +19,11 @@
#ifndef DD_RENDERER_H__
#define DD_RENDERER_H__
#include "Util/Rectangle.h"
#include "Rendering/BaseRenderer.h"
#include "Core/Util/Rectangle.h"
#include "Rendering/Camera.h"
#include "Rendering/RenderQueue.h"
#include "Rendering/ShaderProgram.h"
#include "Core/System.h"
#include "Core/CTransform.h"
#include "Core/CTemplate.h"
@@ -28,46 +32,22 @@
#include "Core/ResourceManager.h"
#include "Core/ConfigFile.h"
#include "Game/EScreenShake.h"
#include "Camera.h"
#include "RenderQueue.h"
#include "ShaderProgram.h"
#include "Rendering/Model.h"
#include "Rendering/Texture.h"
namespace dd
{
class Renderer
class Renderer : public BaseRenderer
{
public:
GLFWwindow* Window() const { return m_Window; }
Rectangle Resolution() const { return m_Resolution; }
void SetResolution(const Rectangle& resolution) { m_Resolution = resolution; }
bool Fullscreen() { return m_Fullscreen; }
void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; }
bool VSYNC() const { return m_VSYNC; }
void SetVSYNC(bool vsync) { m_VSYNC = vsync; }
const dd::Camera* Camera() const { return m_Camera; }
void SetCamera(const dd::Camera* camera)
{
if (camera == nullptr) {
m_Camera = m_DefaultCamera.get();
} else {
m_Camera = camera;
}
}
void Initialize();
void Draw(RenderQueueCollection& rq);
void Initialize() override;
void Draw(RenderQueueCollection& rq) override;
void PlaceCamera(glm::vec3 position);
private:
Rectangle m_Resolution = Rectangle(1280, 720);
bool m_Fullscreen = false;
bool m_VSYNC = false;
std::unique_ptr<dd::Camera> m_DefaultCamera = nullptr;
const dd::Camera* m_Camera = nullptr;
int m_GLVersion[2];
std::string m_GLVendor;
GLFWwindow* m_Window = nullptr;
ShaderProgram* m_SpDeferred1;
ShaderProgram* m_SpDeferred2;
@@ -80,6 +60,7 @@ private:
GLuint m_ScreenQuad = 0;
Model* m_UnitSphere = nullptr;
Model* m_UnitQuad = nullptr;
Texture* m_ErrorTexture;
Texture* m_StandardNormal;
Texture* m_StandardSpecular;
Texture* m_WhiteSphereTexture;
@@ -27,7 +27,7 @@
#include <boost/filesystem.hpp>
#include <boost/filesystem/path.hpp>
#include "ResourceManager.h"
#include "Core/ResourceManager.h"
namespace dd
{
@@ -19,17 +19,12 @@
#ifndef Texture_h__
#define Texture_h__
#include <string>
#include <unordered_map>
#include <cstdio>
#include "ResourceManager.h"
#include "PNG.h"
#include "Rendering/BaseTexture.h"
namespace dd
{
class Texture : public Resource
class Texture : public BaseTexture
{
friend class ResourceManager;
@@ -41,16 +36,9 @@ public:
void Bind(GLenum textureUnit = GL_TEXTURE0);
operator GLuint() const { return m_Texture; }
unsigned int Width = 0;
unsigned int Height = 0;
private:
GLuint m_Texture = 0;
};
}
#endif // Texture_h__
@@ -16,8 +16,8 @@
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef Model_h__
#define Model_h__
#ifndef RawModel_h__
#define RawModel_h__
#include <string>
#include <fstream>
@@ -34,21 +34,21 @@
#include <boost/filesystem/path.hpp>
#include "Core/ResourceManager.h"
#include "Core/Texture.h"
#include "Core/Skeleton.h"
#include "Rendering/Texture.h"
#include "Rendering/Skeleton.h"
namespace dd
{
class Model : public Resource
class RawModel : public Resource
{
friend class ResourceManager;
private:
Model(std::string fileName);
protected:
RawModel(std::string fileName);
public:
~Model();
~RawModel();
struct Vertex
{
@@ -75,17 +75,11 @@ public:
unsigned int EndIndex;
};
GLuint VAO;
GLuint ElementBuffer;
std::vector<MaterialGroup> TextureGroups;
std::vector<std::shared_ptr<Texture>> texture;
glm::mat4 GetMatrix();
std::vector<glm::vec3> Vertices;
std::vector<Vertex> m_Vertices;
std::vector<unsigned int> m_Indices;
Skeleton* m_Skeleton = nullptr;
glm::mat4 m_Matrix;
private:
@@ -98,17 +92,9 @@ private:
std::vector<glm::vec3> BiTangentNormals;
std::vector<glm::vec2> TextureCoords;
GLuint VertexBuffer;
GLuint DiffuseVertexColorBuffer;
GLuint SpecularVertexColorBuffer;
GLuint NormalBuffer;
GLuint TangentNormalsBuffer;
GLuint BiTangentNormalsBuffer;
GLuint TextureCoordBuffer;
void CreateSkeleton(std::vector<std::tuple<std::string, glm::mat4>> &boneInfo, std::map<std::string, int> &boneNameMapping, aiNode* node, int parentID);
};
}
#endif // Model_h__
#endif
+198
View File
@@ -0,0 +1,198 @@
/*
This file is part of Daydream Engine.
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
Daydream Engine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Daydream Engine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RenderQueue_h__
#define RenderQueue_h__
#include <cstdint>
#include <forward_list>
#include "Core/Util/Rectangle.h"
namespace dd
{
class Model;
class Skeleton;
class Texture;
class RenderQueue;
struct RenderJob
{
friend class RenderQueue;
float Depth;
protected:
uint64_t Hash;
virtual void CalculateHash() = 0;
bool operator<(const RenderJob& rhs)
{
return this->Hash < rhs.Hash;
}
};
struct ModelJob : RenderJob
{
unsigned int ShaderID = 0;
unsigned int TextureID = 0;
glm::mat4 ModelMatrix;
const Texture* DiffuseTexture;
const Texture* NormalTexture;
const Texture* SpecularTexture;
float Shininess = 0.f;
glm::vec4 Color;
const dd::Model* Model = nullptr;
unsigned int StartIndex = 0;
unsigned int EndIndex = 0;
// Animation
dd::Skeleton* Skeleton = nullptr;
bool NoRootMotion = true;
std::string AnimationName;
double AnimationTime = 0;
void CalculateHash() override
{
Hash = TextureID;
}
};
struct SpriteJob : RenderJob
{
unsigned int ShaderID = 0;
unsigned int TextureID = 0;
glm::mat4 ModelMatrix;
const Texture* DiffuseTexture = nullptr;
const Texture* NormalTexture = nullptr;
const Texture* SpecularTexture = nullptr;
glm::vec4 Color;
void CalculateHash() override
{
Hash = TextureID;
}
};
struct PointLightJob : RenderJob
{
glm::vec3 Position;
glm::vec3 SpecularColor = glm::vec3(1, 1, 1);
glm::vec3 DiffuseColor = glm::vec3(1, 1, 1);
float Radius = 1.f;
void CalculateHash() override
{
Hash = 0;
}
};
struct FrameJob : SpriteJob
{
Rectangle Scissor;
Rectangle Viewport;
std::string Name;
void CalculateHash() override
{
Hash = 0;
}
};
struct WaterParticleJob : RenderJob
{
glm::vec3 Position;
glm::vec4 Color;
glm::mat4 ModelMatrix;
void CalculateHash() override
{
Hash = 0;
}
};
class RenderQueue
{
public:
template <typename T>
void Add(T &job)
{
job.CalculateHash();
Jobs.push_back(std::shared_ptr<T>(new T(job)));
m_Size++;
}
void Sort()
{
Jobs.sort();
}
void Clear()
{
Jobs.clear();
m_Size = 0;
}
int Size() const { return m_Size; }
std::list<std::shared_ptr<RenderJob>>::const_iterator begin()
{
return Jobs.begin();
}
std::list<std::shared_ptr<RenderJob>>::const_iterator end()
{
return Jobs.end();
}
std::list<std::shared_ptr<RenderJob>> Jobs;
private:
int m_Size = 0;
};
struct RenderQueueCollection
{
RenderQueue Deferred;
RenderQueue Forward;
RenderQueue Lights;
RenderQueue GUI;
void Clear()
{
Deferred.Clear();
Forward.Clear();
Lights.Clear();
GUI.Clear();
}
void Sort()
{
Deferred.Sort();
Forward.Sort();
Lights.Sort();
GUI.Sort();
}
};
}
#endif // RenderQueue_h__