// ===================================================================================================================== // glw, an open-source library that wraps OpenGL structures into classes. // Copyright (C) 2024 Medusa Slockbower // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // ===================================================================================================================== #ifndef GLW_TEXTURE_ARRAY_H #define GLW_TEXTURE_ARRAY_H #include "common.h" #include "texture.h" namespace glw { template class texarray { // Constants =========================================================================================================== public: inline static constexpr enum_t type = T_; inline static constexpr size_t length = sizeof...(Fs_); private: using array_type = std::tuple...>; // Functions =========================================================================================================== // Helpers template void resize_(size_t size) { get().resize(size); if constexpr (I < length - 1) resize_(size); } template void resize_(glm::ivec2 size) { get().resize(size); if constexpr (I < length - 1) resize_(size); } template void resize_(glm::ivec2 size, size_t samples) { get().resize(size); if constexpr (I < length - 1) resize_(size, samples); } template void resize_(glm::ivec3 size) { get().resize(size); if constexpr (I < length - 1) resize_(size); } template void resize_(glm::ivec3 size, size_t samples) { get().resize(size); if constexpr (I < length - 1) resize_(size, samples); } public: texarray(size_t size) : array_(texture{ size }...) { } texarray(glm::ivec2 size) : array_(texture{ size }...) { } texarray(glm::ivec2 size, size_t samples) : array_(texture{ size, samples }...) { } texarray(glm::ivec3 size) : array_(texture{ size }...) { } texarray(glm::ivec3 size, size_t samples) : array_(texture{ size, samples }...) { } void resize(size_t size) { resize_(size); } void resize(glm::ivec2 size) { resize_(size); } void resize(glm::ivec2 size, size_t samples) { resize_(size, samples); } void resize(glm::ivec3 size) { resize_(size); } void resize(glm::ivec3 size, size_t samples) { resize_(size, samples); } // Variables =========================================================================================================== template constexpr std::tuple_element_t<_Index, array_type>& get() noexcept { return std::get<_Index>(array_); } template constexpr const std::tuple_element_t<_Index, array_type>& get() const noexcept { return std::get<_Index>(array_); } private: array_type array_; }; } #endif //TEXTURE_ARRAY_H