7cbe8acf30
Now the code is being compiled through .lib files!
55 lines
1.9 KiB
C++
55 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <charcoal/Batch.h>
|
|
#include <charcoal/Renderable.h>
|
|
#include <charcoal/Poseable2D.h>
|
|
|
|
#include "BuiltinBatch.h"
|
|
|
|
namespace charcoal
|
|
{
|
|
namespace builtin
|
|
{
|
|
// This has to be made completely seperately in order to avoid the vtable that gets added if Poseable is abstracted between
|
|
// 2D and 3D
|
|
template <typename VertexType, typename IndexType, typename RenderableT = RenderableT<VertexType, IndexType> >
|
|
class Poseable2DBatch : public builtin::Batch<VertexType, IndexType, 1, RenderableT>
|
|
{
|
|
public:
|
|
Poseable2DBatch(
|
|
RenderableT* renderable,
|
|
int element_count
|
|
) : Poseable2DBatch(renderable, element_count, element_count)
|
|
{}
|
|
|
|
Poseable2DBatch(
|
|
RenderableT* renderable,
|
|
int element_count,
|
|
int element_render_count
|
|
) : builtin::Batch<VertexType, IndexType, 1, RenderableT>(renderable, element_render_count), m_pose_elements(element_count)
|
|
{}
|
|
|
|
virtual ~Poseable2DBatch() {}
|
|
|
|
Poseable2D& get_pose(int index) { return m_pose_elements[index]; }
|
|
const Poseable2D& get_pose(int index) const { return m_pose_elements[index]; }
|
|
|
|
protected:
|
|
void setup_element_buffers()
|
|
{
|
|
glBindBuffer(GL_ARRAY_BUFFER, charcoal::Batch<VertexType, IndexType, 1, RenderableT>::m_element_buffers[0]);
|
|
glBufferData(GL_ARRAY_BUFFER, m_pose_elements.size() * sizeof(Poseable), NULL, GL_STREAM_DRAW);
|
|
}
|
|
|
|
void update_element_buffers()
|
|
{
|
|
// TODO: There are probably better ways to do this. Should check with the old engine to see what I did there.
|
|
glBindBuffer(GL_ARRAY_BUFFER, charcoal::Batch<VertexType, IndexType, 1, RenderableT>::m_element_buffers[0]);
|
|
glBufferData(GL_ARRAY_BUFFER, m_pose_elements.size() * sizeof(Poseable), NULL, GL_STREAM_DRAW);
|
|
glBufferSubData(GL_ARRAY_BUFFER, 0, m_pose_elements.size() * sizeof(Poseable), m_pose_elements.data());
|
|
}
|
|
|
|
std::vector<Poseable2D> m_pose_elements;
|
|
};
|
|
}
|
|
} |