aboutsummaryrefslogtreecommitdiffstats
path: root/yage/render/rectangle.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-12-27 19:21:12 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-12-27 19:21:12 +0000
commit354d7df4d2779ed7391701d1ef4344e959b64582 (patch)
tree81ecdc8d323cae78a86fb9c99524f57c705eeabc /yage/render/rectangle.cpp
parentf949692714e72a0e2d45ebb6a5d698424ab71dee (diff)
downloadYAGE-354d7df4d2779ed7391701d1ef4344e959b64582.tar.gz
YAGE-354d7df4d2779ed7391701d1ef4344e959b64582.zip
[Broken] Texture is black.
Diffstat (limited to 'yage/render/rectangle.cpp')
-rw-r--r--yage/render/rectangle.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/yage/render/rectangle.cpp b/yage/render/rectangle.cpp
new file mode 100644
index 00000000..365d058d
--- /dev/null
+++ b/yage/render/rectangle.cpp
@@ -0,0 +1,37 @@
+#include "rectangle.h"
+
+#include "../data/vertex.h"
+
+#include <glad/glad.h>
+
+#include <cstddef>
+
+namespace yage
+{
+
+Rectangle::Rectangle(glm::vec4 position) : position_(position) {}
+
+void Rectangle::render() const
+{
+ // create vertex array
+ GLuint rect_vao, rect_vbo;
+
+ // bind vertex array object
+ glGenVertexArrays(1, &rect_vao);
+ glBindVertexArray(rect_vao);
+
+ // bind vertex buffer object
+ glGenBuffers(1, &rect_vbo);
+ glBindBuffer(GL_ARRAY_BUFFER, rect_vbo);
+
+ // enable vertex attribute arrays
+ glEnableVertexAttribArray(0);
+ glEnableVertexAttribArray(1);
+
+ // set the vertex attribute pointers
+ glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void *)offsetof(Vertex, position));
+
+ glBindVertexArray(0);
+}
+
+} // namepsace yage