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 namespace Ogre
36 {
37  class OverlaySystem;
38  class SceneManager;
39 }
40 
41 namespace rviz
42 {
43 
45 {
46 public:
47 
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(
57  WindowIDType window_id,
58  unsigned int width,
59  unsigned int height,
60  double pixel_ratio = 1.0);
61 
62  Ogre::Root* root() { return ogre_root_; }
63 
64  // Prepare a scene_manager to render overlays.
65  // Needed for Ogre >= 1.9 to use fonts; does nothing for prior versions.
66  void prepareOverlays(Ogre::SceneManager* scene_manager);
67 
68  // @brief return OpenGl Version as integer, e.g. 320 for OpenGl 3.20
69  int getGlVersion() { return gl_version_; }
70 
71  // @brief return GLSL Version as integer, e.g. 150 for GLSL 1.50
72  int getGlslVersion() { return glsl_version_; }
73 
74  // @brief Disables the use of Anti Aliasing
75  static void disableAntiAliasing();
76 
77  // @brief Force to use the provided OpenGL version on startup
78  static void forceGlVersion( int version );
79 
80  // @brief Disable stereo rendering even if supported in HW.
81  static void forceNoStereo();
82 
83  // @brief True if we can render stereo on this device.
84  bool isStereoSupported() { return stereo_supported_; }
85 
86 private:
87  RenderSystem();
88  void setupDummyWindowId();
89  void loadOgrePlugins();
90 
91  // helper for makeRenderWindow()
92  Ogre::RenderWindow* tryMakeRenderWindow(const std::string& name,
93  unsigned int width,
94  unsigned int height,
95  const Ogre::NameValuePairList* params,
96  int max_attempts);
97 
98  // Find and configure the render system.
99  void setupRenderSystem();
100  void setupResources();
101  void detectGlVersion();
102 
104 
105  // ID for a dummy window of size 1x1, used to keep Ogre happy.
106  WindowIDType dummy_window_id_;
107 
108  Ogre::Root* ogre_root_;
109  Ogre::OverlaySystem* ogre_overlay_system_;
110 
113  static bool use_anti_aliasing_;
114  static int force_gl_version_;
116  static bool force_no_stereo_;
117 };
118 
119 } // end namespace rviz
120 
121 #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:62
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 Wed Aug 28 2019 04:01:51