#ifndef SPROUT_DARKROOM_TEXTURES_TEXTURE_HPP #define SPROUT_DARKROOM_TEXTURES_TEXTURE_HPP #include #include #include #include #include // // DARKROOM_LOAD_TEXTURE // #define DARKROOM_LOAD_TEXTURE // // DARKROOM_TEX_VERSION // #define DARKROOM_TEX_VERSION(NUM) NUM // // DARKROOM_TEX_IMAGE_DEFAULT // #define DARKROOM_TEX_IMAGE_DEFAULT 0 // // DARKROOM_TEX_PIXEL_INT_R8G8B8 // #define DARKROOM_TEX_PIXEL_INT_R8G8B8 0 namespace sprout { namespace darkroom { namespace textures { // // version_type // typedef unsigned long version_type; // // info_type // struct info_type { public: unsigned long image_format; unsigned long pixel_format; std::size_t width; std::size_t height; }; // // image_type // template struct image_type { public: typedef Color color_type; typedef color_type value_type; typedef std::size_t size_type; SPROUT_STATIC_CONSTEXPR size_type static_width = Width; SPROUT_STATIC_CONSTEXPR size_type static_height = Height; typedef sprout::array pixels_type; typedef typename sprout::darkroom::access::unit::type color_component_type; private: pixels_type pixels_; public: template SPROUT_CONSTEXPR image_type(unsigned long image_format, unsigned long pixel_format, Elems const&... elems) : pixels_{{ color_type( static_cast((elems >> 16) & 0xFF) / 0xFF, static_cast((elems >> 8) & 0xFF) / 0xFF, static_cast(elems & 0xFF) / 0xFF )... }} { static_assert(sizeof...(Elems) == static_width * static_height, "image_type<>: unmatch image size"); } SPROUT_CONSTEXPR value_type const& operator()(size_type x, size_type y) const { return pixels_[y * static_width + x]; } SPROUT_CONSTEXPR size_type width() const { return static_width; } SPROUT_CONSTEXPR size_type height() const { return static_height; } SPROUT_CONSTEXPR pixels_type const& pixels() const { return pixels_; } }; } // namespace textures } // namespace darkroom } // namespace sprout #endif // #ifndef SPROUT_DARKROOM_TEXTURES_TEXTURE_HPP