#pragma once
#include "../object.h"

namespace render{

class vertexBuffer:_object
{
public:
    vertexBuffer();
    ~vertexBuffer();
    vertexBuffer(const _object&) = delete;
    vertexBuffer(const vertexBuffer&) = delete;

    void gen();
    void free();

    void bind(int = 0);
    void unbind();

    template<typename T>
    void data(unsigned count, const T* data, unsigned usage = 0x88E8)
    {
        _data(count*sizeof(T), data, usage);
    }

    template<typename T>
    void subData(unsigned count, const T* data, int offset = 0)
    {
        _subData(count*sizeof(T), data, offset);
    }

    void createEmptyBuffer(unsigned size, unsigned usage = 0x88E8);
private:
    unsigned obj, mode;

    void _data(unsigned, const void*, unsigned);
    void _subData(unsigned, const void*, int);
    void _alloc();
};

}
