Repository navigation
Expand file tree
/
Copy pathtexture.cpp
More file actions
79 lines (65 loc) · 1.5 KB
/
Copy pathtexture.cpp
File metadata and controls
79 lines (65 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
////////////////////////////////////////////////////////////////////////////////
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE or copy at //
// https://www.boost.org/LICENSE_1_0.txt) //
////////////////////////////////////////////////////////////////////////////////
#include "graphics/texture.h"
#include <cstdint>
#include "graphics/sampler.h"
#include "graphics/texture_usage.h"
namespace iris
{
Texture::Texture(
const DataBuffer &data,
std::uint32_t width,
std::uint32_t height,
const Sampler *sampler,
TextureUsage usage,
std::uint32_t index)
: data_(data)
, width_(width)
, height_(height)
, sampler_(sampler)
, usage_(usage)
, index_(index)
, has_transparency_(false)
{
for (auto i = 3u; i < data_.size(); i += 4u)
{
if (data_[i] != std::byte{0xFF})
{
has_transparency_ = true;
break;
}
}
}
Texture::~Texture() = default;
const DataBuffer &Texture::data() const
{
return data_;
}
std::uint32_t Texture::width() const
{
return width_;
}
std::uint32_t Texture::height() const
{
return height_;
}
const Sampler *Texture::sampler() const
{
return sampler_;
}
TextureUsage Texture::usage() const
{
return usage_;
}
std::uint32_t Texture::index() const
{
return index_;
}
bool Texture::has_transparency() const
{
return has_transparency_;
}
}