Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

pge::occlusionquery Namespace Reference


Functions

int occlusionQuery (AABB *boundingBox)


Function Documentation

int occlusionQuery AABB *  boundingBox  )  [static]
 

Definition at line 18 of file OcclusionQuery.h.

References pge::AABB::renderSolid().

00018                                                              {
00019                         int pixelCount;
00020                         unsigned int queryId;
00021 
00022                         // Generate a new query.
00023                         glGenQueries(1, &queryId);
00024 
00025                         // Do not render anything actually to the screen.
00026                         glColorMask(false, false, false, false);
00027                         glDepthMask(false);
00028                         // Disable texturing for faster "rendering".
00029                         glDisable(GL_TEXTURE_2D);
00030 
00031                         // Start the query.
00032                         glBeginQuery(GL_SAMPLES_PASSED_ARB, queryId);
00033 
00034                         // Here render the AABB which should be checked.
00035                         boundingBox->renderSolid(Vector3f(1.0f, 1.0f, 1.0f));
00036 
00037                         // End the query.
00038                         glEndQuery(GL_SAMPLES_PASSED_ARB);
00039 
00040                         // And set render mode back to normal.
00041                         glColorMask(true, true, true, true);
00042                         glDepthMask(true);
00043 
00044                         // With this construct you can wait for the result and do some calculations in between.
00045                         // But since this engine currently does not support any physics calculations or something similar,
00046                         // there is nothing we could wait for.
00047 
00048                         //available = new int[1];
00049                         //do {
00050 
00051                         // Do some calculations here.
00052 
00053                         //gl.glGetQueryObjectivARB(queryId[0], GL.GL_QUERY_RESULT_AVAILABLE_ARB, IntBuffer.wrap(available));
00054 
00055                         //} while (available[0] == 0);
00056 
00057                         // So we just wait normally for the result.
00058                         glGetQueryObjectiv(queryId, GL_QUERY_RESULT_ARB, &pixelCount);
00059 
00060                         // Delete the query.
00061                         glDeleteQueries(1, &queryId);
00062 
00063                         // Return the value.
00064                         return pixelCount;
00065                 }

Here is the call graph for this function:


Generated on Mon Oct 16 12:10:01 2006 for Phobosengine by doxygen 1.3.4