diff --git a/include/BoundingBox.hpp b/include/BoundingBox.hpp index 6d8354cb..9567ea35 100644 --- a/include/BoundingBox.hpp +++ b/include/BoundingBox.hpp @@ -33,6 +33,15 @@ class BoundingBox : public ::BoundingBox { return *this; } + [[nodiscard]] std::string ToString() const { + return TextFormat( + "BoundingBox(min=(%f, %f, %f), max=(%f, %f, %f))", + min.x, min.y, min.z, max.x, max.y, max.z + ); + } + + operator std::string() const { return ToString(); } + /** * Draw a bounding box with wires */ diff --git a/include/Camera3D.hpp b/include/Camera3D.hpp index 39018938..3baa1d0f 100644 --- a/include/Camera3D.hpp +++ b/include/Camera3D.hpp @@ -42,6 +42,17 @@ class Camera3D : public ::Camera3D { return *this; } + [[nodiscard]] std::string ToString() const { + return TextFormat( + "Camera3D(position=(%f, %f, %f), target=(%f, %f, %f), fovy=%f)", + position.x, position.y, position.z, + target.x, target.y, target.z, + fovy + ); + } + + operator std::string() const { return ToString(); } + /** * Initializes 3D mode with custom camera (3D) */ diff --git a/include/Image.hpp b/include/Image.hpp index 2d3224fc..2b1823ec 100644 --- a/include/Image.hpp +++ b/include/Image.hpp @@ -100,6 +100,10 @@ class Image : public ::Image { other.format = 0; } + [[nodiscard]] std::string ToString() const { return TextFormat("Image(width=%d, height=%d)", width, height); } + + operator std::string() const { return ToString(); } + static ::Image Text(const std::string& text, int fontSize, ::Color color = {255, 255, 255, 255}) { return ::ImageText(text.c_str(), fontSize, color); } diff --git a/include/Matrix.hpp b/include/Matrix.hpp index b6871e87..0035b5c1 100644 --- a/include/Matrix.hpp +++ b/include/Matrix.hpp @@ -81,6 +81,23 @@ class Matrix : public ::Matrix { constexpr bool operator!=(const ::Matrix& other) { return !(*this == other); } + [[nodiscard]] std::string ToString() const { + return TextFormat( + "Matrix(\n" + " %f, %f, %f, %f\n" + " %f, %f, %f, %f\n" + " %f, %f, %f, %f\n" + " %f, %f, %f, %f\n" + ")", + m0, m4, m8, m12, + m1, m5, m9, m13, + m2, m6, m10, m14, + m3, m7, m11, m15 + ); + } + + operator std::string() const { return ToString(); } + #ifndef RAYLIB_CPP_NO_MATH /** * Returns the trace of the matrix (sum of the values along the diagonal) diff --git a/include/MeshUnmanaged.hpp b/include/MeshUnmanaged.hpp index 4fce20e2..4fe1d286 100644 --- a/include/MeshUnmanaged.hpp +++ b/include/MeshUnmanaged.hpp @@ -139,6 +139,15 @@ class MeshUnmanaged : public ::Mesh { return *this; } + [[nodiscard]] std::string ToString() const { + return TextFormat( + "Mesh(vertexCount=%d, triangleCount=%d, boneCount=%d)", + vertexCount, triangleCount, boneCount + ); + } + + operator std::string() const { return ToString(); } + /** * Unload mesh from memory (RAM and/or VRAM) */ diff --git a/include/ModelUnmanaged.hpp b/include/ModelUnmanaged.hpp index 3c0cbd3b..db627019 100644 --- a/include/ModelUnmanaged.hpp +++ b/include/ModelUnmanaged.hpp @@ -59,6 +59,10 @@ class ModelUnmanaged : public ::Model { return *this; } + [[nodiscard]] std::string ToString() const { return TextFormat("Model(meshCount=%d, materialCount=%d)", meshCount, materialCount); } + + operator std::string() const { return ToString(); } + /** * Loads a Model from the given file. * diff --git a/include/MusicUnmanaged.hpp b/include/MusicUnmanaged.hpp index 4b8cee43..def525db 100644 --- a/include/MusicUnmanaged.hpp +++ b/include/MusicUnmanaged.hpp @@ -60,6 +60,10 @@ class MusicUnmanaged : public ::Music { return *this; } + [[nodiscard]] std::string ToString() const { return TextFormat("Music(frameCount=%u, looping=%s)", frameCount, looping ? "true" : "false"); } + + operator std::string() const { return ToString(); } + /** * Load music stream from file. * diff --git a/include/RayCollision.hpp b/include/RayCollision.hpp index 5595cdba..ad10cad2 100644 --- a/include/RayCollision.hpp +++ b/include/RayCollision.hpp @@ -62,6 +62,18 @@ class RayCollision : public ::RayCollision { return *this; } + [[nodiscard]] std::string ToString() const { + return TextFormat( + "RayCollision(hit=%s, distance=%f, point=(%f, %f, %f), normal=(%f, %f, %f))", + hit ? "true" : "false", + distance, + point.x, point.y, point.z, + normal.x, normal.y, normal.z + ); + } + + operator std::string() const { return ToString(); } + GETTERSETTER(bool, Hit, hit) GETTERSETTER(float, Distance, distance) GETTERSETTER(::Vector3, Position, point) diff --git a/include/Rectangle.hpp b/include/Rectangle.hpp index 5056920e..9c217ebb 100644 --- a/include/Rectangle.hpp +++ b/include/Rectangle.hpp @@ -33,6 +33,10 @@ class Rectangle : public ::Rectangle { constexpr explicit operator ::Vector4() const { return {x, y, width, height}; } + [[nodiscard]] std::string ToString() const { return TextFormat("Rectangle(%fx%f, %fx%f)", x, y, width, height); } + + operator std::string() const { return ToString(); } + /** * Draw a color-filled rectangle */ diff --git a/include/RenderTextureUnmanaged.hpp b/include/RenderTextureUnmanaged.hpp index 7894564e..82083c5e 100644 --- a/include/RenderTextureUnmanaged.hpp +++ b/include/RenderTextureUnmanaged.hpp @@ -38,6 +38,10 @@ class RenderTextureUnmanaged : public ::RenderTexture { */ RenderTextureUnmanaged(int width, int height) { Load(width, height); } + [[nodiscard]] std::string ToString() const { return TextFormat("RenderTexture(id=%u)", id); } + + operator std::string() const { return ToString(); } + GETTER(unsigned int, Id, id) /** diff --git a/include/ShaderUnmanaged.hpp b/include/ShaderUnmanaged.hpp index d32fb2da..c8c36555 100644 --- a/include/ShaderUnmanaged.hpp +++ b/include/ShaderUnmanaged.hpp @@ -57,6 +57,10 @@ class ShaderUnmanaged : public ::Shader { return *this; } + [[nodiscard]] std::string ToString() const { return TextFormat("Shader(id=%u)", id); } + + operator std::string() const { return ToString(); } + /** * Begin custom shader drawing. */ diff --git a/include/SoundUnmanaged.hpp b/include/SoundUnmanaged.hpp index 3ea632dc..fa5b3090 100644 --- a/include/SoundUnmanaged.hpp +++ b/include/SoundUnmanaged.hpp @@ -54,6 +54,10 @@ class SoundUnmanaged : public ::Sound { return *this; } + [[nodiscard]] std::string ToString() const { return TextFormat("Sound(frameCount=%u)", frameCount); } + + operator std::string() const { return ToString(); } + /** * Load a sound from the given file. * diff --git a/include/TextureUnmanaged.hpp b/include/TextureUnmanaged.hpp index fa65431f..ef5cbbdb 100644 --- a/include/TextureUnmanaged.hpp +++ b/include/TextureUnmanaged.hpp @@ -86,6 +86,10 @@ class TextureUnmanaged : public ::Texture { return *this; } + [[nodiscard]] std::string ToString() const { return TextFormat("Texture(id=%u, %dx%d)", id, width, height); } + + operator std::string() const { return ToString(); } + /** * Retrieve the width and height of the texture. */ diff --git a/include/WaveUnmanaged.hpp b/include/WaveUnmanaged.hpp index 711294a0..763047d1 100644 --- a/include/WaveUnmanaged.hpp +++ b/include/WaveUnmanaged.hpp @@ -60,6 +60,15 @@ class WaveUnmanaged : public ::Wave { return *this; } + [[nodiscard]] std::string ToString() const { + return TextFormat( + "Wave(frameCount=%u, sampleRate=%u, sampleSize=%u, channels=%u, data=%p)", + frameCount, sampleRate, sampleSize, channels, data + ); + } + + operator std::string() const { return ToString(); } + /** * Load wave data from file. * diff --git a/include/Window.hpp b/include/Window.hpp index 845e12b2..322c9022 100644 --- a/include/Window.hpp +++ b/include/Window.hpp @@ -46,6 +46,10 @@ class Window { */ ~Window() { Close(); } + [[nodiscard]] std::string ToString() const { return TextFormat("Window(%dx%d)", GetWidth(), GetHeight()); } + + operator std::string() const { return ToString(); } + /** * Initializes the window. *