source: nanovis/trunk/PerfQuery.h @ 4822

Last change on this file since 4822 was 3613, checked in by ldelgass, 11 years ago

Include namespace in header guard defines

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * ----------------------------------------------------------------------
4 * PerfQuery.h: performance query class
5 *              It counts then number of pixels rendered on screen using
6 *              OpenGL occlusion query extension
7 *
8 * ======================================================================
9 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
10 *           Purdue Rendering and Perceptualization Lab (PURPL)
11 *
12 *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
13 *
14 *  See the file "license.terms" for information on usage and
15 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
16 * ======================================================================
17 */
18#ifndef NV_PERFQUERY_H
19#define NV_PERFQUERY_H
20
21#include <stdio.h>
22
23#include <GL/glew.h>
24
25#include "Trace.h"
26
27namespace nv {
28
29class PerfQuery
30{
31public:
32    PerfQuery();
33    ~PerfQuery();
34
35    void enable();      //start counting how many pixels are rendered
36    void disable();     //stop counting
37
38    void reset()
39    {
40        pixel = 0;
41    }
42
43    int getPixelCount()
44    {
45        return pixel;           //return current pixel count
46    }
47
48    static bool checkQuerySupport();
49
50    GLuint id;
51    int pixel;
52};
53
54//check if occlusion query is supported
55inline bool PerfQuery::checkQuerySupport()
56{
57    if (!GLEW_ARB_occlusion_query) {
58        TRACE("ARB_occlusion_query extension not supported");
59        return false;
60    }
61    int bitsSupported = -1;
62    glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB,
63                    &bitsSupported);
64    if (bitsSupported == 0) {
65        TRACE("occlusion query not supported!");
66        return false;
67    } else {
68        TRACE("Occlusion query with %d bits supported", bitsSupported);
69        return true;
70    }
71}
72
73}
74
75#endif
76
Note: See TracBrowser for help on using the repository browser.