Graphite  Version 3
An experimental 3D geometry processing program
GLUP_context_ES.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2022 Inria
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of the ALICE Project-Team nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Contact: Bruno Levy
30  *
31  * https://www.inria.fr/fr/bruno-levy
32  *
33  * Inria,
34  * Domaine de Voluceau,
35  * 78150 Le Chesnay - Rocquencourt
36  * FRANCE
37  *
38  */
39 
40 #ifndef GEOGRAM_GFX_GLUP_GLUP_CONTEXT_ES
41 #define GEOGRAM_GFX_GLUP_GLUP_CONTEXT_ES
42 
45 
52 #ifdef GEO_GL_ES2
53 
54 namespace GLUP {
55  using namespace GEO;
56 
57  /*********************************************************************/
58 
68  class Context_ES2 : public Context {
69  public:
70 
74  Context_ES2();
75 
79  ~Context_ES2() override;
80 
84  void begin(GLUPprimitive primitive) override;
85 
89  void end() override;
90 
94  const char* profile_name() const override;
95 
99  void setup() override;
100 
104  bool primitive_supports_array_mode(GLUPprimitive prim) const override;
105 
106 
110  void get_primitive_pseudo_file(
111  std::vector<GLSL::Source>& sources
112  ) override;
113 
117  void get_vertex_shader_preamble_pseudo_file(
118  std::vector<GLSL::Source>& sources
119  ) override;
120 
124  void get_fragment_shader_preamble_pseudo_file(
125  std::vector<GLSL::Source>& sources
126  ) override;
127 
131  void get_toggles_pseudo_file(
132  std::vector<GLSL::Source>& sources
133  ) override;
134 
135  protected:
136 
140  void prepare_to_draw(GLUPprimitive primitive) override;
141 
145  void done_draw(GLUPprimitive primitive) override;
146 
150  Memory::pointer get_state_variable_address(const char* name) override;
151 
155  void do_update_uniform_buffer() override;
156 
160  void copy_uniform_state_to_current_program() override;
161 
165  void update_base_picking_id(GLint new_value) override;
166 
170  void setup_GLUP_POINTS() override;
171 
175  void setup_GLUP_LINES() override;
176 
180  void setup_GLUP_THICK_LINES() override;
181 
197  void setup_primitive_generic(
198  index_t nb_elements_per_glup_primitive,
199  index_t* element_indices
200  );
201 
205  void setup_GLUP_TRIANGLES() override;
206 
210  void setup_GLUP_QUADS() override;
211 
215  void setup_GLUP_TETRAHEDRA() override;
216 
220  void setup_GLUP_PRISMS() override;
221 
225  void setup_GLUP_HEXAHEDRA() override;
226 
230  void setup_GLUP_PYRAMIDS() override;
231 
235  void setup_GLUP_CONNECTORS() override;
236 
240  void setup_GLUP_SPHERES() override;
241 
245  void flush_immediate_buffers() override;
246 
247 
256  bool cell_by_cell_clipping() const;
257 
266  bool sliced_cells_clipping() const;
267 
274  void flush_immediate_buffers_with_cell_by_cell_clipping();
275 
281  void flush_immediate_buffers_with_sliced_cells_clipping();
282 
283 
284  private:
285  index_t nb_clip_cells_elements_;
286  Numeric::uint16* clip_cells_elements_;
287 
288  GLuint clip_cells_elements_VBO_;
289  GLuint clip_cells_VAO_;
290 
291  GLuint sliced_cells_elements_VBO_;
292  GLuint sliced_cells_vertex_attrib_VBO_[4];
293  GLuint sliced_cells_VAO_;
294 
295  double GLSL_version_;
296 
297  bool vertex_id_VBO_bound_;
298  };
299 
300  /*********************************************************************/
301 
302 }
303 
304 #endif
305 
306 #endif
GLUPprimitive
Symbolic values corresponding to GLUP primitive types.
Definition: GLUP.h:470
Internal implementation of GLUP context.
Common include file, providing basic definitions. Should be included before anything else by all head...
byte * pointer
Pointer to unsigned byte(s)
Definition: memory.h:104
uint16_t uint16
Definition: numeric.h:138
Global Vorpaline namespace.
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329