gdk-graphics 0b051eb9b5c1eaa0658babaa4463dd7a80aa9d2c
Loading...
Searching...
No Matches
texture_data.h
1// © Joseph Cameron - All Rights Reserved
2
3#ifndef GDK_GFX_TEXTURE_DATA_H
4#define GDK_GFX_TEXTURE_DATA_H
5
6#include <gdk/texture.h>
7
8#include <array>
9#include <cstddef>
10#include <memory>
11
12namespace gdk::texture_data {
13 using channel_type = unsigned char;
14 using channel_data = std::vector<channel_type>;
15 using encoded_byte = unsigned char;
16
20 struct view {
21 size_t width;
22 size_t height;
24 const channel_type *data;
25 };
26
27 /*/// \brief provides a pointer a contiguous list of channel data representing 3D texture
30 struct view3d {
31 size_t width; //!< number of texels wide
32 size_t height; //!< number of texels tall
33 size_t length; //!< number of texels long
34 texture::format format; //!< format of the data
35 const channel_type *data; //!< ptr to the start of decoded texture data
36 };*/
37
39 std::pair<view, std::shared_ptr<channel_data>> make_from_png(
40 const encoded_byte* aDataStart, const size_t aLength,
41 const texture::format aFormat = texture::format::rgba );
42 std::pair<view, std::shared_ptr<channel_data>> make_from_png(
43 const std::vector<encoded_byte>& aPNGBuffer, const texture::format aFormat = texture::format::rgba );
44 template <std::size_t N>
45 std::pair<view, std::shared_ptr<channel_data>> make_from_png(
46 const std::array<encoded_byte, N>& data, const texture::format aFormat = texture::format::rgba) {
47 return make_from_png(data.data(), N, aFormat);
48 }
49}
50
51#endif
52
format
format of data in the component_type array
Definition texture.h:23
@ rgba
a sequence of 4 channels, single byte colors: red, green, blue, alpha, ...
Definition texture.h:27
provides a pointer a contiguous list of channel data representing 2D texture metadata that contains i...
Definition texture_data.h:20
size_t width
number of texels wide
Definition texture_data.h:21
size_t height
number of texels tall
Definition texture_data.h:22
const channel_type * data
ptr to the start of decoded texture data
Definition texture_data.h:24
texture::format format
format of the data
Definition texture_data.h:23