GameKit
0.0.1a
C++ gamedev tools
include
gk
graphics
Image.hpp
Go to the documentation of this file.
1
/*
2
* =====================================================================================
3
*
4
* Filename: Image.hpp
5
*
6
* Description:
7
*
8
* Created: 20/09/2014 16:21:56
9
*
10
* Author: Quentin Bazin, <gnidmoo@gmail.com>
11
*
12
* =====================================================================================
13
*/
14
#ifndef GK_IMAGE_HPP_
15
#define GK_IMAGE_HPP_
16
17
#include "
gk/graphics/Color.hpp
"
18
#include "
gk/core/Rect.hpp
"
19
#include "
gk/gl/IDrawable.hpp
"
20
#include "
gk/gl/Transformable.hpp
"
21
#include "
gk/gl/VertexBuffer.hpp
"
22
23
namespace
gk
{
24
25
class
Image
:
public
IDrawable
,
public
Transformable
{
26
public
:
27
Image
() =
default
;
28
Image
(
const
std::string &textureName);
29
Image
(
const
Texture
&texture);
30
31
void
load
(
const
Image
&image);
32
void
load
(
const
std::string &textureName);
33
void
load
(
const
Texture
&texture);
34
35
const
FloatRect
&
clipRect
()
const
{
return
m_clipRect
; }
36
void
setClipRect
(
float
x,
float
y,
u16
width
,
u16
height
);
37
38
const
FloatRect
&
posRect
()
const
{
return
m_posRect
; }
39
void
setPosRect
(
float
x,
float
y,
u16
width,
u16
height);
40
41
u16
width
()
const
{
return
m_width
*
getScale
().
x
; }
42
u16
height
()
const
{
return
m_height
*
getScale
().
y
; }
43
44
void
setColor
(
const
Color
&color) {
m_color
= color;
updateVertexBuffer
(); }
45
void
setAlphaMod
(
u8
alpha) {
m_color
.
a
= alpha / 255.0f;
updateVertexBuffer
(); }
46
void
setFlip
(
bool
isFlipped) {
m_isFlipped
= isFlipped; }
47
48
protected
:
49
void
updateVertexBuffer
()
const
;
50
51
void
draw
(
RenderTarget
&target,
RenderStates
states)
const override
;
52
53
const
Texture
*
m_texture
=
nullptr
;
54
55
VertexBuffer
m_vbo
;
56
57
private
:
58
u16
m_width
= 0;
59
u16
m_height
= 0;
60
61
FloatRect
m_clipRect
;
62
FloatRect
m_posRect
;
63
64
Color
m_color
;
65
66
bool
m_isFlipped
=
false
;
67
};
68
69
}
// namespace gk
70
71
#endif // GK_IMAGE_HPP_
gk::Image::load
void load(const Image &image)
Definition:
Image.cpp:33
gk::Image::draw
void draw(RenderTarget &target, RenderStates states) const override
Draw the object to a render target.
Definition:
Image.cpp:124
gk::Vector3::y
T y
Definition:
Vector3.hpp:66
gk::Transformable::getScale
const Vector3f & getScale() const
Definition:
Transformable.hpp:39
VertexBuffer.hpp
gk::Image::setClipRect
void setClipRect(float x, float y, u16 width, u16 height)
Definition:
Image.cpp:61
gk
Definition:
AudioPlayer.hpp:21
Transformable.hpp
gk::Image::height
u16 height() const
Definition:
Image.hpp:42
gk::RenderStates
Definition:
RenderStates.hpp:42
gk::Image::setAlphaMod
void setAlphaMod(u8 alpha)
Definition:
Image.hpp:45
gk::Color
Utility class for manipulating RGBA colors.
Definition:
Color.hpp:25
gk::Image::updateVertexBuffer
void updateVertexBuffer() const
Definition:
Image.cpp:76
u16
unsigned short u16
Definition:
IntTypes.hpp:22
u8
unsigned char u8
Definition:
IntTypes.hpp:21
IDrawable.hpp
gk::Image::setFlip
void setFlip(bool isFlipped)
Definition:
Image.hpp:46
gk::Color::a
float a
Alpha (opacity) component.
Definition:
Color.hpp:114
gk::Image::m_isFlipped
bool m_isFlipped
Definition:
Image.hpp:66
gk::Image::m_posRect
FloatRect m_posRect
Definition:
Image.hpp:62
gk::Image::m_width
u16 m_width
Definition:
Image.hpp:58
gk::Image::m_color
Color m_color
Definition:
Image.hpp:64
gk::Rect< float >
gk::Transformable
Definition:
Transformable.hpp:21
gk::Texture
Image living on the graphics card that can be used for drawing.
Definition:
Texture.hpp:30
gk::Image::clipRect
const FloatRect & clipRect() const
Definition:
Image.hpp:35
gk::VertexBuffer
Definition:
VertexBuffer.hpp:22
Color.hpp
gk::Image::m_texture
const Texture * m_texture
Definition:
Image.hpp:53
gk::RenderTarget
Definition:
RenderTarget.hpp:27
gk::IDrawable
Abstract base class for objects that can be drawn to a render target.
Definition:
IDrawable.hpp:25
gk::Image::setColor
void setColor(const Color &color)
Definition:
Image.hpp:44
gk::Image::m_height
u16 m_height
Definition:
Image.hpp:59
Rect.hpp
gk::Image::m_vbo
VertexBuffer m_vbo
Definition:
Image.hpp:55
gk::Image::posRect
const FloatRect & posRect() const
Definition:
Image.hpp:38
gk::Image::Image
Image()=default
gk::Vector3::x
T x
Definition:
Vector3.hpp:65
gk::Image::m_clipRect
FloatRect m_clipRect
Definition:
Image.hpp:61
gk::Image::width
u16 width() const
Definition:
Image.hpp:41
gk::Image
Definition:
Image.hpp:25
gk::Image::setPosRect
void setPosRect(float x, float y, u16 width, u16 height)
Definition:
Image.cpp:70
Generated by
1.8.12