diff --git a/include/Color.hpp b/include/Color.hpp index 02fd6e2..48213a3 100644 --- a/include/Color.hpp +++ b/include/Color.hpp @@ -13,9 +13,7 @@ namespace raylib { */ class Color : public ::Color { public: - Color(const ::Color& color) { - set(color); - } + Color(const ::Color& color) : ::Color{color.r, color.g, color.b, color.a} {} Color( unsigned char red, diff --git a/include/Matrix.hpp b/include/Matrix.hpp index 6767b87..c35e357 100644 --- a/include/Matrix.hpp +++ b/include/Matrix.hpp @@ -19,6 +19,7 @@ class Matrix : public ::Matrix { set(mat); } + // TODO: Fix the ordering of the Matrix properties. Matrix( float m0 = 0, float m1 = 0, float m2 = 0, float m3 = 0, float m4 = 0, float m5 = 0, float m6 = 0, float m7 = 0, float m8 = 0, float m9 = 0, float m10 = 0, float m11 = 0, diff --git a/include/Rectangle.hpp b/include/Rectangle.hpp index 80fb8a4..f9ea3f7 100644 --- a/include/Rectangle.hpp +++ b/include/Rectangle.hpp @@ -11,9 +11,7 @@ namespace raylib { */ class Rectangle : public ::Rectangle { public: - Rectangle(const ::Rectangle& vec) { - set(vec); - } + Rectangle(const ::Rectangle& rect) : ::Rectangle{rect.x, rect.y, rect.width, rect.height} {} Rectangle(float x, float y, float width, float height) : ::Rectangle{x, y, width, height} {} Rectangle(float x, float y, float width) : ::Rectangle{x, y, width, 0} {} diff --git a/include/RenderTexture.hpp b/include/RenderTexture.hpp index 8d1fe11..56ed977 100644 --- a/include/RenderTexture.hpp +++ b/include/RenderTexture.hpp @@ -22,12 +22,13 @@ class RenderTexture : public ::RenderTexture { set(renderTexture); } - RenderTexture(unsigned int id, ::Texture texture, ::Texture depth) : ::RenderTexture{id, texture, depth} {} + RenderTexture(unsigned int id, const ::Texture& texture, const ::Texture& depth) : ::RenderTexture{id, texture, depth} {} + /** + * Load texture for rendering (framebuffer) + */ RenderTexture(int width, int height) { - if (!Load(width, height)) { - throw RaylibException("Failed to create RenderTexture"); - } + set(::LoadRenderTexture(width, height)); } RenderTexture(const RenderTexture&) = delete; @@ -91,11 +92,10 @@ class RenderTexture : public ::RenderTexture { } /** - * Loads a render texture at the given width and height. + * Load texture for rendering (framebuffer) */ - bool Load(int width, int height) { - set(::LoadRenderTexture(width, height)); - return IsReady(); + static RenderTexture Load(int width, int height) { + return ::LoadRenderTexture(width, height); } /** diff --git a/include/Texture.hpp b/include/Texture.hpp index 6cfea3c..1a2c32b 100644 --- a/include/Texture.hpp +++ b/include/Texture.hpp @@ -36,9 +36,8 @@ class Texture : public ::Texture { /** * Creates a texture object based on the given Texture struct data. */ - Texture(const ::Texture& texture) { - set(texture); - } + Texture(const ::Texture& texture) : + ::Texture{texture.id, texture.width, texture.height, texture.mipmaps, texture.format} {} /** * Creates a texture from the given Image. diff --git a/include/Vector2.hpp b/include/Vector2.hpp index fe954ab..0840103 100644 --- a/include/Vector2.hpp +++ b/include/Vector2.hpp @@ -15,9 +15,7 @@ namespace raylib { */ class Vector2 : public ::Vector2 { public: - Vector2(const ::Vector2& vec) { - set(vec); - } + Vector2(const ::Vector2& vec) : ::Vector2{vec.x, vec.y} {} Vector2(float x, float y) : ::Vector2{x, y} {} Vector2(float x) : ::Vector2{x, 0} {} diff --git a/include/Vector3.hpp b/include/Vector3.hpp index 7ee3fd3..8a3c9d4 100644 --- a/include/Vector3.hpp +++ b/include/Vector3.hpp @@ -15,9 +15,7 @@ namespace raylib { */ class Vector3 : public ::Vector3 { public: - Vector3(const ::Vector3& vec) { - set(vec); - } + Vector3(const ::Vector3& vec) : ::Vector3{vec.x, vec.y, vec.z} {} Vector3(float x, float y, float z) : ::Vector3{x, y, z} {} Vector3(float x, float y) : ::Vector3{x, y, 0} {} diff --git a/include/Vector4.hpp b/include/Vector4.hpp index 57e3cb2..9333612 100644 --- a/include/Vector4.hpp +++ b/include/Vector4.hpp @@ -16,9 +16,7 @@ namespace raylib { */ class Vector4 : public ::Vector4 { public: - Vector4(const ::Vector4& vec) { - set(vec); - } + Vector4(const ::Vector4& vec) : ::Vector4{vec.x, vec.y, vec.z, vec.w} {} Vector4(float x, float y, float z, float w) : ::Vector4{x, y, z, w} {} Vector4(float x, float y, float z) : ::Vector4{x, y, z, 0} {} diff --git a/include/Window.hpp b/include/Window.hpp index 7acf428..0628f32 100644 --- a/include/Window.hpp +++ b/include/Window.hpp @@ -62,7 +62,9 @@ class Window { * Close window and unload OpenGL context */ inline void Close() { - ::CloseWindow(); + if (::IsWindowReady()) { + ::CloseWindow(); + } } /**