]> git.mxchange.org Git - flightgear.git/blob - src/Viewer/WindowBuilder.hxx
considering u,v,wbody-fps are the ECEF velocity expressed in body axis, change in...
[flightgear.git] / src / Viewer / WindowBuilder.hxx
1 // Copyright (C) 2008  Tim Moore
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16
17 #ifndef FLIGHTGEAR_WINDOWBUILDER_HXX
18 #define FLIGHTGEAR_WINDOWBUILDER_HXX 1
19
20 #include <osg/ref_ptr>
21 #include <osg/Referenced>
22 #include <osg/GraphicsContext>
23
24 #include <string>
25
26 class SGPropertyNode;
27
28 namespace flightgear
29 {
30 class GraphicsWindow;
31 /** Singleton Builder class for creating a GraphicsWindow from property
32  * nodes. This involves initializing an osg::GraphicsContext::Traits
33  * structure from the property node values and creating an
34  * osgViewer::GraphicsWindow.
35  */
36 class WindowBuilder : public osg::Referenced
37 {
38 public:
39     /** Initialize the singleton window builder.
40      * @param stencil whether windows should allocate stencil planes
41      */
42     static void initWindowBuilder(bool stencil);
43     /** Get the singleton window builder
44      */
45     static WindowBuilder* getWindowBuilder() { return windowBuilder.get(); }
46     /** Create a window from its property node description.
47      * @param winNode The window's root property node
48      * @return a graphics window.
49      */
50     GraphicsWindow* buildWindow(const SGPropertyNode* winNode);
51     /** Get a window whose properties come from FlightGear's
52      * command line arguments and their defaults. The window is opened
53      * if it has not been already.
54      * @return the default graphics window
55      */
56     GraphicsWindow* getDefaultWindow();
57     /** Get the name used to look up the default window.
58      */
59     const std::string& getDefaultWindowName() { return defaultWindowName; }
60 protected:
61     WindowBuilder(bool stencil);
62     static osg::GraphicsContext::Traits* makeDefaultTraits(bool stencil);
63     osg::ref_ptr<osg::GraphicsContext::Traits> defaultTraits;
64     int defaultCounter;
65     static osg::ref_ptr<WindowBuilder> windowBuilder;
66     static const std::string defaultWindowName;
67 };
68
69 /** Silly function for making the default window and camera
70  * names. This concatenates a string with in integer.
71  */
72 std::string makeName(const std::string& prefix, int num);
73
74 }
75 #endif