add particles (WIP)

This commit is contained in:
MihailRis
2024-11-02 20:40:40 +03:00
parent a0f885e26a
commit 217176f74f
8 changed files with 280 additions and 4 deletions
+55 -1
View File
@@ -29,13 +29,18 @@ public:
~MainBatch();
void begin();
void prepare(int vertices);
void setTexture(const Texture* texture);
void setTexture(const Texture* texture, const UVRegion& region);
void flush();
inline void vertex(
glm::vec3 pos, glm::vec2 uv, glm::vec4 light, glm::vec3 tint
const glm::vec3& pos,
const glm::vec2& uv,
const glm::vec4& light,
const glm::vec3& tint
) {
float* buffer = this->buffer.get();
buffer[index++] = pos.x;
@@ -59,4 +64,53 @@ public:
buffer[index++] = compressed.floating;
}
inline void quad(
const glm::vec3& pos,
const glm::vec3& right,
const glm::vec3& up,
const glm::vec2& size,
const glm::vec4& light,
const glm::vec3& tint,
const UVRegion& subregion
) {
prepare(6);
vertex(
pos - right * size.x * 0.5f - up * size.y * 0.5f,
{subregion.u1, subregion.v1},
light,
tint
);
vertex(
pos + right * size.x * 0.5f - up * size.y * 0.5f,
{subregion.u2, subregion.v1},
light,
tint
);
vertex(
pos + right * size.x * 0.5f + up * size.y * 0.5f,
{subregion.u2, subregion.v2},
light,
tint
);
vertex(
pos - right * size.x * 0.5f - up * size.y * 0.5f,
{subregion.u1, subregion.v1},
light,
tint
);
vertex(
pos + right * size.x * 0.5f + up * size.y * 0.5f,
{subregion.u2, subregion.v2},
light,
tint
);
vertex(
pos - right * size.x * 0.5f + up * size.y * 0.5f,
{subregion.u1, subregion.v2},
light,
tint
);
}
};