Merge branch 'master' into LevelSystemAndSuch
This commit is contained in:
Regular → Executable
+30
-13
@@ -99,21 +99,12 @@ public:
|
||||
|
||||
//TODO: Remove tobias light-test code.
|
||||
/*{
|
||||
auto t_BrickWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_BrickWall);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(t_BrickWall);
|
||||
//TODO: Rename SpriteFile to DiffuseTexture or similar.
|
||||
sprite->SpriteFile = "Textures/Test/Brick_Diffuse.png";
|
||||
sprite->NormalTexture = "Textures/Test/Brick_Normal.png";
|
||||
sprite->SpecularTexture = "Textures/Test/Brick_Specular.png";
|
||||
}*/
|
||||
|
||||
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
transform->Position = glm::vec3(0.5f, 0.f, -10.f);
|
||||
transform->Position = glm::vec3(0.5f, 0.f, -9.9f);
|
||||
transform->Scale = glm::vec3(1.f, 1.f, 1.f);
|
||||
|
||||
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(ent);
|
||||
@@ -137,6 +128,28 @@ public:
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
{
|
||||
auto t_BrickWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_BrickWall);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(t_BrickWall);
|
||||
//TODO: Rename SpriteFile to DiffuseTexture or similar.
|
||||
sprite->SpriteFile = "Textures/Ball.png";
|
||||
sprite->NormalTexture = "Textures/Test/Brick_Normal.png";
|
||||
sprite->SpecularTexture = "Textures/Test/Brick_Specular.png";
|
||||
}
|
||||
|
||||
{
|
||||
auto t_BrickWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_BrickWall);
|
||||
transform->Position = glm::vec3(0.4f, 0.f, -9.5f);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(t_BrickWall);
|
||||
//TODO: Rename SpriteFile to DiffuseTexture or similar.
|
||||
sprite->SpriteFile = "Textures/Ball.png";
|
||||
sprite->NormalTexture = "Textures/Test/Brick_Normal.png";
|
||||
sprite->SpecularTexture = "Textures/Test/Brick_Specular.png";
|
||||
}
|
||||
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
@@ -343,7 +356,7 @@ public:
|
||||
glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position)
|
||||
* glm::toMat4(orientation2D)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueSprite(texturediff, texturenorm, texturespec, modelMatrix, spriteComponent->Color);
|
||||
EnqueueSprite(texturediff, texturenorm, texturespec, modelMatrix, spriteComponent->Color, absoluteTransform.Position.z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,13 +379,15 @@ public:
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
//TODO: This Depth is probably wrong.
|
||||
job.Depth = (glm::vec4(1,1,1,0) * modelMatrix).z;
|
||||
|
||||
m_RendererQueue.Deferred.Add(job);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Get this out of engine.h
|
||||
void EnqueueSprite(Texture* texture, Texture* normalTexture, Texture* specularTexture, glm::mat4 modelMatrix, glm::vec4 color)
|
||||
void EnqueueSprite(Texture* texture, Texture* normalTexture, Texture* specularTexture, glm::mat4 modelMatrix, glm::vec4 color, float depth)
|
||||
{
|
||||
SpriteJob job;
|
||||
job.TextureID = texture->ResourceID;
|
||||
@@ -381,8 +396,10 @@ public:
|
||||
job.SpecularTexture = *specularTexture;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
job.Depth = depth;
|
||||
|
||||
m_RendererQueue.Deferred.Add(job);
|
||||
|
||||
m_RendererQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
void EnqueuePointLight(glm::vec3 position, glm::vec3 diffuseColor, glm::vec3 specularColor, float radius)
|
||||
|
||||
@@ -93,6 +93,8 @@ private:
|
||||
void CreateBuffers();
|
||||
GLuint CreateQuad();
|
||||
|
||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
||||
|
||||
void DrawDeferred(RenderQueue &objects, RenderQueue &lights);
|
||||
void DrawForward(RenderQueue &objects, RenderQueue &lights);
|
||||
void DrawScene(RenderQueue &objects, ShaderProgram &program);
|
||||
|
||||
Reference in New Issue
Block a user