#pragma once

#include "../../api/Models.hpp"
#include <GL/gl3w.h>
#include <vector>
#include <glm/glm.hpp>

namespace render::gl {

/// Positions only buffer
class Shape final: public render::Shape {
public:
    Shape(const std::vector<glm::vec3>&);
    ~Shape();

    size_t draw(GLenum format);

private:
    size_t size;
    GLuint bufferId;
};

class ColoredShape final: public render::ColoredShape {
public:
    ColoredShape(const std::vector<glm::vec3>&, const std::vector<glm::vec4>&);
    ~ColoredShape();

    size_t draw();
    size_t drawInstanced(size_t count);

private:
    size_t size;
    GLuint vertexBufferId;
    GLuint colorBufferId;

    void enableAttribs();
    void disableAttribs();
};

class Model final: public render::Model {
public:
    Model(const Data&);
    ~Model();

    static void MakeDefault();

    size_t draw();
    size_t drawInstanced(size_t count);

private:
    size_t indexSize;
    GLuint vertexBufferId;
    GLuint indexBufferId;
};
class LodModel final: public render::LodModel {
public:
    LodModel(const LodData&);
    ~LodModel();

    static void MakeDefault();

    size_t draw();
    size_t drawInstanced(size_t count);

private:
    GLuint vertexBufferId;
    GLuint indexBufferId;
};

}