Merge pull request #212 from RobLoach/initializers

Clean up initializer lists
This commit is contained in:
Rob Loach
2022-08-30 02:06:23 -04:00
committed by GitHub
9 changed files with 19 additions and 27 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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} {}

View File

@@ -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);
}
/**

View File

@@ -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.

View File

@@ -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} {}

View File

@@ -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} {}

View File

@@ -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} {}

View File

@@ -62,7 +62,9 @@ class Window {
* Close window and unload OpenGL context
*/
inline void Close() {
::CloseWindow();
if (::IsWindowReady()) {
::CloseWindow();
}
}
/**