render_system.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 #ifndef RENDER_SYSTEM_H
30 #define RENDER_SYSTEM_H
31 
32 #include <OgreRoot.h>
33 #include <stdint.h>
34 
35 #include "rviz/rviz_export.h"
36 
37 namespace Ogre
38 {
39 class OverlaySystem;
40 class SceneManager;
41 } // namespace Ogre
42 
43 namespace rviz
44 {
45 class RVIZ_EXPORT RenderSystem
46 {
47 public:
48 #if defined(Q_OS_MAC) || defined(Q_OS_WIN)
49  typedef size_t WindowIDType;
50 #else
51  typedef unsigned long WindowIDType;
52 #endif
53 
54  static RenderSystem* get();
55 
56  Ogre::RenderWindow* makeRenderWindow(WindowIDType window_id,
57  unsigned int width,
58  unsigned int height,
59  double pixel_ratio = 1.0);
60 
61  Ogre::Root* root()
62  {
63  return ogre_root_;
64  }
65 
66  // Prepare a scene_manager to render overlays.
67  // Needed for Ogre >= 1.9 to use fonts; does nothing for prior versions.
68  void prepareOverlays(Ogre::SceneManager* scene_manager);
69 
70  // @brief return OpenGl Version as integer, e.g. 320 for OpenGl 3.20
72  {
73  return gl_version_;
74  }
75 
76  // @brief return GLSL Version as integer, e.g. 150 for GLSL 1.50
78  {
79  return glsl_version_;
80  }
81 
82  // @brief Disables the use of Anti Aliasing
83  static void disableAntiAliasing();
84 
85  // @brief Force to use the provided OpenGL version on startup
86  static void forceGlVersion(int version);
87 
88  // @brief Disable stereo rendering even if supported in HW.
89  static void forceNoStereo();
90 
91  // @brief True if we can render stereo on this device.
93  {
94  return stereo_supported_;
95  }
96 
97 private:
98  RenderSystem();
99  void setupDummyWindowId();
100  void loadOgrePlugins();
101 
102  // helper for makeRenderWindow()
103  Ogre::RenderWindow* tryMakeRenderWindow(const std::string& name,
104  unsigned int width,
105  unsigned int height,
106  const Ogre::NameValuePairList* params,
107  int max_attempts);
108 
109  // Find and configure the render system.
110  void setupRenderSystem();
111  void setupResources();
112  void detectGlVersion();
113 
115 
116  // ID for a dummy window of size 1x1, used to keep Ogre happy.
117  WindowIDType dummy_window_id_;
118 
119  Ogre::Root* ogre_root_;
120  Ogre::OverlaySystem* ogre_overlay_system_;
121 
124  static bool use_anti_aliasing_;
125  static int force_gl_version_;
127  static bool force_no_stereo_;
128 };
129 
130 } // end namespace rviz
131 
132 #endif // RENDER_SYSTEM_H
static RenderSystem * instance_
static int force_gl_version_
WindowIDType dummy_window_id_
unsigned long WindowIDType
Definition: render_system.h:51
Ogre::Root * ogre_root_
Ogre::Root * root()
Definition: render_system.h:61
static bool force_no_stereo_
Ogre::OverlaySystem * ogre_overlay_system_
static bool use_anti_aliasing_


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Mon Aug 15 2022 02:05:17