Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_graphics
Rendering
Texture.cpp
Go to the documentation of this file.
1
#include "
Texture.hpp
"
2
3
#include <
ivorium_core/ivorium_core.hpp
>
4
#include <
ivorium_systems/ivorium_systems.hpp
>
5
6
namespace
iv
7
{
8
9
const
StringIO< Texture::Filtering >::ValuesType
StringIO< Texture::Filtering >::Values
=
10
{
11
{
Texture::Filtering::Nearest
,
"Nearest"
},
12
{
Texture::Filtering::SmoothMsdf
,
"SmoothMsdf"
},
13
{
Texture::Filtering::Smooth2D
,
"Smooth2D"
},
14
{
Texture::Filtering::Smooth3D
,
"Smooth3D"
}
15
};
16
17
Texture::Metadata::Metadata
() :
18
size( 0, 0 ),
19
density( 1.0 ),
20
filtering(
Filtering
::
Nearest
),
21
format(
PixelFormat
::
RGBA
),
22
color_space(
ColorSpace
::
sRGB
),
23
msdf_pixelRange( 1.0f ),
24
hitmap( false ),
25
instant_loading( false )
26
{
27
}
28
29
Texture::Texture
(
Instance
* inst ) :
30
cm
( inst, this,
"Texture"
),
31
_metadata
(),
32
_gl_texture
(),
33
_hitmap
(),
34
inst( inst )
35
{
36
}
37
38
Instance
*
Texture::instance
()
const
39
{
40
return
this->inst;
41
}
42
43
Texture::Metadata
const
&
Texture::metadata
()
const
44
{
45
return
this->
_metadata
;
46
}
47
48
GlTexture
const
*
Texture::gl_texture
()
const
49
{
50
return
&this->
_gl_texture
;
51
}
52
53
bool
Texture::hittest
(
int
x,
int
y )
const
54
{
55
int
id
= y * this->
_metadata
.
size
.x + x;
56
if
( id < 0 || id >= this->
_hitmap
.size() )
57
return
false
;
58
return
this->
_hitmap
[ id ];
59
}
60
61
}