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 <GL/glew.h> |
---|
23 | |
---|
24 | #include "define.h" |
---|
25 | |
---|
26 | //check if occlusion query is supported |
---|
27 | inline bool check_query_support() |
---|
28 | { |
---|
29 | int bitsSupported = -1; |
---|
30 | glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB, |
---|
31 | &bitsSupported); |
---|
32 | if(bitsSupported == 0) { |
---|
33 | fprintf(stderr, "occlusion query not supported!\n"); |
---|
34 | return false; |
---|
35 | } else { |
---|
36 | fprintf(stderr, "Occlusion query with %d bits supported\n", |
---|
37 | bitsSupported); |
---|
38 | return true; |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | class PerfQuery |
---|
43 | { |
---|
44 | |
---|
45 | public: |
---|
46 | NVISid 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.