Batch::Batch(PrimitiveType t):
prim_type(t),
+ gl_prim_type(GL::get_gl_primitive_type(prim_type)),
index_type(UNSIGNED_SHORT),
gl_index_type(get_gl_type(index_type)),
max_index(0),
private:
PrimitiveType prim_type;
+ GLenum gl_prim_type;
DataType index_type;
GLenum gl_index_type;
std::vector<UInt8> data;
~Batch();
PrimitiveType get_type() const { return prim_type; }
+ GLenum get_gl_primitive_type() const { return gl_prim_type; }
void set_index_type(DataType);
DataType get_index_type() const { return index_type; }
GLenum get_gl_index_type() const { return gl_index_type; }
{
pipeline_state->apply();
void *data_ptr = reinterpret_cast<void *>(batch.get_offset());
- glDrawElements(batch.get_type(), batch.size(), batch.get_gl_index_type(), data_ptr);
+ glDrawElements(batch.get_gl_primitive_type(), batch.size(), batch.get_gl_index_type(), data_ptr);
}
void Commands::draw_instanced(const Batch &batch, unsigned count)
pipeline_state->apply();
void *data_ptr = reinterpret_cast<void *>(batch.get_offset());
- glDrawElementsInstanced(batch.get_type(), batch.size(), batch.get_gl_index_type(), data_ptr, count);
+ glDrawElementsInstanced(batch.get_gl_primitive_type(), batch.size(), batch.get_gl_index_type(), data_ptr, count);
}
void Commands::resolve_multisample(Framebuffer &target, BufferBits buffers)
#include <msp/strings/format.h>
#include "primitivetype.h"
+using namespace std;
+
namespace Msp {
namespace GL {
+GLenum get_gl_primitive_type(PrimitiveType pt)
+{
+ switch(pt)
+ {
+ case POINTS: return GL_POINTS;
+ case LINES: return GL_LINES;
+ case LINE_STRIP: return GL_LINE_STRIP;
+ case LINE_LOOP: return GL_LINE_LOOP;
+ case TRIANGLES: return GL_TRIANGLES;
+ case TRIANGLE_STRIP: return GL_TRIANGLE_STRIP;
+ case TRIANGLE_FAN: return GL_TRIANGLE_FAN;
+ default: throw invalid_argument("get_gl_primitive_type");
+ }
+}
+
void operator>>(const LexicalConverter &conv, PrimitiveType &pt)
{
if(conv.get()=="POINTS")
enum PrimitiveType
{
- POINTS = GL_POINTS,
- LINES = GL_LINES,
- LINE_STRIP = GL_LINE_STRIP,
- LINE_LOOP = GL_LINE_LOOP,
- TRIANGLES = GL_TRIANGLES,
- TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
- TRIANGLE_FAN = GL_TRIANGLE_FAN
+ POINTS,
+ LINES,
+ LINE_STRIP,
+ LINE_LOOP,
+ TRIANGLES,
+ TRIANGLE_STRIP,
+ TRIANGLE_FAN
};
+GLenum get_gl_primitive_type(PrimitiveType);
+
void operator>>(const LexicalConverter &, PrimitiveType &);
} // namespace GL