From 8ad8165816929301a87e90bbb32c3df6b69030ee Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 2 Sep 2017 12:28:11 +0100 Subject: Updating docs --- spritebatch_8h_source.html | 131 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 spritebatch_8h_source.html (limited to 'spritebatch_8h_source.html') diff --git a/spritebatch_8h_source.html b/spritebatch_8h_source.html new file mode 100644 index 00000000..46a74313 --- /dev/null +++ b/spritebatch_8h_source.html @@ -0,0 +1,131 @@ + + + + + + + +YAGE: include/YAGE/spritebatch.h Source File + + + + + + + + + + + + + + +
+
+ + + + + + +
+
YAGE +  v0.1.1 +
+
Yet Another Game Engine
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
spritebatch.h
+
+
+Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * spritebatch.h
3  *
4  * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License
5  * See file LICENSE for more details
6  * ----------------------------------------------------------------------------
7  */
8 
9 #ifndef YAGE_SPRITE_BATCH_H
10 #define YAGE_SPRITE_BATCH_H
11 
12 #include "vertex.h"
13 
14 #include <GL/glew.h>
15 #include <glm/glm.hpp>
16 
17 #include <vector>
18 
19 namespace yage
20 {
21 
22 class SpriteBatch;
23 
26 class Glyph
27 {
28 private:
29  GLuint texture_;
30  float depth_;
35 
36 public:
37  Glyph(GLuint texture, float depth, const Vertex &top_left,
38  const Vertex &top_right, const Vertex &bottom_right,
39  const Vertex &bottom_left);
40 
41  GLuint texture() const { return texture_; }
42  float depth() const { return depth_; }
43  Vertex top_left() const { return top_left_; }
44  Vertex top_right() const { return top_right_; }
45  Vertex bottom_right() const { return bottom_right_; }
46  Vertex bottom_left() const { return bottom_left_; }
47 };
48 
50 {
51  friend SpriteBatch;
52 
53 private:
54  GLsizei num_vertices_;
55  GLint offset_;
56  GLuint texture_;
57 
58 public:
59  RenderBatch(GLint offset, GLsizei num_vertices, GLuint texture);
60 
61  GLint offset() const { return offset_; }
62  GLsizei num_vertices() const { return num_vertices_; }
63  GLuint texture() const { return texture_; }
64 };
65 
67 {
68 public:
69  static const int NUM_VERTICES = 6;
70 
71 private:
72  GLuint vbo_ = 0;
73  GLuint vao_ = 0;
74  std::vector<Glyph> glyphs_;
75  std::vector<Glyph *> glyph_ptrs_;
76  std::vector<RenderBatch> render_batches_;
77 
78 public:
79  SpriteBatch();
80  SpriteBatch(const SpriteBatch &) = delete;
81  SpriteBatch(SpriteBatch &&) = delete;
82  ~SpriteBatch();
83 
84  SpriteBatch &operator=(const SpriteBatch &) = delete;
85  SpriteBatch &operator=(SpriteBatch &&) = delete;
86 
87  // initialize vaos and vbos
88  void init();
89  void begin();
90  void end();
91  // adds a sprite to the sprite batch to be rendered later
92  void draw(const glm::vec4 &destination_rect, const glm::vec4 &uv_rect,
93  GLuint texture, const Color &color, float depth);
94  // render the batch
95  void render();
96 
97 private:
98  void createVertexArray();
99  void createRenderBatches();
100  void sortGlyphs();
101 };
102 
103 } // namespace yage
104 
105 #endif
Definition: spritebatch.h:49
+
bool init()
Initializes YAGE.
Definition: yage.h:47
+
std::vector< Glyph * > glyph_ptrs_
Definition: spritebatch.h:75
+
GLuint texture_
Definition: spritebatch.h:56
+
Vertex bottom_left_
Definition: spritebatch.h:34
+
Vertex top_right() const
Definition: spritebatch.h:44
+
GLuint texture() const
Definition: spritebatch.h:41
+
Definition: vertex.h:49
+
float depth() const
Definition: spritebatch.h:42
+
Definition: spritebatch.h:66
+
Vertex top_left_
Definition: spritebatch.h:31
+
GLuint texture() const
Definition: spritebatch.h:63
+
Glyph(GLuint texture, float depth, const Vertex &top_left, const Vertex &top_right, const Vertex &bottom_right, const Vertex &bottom_left)
Definition: spritebatch.cpp:19
+
float depth_
Definition: spritebatch.h:30
+ +
friend SpriteBatch
Definition: spritebatch.h:51
+
GLuint texture_
Definition: spritebatch.h:29
+
Vertex bottom_left() const
Definition: spritebatch.h:46
+
Vertex bottom_right() const
Definition: spritebatch.h:45
+
Vertex bottom_right_
Definition: spritebatch.h:33
+
std::vector< RenderBatch > render_batches_
Definition: spritebatch.h:76
+
std::vector< Glyph > glyphs_
Definition: spritebatch.h:74
+
GLint offset_
Definition: spritebatch.h:55
+
Vertex top_right_
Definition: spritebatch.h:32
+
GLsizei num_vertices() const
Definition: spritebatch.h:62
+
GLint offset() const
Definition: spritebatch.h:61
+
Glyph with information of the texture.
Definition: spritebatch.h:26
+
Vertex top_left() const
Definition: spritebatch.h:43
+
Project namespace.
Definition: body.cpp:13
+
GLsizei num_vertices_
Definition: spritebatch.h:54
+
Definition: vertex.h:26
+
+
+ + + + -- cgit