Choreonoid  1.8
GLSLSceneRenderer.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_BASE_GLSL_SCENE_RENDERER_H
7 #define CNOID_BASE_GLSL_SCENE_RENDERER_H
8 
9 #include <cnoid/GLSceneRenderer>
10 #include "exportdecl.h"
11 
12 namespace cnoid {
13 
14 class ShaderProgram;
15 class LightingProgram;
16 
17 class CNOID_EXPORT GLSLSceneRenderer : public GLSceneRenderer
18 {
19  public:
20  GLSLSceneRenderer(SgGroup* root = nullptr);
21  virtual ~GLSLSceneRenderer();
22 
23  static void addExtension(std::function<void(GLSLSceneRenderer* renderer)> func);
24  virtual void applyExtensions() override;
25  virtual bool applyNewExtensions() override;
26 
27  virtual void setOutputStream(std::ostream& os) override;
28 
29  virtual PolymorphicSceneNodeFunctionSet* renderingFunctions() override;
30  virtual void renderCustomGroup(SgGroup* transform, std::function<void()> traverseFunction) override;
31  virtual void renderCustomTransform(SgTransform* transform, std::function<void()> traverseFunction) override;
32  virtual void renderNode(SgNode* node) override;
33 
34  virtual void addNodeDecoration(SgNode* node, NodeDecorationFunction func, int id) override;
35  virtual void clearNodeDecorations(int id) override;
36 
37  virtual const Affine3& currentModelTransform() const override;
38  virtual const Matrix4& projectionMatrix() const override;
39  const Isometry3& viewTransform() const;
40  const Matrix4& viewProjectionMatrix() const;
41  Matrix4 modelViewMatrix() const;
42  Matrix4 modelViewProjectionMatrix() const;
43  virtual double projectedPixelSizeRatio(const Vector3& position) const override;
44 
45  void pushShaderProgram(ShaderProgram* program);
46  void popShaderProgram();
47 
48  void renderLights(LightingProgram* program);
49  void renderFog(LightingProgram* program);
50 
51  void dispatchToTransparentPhase(
52  ReferencedPtr object, int id,
53  const std::function<void(Referenced* object, const Affine3& modelTransform, int id)>& renderingFunction);
54 
55  virtual bool initializeGL() override;
56  virtual void flushGL() override;
57  virtual void clearGL() override;
58  virtual void setDefaultFramebufferObject(unsigned int id) override;
59  virtual const std::string& glVendor() const override;
60  virtual void setViewport(int x, int y, int width, int height) override;
61  virtual void updateViewportInformation(int x, int y, int width, int height) override;
62 
63  virtual const Vector3& pickedPoint() const override;
64  virtual const SgNodePath& pickedNodePath() const override;
65  virtual bool isRenderingPickingImage() const override;
66 
67  virtual void setLightingMode(LightingMode mode) override;
68  virtual LightingMode lightingMode() const override;
69 
70  virtual void clearShadows() override;
71  virtual void enableShadowOfLight(int index, bool on) override;
72  virtual void enableShadowAntiAliasing(bool on) override;
73  virtual void setDefaultSmoothShading(bool on) override;
74  virtual SgMaterial* defaultMaterial() override;
75  virtual void enableTexture(bool on) override;
76  virtual void setDefaultPointSize(double size) override;
77  virtual void setDefaultLineWidth(double width) override;
78  virtual void showNormalVectors(double length) override;
79  virtual void requestToClearResources() override;
80  virtual void enableUnusedResourceCheck(bool on) override;
81  virtual void setColor(const Vector3f& color) override;
82  virtual void setUpsideDown(bool on) override;
83  virtual void setBackFaceCullingMode(int mode) override;
84  virtual int backFaceCullingMode() const override;
85  virtual void setBoundingBoxRenderingForLightweightRenderingGroupEnabled(bool on) override;
86 
87  void setLowMemoryConsumptionMode(bool on);
88 
89  virtual void setPickingImageOutputEnabled(bool on) override;
90  virtual bool getPickingImage(Image& out_image) override;
91 
92  virtual bool isShadowCastingAvailable() const override;
93 
94  class Impl;
95 
96 protected:
97  virtual void doRender() override;
98  virtual bool doPick(int x, int y) override;
99 
100 private:
101  Impl* impl;
102 };
103 
104 }
105 
106 #endif
cnoid::SgTransform
Definition: SceneGraph.h:336
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::GLSLSceneRenderer
Definition: GLSLSceneRenderer.h:17
cnoid::GLSceneRenderer::LightingMode
LightingMode
Definition: GLSceneRenderer.h:74
cnoid::SgGroup
Definition: SceneGraph.h:220
cnoid::Isometry3
Eigen::Isometry3d Isometry3
Definition: EigenTypes.h:73
cnoid::GLSceneRenderer
Definition: GLSceneRenderer.h:16
cnoid::ref_ptr< Referenced >
cnoid::Matrix4
Eigen::Matrix4d Matrix4
Definition: EigenTypes.h:58
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::SceneRenderer::NodeDecorationFunction
std::function< SgNode *(SgNode *targetNode)> NodeDecorationFunction
Definition: SceneRenderer.h:42
cnoid::Referenced
Definition: Referenced.h:54
cnoid::PolymorphicSceneNodeFunctionSet
Definition: PolymorphicSceneNodeFunctionSet.h:10
cnoid::SgNodePath
std::vector< SgNode * > SgNodePath
Definition: SceneGraph.h:24
cnoid::Image
Definition: Image.h:16
cnoid::LightingProgram
Definition: ShaderPrograms.h:206
cnoid::SgMaterial
Definition: SceneDrawables.h:18
cnoid::SgNode
Definition: SceneGraph.h:157
cnoid::Affine3
Eigen::Affine3d Affine3
Definition: EigenTypes.h:62
cnoid::ShaderProgram
Definition: ShaderPrograms.h:21