X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fcommands.cpp;h=ebc6394e44b4eaca1883e31f744f0b40a317ec41;hb=3c0cbf0529aa06d9809ad3aa9e282400e8209b4d;hp=2eb4659ad8e6ae0f62ecb2ec2e9aed362dc6afc3;hpb=006bdb4f8660098fc524dcca80b24c943c65b249;p=libs%2Fgl.git diff --git a/source/core/commands.cpp b/source/core/commands.cpp index 2eb4659a..ebc6394e 100644 --- a/source/core/commands.cpp +++ b/source/core/commands.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -9,6 +10,7 @@ #include "error.h" #include "gl.h" #include "pipelinestate.h" +#include "query.h" using namespace std; @@ -19,9 +21,11 @@ Commands::Commands(): pipeline_state(0) { } -void Commands::use_pipeline(const PipelineState &ps) +void Commands::use_pipeline(const PipelineState *ps) { - pipeline_state = &ps; + pipeline_state = ps; + if(!pipeline_state) + PipelineState::clear(); } void Commands::clear(const ClearValue *values) @@ -68,7 +72,7 @@ void Commands::draw(const Batch &batch) { pipeline_state->apply(); void *data_ptr = reinterpret_cast(batch.get_offset()); - glDrawElements(batch.get_gl_primitive_type(), batch.size(), batch.get_gl_index_type(), data_ptr); + glDrawElements(batch.gl_prim_type, batch.size(), batch.gl_index_type, data_ptr); } void Commands::draw_instanced(const Batch &batch, unsigned count) @@ -77,10 +81,10 @@ void Commands::draw_instanced(const Batch &batch, unsigned count) pipeline_state->apply(); void *data_ptr = reinterpret_cast(batch.get_offset()); - glDrawElementsInstanced(batch.get_gl_primitive_type(), batch.size(), batch.get_gl_index_type(), data_ptr, count); + glDrawElementsInstanced(batch.gl_prim_type, batch.size(), batch.gl_index_type, data_ptr, count); } -void Commands::resolve_multisample(Framebuffer &target, BufferBits buffers) +void Commands::resolve_multisample(Framebuffer &target) { static Require _req(EXT_framebuffer_blit); @@ -88,6 +92,7 @@ void Commands::resolve_multisample(Framebuffer &target, BufferBits buffers) unsigned width = min(source->get_width(), target.get_width()); unsigned height = min(source->get_height(), target.get_height()); + unsigned buffers = get_gl_buffer_bits(source->get_format())&get_gl_buffer_bits(target.get_format()); if(ARB_direct_state_access) glBlitNamedFramebuffer(source->id, target.id, 0, 0, width, height, 0, 0, width, height, buffers, GL_NEAREST); @@ -104,5 +109,17 @@ void Commands::resolve_multisample(Framebuffer &target, BufferBits buffers) } } +void Commands::begin_query(const QueryPool &pool, unsigned index) +{ + if(index>=pool.queries.size()) + throw out_of_range("OpenGLCommands::begin_query"); + glBeginQuery(pool.gl_type, pool.queries[index]); +} + +void Commands::end_query(const QueryPool &pool, unsigned) +{ + glEndQuery(pool.gl_type); +} + } // namespace GL } // namespace Msp