Choreonoid  1.8
GLSceneRenderer.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_BASE_GL_SCENE_RENDERER_H
7 #define CNOID_BASE_GL_SCENE_RENDERER_H
8 
9 #include <cnoid/SceneRenderer>
10 #include "exportdecl.h"
11 
12 namespace cnoid {
13 
14 class Image;
15 
16 class CNOID_EXPORT GLSceneRenderer : public SceneRenderer
17 {
18 public:
19  static void initializeClass();
20 
21  enum RendererType { GL1_RENDERER, GLSL_RENDERER };
22  static int rendererType();
23  static GLSceneRenderer* create(SgGroup* root = nullptr);
24 
25  GLSceneRenderer(SgGroup* root = nullptr);
26  virtual ~GLSceneRenderer();
27 
28  virtual void setOutputStream(std::ostream& os);
29 
30  virtual SgGroup* sceneRoot() override;
31  virtual SgGroup* scene() override;
32 
33  virtual bool initializeGL() = 0;
34  virtual void flushGL() = 0;
35 
44  virtual void clearGL();
45 
46  virtual void setDefaultFramebufferObject(unsigned int id);
47 
48  virtual const std::string& glVendor() const = 0;
49 
50  virtual void setViewport(int x, int y, int width, int height) = 0;
51 
52  // Call this function instead of setViewport when the viewport is specified by the system.
53  virtual void updateViewportInformation(int x, int y, int width, int height);
54 
55  Array4i viewport() const;
56  void getViewport(int& out_x, int& out_y, int& out_width, int& out_height) const;
57  double aspectRatio() const; // width / height;
58 
59  void getPerspectiveProjectionMatrix(
60  double fovy, double aspect, double zNear, double zFar, Matrix4& out_matrix);
61  void getOrthographicProjectionMatrix(
62  double left, double right, double bottom, double top, double nearVal, double farVal, Matrix4& out_matrix);
63 
64  void getViewFrustum(const SgPerspectiveCamera* camera, double& left, double& right, double& bottom, double& top) const;
65  void getViewVolume(const SgOrthographicCamera* camera, float& out_left, float& out_right, float& out_bottom, float& out_top) const;
66 
67  bool unproject(double x, double y, double z, Vector3& out_projected) const;
68 
69  const Vector3f& backgroundColor() const;
70  void setBackgroundColor(const Vector3f& color);
71  const Vector3f& defaultColor() const;
72  void setDefaultColor(const Vector3f& color);
73 
74  enum LightingMode {
79  NumLightingModes
80  };
81  virtual void setLightingMode(LightingMode mode) = 0;
82  virtual LightingMode lightingMode() const = 0;
83 
84  virtual void clearShadows();
85  virtual void enableShadowOfLight(int index, bool on = true);
86  virtual void enableShadowAntiAliasing(bool on);
87  virtual void setDefaultSmoothShading(bool on) = 0;
88  virtual SgMaterial* defaultMaterial() = 0;
89  virtual void enableTexture(bool on) = 0;
90  virtual void setDefaultPointSize(double size) = 0;
91  virtual void setDefaultLineWidth(double width) = 0;
92  virtual void showNormalVectors(double length) = 0;
93  virtual void requestToClearResources() = 0;
94  virtual void enableUnusedResourceCheck(bool on) = 0;
95  virtual const Vector3& pickedPoint() const = 0;
96  virtual const SgNodePath& pickedNodePath() const = 0;
97  virtual void setColor(const Vector3f& color) = 0;
98  virtual void setUpsideDown(bool on);
99 
100  enum CullingMode {
104  N_CULLING_MODES
105  };
106 
107  virtual void setBackFaceCullingMode(int mode) = 0;
108  virtual int backFaceCullingMode() const = 0;
109 
110  virtual void setBoundingBoxRenderingForLightweightRenderingGroupEnabled(bool on);
111 
112  virtual void setPickingImageOutputEnabled(bool on);
113  virtual bool getPickingImage(Image& out_image);
114 
115  virtual bool isShadowCastingAvailable() const;
116 
117 private:
118  class Impl;
119  Impl* impl;
120 };
121 
122 }
123 
124 #endif
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::GLSceneRenderer::MinimumLighting
@ MinimumLighting
Definition: GLSceneRenderer.h:76
cnoid::SgPerspectiveCamera
Definition: SceneCameras.h:56
cnoid::GLSceneRenderer::LightingMode
LightingMode
Definition: GLSceneRenderer.h:74
cnoid::SgGroup
Definition: SceneGraph.h:220
cnoid::GLSceneRenderer::RendererType
RendererType
Definition: GLSceneRenderer.h:21
cnoid::GLSceneRenderer::NormalLighting
@ NormalLighting
Definition: GLSceneRenderer.h:75
cnoid::GLSceneRenderer
Definition: GLSceneRenderer.h:16
cnoid::Matrix4
Eigen::Matrix4d Matrix4
Definition: EigenTypes.h:58
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::GLSceneRenderer::ENABLE_BACK_FACE_CULLING
@ ENABLE_BACK_FACE_CULLING
Definition: GLSceneRenderer.h:101
cnoid::GLSceneRenderer::FORCE_BACK_FACE_CULLING
@ FORCE_BACK_FACE_CULLING
Definition: GLSceneRenderer.h:103
cnoid::SgNodePath
std::vector< SgNode * > SgNodePath
Definition: SceneGraph.h:24
cnoid::Image
Definition: Image.h:16
cnoid::GLSceneRenderer::NoLighting
@ NoLighting
Definition: GLSceneRenderer.h:78
cnoid::GLSceneRenderer::DISABLE_BACK_FACE_CULLING
@ DISABLE_BACK_FACE_CULLING
Definition: GLSceneRenderer.h:102
cnoid::SgMaterial
Definition: SceneDrawables.h:18
cnoid::SgOrthographicCamera
Definition: SceneCameras.h:83
cnoid::GLSceneRenderer::SolidColorLighting
@ SolidColorLighting
Definition: GLSceneRenderer.h:77
cnoid::SceneRenderer
Definition: SceneRenderer.h:15
cnoid::GLSceneRenderer::CullingMode
CullingMode
Definition: GLSceneRenderer.h:100