summaryrefslogtreecommitdiffhomepage
path: root/src/batch.hpp
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2022-11-24 21:44:59 -0500
committerrealtradam <[email protected]>2022-11-24 21:44:59 -0500
commitf2a9e986afe980c6b32f7f40d1fe2b0294d86d90 (patch)
tree252b7e7a2a8fa5ff71b1b7953ec9af2492a2ea2d /src/batch.hpp
parentf0f30c12fe919862ade380513c02c9845598ac46 (diff)
downloadOgle-f2a9e986afe980c6b32f7f40d1fe2b0294d86d90.tar.gz
Ogle-f2a9e986afe980c6b32f7f40d1fe2b0294d86d90.zip
implemented proper batch rendering of quads and textures
Diffstat (limited to 'src/batch.hpp')
-rw-r--r--src/batch.hpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/batch.hpp b/src/batch.hpp
new file mode 100644
index 0000000..444a547
--- /dev/null
+++ b/src/batch.hpp
@@ -0,0 +1,45 @@
+#pragma once
+
+#include <vector>
+
+#include "glad/glad.h"
+#include <glm/glm.hpp>
+
+#include "texture.hpp"
+
+class Batch
+{
+ public:
+ unsigned int VAO, VBO, EBO;
+ std::vector<float> vertices = {};
+ std::vector<unsigned int> indices = {};
+ unsigned int size, batch_limit;
+ unsigned int last_texture = 0;
+
+ Batch(unsigned int batch_limit = 8192);
+ int drawTexture(
+ Texture texture,
+ float x,
+ float y,
+ float width,
+ float height,
+ glm::vec4 color
+ );
+ int drawRectangle(
+ float x,
+ float y,
+ float width,
+ float height,
+ glm::vec4 color
+ );
+ void flush_batch();
+ private:
+ int primativeDrawQuad(
+ unsigned int texture_id,
+ glm::vec3 a,
+ glm::vec3 b,
+ glm::vec3 c,
+ glm::vec3 d,
+ glm::vec4 color
+ );
+};