Added projection matrix; Now 3D
This commit is contained in:
1 parent
bd8df1c2cf
commit
4f1ea8327a
9 files changed
+13
-8
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace nf {
|
||||
Entity::Entity() :
|
||||
m_model(nullptr),
|
||||
m_position(0.0),
|
||||
m_rotation(0.0),
|
||||
m_scale(1.0)
|
||||
@@ -14,7 +15,7 @@ namespace nf {
|
||||
m_model->create(vertexBufferData, vertexBufferSize, indexBufferData, indexBufferCount);
|
||||
}
|
||||
|
||||
void Entity::setLocation(float x, float y, float z) {
|
||||
void Entity::setPosition(float x, float y, float z) {
|
||||
m_position = { x, y, z };
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@ namespace nf {
|
||||
void Model::create(const void* vertexBufferData, const size_t vertexBufferSize, const void* indexBufferData, size_t indexBufferCount) {
|
||||
m_vao = new VertexArray;
|
||||
m_vao->addBuffer(vertexBufferData, vertexBufferSize);
|
||||
m_vao->push<float>(2);
|
||||
//TODO: Change this to 3
|
||||
m_vao->push<float>(3);
|
||||
m_vao->finishBufferLayout();
|
||||
m_ib = new IndexBuffer(indexBufferData, indexBufferCount);
|
||||
}
|
||||
|
||||
@@ -70,11 +70,13 @@ namespace nf {
|
||||
|
||||
void Renderer::doFrame() {
|
||||
glViewport(0, 0, m_app->getConfig().width, m_app->getConfig().height);
|
||||
proj = glm::perspective(glm::radians(45.0f), (float)m_app->getConfig().width / (float)m_app->getConfig().height, 0.1f, 100.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
for (Entity* draw : m_lGame) {
|
||||
Entity& curr = *draw;
|
||||
curr.bind(m_defaultShader);
|
||||
m_defaultShader->setUniform("proj", proj);
|
||||
glDrawElements(GL_TRIANGLES, curr.getModel()->getIndexCount(), GL_UNSIGNED_INT, nullptr);
|
||||
}
|
||||
m_lGame.clear();
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace nf {
|
||||
}
|
||||
|
||||
void Shader::setUniform(const char* name, glm::mat4& data) {
|
||||
if (m_uniformLocations.find(name) != m_uniformLocations.end())
|
||||
if (m_uniformLocations.find(name) == m_uniformLocations.end())
|
||||
getUniformLocation(name);
|
||||
glUniformMatrix4fv(m_uniformLocations[name], 1, GL_FALSE, glm::value_ptr(data));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user