charcoal/CharcoalBuiltin/TexturedBatch.h

40 lines
1.0 KiB
C
Raw Permalink Normal View History

#pragma once
#include "TexturedTypes.h"
#include "TexturedRenderable.h"
#include "PoseableBatch.h"
namespace charcoal
{
namespace builtin
{
namespace textured
{
class Batch : public PoseableBatch<Vertex, Index, 2, Renderable>
{
public:
using PoseableBatch<Vertex, Index, 2, Renderable>::PoseableBatch;
protected:
void setup_vao_vertex() override
{
glBindBuffer(GL_ARRAY_BUFFER, m_vertex_vbo);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, position));
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, uv));
glVertexAttribDivisor(0, 0);
glVertexAttribDivisor(1, 0);
}
void preprender() const override {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_p_renderable->get_texture()->get_texture());
glBindSampler(0, m_p_renderable->get_sampler()->get_sampler());
}
};
}
}
}