Skip to content

Commit 3fd1253

Browse files
authored
Merge pull request #212 from RobLoach/initializers
Clean up initializer lists
2 parents ed54fba + a32d084 commit 3fd1253

File tree

9 files changed

+19
-27
lines changed

9 files changed

+19
-27
lines changed

include/Color.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ namespace raylib {
1313
*/
1414
class Color : public ::Color {
1515
public:
16-
Color(const ::Color& color) {
17-
set(color);
18-
}
16+
Color(const ::Color& color) : ::Color{color.r, color.g, color.b, color.a} {}
1917

2018
Color(
2119
unsigned char red,

include/Matrix.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Matrix : public ::Matrix {
1919
set(mat);
2020
}
2121

22+
// TODO: Fix the ordering of the Matrix properties.
2223
Matrix(
2324
float m0 = 0, float m1 = 0, float m2 = 0, float m3 = 0, float m4 = 0, float m5 = 0,
2425
float m6 = 0, float m7 = 0, float m8 = 0, float m9 = 0, float m10 = 0, float m11 = 0,

include/Rectangle.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ namespace raylib {
1111
*/
1212
class Rectangle : public ::Rectangle {
1313
public:
14-
Rectangle(const ::Rectangle& vec) {
15-
set(vec);
16-
}
14+
Rectangle(const ::Rectangle& rect) : ::Rectangle{rect.x, rect.y, rect.width, rect.height} {}
1715

1816
Rectangle(float x, float y, float width, float height) : ::Rectangle{x, y, width, height} {}
1917
Rectangle(float x, float y, float width) : ::Rectangle{x, y, width, 0} {}

include/RenderTexture.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ class RenderTexture : public ::RenderTexture {
2222
set(renderTexture);
2323
}
2424

25-
RenderTexture(unsigned int id, ::Texture texture, ::Texture depth) : ::RenderTexture{id, texture, depth} {}
25+
RenderTexture(unsigned int id, const ::Texture& texture, const ::Texture& depth) : ::RenderTexture{id, texture, depth} {}
2626

27+
/**
28+
* Load texture for rendering (framebuffer)
29+
*/
2730
RenderTexture(int width, int height) {
28-
if (!Load(width, height)) {
29-
throw RaylibException("Failed to create RenderTexture");
30-
}
31+
set(::LoadRenderTexture(width, height));
3132
}
3233

3334
RenderTexture(const RenderTexture&) = delete;
@@ -91,11 +92,10 @@ class RenderTexture : public ::RenderTexture {
9192
}
9293

9394
/**
94-
* Loads a render texture at the given width and height.
95+
* Load texture for rendering (framebuffer)
9596
*/
96-
bool Load(int width, int height) {
97-
set(::LoadRenderTexture(width, height));
98-
return IsReady();
97+
static RenderTexture Load(int width, int height) {
98+
return ::LoadRenderTexture(width, height);
9999
}
100100

101101
/**

include/Texture.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ class Texture : public ::Texture {
3636
/**
3737
* Creates a texture object based on the given Texture struct data.
3838
*/
39-
Texture(const ::Texture& texture) {
40-
set(texture);
41-
}
39+
Texture(const ::Texture& texture) :
40+
::Texture{texture.id, texture.width, texture.height, texture.mipmaps, texture.format} {}
4241

4342
/**
4443
* Creates a texture from the given Image.

include/Vector2.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ namespace raylib {
1515
*/
1616
class Vector2 : public ::Vector2 {
1717
public:
18-
Vector2(const ::Vector2& vec) {
19-
set(vec);
20-
}
18+
Vector2(const ::Vector2& vec) : ::Vector2{vec.x, vec.y} {}
2119

2220
Vector2(float x, float y) : ::Vector2{x, y} {}
2321
Vector2(float x) : ::Vector2{x, 0} {}

include/Vector3.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ namespace raylib {
1515
*/
1616
class Vector3 : public ::Vector3 {
1717
public:
18-
Vector3(const ::Vector3& vec) {
19-
set(vec);
20-
}
18+
Vector3(const ::Vector3& vec) : ::Vector3{vec.x, vec.y, vec.z} {}
2119

2220
Vector3(float x, float y, float z) : ::Vector3{x, y, z} {}
2321
Vector3(float x, float y) : ::Vector3{x, y, 0} {}

include/Vector4.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ namespace raylib {
1616
*/
1717
class Vector4 : public ::Vector4 {
1818
public:
19-
Vector4(const ::Vector4& vec) {
20-
set(vec);
21-
}
19+
Vector4(const ::Vector4& vec) : ::Vector4{vec.x, vec.y, vec.z, vec.w} {}
2220

2321
Vector4(float x, float y, float z, float w) : ::Vector4{x, y, z, w} {}
2422
Vector4(float x, float y, float z) : ::Vector4{x, y, z, 0} {}

include/Window.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ class Window {
6262
* Close window and unload OpenGL context
6363
*/
6464
inline void Close() {
65-
::CloseWindow();
65+
if (::IsWindowReady()) {
66+
::CloseWindow();
67+
}
6668
}
6769

6870
/**

0 commit comments

Comments
 (0)