some more work on the call stack of the visual component
This commit is contained in:
parent
dd908ead95
commit
70424c8819
15 changed files with 136 additions and 55 deletions
|
@ -33,20 +33,27 @@ public:
|
|||
|
||||
image() = default;
|
||||
|
||||
using data_t = std::byte;
|
||||
|
||||
enum pixel_layout {
|
||||
RGB8,
|
||||
RGBA8,
|
||||
LUM
|
||||
LUM,
|
||||
DEPTH,
|
||||
HDR
|
||||
};
|
||||
|
||||
image(const sizei& s, pixel_layout t, void *ptr = nullptr);
|
||||
|
||||
bool create(const sizei& s, pixel_layout t, void *ptr = nullptr);
|
||||
|
||||
void destroy(bool release_memory = false);
|
||||
void release(bool release_memory = false);
|
||||
|
||||
const uint8_t *data() const { return _data.data(); }
|
||||
uint8_t *data() { return _data.data(); }
|
||||
const data_t *data() const { return _data.data(); }
|
||||
data_t *data() { return _data.data(); }
|
||||
|
||||
const float *data_float() const { return reinterpret_cast<const float*>(_data.data()); }
|
||||
float *data_float() { return reinterpret_cast<float*>(_data.data());}
|
||||
|
||||
pixel_layout layout() const;
|
||||
void set_layout(const pixel_layout &layout);
|
||||
|
@ -66,7 +73,7 @@ protected:
|
|||
pixel_layout _layout;
|
||||
uint64_t _change_count;
|
||||
|
||||
std::vector<uint8_t> _data;
|
||||
std::vector<data_t> _data;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -33,10 +33,13 @@ namespace pw {
|
|||
class mesh {
|
||||
public:
|
||||
|
||||
typedef std::vector<int32_t> indexarray_t;
|
||||
typedef std::vector<real_t> valuearray_t;
|
||||
typedef std::vector<vector3> vertex3array_t;
|
||||
typedef std::vector<vector2> vertex2array_t;
|
||||
using index_t = unsigned int ;
|
||||
|
||||
using valuearray_t = std::vector<real_t> ;
|
||||
using indexarray_t = std::vector<index_t> ;
|
||||
|
||||
using vertex2array_t = std::vector<vector2> ;
|
||||
using vertex3array_t = std::vector<vector3> ;
|
||||
|
||||
enum topology_type {
|
||||
triangles,
|
||||
|
@ -56,6 +59,9 @@ public:
|
|||
void set_vertices(const vertex3array_t& v);
|
||||
const vertex3array_t& vertices() const { return _vertices; }
|
||||
|
||||
void set_normals(const mesh::vertex3array_t &v);
|
||||
const mesh::vertex3array_t& normals() const;
|
||||
|
||||
void set_topology(topology_type t) { _topology = t; }
|
||||
topology_type topology() { return _topology; }
|
||||
|
||||
|
@ -67,8 +73,6 @@ public:
|
|||
|
||||
void compute_normals();
|
||||
|
||||
void set_normals(const mesh::vertex3array_t &v);
|
||||
const mesh::vertex3array_t& normals() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ image::image(const sizei &s, image::pixel_layout t, void *ptr)
|
|||
|
||||
bool image::create(const sizei &s, image::pixel_layout t, void *ptr)
|
||||
{
|
||||
auto n = bytes_per_pixel(t) * s.area();
|
||||
size_t n = bytes_per_pixel(t) * s.area();
|
||||
|
||||
if (ptr != nullptr) {
|
||||
|
||||
auto a = reinterpret_cast<uint8_t*>(ptr);
|
||||
auto a = reinterpret_cast<image::data_t*>(ptr);
|
||||
|
||||
_data.assign(a,a + n);
|
||||
_size = s;
|
||||
|
@ -23,14 +23,14 @@ bool image::create(const sizei &s, image::pixel_layout t, void *ptr)
|
|||
|
||||
} else {
|
||||
|
||||
_data.resize(n,0);
|
||||
_data.resize(n);
|
||||
_size = sizei(0,0);
|
||||
}
|
||||
|
||||
return !_data.empty();
|
||||
}
|
||||
|
||||
void image::destroy(bool release_memory)
|
||||
void image::release(bool release_memory)
|
||||
{
|
||||
_data.clear();
|
||||
|
||||
|
@ -41,11 +41,13 @@ uint32_t image::bytes_per_pixel(image::pixel_layout t)
|
|||
{
|
||||
switch (t) {
|
||||
case pw::image::RGB8:
|
||||
return 3;
|
||||
return 3 * sizeof(data_t);
|
||||
case pw::image::RGBA8:
|
||||
return 4;
|
||||
return 4 * sizeof(data_t);
|
||||
case pw::image::LUM:
|
||||
return 1;
|
||||
return 1 * sizeof(data_t);
|
||||
case pw::image::DEPTH:
|
||||
return 1 * sizeof(float);
|
||||
}
|
||||
|
||||
return std::numeric_limits<uint32_t>::max();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue