1 /* 2 * Modern effects for a modern Streamer 3 * Copyright (C) 2017 Michael Fabian Dirks 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 */ 19 20 #pragma once 21 #include "common.hpp" 22 23 namespace gs { 24 class texture { 25 public: 26 enum class type : uint8_t { Normal, Volume, Cube }; 27 28 enum class flags : uint8_t { 29 None, 30 Dynamic, 31 BuildMipMaps, 32 }; 33 34 protected: 35 gs_texture_t* _texture; 36 bool _is_owner = true; 37 type _type = type::Normal; 38 39 public: 40 ~texture(); 41 42 /*! 43 * \brief Create a 2D Texture 44 * 45 * \param width Width of the 2D Texture 46 * \param height Height of the 2D Texture 47 * \param format Color Format to use 48 * \param mip_levels Number of Mip Levels available 49 * \param mip_data Texture data including mipmaps 50 * \param texture_flags Texture Flags 51 */ 52 texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels, const uint8_t** mip_data, 53 gs::texture::flags texture_flags); 54 55 /*! 56 * \brief Create a 3D Texture 57 * 58 * \param width Width of the 3D Texture 59 * \param height Height of the 3D Texture 60 * \param depth Depth of the 3D Texture 61 * \param format Color Format to use 62 * \param mip_levels Number of Mip Levels available 63 * \param mip_data Texture data including mipmaps 64 * \param texture_flags Texture Flags 65 */ 66 texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, uint32_t mip_levels, 67 const uint8_t** mip_data, gs::texture::flags texture_flags); 68 69 /*! 70 * \brief Create a Cube Texture 71 * 72 * \param size Size of each Cube Maps face 73 * \param format Color Format to use 74 * \param mip_levels Number of Mip Levels available 75 * \param mip_data Texture data including mipmaps 76 * \param texture_flags Texture Flags 77 */ 78 texture(uint32_t size, gs_color_format format, uint32_t mip_levels, const uint8_t** mip_data, 79 gs::texture::flags texture_flags); 80 81 /*! 82 * \brief Load a texture from a file 83 * 84 * Creates a new #GS::Texture from a file located on disk. If the 85 * file can not be found, accessed or read, a #Plugin::file_not_found_error 86 * will be thrown. If there is an error reading the file, a 87 * #Plugin::io_error will be thrown. 88 * 89 * \param file File to create the texture from. 90 */ 91 texture(std::string file); 92 93 /*! 94 * \brief Create a texture from an existing gs_texture_t object. 95 */ texture(gs_texture_t * tex,bool takeOwnership=false)96 texture(gs_texture_t* tex, bool takeOwnership = false) : _texture(tex), _is_owner(takeOwnership) {} 97 98 void load(int32_t unit); 99 100 gs_texture_t* get_object(); 101 102 uint32_t get_width(); 103 104 uint32_t get_height(); 105 106 uint32_t get_depth(); 107 108 gs::texture::type get_type(); 109 110 gs_color_format get_color_format(); 111 }; 112 } // namespace gs 113 114 P_ENABLE_BITMASK_OPERATORS(gs::texture::flags) 115