WIP Renderer
This commit is contained in:
@@ -60,18 +60,13 @@ void Renderer::Draw(double _dt)
|
|||||||
for(int i = 0; i < ModelsToRender.size(); i++)
|
for(int i = 0; i < ModelsToRender.size(); i++)
|
||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
//FIXA MED FLERA TEXTURER
|
|
||||||
glBindTexture(GL_TEXTURE_2D, ModelsToRender[i]->model->texture[0]->texture);
|
glBindTexture(GL_TEXTURE_2D, ModelsToRender[i]->model->texture[0]->texture);
|
||||||
MVP = cameraMatrix; // * ModelMatrix;
|
MVP = cameraMatrix * ModelsToRender[i]->ModelMatrix;
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||||
glBindVertexArray(ModelsToRender[i]->model->VAO);
|
glBindVertexArray(ModelsToRender[i]->model->VAO);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, ModelsToRender[i]->model->Vertices.size());
|
glDrawArrays(GL_TRIANGLES, 0, ModelsToRender[i]->model->Vertices.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelsToRender.clear();
|
ModelsToRender.clear();
|
||||||
// Vertices;
|
|
||||||
// std::vector<glm::vec3> Normals;
|
|
||||||
// std::vector<glm::vec2> TextureCoords;
|
|
||||||
|
|
||||||
glfwSwapBuffers(m_Window);
|
glfwSwapBuffers(m_Window);
|
||||||
}
|
}
|
||||||
@@ -86,9 +81,12 @@ void Renderer::AddTextToDraw()
|
|||||||
//Add to draw shit vector
|
//Add to draw shit vector
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::AddModelToDraw(Model* _model, glm::mat4 _modelMatrix)
|
void Renderer::AddModelToDraw(Model* _model, glm::vec3 _position, glm::quat _orientation)
|
||||||
{
|
{
|
||||||
ModelsToRender.push_back(new ModelData(_model, _modelMatrix));
|
glm::mat4 RotationMatrix = glm::toMat4(_orientation);
|
||||||
|
glm::mat4 ModelMatrix = glm::translate(glm::mat4(), _position) * RotationMatrix ;
|
||||||
|
// You can now use ModelMatrix to build the MVP matrix
|
||||||
|
ModelsToRender.push_back(new ModelData(_model, ModelMatrix));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fixa med shaders, lägga in alla verts osv.
|
//Fixa med shaders, lägga in alla verts osv.
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#include <glm/gtc/constants.hpp>
|
#include <glm/gtc/constants.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
#include <glm/gtx/quaternion.hpp>
|
||||||
|
|
||||||
#include "glerror.h"
|
#include "glerror.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
@@ -35,8 +37,8 @@ public:
|
|||||||
struct ModelData
|
struct ModelData
|
||||||
{
|
{
|
||||||
Model* model;
|
Model* model;
|
||||||
glm::mat4 modelMatrix;
|
glm::mat4 ModelMatrix;
|
||||||
ModelData(Model* _model, glm::mat4 _modelMatrix) : model(_model), modelMatrix(_modelMatrix)
|
ModelData(Model* _model, glm::mat4 _modelMatrix) : model(_model), ModelMatrix(_modelMatrix)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ public:
|
|||||||
void Draw(double dt);
|
void Draw(double dt);
|
||||||
void DrawText();
|
void DrawText();
|
||||||
|
|
||||||
void AddModelToDraw(Model*, glm::mat4);
|
void AddModelToDraw(Model*, glm::vec3, glm::quat);
|
||||||
void AddTextToDraw();
|
void AddTextToDraw();
|
||||||
|
|
||||||
void LoadContent();
|
void LoadContent();
|
||||||
|
|||||||
Reference in New Issue
Block a user