Line | |
---|
1 | |
---|
2 | /* |
---|
3 | * ---------------------------------------------------------------------- |
---|
4 | * PerfQuery.cpp: performance query class |
---|
5 | * |
---|
6 | * ====================================================================== |
---|
7 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
8 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
9 | * |
---|
10 | * Copyright (c) 2004-2006 Purdue Research Foundation |
---|
11 | * |
---|
12 | * See the file "license.terms" for information on usage and |
---|
13 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
14 | * ====================================================================== |
---|
15 | */ |
---|
16 | |
---|
17 | #include <assert.h> |
---|
18 | #include "PerfQuery.h" |
---|
19 | |
---|
20 | |
---|
21 | PerfQuery::PerfQuery(){ |
---|
22 | glGenQueriesARB(1, &id); |
---|
23 | pixel = 0; |
---|
24 | } |
---|
25 | |
---|
26 | PerfQuery::~PerfQuery(){ |
---|
27 | glDeleteQueriesARB(1, &id); |
---|
28 | } |
---|
29 | |
---|
30 | //There can only be one active query at any given moment |
---|
31 | void PerfQuery::enable(){ |
---|
32 | glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id); |
---|
33 | } |
---|
34 | |
---|
35 | void PerfQuery::disable(){ |
---|
36 | glEndQueryARB(GL_SAMPLES_PASSED_ARB); |
---|
37 | |
---|
38 | GLuint count; |
---|
39 | glGetQueryObjectuivARB(id, GL_QUERY_RESULT_ARB, &count); |
---|
40 | |
---|
41 | //accumulate pixel count count |
---|
42 | pixel+=count; |
---|
43 | } |
---|
44 | |
---|
Note: See
TracBrowser
for help on using the repository browser.