1 | /********************************************************************************
|
---|
2 | * Volatile - Volume Visualization Software for SAGE
|
---|
3 | * Copyright (C) 2004 Electronic Visualization Laboratory,
|
---|
4 | * University of Illinois at Chicago
|
---|
5 | *
|
---|
6 | * All rights reserved.
|
---|
7 | *
|
---|
8 | * Redistribution and use in source and binary forms, with or without
|
---|
9 | * modification, are permitted provided that the following conditions are met:
|
---|
10 | *
|
---|
11 | * * Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | * * Redistributions in binary form must reproduce the above
|
---|
14 | * copyright notice, this list of conditions and the following disclaimer
|
---|
15 | * in the documentation and/or other materials provided with the distribution.
|
---|
16 | * * Neither the name of the University of Illinois at Chicago nor
|
---|
17 | * the names of its contributors may be used to endorse or promote
|
---|
18 | * products derived from this software without specific prior written permission.
|
---|
19 | *
|
---|
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
---|
23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
---|
24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
---|
26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
---|
27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
---|
28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
---|
29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
31 | *
|
---|
32 | * Direct questions, comments etc about Volatile to www.evl.uic.edu/cavern/forum
|
---|
33 | *********************************************************************************/
|
---|
34 |
|
---|
35 | //CFrameTimer & vFPSText.h Class
|
---|
36 | //Calculates FPS depending on frame history
|
---|
37 | //so that the transition is smooth
|
---|
38 | //abd vFPSText.just draw the text and queries the timer
|
---|
39 | //Shalini Venkataraman Apr 2002
|
---|
40 | // Added changes for linux port, Atul Nayak , Jun 27 2002
|
---|
41 | #ifndef _VFPSTEXT_H_
|
---|
42 | #define _VFPSTEXT_H_
|
---|
43 | #ifdef WIN32
|
---|
44 | #include <windows.h>
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | #if defined(linux) || defined(__APPLE__)
|
---|
48 | #include <sys/time.h>
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | #define FRAME_HISTORY 10 //number of frames used in smoothing
|
---|
52 | #include "vPrimitive.h"
|
---|
53 |
|
---|
54 | class CFrameTimer {
|
---|
55 | double elapsedTime; //time elapsed since timer was instantiated
|
---|
56 | #ifdef WIN32
|
---|
57 | LARGE_INTEGER last; //last counter
|
---|
58 | #endif
|
---|
59 | #if defined(linux) || defined(__APPLE__)
|
---|
60 | struct timeval _tstart;
|
---|
61 | struct timezone tz;
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | double timerResolution; //time for one count
|
---|
65 | double frameTimes[FRAME_HISTORY]; //array of previous times
|
---|
66 | int frameLocation; //next index into frameTimes array
|
---|
67 | unsigned int framesProcessed; //no of times the counter was pinged
|
---|
68 | public:
|
---|
69 | CFrameTimer();
|
---|
70 | //ping counter to calculate the time elapsed and store it
|
---|
71 | void pingFrameCounter();
|
---|
72 | //get the current smoothed FPS depending on frame history
|
---|
73 | float getFPS();
|
---|
74 |
|
---|
75 | };
|
---|
76 | class vText : public vPrimitive {
|
---|
77 | public:
|
---|
78 | vText():vPrimitive() { };
|
---|
79 | vText(const char* str);
|
---|
80 | void draw();
|
---|
81 | void init();
|
---|
82 | char myText[256];
|
---|
83 | };
|
---|
84 |
|
---|
85 | class vFPSText : public vText {
|
---|
86 | public:
|
---|
87 | vFPSText():vText() {};
|
---|
88 | void draw();
|
---|
89 | void init();
|
---|
90 | private:
|
---|
91 | CFrameTimer* timer;
|
---|
92 | };
|
---|
93 |
|
---|
94 | class vVolText : public vText {
|
---|
95 | public:
|
---|
96 | vVolText():vText() {};
|
---|
97 | void draw();
|
---|
98 | void init();
|
---|
99 | private:
|
---|
100 | };
|
---|
101 |
|
---|
102 | #endif
|
---|
103 |
|
---|