@@ -38,9 +38,17 @@ class QOpenGLFramebufferObject;
3838namespace CGAL {
3939namespace Three {
4040
41+ // !
42+ // ! \brief The Primitive_container struct provides a base for the OpenGL data wrappers.
43+ // !
4144struct DEMO_FRAMEWORK_EXPORT Primitive_container
4245{
4346
47+ // !
48+ // ! \brief Primitive_container constructor.
49+ // ! \param program the `QOpenGLShaderProgram` used by the VAOs.
50+ // ! \param indexed must be `true` if the data is indexed, `false` otherwise.
51+ // !
4452 Primitive_container (int program, bool indexed)
4553 : program_id(program), indexed(indexed),
4654 flat_size (0 ), idx_size(0 )
@@ -56,17 +64,41 @@ struct DEMO_FRAMEWORK_EXPORT Primitive_container
5664 removeViewer (viewer);
5765 }
5866 }
67+
68+ // !
69+ // ! \brief initGL initializes the OpenGL containers.
70+ // ! \attention It must be called within a valid OpenGL context. The `draw()` function of an item is always a safe place to call this.
71+ // !
72+ // ! \param item the `Scene_item` that uses this container.
73+ // ! \param viewer the active `Viewer_interface`.
5974 virtual void initGL (const CGAL::Three::Scene_item& item, CGAL::Three::Viewer_interface* viewer) const = 0;
75+
76+ // !
77+ // ! \brief removeViewer deletes and removes the Vao assigned to `viewer` from `Vaos`.
78+ // ! \param viewer the `Viewer_interface` to remove.
79+ // !
6080 void removeViewer (CGAL::Three::Viewer_interface* viewer) const
6181 {
6282 delete VAOs[viewer];
6383 VAOs.remove (viewer);
6484 }
6585
86+ // !
87+ // ! \brief draw is the function that actually renders the data.
88+ // ! \param item the `Scene_item` that uses this container.
89+ // ! \param viewer the active `Viewer_interface`.
90+ // ! \param is_color_uniform should be `true` if the item is unicolor.
91+ // !
6692 virtual void draw (const Scene_item &item, CGAL::Three::Viewer_interface* viewer,
6793 bool is_color_uniform,
6894 QOpenGLFramebufferObject* fbo = NULL ) const = 0;
6995
96+ // !
97+ // ! \brief initializeBuffers sends the data to the GPU memory.
98+ // !
99+ // ! It actually fills up the buffers with the data provided by `Vbo::allocate()`;
100+ // ! \param viewer the active `Viewer_interface`.
101+ // !
70102 void initializeBuffers (CGAL::Three::Viewer_interface* viewer) const
71103 {
72104 if (!VAOs[viewer])
@@ -102,6 +134,9 @@ struct DEMO_FRAMEWORK_EXPORT Primitive_container
102134 is_init[viewer] = true ;
103135 }
104136
137+ // !
138+ // ! \brief reset_vbos de-allocates the `Vbo`s. It must be called when the `Vbo`s data is updated.
139+ // !
105140 void reset_vbos ()
106141 {
107142 Q_FOREACH (CGAL::Three::Vbo* vbo, VBOs)
@@ -112,16 +147,46 @@ struct DEMO_FRAMEWORK_EXPORT Primitive_container
112147 }
113148 }
114149
150+ // !
151+ // ! \brief VAOs holds the `Vao`s for each `Viewer_interface`. As a `Vao` is context dependent, there must be one Vao for each `Viewer_interface`.
152+ // !
115153 mutable QMap<CGAL::Three::Viewer_interface*, Vao*> VAOs;
154+ // !
155+ // ! \brief VBOs holds the `Vbo`s containing the data for this container.
156+ // !
116157 mutable std::vector<Vbo*> VBOs;
158+ // !
159+ // ! \brief program_id is the `OpenGL_program_IDs` used with this container.
160+ // !
117161 int program_id;
162+ // !
163+ // ! \brief indexed specifies if the data is indexed or not. This matters for the internal drawing functions.
164+ // !
118165 bool indexed;
119166 mutable QMap<CGAL::Three::Viewer_interface*, bool > is_init;
120167 mutable QMap<CGAL::Three::Viewer_interface*, bool > is_gl_init;
168+
169+ // !
170+ // ! \brief is_selected must be filled with the selected state of the item that holds this container everytime this state changes.
171+ // ! If program_id doesn't use this property, it can be ignored.
172+ // !
121173 mutable bool is_selected;
174+ // !
175+ // ! \brief flat_size contains the number of units contained in the vertex buffer.
176+ // ! You can ignore it if `indexed` is true.
177+ // !
122178 mutable std::size_t flat_size;
179+ // ! \brief flat_size contains the number of units contained in the barycenter buffer.
180+ // ! You can ignore it if `program_id` is not an instanced program (like PROGRAM_SPHERES, PROGRAM_CUTPLANE_SPHERES,
181+ // ! PROGRAM_INSTANCED_WIRE or PROGRAM_INSTANCED).
123182 mutable std::size_t center_size;
183+ // !
184+ // ! \brief idx_size contains the number of indices in an `Index_buffer`. You can ignore it if `indexed` is `false`.
185+ // !
124186 mutable std::size_t idx_size;
187+ // !
188+ // ! \brief color contains the color of the data. Ignore it if `is_color_uniform` is `false` in `draw()`.
189+ // !
125190 mutable QColor color;
126191}; // end of class Triangle_container
127192
0 commit comments