2 #include <msp/gl/extensions/arb_direct_state_access.h>
3 #include <msp/gl/extensions/arb_draw_instanced.h>
4 #include <msp/gl/extensions/ext_framebuffer_blit.h>
5 #include <msp/gl/extensions/ext_framebuffer_object.h>
9 #include "pipelinestate.h"
20 void Commands::use_pipeline(const PipelineState &ps)
25 void Commands::clear(BufferBits buffers)
27 pipeline_state->apply();
31 void Commands::draw(const Batch &batch)
33 pipeline_state->apply();
34 void *data_ptr = reinterpret_cast<void *>(batch.get_offset());
35 glDrawElements(batch.get_gl_primitive_type(), batch.size(), batch.get_gl_index_type(), data_ptr);
38 void Commands::draw_instanced(const Batch &batch, unsigned count)
40 static Require req(ARB_draw_instanced);
42 pipeline_state->apply();
43 void *data_ptr = reinterpret_cast<void *>(batch.get_offset());
44 glDrawElementsInstanced(batch.get_gl_primitive_type(), batch.size(), batch.get_gl_index_type(), data_ptr, count);
47 void Commands::resolve_multisample(Framebuffer &target, BufferBits buffers)
49 const Framebuffer *source = pipeline_state->get_framebuffer();
51 unsigned width = min(source->get_width(), target.get_width());
52 unsigned height = min(source->get_height(), target.get_height());
54 if(ARB_direct_state_access)
55 glBlitNamedFramebuffer(source->get_id(), target.get_id(), 0, 0, width, height, 0, 0, width, height, buffers, GL_NEAREST);
58 glBindFramebuffer(GL_READ_FRAMEBUFFER, source->get_id());
59 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, target.get_id());
63 glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, buffers, GL_NEAREST);
65 glBindFramebuffer(GL_FRAMEBUFFER, source->get_id());