source: trunk/gui/vizservers/nanovis/PerfQuery.cpp @ 401

Last change on this file since 401 was 377, checked in by qiaow, 18 years ago

Added PerfQuery? class for tracking number of pixels rendered on screen

File size: 1.2 KB
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
20PerfQuery::PerfQuery(){
21  glGenQueriesARB(1, &id);
22  pixel = 0;
23}
24
25PerfQuery::~PerfQuery(){
26  glDeleteQueriesARB(1, &id);
27}
28
29void PerfQuery::reset(){ pixel=0; }
30
31//There can only be one active query at any given moment
32void PerfQuery::enable(){
33  glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id);
34}
35
36void 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
46int PerfQuery::get_pixel_count(){ return pixel; }
Note: See TracBrowser for help on using the repository browser.