diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-12-20 20:21:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-20 20:21:40 +0100 |
commit | d8201e470891376d74a2b9e28743e8ba2f57174e (patch) | |
tree | bf748a539a3c9c18e3fefcba0c2be4ab5e0c67a8 /src/RendererEntity.cpp | |
parent | Merge pull request #28 from uis246/iss11 (diff) | |
parent | Fixes #29 (diff) | |
download | AltCraft-d8201e470891376d74a2b9e28743e8ba2f57174e.tar AltCraft-d8201e470891376d74a2b9e28743e8ba2f57174e.tar.gz AltCraft-d8201e470891376d74a2b9e28743e8ba2f57174e.tar.bz2 AltCraft-d8201e470891376d74a2b9e28743e8ba2f57174e.tar.lz AltCraft-d8201e470891376d74a2b9e28743e8ba2f57174e.tar.xz AltCraft-d8201e470891376d74a2b9e28743e8ba2f57174e.tar.zst AltCraft-d8201e470891376d74a2b9e28743e8ba2f57174e.zip |
Diffstat (limited to 'src/RendererEntity.cpp')
-rw-r--r-- | src/RendererEntity.cpp | 62 |
1 files changed, 20 insertions, 42 deletions
diff --git a/src/RendererEntity.cpp b/src/RendererEntity.cpp index a987139..d465a07 100644 --- a/src/RendererEntity.cpp +++ b/src/RendererEntity.cpp @@ -8,53 +8,30 @@ #include "Renderer.hpp" const GLfloat vertices[] = { - //Z+ edge -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, + -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, - -0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, - - //Z- edge - -0.5f, -0.5f, -0.5f, + 0.5f, 0.5f, 0.5f, + -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, + -0.5f, -0.5f, -0.5f, + -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, - -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, - - //X+ edge - -0.5f, -0.5f, -0.5f, - -0.5f, -0.5f, 0.5f, - -0.5f, 0.5f, -0.5f, + 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, + -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, - - //X- edge - 0.5f, -0.5f, 0.5f, - 0.5f, 0.5f, -0.5f, - 0.5f, 0.5f, 0.5f, - 0.5f, -0.5f, 0.5f, - 0.5f, -0.5f, -0.5f, - 0.5f, 0.5f, -0.5f, - - //Y+ edge - 0.5f, 0.5f, -0.5f, - -0.5f, 0.5f, 0.5f, - 0.5f, 0.5f, 0.5f, - 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, - -0.5f, 0.5f, 0.5f, - - //Y- edge - -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, - -0.5f, -0.5f, -0.5f, - 0.5f, -0.5f, -0.5f, - -0.5f, -0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, -0.5f }; const GLfloat uv_coords[] = { @@ -110,12 +87,7 @@ const GLfloat uv_coords[] = { const GLuint magic = 993214; GLuint Vbo = magic,Vao = magic,Vbo2 = magic; -RendererEntity::RendererEntity(World *ptr, unsigned int id) -{ - world = ptr; - entityId = id; - - +GLuint RendererEntity::GetVao(){ if (Vbo == magic) { glGenBuffers(1, &Vbo); glBindBuffer(GL_ARRAY_BUFFER, Vbo); @@ -128,7 +100,7 @@ RendererEntity::RendererEntity(World *ptr, unsigned int id) glGenVertexArrays(1, &Vao); glBindVertexArray(Vao); { - glBindBuffer(GL_ARRAY_BUFFER, Vbo); + glBindBuffer(GL_ARRAY_BUFFER, Vbo); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0); glEnableVertexAttribArray(0); @@ -138,13 +110,19 @@ RendererEntity::RendererEntity(World *ptr, unsigned int id) } glBindVertexArray(0); } + return Vao; +} + +RendererEntity::RendererEntity(World *ptr, unsigned int id) +{ + world = ptr; + entityId = id; } RendererEntity::~RendererEntity() { } void RendererEntity::Render(RenderState & renderState) { - renderState.SetActiveVao(Vao); glm::mat4 model = glm::mat4(1.0); Entity& entity = world->GetEntity(entityId); model = glm::translate(model, entity.pos.glm()); @@ -154,7 +132,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_LINE_STRIP, 0, 36); + glDrawArrays(GL_LINES, 0, 24); glCheckError(); -}
\ No newline at end of file +} |