@@ -14,16 +14,19 @@ namespace raylib {
1414 * Texture type
1515 */
1616class Texture : public ::Texture {
17- public:
17+ public:
1818 /* *
19- * Default constructor to create an empty Texture object .
19+ * Default texture constructor .
2020 */
21- Texture (unsigned int id = 0 ,
22- int width = 0 ,
23- int height = 0 ,
24- int mipmaps = 0 ,
25- int format = 0 ) : ::Texture{id, width, height, mipmaps, format} {
26- // Nothing.
21+ Texture () {
22+ set (::Texture{0 , 0 , 0 , 0 , 0 });
23+ }
24+
25+ /* *
26+ * Move/Create a texture structure manually.
27+ */
28+ Texture (unsigned int id, int width, int height, int mipmaps, int format) {
29+ set (::Texture{id, width, height, mipmaps, format});
2730 }
2831
2932 /* *
@@ -39,9 +42,7 @@ class Texture : public ::Texture {
3942 * @throws raylib::RaylibException Throws if failed to create the texture from the given image.
4043 */
4144 Texture (const ::Image& image) {
42- if (!Load (image)) {
43- throw RaylibException (" Failed to load Texture from Image" );
44- }
45+ Load (image);
4546 }
4647
4748 /* *
@@ -52,9 +53,7 @@ class Texture : public ::Texture {
5253 * @see LoadTextureCubemap()
5354 */
5455 Texture (const ::Image& image, int layout) {
55- if (!Load (image, layout)) {
56- throw RaylibException (" Failed to load Texture from Cubemap" );
57- }
56+ Load (image, layout);
5857 }
5958
6059 /* *
@@ -63,9 +62,7 @@ class Texture : public ::Texture {
6362 * @throws raylib::RaylibException Throws if failed to create the texture from the given file.
6463 */
6564 Texture (const std::string& fileName) {
66- if (!Load (fileName)) {
67- throw RaylibException (TextFormat (" Failed to load Texture from file: %s" , fileName.c_str ()));
68- }
65+ Load (fileName);
6966 }
7067
7168 Texture (const Texture&) = delete ;
@@ -124,25 +121,31 @@ class Texture : public ::Texture {
124121 /* *
125122 * Load texture from image data
126123 */
127- bool Load (const ::Image& image) {
124+ void Load (const ::Image& image) {
128125 set (::LoadTextureFromImage (image));
129- return IsReady ();
126+ if (!IsReady ()) {
127+ throw RaylibException (" Failed to load Texture from Image" );
128+ }
130129 }
131130
132131 /* *
133132 * Load cubemap from image, multiple image cubemap layouts supported
134133 */
135- bool Load (const ::Image& image, int layoutType) {
134+ void Load (const ::Image& image, int layoutType) {
136135 set (::LoadTextureCubemap (image, layoutType));
137- return IsReady ();
136+ if (!IsReady ()) {
137+ throw RaylibException (" Failed to load Texture from Cubemap" );
138+ }
138139 }
139140
140141 /* *
141142 * Load texture from file into GPU memory (VRAM)
142143 */
143- bool Load (const std::string& fileName) {
144+ void Load (const std::string& fileName) {
144145 set (::LoadTexture (fileName.c_str ()));
145- return IsReady ();
146+ if (!IsReady ()) {
147+ throw RaylibException (" Failed to load Texture from file: " + fileName);
148+ }
146149 }
147150
148151 /* *
@@ -306,7 +309,7 @@ class Texture : public ::Texture {
306309 return id != 0 ;
307310 }
308311
309- private:
312+ private:
310313 void set (const ::Texture& texture) {
311314 id = texture.id ;
312315 width = texture.width ;
0 commit comments