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

Last change on this file since 2618 was 2096, checked in by ldelgass, 13 years ago

Normalize line endings, set eol-style to native on *.cpp, *.h files

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