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