Definition at line 104 of file main.cpp.
◆ empty()
| bool anonymous_namespace{main.cpp}::Texture::empty |
( |
| ) |
const |
|
inlinenodiscard |
Definition at line 107 of file main.cpp.
107 {
109 }
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 47 of file main.cpp.
47 {
50 }
51
52 u = std::clamp(u, 0.0f, 1.0f);
53 v = std::clamp(v, 0.0f, 1.0f);
54 const int x = std::clamp(
static_cast<int>(u *
static_cast<float>(
width - 1) + 0.5f), 0,
width - 1);
55 const int y = std::clamp(
static_cast<int>(v *
static_cast<float>(
height - 1) + 0.5f), 0,
height - 1);
56 return pixels[
static_cast<std::size_t
>(y *
width + x)];
57 }
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 47 of file main.cpp.
47 {
50 }
51
52 u = std::clamp(u, 0.0f, 1.0f);
53 v = std::clamp(v, 0.0f, 1.0f);
54 const int x = std::clamp(
static_cast<int>(u *
static_cast<float>(
width - 1) + 0.5f), 0,
width - 1);
55 const int y = std::clamp(
static_cast<int>(v *
static_cast<float>(
height - 1) + 0.5f), 0,
height - 1);
56 return pixels[
static_cast<std::size_t
>(y *
width + x)];
57 }
◆ 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 119 of file main.cpp.
119 {
120 level = std::clamp(level, 0.0f,
static_cast<float>(
levels.size() - 1));
121 const std::size_t first_level = static_cast<std::size_t>(std::floor(level));
122 const std::size_t second_level = std::min(first_level + 1,
levels.size() - 1);
123 const float fraction = level - static_cast<float>(first_level);
124 const mxvk::MXCOLOR first_color =
levels[first_level].sample_bilinear(u, v, repeat_horizontal);
125 if (first_level == second_level) {
126 return first_color;
127 }
128 return interpolate_color(first_color,
levels[second_level].sample_bilinear(u, v, repeat_horizontal), fraction);
129 }
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 202 of file main.cpp.
202 {
203 const float clamped_lod = std::clamp(lod, 0.0f,
static_cast<float>(
mipmaps.size()));
204 const int first_level = static_cast<int>(std::floor(clamped_lod));
205 const int second_level = std::min(first_level + 1,
static_cast<int>(
mipmaps.size()));
206 const float blend = clamped_lod - static_cast<float>(first_level);
207 const mxvk::MXCOLOR first = sample_bilinear(first_level, u, v);
208 const mxvk::MXCOLOR second = sample_bilinear(second_level, u, v);
209 return blend_color(first, second, blend);
210 }
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 59 of file main.cpp.
59 {
60 u = std::clamp(u, 0.0f, 1.0f);
61 v = std::clamp(v, 0.0f, 1.0f);
62 const int x =
static_cast<int>(u *
static_cast<float>(
width - 1) + 0.5f);
63 const int y =
static_cast<int>(v *
static_cast<float>(
height - 1) + 0.5f);
64 return pixels[
static_cast<std::size_t
>(y *
width + x)];
65 }
◆ sample_nearest() [2/2]
| mxvk::MXCOLOR anonymous_namespace{main.cpp}::Texture::sample_nearest |
( |
float | u, |
|
|
float | v ) const |
|
inlinenodiscard |
Definition at line 59 of file main.cpp.
59 {
60 u = std::clamp(u, 0.0f, 1.0f);
61 v = std::clamp(v, 0.0f, 1.0f);
62 const int x =
static_cast<int>(u *
static_cast<float>(
width - 1) + 0.5f);
63 const int y =
static_cast<int>(v *
static_cast<float>(
height - 1) + 0.5f);
64 return pixels[
static_cast<std::size_t
>(y *
width + x)];
65 }
◆ 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: