summaryrefslogtreecommitdiffstats
path: root/src/RendererEntity.cpp
diff options
context:
space:
mode:
authoruis <uis9936@gmail.com>2018-12-19 12:45:39 +0100
committeruis <uis9936@gmail.com>2018-12-20 20:01:07 +0100
commit3770fee3778f74112d3687ad0c382f0aefa5d7a4 (patch)
treebf748a539a3c9c18e3fefcba0c2be4ab5e0c67a8 /src/RendererEntity.cpp
parent #11 Single field for ip and port (diff)
downloadAltCraft-3770fee3778f74112d3687ad0c382f0aefa5d7a4.tar
AltCraft-3770fee3778f74112d3687ad0c382f0aefa5d7a4.tar.gz
AltCraft-3770fee3778f74112d3687ad0c382f0aefa5d7a4.tar.bz2
AltCraft-3770fee3778f74112d3687ad0c382f0aefa5d7a4.tar.lz
AltCraft-3770fee3778f74112d3687ad0c382f0aefa5d7a4.tar.xz
AltCraft-3770fee3778f74112d3687ad0c382f0aefa5d7a4.tar.zst
AltCraft-3770fee3778f74112d3687ad0c382f0aefa5d7a4.zip
Diffstat (limited to '')
-rw-r--r--src/RendererEntity.cpp62
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
+}