raylib-cpp
C++ object-oriented wrapper library for raylib.
Loading...
Searching...
No Matches
RenderTexture.hpp
1#ifndef RAYLIB_CPP_INCLUDE_RENDERTEXTURE_HPP_
2#define RAYLIB_CPP_INCLUDE_RENDERTEXTURE_HPP_
3
4#include "./raylib.hpp"
5#include "./raylib-cpp-utils.hpp"
6#include "./RaylibException.hpp"
7#include "./TextureUnmanaged.hpp"
8
9namespace raylib {
13class RenderTexture : public ::RenderTexture {
14 public:
19 id = 0;
20 }
21
22 RenderTexture(const ::RenderTexture& renderTexture) {
23 set(renderTexture);
24 }
25
26 RenderTexture(unsigned int id, const ::Texture& texture, const ::Texture& depth) :
27 ::RenderTexture{id, texture, depth} {}
28
32 RenderTexture(int width, int height) {
33 set(::LoadRenderTexture(width, height));
34 }
35
36 RenderTexture(const RenderTexture&) = delete;
37
39 set(other);
40
41 other.id = 0;
42 other.texture = {};
43 other.depth = {};
44 }
45
46 GETTER(unsigned int, Id, id)
47
48
52 return texture;
53 }
54
55 void SetTexture(const ::Texture& newTexture) {
56 texture = newTexture;
57 }
58
63 return depth;
64 }
65
66 void SetDepth(const ::Texture& newDepth) {
67 depth = newDepth;
68 }
69
70 RenderTexture& operator=(const ::RenderTexture& texture) {
71 set(texture);
72 return *this;
73 }
74
75 RenderTexture& operator=(const RenderTexture&) = delete;
76
77 RenderTexture& operator=(RenderTexture&& other) noexcept {
78 if (this == &other) {
79 return *this;
80 }
81
82 Unload();
83 set(other);
84
85 other.id = 0;
86 other.texture = {};
87 other.depth = {};
88
89 return *this;
90 }
91
92 ~RenderTexture() {
93 Unload();
94 }
95
96 void Unload() {
97 UnloadRenderTexture(*this);
98 }
99
104 ::BeginTextureMode(*this);
105 return *this;
106 }
107
112 ::EndTextureMode();
113 return *this;
114 }
115
119 static RenderTexture Load(int width, int height) {
120 return ::LoadRenderTexture(width, height);
121 }
122
126 bool IsReady() const {
127 return ::IsRenderTextureReady(*this);
128 }
129
130 protected:
131 void set(const ::RenderTexture& renderTexture) {
132 id = renderTexture.id;
133 texture = renderTexture.texture;
134 depth = renderTexture.depth;
135 }
136};
137
138using RenderTexture2D = RenderTexture;
139
140} // namespace raylib
141
144
145#endif // RAYLIB_CPP_INCLUDE_RENDERTEXTURE_HPP_
RenderTexture type, for texture rendering.
TextureUnmanaged GetTexture()
Get the color buffer attachment texture.
bool IsReady() const
Retrieves whether or not the render texture is ready.
RenderTexture & BeginMode()
Initializes render texture for drawing.
RenderTexture & EndMode()
Ends drawing to render texture.
TextureUnmanaged GetDepth()
Depth buffer attachment texture.
RenderTexture()
Default constructor to build an empty RenderTexture.
static RenderTexture Load(int width, int height)
Load texture for rendering (framebuffer)
RenderTexture(int width, int height)
Load texture for rendering (framebuffer)
A Texture that is not managed by C++ RAII.