charcoal/Example/MyBatch.h
elipzer d25b5da9d2 Added a function for resizing element buffers.
This should be useful in the future for allowing for more efficient
resizing of element buffers rather than re-allocating them every
frame.
2018-11-12 11:13:12 -05:00

43 lines
1.2 KiB
C++

#pragma once
#include <charcoal/InstancedElementBatch.h>
#include <charcoal/Poseable.h>
#include "MySimpleShaderProgram.h"
using namespace charcoal;
class MyBatch : public charcoal::InstancedElementBatch<MySimpleShaderProgram::Vertex, MySimpleShaderProgram::Index, 2>
{
public:
MyBatch(
const MySimpleShaderProgram::RenderableT* renderable,
int element_count
) : MyBatch(renderable, element_count, element_count) {}
MyBatch(
const MySimpleShaderProgram::RenderableT* renderable,
int element_count,
int element_render_count
) : InstancedElementBatch(renderable, element_render_count), m_color_elements(element_count), m_poseable_elements(element_count) {}
MySimpleShaderProgram::Color& get_color(int index) { return m_color_elements[index]; }
Poseable& get_pose(int index) { return m_poseable_elements[index]; }
protected:
void setup_element_buffers() override;
void resize_element_buffers() override;
void update_element_buffers() override;
void setup_vao() override;
private:
const int COLOR_VBO_INDEX = 0;
const int POSEABLE_VBO_INDEX = 1;
std::vector<MySimpleShaderProgram::Color> m_color_elements;
std::vector<Poseable> m_poseable_elements;
};