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 static Require _req(EXT_framebuffer_blit);
51 const Framebuffer *source = pipeline_state->get_framebuffer();
53 unsigned width = min(source->get_width(), target.get_width());
54 unsigned height = min(source->get_height(), target.get_height());
56 if(ARB_direct_state_access)
57 glBlitNamedFramebuffer(source->id, target.id, 0, 0, width, height, 0, 0, width, height, buffers, GL_NEAREST);
60 glBindFramebuffer(GL_READ_FRAMEBUFFER, source->id);
61 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, target.id);
65 glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, buffers, GL_NEAREST);
67 glBindFramebuffer(GL_FRAMEBUFFER, source->id);