fiddling around with new image layout storage
This commit is contained in:
parent
43d5ceabb8
commit
30cc534a37
5 changed files with 37 additions and 9 deletions
|
@ -8,6 +8,7 @@ Language: Cpp
|
|||
# Force pointers to the type for C++.
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Left
|
||||
|
||||
LambdaBodyIndentation: OuterScope
|
||||
AlignArrayOfStructures: Left
|
||||
|
||||
AlignConsecutiveAssignments: true
|
||||
|
|
|
@ -1,16 +1,39 @@
|
|||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <print>
|
||||
#include <pw/core/image.hpp>
|
||||
#include <tuple>
|
||||
|
||||
namespace pw {
|
||||
|
||||
struct image_layout {
|
||||
enum pixel_layout { RGB8, RGBA, LUM, DEPTH };
|
||||
enum pixel_layout { RGB8, RGBA8, LUM8, DEPTH };
|
||||
|
||||
static constexpr auto bits_per_channel(pixel_layout layout) {
|
||||
constexpr auto lut =
|
||||
std::array{std::make_tuple(RGB8, sizeof(std::uint8_t) << 3),
|
||||
std::make_tuple(DEPTH, sizeof(float) << 3)};
|
||||
|
||||
const auto iter = std::find_if(
|
||||
std::begin(lut), std::end(lut),
|
||||
[&layout](const auto& v) { return std::get<0>(v) == layout; });
|
||||
|
||||
return iter != std::end(lut) ? std::get<1>(*iter) : 0u;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace pw
|
||||
|
||||
auto main() -> int {
|
||||
|
||||
auto val = pw::image_layout::bits_per_channel(
|
||||
pw::image_layout::pixel_layout::RGB8);
|
||||
|
||||
std::print("RGB8 = {}bits per channel\n", val);
|
||||
std::print("DEPTH = {}bits per channel\n",
|
||||
pw::image_layout::bits_per_channel(
|
||||
pw::image_layout::pixel_layout::DEPTH));
|
||||
|
||||
// pw::image
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ auto main() -> int {
|
|||
|
||||
std::print("\nm44=[{}]\n", m44);
|
||||
|
||||
|
||||
// auto m_init_ded = pw::matrix{
|
||||
// {1, 2},
|
||||
// {3, 4}
|
||||
|
|
|
@ -18,10 +18,10 @@ auto main() -> int {
|
|||
auto geom = pw::primitives{
|
||||
.vertices = {{1.2f, 2.4f, 4.8f},
|
||||
{2.4f, 1.2f, 4.8f},
|
||||
{1.2f, 4.8f, 2.4f} },
|
||||
.indices = {0, 1, 2},
|
||||
.topology = pw::primitives::topology_type::triangle_list
|
||||
};
|
||||
{1.2f, 4.8f, 2.4f}},
|
||||
.indices = {0, 1, 2},
|
||||
|
||||
.topology = pw::primitives::topology_type::triangle_list};
|
||||
|
||||
auto mesh = pw::mesh{
|
||||
.geometry = geom,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include <pw/core/formatter.hpp>
|
||||
#include <pw/core/serialize.hpp>
|
||||
#include <pw/core/vector.hpp>
|
||||
#include <pw/core/formatter.hpp>
|
||||
|
||||
#include <print>
|
||||
#include <tuple>
|
||||
|
@ -69,7 +69,12 @@ auto main() -> int {
|
|||
std::print("y: {}\n", vec3f.get<1>());
|
||||
std::print("tuple size {}\n", std::tuple_size_v<decltype(vec3f)>);
|
||||
|
||||
const auto& [x, y, z] = vec3f;
|
||||
auto& [x, y, z] = vec3f;
|
||||
std::print("x:{} y:{} z:{}\n", x, y, z);
|
||||
|
||||
x++;
|
||||
y--;
|
||||
z = 0;
|
||||
std::print("x:{} y:{} z:{}\n", x, y, z);
|
||||
|
||||
auto min_ab{vec3f.min(pw::vector{1.3f, 0.9f, 2.3f})};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue