[EDIT] renaming the static_shader
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
|
||||
namespace entities
|
||||
{
|
||||
/*
|
||||
* This class represents the viewport of the game. The whole game is seen through this class
|
||||
*/
|
||||
|
||||
class Camera
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "renderEngine/loader.h"
|
||||
#include "renderEngine/obj_loader.h"
|
||||
#include "renderEngine/renderer.h"
|
||||
#include "shaders/static_shader.h"
|
||||
#include "shaders/entity_shader.h"
|
||||
#include "toolbox/toolbox.h"
|
||||
|
||||
#pragma comment(lib, "glfw3.lib")
|
||||
@@ -46,7 +46,7 @@ int main(void)
|
||||
});
|
||||
|
||||
|
||||
models::RawModel raw_model = LoadObjModel("res/Tree.obj");
|
||||
models::RawModel raw_model = render_engine::LoadObjModel("res/Tree.obj");
|
||||
models::ModelTexture texture = { render_engine::loader::LoadTexture("res/TreeTexture.png") };
|
||||
texture.shine_damper = 10;
|
||||
texture.reflectivity = 1;
|
||||
@@ -55,7 +55,7 @@ int main(void)
|
||||
|
||||
entities::Light light(glm::vec3(0, 0, -30), glm::vec3(1, 1, 1));
|
||||
|
||||
shaders::StaticShader shader;
|
||||
shaders::EntityShader shader;
|
||||
shader.Init();
|
||||
render_engine::renderer::Init(shader);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace render_engine
|
||||
/*
|
||||
This function will load the projectionMatrix into the shader
|
||||
*/
|
||||
void Init(shaders::StaticShader& shader)
|
||||
void Init(shaders::EntityShader& shader)
|
||||
{
|
||||
// Faces which are not facing the camera are not rendered
|
||||
glEnable(GL_CULL_FACE);
|
||||
@@ -43,7 +43,7 @@ namespace render_engine
|
||||
/*
|
||||
This function will Render a Model on the screen.
|
||||
*/
|
||||
void Render(entities::Entity& entity, shaders::StaticShader& shader)
|
||||
void Render(entities::Entity& entity, shaders::EntityShader& shader)
|
||||
{
|
||||
const models::TexturedModel model = entity.GetModel();
|
||||
const models::RawModel raw_model = model.raw_model;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../entities/entity.h"
|
||||
#include "../shaders/static_shader.h"
|
||||
#include "../shaders/entity_shader.h"
|
||||
|
||||
namespace render_engine
|
||||
{
|
||||
@@ -10,7 +10,7 @@ namespace render_engine
|
||||
/*
|
||||
Call this function when starting the program
|
||||
*/
|
||||
void Init(shaders::StaticShader& shader);
|
||||
void Init(shaders::EntityShader& shader);
|
||||
|
||||
/*
|
||||
Call this function before rendering.
|
||||
@@ -20,6 +20,6 @@ namespace render_engine
|
||||
/*
|
||||
Call this function when wanting to Render a mesh to the screen.
|
||||
*/
|
||||
void Render(entities::Entity& entity, shaders::StaticShader& shader);
|
||||
void Render(entities::Entity& entity, shaders::EntityShader& shader);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "loader.h"
|
||||
#include "obj_loader.h"
|
||||
|
||||
namespace render_engine
|
||||
{
|
||||
static void Split(const std::string& s, char delim, std::vector<std::string>& elems)
|
||||
{
|
||||
std::stringstream ss;
|
||||
@@ -109,7 +111,8 @@ models::RawModel LoadObjModel(std::string file_name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (const std::exception& e)
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
// Always go in here
|
||||
}
|
||||
@@ -127,3 +130,4 @@ models::RawModel LoadObjModel(std::string file_name)
|
||||
|
||||
return render_engine::loader::LoadToVAO(vertex_array, texture_array, normal_array, indices);
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,10 @@
|
||||
#include <string>
|
||||
#include "../models/model.h"
|
||||
|
||||
namespace render_engine
|
||||
{
|
||||
/*
|
||||
* This function retrieves an .obj file, loads it into the VBO and returns a RawModel
|
||||
*/
|
||||
models::RawModel LoadObjModel(std::string file_name);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "static_shader.h"
|
||||
#include "entity_shader.h"
|
||||
#include "../toolbox/toolbox.h"
|
||||
|
||||
namespace shaders
|
||||
@@ -90,39 +90,39 @@ namespace shaders
|
||||
)";
|
||||
|
||||
|
||||
StaticShader::StaticShader(): ShaderProgram(vertex_shader, fragment_shader)
|
||||
EntityShader::EntityShader(): ShaderProgram(vertex_shader, fragment_shader)
|
||||
{
|
||||
}
|
||||
|
||||
void StaticShader::LoadModelMatrix(const glm::mat4& matrix) const
|
||||
void EntityShader::LoadModelMatrix(const glm::mat4& matrix) const
|
||||
{
|
||||
LoadMatrix(location_model_matrix, matrix);
|
||||
}
|
||||
|
||||
void StaticShader::LoadProjectionMatrix(const glm::mat4& projection) const
|
||||
void EntityShader::LoadProjectionMatrix(const glm::mat4& projection) const
|
||||
{
|
||||
LoadMatrix(location_projection_matrix, projection);
|
||||
}
|
||||
|
||||
void StaticShader::LoadViewMatrix(entities::Camera& camera) const
|
||||
void EntityShader::LoadViewMatrix(entities::Camera& camera) const
|
||||
{
|
||||
const glm::mat4 view_matrix = toolbox::CreateViewMatrix(camera);
|
||||
LoadMatrix(location_view_matrix, view_matrix);
|
||||
}
|
||||
|
||||
void StaticShader::LoadLight(entities::Light& light) const
|
||||
void EntityShader::LoadLight(entities::Light& light) const
|
||||
{
|
||||
LoadVector(location_light_position, light.GetPosition());
|
||||
LoadVector(location_light_color, light.GetColor());
|
||||
}
|
||||
|
||||
void StaticShader::LoadShineVariables(float shine_damper, float reflectivity) const
|
||||
void EntityShader::LoadShineVariables(float shine_damper, float reflectivity) const
|
||||
{
|
||||
LoadFloat(location_shine_damper, shine_damper);
|
||||
LoadFloat(location_reflectivity, reflectivity);
|
||||
}
|
||||
|
||||
void StaticShader::SetAttributes() const
|
||||
void EntityShader::SetAttributes() const
|
||||
{
|
||||
// Load the position VBO and textureCoords VBO from the VAO into the shader "in" variables
|
||||
SetAttribute(0, "position");
|
||||
@@ -130,7 +130,7 @@ namespace shaders
|
||||
SetAttribute(2, "normal");
|
||||
}
|
||||
|
||||
void StaticShader::GetAllUniformLocations()
|
||||
void EntityShader::GetAllUniformLocations()
|
||||
{
|
||||
// Get the locations from the uniform variables from the shaders
|
||||
location_model_matrix = GetUniformLocation("model_matrix");
|
||||
@@ -6,12 +6,12 @@
|
||||
#include "../entities/light.h"
|
||||
|
||||
/*
|
||||
This class does represents the shaders for the models.
|
||||
This class handles the shaders for the entities.
|
||||
*/
|
||||
|
||||
namespace shaders
|
||||
{
|
||||
class StaticShader : public ShaderProgram
|
||||
class EntityShader : public ShaderProgram
|
||||
{
|
||||
private:
|
||||
GLuint location_model_matrix;
|
||||
@@ -23,7 +23,7 @@ namespace shaders
|
||||
GLuint location_reflectivity;
|
||||
|
||||
public:
|
||||
StaticShader();
|
||||
EntityShader();
|
||||
|
||||
void LoadModelMatrix(const glm::mat4& matrix) const;
|
||||
void LoadProjectionMatrix(const glm::mat4& projection) const;
|
||||
@@ -26,7 +26,7 @@
|
||||
<ClCompile Include="src\renderEngine\obj_loader.cpp" />
|
||||
<ClCompile Include="src\renderEngine\renderer.cpp" />
|
||||
<ClCompile Include="src\shaders\shader_program.cpp" />
|
||||
<ClCompile Include="src\shaders\static_shader.cpp" />
|
||||
<ClCompile Include="src\shaders\entity_shader.cpp" />
|
||||
<ClCompile Include="src\toolbox\toolbox.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -38,7 +38,7 @@
|
||||
<ClInclude Include="src\renderEngine\obj_loader.h" />
|
||||
<ClInclude Include="src\renderEngine\renderer.h" />
|
||||
<ClInclude Include="src\shaders\shader_program.h" />
|
||||
<ClInclude Include="src\shaders\static_shader.h" />
|
||||
<ClInclude Include="src\shaders\entity_shader.h" />
|
||||
<ClInclude Include="src\stb_image.h" />
|
||||
<ClInclude Include="src\toolbox\toolbox.h" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -33,15 +33,15 @@
|
||||
<ClCompile Include="src\shaders\shader_program.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\shaders\static_shader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\renderEngine\obj_loader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\toolbox\toolbox.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\shaders\entity_shader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\entities\Camera.h">
|
||||
@@ -65,9 +65,6 @@
|
||||
<ClInclude Include="src\shaders\shader_program.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\shaders\static_shader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\renderEngine\obj_loader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -77,5 +74,8 @@
|
||||
<ClInclude Include="src\entities\light.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\shaders\entity_shader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user