FlightGear next
splash.hxx
Go to the documentation of this file.
1// splash.hxx -- draws the initial splash screen
2//
3// Written by Curtis Olson, started July 1998. (With a little looking
4// at Freidemann's panel code.) :-)
5//
6// Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
7//
8// This program is free software; you can redistribute it and/or
9// modify it under the terms of the GNU General Public License as
10// published by the Free Software Foundation; either version 2 of the
11// License, or (at your option) any later version.
12//
13// This program is distributed in the hope that it will be useful, but
14// WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21//
22// $Id$
23
24
25#ifndef _SPLASH_HXX
26#define _SPLASH_HXX
27
28#include <config.h>
29
30#include <osg/Group>
31#include <osgText/Text>
32
33#ifdef ENABLE_OSGXR
34#include <osgXR/CompositionLayerQuad>
35#include <osgXR/Swapchain>
36#endif
37
38#include <simgear/props/props.hxx>
39#include <simgear/timing/timestamp.hxx>
40
41#include <vector>
42
43namespace osg
44{
45 class Texture2D;
46 class Image;
47 class Camera;
48}
49
50class SplashScreen : public osg::Group
51{
52public:
55
56 void resize(int width, int height);
57
58private:
59 // model-content or content
60 struct TextItem
61 {
62 osg::ref_ptr<osgText::Text> textNode;
63 SGPropertyNode_ptr dynamicContent;
64 osg::Vec2 fractionalPosition; // position in the 0.0 .. 1.0 range
65 double fractionalCharSize;
66 double maxWidthFraction = -1.0;
67 unsigned int maxLineCount = 0;
68 double maxHeightFraction = -1.0;
69 SGCondition* condition;
70 unsigned int drawMode;
71 void recomputeSize(int height) const;
72 void reposition(int width, int height) const;
73
74 };
75 // used to manage the displayed images on the splash screen
76 struct ImageItem
77 {
78 std::string name;
79 double x;
80 double y;
81 double width;
82 double height;
83 bool isBackground;
84 double aspectRatio;
85 int imageWidth;
86 int imageHeight;
87 osg::ref_ptr<osg::Vec3Array> vertexArray = nullptr;
88 osg::ref_ptr<osg::Image> Image = nullptr;
89 SGCondition* condition;
90 osg::Node::NodeMask nodeMask;
91 osg::Geode* geode;
92 };
93
95
96 void createNodes();
97 void CreateTextFromNode(const SGPropertyNode_ptr& content, osg::Geode* geode, bool modelContent);
98
99 void doUpdate();
100 void updateSplashSpinner();
101 void updateTipText();
102
103 std::string selectSplashImage();
104
105 TextItem* addText(osg::Geode* geode, const osg::Vec2& pos, double size, const std::string& text,
106 const osgText::Text::AlignmentType alignment,
107 SGPropertyNode* dynamicValue = nullptr,
108 double maxWidthFraction = -1.0,
109 const osg::Vec4& textColor = osg::Vec4(1, 1, 1, 1),
110 const std::string &fontFace = "Fonts/LiberationFonts/LiberationSans-BoldItalic.ttf");
111
112 osg::ref_ptr<osg::Camera> createFBOCamera();
113 void manuallyResizeFBO(int width, int height);
114
115 bool _legacySplashScreenMode = false;
116 SGPropertyNode_ptr _splashAlphaNode;
117 osg::ref_ptr<osg::Camera> _splashFBOCamera;
118 osg::Vec3Array* _splashSpinnerVertexArray = nullptr;
119
120 osg::ref_ptr<osg::Program> _program;
121
122 int _width, _height;
123
124 osg::Texture2D* _splashFBOTexture;
125 osg::Vec4Array* _splashFSQuadColor;
126 osg::ref_ptr<osg::Camera> _splashQuadCamera;
127
128 std::vector<ImageItem> _imageItems;
129
130#ifdef ENABLE_OSGXR
131 // Splash as OpenXR composition layer
132 osg::ref_ptr<osgXR::Swapchain> _splashSwapchain;
133 osg::ref_ptr<osgXR::CompositionLayerQuad> _splashLayer;
134#endif
135
136 std::vector<TextItem> _items;
137
138 SGTimeStamp _splashStartTime;
139 bool _haveSetStartupTip = false;
140 const ImageItem* addImage(const std::string& path, bool isAbsolutePath, double x, double y, double width, double height, SGPropertyNode* condition, bool isSplash);
141};
142
145void fgSplashProgress ( const char *identifier, unsigned int percent = 0 );
146
147#endif // _SPLASH_HXX
148
149
void resize(int width, int height)
Definition splash.cxx:775
friend class SplashScreenUpdateCallback
Definition splash.hxx:94
const char * name
Definition AIBase.hxx:25
void fgSplashProgress(const char *identifier, unsigned int percent=0)
Set progress information.
Definition splash.cxx:863