Sceneview
 All Classes Functions Variables Enumerations Enumerator Groups Pages
draw_context.hpp
1 // Copyright [2015] Albert Huang
2 
3 #ifndef SCENEVIEW_DRAW_CONTEXT_HPP__
4 #define SCENEVIEW_DRAW_CONTEXT_HPP__
5 
6 #include <vector>
7 
8 #include <QColor>
9 
10 #include <sceneview/drawable.hpp>
11 #include <sceneview/resource_manager.hpp>
12 #include <sceneview/scene.hpp>
13 
14 class QOpenGLShaderProgram;
15 
16 namespace sv {
17 
18 class AxisAlignedBox;
19 class CameraNode;
20 class DrawGroup;
21 class DrawNode;
22 class Renderer;
23 class Plane;
24 
25 class DrawContext {
26  public:
27  DrawContext(const ResourceManager::Ptr& resources,
28  const Scene::Ptr& scene);
29 
30  void Draw(int viewport_width,
31  int viewport_height,
32  std::vector<Renderer*>* prenderers);
33 
34  void SetClearColor(const QColor& color);
35 
36  void SetDrawGroups(const std::vector<DrawGroup*>& groups);
37 
38  private:
39  void PrepareFixedFunctionPipeline();
40 
41  void DrawDrawGroup(DrawGroup* dgroup);
42 
43  void DrawDrawNode(DrawNode* node);
44 
45  void ActivateMaterial();
46 
47  void DrawGeometry();
48 
49  void DrawBoundingBox(const AxisAlignedBox& box);
50 
51  ResourceManager::Ptr resources_;
52 
53  Scene::Ptr scene_;
54 
55  QColor clear_color_;
56 
57  // Rendering variables
58  int viewport_width_ = 0;
59  int viewport_height_ = 0;
60  CameraNode* cur_camera_ = nullptr;
61 
62  MaterialResource::Ptr material_;
63  GeometryResource::Ptr geometry_;
64  ShaderResource::Ptr shader_;
65  QOpenGLShaderProgram* program_;
66  QMatrix4x4 model_mat_;
67 
68  std::vector<DrawGroup*> draw_groups_;
69 
70  bool gl_two_sided_;
71  bool gl_depth_test_;
72  GLenum gl_depth_func_;
73  bool gl_depth_write_;
74  bool gl_color_write_;
75  float gl_point_size_;
76  float gl_line_width_;
77  bool gl_blend_;
78  GLenum gl_sfactor_;
79  GLenum gl_dfactor_;
80 
81  // For debugging
82  DrawNode* bounding_box_node_;
83  bool draw_bounding_boxes_;
84 };
85 
86 } // namespace sv
87 
88 #endif // SCENEVIEW_DRAW_CONTEXT_HPP__
An axis-aligned box typically used for bounding box and intersection calculations.
Definition: axis_aligned_box.hpp:17
Scene node that contains a list of drawable objects.
Definition: draw_node.hpp:26
Camera.
Definition: camera_node.hpp:25
Definition: draw_group.hpp:22
Definition: draw_context.hpp:25