Definition at line 85 of file main.cpp.
◆ empty()
| bool anonymous_namespace{main.cpp}::Texture::empty |
( |
| ) |
const |
|
inlinenodiscard |
Definition at line 88 of file main.cpp.
88{
return levels.empty() ||
levels.front().width <= 0 ||
levels.front().height <= 0 ||
levels.front().pixels.empty(); }
std::vector< MipLevel > levels
◆ height()
| int anonymous_namespace{main.cpp}::Texture::height |
( |
| ) |
const |
|
inlinenodiscard |
◆ sample() [1/3]
| mxvk::MXCOLOR anonymous_namespace{main.cpp}::Texture::sample |
( |
float | u, |
|
|
float | v ) const |
|
inlinenodiscard |
Definition at line 45 of file main.cpp.
45 {
48 }
49
50 u = std::clamp(u, 0.0f, 1.0f);
51 v = std::clamp(v, 0.0f, 1.0f);
52 const int x = std::clamp(
static_cast<int>(u *
static_cast<float>(
width - 1) + 0.5f), 0,
width - 1);
53 const int y = std::clamp(
static_cast<int>(v *
static_cast<float>(
height - 1) + 0.5f), 0,
height - 1);
54 return pixels[
static_cast<std::size_t
>(y *
width + x)];
55 }
constexpr MXCOLOR MXVK_RGB(int r, int g, int b)
Build an opaque ARGB color from red, green, and blue components.
std::vector< mxvk::MXCOLOR > pixels
◆ sample() [2/3]
| mxvk::MXCOLOR anonymous_namespace{main.cpp}::Texture::sample |
( |
float | u, |
|
|
float | v ) const |
|
inlinenodiscard |
Definition at line 45 of file main.cpp.
45 {
48 }
49
50 u = std::clamp(u, 0.0f, 1.0f);
51 v = std::clamp(v, 0.0f, 1.0f);
52 const int x = std::clamp(
static_cast<int>(u *
static_cast<float>(
width - 1) + 0.5f), 0,
width - 1);
53 const int y = std::clamp(
static_cast<int>(v *
static_cast<float>(
height - 1) + 0.5f), 0,
height - 1);
54 return pixels[
static_cast<std::size_t
>(y *
width + x)];
55 }
◆ sample() [3/3]
| mxvk::MXCOLOR anonymous_namespace{main.cpp}::Texture::sample |
( |
float | u, |
|
|
float | v, |
|
|
float | level, |
|
|
bool | repeat_horizontal ) const |
|
inlinenodiscard |
Definition at line 94 of file main.cpp.
94 {
95 level = std::clamp(level, 0.0f,
static_cast<float>(
levels.size() - 1));
96 const std::size_t first_level = static_cast<std::size_t>(std::floor(level));
97 const std::size_t second_level = std::min(first_level + 1,
levels.size() - 1);
98 const float fraction = level - static_cast<float>(first_level);
99 const mxvk::MXCOLOR first_color =
levels[first_level].sample_bilinear(u, v, repeat_horizontal);
100 if (first_level == second_level) {
101 return first_color;
102 }
103 return interpolate_color(first_color,
levels[second_level].sample_bilinear(u, v, repeat_horizontal), fraction);
104 }
mxvk::MXCOLOR interpolate_color(mxvk::MXCOLOR first, mxvk::MXCOLOR second, float fraction)
std::uint32_t MXCOLOR
Packed 32-bit color in ARGB byte order.
◆ sample_filtered()
| mxvk::MXCOLOR anonymous_namespace{main.cpp}::Texture::sample_filtered |
( |
float | u, |
|
|
float | v, |
|
|
float | lod ) const |
|
inlinenodiscard |
Definition at line 194 of file main.cpp.
194 {
195 const float clamped_lod = std::clamp(lod, 0.0f,
static_cast<float>(
mipmaps.size()));
196 const int first_level = static_cast<int>(std::floor(clamped_lod));
197 const int second_level = std::min(first_level + 1,
static_cast<int>(
mipmaps.size()));
198 const float blend = clamped_lod - static_cast<float>(first_level);
199 const mxvk::MXCOLOR first = sample_bilinear(first_level, u, v);
200 const mxvk::MXCOLOR second = sample_bilinear(second_level, u, v);
201 return blend_color(first, second, blend);
202 }
std::vector< TextureLevel > mipmaps
◆ sample_nearest() [1/2]
| mxvk::MXCOLOR anonymous_namespace{main.cpp}::Texture::sample_nearest |
( |
float | u, |
|
|
float | v ) const |
|
inlinenodiscard |
Definition at line 57 of file main.cpp.
57 {
58 u = std::clamp(u, 0.0f, 1.0f);
59 v = std::clamp(v, 0.0f, 1.0f);
60 const int x =
static_cast<int>(u *
static_cast<float>(
width - 1) + 0.5f);
61 const int y =
static_cast<int>(v *
static_cast<float>(
height - 1) + 0.5f);
62 return pixels[
static_cast<std::size_t
>(y *
width + x)];
63 }
◆ sample_nearest() [2/2]
| mxvk::MXCOLOR anonymous_namespace{main.cpp}::Texture::sample_nearest |
( |
float | u, |
|
|
float | v ) const |
|
inlinenodiscard |
Definition at line 57 of file main.cpp.
57 {
58 u = std::clamp(u, 0.0f, 1.0f);
59 v = std::clamp(v, 0.0f, 1.0f);
60 const int x =
static_cast<int>(u *
static_cast<float>(
width - 1) + 0.5f);
61 const int y =
static_cast<int>(v *
static_cast<float>(
height - 1) + 0.5f);
62 return pixels[
static_cast<std::size_t
>(y *
width + x)];
63 }
◆ width()
| int anonymous_namespace{main.cpp}::Texture::width |
( |
| ) |
const |
|
inlinenodiscard |
◆ height
| int anonymous_namespace{main.cpp}::Texture::height = 0 |
◆ levels
| std::vector<MipLevel> anonymous_namespace{main.cpp}::Texture::levels |
◆ mipmaps
| std::vector<TextureLevel> anonymous_namespace{main.cpp}::Texture::mipmaps |
◆ pixels
| std::vector< mxvk::MXCOLOR > anonymous_namespace{main.cpp}::Texture::pixels |
◆ width
| int anonymous_namespace{main.cpp}::Texture::width = 0 |
The documentation for this struct was generated from the following files: