#ifndef RENDERER_H
#define RENDERER_H
#include <glad/glad.h>
#include <vector>
#include <string>
#include "shaderClass.h"
class Renderer {
public:
Renderer(Shader& shaderProgram, GLuint* textureIDs, int textureCount);
~Renderer();
struct ColorRGB {
float r, g, b;
ColorRGB(float r, float g, float b) : r(r), g(g), b(b) {}
ColorRGB(int r, int g, int b) : r(r / 255.0f), g(g / 255.0f), b(b / 255.0f) {}
ColorRGB() : r(0), g(0), b(0) {}
};
struct QuadVertices {
GLfloat x1, y1, x2, y2, x3, y3, x4, y4;
};
void renderFrame();
void drawQuad(const QuadVertices& verts, const ColorRGB& color, int textureIndex, const float* uvs = nullptr);
private:
Shader& shaderProgram;
GLuint* textureIDs;
int textureCount;
GLuint masterVAO;
GLuint masterVBO;
GLuint masterEBO;
GLint* textureUniformLocations;
std::vector<std::pair<float, float>> texelSizes;
std::vector<GLfloat> masterVertices;
std::vector<GLuint> masterIndices;
void init();
};
GLuint loadTexture(const char* filepath);
void captureRegion(int x, int y, int w, int h, const std::string& filepath);
#endif