summaryrefslogtreecommitdiffhomepage
path: root/src/batch.hpp
blob: 444a5477b84884d14dfcb747628c9dffa9fbbb8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
				);
};