Rune Engine  Version 0.2.7-alpha
Documentation for how to make games using the Rune Engine.
sprite.h
1 
9 #ifndef SPRITE_H_DEFINED
10 #define SPRITE_H_DEFINED
11 
12 #include "core.h"
13 #include <Entities\component.h>
14 #include "renderWindow.h"
15 #include "texture.h"
16 #include "drawable.h"
17 #include "shader.h"
18 #include <Math\vec2.h>
19 #include <string>
20 #include "rect.h"
21 
22 namespace rune{
23 
24 class RUNE_ENGINE Sprite : public Drawable, public Component
25 {
26 private:
27 
28  Texture spriteTexture;
29 
30  unsigned int indices[6] =
31  {
32  0, 1, 3, // first triangle
33  1, 2, 3 // second triangle
34  };
35 
36  unsigned int VBO;
37  unsigned int EBO;
38  unsigned int VAO;
39 
40  //Texture rectangle
41  IntRect textureSpace;
42 
43  bool isMirrored;
44 
45  unsigned int spriteDrawMode;
46 
47  const char* defaultSprite =
48  {
49  #include <Shaders/defaultSprite.glsl>
50  };
51 
52 public:
56  Sprite();
58  Sprite(std::string const& spriteLocation, unsigned int drawMode = LINEAR_FILTER);
60  virtual void awake() override;
62  virtual void start() override;
64  void setUpBuffers(void);
66  virtual void draw(rune::RenderWindow&);
68  void setTexture(std::string const& texture, unsigned int drawMode = LINEAR_FILTER);
70  void setTexture(Texture* texture);
72  void setTextureRect(int xPos, int yPos, int width, int height);
74  IntRect getTextureRect(void);
76  unsigned int getDrawMode();
78  void setMirror(bool mirror);
80  bool getMirror(void);
83 
84 };
85 
86 }
87 
88 #endif
rune::Sprite::objectShader
Shader objectShader
The Shader that should be used to draw the sprite.
Definition: sprite.h:54
rune::Component
A component of a rune::GameObject, this class is used to add functionality to a object in the game wo...
Definition: component.h:23
rune::Shader
A shader that can be used to render objects to the screen.
Definition: shader.h:41
rune::Drawable
Interface class for creating something that can be drawn to the screen.
Definition: drawable.h:20
rune::Rect< int >
rune::Sprite::spriteColor
Color spriteColor
The Color of the sprite for drawing purposes.
Definition: sprite.h:82
rune::RenderWindow
A window that the game can be drawn to.
Definition: renderWindow.h:26
rune::Sprite
A sprite that can be given a texture and animated.
Definition: sprite.h:25
rune::Color
A color object to be applied to drawable objects.
Definition: color.h:19
rune
The main namespace to be used for interfacing with the engine.
Definition: animator.h:21
rune::Texture
A texture that can be applied to drawable objects.
Definition: texture.h:23