From 0b8a907d1f99b20cc789806ff70394a18cbea1d9 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sun, 13 Aug 2017 17:38:57 +0100 Subject: Updating docs --- annotated.html | 7 ++- body_8hpp_source.html | 6 +- camera2d_8hpp_source.html | 4 +- classes.html | 13 +++-- classyage_1_1Glyph-members.html | 82 +++++++++++++++++++++++++++ classyage_1_1Glyph.html | 92 +++++++++++++++++++++++++++++++ classyage_1_1Matrix-members.html | 2 +- classyage_1_1Matrix.html | 2 +- classyage_1_1Vector2-members.html | 2 +- classyage_1_1Vector2.html | 2 +- collider_8hpp_source.html | 4 +- collisionbody_8hpp_source.html | 4 +- dir_5ac3a90c14a160db9539610948ce4998.html | 2 +- dir_68267d1309a1af8e8297ef4c3efbcdba.html | 2 +- dir_b233a2caca2b45d5ef987dbbf49782d0.html | 2 +- dir_d44c64559bbebec7f509842c48db8b23.html | 2 +- dir_f562165b51c585c003877be645f219b5.html | 2 +- files.html | 2 +- functions.html | 2 +- functions_func.html | 2 +- functions_vars.html | 2 +- glslprogram_8hpp_source.html | 4 +- group__getters.html | 76 +++++++++++++++++++++++++ hierarchy.html | 13 +++-- imageloader_8hpp_source.html | 4 +- index.html | 2 +- inputmanager_8hpp_source.html | 2 +- iomanager_8hpp_source.html | 4 +- math_8hpp_source.html | 2 +- matrix_8hpp.html | 2 +- matrix_8hpp_source.html | 20 +++---- md_README.html | 4 +- md_docs_README.html | 2 +- menudata.js | 1 + modules.html | 80 +++++++++++++++++++++++++++ namespacemembers.html | 2 +- namespacemembers_func.html | 2 +- namespaces.html | 2 +- namespaceyage_1_1matrix.html | 2 +- pages.html | 2 +- particlebody_8hpp_source.html | 6 +- physics_8hpp_source.html | 2 +- picopng_8hpp_source.html | 2 +- rectanglecollider_8hpp_source.html | 4 +- resourcemanager_8hpp_source.html | 4 +- rigidbody_8hpp_source.html | 4 +- search/all_2.js | 4 +- search/classes_0.js | 4 +- search/classes_1.js | 5 +- search/classes_2.html | 26 +++++++++ search/classes_2.js | 5 ++ search/groups_0.html | 26 +++++++++ search/groups_0.js | 4 ++ search/searchdata.js | 11 ++-- sprite_8hpp_source.html | 4 +- spritebatch_8hpp_source.html | 5 +- texture_8hpp_source.html | 4 +- texturecache_8hpp_source.html | 4 +- vertex_8hpp_source.html | 4 +- window_8hpp_source.html | 4 +- yage_8hpp_source.html | 4 +- 61 files changed, 500 insertions(+), 100 deletions(-) create mode 100644 classyage_1_1Glyph-members.html create mode 100644 classyage_1_1Glyph.html create mode 100644 group__getters.html create mode 100644 modules.html create mode 100644 search/classes_2.html create mode 100644 search/classes_2.js create mode 100644 search/groups_0.html create mode 100644 search/groups_0.js diff --git a/annotated.html b/annotated.html index 719dee3d..f87db39d 100644 --- a/annotated.html +++ b/annotated.html @@ -67,14 +67,15 @@ $(function() {
Here are the classes, structs, unions and interfaces with brief descriptions:
[detail level 12]
- - + + +
 Nyage
 CMatrixBase Matrix class used by other similar classes
 CVector22D Vector class
 CGlyphGlyph with information of the texture
 CMatrixBase Matrix class used by other similar classes
 CVector22D Vector class
diff --git a/body_8hpp_source.html b/body_8hpp_source.html index d49146c8..4a4faa22 100644 --- a/body_8hpp_source.html +++ b/body_8hpp_source.html @@ -68,13 +68,13 @@ $(function() {
body.hpp
-
1 /* ----------------------------------------------------------------------------
2  * body.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_BODY_HPP
10 #define YAGE_BODY_HPP
11 
12 #include "Math/matrix.hpp"
13 
14 namespace yage
15 {
16 
17 class Body
18 {
19 public:
20  // gravity constant
21  static const double GRAVITY;
22 protected:
23  // center of mass of the object
24  Vector2d position_=Vector2d(0, 0);
25 
26  // mass of the object
27  double mass_=1;
28 
29  // current velocity of the object
30  Vector2d velocity_=Vector2d(0, 0);
31 
32  // boolean that defines if gravity can act on the object
33  bool gravity_=true;
34 
35  // current acceleration
36  Vector2d acceleration_=Vector2d(0, 0);
37 
38  // force acting on the body
39  Vector2d force_=Vector2d(0, 0);
40 
41 public:
42  virtual ~Body();
43 
44  // apply force to the object and update the velocity
45  virtual void applyForce(const Vector2d &force)=0;
46  virtual void update()=0;
47 
48  double xPosition() const;
49  double yPosition() const;
50 protected:
51  // protected constructor to initialize member variables
52  Body(const Vector2d &position=Vector2d(0, 0),
53  double mass=1,
54  const Vector2d &velocity=Vector2d(0, 0),
55  bool gravity=false);
56 };
57 
58 } // yage
59 
60 #endif
Templated matrix class.
-
Vector2< double > Vector2d
Definition of a 2D vector.
Definition: matrix.hpp:388
+
1 /* ----------------------------------------------------------------------------
2  * body.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_PHYSICS_BODY_HPP
10 #define YAGE_PHYSICS_BODY_HPP
11 
12 #include "Math/matrix.hpp"
13 
14 namespace yage {
15 class Body {
16 public:
17  // gravity constant
18  static const double GRAVITY;
19 
20 protected:
21  // center of mass of the object
22  Vector2d position_ = Vector2d(0, 0);
23 
24  // mass of the object
25  double mass_ = 1;
26 
27  // current velocity of the object
28  Vector2d velocity_ = Vector2d(0, 0);
29 
30  // boolean that defines if gravity can act on the object
31  bool gravity_ = true;
32 
33  // current acceleration
34  Vector2d acceleration_ = Vector2d(0, 0);
35 
36  // force acting on the body
37  Vector2d force_ = Vector2d(0, 0);
38 
39 public:
40  // apply force to the object and update the velocity
41  virtual void applyForce(const Vector2d& force) = 0;
42  virtual void update() = 0;
43 
44  double xPosition() const;
45  double yPosition() const;
46 
47 protected:
48  // protected constructor to initialize member variables
49  Body(const Vector2d& position = Vector2d(0, 0), double mass = 1, const Vector2d& velocity = Vector2d(0, 0), bool gravity = false);
50 };
51 } // namespace yage
52 
53 #endif
Templated matrix class.
+
Vector2< double > Vector2d
Definition of a 2D vector.
Definition: matrix.hpp:313
Definition: camera2d.hpp:17
diff --git a/camera2d_8hpp_source.html b/camera2d_8hpp_source.html index 819424df..62b052f7 100644 --- a/camera2d_8hpp_source.html +++ b/camera2d_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
camera2d.hpp
-
1 /* ----------------------------------------------------------------------------
2  * camera2d.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 CAMERA_2D_HPP
10 #define CAMERA_2D_HPP
11 
12 #include "glslprogram.hpp"
13 
14 #include <glm/glm.hpp>
15 #include <glm/gtc/matrix_transform.hpp>
16 
17 namespace yage
18 {
19 
20 class Camera2D
21 {
22 private:
23  bool matrix_needs_update_=true;
24  float scale_=1;
25  glm::vec2 position_;
26  glm::mat4 camera_matrix_;
27  glm::mat4 ortho_matrix_;
28 
29 public:
30  Camera2D(int screen_width=1280, int screen_height=720);
31  virtual ~Camera2D();
32 
33  // update camera location
34  void update(GlslProgram &program);
35  // camera movement
36  void move(const glm::vec2 &direction);
37 };
38 
39 } // yage
40 
41 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * camera2d.hpp
3  *
4  * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
5  * MIT License, see LICENSE file for more details.
6  * ----------------------------------------------------------------------------
7  */
8 
9 #ifndef CAMERA_2D_HPP
10 #define CAMERA_2D_HPP
11 
12 #include "glslprogram.hpp"
13 
14 #include <glm/glm.hpp>
15 #include <glm/gtc/matrix_transform.hpp>
16 
17 namespace yage {
18 
19 class Camera2D {
20 private:
21  bool matrix_needs_update_ = true;
22  float scale_ = 1;
23  glm::vec2 position_;
24  glm::mat4 camera_matrix_;
25  glm::mat4 ortho_matrix_;
26 
27 public:
28  Camera2D(int screen_width = 1280, int screen_height = 720);
29 
30  // update camera location
31  void update(GlslProgram& program);
32  // camera movement
33  void move(const glm::vec2& direction);
34 };
35 
36 } // yage
37 
38 #endif
Definition: camera2d.hpp:17
diff --git a/classes.html b/classes.html index 8da32181..11d168a6 100644 --- a/classes.html +++ b/classes.html @@ -64,20 +64,21 @@ $(function() {
Class Index
-
m | v
+
g | m | v
- - - + +
  m  
+
  g  
+
  m  
  v  
Matrix (yage)   Vector2 (yage)   
Glyph (yage)   Matrix (yage)   Vector2 (yage)   
-
m | v
+
g | m | v
diff --git a/classyage_1_1Glyph-members.html b/classyage_1_1Glyph-members.html new file mode 100644 index 00000000..679385e6 --- /dev/null +++ b/classyage_1_1Glyph-members.html @@ -0,0 +1,82 @@ + + + + + + + +YAGE: Member List + + + + + + + + + +
+
+ + + + + + +
+
YAGE +  0.02 +
+
Yet Another Game Engine
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
yage::Glyph Member List
+
+
+ +

This is the complete list of members for yage::Glyph, including all inherited members.

+ +
+ + + + diff --git a/classyage_1_1Glyph.html b/classyage_1_1Glyph.html new file mode 100644 index 00000000..252a1514 --- /dev/null +++ b/classyage_1_1Glyph.html @@ -0,0 +1,92 @@ + + + + + + + +YAGE: yage::Glyph Class Reference + + + + + + + + + +
+
+ + + + + + +
+
YAGE +  0.02 +
+
Yet Another Game Engine
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+ +
+
yage::Glyph Class Reference
+
+
+ +

Glyph with information of the texture. + More...

+ +

#include <spritebatch.hpp>

+

Detailed Description

+

Glyph with information of the texture.

+

The documentation for this class was generated from the following files: +
+ + + + diff --git a/classyage_1_1Matrix-members.html b/classyage_1_1Matrix-members.html index 54a2bdec..78bb2b90 100644 --- a/classyage_1_1Matrix-members.html +++ b/classyage_1_1Matrix-members.html @@ -79,7 +79,7 @@ $(function() { diff --git a/classyage_1_1Matrix.html b/classyage_1_1Matrix.html index b90c92a4..a7e87954 100644 --- a/classyage_1_1Matrix.html +++ b/classyage_1_1Matrix.html @@ -154,7 +154,7 @@ template<int Rows = 4, int Cols = 4, class Type = double> diff --git a/classyage_1_1Vector2-members.html b/classyage_1_1Vector2-members.html index 89171f86..117d4683 100644 --- a/classyage_1_1Vector2-members.html +++ b/classyage_1_1Vector2-members.html @@ -79,7 +79,7 @@ $(function() { diff --git a/classyage_1_1Vector2.html b/classyage_1_1Vector2.html index 4badb603..7d3ee386 100644 --- a/classyage_1_1Vector2.html +++ b/classyage_1_1Vector2.html @@ -89,7 +89,7 @@ class yage::Vector2< Type > diff --git a/collider_8hpp_source.html b/collider_8hpp_source.html index d10aa378..820b0712 100644 --- a/collider_8hpp_source.html +++ b/collider_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
collider.hpp
-
1 /* ----------------------------------------------------------------------------
2  * collider.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_COLLIDER_HPP
10 #define YAGE_COLLIDER_HPP
11 
12 #include <glm/glm.hpp>
13 
14 namespace yage
15 {
16 
17 // The Collider class helps collision detection by providing a general shape
18 // for different shapes to have their own collision algorithms.
19 class Collider
20 {
21 protected:
22  // position of the object
23  glm::vec2 position_;
24 
25  // size of the object
26  glm::vec2 size_;
27 
28 public:
29  Collider(const glm::vec2 &position, const glm::vec2 &size) : position_(position), size_(size) {}
30 
31  // virtual deconstructor for classes that inherits
32  virtual ~Collider() {}
33 
34  // function that checks if two colliders are colliding
35  virtual bool collides(const Collider &collider) const=0;
36 
37  // function that returns if a point is inside the shape
38  virtual bool inside(const glm::vec2 &point) const=0;
39 };
40 
41 } // yage
42 
43 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * collider.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_PHYSICS_COLLIDER_HPP
10 #define YAGE_PHYSICS_COLLIDER_HPP
11 
12 #include <glm/glm.hpp>
13 
14 namespace yage {
15 
16 // The Collider class helps collision detection by providing a general shape
17 // for different shapes to have their own collision algorithms.
18 class Collider {
19 protected:
20  // position of the object
21  glm::vec2 position_;
22 
23  // size of the object
24  glm::vec2 size_;
25 
26 public:
27  Collider(const glm::vec2& position, const glm::vec2& size)
28  : position_(position), size_(size) {}
29 
30  // function that checks if two colliders are colliding
31  virtual bool collides(const Collider& collider) const = 0;
32 
33  // function that returns if a point is inside the shape
34  virtual bool inside(const glm::vec2& point) const = 0;
35 };
36 
37 } // namespace yage
38 
39 #endif
Definition: camera2d.hpp:17
diff --git a/collisionbody_8hpp_source.html b/collisionbody_8hpp_source.html index 0cf53366..3e88cc8c 100644 --- a/collisionbody_8hpp_source.html +++ b/collisionbody_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
collisionbody.hpp
-
1 /* ----------------------------------------------------------------------------
2  * collisionbody.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_COLLISION_BODY_HPP
10 #define YAGE_COLLISION_BODY_HPP
11 
12 #include "Physics/body.hpp"
13 
14 namespace yage
15 {
16 
17 // a collision body will be a body that is static and not affected by gravity,
18 // with infinite mass
19 class CollisionBody : public Body
20 {
21 public:
22  CollisionBody();
23  virtual ~CollisionBody();
24 };
25 
26 } // yage
27 
28 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * collisionbody.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_COLLISION_BODY_HPP
10 #define YAGE_COLLISION_BODY_HPP
11 
12 #include "Physics/body.hpp"
13 
14 namespace yage {
15 
16 // a collision body will be a body that is static and not affected by gravity,
17 // with infinite mass
18 class CollisionBody : public Body {
19 public:
20  CollisionBody();
21  virtual ~CollisionBody();
22 };
23 
24 } // yage
25 
26 #endif
Definition: camera2d.hpp:17
diff --git a/dir_5ac3a90c14a160db9539610948ce4998.html b/dir_5ac3a90c14a160db9539610948ce4998.html index a0d8926f..987b240f 100644 --- a/dir_5ac3a90c14a160db9539610948ce4998.html +++ b/dir_5ac3a90c14a160db9539610948ce4998.html @@ -78,7 +78,7 @@ Files
diff --git a/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 65219ecb..97a9095d 100644 --- a/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -71,7 +71,7 @@ $(function() { diff --git a/dir_b233a2caca2b45d5ef987dbbf49782d0.html b/dir_b233a2caca2b45d5ef987dbbf49782d0.html index 6bd4ef22..46b92c98 100644 --- a/dir_b233a2caca2b45d5ef987dbbf49782d0.html +++ b/dir_b233a2caca2b45d5ef987dbbf49782d0.html @@ -71,7 +71,7 @@ $(function() { diff --git a/dir_d44c64559bbebec7f509842c48db8b23.html b/dir_d44c64559bbebec7f509842c48db8b23.html index 4c90c16d..ccf292aa 100644 --- a/dir_d44c64559bbebec7f509842c48db8b23.html +++ b/dir_d44c64559bbebec7f509842c48db8b23.html @@ -75,7 +75,7 @@ Directories diff --git a/dir_f562165b51c585c003877be645f219b5.html b/dir_f562165b51c585c003877be645f219b5.html index 36b0fb5c..f2b23a5c 100644 --- a/dir_f562165b51c585c003877be645f219b5.html +++ b/dir_f562165b51c585c003877be645f219b5.html @@ -75,7 +75,7 @@ Directories diff --git a/files.html b/files.html index 6db64c5c..37ef7441 100644 --- a/files.html +++ b/files.html @@ -98,7 +98,7 @@ $(function() { diff --git a/functions.html b/functions.html index d247837c..53093eb2 100644 --- a/functions.html +++ b/functions.html @@ -80,7 +80,7 @@ $(function() { diff --git a/functions_func.html b/functions_func.html index 6d8a46c7..f4986c3a 100644 --- a/functions_func.html +++ b/functions_func.html @@ -77,7 +77,7 @@ $(function() { diff --git a/functions_vars.html b/functions_vars.html index c00f4a49..320cc8aa 100644 --- a/functions_vars.html +++ b/functions_vars.html @@ -68,7 +68,7 @@ $(function() { diff --git a/glslprogram_8hpp_source.html b/glslprogram_8hpp_source.html index efad4f0d..31168026 100644 --- a/glslprogram_8hpp_source.html +++ b/glslprogram_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
glslprogram.hpp
-
1 /* ----------------------------------------------------------------------------
2  * glslprogram.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 GLSL_PROGRAM_HPP
10 #define GLSL_PROGRAM_HPP
11 
12 #include <GL/glew.h>
13 
14 #include <string>
15 
16 namespace yage
17 {
18 
19 class GlslProgram
20 {
21 private:
22  // compiled shader program id
23  GLuint program_id_ = 0;
24  GLuint vertex_shader_id_ = 0;
25  GLuint fragment_shader_id_ = 0;
26  int attribute_index_ = 0;
27 
28  // compiles one shader
29  void compileShader(const GLuint &shader, const std::string &file_path);
30 public:
31  GlslProgram();
32  ~GlslProgram();
33 
34  // compiles vertex and fragment shader
35  void compileShaders(const std::string &vertex_shader_path, const std::string &fragment_shader_path);
36  void linkShaders();
37  void addAttribute(const std::string &attribute_name);
38  GLint getUniformLocation(const std::string &uniform_name);
39  void use();
40  void unuse();
41 };
42 
43 } // yage
44 
45 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * glslprogram.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 GLSL_PROGRAM_HPP
10 #define GLSL_PROGRAM_HPP
11 
12 #include <GL/glew.h>
13 
14 #include <string>
15 
16 namespace yage {
17 
18 class GlslProgram {
19 private:
21  GLuint program_id_ = 0;
22  GLuint vertex_shader_id_ = 0;
23  GLuint fragment_shader_id_ = 0;
24  int attribute_index_ = 0;
25 
27  void compileShader(const GLuint& shader, const std::string& file_path);
28 
29 public:
30  GlslProgram() = default;
31  GlslProgram(const GlslProgram&) = delete;
32  GlslProgram(GlslProgram&&) = delete;
33  ~GlslProgram();
34 
35  GlslProgram& operator=(const GlslProgram&) = delete;
36  GlslProgram& operator=(GlslProgram&&) = delete;
37 
39  void compileShaders(const std::string& vertex_shader_path,
40  const std::string& fragment_shader_path);
41  void linkShaders();
42  void addAttribute(const std::string& attribute_name);
43  GLint getUniformLocation(const std::string& uniform_name);
44  void use();
45  void unuse();
46 };
47 
48 } // yage
49 
50 #endif
Definition: camera2d.hpp:17
diff --git a/group__getters.html b/group__getters.html new file mode 100644 index 00000000..48c1fd13 --- /dev/null +++ b/group__getters.html @@ -0,0 +1,76 @@ + + + + + + + +YAGE: Getters + + + + + + + + + +
+
+ + + + + + +
+
YAGE +  0.02 +
+
Yet Another Game Engine
+
+
+ + + + + + + +
+ +
+
+ + +
+ +
+ +
+
+
Getters
+
+
+

Detailed Description

+
+ + + + diff --git a/hierarchy.html b/hierarchy.html index b60429b2..923a0087 100644 --- a/hierarchy.html +++ b/hierarchy.html @@ -66,17 +66,18 @@ $(function() {
This inheritance list is sorted roughly, but not completely, alphabetically:
- - - - - + + + + + +
 Cyage::Matrix< Rows, Cols, Type >Base Matrix class used by other similar classes
 Cyage::Matrix< Rows, 1, double >
 Cyage::Matrix< Rows, 1, Type >
 Cyage::Vector2< Type >2D Vector class
 Cyage::Vector2< double >
 Cyage::GlyphGlyph with information of the texture
 Cyage::Matrix< Rows, Cols, Type >Base Matrix class used by other similar classes
 Cyage::Matrix< Rows, 1, double >
 Cyage::Matrix< Rows, 1, Type >
 Cyage::Vector2< Type >2D Vector class
 Cyage::Vector2< double >
diff --git a/imageloader_8hpp_source.html b/imageloader_8hpp_source.html index 2a8a47a7..6c0cbedd 100644 --- a/imageloader_8hpp_source.html +++ b/imageloader_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
imageloader.hpp
-
1 /* ----------------------------------------------------------------------------
2  * imageloader.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 IMAGE_LOADER_HPP
10 #define IMAGE_LOADER_HPP
11 
12 #include "texture.hpp"
13 
14 #include <string>
15 
16 namespace yage
17 {
18 
19 class ImageLoader
20 {
21 public:
22  static Texture loadPng(const std::string &file_path);
23 };
24 
25 } // yage
26 
27 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * imageloader.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 IMAGE_LOADER_HPP
10 #define IMAGE_LOADER_HPP
11 
12 #include "texture.hpp"
13 
14 #include <string>
15 
16 namespace yage {
17 
18 class ImageLoader {
19 public:
20  static Texture loadPng(const std::string& file_path);
21 };
22 
23 } // yage
24 
25 #endif
Definition: camera2d.hpp:17
diff --git a/index.html b/index.html index 1b4257c8..49764fc2 100644 --- a/index.html +++ b/index.html @@ -67,7 +67,7 @@ $(function() {
diff --git a/inputmanager_8hpp_source.html b/inputmanager_8hpp_source.html index 7c08b79a..81f36ced 100644 --- a/inputmanager_8hpp_source.html +++ b/inputmanager_8hpp_source.html @@ -72,7 +72,7 @@ $(function() { diff --git a/iomanager_8hpp_source.html b/iomanager_8hpp_source.html index 7e87d3cd..ac1cfb8d 100644 --- a/iomanager_8hpp_source.html +++ b/iomanager_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
iomanager.hpp
-
1 /* ----------------------------------------------------------------------------
2  * iomanager.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 IO_MANAGER_HPP
10 #define IO_MANAGER_HPP
11 
12 #include <string>
13 #include <vector>
14 
15 namespace yage
16 {
17 
18 class IoManager
19 {
20 public:
21  static bool readFileToBuffer(const std::string &file_path, std::vector<unsigned char> &buffer);
22 };
23 
24 } // yage
25 
26 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * iomanager.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 IO_MANAGER_HPP
10 #define IO_MANAGER_HPP
11 
12 #include <string>
13 #include <vector>
14 
15 namespace yage {
16 
17 class IoManager {
18 public:
19  static bool readFileToBuffer(const std::string &file_path,
20  std::vector<unsigned char> &buffer);
21 };
22 
23 } // yage
24 
25 #endif
Definition: camera2d.hpp:17
diff --git a/math_8hpp_source.html b/math_8hpp_source.html index d0365783..6cf8a9d0 100644 --- a/math_8hpp_source.html +++ b/math_8hpp_source.html @@ -72,7 +72,7 @@ $(function() {
diff --git a/matrix_8hpp.html b/matrix_8hpp.html index ab72864e..a69866e8 100644 --- a/matrix_8hpp.html +++ b/matrix_8hpp.html @@ -132,7 +132,7 @@ Functions diff --git a/matrix_8hpp_source.html b/matrix_8hpp_source.html index 03a28e8a..26233d2f 100644 --- a/matrix_8hpp_source.html +++ b/matrix_8hpp_source.html @@ -68,20 +68,20 @@ $(function() {
matrix.hpp
-Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * matrix.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 
21 #ifndef YAGE_MATH_MATRIX_HPP
22 #define YAGE_MATH_MATRIX_HPP
23 
24 #include <algorithm>
25 #include <exception>
26 #include <iostream>
27 #include <sstream>
28 #include <string>
29 #include <vector>
30 
31 
32 namespace yage
33 {
34 
35 template<int Rows, int Cols, class Type> class Matrix;
36 
44 namespace detail
45 {
46 
55 template<int Rows, int Cols, class Type> class Row
56 {
57 private:
58  Matrix<Rows, Cols, Type> *parent_;
59  int index_;
60 
61 public:
62  Row<Rows, Cols, Type>(Matrix<Rows, Cols, Type> *parent, int index) :
63  parent_(parent), index_(index)
64  {}
65 
66  Type& operator[](int col)
67  {
68  // the index is the y-position of the element in the matrix
69  return parent_->data_[index_*Cols+col];
70  }
71 
72  const Type& operator[](int col) const
73  {
74  return parent_->data_[index_*Cols+col];
75  }
76 };
77 
78 } // detail
79 
88 template<int Rows=4, int Cols=4, class Type=double> class Matrix
89 {
90  // friended with the row class so that it can access protected member data
91  friend class detail::Row<Rows, Cols, Type>;
92 protected:
94  std::vector<Type> data_;
95 
96 public:
98  Matrix<Rows, Cols, Type>() : data_(Rows*Cols) {}
99 
101  int rowSize() const
102  {
103  return Rows;
104  }
105 
107  int colSize() const
108  {
109  return Cols;
110  }
111 
119  {
120  Matrix<1, Cols, Type> rowMatrix;
121  for(int i=0; i<Cols; ++i)
122  {
123  rowMatrix[0][i]=data_[row][i];
124  }
125  return rowMatrix;
126  }
127 
128  // returns the column in a column matrix
129  Matrix<Rows, 1, Type> getCol(int col) const
130  {
131  Matrix<Rows, 1, Type> colMatrix;
132  for(int i=0; i<Rows; ++i)
133  {
134  colMatrix[i][0]=data_[i][col];
135  }
136  return colMatrix;
137  }
138 
139  // iterator support for begin
140  typename std::vector<Type>::iterator begin()
141  {
142  return data_.begin();
143  }
144 
145  // iterator support for end
146  typename std::vector<Type>::iterator end()
147  {
148  return data_.end();
149  }
150 
151  // prints out the matrix, but can also be implemented by other classes to print data
152  // differently
153  virtual std::string toString() const
154  {
155  std::stringstream ss;
156  ss<<'[';
157  for(int i=0; i<Rows-1; ++i)
158  {
159  ss<<'[';
160  for(int j=0; j<Cols-1; ++j)
161  {
162  ss<<data_[i*Cols+j]<<' ';
163  }
164  ss<<data_[(Rows-1)*Cols+Cols-1]<<"],";
165  }
166  ss<<'[';
167  for(int j=0; j<Cols-1; ++j)
168  {
169  ss<<data_[(Rows-1)*Cols+j]<<' ';
170  }
171  ss<<data_[(Rows-1)*Cols+Cols-1]<<"]]";
172  return ss.str();
173  }
174 
175  detail::Row<Rows, Cols, Type> operator[](int row)
176  {
177  return detail::Row<Rows, Cols, Type>(this, row);
178  }
179 
180  detail::Row<Rows, Cols, Type> operator[](int row) const
181  {
182  // TODO got to fix this
183  return detail::Row<Rows, Cols, Type>((Matrix<Rows, Cols, Type>*)this, row);
184  }
185 
186  Matrix<Rows, Cols, Type>& operator=(const Matrix<Rows, Cols, Type> &other)
187  {
188  if(this!=&other)
189  {
190  data_=other.data_;
191  }
192  return *this;
193  }
194 
195  Matrix<Rows, Cols, Type>& operator+=(const Matrix<Rows, Cols, Type> &rhs)
196  {
197  std::vector<Type> out;
198  out.reserve(data_.size());
199  std::transform(data_.begin(), data_.end(), rhs.data_.begin(), std::back_inserter(out),
200  [] (Type a, Type b) {
201  return a+b;
202  });
203  data_=std::move(out);
204  return *this;
205  }
206 
207  Matrix<Rows, Cols, Type>& operator-=(const Matrix<Rows, Cols, Type> &rhs)
208  {
209  std::vector<Type> out;
210  out.reserve(data_.size());
211  std::transform(data_.begin(), data_.end(), rhs.begin(), std::back_inserter(out),
212  [] (Type a, Type b) {
213  return a-b;
214  });
215  data_=std::move(out);
216  return *this;
217  }
218 };
219 
220 template<int M, int N, class T>
221 Matrix<M, N, T> operator+(Matrix<M, N, T> lhs, const Matrix<M, N, T> &rhs)
222 {
223  lhs+=rhs;
224  return lhs;
225 }
226 
227 template<int M, int N, class T>
228 Matrix<M, N, T> operator-(Matrix<M, N, T> lhs, const Matrix<M, N, T> &rhs)
229 {
230  lhs-=rhs;
231  return lhs;
232 }
233 
234 template<int M, int N, class T>
235 Matrix<M, N, T> operator+(Matrix<M, N, T> lhs, const T &rhs)
236 {
237  for(auto &data : lhs)
238  {
239  data+=rhs;
240  }
241  return lhs;
242 }
243 
244 template<int M, int N, class T>
245 Matrix<M, N, T> operator+(const T &lhs, Matrix<M, N, T> rhs)
246 {
247  for(auto &data : rhs)
248  {
249  data+=lhs;
250  }
251  return rhs;
252 }
253 
254 template<int M, int N, class T>
255 Matrix<M, N, T> operator-(Matrix<M, N, T> lhs, const T &rhs)
256 {
257  for(auto &data : lhs)
258  {
259  data-=rhs;
260  }
261  return lhs;
262 }
263 
264 template<int M, int N, class T>
265 Matrix<M, N, T> operator-(const T &lhs, Matrix<M, N, T> rhs)
266 {
267  for(auto &data : rhs)
268  {
269  data=lhs-data;
270  }
271  return rhs;
272 }
273 
274 template<int M, int N, class T>
275 Matrix<M, N, T> operator*(Matrix<M, N, T> lhs, const T &rhs)
276 {
277  for(auto &data : lhs)
278  {
279  data*=rhs;
280  }
281  return lhs;
282 }
283 
284 template<int M, int N, class T>
285 Matrix<M, N, T> operator*(const T &lhs, Matrix<M, N, T> rhs)
286 {
287  for(auto &data : rhs)
288  {
289  data*=lhs;
290  }
291  return rhs;
292 }
293 
294 template<int M, int N, class T>
295 Matrix<M, N, T> operator/(Matrix<M, N, T> lhs, const T &rhs)
296 {
297  for(auto &data : lhs)
298  {
299  data/=rhs;
300  }
301  return lhs;
302 }
303 
304 template<int M, int N, class T>
305 bool operator==(const Matrix<M, N, T> &lhs, const Matrix<M, N, T> &rhs)
306 {
307  for(int i=0; i<M; ++i)
308  for(int j=0; j<N; ++j)
309  if(lhs[i][j]!=rhs[i][j])
310  return false;
311  return true;
312 }
313 
314 template<int M, int N, class T>
315 std::ostream& operator<<(std::ostream &os, const Matrix<M, N, T> &mat)
316 {
317  return os<<mat.toString();
318 }
319 
320 template<int Rows=2, class Type=double> class Vector : public Matrix<Rows, 1, Type>
321 {
322 public:
323  Vector<Rows, Type>() : Matrix<Rows, 1, Type>() {}
324  explicit Vector<Rows, Type>(const Matrix<Rows, 1, Type> &other) : Matrix<Rows, 1, Type>(other) {}
325 
326  Type& operator[](int col)
327  {
328  return this->data_[col];
329  }
330 
331  const Type& operator[](int col) const
332  {
333  return this->data_[col];
334  }
335 
336  virtual std::string toString() const
337  {
338  std::stringstream ss;
339  ss<<"[";
340  for(std::size_t i=0; i<this->data_.size()-1; ++i)
341  {
342  ss<<this->data_[i]<<" ";
343  }
344  ss<<this->data_[this->data_.size()-1]<<"]";
345  return ss.str();
346  }
347 };
348 
353 template<class Type=double> class Vector2 : public Vector<2, Type>
354 {
355 public:
356  Vector2<Type>() : Vector<2, Type>() {}
357 
358  Vector2<Type>(Type x, Type y)
359  {
360  this->data_[0]=x;
361  this->data_[1]=y;
362  }
363 
364  Vector2<Type>(const Matrix<2, 1, Type> &other) : Vector<2, Type>(other) {}
365 
366  Type& x()
367  {
368  return this->data_[0];
369  }
370 
371  const Type& x() const
372  {
373  return this->data_[0];
374  }
375 
376  Type& y()
377  {
378  return this->data_[1];
379  }
380 
381  const Type& y() const
382  {
383  return this->data_[1];
384  }
385 };
386 
389 
391 namespace matrix
392 {
393 
398 template<int M, int N, class T> Matrix<N, M, T> transpose(const Matrix<M, N, T> &m)
399 {
400  Matrix<N, M, T> trans;
401  for(int i=0; i<M; ++i)
402  {
403  for(int j=0; j<N; ++j)
404  {
405  trans[j][i]=m[i][j];
406  }
407  }
408  return trans;
409 }
410 
415 template<int R, class T> T dot(const Matrix<R, 1, T> &m1, const Matrix<R, 1, T> &m2)
416 {
417  T sum=0;
418  for(int i=0; i<R; ++i)
419  {
420  sum += m1[i][0]*m2[i][0];
421  }
422  return sum;
423 }
424 
431 template<int M, int N, int P, int Q, class T>
433 {
434  if(N!=P)
435  {
436  throw std::runtime_error("Matrices don't have the right dimensions for multiplication");
437  }
438 
439  Matrix<M, Q, T> res;
440 
441  for(int i=0; i<M; ++i)
442  {
443  for(int j=0; j<Q; ++j)
444  {
445  res[i][j] = dot(transpose(m1.getRow(i)), m2.getCol(j));
446  }
447  }
448 
449  return res;
450 }
451 
452 } // matrix
453 
454 } // yage
455 
456 #endif
int rowSize() const
Returns the row size of the Matrix.
Definition: matrix.hpp:101
-
int colSize() const
Returns the column size of the Matrixxs.
Definition: matrix.hpp:107
-
2D Vector class.
Definition: matrix.hpp:353
-
std::vector< Type > data_
Vector containing the data of the matrix.
Definition: matrix.hpp:94
-
Matrix< M, Q, T > multiply(const Matrix< M, N, T > &m1, const Matrix< P, Q, T > &m2)
Multiplies two matrices together.
Definition: matrix.hpp:432
-
Matrix< N, M, T > transpose(const Matrix< M, N, T > &m)
Transposes a matrix and returns the result.
Definition: matrix.hpp:398
-
Base Matrix class used by other similar classes.
Definition: matrix.hpp:35
-
T dot(const Matrix< R, 1, T > &m1, const Matrix< R, 1, T > &m2)
Returns the dot product between two vectors.
Definition: matrix.hpp:415
-
Matrix< 1, Cols, Type > getRow(int row) const
Return the row specified row as a Matrix with only one row.
Definition: matrix.hpp:118
+Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * matrix.hpp
3  *
4  * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License
5  * See file LICENSE for more details
6  * ----------------------------------------------------------------------------
7  */
8 
19 #ifndef YAGE_MATH_MATRIX_HPP
20 #define YAGE_MATH_MATRIX_HPP
21 
22 #include <algorithm>
23 #include <exception>
24 #include <iostream>
25 #include <sstream>
26 #include <string>
27 #include <vector>
28 
29 namespace yage {
30 
31 template <int Rows, int Cols, class Type>
32 class Matrix;
33 
41 namespace detail {
42 
51 template <int Rows, int Cols, class Type>
52 class Row {
53 private:
54  Matrix<Rows, Cols, Type>* parent_;
55  int index_;
56 
57 public:
58  Row<Rows, Cols, Type>(Matrix<Rows, Cols, Type>* parent, int index)
59  : parent_(parent), index_(index) {}
60 
61  Type& operator[](int col) {
62  // the index is the y-position of the element in the matrix
63  return parent_->data_[index_ * Cols + col];
64  }
65 
66  const Type& operator[](int col) const {
67  return parent_->data_[index_ * Cols + col];
68  }
69 };
70 
71 } // detail
72 
81 template <int Rows = 4, int Cols = 4, class Type = double>
82 class Matrix {
83  // friended with the row class so that it can access protected member data
84  friend class detail::Row<Rows, Cols, Type>;
85 
86 protected:
88  std::vector<Type> data_;
89 
90 public:
92  Matrix<Rows, Cols, Type>() : data_(Rows * Cols) {}
93  Matrix<Rows, Cols, Type>(const std::vector<Type>& data) : data_(data) {}
94 
96  int rowSize() const { return Rows; }
97 
99  int colSize() const { return Cols; }
100 
107  Matrix<1, Cols, Type> getRow(int row) const {
108  Matrix<1, Cols, Type> rowMatrix;
109  for (int i = 0; i < Cols; ++i) {
110  rowMatrix[0][i] = data_[row][i];
111  }
112  return rowMatrix;
113  }
114 
115  // returns the column in a column matrix
116  Matrix<Rows, 1, Type> getCol(int col) const {
117  Matrix<Rows, 1, Type> colMatrix;
118  for (int i = 0; i < Rows; ++i) {
119  colMatrix[i][0] = data_[i][col];
120  }
121  return colMatrix;
122  }
123 
124  // iterator support for begin
125  typename std::vector<Type>::iterator begin() { return data_.begin(); }
126 
127  // iterator support for end
128  typename std::vector<Type>::iterator end() { return data_.end(); }
129 
130  // prints out the matrix, but can also be implemented by other classes to
131  // print data differently
132  virtual std::string toString() const {
133  std::stringstream ss;
134  ss << '[';
135  for (int i = 0; i < Rows - 1; ++i) {
136  ss << '[';
137  for (int j = 0; j < Cols - 1; ++j) {
138  ss << data_[i * Cols + j] << ' ';
139  }
140  ss << data_[(Rows - 1) * Cols + Cols - 1] << "],";
141  }
142  ss << '[';
143  for (int j = 0; j < Cols - 1; ++j) {
144  ss << data_[(Rows - 1) * Cols + j] << ' ';
145  }
146  ss << data_[(Rows - 1) * Cols + Cols - 1] << "]]";
147  return ss.str();
148  }
149 
150  detail::Row<Rows, Cols, Type> operator[](int row) {
151  return detail::Row<Rows, Cols, Type>(this, row);
152  }
153 
154  detail::Row<Rows, Cols, Type> operator[](int row) const {
155  // TODO got to fix this
156  return detail::Row<Rows, Cols, Type>((Matrix<Rows, Cols, Type>*)this,
157  row);
158  }
159 
160  Matrix<Rows, Cols, Type>& operator+=(const Matrix<Rows, Cols, Type>& rhs) {
161  std::vector<Type> out;
162  out.reserve(data_.size());
163  std::transform(data_.begin(), data_.end(), rhs.data_.begin(),
164  std::back_inserter(out),
165  [](Type a, Type b) { return a + b; });
166  data_ = std::move(out);
167  return *this;
168  }
169 
170  Matrix<Rows, Cols, Type>& operator-=(const Matrix<Rows, Cols, Type>& rhs) {
171  std::vector<Type> out;
172  out.reserve(data_.size());
173  std::transform(data_.begin(), data_.end(), rhs.begin(),
174  std::back_inserter(out),
175  [](Type a, Type b) { return a - b; });
176  data_ = std::move(out);
177  return *this;
178  }
179 };
180 
181 template <int M, int N, class T>
182 Matrix<M, N, T> operator+(Matrix<M, N, T> lhs, const Matrix<M, N, T>& rhs) {
183  lhs += rhs;
184  return lhs;
185 }
186 
187 template <int M, int N, class T>
188 Matrix<M, N, T> operator-(Matrix<M, N, T> lhs, const Matrix<M, N, T>& rhs) {
189  lhs -= rhs;
190  return lhs;
191 }
192 
193 template <int M, int N, class T>
194 Matrix<M, N, T> operator+(Matrix<M, N, T> lhs, const T& rhs) {
195  for (auto& data : lhs) {
196  data += rhs;
197  }
198  return lhs;
199 }
200 
201 template <int M, int N, class T>
202 Matrix<M, N, T> operator+(const T& lhs, Matrix<M, N, T> rhs) {
203  for (auto& data : rhs) {
204  data += lhs;
205  }
206  return rhs;
207 }
208 
209 template <int M, int N, class T>
210 Matrix<M, N, T> operator-(Matrix<M, N, T> lhs, const T& rhs) {
211  for (auto& data : lhs) {
212  data -= rhs;
213  }
214  return lhs;
215 }
216 
217 template <int M, int N, class T>
218 Matrix<M, N, T> operator-(const T& lhs, Matrix<M, N, T> rhs) {
219  for (auto& data : rhs) {
220  data = lhs - data;
221  }
222  return rhs;
223 }
224 
225 template <int M, int N, class T>
226 Matrix<M, N, T> operator*(Matrix<M, N, T> lhs, const T& rhs) {
227  for (auto& data : lhs) {
228  data *= rhs;
229  }
230  return lhs;
231 }
232 
233 template <int M, int N, class T>
234 Matrix<M, N, T> operator*(const T& lhs, Matrix<M, N, T> rhs) {
235  for (auto& data : rhs) {
236  data *= lhs;
237  }
238  return rhs;
239 }
240 
241 template <int M, int N, class T>
242 Matrix<M, N, T> operator/(Matrix<M, N, T> lhs, const T& rhs) {
243  for (auto& data : lhs) {
244  data /= rhs;
245  }
246  return lhs;
247 }
248 
249 template <int M, int N, class T>
250 bool operator==(const Matrix<M, N, T>& lhs, const Matrix<M, N, T>& rhs) {
251  for (int i = 0; i < M; ++i)
252  for (int j = 0; j < N; ++j)
253  if (lhs[i][j] != rhs[i][j]) return false;
254  return true;
255 }
256 
257 template <int M, int N, class T>
258 std::ostream& operator<<(std::ostream& os, const Matrix<M, N, T>& mat) {
259  return os << mat.toString();
260 }
261 
262 template <int Rows = 2, class Type = double>
263 class Vector : public Matrix<Rows, 1, Type> {
264 public:
265  Vector<Rows, Type>() : Matrix<Rows, 1, Type>() {}
266  Vector<Rows, Type>(const Matrix<Rows, 1, Type>& other)
267  : Matrix<Rows, 1, Type>(other) {}
268  Vector<Rows, Type>(const std::vector<Type>& data)
269  : Matrix<Rows, 1, Type>(data) {}
270 
271  Type& operator[](int col) { return this->data_[col]; }
272 
273  const Type& operator[](int col) const { return this->data_[col]; }
274 
275  virtual std::string toString() const {
276  std::stringstream ss;
277  ss << "[";
278  for (std::size_t i = 0; i < this->data_.size() - 1; ++i) {
279  ss << this->data_[i] << " ";
280  }
281  ss << this->data_[this->data_.size() - 1] << "]";
282  return ss.str();
283  }
284 };
285 
290 template <class Type = double>
291 class Vector2 : public Vector<2, Type> {
292 public:
293  Vector2<Type>() : Vector<2, Type>() {}
294  Vector2<Type>(const std::vector<Type>& data) : Vector<2, Type>(data) {}
295 
296  Vector2<Type>(Type x, Type y) {
297  this->data_[0] = x;
298  this->data_[1] = y;
299  }
300 
301  Vector2<Type>(const Matrix<2, 1, Type>& other) : Vector<2, Type>(other) {}
302 
303  Type& x() { return this->data_[0]; }
304 
305  const Type& x() const { return this->data_[0]; }
306 
307  Type& y() { return this->data_[1]; }
308 
309  const Type& y() const { return this->data_[1]; }
310 };
311 
314 
316 namespace matrix {
317 
322 template <int M, int N, class T>
324  Matrix<N, M, T> trans;
325  for (int i = 0; i < M; ++i) {
326  for (int j = 0; j < N; ++j) {
327  trans[j][i] = m[i][j];
328  }
329  }
330  return trans;
331 }
332 
337 template <int R, class T>
338 T dot(const Matrix<R, 1, T>& m1, const Matrix<R, 1, T>& m2) {
339  T sum = 0;
340  for (int i = 0; i < R; ++i) {
341  sum += m1[i][0] * m2[i][0];
342  }
343  return sum;
344 }
345 
352 template <int M, int N, int P, int Q, class T>
354  if (N != P) {
355  throw std::runtime_error(
356  "Matrices don't have the right dimensions for multiplication");
357  }
358 
359  Matrix<M, Q, T> res;
360 
361  for (int i = 0; i < M; ++i) {
362  for (int j = 0; j < Q; ++j) {
363  res[i][j] = dot(transpose(m1.getRow(i)), m2.getCol(j));
364  }
365  }
366 
367  return res;
368 }
369 
370 } // matrix
371 
372 } // yage
373 
374 #endif
int rowSize() const
Returns the row size of the Matrix.
Definition: matrix.hpp:96
+
int colSize() const
Returns the column size of the Matrixxs.
Definition: matrix.hpp:99
+
2D Vector class.
Definition: matrix.hpp:291
+
std::vector< Type > data_
Vector containing the data of the matrix.
Definition: matrix.hpp:88
+
Matrix< M, Q, T > multiply(const Matrix< M, N, T > &m1, const Matrix< P, Q, T > &m2)
Multiplies two matrices together.
Definition: matrix.hpp:353
+
Matrix< N, M, T > transpose(const Matrix< M, N, T > &m)
Transposes a matrix and returns the result.
Definition: matrix.hpp:323
+
Base Matrix class used by other similar classes.
Definition: matrix.hpp:32
+
T dot(const Matrix< R, 1, T > &m1, const Matrix< R, 1, T > &m2)
Returns the dot product between two vectors.
Definition: matrix.hpp:338
+
Matrix< 1, Cols, Type > getRow(int row) const
Return the row specified row as a Matrix with only one row.
Definition: matrix.hpp:107
Definition: camera2d.hpp:17
diff --git a/md_README.html b/md_README.html index cc6fe145..5698ab71 100644 --- a/md_README.html +++ b/md_README.html @@ -66,11 +66,11 @@ $(function() {

YAGE stands for Yet Another Game Engine.

License

-

Copyright (c) 2017 Yann Herklotz Grave ymher.nosp@m.klot.nosp@m.z@gma.nosp@m.il.c.nosp@m.om – MIT License, see file LICENSE for more details.

+

Copyright (c) 2017 Yann Herklotz Grave ymher.nosp@m.klot.nosp@m.z@gma.nosp@m.il.c.nosp@m.om – MIT License, see file LICENSE for more details.

diff --git a/md_docs_README.html b/md_docs_README.html index 346b5846..7dbc805d 100644 --- a/md_docs_README.html +++ b/md_docs_README.html @@ -68,7 +68,7 @@ $(function() {
diff --git a/menudata.js b/menudata.js index bc91e661..81377f49 100644 --- a/menudata.js +++ b/menudata.js @@ -1,6 +1,7 @@ var menudata={children:[ {text:"Main Page",url:"index.html"}, {text:"Related Pages",url:"pages.html"}, +{text:"Modules",url:"modules.html"}, {text:"Namespaces",url:"namespaces.html",children:[ {text:"Namespace List",url:"namespaces.html"}, {text:"Namespace Members",url:"namespacemembers.html",children:[ diff --git a/modules.html b/modules.html new file mode 100644 index 00000000..3ef0e2db --- /dev/null +++ b/modules.html @@ -0,0 +1,80 @@ + + + + + + + +YAGE: Modules + + + + + + + + + +
+
+ + + + + + +
+
YAGE +  0.02 +
+
Yet Another Game Engine
+
+
+ + + + + + + +
+ +
+
+ + +
+ +
+ +
+
+
Modules
+
+
+
Here is a list of all modules:
+ + +
 Getters
+
+
+ + + + diff --git a/namespacemembers.html b/namespacemembers.html index 4465c8c6..83ec0c77 100644 --- a/namespacemembers.html +++ b/namespacemembers.html @@ -74,7 +74,7 @@ $(function() { diff --git a/namespacemembers_func.html b/namespacemembers_func.html index 7c6413c6..d9a099d5 100644 --- a/namespacemembers_func.html +++ b/namespacemembers_func.html @@ -74,7 +74,7 @@ $(function() { diff --git a/namespaces.html b/namespaces.html index 12a3e6ab..4b92ebe7 100644 --- a/namespaces.html +++ b/namespaces.html @@ -73,7 +73,7 @@ $(function() { diff --git a/namespaceyage_1_1matrix.html b/namespaceyage_1_1matrix.html index 6bbb23d7..f7898859 100644 --- a/namespaceyage_1_1matrix.html +++ b/namespaceyage_1_1matrix.html @@ -200,7 +200,7 @@ template<int M, int N, class T > diff --git a/pages.html b/pages.html index 0d8da675..e24c0eaf 100644 --- a/pages.html +++ b/pages.html @@ -73,7 +73,7 @@ $(function() { diff --git a/particlebody_8hpp_source.html b/particlebody_8hpp_source.html index 60ed0061..43b55b36 100644 --- a/particlebody_8hpp_source.html +++ b/particlebody_8hpp_source.html @@ -68,13 +68,13 @@ $(function() {
particlebody.hpp
-
1 /* ----------------------------------------------------------------------------
2  * particlebody.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_PARTICLE_BODY_HPP
10 #define YAGE_PARTICLE_BODY_HPP
11 
12 #include "Math/matrix.hpp"
13 
14 #include "body.hpp"
15 
16 namespace yage
17 {
18 
19 class ParticleBody : public Body
20 {
21 public:
22  ParticleBody(const Vector2d &position=Vector2d(0, 0),
23  double mass=1,
24  const Vector2d &velocity=Vector2d(0, 0),
25  bool gravity=true);
26 
27  // apply a force to the rigid body
28  virtual void applyForce(const Vector2d &force);
29  virtual void update();
30 };
31 
32 } // yage
33 
34 #endif
Templated matrix class.
-
Vector2< double > Vector2d
Definition of a 2D vector.
Definition: matrix.hpp:388
+
1 /* ----------------------------------------------------------------------------
2  * particlebody.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_PARTICLE_BODY_HPP
10 #define YAGE_PARTICLE_BODY_HPP
11 
12 #include "Math/matrix.hpp"
13 
14 #include "body.hpp"
15 
16 namespace yage {
17 
18 class ParticleBody : public Body {
19 public:
20  ParticleBody(const Vector2d& position = Vector2d(0, 0), double mass = 1,
21  const Vector2d& velocity = Vector2d(0, 0),
22  bool gravity = true);
23 
24  // apply a force to the rigid body
25  virtual void applyForce(const Vector2d& force);
26  virtual void update();
27 };
28 
29 } // yage
30 
31 #endif
Templated matrix class.
+
Vector2< double > Vector2d
Definition of a 2D vector.
Definition: matrix.hpp:313
Definition: camera2d.hpp:17
diff --git a/physics_8hpp_source.html b/physics_8hpp_source.html index 38aefb82..1bb17110 100644 --- a/physics_8hpp_source.html +++ b/physics_8hpp_source.html @@ -71,7 +71,7 @@ $(function() {
1 /* ----------------------------------------------------------------------------
2  * physics.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_PHYSICS_HPP
10 #define YAGE_PHYSICS_HPP
11 
12 #include "body.hpp"
13 #include "collider.hpp"
14 #include "collisionbody.hpp"
15 #include "particlebody.hpp"
16 #include "rectanglecollider.hpp"
17 #include "rigidbody.hpp"
18 
19 #endif
diff --git a/picopng_8hpp_source.html b/picopng_8hpp_source.html index 08df6b61..5df913f1 100644 --- a/picopng_8hpp_source.html +++ b/picopng_8hpp_source.html @@ -72,7 +72,7 @@ $(function() { diff --git a/rectanglecollider_8hpp_source.html b/rectanglecollider_8hpp_source.html index f4720d2b..26aab10d 100644 --- a/rectanglecollider_8hpp_source.html +++ b/rectanglecollider_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
rectanglecollider.hpp
-
1 /* ----------------------------------------------------------------------------
2  * rectanglecollider.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_RECTANGLE_COLLIDER_HPP
10 #define YAGE_RECTANGLE_COLLIDER_HPP
11 
12 #include "Physics/collider.hpp"
13 
14 #include <glm/glm.hpp>
15 
16 namespace yage
17 {
18 
19 class RectangleCollider : public Collider
20 {
21 public:
22  RectangleCollider(const glm::vec2 &position, const glm::vec2 &size);
23 
24  virtual bool collides(const Collider &collider) const;
25  virtual bool inside(const glm::vec2 &point) const;
26 };
27 
28 } // yage
29 
30 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * rectanglecollider.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_RECTANGLE_COLLIDER_HPP
10 #define YAGE_RECTANGLE_COLLIDER_HPP
11 
12 #include "Physics/collider.hpp"
13 
14 #include <glm/glm.hpp>
15 
16 namespace yage {
17 
18 class RectangleCollider : public Collider {
19 public:
20  RectangleCollider(const glm::vec2& position, const glm::vec2& size);
21 
22  virtual bool collides(const Collider& collider) const;
23  virtual bool inside(const glm::vec2& point) const;
24 };
25 
26 } // yage
27 
28 #endif
Definition: camera2d.hpp:17
diff --git a/resourcemanager_8hpp_source.html b/resourcemanager_8hpp_source.html index 9efa7025..c7ba8148 100644 --- a/resourcemanager_8hpp_source.html +++ b/resourcemanager_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
resourcemanager.hpp
-
1 /* ----------------------------------------------------------------------------
2  * resourcemanager.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 RESOURCE_MANAGER_HPP
10 #define RESOURCE_MANAGER_HPP
11 
12 #include "texture.hpp"
13 #include "texturecache.hpp"
14 
15 #include <string>
16 
17 namespace yage
18 {
19 
20 class ResourceManager
21 {
22 private:
23  static TextureCache texture_cache_;
24 public:
25  static Texture getTexture(const std::string &texture_path);
26 };
27 
28 } // yage
29 
30 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * resourcemanager.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 RESOURCE_MANAGER_HPP
10 #define RESOURCE_MANAGER_HPP
11 
12 #include "texture.hpp"
13 #include "texturecache.hpp"
14 
15 #include <string>
16 
17 namespace yage {
18 
19 class ResourceManager {
20 private:
21  static TextureCache texture_cache_;
22 
23 public:
24  static Texture getTexture(const std::string& texture_path);
25 };
26 
27 } // yage
28 
29 #endif
Definition: camera2d.hpp:17
diff --git a/rigidbody_8hpp_source.html b/rigidbody_8hpp_source.html index 916950b1..baacb7a1 100644 --- a/rigidbody_8hpp_source.html +++ b/rigidbody_8hpp_source.html @@ -68,12 +68,12 @@ $(function() {
rigidbody.hpp
-
1 /* ----------------------------------------------------------------------------
2  * rigidbody.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_RIGID_BODY_HPP
10 #define YAGE_RIGID_BODY_HPP
11 
12 #include <glm/glm.hpp>
13 
14 #include "particlebody.hpp"
15 
16 namespace yage
17 {
18 
19 class RigidBody : public ParticleBody
20 {
21 public:
22  RigidBody(const Vector2d &position=Vector2d(0, 0),
23  double mass=1,
24  const Vector2d &velocity=Vector2d(0, 0),
25  bool gravity=true);
26 };
27 
28 } // yage
29 
30 #endif
Vector2< double > Vector2d
Definition of a 2D vector.
Definition: matrix.hpp:388
+
1 /* ----------------------------------------------------------------------------
2  * rigidbody.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_RIGID_BODY_HPP
10 #define YAGE_RIGID_BODY_HPP
11 
12 #include <glm/glm.hpp>
13 
14 #include "particlebody.hpp"
15 
16 namespace yage {
17 
18 class RigidBody : public ParticleBody {
19 public:
20  RigidBody(const Vector2d& position = Vector2d(0, 0), double mass = 1,
21  const Vector2d& velocity = Vector2d(0, 0), bool gravity = true);
22 };
23 
24 } // yage
25 
26 #endif
Vector2< double > Vector2d
Definition of a 2D vector.
Definition: matrix.hpp:313
Definition: camera2d.hpp:17
diff --git a/search/all_2.js b/search/all_2.js index 995953e1..30f36c7e 100644 --- a/search/all_2.js +++ b/search/all_2.js @@ -1,4 +1,6 @@ var searchData= [ - ['getrow',['getRow',['../classyage_1_1Matrix.html#adffb22a99417271958621ff1f51b7f08',1,'yage::Matrix']]] + ['getrow',['getRow',['../classyage_1_1Matrix.html#adffb22a99417271958621ff1f51b7f08',1,'yage::Matrix']]], + ['getters',['Getters',['../group__getters.html',1,'']]], + ['glyph',['Glyph',['../classyage_1_1Glyph.html',1,'yage']]] ]; diff --git a/search/classes_0.js b/search/classes_0.js index b3ac49ff..b5fe9ac1 100644 --- a/search/classes_0.js +++ b/search/classes_0.js @@ -1,6 +1,4 @@ var searchData= [ - ['matrix',['Matrix',['../classyage_1_1Matrix.html',1,'yage']]], - ['matrix_3c_20rows_2c_201_2c_20double_20_3e',['Matrix< Rows, 1, double >',['../classyage_1_1Matrix.html',1,'yage']]], - ['matrix_3c_20rows_2c_201_2c_20type_20_3e',['Matrix< Rows, 1, Type >',['../classyage_1_1Matrix.html',1,'yage']]] + ['glyph',['Glyph',['../classyage_1_1Glyph.html',1,'yage']]] ]; diff --git a/search/classes_1.js b/search/classes_1.js index 7dd4e2bf..b3ac49ff 100644 --- a/search/classes_1.js +++ b/search/classes_1.js @@ -1,5 +1,6 @@ var searchData= [ - ['vector2',['Vector2',['../classyage_1_1Vector2.html',1,'yage']]], - ['vector2_3c_20double_20_3e',['Vector2< double >',['../classyage_1_1Vector2.html',1,'yage']]] + ['matrix',['Matrix',['../classyage_1_1Matrix.html',1,'yage']]], + ['matrix_3c_20rows_2c_201_2c_20double_20_3e',['Matrix< Rows, 1, double >',['../classyage_1_1Matrix.html',1,'yage']]], + ['matrix_3c_20rows_2c_201_2c_20type_20_3e',['Matrix< Rows, 1, Type >',['../classyage_1_1Matrix.html',1,'yage']]] ]; diff --git a/search/classes_2.html b/search/classes_2.html new file mode 100644 index 00000000..5c09c969 --- /dev/null +++ b/search/classes_2.html @@ -0,0 +1,26 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/search/classes_2.js b/search/classes_2.js new file mode 100644 index 00000000..7dd4e2bf --- /dev/null +++ b/search/classes_2.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['vector2',['Vector2',['../classyage_1_1Vector2.html',1,'yage']]], + ['vector2_3c_20double_20_3e',['Vector2< double >',['../classyage_1_1Vector2.html',1,'yage']]] +]; diff --git a/search/groups_0.html b/search/groups_0.html new file mode 100644 index 00000000..1ede28df --- /dev/null +++ b/search/groups_0.html @@ -0,0 +1,26 @@ + + + + + + + + + +
+
Loading...
+
+ +
Searching...
+
No Matches
+ +
+ + diff --git a/search/groups_0.js b/search/groups_0.js new file mode 100644 index 00000000..d99cb612 --- /dev/null +++ b/search/groups_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['getters',['Getters',['../group__getters.html',1,'']]] +]; diff --git a/search/searchdata.js b/search/searchdata.js index 3614459b..3e32b04c 100644 --- a/search/searchdata.js +++ b/search/searchdata.js @@ -1,13 +1,14 @@ var indexSectionsWithContent = { 0: "cdgmrtvy", - 1: "mv", + 1: "gmv", 2: "y", 3: "m", 4: "cdgmrt", 5: "d", 6: "v", - 7: "dy" + 7: "g", + 8: "dy" }; var indexSectionNames = @@ -19,7 +20,8 @@ var indexSectionNames = 4: "functions", 5: "variables", 6: "typedefs", - 7: "pages" + 7: "groups", + 8: "pages" }; var indexSectionLabels = @@ -31,6 +33,7 @@ var indexSectionLabels = 4: "Functions", 5: "Variables", 6: "Typedefs", - 7: "Pages" + 7: "Modules", + 8: "Pages" }; diff --git a/sprite_8hpp_source.html b/sprite_8hpp_source.html index 98072d40..b27ebbec 100644 --- a/sprite_8hpp_source.html +++ b/sprite_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
sprite.hpp
-
1 /* ----------------------------------------------------------------------------
2  * sprite.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 SPRITE_HPP
10 #define SPRITE_HPP
11 
12 #include "texture.hpp"
13 
14 #include <GL/glew.h>
15 
16 #include <string>
17 
18 namespace yage
19 {
20 
21 class Sprite
22 {
23 private:
24  float x_;
25  float y_;
26  float width_;
27  float height_;
28  GLuint vbo_id_ = 0;
29  Texture texture_;
30 public:
31  Sprite();
32  ~Sprite();
33 
34  void init(float x, float y, float width, float height, const std::string &texture_path);
35  void draw();
36 };
37 
38 } // yage
39 
40 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * sprite.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 SPRITE_HPP
10 #define SPRITE_HPP
11 
12 #include "texture.hpp"
13 
14 #include <GL/glew.h>
15 
16 #include <string>
17 
18 namespace yage {
19 
20 class Sprite {
21 private:
22  float x_;
23  float y_;
24  float width_;
25  float height_;
26  GLuint vbo_id_ = 0;
27  Texture texture_;
28 
29 public:
30  Sprite();
31  Sprite(const Sprite&) = delete;
32  Sprite(Sprite&&) = delete;
33  ~Sprite();
34 
35  Sprite& operator=(const Sprite&) = delete;
36  Sprite& operator=(Sprite&&) = delete;
37 
38  void init(float x, float y, float width, float height,
39  const std::string& texture_path);
40  void draw();
41 };
42 
43 } // yage
44 
45 #endif
Definition: camera2d.hpp:17
diff --git a/spritebatch_8hpp_source.html b/spritebatch_8hpp_source.html index e522137e..6a16a174 100644 --- a/spritebatch_8hpp_source.html +++ b/spritebatch_8hpp_source.html @@ -68,11 +68,12 @@ $(function() {
spritebatch.hpp
-
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 SPRITE_BATCH_HPP
10 #define 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 
24 class Glyph
25 {
26  // member variables
27 private:
28  GLuint texture_;
29  float depth_;
30  Vertex top_left_;
31  Vertex top_right_;
32  Vertex bottom_right_;
33  Vertex bottom_left_;
34 
35  // member functions
36 public:
37  Glyph(GLuint texture, float depth, const Vertex &top_left, const Vertex &top_right, const Vertex &bottom_right, const Vertex &bottom_left);
38 
39  inline GLuint texture() const { return texture_; }
40  inline float depth() const { return depth_; }
41  inline Vertex top_left() const { return top_left_; }
42  inline Vertex top_right() const { return top_right_; }
43  inline Vertex bottom_right() const { return bottom_right_; }
44  inline Vertex bottom_left() const { return bottom_left_; }
45 };
46 
47 class RenderBatch
48 {
49  friend SpriteBatch;
50  // member variables
51 private:
52  GLsizei num_vertices_;
53  GLint offset_;
54  GLuint texture_;
55 
56  // member functions
57 public:
58  RenderBatch(GLint offset, GLsizei num_vertices, GLuint texture);
59 
60  // getters
61  inline GLint offset() const { return offset_; }
62  inline GLsizei num_vertices() const { return num_vertices_; }
63  inline GLuint texture() const { return texture_; }
64 };
65 
66 class SpriteBatch
67 {
68  // member variables
69 public:
70  static const int NUM_VERTICES=6;
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  // member functions
79 public:
80  SpriteBatch();
81  ~SpriteBatch();
82 
83  // initialize vaos and vbos
84  void init();
85  void begin();
86  void end();
87  // adds a sprite to the sprite batch to be rendered later
88  void draw(const glm::vec4 &destination_rect, const glm::vec4 &uv_rect, GLuint texture, const Color &color, float depth);
89  // render the batch
90  void render();
91 private:
92  void createVertexArray();
93  void createRenderBatches();
94  void sortGlyphs();
95 };
96 
97 } // yage
98 
99 #endif
Definition: camera2d.hpp:17
+
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 class SpriteBatch;
22 
25 class Glyph {
26  // member variables
27 private:
28  GLuint texture_;
29  float depth_;
30  Vertex top_left_;
31  Vertex top_right_;
32  Vertex bottom_right_;
33  Vertex bottom_left_;
34 
35  // member functions
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 
49 class RenderBatch {
50  friend SpriteBatch;
51  // member variables
52 private:
53  GLsizei num_vertices_;
54  GLint offset_;
55  GLuint texture_;
56 
57  // member functions
58 public:
59  RenderBatch(GLint offset, GLsizei num_vertices, GLuint texture);
60 
66  GLint offset() const { return offset_; }
67  GLsizei num_vertices() const { return num_vertices_; }
68  GLuint texture() const { return texture_; }
70 };
71 
72 class SpriteBatch {
73  // member variables
74 public:
75  static const int NUM_VERTICES = 6;
76 
77 private:
78  GLuint vbo_ = 0;
79  GLuint vao_ = 0;
80  std::vector<Glyph> glyphs_;
81  std::vector<Glyph*> glyph_ptrs_;
82  std::vector<RenderBatch> render_batches_;
83 
84  // member functions
85 public:
86  SpriteBatch();
87  SpriteBatch(const SpriteBatch&) = delete;
88  SpriteBatch(SpriteBatch&&) = delete;
89  ~SpriteBatch();
90 
91  SpriteBatch& operator=(const SpriteBatch&) = delete;
92  SpriteBatch& operator=(SpriteBatch&&) = delete;
93 
94  // initialize vaos and vbos
95  void init();
96  void begin();
97  void end();
98  // adds a sprite to the sprite batch to be rendered later
99  void draw(const glm::vec4& destination_rect, const glm::vec4& uv_rect,
100  GLuint texture, const Color& color, float depth);
101  // render the batch
102  void render();
103 
104 private:
105  void createVertexArray();
106  void createRenderBatches();
107  void sortGlyphs();
108 };
109 
110 } // yage
111 
112 #endif
Glyph with information of the texture.
Definition: spritebatch.hpp:25
+
Definition: camera2d.hpp:17
diff --git a/texture_8hpp_source.html b/texture_8hpp_source.html index cf1ec777..c4da14f8 100644 --- a/texture_8hpp_source.html +++ b/texture_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
texture.hpp
-
1 /* ----------------------------------------------------------------------------
2  * texture.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 GL_TEXTURE_HPP
10 #define GL_TEXTURE_HPP
11 
12 #include <GL/glew.h>
13 
14 namespace yage
15 {
16 
17 struct Texture
18 {
19  GLuint id;
20  int width;
21  int height;
22 };
23 
24 } // yage
25 
26 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * texture.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 GL_TEXTURE_HPP
10 #define GL_TEXTURE_HPP
11 
12 #include <GL/glew.h>
13 
14 namespace yage {
15 
16 struct Texture {
17  GLuint id;
18  int width;
19  int height;
20 };
21 
22 } // yage
23 
24 #endif
Definition: camera2d.hpp:17
diff --git a/texturecache_8hpp_source.html b/texturecache_8hpp_source.html index f1146b86..f2247f37 100644 --- a/texturecache_8hpp_source.html +++ b/texturecache_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
texturecache.hpp
-
1 /* ----------------------------------------------------------------------------
2  * texturecache.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 TEXTURE_CACHE_HPP
10 #define TEXTURE_CACHE_HPP
11 
12 #include "texture.hpp"
13 
14 #include <unordered_map>
15 
16 namespace yage
17 {
18 
19 class TextureCache
20 {
21 private:
22  std::unordered_map<std::string, Texture> texture_map_;
23 public:
24  TextureCache();
25  ~TextureCache();
26 
27  Texture getTexture(const std::string &texture_path);
28 };
29 
30 } // yage
31 
32 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * texturecache.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 TEXTURE_CACHE_HPP
10 #define TEXTURE_CACHE_HPP
11 
12 #include "texture.hpp"
13 
14 #include <unordered_map>
15 
16 namespace yage {
17 
18 class TextureCache {
19 private:
20  std::unordered_map<std::string, Texture> texture_map_;
21 
22 public:
23  TextureCache();
24 
25  Texture getTexture(const std::string& texture_path);
26 };
27 
28 } // yage
29 
30 #endif
Definition: camera2d.hpp:17
diff --git a/vertex_8hpp_source.html b/vertex_8hpp_source.html index 6a3021f1..e52debb7 100644 --- a/vertex_8hpp_source.html +++ b/vertex_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
vertex.hpp
-
1 /* ----------------------------------------------------------------------------
2  * vertex.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 VERTEX_HPP
10 #define VERTEX_HPP
11 
12 #include <GL/glew.h>
13 
14 namespace yage
15 {
16 
17 struct Position
18 {
19  float x;
20  float y;
21 
22  Position()
23  {}
24 
25  Position(float x_, float y_) :
26  x(x_), y(y_)
27  {}
28 };
29 
30 struct Color
31 {
32  GLubyte r;
33  GLubyte g;
34  GLubyte b;
35  GLubyte a;
36 
37  Color()
38  {}
39 
40  Color(GLubyte r_, GLubyte g_, GLubyte b_, GLubyte a_) :
41  r(r_), g(g_), b(b_), a(a_)
42  {}
43 };
44 
45 struct UV
46 {
47  float u;
48  float v;
49 
50  UV()
51  {}
52 
53  UV(float u_, float v_) :
54  u(u_), v(v_)
55  {}
56 };
57 
58 struct Vertex
59 {
60  Position position;
61  Color color;
62  UV uv;
63 
64  Vertex()
65  {}
66 
67  Vertex(const Position &position_, const Color &color_, const UV &uv_) :
68  position(position_), color(color_), uv(uv_)
69  {}
70 
71  void setPosition(float x, float y)
72  {
73  position.x = x;
74  position.y = y;
75  }
76 
77  void setColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
78  {
79  color.r = r;
80  color.g = g;
81  color.b = b;
82  color.a = a;
83  }
84 
85  void setUv(float u, float v)
86  {
87  uv.u = u;
88  uv.v = v;
89  }
90 };
91 
92 } // yage
93 
94 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * vertex.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 VERTEX_HPP
10 #define VERTEX_HPP
11 
12 #include <GL/glew.h>
13 
14 namespace yage {
15 
16 struct Position {
17  float x;
18  float y;
19 
20  Position() {}
21 
22  Position(float x_, float y_) : x(x_), y(y_) {}
23 };
24 
25 struct Color {
26  GLubyte r;
27  GLubyte g;
28  GLubyte b;
29  GLubyte a;
30 
31  Color() {}
32 
33  Color(GLubyte r_, GLubyte g_, GLubyte b_, GLubyte a_)
34  : r(r_), g(g_), b(b_), a(a_) {}
35 };
36 
37 struct UV {
38  float u;
39  float v;
40 
41  UV() {}
42 
43  UV(float u_, float v_) : u(u_), v(v_) {}
44 };
45 
46 struct Vertex {
47  Position position;
48  Color color;
49  UV uv;
50 
51  Vertex() {}
52 
53  Vertex(const Position& position_, const Color& color_, const UV& uv_)
54  : position(position_), color(color_), uv(uv_) {}
55 
56  void setPosition(float x, float y) {
57  position.x = x;
58  position.y = y;
59  }
60 
61  void setColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a) {
62  color.r = r;
63  color.g = g;
64  color.b = b;
65  color.a = a;
66  }
67 
68  void setUv(float u, float v) {
69  uv.u = u;
70  uv.v = v;
71  }
72 };
73 
74 } // yage
75 
76 #endif
Definition: camera2d.hpp:17
diff --git a/window_8hpp_source.html b/window_8hpp_source.html index 1d2360e9..2be17c43 100644 --- a/window_8hpp_source.html +++ b/window_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
window.hpp
-
1 /* ----------------------------------------------------------------------------
2  * window.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 WINDOW_HPP
10 #define WINDOW_HPP
11 
12 #include <SDL2/SDL.h>
13 
14 #include <string>
15 
16 namespace yage
17 {
18 
19 // window flags that can change it's appearance
20 enum WindowFlags : unsigned
21 {
22  SHOWN=0x1,
23  HIDDEN=0x2,
24  FULLSCREEN=0x4,
25  BORDERLESS=0x8,
26 };
27 
28 // window wrapper around SDL_Window pointer
29 class Window
30 {
31 public: // member variables
32 private:
33  // window handle
34  SDL_Window *window_=nullptr;
35 
36 public: // member functions
37  Window();
38  // destroys the window handle
39  ~Window();
40 
41  // create the window, initialize the handle and update the width and height
42  void create(const std::string &window_name, int width, int height, unsigned flags=WindowFlags::SHOWN);
43  // swap the buffer
44  void swapBuffer();
45  // clear buffer
46  void clearBuffer();
47 private:
48 };
49 
50 } // yage
51 
52 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * window.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 WINDOW_HPP
10 #define WINDOW_HPP
11 
12 #include <SDL2/SDL.h>
13 
14 #include <string>
15 
16 namespace yage {
17 
18 // window flags that can change it's appearance
19 enum WindowFlags : unsigned {
20  SHOWN = 0x1,
21  HIDDEN = 0x2,
22  FULLSCREEN = 0x4,
23  BORDERLESS = 0x8,
24 };
25 
26 // window wrapper around SDL_Window pointer
27 class Window {
28 private:
30  SDL_Window* window_ = nullptr;
31 
32 public:
33  Window();
34  Window(const Window&) = delete;
35  Window(Window&&) = delete;
37  ~Window();
38 
39  Window& operator=(const Window&) = delete;
40  Window& operator=(Window&&) = delete;
41 
43  void create(const std::string& window_name, int width, int height,
44  unsigned flags = WindowFlags::SHOWN);
46  void swapBuffer();
48  void clearBuffer();
49 };
50 
51 } // namespace yage
52 
53 #endif
Definition: camera2d.hpp:17
diff --git a/yage_8hpp_source.html b/yage_8hpp_source.html index 236e7d75..c692cf35 100644 --- a/yage_8hpp_source.html +++ b/yage_8hpp_source.html @@ -68,11 +68,11 @@ $(function() {
yage.hpp
-
1 /* ----------------------------------------------------------------------------
2  * yage.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_HPP
10 #define YAGE_HPP
11 
12 #include "camera2d.hpp"
13 #include "glslprogram.hpp"
14 #include "imageloader.hpp"
15 #include "inputmanager.hpp"
16 #include "iomanager.hpp"
17 #include "picopng.hpp"
18 #include "resourcemanager.hpp"
19 #include "spritebatch.hpp"
20 #include "texture.hpp"
21 #include "vertex.hpp"
22 #include "window.hpp"
23 
24 #include <SDL2/SDL.h>
25 
26 #include <stdexcept>
27 
28 namespace yage
29 {
30 
31 bool init()
32 {
33  if(SDL_Init(SDL_INIT_VIDEO))
34  {
35  return false;
36  }
37  return true;
38 }
39 
40 void quit()
41 {
42  SDL_Quit();
43 }
44 
45 };
46 
47 #endif
Definition: camera2d.hpp:17
+
1 /* ----------------------------------------------------------------------------
2  * yage.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_HPP
10 #define YAGE_HPP
11 
12 #include "camera2d.hpp"
13 #include "glslprogram.hpp"
14 #include "imageloader.hpp"
15 #include "inputmanager.hpp"
16 #include "iomanager.hpp"
17 #include "picopng.hpp"
18 #include "resourcemanager.hpp"
19 #include "spritebatch.hpp"
20 #include "texture.hpp"
21 #include "vertex.hpp"
22 #include "window.hpp"
23 
24 #include <SDL2/SDL.h>
25 
26 #include <stdexcept>
27 
28 namespace yage {
29 
30 bool init() { return SDL_Init(SDL_INIT_VIDEO); }
31 void quit() { SDL_Quit(); }
32 
33 };
34 
35 #endif
Definition: camera2d.hpp:17
-- cgit