diff --git a/include/AudioStream.hpp b/include/AudioStream.hpp index 5b8a854..f80613d 100644 --- a/include/AudioStream.hpp +++ b/include/AudioStream.hpp @@ -21,6 +21,17 @@ class AudioStream : public ::AudioStream { set(InitAudioStream(SampleRate, SampleSize, Channels)); } + AudioStream(const AudioStream&) = delete; + + AudioStream(AudioStream&& other) { + set(other); + + other.buffer = nullptr; + other.sampleRate = 0; + other.sampleSize = 0; + other.channels = 0; + } + ~AudioStream() { Close(); } @@ -35,6 +46,24 @@ class AudioStream : public ::AudioStream { return *this; } + AudioStream& operator=(const AudioStream&) = delete; + + AudioStream& operator=(AudioStream&& other) { + if (this == &other) { + return *this; + } + + Close(); + set(other); + + other.buffer = nullptr; + other.sampleRate = 0; + other.sampleSize = 0; + other.channels = 0; + + return *this; + } + /** * Update audio stream buffers with data */ diff --git a/include/Font.hpp b/include/Font.hpp index ca78251..81d2a2d 100644 --- a/include/Font.hpp +++ b/include/Font.hpp @@ -38,6 +38,19 @@ class Font : public ::Font { charsCount)); } + Font(const Font&) = delete; + + Font(Font&& other) { + set(other); + + other.baseSize = 0; + other.charsCount = 0; + other.charsPadding = 0; + other.texture = { 0 }; + other.recs = nullptr; + other.chars = nullptr; + } + ~Font() { Unload(); } @@ -58,6 +71,26 @@ class Font : public ::Font { return *this; } + Font& operator=(const Font&) = delete; + + Font& operator=(Font&& other) { + if (this == &other) { + return *this; + } + + Unload(); + set(other); + + other.baseSize = 0; + other.charsCount = 0; + other.charsPadding = 0; + other.texture = { 0 }; + other.recs = nullptr; + other.chars = nullptr; + + return *this; + } + /** * Draw text using font and additional parameters. */ diff --git a/include/Image.hpp b/include/Image.hpp index 53eaf59..eea3879 100644 --- a/include/Image.hpp +++ b/include/Image.hpp @@ -47,6 +47,20 @@ class Image : public ::Image { set(::ImageTextEx(font, text.c_str(), fontSize, spacing, tint)); } + Image(const Image& other) { + set(other.Copy()); + } + + Image(Image&& other) { + set(other); + + other.data = nullptr; + other.width = 0; + other.height = 0; + other.mipmaps = 0; + other.format = 0; + } + static ::Image Text(const std::string& text, int fontSize, ::Color color = {255, 255, 255, 255}) { return ::ImageText(text.c_str(), fontSize, color); @@ -132,6 +146,32 @@ class Image : public ::Image { return *this; } + Image& operator=(const Image& other) { + if (this == &other) { + return *this; + } + + Unload(); + set(other.Copy()); + } + + Image& operator=(Image&& other) { + if (this == &other) { + return *this; + } + + Unload(); + set(other); + + other.data = nullptr; + other.width = 0; + other.height = 0; + other.mipmaps = 0; + other.format = 0; + + return *this; + } + /** * Load image from file into CPU memory (RAM) */ diff --git a/include/Material.hpp b/include/Material.hpp index f46ed92..aad7da4 100644 --- a/include/Material.hpp +++ b/include/Material.hpp @@ -24,6 +24,15 @@ class Material : public ::Material { set(LoadMaterialDefault()); } + Material(const Material&) = delete; + + Material(Material&& other) { + set(other); + + other.maps = nullptr; + other.shader = { 0 }; + } + ~Material() { Unload(); } @@ -33,6 +42,7 @@ class Material : public ::Material { */ static std::vector Load(const std::string& fileName) { int count = 0; + // this function possibly leaks the materials array ::Material* materials = ::LoadMaterials(fileName.c_str(), &count); return std::vector(materials, materials + count); } @@ -47,6 +57,22 @@ class Material : public ::Material { return *this; } + Material& operator=(const Material&) = delete; + + Material& operator=(Material&& other) { + if (this != &other) { + return *this; + } + + Unload(); + set(other); + + other.maps = nullptr; + other.shader = { 0 }; + + return *this; + } + /** * Unload material from memory */ diff --git a/include/Mesh.hpp b/include/Mesh.hpp index 1069e10..4c1dc22 100644 --- a/include/Mesh.hpp +++ b/include/Mesh.hpp @@ -30,6 +30,28 @@ class Mesh : public ::Mesh { // return std::vector(meshes, meshes + count); // } + Mesh(const Mesh&) = delete; + + Mesh(Mesh&& other) { + set(other); + + other.vertexCount = 0; + other.triangleCount = 0; + other.vertices = nullptr; + other.texcoords = nullptr; + other.texcoords2 = nullptr; + other.normals = nullptr; + other.tangents = nullptr; + other.colors = nullptr; + other.indices = nullptr; + other.animVertices = nullptr; + other.animNormals = nullptr; + other.boneIds = nullptr; + other.boneWeights = nullptr; + other.vaoId = 0; + other.vboId = nullptr; + } + /** * Generate polygonal mesh */ @@ -121,6 +143,35 @@ class Mesh : public ::Mesh { return *this; } + Mesh& operator=(const Mesh&) = delete; + + Mesh& operator=(Mesh&& other) { + if (this != &other) { + return *this; + } + + Unload(); + set(other); + + other.vertexCount = 0; + other.triangleCount = 0; + other.vertices = nullptr; + other.texcoords = nullptr; + other.texcoords2 = nullptr; + other.normals = nullptr; + other.tangents = nullptr; + other.colors = nullptr; + other.indices = nullptr; + other.animVertices = nullptr; + other.animNormals = nullptr; + other.boneIds = nullptr; + other.boneWeights = nullptr; + other.vaoId = 0; + other.vboId = nullptr; + + return *this; + } + ~Mesh() { Unload(); } diff --git a/include/Model.hpp b/include/Model.hpp index f4b5e60..185295e 100644 --- a/include/Model.hpp +++ b/include/Model.hpp @@ -29,6 +29,20 @@ class Model : public ::Model { Unload(); } + Model(const Model&) = delete; + + Model(Model&& other) { + set(other); + + other.bones = nullptr; + other.boneCount = 0; + other.materials = nullptr; + other.materialCount = 0; + other.meshes = nullptr; + other.meshCount = 0; + other.bindPose = nullptr; + } + GETTERSETTER(::Matrix, Transform, transform) GETTERSETTER(int, MeshCount, meshCount) GETTERSETTER(int, MaterialCount, materialCount) @@ -44,6 +58,27 @@ class Model : public ::Model { return *this; } + Model& operator=(const Model&) = delete; + + Model& operator=(Model&& other) { + if (this != &other) { + return *this; + } + + Unload(); + set(other); + + other.bones = nullptr; + other.boneCount = 0; + other.materials = nullptr; + other.materialCount = 0; + other.meshes = nullptr; + other.meshCount = 0; + other.bindPose = nullptr; + + return *this; + } + /** * Unload model (including meshes) from memory (RAM and/or VRAM) */ diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index 1f57062..fd24b03 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -18,6 +18,17 @@ class ModelAnimation : public ::ModelAnimation { set(model); } + ModelAnimation(const ModelAnimation&) = delete; + + ModelAnimation(ModelAnimation&& other) { + set(other); + + other.boneCount = 0; + other.bones = nullptr; + other.frameCount = 0; + other.framePoses = nullptr; + } + ~ModelAnimation() { Unload(); } @@ -41,6 +52,23 @@ class ModelAnimation : public ::ModelAnimation { return *this; } + + ModelAnimation& operator=(const ModelAnimation&) = delete; + + ModelAnimation& operator=(ModelAnimation&& other) { + if (this != &other) { + return *this; + } + + Unload(); + set(other); + + other.boneCount = 0; + other.bones = nullptr; + other.frameCount = 0; + other.framePoses = nullptr; + } + /** * Unload animation data */ diff --git a/include/Music.hpp b/include/Music.hpp index 0bd10f7..896159d 100644 --- a/include/Music.hpp +++ b/include/Music.hpp @@ -30,6 +30,18 @@ class Music : public ::Music { set(::LoadMusicStreamFromMemory(fileType.c_str(), data, dataSize)); } + Music(const Music&) = delete; + + Music(Music&& other) { + set(other); + + other.ctxType = 0; + other.ctxData = nullptr; + other.looping = false; + other.sampleCount = 0; + other.stream = { 0 }; + } + /** * Unload music stream */ @@ -48,6 +60,25 @@ class Music : public ::Music { return *this; } + Music& operator=(const Music&) = delete; + + Music& operator=(Music&& other) { + if (this == &other) { + return *this; + } + + Unload(); + set(other); + + other.ctxType = 0; + other.ctxData = nullptr; + other.looping = false; + other.sampleCount = 0; + other.stream = { 0 }; + + return *this; + } + /** * Unload music stream */ diff --git a/include/RenderTexture.hpp b/include/RenderTexture.hpp index 7af647a..7df17a8 100644 --- a/include/RenderTexture.hpp +++ b/include/RenderTexture.hpp @@ -20,6 +20,16 @@ class RenderTexture : public ::RenderTexture { set(LoadRenderTexture(width, height)); } + RenderTexture(const RenderTexture&) = delete; + + RenderTexture(RenderTexture&& other) { + set(other); + + other.id = 0; + other.texture = { 0 }; + other.depth = { 0 }; + } + GETTERSETTER(unsigned int, Id, id) GETTERSETTER(::Texture2D, Texture, texture) GETTERSETTER(::Texture2D, Depth, depth) @@ -29,6 +39,23 @@ class RenderTexture : public ::RenderTexture { return *this; } + RenderTexture& operator=(const RenderTexture&) = delete; + + RenderTexture& operator=(RenderTexture&& other) { + if (this == &other) { + return *this; + } + + Unload(); + set(other); + + other.id = 0; + other.texture = { 0 }; + other.depth = { 0 }; + + return *this; + } + ~RenderTexture() { Unload(); } diff --git a/include/Shader.hpp b/include/Shader.hpp index 594b300..f53304f 100644 --- a/include/Shader.hpp +++ b/include/Shader.hpp @@ -23,6 +23,15 @@ class Shader : public ::Shader { set(::LoadShader(vsFileName.c_str(), fsFileName.c_str())); } + Shader(const Shader&) = delete; + + Shader(Shader&& other) { + set(other); + + other.id = 0; + other.locs = nullptr; + } + /** * Load shader from files and bind default locations. */ @@ -42,6 +51,20 @@ class Shader : public ::Shader { return *this; } + Shader& operator=(const Shader&) = delete; + + Shader& operator=(Shader&& other) { + if (this != &other) { + return *this; + } + + Unload(); + set(other); + + other.id = 0; + other.locs = nullptr; + } + ~Shader() { Unload(); } diff --git a/include/Texture.hpp b/include/Texture.hpp index 423037d..0ddf312 100644 --- a/include/Texture.hpp +++ b/include/Texture.hpp @@ -38,6 +38,18 @@ class Texture : public ::Texture { Load(fileName); } + Texture(const Texture&) = delete; + + Texture(Texture&& other) { + set(other); + + other.id = 0; + other.width = 0; + other.height = 0; + other.mipmaps = 0; + other.format = 0; + } + ~Texture() { Unload(); } @@ -53,6 +65,25 @@ class Texture : public ::Texture { return *this; } + Texture& operator=(const Texture&) = delete; + + Texture& operator=(Texture&& other) { + if (this == &other) { + return *this; + } + + Unload(); + set(other); + + other.id = 0; + other.width = 0; + other.height = 0; + other.mipmaps = 0; + other.format = 0; + + return *this; + } + /** * Retrieve the width and height of the texture. */ diff --git a/include/Wave.hpp b/include/Wave.hpp index 9e0a843..8ac9e15 100644 --- a/include/Wave.hpp +++ b/include/Wave.hpp @@ -38,6 +38,18 @@ class Wave : public ::Wave { set(::LoadWaveFromMemory(fileType.c_str(), fileData, dataSize)); } + Wave(const Wave&) = delete; + + Wave(Wave&& other) { + set(other); + + other.sampleCount = 0; + other.sampleRate = 0; + other.sampleSize = 0; + other.channels = 0; + other.data = nullptr; + } + /** * Unload wave data */ @@ -56,6 +68,25 @@ class Wave : public ::Wave { return *this; } + Wave& operator=(const Wave&) = delete; + + Wave& operator=(Wave&& other) { + if (this != &other) { + return *this; + } + + Unload(); + set(other); + + other.sampleCount = 0; + other.sampleRate = 0; + other.sampleSize = 0; + other.channels = 0; + other.data = nullptr; + + return *this; + } + /** * Convert wave data to desired format */