Euphoria
buffer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "render/id.h"
5 
6 
7 namespace eu::render
8 {
12  struct VertexBuffer : public Id
13  {
14  VertexBuffer();
15  ~VertexBuffer();
16 
17  VertexBuffer(const VertexBuffer&) = delete;
19  void operator=(const VertexBuffer&) = delete;
20  void operator=(VertexBuffer&&) = delete;
21 
22  void set_data(const std::vector<float>& data);
23 
24  static void bind(const VertexBuffer* vbo);
25 
26  static const VertexBuffer*& get_bound();
27  };
28 
29 
33  struct PointLayout : public Id
34  {
35  std::vector<ShaderAttribute> attributes;
36 
37  PointLayout();
38  ~PointLayout();
39 
40  PointLayout(const PointLayout&) = delete;
41  PointLayout(PointLayout&&) = delete;
42  void operator=(const PointLayout&) = delete;
43  void operator=(PointLayout&&) = delete;
44 
45  static const PointLayout*& get_bound();
46 
47  void bind_data(const ShaderAttribute& attribute, int stride, int offset);
48 
49  static void bind(const PointLayout* vao);
50  };
51 
52 
53  enum class RenderMode
54  {
55  lines,
56  triangles
57  };
58 
59 
63  struct IndexBuffer : public Id
64  {
65  IndexBuffer();
66  ~IndexBuffer();
67 
68  IndexBuffer(const IndexBuffer&) = delete;
69  IndexBuffer(IndexBuffer&&) = delete;
70  void operator=(const IndexBuffer&) = delete;
71  void operator=(IndexBuffer&&) = delete;
72 
73  static const IndexBuffer*& get_bound();
74 
75  void set_data(const std::vector<unsigned int>& indices);
76 
78  void draw(RenderMode mode, int count) const;
79 
80  static void bind(const IndexBuffer* ebo);
81  };
82 
83 }
RenderMode
Definition: buffer.h:54
constexpr int stride
Definition: spritebatch.cc:11
Reuses points.
Definition: buffer.h:64
IndexBuffer(const IndexBuffer &)=delete
static const IndexBuffer *& get_bound()
Definition: buffer.cc:224
void set_data(const std::vector< unsigned int > &indices)
Definition: buffer.cc:162
void operator=(IndexBuffer &&)=delete
IndexBuffer(IndexBuffer &&)=delete
void operator=(const IndexBuffer &)=delete
void draw(RenderMode mode, int count) const
Definition: buffer.cc:176
static void bind(const IndexBuffer *ebo)
Definition: buffer.cc:216
Stores what the data in the vertex_buffer is and how it is laid out/used Represents a OpenGL Vertex A...
Definition: buffer.h:34
static const PointLayout *& get_bound()
Definition: buffer.cc:139
std::vector< ShaderAttribute > attributes
Definition: buffer.h:35
PointLayout(PointLayout &&)=delete
PointLayout(const PointLayout &)=delete
void operator=(PointLayout &&)=delete
static void bind(const PointLayout *vao)
Definition: buffer.cc:130
void operator=(const PointLayout &)=delete
void bind_data(const ShaderAttribute &attribute, int stride, int offset)
Definition: buffer.cc:110
Represents a shader attribute like vertex, normal or uv coord.
Stores vertices, uv, etc.
Definition: buffer.h:13
void operator=(const VertexBuffer &)=delete
VertexBuffer(const VertexBuffer &)=delete
static const VertexBuffer *& get_bound()
Definition: buffer.cc:47
VertexBuffer(VertexBuffer &&)=delete
void operator=(VertexBuffer &&)=delete
void set_data(const std::vector< float > &data)
Definition: buffer.cc:29
static void bind(const VertexBuffer *vbo)
Definition: buffer.cc:38