[EDIT] code style guide finished

This commit is contained in:
Menno
2021-05-18 12:43:22 +02:00
parent 41e02b0c39
commit 438b219d0a
17 changed files with 83 additions and 86 deletions

View File

@@ -6,9 +6,9 @@ namespace render_engine
{
namespace loader
{
static GLuint create_vao();
static void store_data_in_attribute_list(int attribute_number, int coordinate_size, std::vector<float>& data);
static void bind_indices_buffer(std::vector<unsigned int>& indices);
static GLuint CreateVao();
static void StoreDataInAttributeList(int attribute_number, int coordinate_size, std::vector<float>& data);
static void BindIndicesBuffer(std::vector<unsigned int>& indices);
static std::vector<GLuint> vaos;
static std::vector<GLuint> vbos;
@@ -19,10 +19,10 @@ namespace render_engine
*/
struct models::RawModel LoadToVAO(std::vector<float>& positions, std::vector<float>& texture_coords, std::vector<unsigned int>& indices)
{
GLuint vao_id = create_vao();
bind_indices_buffer(indices);
store_data_in_attribute_list(0, 3, positions);
store_data_in_attribute_list(1, 2, texture_coords);
GLuint vao_id = CreateVao();
BindIndicesBuffer(indices);
StoreDataInAttributeList(0, 3, positions);
StoreDataInAttributeList(1, 2, texture_coords);
glBindVertexArray(0);
return { vao_id, static_cast<int>(indices.size()) };
}
@@ -61,7 +61,7 @@ namespace render_engine
/*
This function will create a new VAO for a new mesh.
*/
static GLuint create_vao()
static GLuint CreateVao()
{
GLuint vao_id;
glGenVertexArrays(1, &vao_id);
@@ -73,7 +73,7 @@ namespace render_engine
/*
This function can store data (vbo) in a vao.
*/
static void store_data_in_attribute_list(int attribute_number, int coordinate_size, std::vector<float>& data)
static void StoreDataInAttributeList(int attribute_number, int coordinate_size, std::vector<float>& data)
{
GLuint vbo_id;
glGenBuffers(1, &vbo_id);
@@ -105,7 +105,7 @@ namespace render_engine
3,1,2
};
*/
static void bind_indices_buffer(std::vector<unsigned int>& indices)
static void BindIndicesBuffer(std::vector<unsigned int>& indices)
{
GLuint vbo_id;
glGenBuffers(1, &vbo_id);

View File

@@ -2,7 +2,7 @@
#include <string>
#include <vector>
#include "../models/Model.h"
#include "../models/model.h"
namespace render_engine
{

View File

@@ -1,9 +1,8 @@
#include <GL/glew.h>
#include <glm/gtc/matrix_transform.hpp>
#include <iostream>
#include "../models/Model.h"
#include "../models/model.h"
#include "renderer.h"
#include "../toolbox/math.h"
#include "../toolbox/toolbox.h"
namespace render_engine
{
@@ -41,24 +40,24 @@ namespace render_engine
*/
void Render(entities::Entity& entity, shaders::StaticShader& shader)
{
const models::TexturedModel model = entity.getModel();
const models::RawModel rawModel = model.rawModel;
const models::TexturedModel model = entity.GetModel();
const models::RawModel rawModel = model.raw_model;
// Enable the model
glBindVertexArray(rawModel.vaoID);
glBindVertexArray(rawModel.vao_id);
// Enable the inputs for the vertexShader
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
// Load the transformation of the model into the shader
const glm::mat4 modelMatrix = toolbox::CreateModelMatrix(entity.getPosition(), entity.getRotation(), entity.getScale());
const glm::mat4 modelMatrix = toolbox::CreateModelMatrix(entity.GetPosition(), entity.GetRotation(), entity.GetScale());
shader.LoadModelMatrix(modelMatrix);
// Draw the model
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, model.texture.textureID);
glDrawElements(GL_TRIANGLES, rawModel.vertexCount, GL_UNSIGNED_INT, 0);
glBindTexture(GL_TEXTURE_2D, model.texture.texture_id);
glDrawElements(GL_TRIANGLES, rawModel.vertex_count, GL_UNSIGNED_INT, 0);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);

View File

@@ -1,6 +1,6 @@
#pragma once
#include "../entities/Entity.h"
#include "../entities/entity.h"
#include "../shaders/static_shader.h"
namespace render_engine

View File

@@ -1,6 +1,6 @@
#pragma once
#include <string>
#include "../models/Model.h"
#include "../models/model.h"
models::RawModel LoadObjModel(std::string file_name);