Removed OpenGL specifics from RenderQueue

This commit is contained in:
2015-10-06 19:34:31 +02:00
parent 13360856f9
commit 00f537bc03
4 changed files with 34 additions and 43 deletions
+7 -9
View File
@@ -533,11 +533,10 @@ public:
{ {
ModelJob job; ModelJob job;
job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0; job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0;
job.DiffuseTexture = (texGroup.Texture) ? *texGroup.Texture : 0; job.DiffuseTexture = texGroup.Texture.get();
job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0; job.NormalTexture = texGroup.NormalMap.get();
job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0; job.SpecularTexture = texGroup.SpecularMap.get();
job.VAO = model->VAO; job.Model = model;
job.ElementBuffer = model->ElementBuffer;
job.StartIndex = texGroup.StartIndex; job.StartIndex = texGroup.StartIndex;
job.EndIndex = texGroup.EndIndex; job.EndIndex = texGroup.EndIndex;
job.ModelMatrix = modelMatrix * model->m_Matrix; job.ModelMatrix = modelMatrix * model->m_Matrix;
@@ -561,14 +560,13 @@ public:
{ {
SpriteJob job; SpriteJob job;
job.TextureID = texture->ResourceID; job.TextureID = texture->ResourceID;
job.DiffuseTexture = *texture; job.DiffuseTexture = texture;
job.NormalTexture = *normalTexture; job.NormalTexture = normalTexture;
job.SpecularTexture = *specularTexture; job.SpecularTexture = specularTexture;
job.ModelMatrix = modelMatrix; job.ModelMatrix = modelMatrix;
job.Color = color; job.Color = color;
job.Depth = depth; job.Depth = depth;
m_RendererQueue.Forward.Add(job); m_RendererQueue.Forward.Add(job);
} }
@@ -78,6 +78,7 @@ private:
GLuint m_ScreenQuad = 0; GLuint m_ScreenQuad = 0;
Model* m_UnitSphere = nullptr; Model* m_UnitSphere = nullptr;
Model* m_UnitQuad = nullptr; Model* m_UnitQuad = nullptr;
Texture* m_ErrorTexture;
Texture* m_StandardNormal; Texture* m_StandardNormal;
Texture* m_StandardSpecular; Texture* m_StandardSpecular;
Texture* m_WhiteSphereTexture; Texture* m_WhiteSphereTexture;
+7 -22
View File
@@ -56,13 +56,12 @@ struct ModelJob : RenderJob
glm::mat4 ProjectionMatrix; glm::mat4 ProjectionMatrix;
glm::mat4 ViewMatrix; glm::mat4 ViewMatrix;
glm::mat4 ModelMatrix; glm::mat4 ModelMatrix;
GLuint DiffuseTexture; const Texture* DiffuseTexture;
GLuint NormalTexture; const Texture* NormalTexture;
GLuint SpecularTexture; const Texture* SpecularTexture;
float Shininess; float Shininess;
glm::vec4 Color; glm::vec4 Color;
GLuint VAO; const dd::Model* Model;
GLuint ElementBuffer;
unsigned int StartIndex; unsigned int StartIndex;
unsigned int EndIndex; unsigned int EndIndex;
@@ -72,20 +71,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 struct SpriteJob : RenderJob
{ {
unsigned int ShaderID; unsigned int ShaderID;
@@ -94,9 +79,9 @@ struct SpriteJob : RenderJob
glm::mat4 ProjectionMatrix; glm::mat4 ProjectionMatrix;
glm::mat4 ViewMatrix; glm::mat4 ViewMatrix;
glm::mat4 ModelMatrix; glm::mat4 ModelMatrix;
GLuint DiffuseTexture; const Texture* DiffuseTexture;
GLuint NormalTexture; const Texture* NormalTexture;
GLuint SpecularTexture; const Texture* SpecularTexture;
glm::vec4 Color; glm::vec4 Color;
void CalculateHash() override void CalculateHash() override
+19 -12
View File
@@ -121,6 +121,7 @@ void dd::Renderer::CreateBuffers()
m_ScreenQuad = CreateQuad(); m_ScreenQuad = CreateQuad();
m_UnitQuad = ResourceManager::Load<Model>("Models/Core/UnitQuad.obj"); m_UnitQuad = ResourceManager::Load<Model>("Models/Core/UnitQuad.obj");
m_UnitSphere = ResourceManager::Load<Model>("Models/Core/UnitSphere.obj"); m_UnitSphere = ResourceManager::Load<Model>("Models/Core/UnitSphere.obj");
m_ErrorTexture = ResourceManager::Load<Texture>("Textures/Core/ErrorTexture.png");
m_StandardNormal = ResourceManager::Load<Texture>("Textures/Core/NeutralNormalMap.png"); m_StandardNormal = ResourceManager::Load<Texture>("Textures/Core/NeutralNormalMap.png");
m_StandardSpecular = ResourceManager::Load<Texture>("Textures/Core/NeutralSpecularMap.png"); m_StandardSpecular = ResourceManager::Load<Texture>("Textures/Core/NeutralSpecularMap.png");
m_WhiteSphereTexture = ResourceManager::Load<Texture>("Textures/Test/Water.png"); m_WhiteSphereTexture = ResourceManager::Load<Texture>("Textures/Test/Water.png");
@@ -413,19 +414,25 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program)
glUniform1f(glGetUniformLocation(shaderProgramHandle, "LightRadius"), 40.0f); glUniform1f(glGetUniformLocation(shaderProgramHandle, "LightRadius"), 40.0f);
glUniform1f(glGetUniformLocation(shaderProgramHandle, "MaterialShininess"), modelJob->Shininess); glUniform1f(glGetUniformLocation(shaderProgramHandle, "MaterialShininess"), modelJob->Shininess);
glActiveTexture(GL_TEXTURE0); if (modelJob->DiffuseTexture != nullptr) {
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture); glActiveTexture(GL_TEXTURE0);
if (modelJob->NormalTexture != 0) { glBindTexture(GL_TEXTURE_2D, *modelJob->DiffuseTexture);
} else {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, *m_ErrorTexture);
}
if (modelJob->NormalTexture != nullptr) {
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture); glBindTexture(GL_TEXTURE_2D, *modelJob->NormalTexture);
} else { } else {
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, *m_StandardNormal); glBindTexture(GL_TEXTURE_2D, *m_StandardNormal);
} }
if (modelJob->SpecularTexture != 0) { if (modelJob->SpecularTexture != nullptr) {
glActiveTexture(GL_TEXTURE2); glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture); glBindTexture(GL_TEXTURE_2D, *modelJob->SpecularTexture);
} else { } else {
glActiveTexture(GL_TEXTURE2); glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, *m_StandardSpecular); glBindTexture(GL_TEXTURE_2D, *m_StandardSpecular);
@@ -445,8 +452,8 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program)
} }
} }
glBindVertexArray(modelJob->VAO); glBindVertexArray(modelJob->Model->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->ElementBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, 0, modelJob->StartIndex); glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, 0, modelJob->StartIndex);
continue; continue;
@@ -463,11 +470,11 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program)
glUniform4fv(glGetUniformLocation(shaderProgramHandle, "Color"), 1, glm::value_ptr(spriteJob->Color)); glUniform4fv(glGetUniformLocation(shaderProgramHandle, "Color"), 1, glm::value_ptr(spriteJob->Color));
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture); glBindTexture(GL_TEXTURE_2D, *spriteJob->DiffuseTexture);
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, spriteJob->NormalTexture); glBindTexture(GL_TEXTURE_2D, *spriteJob->NormalTexture);
glActiveTexture(GL_TEXTURE2); glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, spriteJob->SpecularTexture); glBindTexture(GL_TEXTURE_2D, *spriteJob->SpecularTexture);
glBindVertexArray(m_UnitQuad->VAO); glBindVertexArray(m_UnitQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_UnitQuad->ElementBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_UnitQuad->ElementBuffer);
@@ -688,7 +695,7 @@ void dd::Renderer::DrawGUI(dd::RenderQueue& rq)
glUniform4fv(glGetUniformLocation(*m_SpScreen, "Color"), 1, glm::value_ptr(frameJob->Color)); glUniform4fv(glGetUniformLocation(*m_SpScreen, "Color"), 1, glm::value_ptr(frameJob->Color));
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, frameJob->DiffuseTexture); glBindTexture(GL_TEXTURE_2D, *frameJob->DiffuseTexture);
//glActiveTexture(GL_TEXTURE1); //glActiveTexture(GL_TEXTURE1);
//glBindTexture(GL_TEXTURE_2D, frameJob->NormalTexture); //glBindTexture(GL_TEXTURE_2D, frameJob->NormalTexture);
//glActiveTexture(GL_TEXTURE2); //glActiveTexture(GL_TEXTURE2);