Changeset 2663 for GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.cpp
- Timestamp:
- 04/29/08 11:19:06 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.cpp
r2629 r2663 12 12 #endif 13 13 14 #ifdef _WIN3214 //#ifdef _WIN32 15 15 // This Macro does not compile under LINUX 16 #define _ARBGL 17 #endif 16 //#define _ARBGL 17 //#endif 18 18 19 19 20 using namespace std; 20 21 21 namespace GtpVisibilityPreprocessor { 22 23 bool OcclusionQuery::sUseArbQueries = true; 22 namespace GtpVisibilityPreprocessor 23 { 24 25 const static bool sUseArbQueries = true; 24 26 25 27 … … 27 29 { 28 30 GLuint id; 29 30 if (sUseArbQueries) 31 { 32 #ifdef _ ARBGL33 34 31 32 if (sUseArbQueries) 33 { 34 #ifdef _WIN32 35 // VH 36 glGenQueriesARB(1, &id); 35 37 #endif 36 38 } 37 39 else 38 40 { 39 #ifdef _ ARBGL40 41 #ifdef _WIN32 42 // VH 41 43 glGenOcclusionQueriesNV(1, &id); 42 44 #endif 43 45 } 44 46 } 47 45 48 46 49 OcclusionQuery::OcclusionQuery(const unsigned int idx): 47 50 mId(idx) 48 {} 51 { 52 } 49 53 50 54 … … 53 57 if (sUseArbQueries) 54 58 { 55 #ifdef _ ARBGL56 59 #ifdef _WIN32 60 // VH 57 61 glDeleteQueriesARB(1, &mId); 58 62 #endif … … 60 64 else 61 65 { 62 #ifdef _ ARBGL63 66 #ifdef _WIN32 67 // VH 64 68 glDeleteOcclusionQueriesNV(1, &mId); 65 69 #endif … … 67 71 68 72 } 69 //----------------------------------------------------------------------- 73 74 70 75 void OcclusionQuery::BeginQuery() 71 76 { 72 77 if (sUseArbQueries) 73 78 { 74 #ifdef _ARBGL 75 // VH 79 #ifdef _WIN32 80 // VH 81 cout << "issuing arb query" << endl; 76 82 glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mId); 77 83 #endif … … 79 85 else 80 86 { 81 #ifdef _ARBGL 82 // VH 87 #ifdef _WIN32 88 // VH 89 cout << "issuing nv query" << endl; 83 90 glBeginOcclusionQueryNV(mId); 84 91 #endif 85 92 } 86 93 } 87 //----------------------------------------------------------------------- 94 95 88 96 void OcclusionQuery::EndQuery() 89 97 { 90 98 if (sUseArbQueries) 91 99 { 92 #ifdef _ARBGL 93 // VH 100 #ifdef _WIN32 101 // VH 102 cout << "ending query" << endl; 94 103 glEndQueryARB(GL_SAMPLES_PASSED_ARB); 95 104 #endif … … 97 106 else 98 107 { 99 #ifdef _ ARBGL100 108 #ifdef _WIN32 109 // VH 101 110 glEndOcclusionQueryNV(); 102 111 #endif … … 110 119 } 111 120 121 112 122 bool OcclusionQuery::ResultAvailable() const 113 123 { 114 GLuint available; 115 116 if (sUseArbQueries) 117 { 118 #ifdef _ARBGL 119 // VH 120 //GLint available; 121 glGetQueryObjectuivARB(mId, 122 GL_QUERY_RESULT_AVAILABLE_ARB, 123 &available); 124 GLuint available = GL_TRUE; 125 126 if (sUseArbQueries) 127 { 128 #ifdef _WIN32 129 // VH 130 glGetQueryObjectuivARB(mId, GL_QUERY_RESULT_AVAILABLE_ARB, &available); 124 131 #endif 125 return available == GL_TRUE; 126 } 127 else 128 { 129 #ifdef _ARBGL 132 } 133 else 134 { 135 #ifdef _WIN32 130 136 // VH 131 137 glGetOcclusionQueryuivNV(mId, GL_PIXEL_COUNT_AVAILABLE_NV, &available); 132 138 #endif 133 return available == GL_TRUE;134 } 135 139 } 140 141 return available == GL_TRUE; 136 142 } 137 143 … … 139 145 unsigned int OcclusionQuery::GetQueryResult() const 140 146 { 141 GLuint sampleCount ;142 143 if (sUseArbQueries) 144 { 145 #ifdef _ ARBGL146 147 GLuint sampleCount = 1; 148 149 if (sUseArbQueries) 150 { 151 #ifdef _WIN32 152 // VH 147 153 glGetQueryObjectuivARB(mId, GL_QUERY_RESULT_ARB, &sampleCount); 148 154 #endif 149 return sampleCount;150 155 } 151 156 else 152 157 { 153 #ifdef _ ARBGL154 158 #ifdef _WIN32 159 // VH 155 160 glGetOcclusionQueryuivNV(mId, GL_PIXEL_COUNT_NV, &sampleCount); 156 161 #endif 157 return sampleCount;158 162 } 159 } 160 161 162 void OcclusionQuery::GenQueries(std::vector<OcclusionQuery * > &queries, const int numQueries) 163 164 return sampleCount; 165 } 166 167 168 void OcclusionQuery::GenQueries(std::vector<OcclusionQuery * > &queries, 169 int numQueries) 163 170 { 164 171 if ((int)queries.size() < numQueries) … … 170 177 if (sUseArbQueries) 171 178 { 172 #ifdef _ ARBGL173 179 #ifdef _WIN32 180 // VH 174 181 glGenQueriesARB(n, (unsigned int *)newQueries); 182 cout << "creating " << n << " arb queries" << endl; 175 183 #endif 176 184 } 177 185 else 178 186 { 179 #ifdef _ARBGL 180 // VH 181 glGenOcclusionQueriesNV(n, (unsigned int *)newQueries); 187 #ifdef _WIN32 188 // VH 189 glGenOcclusionQueriesNV(n, (unsigned int *)newQueries); 190 cout << "creating " << n << " nv queries" << endl; 182 191 #endif 183 192 } … … 192 201 } 193 202 } 203 204 194 205 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.