[FEATURE] single light support
This commit is contained in:
@@ -17,9 +17,14 @@ namespace render_engine
|
||||
*/
|
||||
void Init(shaders::StaticShader& shader)
|
||||
{
|
||||
// Faces which are not facing the camera are not rendered
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
const glm::mat4 projectionMatrix =
|
||||
glm::perspective(glm::radians(FOV), (WINDOW_WIDTH / WINDOW_HEIGT), NEAR_PLANE, FAR_PLANE);
|
||||
|
||||
|
||||
// Load the projectionmatrix into the shader
|
||||
shader.Start();
|
||||
shader.LoadProjectionMatrix(projectionMatrix);
|
||||
shader.Stop();
|
||||
@@ -41,26 +46,31 @@ namespace render_engine
|
||||
void Render(entities::Entity& entity, shaders::StaticShader& shader)
|
||||
{
|
||||
const models::TexturedModel model = entity.GetModel();
|
||||
const models::RawModel rawModel = model.raw_model;
|
||||
const models::RawModel raw_model = model.raw_model;
|
||||
const models::ModelTexture texture = model.texture;
|
||||
|
||||
// Enable the model
|
||||
glBindVertexArray(rawModel.vao_id);
|
||||
glBindVertexArray(raw_model.vao_id);
|
||||
|
||||
// Enable the inputs for the vertexShader
|
||||
// Enable the VBO's from the model (VAO)
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glEnableVertexAttribArray(2);
|
||||
|
||||
// Load the transformation of the model into the shader
|
||||
const glm::mat4 modelMatrix = toolbox::CreateModelMatrix(entity.GetPosition(), entity.GetRotation(), entity.GetScale());
|
||||
shader.LoadModelMatrix(modelMatrix);
|
||||
shader.LoadShineVariables(texture.shine_damper, texture.reflectivity);
|
||||
|
||||
// Draw the model
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, model.texture.texture_id);
|
||||
glDrawElements(GL_TRIANGLES, rawModel.vertex_count, GL_UNSIGNED_INT, 0);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, raw_model.vertex_count, GL_UNSIGNED_INT, 0);
|
||||
|
||||
// Disable the VBO's and model
|
||||
glDisableVertexAttribArray(0);
|
||||
glDisableVertexAttribArray(1);
|
||||
glDisableVertexAttribArray(2);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user