hx3d  1
2D/3D Simple Game Framework
sprite.hpp
1 /*
2  Sprite.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #ifndef HX3D_GRAPHICS_SPRITE
22 #define HX3D_GRAPHICS_SPRITE
23 
24 #include "hx3d/graphics/mesh.hpp"
25 #include "hx3d/graphics/texture.hpp"
26 #include "hx3d/graphics/framebuffer.hpp"
27 #include "hx3d/graphics/texture_region.hpp"
28 
29 namespace hx3d {
30 namespace graphics {
31 
62 class Sprite: public Mesh {
63 
64 public:
65 
71  Sprite();
72 
78  void setTexture(const Ptr<Texture>& texture);
79 
85  void setTexture(Framebuffer& buffer);
86 
92  void setTexture(TextureRegion& region);
93 
100 
104  void scaleTexture();
105 
106  virtual void draw(Ptr<Shader> shader) override;
107 
108 private:
110  Ptr<Texture> _texture;
111 };
112 
113 } /* graphics */
114 } /* hx3d */
115 
116 #endif
Sprite()
Create a sprite without texture.
Definition: sprite.cpp:28
void setTexture(const Ptr< Texture > &texture)
Set the sprite texture.
Definition: sprite.cpp:36
hx3d framework namespace
Definition: audio.hpp:26
virtual void draw(Ptr< Shader > shader) override
Draw the mesh using a shader.
Definition: sprite.cpp:94
Defines a rectangle in a texture.
void scaleTexture()
Scale the texture coordinates following the texture size.
Definition: sprite.cpp:78
2D texture manipulation.
Definition: sprite.hpp:62
Displayable 2D/3D element.
Definition: mesh.hpp:41
Render-to-texture buffer.
Definition: framebuffer.hpp:37
Ptr< Texture > getTexture()
Get the sprite texture.
Definition: sprite.cpp:74
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
Definition: ptr.hpp:34