[EDIT] comments on each function

This commit is contained in:
Menno
2021-05-21 15:09:07 +02:00
parent e10aea5a15
commit bb4fcbc97b
9 changed files with 160 additions and 19 deletions

View File

@@ -12,6 +12,7 @@ namespace entities
class Camera
{
private:
// The movement speed of the camera
const float SPEED = 0.52f;
glm::vec3 position;
@@ -20,6 +21,11 @@ namespace entities
public:
Camera(const ::glm::vec3& position, const ::glm::vec3& rotation);
/*
* @brief: This funtion moves the camera's position from the inputs of the keyboard
*
* @param window: The OpenGL window
*/
void Move(GLFWwindow* window);
inline glm::vec3 GetPosition() const{ return position; }

View File

@@ -20,7 +20,18 @@ namespace entities
public:
Entity(const models::TexturedModel& model, const glm::vec3& position, const glm::vec3& rotation, float scale);
/*
* @brief: This function increases the position of the entity
*
* @param distance: The amount of distance in each axis the entity needs to move
*/
void IncreasePosition(const glm::vec3& distance);
/*
* @brief: This function increases the rotation of the entity
*
* @param rotation: The angle of each axis the entity needs to rotate
*/
void IncreaseRotation(const glm::vec3& rotation);
inline models::TexturedModel GetModel() const{return model;}

View File

@@ -5,11 +5,11 @@
namespace models
{
/*
Structure for storing a vboID and vertex_count.
Structure for storing a vboID and vertex_count (this representa a mesh without a model).
This structure represents a Bare bones Model (A mesh without a texture).
The vao_id, points to an ID stored by openGL and the
vertex_count is how many triangles in the mesh there are.
vao_id = The openGL id of the model
vertex_count = The amount of vertices in the model
model_size = The size on each axis of the model
*/
struct RawModel
{
@@ -21,6 +21,7 @@ namespace models
/*
Structure for storing a texture (texture_id) to apply to a RawModel.
texture_id = The openGL id of the textures
shine_damper = A damper for the angle the model needs to be look at to see reflections
reflectivity = The amount of light the model reflects
*/

View File

@@ -9,17 +9,24 @@ namespace render_engine
namespace loader
{
/*
This function generates a model from model data.
@brief: This function generates a model from model data.
@param position: The positions of each vertex (in order: x, y, z) in the model
@param texture_coords: The texture coordinates of the model
@param normals: The normals of each face of the model
@param indices: A list with a sort of lookup table to the positions parameter
*/
models::RawModel LoadToVAO(std::vector<float>& positions, std::vector<float>& texture_coords, std::vector<float>& normals, std::vector<unsigned int>& indices);
/*
Loads a texture from a file into openGL using stb_image.h
@brief: Loads a texture from a file into openGL using stb_image.h
@param file_name: The filepath to the texture
*/
GLuint LoadTexture(std::string file_name);
/*
Call this function when cleaning up all the meshes (when exiting the program).
@brief: Call this function when cleaning up all the meshes (when exiting the program).
*/
void CleanUp();
}

View File

@@ -10,17 +10,23 @@ namespace render_engine
const glm::vec3 SKY_COLOR = { 0.3f, 0.4f, 0.6f };
/*
Call this function when starting the program
@brief: Call this function when starting the program
@param shader: The shader to render the entities with
*/
void Init(shaders::EntityShader& shader);
/*
Call this function before rendering.
@brief: Call this function before rendering.
This function will enable culling and load the projectionMatrix into the shader.
*/
void Prepare();
/*
Call this function when wanting to Render a mesh to the screen.
@brief: Call this function when wanting to Render a mesh to the screen.
@param entity: The entity which needs to be rendered
@param shader: The shader the entity needs to be rendered with
*/
void Render(entities::Entity& entity, shaders::EntityShader& shader);
}

View File

@@ -6,7 +6,9 @@
namespace render_engine
{
/*
* This function retrieves an .obj file, loads it into the VBO and returns a RawModel
* @brief: This function retrieves an .obj file, loads it into the VBO and returns a RawModel
*
* @param file_name: The path to the .obj file
*/
models::RawModel LoadObjModel(std::string file_name);
}

View File

@@ -26,13 +26,47 @@ namespace shaders
public:
EntityShader();
/*
* @brief: A method to load the model matrix into the shader
*
* @param matrix: The model matrix
*/
void LoadModelMatrix(const glm::mat4& matrix) const;
/*
* @brief: A method to load the projection matrix into the shader
*
* @param projection: The projection matrix
*/
void LoadProjectionMatrix(const glm::mat4& projection) const;
/*
* @brief: A method to load the view matrix (camera) into the shader
*
* @param camera: The camera which the scene needs to be rendered from
*/
void LoadViewMatrix(entities::Camera& camera) const;
/*
* @brief: A method to load a light into the shader
*
* @param light: The light
*/
void LoadLight(entities::Light& light) const;
/*
* @brief: A method to load the the shine variables from a model into the shader
*
* @param shine_damper: The dampening of the angle from when to render reflectivity on the vertex
* @param reflectivity: The amount the model reflects
*/
void LoadShineVariables(float shine_damper, float reflectivity) const;
/*
* @brief: A method to load the sky color into the shader. This color will be used for the fog
*
* @param sky_color: The color of the sky
*/
void LoadSkyColor(glm::vec3 sky_color) const;
protected:

View File

@@ -21,29 +21,87 @@ namespace shaders
ShaderProgram(std::string& vertex_shader, std::string& fragment_shader);
virtual ~ShaderProgram() = default;
// Call this function after making the shaderprogram (sets all the attributes of the shader)
/*
* @brief: Call this function after making the shaderprogram (sets all the attributes of the shader)
*/
void Init();
// Call this function before rendering
/*
* @brief: Call this function before rendering
*/
void Start() const;
// Call this function after rendering
/*
* @brief: Call this function after rendering
*/
void Stop() const;
// Call this function when closing the application
/*
* @brief: Call this function when closing the application
*/
void CleanUp() const;
protected:
// Set the inputs of the vertex shader
/*
* @brief: Set the inputs of the vertex shader
*/
virtual void SetAttributes() const = 0;
/*
* @brief: Sets/binds a input variable (in) to a VBO from the model
*
* @param attribute: The id of the VBO
* @param variable_name: The name of the "in" variable in the shader
*/
void SetAttribute(const GLuint attribute, const char* variable_name) const;
// Loads value's (uniform variables) into the shader
/*
* @brief: This function loads a float value into a uniform variable into the shader
*
* @param location: The location of the variable in openGL
* @param value: The value which will be loaded into the variable
*/
void LoadFloat(GLuint location, GLfloat value) const;
/*
* @brief: This function loads a vector value into a uniform variable into the shader
*
* @param location: The location of the variable in openGL
* @param vector: The value which will be loaded into the variable
*/
void LoadVector(GLuint location, glm::vec3 vector) const;
/*
* @brief: This function loads a 4x4 matrix value into a uniform variable into the shader
*
* @param location: The location of the variable in openGL
* @param matrix: The value which will be loaded into the variable
*/
void LoadMatrix(GLuint location, glm::mat4 matrix) const;
/*
* @brief: This function will get all the locations of each uniform variable
*/
virtual void GetAllUniformLocations() = 0;
/*
* @brief: This function will retrieve the location of a uniform variable
*
* @param uniform_name: The name of the uniform variable
*
* @return: The location of the uniform variable
*/
GLuint GetUniformLocation(const GLchar* uniform_name) const;
private:
/*
* @brief: This function will load a shader into openGL
*
* @param shader_string: The shader as a string (the whole code)
* @param type: The type of the shader (Vertex/Fragment)
*
* @return: The id of the shader given by openGL
*/
GLuint LoadShader(const std::string& shader_string, GLuint type) const;
};
}

View File

@@ -7,8 +7,24 @@ namespace toolbox
{
#define WINDOW_WIDTH 1400.0f
#define WINDOW_HEIGT 800.0f
/*
* @brief: This function will create a model matrix
*
* @param translation: The position of the model
* @param rotation: The rotation of the model
* @param scale: The scale of the model
*
* @return: The model matrix of the model
*/
glm::mat4 CreateModelMatrix(glm::vec3 translation, glm::vec3 rotation, float scale);
/*
* @brief: This function will create a view matrix from the camera's position
*
* @param camera: The camera the view matrix needs to be made from
*
* @return: The view matrix
*/
glm::mat4 CreateViewMatrix(entities::Camera& camera);
}