From 45a0a2a6c1e8fa6b00a44f0a27e1336af48de28f Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 10 Aug 2019 16:55:34 -0400 Subject: [PATCH] Update confic --- examples/textures/textures_image_drawing.cpp | 2 -- include/raylib/Camera3D.hpp | 37 ++++++++++++-------- include/raylib/Font.hpp | 13 ++++--- include/raylib/Image.hpp | 5 +-- include/raylib/Material.hpp | 1 - include/raylib/Mesh.hpp | 10 ++++++ include/raylib/Model.hpp | 10 ++++++ include/raylib/Ray.hpp | 10 ++++++ include/raylib/RayHitInfo.hpp | 10 ++++++ include/raylib/Rectangle.hpp | 10 ++++++ include/raylib/RenderTexture2D.hpp | 11 ++++++ include/raylib/Shader.hpp | 10 ++++++ include/raylib/Sound.hpp | 10 ++++++ include/raylib/Texture2D.hpp | 24 ++++++++----- include/raylib/Vector2.hpp | 24 ++++++++++--- include/raylib/Vector3.hpp | 10 ++++++ include/raylib/Vector4.hpp | 10 ++++++ include/raylib/Wave.hpp | 10 ++++++ tests/raylib_test.cpp | 3 ++ 19 files changed, 182 insertions(+), 38 deletions(-) diff --git a/examples/textures/textures_image_drawing.cpp b/examples/textures/textures_image_drawing.cpp index aecb869..bdae00b 100644 --- a/examples/textures/textures_image_drawing.cpp +++ b/examples/textures/textures_image_drawing.cpp @@ -13,8 +13,6 @@ #include "raylib/raylib.hpp" -#include - int main(void) { // Initialization diff --git a/include/raylib/Camera3D.hpp b/include/raylib/Camera3D.hpp index 01ae266..beed192 100644 --- a/include/raylib/Camera3D.hpp +++ b/include/raylib/Camera3D.hpp @@ -18,6 +18,22 @@ namespace raylib { Camera3D() {} + GETTERSETTER(Vector3,Position,position) + GETTERSETTER(Vector3,Target,target) + GETTERSETTER(Vector3,Up,up) + GETTERSETTER(float,Fovy,fovy) + GETTERSETTER(int,Type,type) + + Camera3D& operator=(const ::Camera3D& camera) { + set(camera); + return *this; + } + + Camera3D& operator=(const Camera3D& camera) { + set(camera); + return *this; + } + inline void set(const ::Camera3D& camera) { position = camera.position; target = camera.target; @@ -57,22 +73,13 @@ namespace raylib { ::UpdateVrTracking(this); } - GETTERSETTER(Vector3,Position,position) - GETTERSETTER(Vector3,Target,target) - GETTERSETTER(Vector3,Up,up) - GETTERSETTER(float,Fovy,fovy) - GETTERSETTER(int,Type,type) - - Camera3D& operator=(const ::Camera3D& camera) { - set(camera); - return *this; - } - - Camera3D& operator=(const Camera3D& camera) { - set(camera); - return *this; - } + Ray GetMouseRay(::Vector2 mousePosition) { + return ::GetMouseRay(mousePosition, *this); + } + Vector2 GetWorldToScreen(::Vector3 position) { + return ::GetWorldToScreen(position, *this); + } }; typedef Camera3D Camera; diff --git a/include/raylib/Font.hpp b/include/raylib/Font.hpp index 3764723..7528a73 100644 --- a/include/raylib/Font.hpp +++ b/include/raylib/Font.hpp @@ -2,7 +2,6 @@ #define RAYLIB_CPP_FONT_HPP_ #include -#include #include "raylib.h" #include "utils.hpp" @@ -15,9 +14,7 @@ namespace raylib { } Font(const std::string& fileName) { - std::cout << "std" << fileName << std::endl; set(LoadFont(fileName.c_str())); - std::cout << "asdsadds()" << std::endl; } Font(const std::string& fileName, int fontSize, int* fontChars, int charCount) { @@ -33,7 +30,6 @@ namespace raylib { } void Unload() { - std::cout << "UnloadFont()" << std::endl; UnloadFont(*this); } @@ -46,7 +42,6 @@ namespace raylib { } void set(const Font& font) { - std::cout << "set()" << std::endl; baseSize = font.baseSize; charsCount = font.charsCount; texture = font.texture; @@ -79,6 +74,14 @@ namespace raylib { void DrawText(const std::string& text, ::Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, ::Color selectText, Color selectBack) { DrawTextRecEx(*this, text.c_str(), rec, fontSize, spacing, wordWrap, tint, selectStart, selectLength, selectText, selectBack); } + + Vector2 MeasureText(const std::string& text, float fontSize, float spacing) { + return ::MeasureTextEx(*this, text.c_str(), fontSize, spacing); + } + + int GetGlyphIndex(int character) { + return ::GetGlyphIndex(*this, character); + } }; } diff --git a/include/raylib/Image.hpp b/include/raylib/Image.hpp index 481ebc0..4c20e4d 100644 --- a/include/raylib/Image.hpp +++ b/include/raylib/Image.hpp @@ -4,7 +4,6 @@ #include #include "raylib.h" #include "utils.hpp" -#include namespace raylib { class Image : public ::Image { @@ -65,7 +64,6 @@ namespace raylib { } void Unload() { - std::cout << "UnloadImage()" << std::endl; UnloadImage(*this); }; @@ -134,6 +132,9 @@ namespace raylib { ImageColorReplace(this, color, replace); } + ::Color* GetData() { + return ::GetImageData(*this); + } }; } diff --git a/include/raylib/Material.hpp b/include/raylib/Material.hpp index 6e9f57e..2303739 100644 --- a/include/raylib/Material.hpp +++ b/include/raylib/Material.hpp @@ -37,7 +37,6 @@ namespace raylib { return *this; } - void Unload() { UnloadMaterial(*this); } diff --git a/include/raylib/Mesh.hpp b/include/raylib/Mesh.hpp index 32c845d..95ac65f 100644 --- a/include/raylib/Mesh.hpp +++ b/include/raylib/Mesh.hpp @@ -39,6 +39,16 @@ namespace raylib { GETTERSETTER(float,VertexCount,vertexCount) GETTERSETTER(float,TriangleCount,triangleCount) + Mesh& operator=(const ::Mesh& mesh) { + set(mesh); + return *this; + } + + Mesh& operator=(const Mesh& mesh) { + set(mesh); + return *this; + } + ~Mesh() { Unload(); } diff --git a/include/raylib/Model.hpp b/include/raylib/Model.hpp index 2ef09e5..2748c5c 100644 --- a/include/raylib/Model.hpp +++ b/include/raylib/Model.hpp @@ -42,6 +42,16 @@ namespace raylib { GETTERSETTER(int,MeshCount,meshCount) GETTERSETTER(int,MaterialCount,materialCount) + Model& operator=(const ::Model& model) { + set(model); + return *this; + } + + Model& operator=(const Model& model) { + set(model); + return *this; + } + void Unload() { UnloadModel(*this); } diff --git a/include/raylib/Ray.hpp b/include/raylib/Ray.hpp index c7bfb1a..683accf 100644 --- a/include/raylib/Ray.hpp +++ b/include/raylib/Ray.hpp @@ -27,6 +27,16 @@ namespace raylib { direction = ray.direction; } + Ray& operator=(const ::Ray& ray) { + set(ray); + return *this; + } + + Ray& operator=(const Ray& ray) { + set(ray); + return *this; + } + GETTERSETTER(::Vector3,Position,position) GETTERSETTER(::Vector3,Direction,direction) diff --git a/include/raylib/RayHitInfo.hpp b/include/raylib/RayHitInfo.hpp index 2847caa..43dae51 100644 --- a/include/raylib/RayHitInfo.hpp +++ b/include/raylib/RayHitInfo.hpp @@ -18,6 +18,16 @@ namespace raylib { normal = Normal; }; + RayHitInfo& operator=(const ::RayHitInfo& ray) { + set(ray); + return *this; + } + + RayHitInfo& operator=(const RayHitInfo& ray) { + set(ray); + return *this; + } + inline void set(::RayHitInfo ray) { hit = ray.hit; distance = ray.distance; diff --git a/include/raylib/Rectangle.hpp b/include/raylib/Rectangle.hpp index 014c874..87e115b 100644 --- a/include/raylib/Rectangle.hpp +++ b/include/raylib/Rectangle.hpp @@ -17,6 +17,7 @@ namespace raylib { width = Width; height = Height; }; + inline void set(::Rectangle rect) { x = rect.x; y = rect.y; @@ -68,6 +69,15 @@ namespace raylib { ::DrawRectangleRoundedLines(*this, roundness, segments, lineThick, color); } + bool CheckCollision(::Rectangle rec2) { + return ::CheckCollisionRecs(*this, rec2); + } + Rectangle GetCollisionRec(::Rectangle rec2) { + return ::GetCollisionRec(*this, rec2); + } + bool CheckCollisionPointRec(::Vector2 point) { + return ::CheckCollisionPointRec(point, *this); + } }; } diff --git a/include/raylib/RenderTexture2D.hpp b/include/raylib/RenderTexture2D.hpp index af1d94a..f5970d1 100644 --- a/include/raylib/RenderTexture2D.hpp +++ b/include/raylib/RenderTexture2D.hpp @@ -29,6 +29,16 @@ namespace raylib { GETTERSETTER(Texture2D,Depth,depth) GETTERSETTER(bool,DepthTexture,depthTexture) + RenderTexture2D& operator=(const ::RenderTexture2D& texture) { + set(texture); + return *this; + } + + RenderTexture2D& operator=(const RenderTexture2D& texture) { + set(texture); + return *this; + } + ~RenderTexture2D() { Unload(); }; @@ -41,6 +51,7 @@ namespace raylib { ::BeginTextureMode(*this); } }; + typedef RenderTexture2D RenderTexture; } #endif diff --git a/include/raylib/Shader.hpp b/include/raylib/Shader.hpp index 22ebd5e..a905677 100644 --- a/include/raylib/Shader.hpp +++ b/include/raylib/Shader.hpp @@ -27,6 +27,16 @@ namespace raylib { GETTERSETTER(unsigned int,Id,i) + Shader& operator=(const ::Shader& shader) { + set(shader); + return *this; + } + + Shader& operator=(const Shader& shader) { + set(shader); + return *this; + } + ~Shader() { Unload(); } diff --git a/include/raylib/Sound.hpp b/include/raylib/Sound.hpp index 36285d4..fbedd9b 100644 --- a/include/raylib/Sound.hpp +++ b/include/raylib/Sound.hpp @@ -33,6 +33,16 @@ namespace raylib { GETTERSETTER(unsigned int,SampleCount,sampleCount) GETTERSETTER(::AudioStream,Stream,stream) + Sound& operator=(const ::Sound& sound) { + set(sound); + return *this; + } + + Sound& operator=(const Sound& sound) { + set(sound); + return *this; + } + void Update(const void *data, int sampleCount) { UpdateSound(*this, data, sampleCount); } diff --git a/include/raylib/Texture2D.hpp b/include/raylib/Texture2D.hpp index 9400dcd..7ff7a96 100644 --- a/include/raylib/Texture2D.hpp +++ b/include/raylib/Texture2D.hpp @@ -5,7 +5,6 @@ #include "raylib.h" #include "utils.hpp" #include "Vector2.hpp" -#include namespace raylib { class Texture2D : public ::Texture2D { @@ -32,6 +31,22 @@ namespace raylib { format = texture.format; } + GETTERSETTER(unsigned int,Id,id) + GETTERSETTER(int,Width,width) + GETTERSETTER(int,Height,height) + GETTERSETTER(int,Mipmaps,mipmaps) + GETTERSETTER(int,Format,format) + + Texture2D& operator=(const ::Texture2D& texture) { + set(texture); + return *this; + } + + Texture2D& operator=(const Texture2D& texture) { + set(texture); + return *this; + } + bool LoadFromImage(::Image& image) { set(LoadTextureFromImage(image)); } @@ -64,15 +79,8 @@ namespace raylib { } void Unload() { - std::cout << "UnloadTexture()" << std::endl; UnloadTexture(*this); }; - - GETTERSETTER(unsigned int,Id,id) - GETTERSETTER(int,Width,width) - GETTERSETTER(int,Height,height) - GETTERSETTER(int,Mipmaps,mipmaps) - GETTERSETTER(int,Format,format) }; typedef Texture2D Texture; } diff --git a/include/raylib/Vector2.hpp b/include/raylib/Vector2.hpp index adff393..6d4b827 100644 --- a/include/raylib/Vector2.hpp +++ b/include/raylib/Vector2.hpp @@ -22,24 +22,38 @@ namespace raylib { GETTERSETTER(float,X,x) GETTERSETTER(float,Y,y) + Vector2& operator=(const ::Vector2& vector2) { + set(vector2); + return *this; + } + + Vector2& operator=(const Vector2& vector2) { + set(vector2); + return *this; + } + void DrawPixel(::Color color) { - DrawPixelV(*this, color); + ::DrawPixelV(*this, color); } void DrawLine(::Vector2 endPos, ::Color color) { - DrawLineV(*this, endPos, color); + ::DrawLineV(*this, endPos, color); } void DrawLine(::Vector2 endPos, float thick, ::Color color) { - DrawLineEx(*this, endPos, thick, color); + ::DrawLineEx(*this, endPos, thick, color); + } + + void DrawLineBezier(::Vector2 endPos, float thick, ::Color color) { + ::DrawLineBezier(*this, endPos, thick, color); } void DrawCircle(float radius, ::Color color) { - DrawCircleV(*this, radius, color); + ::DrawCircleV(*this, radius, color); } void DrawRectangle(::Vector2 size, ::Color color) { - DrawRectangleV(*this, size, color); + ::DrawRectangleV(*this, size, color); } void DrawPoly(int sides, float radius, float rotation, ::Color color) { diff --git a/include/raylib/Vector3.hpp b/include/raylib/Vector3.hpp index 626bb81..42cace3 100644 --- a/include/raylib/Vector3.hpp +++ b/include/raylib/Vector3.hpp @@ -29,6 +29,16 @@ namespace raylib { GETTERSETTER(float,Y,y) GETTERSETTER(float,Z,z) + Vector3& operator=(const ::Vector3& vector3) { + set(vector3); + return *this; + } + + Vector3& operator=(const Vector3& vector3) { + set(vector3); + return *this; + } + void DrawGizmo() { ::DrawGizmo(*this); } diff --git a/include/raylib/Vector4.hpp b/include/raylib/Vector4.hpp index 4ed9a79..d3dea68 100644 --- a/include/raylib/Vector4.hpp +++ b/include/raylib/Vector4.hpp @@ -33,6 +33,16 @@ namespace raylib { GETTERSETTER(float,Y,y) GETTERSETTER(float,Z,z) GETTERSETTER(float,W,w) + + Vector4& operator=(const ::Vector4& vector4) { + set(vector4); + return *this; + } + + Vector4& operator=(const Vector4& vector4) { + set(vector4); + return *this; + } }; } diff --git a/include/raylib/Wave.hpp b/include/raylib/Wave.hpp index 3166606..f1ba24a 100644 --- a/include/raylib/Wave.hpp +++ b/include/raylib/Wave.hpp @@ -40,6 +40,16 @@ namespace raylib { GETTERSETTER(unsigned int,W,channels) GETTERSETTER(void*,Data,data) + Wave& operator=(const ::Wave& wave) { + set(wave); + return *this; + } + + Wave& operator=(const Wave& wave) { + set(wave); + return *this; + } + void Format(int SampleRate = 0, int SampleSize = 0, int Channels = 2) { WaveFormat(this, SampleRate, SampleSize, Channels); } diff --git a/tests/raylib_test.cpp b/tests/raylib_test.cpp index c5cb226..7c1c7a0 100644 --- a/tests/raylib_test.cpp +++ b/tests/raylib_test.cpp @@ -17,5 +17,8 @@ TEST_CASE("raylib_test", "[raylib_test]" ) { SECTION("Color") { raylib::Color c(RED); CHECK(c.ToInt() == ColorToInt(RED)); + + c = RAYWHITE; + CHECK(c.r == RAYWHITE.r); } }