Line | |
---|
1 | #include <iostream>
|
---|
2 | #include "OcclusionQuery.h"
|
---|
3 | #include "glInterface.h"
|
---|
4 |
|
---|
5 | using namespace std;
|
---|
6 |
|
---|
7 |
|
---|
8 | namespace CHCDemo
|
---|
9 | {
|
---|
10 |
|
---|
11 | OcclusionQuery::OcclusionQuery()
|
---|
12 | {
|
---|
13 | glGenQueriesARB(1, &mQueryId);
|
---|
14 |
|
---|
15 | // reverse for multiequeries with 32 nodes
|
---|
16 | mNodes.reserve(32);
|
---|
17 | }
|
---|
18 |
|
---|
19 |
|
---|
20 | OcclusionQuery::OcclusionQuery(unsigned int idx):
|
---|
21 | mQueryId(idx)
|
---|
22 | {
|
---|
23 | // reverse for multiequeries with 32 nodes
|
---|
24 | mNodes.reserve(32);
|
---|
25 | }
|
---|
26 |
|
---|
27 |
|
---|
28 | OcclusionQuery::~OcclusionQuery()
|
---|
29 | {
|
---|
30 | glDeleteQueriesARB(1, &mQueryId);
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | void OcclusionQuery::BeginQuery()
|
---|
35 | {
|
---|
36 | glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mQueryId);
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 | void OcclusionQuery::EndQuery()
|
---|
41 | {
|
---|
42 | glEndQueryARB(GL_SAMPLES_PASSED_ARB);
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | unsigned int OcclusionQuery::GetQueryId() const
|
---|
47 | {
|
---|
48 | return mQueryId;
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | bool 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 |
|
---|
62 | unsigned 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.