* A RenderTexture that is not managed by C++ RAII. * * Make sure to Unload() this if needed, otherwise use raylib::RenderTexture. * * @see raylib::RenderTexture */
| 14 | * @see raylib::RenderTexture |
| 15 | */ |
| 16 | class RenderTextureUnmanaged : public ::RenderTexture { |
| 17 | public: |
| 18 | /** |
| 19 | * Default constructor to build an empty RenderTexture. |
| 20 | */ |
| 21 | RenderTextureUnmanaged() : ::RenderTexture{0, {}, {}} {} |
| 22 | |
| 23 | /** |
| 24 | * Creates a RenderTexture from an existing RenderTexture struct. |
| 25 | */ |
| 26 | RenderTextureUnmanaged(const ::RenderTexture& renderTexture) : ::RenderTexture(renderTexture) {} |
| 27 | |
| 28 | /** |
| 29 | * Creates a RenderTexture from its components. |
| 30 | */ |
| 31 | RenderTextureUnmanaged(unsigned int id, const ::Texture& texture, const ::Texture& depth) |
| 32 | : ::RenderTexture{id, texture, depth} {} |
| 33 | |
| 34 | /** |
| 35 | * Load texture for rendering (framebuffer). |
| 36 | * |
| 37 | * @throws raylib::RaylibException Throws if failed to create the render texture. |
| 38 | */ |
| 39 | RenderTextureUnmanaged(int width, int height) { Load(width, height); } |
| 40 | |
| 41 | [[nodiscard]] std::string ToString() const { return TextFormat("RenderTexture(id=%u)", id); } |
| 42 | |
| 43 | operator std::string() const { return ToString(); } |
| 44 | |
| 45 | GETTER(unsigned int, Id, id) |
| 46 | |
| 47 | /** |
| 48 | * Get the color buffer attachment texture. |
| 49 | */ |
| 50 | TextureUnmanaged GetTexture() { return texture; } |
| 51 | RLCPP_NODISCARD TextureUnmanaged GetTexture() const { return texture; } |
| 52 | void SetTexture(const ::Texture& newTexture) { texture = newTexture; } |
| 53 | |
| 54 | /** |
| 55 | * Get the depth buffer attachment texture. |
| 56 | */ |
| 57 | TextureUnmanaged GetDepth() { return depth; } |
| 58 | void SetDepth(const ::Texture& newDepth) { depth = newDepth; } |
| 59 | |
| 60 | RenderTextureUnmanaged& operator=(const ::RenderTexture& other) { |
| 61 | set(other); |
| 62 | return *this; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Load texture for rendering (framebuffer). |
| 67 | * |
| 68 | * @throws raylib::RaylibException Throws if failed to create the render texture. |
| 69 | */ |
| 70 | void Load(int width, int height) { |
| 71 | set(::LoadRenderTexture(width, height)); |
| 72 | if (!IsValid()) { |
| 73 | throw RaylibException("Failed to create RenderTexture"); |
nothing calls this directly
no outgoing calls
no test coverage detected