source: nanovis/branches/1.1/PerfQuery.h @ 4879

Last change on this file since 4879 was 3502, checked in by ldelgass, 11 years ago

Add basic VTK structured points reader to nanovis, update copyright dates.

  • Property svn:eol-style set to native
File size: 1.7 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 PERFQUERY_H
19#define PERFQUERY_H
20
21#include <stdio.h>
22
23#include <GL/glew.h>
24
25#include "Trace.h"
26
27class PerfQuery
28{
29public:
30    PerfQuery();
31    ~PerfQuery();
32
33    void enable();      //start counting how many pixels are rendered
34    void disable();     //stop counting
35
36    void reset()
37    {
38        pixel = 0;
39    }
40
41    int getPixelCount()
42    {
43        return pixel;           //return current pixel count
44    }
45
46    static bool checkQuerySupport();
47
48    GLuint id;
49    int pixel;
50};
51
52//check if occlusion query is supported
53inline bool PerfQuery::checkQuerySupport()
54{
55    if (!GLEW_ARB_occlusion_query) {
56        TRACE("ARB_occlusion_query extension not supported");
57        return false;
58    }
59    int bitsSupported = -1;
60    glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB,
61                    &bitsSupported);
62    if (bitsSupported == 0) {
63        TRACE("occlusion query not supported!");
64        return false;
65    } else {
66        TRACE("Occlusion query with %d bits supported", bitsSupported);
67        return true;
68    }
69}
70#endif
71
Note: See TracBrowser for help on using the repository browser.