yupplemayham/YuppleMayham/include/graphics/quad.h

56 lines
1.2 KiB
C++

#ifndef _H_QUAD_H
#define _H_QUAD_H
#include <thirdparty/glad/glad.h>
#include <cstring>
class Quad
{
public:
void draw();
~Quad();
protected:
Quad(const float* vertexData);
private:
unsigned indices[6] = {
0, 1, 2,
3, 2, 0
};
// Vertex Array, Vertex Buffer, Element Buffer
unsigned VAO, VBO, EBO;
float vertices[20];
};
class UnitQuad : public Quad
{
public:
UnitQuad() : Quad(vertices) {}
private:
// simple rectangle. Most scales will be done based on this generic vertex data.
static constexpr float vertices[20] = {
// vertex texturecoords
-0.5f, -0.5f, 0.0f, 0.0f, 0.0f, // bottom left
0.5f, -0.5f, 0.0f, 1.0f, 0.0f, // bottom right
0.5f, 0.5f, 0.0f, 1.0f, 1.0f, // top right
-0.5f, 0.5f, 0.0f, 0.0f, 1.0f // top left
};
};
class ScreenQuad : public Quad
{
public:
ScreenQuad() : Quad(vertices) {}
private:
// simple rectangle. Most scales will be done based on this generic vertex data.
static constexpr float vertices[20] = {
// vertex texturecoords
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, // bottom left
1.0f, -1.0f, 0.0f, 1.0f, 0.0f, // bottom right
1.0f, 1.0f, 0.0f, 1.0f, 1.0f, // top right
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f // top left
};
};
#endif // _H_QUAD_H