]> git.mxchange.org Git - flightgear.git/blob - src/Include/general.hxx
Make comparisons against OSG version less flakey
[flightgear.git] / src / Include / general.hxx
1 // general.hxx -- a general house keeping data structure definition for 
2 //                various info that might need to be accessible from all 
3 //                parts of the sim.
4 //
5 // Written by Curtis Olson, started July 1997.
6 //
7 // Copyright (C) 1997  Curtis L. Olson  - http://www.flightgear.org/~curt
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22 //
23 // $Id$
24
25
26 #ifndef _GENERAL_HXX
27 #define _GENERAL_HXX
28
29
30 #ifndef __cplusplus                                                          
31 # error This library requires C++
32 #endif                                   
33
34 #include <osg/Version>
35
36 #define FG_OSG_VERSION \
37     ((OPENSCENEGRAPH_MAJOR_VERSION*10000)\
38      + (OPENSCENEGRAPH_MINOR_VERSION*1000) + OPENSCENEGRAPH_PATCH_VERSION)
39
40 // #define FANCY_FRAME_COUNTER
41 #ifdef FANCY_FRAME_COUNTER
42 #define FG_FRAME_RATE_HISTORY 10
43 #endif
44
45
46 // the general house keeping structure definition
47 class FGGeneral {
48     // Info about OpenGL
49     char *glVendor;
50     char *glRenderer;
51     char *glVersion;
52     int glMaxTexSize;
53     int glDepthBits;
54
55     // Last frame rate measurement
56     int frame_rate;
57 #ifdef FANCY_FRAME_COUNTER
58     double frames[FG_FRAME_RATE_HISTORY];
59 #endif
60
61 public:
62
63     inline void set_glVendor( char *str ) { glVendor = str; }
64     inline char* get_glRenderer() const { return glRenderer; }
65     inline void set_glRenderer( char *str ) { glRenderer = str; }
66     inline void set_glVersion( char *str ) { glVersion = str; }
67     inline void set_glMaxTexSize( int i ) { glMaxTexSize = i; }
68     inline int get_glMaxTexSize() const { return glMaxTexSize; }
69     inline void set_glDepthBits( int d ) { glDepthBits = d; }
70     inline int get_glDepthBits() const { return glDepthBits; }
71     inline double get_frame_rate() const { return frame_rate; }
72 #ifdef FANCY_FRAME_COUNTER
73     inline double get_frame(int idx) const { return frames[idx]; }
74     inline void set_frame( int idx, double value ) { frames[idx] = value; }
75     inline void set_frame_rate( double rate ) { frame_rate = rate; }
76 #else
77     inline void set_frame_rate( int rate ) { frame_rate = rate; }
78 #endif
79 };
80
81 // general contains all the general house keeping parameters.
82 extern FGGeneral general;
83
84
85 #endif // _GENERAL_HXX
86
87