X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Foccludedscene.cpp;h=3d540a72ac8739e6b780ff7e7cc19845104741fc;hp=8d05f7c18161d8af7833fd1f62cae4f9effc21ad;hb=782344299d402dfc7e4eb038bba876d7455f50f5;hpb=041717fbfb7d9a46459f15ecc55a5520f84d006c diff --git a/source/occludedscene.cpp b/source/occludedscene.cpp index 8d05f7c1..3d540a72 100644 --- a/source/occludedscene.cpp +++ b/source/occludedscene.cpp @@ -1,38 +1,25 @@ #include #include +#include #include "camera.h" #include "occludedscene.h" +#include "programbuilder.h" #include "renderer.h" #include "sphere.h" using namespace std; -namespace { - -const char vshader[] = - "void main()\n" - "{\n" - " gl_Position = gl_ProjectionMatrix*gl_ModelViewMatrix*gl_Vertex;\n" - "}"; - -const char fshader[] = - "void main()\n" - "{\n" - " gl_FragColor = vec4(1.0);\n" - "}"; - -} - namespace Msp { namespace GL { OccludedScene::OccludedScene(): bounding_mesh((VERTEX3, NORMAL3)), - bounding_shader(vshader, fshader), + bounding_shader(ProgramBuilder::StandardFeatures()), occluder_min_size(0.25f), cache_dirty(false) { static Require req(ARB_occlusion_query); + static Require req2(ARB_occlusion_query2); /* Use a slightly larger radius to ensure that all parts of the renderable fit inside the icosahedron */ @@ -149,13 +136,13 @@ void OccludedScene::render(Renderer &renderer, const Tag &tag) const for(OccludedArray::const_iterator i=occluded_cache.begin(); (i!=occluded_cache.end() && i->in_frustum); ++i) if(!i->occluder) { - glBeginQuery(GL_SAMPLES_PASSED, i->query); + glBeginQuery(GL_ANY_SAMPLES_PASSED, i->query); Renderer::Push push2(renderer); renderer.transform(Matrix(*i->renderable->get_matrix()) .translate(i->bounding_sphere->get_center()) .scale(i->bounding_sphere->get_radius())); bounding_mesh.draw(renderer); - glEndQuery(GL_SAMPLES_PASSED); + glEndQuery(GL_ANY_SAMPLES_PASSED); } glColorMask(true, true, true, true); @@ -166,9 +153,9 @@ void OccludedScene::render(Renderer &renderer, const Tag &tag) const for(OccludedArray::const_iterator i=occluded_cache.begin(); (i!=occluded_cache.end() && i->in_frustum); ++i) if(!i->occluder) { - int samples_passed; - glGetQueryObjectiv(i->query, GL_QUERY_RESULT, &samples_passed); - if(samples_passed>0) + unsigned any_passed = 0; + glGetQueryObjectuiv(i->query, GL_QUERY_RESULT, &any_passed); + if(any_passed) renderer.render(*i->renderable, tag); } }