]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/commands.cpp
Use friend declaration to access hidden data in Batch
[libs/gl.git] / source / core / commands.cpp
index 19ff10115e53e10faf612220c2daf3f4697f841e..ebc6394e44b4eaca1883e31f744f0b40a317ec41 100644 (file)
@@ -1,6 +1,7 @@
 #include <algorithm>
 #include <msp/gl/extensions/arb_direct_state_access.h>
 #include <msp/gl/extensions/arb_draw_instanced.h>
+#include <msp/gl/extensions/arb_occlusion_query.h>
 #include <msp/gl/extensions/ext_framebuffer_blit.h>
 #include <msp/gl/extensions/ext_framebuffer_object.h>
 #include <msp/gl/extensions/msp_clear_buffer.h>
@@ -9,6 +10,7 @@
 #include "error.h"
 #include "gl.h"
 #include "pipelinestate.h"
+#include "query.h"
 
 using namespace std;
 
@@ -70,7 +72,7 @@ void Commands::draw(const Batch &batch)
 {
        pipeline_state->apply();
        void *data_ptr = reinterpret_cast<void *>(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)
@@ -79,7 +81,7 @@ void Commands::draw_instanced(const Batch &batch, unsigned count)
 
        pipeline_state->apply();
        void *data_ptr = reinterpret_cast<void *>(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)
@@ -107,5 +109,17 @@ void Commands::resolve_multisample(Framebuffer &target)
        }
 }
 
+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