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_8hpp_source.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'spritebatch_8hpp_source.html') diff --git a/spritebatch_8hpp_source.html b/spritebatch_8hpp_source.html index 8de31732..5b2f89f0 100644 --- a/spritebatch_8hpp_source.html +++ b/spritebatch_8hpp_source.html @@ -29,7 +29,7 @@
YAGE -  0.02 +  v0.1.1
Yet Another Game Engine
@@ -86,7 +86,7 @@ $(document).ready(function(){initNavTree('spritebatch_8hpp_source.html','');});
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * spritebatch.hpp
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_HPP
10 #define YAGE_SPRITE_BATCH_HPP
11 
12 #include "vertex.hpp"
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.hpp:49
-
bool init()
Definition: yage.hpp:31
+
bool init()
Initializes YAGE.
Definition: yage.hpp:47
std::vector< Glyph * > glyph_ptrs_
Definition: spritebatch.hpp:75
GLuint texture_
Definition: spritebatch.hpp:56
Vertex bottom_left_
Definition: spritebatch.hpp:34
@@ -113,7 +113,7 @@ $(document).ready(function(){initNavTree('spritebatch_8hpp_source.html','');});
GLint offset() const
Definition: spritebatch.hpp:61
Glyph with information of the texture.
Definition: spritebatch.hpp:26
Vertex top_left() const
Definition: spritebatch.hpp:43
-
Templated matrix class.
Definition: camera2d.hpp:17
+
Project namespace.
Definition: body.cpp:13
GLsizei num_vertices_
Definition: spritebatch.hpp:54
Definition: vertex.hpp:26
@@ -122,7 +122,7 @@ $(document).ready(function(){initNavTree('spritebatch_8hpp_source.html','');});