00001
00002
00003 #ifndef OCCLUSIONQUERY_H
00004 #define OCCLUSIONQUERY_H
00005
00006
00007 #include "Renderer.h"
00008
00009 #include "AABB.h"
00010 #include "Vector3f.h"
00011
00012
00013 namespace pge {
00014 namespace occlusionquery {
00015
00016
00017
00018 static int occlusionQuery(AABB *boundingBox) {
00019 int pixelCount;
00020 unsigned int queryId;
00021
00022
00023 glGenQueries(1, &queryId);
00024
00025
00026 glColorMask(false, false, false, false);
00027 glDepthMask(false);
00028
00029 glDisable(GL_TEXTURE_2D);
00030
00031
00032 glBeginQuery(GL_SAMPLES_PASSED_ARB, queryId);
00033
00034
00035 boundingBox->renderSolid(Vector3f(1.0f, 1.0f, 1.0f));
00036
00037
00038 glEndQuery(GL_SAMPLES_PASSED_ARB);
00039
00040
00041 glColorMask(true, true, true, true);
00042 glDepthMask(true);
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 glGetQueryObjectiv(queryId, GL_QUERY_RESULT_ARB, &pixelCount);
00059
00060
00061 glDeleteQueries(1, &queryId);
00062
00063
00064 return pixelCount;
00065 }
00066 };
00067 };
00068
00069 #endif