@@ -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,42 @@ 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+ // ! \param fbo holds the texture that is used for transparency.
92+ // !
6693 virtual void draw (const Scene_item &item, CGAL::Three::Viewer_interface* viewer,
6794 bool is_color_uniform,
6895 QOpenGLFramebufferObject* fbo = NULL ) const = 0;
6996
97+ // !
98+ // ! \brief initializeBuffers sends the data to the GPU memory.
99+ // !
100+ // ! It actually fills up the buffers with the data provided by `Vbo::allocate()`;
101+ // ! \param viewer the active `Viewer_interface`.
102+ // !
70103 void initializeBuffers (CGAL::Three::Viewer_interface* viewer) const
71104 {
72105 if (!VAOs[viewer])
@@ -102,6 +135,9 @@ struct DEMO_FRAMEWORK_EXPORT Primitive_container
102135 is_init[viewer] = true ;
103136 }
104137
138+ // !
139+ // ! \brief reset_vbos de-allocates the `Vbo`s. It must be called when the `Vbo`s data is updated.
140+ // !
105141 void reset_vbos ()
106142 {
107143 Q_FOREACH (CGAL::Three::Vbo* vbo, VBOs)
@@ -112,16 +148,46 @@ struct DEMO_FRAMEWORK_EXPORT Primitive_container
112148 }
113149 }
114150
151+ // !
152+ // ! \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`.
153+ // !
115154 mutable QMap<CGAL::Three::Viewer_interface*, Vao*> VAOs;
155+ // !
156+ // ! \brief VBOs holds the `Vbo`s containing the data for this container.
157+ // !
116158 mutable std::vector<Vbo*> VBOs;
159+ // !
160+ // ! \brief program_id is the `OpenGL_program_IDs` used with this container.
161+ // !
117162 int program_id;
163+ // !
164+ // ! \brief indexed specifies if the data is indexed or not. This matters for the internal drawing functions.
165+ // !
118166 bool indexed;
119167 mutable QMap<CGAL::Three::Viewer_interface*, bool > is_init;
120168 mutable QMap<CGAL::Three::Viewer_interface*, bool > is_gl_init;
169+
170+ // !
171+ // ! \brief is_selected must be filled with the selected state of the item that holds this container everytime this state changes.
172+ // ! If program_id doesn't use this property, it can be ignored.
173+ // !
121174 mutable bool is_selected;
175+ // !
176+ // ! \brief flat_size contains the number of units contained in the vertex buffer.
177+ // ! You can ignore it if `indexed` is true.
178+ // !
122179 mutable std::size_t flat_size;
180+ // ! \brief flat_size contains the number of units contained in the barycenter buffer.
181+ // ! You can ignore it if `program_id` is not an instanced program (like PROGRAM_SPHERES, PROGRAM_CUTPLANE_SPHERES,
182+ // ! PROGRAM_INSTANCED_WIRE or PROGRAM_INSTANCED).
123183 mutable std::size_t center_size;
184+ // !
185+ // ! \brief idx_size contains the number of indices in an `Index_buffer`. You can ignore it if `indexed` is `false`.
186+ // !
124187 mutable std::size_t idx_size;
188+ // !
189+ // ! \brief color contains the color of the data. Ignore it if `is_color_uniform` is `false` in `draw()`.
190+ // !
125191 mutable QColor color;
126192}; // end of class Triangle_container
127193
0 commit comments