summaryrefslogtreecommitdiffstats
path: root/src/RendererEntity.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-18 17:13:01 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-18 17:13:01 +0200
commita2fe2786682e626dae25db2d375280c83b615796 (patch)
tree34bc8295ad75b967519959e6300aada5531e2345 /src/RendererEntity.cpp
parent2017-08-17 (diff)
downloadAltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar.gz
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar.bz2
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar.lz
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar.xz
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.tar.zst
AltCraft-a2fe2786682e626dae25db2d375280c83b615796.zip
Diffstat (limited to '')
-rw-r--r--src/RendererEntity.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/RendererEntity.cpp b/src/RendererEntity.cpp
index 3adcf60..6a92cec 100644
--- a/src/RendererEntity.cpp
+++ b/src/RendererEntity.cpp
@@ -109,19 +109,23 @@ RendererEntity::RendererEntity(World *ptr, unsigned int id)
entityId = id;
- if (Vbo == magic || Vao == magic) {
- glGenVertexArrays(1, &Vao);
+ if (Vbo == magic) {
glGenBuffers(1, &Vbo);
+ glBindBuffer(GL_ARRAY_BUFFER, Vbo);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
+
glGenBuffers(1, &Vbo2);
+ glBindBuffer(GL_ARRAY_BUFFER, Vbo2);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(uv_coords), uv_coords, GL_STATIC_DRAW);
+ glGenVertexArrays(1, &Vao);
glBindVertexArray(Vao);
{
- glBindBuffer(GL_ARRAY_BUFFER, Vbo);
- glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
+ glBindBuffer(GL_ARRAY_BUFFER, Vbo);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
+
glBindBuffer(GL_ARRAY_BUFFER, Vbo2);
- glBufferData(GL_ARRAY_BUFFER, sizeof(uv_coords), uv_coords, GL_STATIC_DRAW);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(1);
}
@@ -133,7 +137,7 @@ RendererEntity::~RendererEntity() {
}
void RendererEntity::Render(RenderState & renderState) {
- renderState.SetActiveVao(Vao);
+ renderState.SetActiveVao(Vao);
glm::mat4 model;
Entity& entity = world->GetEntity(entityId);
model = glm::translate(model, entity.pos.glm());
@@ -142,6 +146,7 @@ void RendererEntity::Render(RenderState & renderState) {
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));
glUniform3f(colorLoc, entity.renderColor.x, entity.renderColor.y, entity.renderColor.z);
+ glCheckError();
glDrawArrays(GL_TRIANGLES, 0, 36);
glCheckError();