source: trunk/packages/vizservers/nanovis/PerfQuery.h @ 3611

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

Use nv namespace for classes in nanovis rather than prefixing class names with
Nv (still need to convert shader classes).

  • Property svn:eol-style set to native
File size: 1.8 KB
RevLine 
[2798]1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
[377]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 *
[3502]12 *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
[377]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 */
[2877]18#ifndef PERFQUERY_H
19#define PERFQUERY_H
[377]20
21#include <stdio.h>
[2822]22
[377]23#include <GL/glew.h>
24
[2822]25#include "Trace.h"
[377]26
[3611]27namespace nv {
28
[377]29class PerfQuery
30{
31public:
[981]32    PerfQuery();
33    ~PerfQuery();
[2877]34
[2822]35    void enable();      //start counting how many pixels are rendered
36    void disable();     //stop counting
[377]37
[2822]38    void reset()
[2877]39    {
40        pixel = 0;
[981]41    }
[2822]42
[2877]43    int getPixelCount()
[2822]44    {
[2877]45        return pixel;           //return current pixel count
[981]46    }
[2877]47
48    static bool checkQuerySupport();
49
50    GLuint id;
51    int pixel;
[377]52};
53
[2877]54//check if occlusion query is supported
55inline bool PerfQuery::checkQuerySupport()
56{
57    if (!GLEW_ARB_occlusion_query) {
[3452]58        TRACE("ARB_occlusion_query extension not supported");
[2877]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) {
[3452]65        TRACE("occlusion query not supported!");
[2877]66        return false;
67    } else {
[3452]68        TRACE("Occlusion query with %d bits supported", bitsSupported);
[2877]69        return true;
70    }
71}
[3611]72
73}
74
[377]75#endif
76
Note: See TracBrowser for help on using the repository browser.