[EDIT] comments on each function
This commit is contained in:
@@ -12,6 +12,7 @@ namespace entities
|
|||||||
class Camera
|
class Camera
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
// The movement speed of the camera
|
||||||
const float SPEED = 0.52f;
|
const float SPEED = 0.52f;
|
||||||
|
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
@@ -20,6 +21,11 @@ namespace entities
|
|||||||
public:
|
public:
|
||||||
Camera(const ::glm::vec3& position, const ::glm::vec3& rotation);
|
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);
|
void Move(GLFWwindow* window);
|
||||||
|
|
||||||
inline glm::vec3 GetPosition() const{ return position; }
|
inline glm::vec3 GetPosition() const{ return position; }
|
||||||
|
|||||||
@@ -20,7 +20,18 @@ namespace entities
|
|||||||
public:
|
public:
|
||||||
Entity(const models::TexturedModel& model, const glm::vec3& position, const glm::vec3& rotation, float scale);
|
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);
|
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);
|
void IncreaseRotation(const glm::vec3& rotation);
|
||||||
|
|
||||||
inline models::TexturedModel GetModel() const{return model;}
|
inline models::TexturedModel GetModel() const{return model;}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
namespace models
|
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).
|
vao_id = The openGL id of the model
|
||||||
The vao_id, points to an ID stored by openGL and the
|
vertex_count = The amount of vertices in the model
|
||||||
vertex_count is how many triangles in the mesh there are.
|
model_size = The size on each axis of the model
|
||||||
*/
|
*/
|
||||||
struct RawModel
|
struct RawModel
|
||||||
{
|
{
|
||||||
@@ -21,6 +21,7 @@ namespace models
|
|||||||
/*
|
/*
|
||||||
Structure for storing a texture (texture_id) to apply to a RawModel.
|
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
|
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
|
reflectivity = The amount of light the model reflects
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,17 +9,24 @@ namespace render_engine
|
|||||||
namespace loader
|
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);
|
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);
|
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();
|
void CleanUp();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,17 +10,23 @@ namespace render_engine
|
|||||||
const glm::vec3 SKY_COLOR = { 0.3f, 0.4f, 0.6f };
|
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);
|
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();
|
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);
|
void Render(entities::Entity& entity, shaders::EntityShader& shader);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
namespace render_engine
|
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);
|
models::RawModel LoadObjModel(std::string file_name);
|
||||||
}
|
}
|
||||||
@@ -26,13 +26,47 @@ namespace shaders
|
|||||||
public:
|
public:
|
||||||
EntityShader();
|
EntityShader();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief: A method to load the model matrix into the shader
|
||||||
|
*
|
||||||
|
* @param matrix: The model matrix
|
||||||
|
*/
|
||||||
void LoadModelMatrix(const glm::mat4& matrix) const;
|
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;
|
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;
|
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;
|
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;
|
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;
|
void LoadSkyColor(glm::vec3 sky_color) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -21,29 +21,87 @@ namespace shaders
|
|||||||
ShaderProgram(std::string& vertex_shader, std::string& fragment_shader);
|
ShaderProgram(std::string& vertex_shader, std::string& fragment_shader);
|
||||||
virtual ~ShaderProgram() = default;
|
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();
|
void Init();
|
||||||
// Call this function before rendering
|
|
||||||
|
/*
|
||||||
|
* @brief: Call this function before rendering
|
||||||
|
*/
|
||||||
void Start() const;
|
void Start() const;
|
||||||
// Call this function after rendering
|
|
||||||
|
/*
|
||||||
|
* @brief: Call this function after rendering
|
||||||
|
*/
|
||||||
void Stop() const;
|
void Stop() const;
|
||||||
// Call this function when closing the application
|
|
||||||
|
/*
|
||||||
|
* @brief: Call this function when closing the application
|
||||||
|
*/
|
||||||
void CleanUp() const;
|
void CleanUp() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Set the inputs of the vertex shader
|
/*
|
||||||
|
* @brief: Set the inputs of the vertex shader
|
||||||
|
*/
|
||||||
virtual void SetAttributes() const = 0;
|
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;
|
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;
|
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;
|
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;
|
void LoadMatrix(GLuint location, glm::mat4 matrix) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief: This function will get all the locations of each uniform variable
|
||||||
|
*/
|
||||||
virtual void GetAllUniformLocations() = 0;
|
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;
|
GLuint GetUniformLocation(const GLchar* uniform_name) const;
|
||||||
|
|
||||||
private:
|
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;
|
GLuint LoadShader(const std::string& shader_string, GLuint type) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,23 @@ namespace toolbox
|
|||||||
#define WINDOW_WIDTH 1400.0f
|
#define WINDOW_WIDTH 1400.0f
|
||||||
#define WINDOW_HEIGT 800.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);
|
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);
|
glm::mat4 CreateViewMatrix(entities::Camera& camera);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user