gdk-graphics  1b6d84e044c2c953fd7c9501e628a67e80f4da0d
webgl1es2_model.h
1 // © Joseph Cameron - All Rights Reserved
2 
3 #ifndef GDK_GFX_VERTEX_DATA_H
4 #define GDK_GFX_VERTEX_DATA_H
5 
6 #include <gdk/model.h>
7 #include <gdk/webgl1es2_vertex_format.h>
8 #include <jfc/shared_proxy_ptr.h>
9 #include <jfc/unique_handle.h>
10 
11 #include <iosfwd>
12 #include <string>
13 
14 namespace gdk
15 {
17  class webgl1es2_model final : public model
18  {
19  public:
24 
26  using index_data_type = GLushort;
27 
29  enum class Type
30  {
32  Dynamic,
33 
35  Static,
36 
38  Stream
39  };
40 
42  enum class PrimitiveMode
43  {
45  Points,
46 
48  Lines,
49 
52  LineStrip,
53 
55  LineLoop,
56 
58  Triangles,
59 
61  TriangleStrip,
62 
65  TriangleFan
66  };
67 
72  void bind(const webgl1es2_shader_program &aShaderProgram) const;
73 
75  void draw() const;
76 
78  virtual void update_vertex_data(const UsageHint &,
79  const vertex_data& vertexDataView) override;
80 
82  bool operator==(const webgl1es2_model &);
84  bool operator!=(const webgl1es2_model &);
85 
89  webgl1es2_model(webgl1es2_model &&) = default;
90 
92  webgl1es2_model &operator=(const webgl1es2_model &other) = delete;
94  webgl1es2_model(const webgl1es2_model &) = delete;
95 
96  webgl1es2_model(const UsageHint &aUsage, const vertex_data &aData);
97 
99  static const jfc::shared_proxy_ptr<gdk::webgl1es2_model> Quad;
101  static const jfc::shared_proxy_ptr<gdk::webgl1es2_model> Cube;
102 
103  private:
105  jfc::unique_handle<GLuint> m_IndexBufferHandle;
106 
108  GLsizei m_IndexCount = 0;
109 
111  jfc::unique_handle<GLuint> m_VertexBufferHandle;
112 
115 
117  GLsizei m_VertexCount = 0;
118 
120  PrimitiveMode m_PrimitiveMode = PrimitiveMode::Triangles;
121  };
122 }
123 
124 #endif
125 
static const jfc::shared_proxy_ptr< gdk::webgl1es2_model > Cube
a cube with format pos3uv2norm3
Definition: webgl1es2_model.h:101
static const jfc::shared_proxy_ptr< gdk::webgl1es2_model > Quad
a quad with format pos3uv2
Definition: webgl1es2_model.h:99
used to construct a model. Vertex data represents a set of vertex data in system memory ...
Definition: vertex_data.h:44
GLushort index_data_type
type that must be used for index buffer data
Definition: webgl1es2_model.h:26
bool operator!=(const webgl1es2_model &)
equality semantics based on handle values
Vertex data representing a 3D graphical object.
Definition: model.h:11
Definition: camera.h:9
The data store contents will be modified once and used at most a few times.
bool operator==(const webgl1es2_model &)
equality semantics based on handle values
void draw() const
invokes pipeline on the data. data must be bound
The data store contents will be modified repeatedly and used many times.
Every 3 verticies define a triangle.
Specifies drawing behaviours at the two programmable stages in the OpenGL ES 2.0/WebGL 1...
Definition: webgl1es2_shader_program.h:24
webgl1es2_model(webgl1es2_model &&)=default
support move semantics
Type
Hint to the graphics device about how the vertex data will be used.
Definition: webgl1es2_model.h:29
webgl1es2_model & operator=(webgl1es2_model &&)=default
support move semantics
virtual void update_vertex_data(const UsageHint &, const vertex_data &vertexDataView) override
replace current data in the vbo and ibo with new data
Vertex data representing a 3D graphical object.
Definition: webgl1es2_model.h:17
GLfloat attribute_component_data_type
Definition: webgl1es2_model.h:23
informs the gl context how to interpret the currently bound vertex data.
Definition: webgl1es2_vertex_format.h:26
PrimitiveMode
Determines the primitive type used at the primitive assembly stage.
Definition: webgl1es2_model.h:42
The data store contents will be modified once and used many times.
static const webgl1es2_vertex_format Pos3uv2
{3 position, 2 uv} format
Definition: webgl1es2_vertex_format.h:58
void bind(const webgl1es2_shader_program &aShaderProgram) const
strong association with draw. If draw is on this instance is not called after bind() has not been cal...