source: GTP/trunk/App/Demos/Vis/CHC_revisited/OcclusionQuery.cpp @ 2753

Revision 2753, 1.1 KB checked in by mattausch, 17 years ago (diff)
Line 
1#include <iostream>
2#include "OcclusionQuery.h"
3#include "glInterface.h"
4
5using namespace std;
6
7
8namespace CHCDemo
9{
10
11OcclusionQuery::OcclusionQuery()
12{
13        glGenQueriesARB(1, &mQueryId);
14
15        // reverse for multiequeries with 32 nodes
16        mNodes.reserve(32);
17}
18
19
20OcclusionQuery::OcclusionQuery(unsigned int idx):
21mQueryId(idx)
22{
23        // reverse for multiequeries with 32 nodes
24        mNodes.reserve(32);
25}
26
27
28OcclusionQuery::~OcclusionQuery()
29{
30        glDeleteQueriesARB(1, &mQueryId);
31}
32
33
34void OcclusionQuery::BeginQuery()
35{
36        glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mQueryId);
37}
38
39
40void OcclusionQuery::EndQuery()
41{
42        glEndQueryARB(GL_SAMPLES_PASSED_ARB);
43}
44
45
46unsigned int OcclusionQuery::GetQueryId() const
47{
48        return mQueryId;
49}
50
51
52bool OcclusionQuery::ResultAvailable() const
53{
54        GLuint available = GL_FALSE;
55
56        glGetQueryObjectuivARB(mQueryId, GL_QUERY_RESULT_AVAILABLE_ARB, &available);
57
58        return available == GL_TRUE;
59}
60
61
62unsigned int OcclusionQuery::GetQueryResult() const
63{
64        GLuint sampleCount = 1;
65
66        glGetQueryObjectuivARB(mQueryId, GL_QUERY_RESULT_ARB, &sampleCount);
67       
68        return sampleCount;
69}
70
71} // namespace
Note: See TracBrowser for help on using the repository browser.