diff --git a/include/Camera2D.hpp b/include/Camera2D.hpp index e5b9cc0..45b52d1 100644 --- a/include/Camera2D.hpp +++ b/include/Camera2D.hpp @@ -50,8 +50,8 @@ class Camera2D : public ::Camera2D { return *this; } - GETTERSETTER(Vector2, Offset, offset) - GETTERSETTER(Vector2, Target, target) + GETTERSETTER(::Vector2, Offset, offset) + GETTERSETTER(::Vector2, Target, target) GETTERSETTER(float, Rotation, rotation) GETTERSETTER(float, Zoom, zoom) diff --git a/include/Camera3D.hpp b/include/Camera3D.hpp index bc5fb5f..6793aa2 100644 --- a/include/Camera3D.hpp +++ b/include/Camera3D.hpp @@ -43,9 +43,9 @@ class Camera3D : public ::Camera3D { Camera3D() {} - GETTERSETTER(Vector3, Position, position) - GETTERSETTER(Vector3, Target, target) - GETTERSETTER(Vector3, Up, up) + GETTERSETTER(::Vector3, Position, position) + GETTERSETTER(::Vector3, Target, target) + GETTERSETTER(::Vector3, Up, up) GETTERSETTER(float, Fovy, fovy) GETTERSETTER(int, Type, type) diff --git a/include/Font.hpp b/include/Font.hpp index 1306e81..0ce67ef 100644 --- a/include/Font.hpp +++ b/include/Font.hpp @@ -65,9 +65,9 @@ class Font : public ::Font { GETTERSETTER(int, BaseSize, baseSize) GETTERSETTER(int, CharsCount, charsCount) - GETTERSETTER(Texture2D, Texture, texture) - GETTERSETTER(Rectangle*, Recs, recs) - GETTERSETTER(CharInfo*, Chars, chars) + GETTERSETTER(::Texture2D, Texture, texture) + GETTERSETTER(::Rectangle*, Recs, recs) + GETTERSETTER(::CharInfo*, Chars, chars) Font& operator=(const ::Font& font) { set(font); diff --git a/include/Image.hpp b/include/Image.hpp index 0090832..dbbed69 100644 --- a/include/Image.hpp +++ b/include/Image.hpp @@ -140,6 +140,7 @@ class Image : public ::Image { ::ExportImage(*this, fileName.c_str()); return *this; } + inline Image& ExportAsCode(const std::string& fileName) { ::ExportImageAsCode(*this, fileName.c_str()); return *this; @@ -368,10 +369,14 @@ class Image : public ::Image { return ::GetImageDataNormalized(*this); } - inline operator Texture2D() { + ::Texture2D LoadTexture() { return ::LoadTextureFromImage(*this); } + inline operator ::Texture2D() { + return LoadTexture(); + } + protected: inline void set(::Image image) { data = image.data; diff --git a/include/Mesh.hpp b/include/Mesh.hpp index 1a943f5..d582ef8 100644 --- a/include/Mesh.hpp +++ b/include/Mesh.hpp @@ -73,6 +73,7 @@ class Mesh : public ::Mesh { inline raylib::BoundingBox BoundingBox() { return ::MeshBoundingBox(*this); } + operator raylib::BoundingBox() { return BoundingBox(); } @@ -95,6 +96,7 @@ class Mesh : public ::Mesh { inline raylib::Model LoadModelFrom() { return ::LoadModelFromMesh(*this); } + operator raylib::Model() { return LoadModelFrom(); } diff --git a/include/Model.hpp b/include/Model.hpp index a56562d..d8c8f9d 100644 --- a/include/Model.hpp +++ b/include/Model.hpp @@ -53,6 +53,7 @@ class Model : public ::Model { GETTERSETTER(::Matrix, Transform, transform) GETTERSETTER(int, MeshCount, meshCount) GETTERSETTER(int, MaterialCount, materialCount) + GETTERSETTER(int, BoneCount, boneCount) Model& operator=(const ::Model& model) { set(model); @@ -91,11 +92,11 @@ class Model : public ::Model { transform = model.transform; meshCount = model.meshCount; - meshes = model.meshes; - materialCount = model.materialCount; + meshes = model.meshes; materials = model.materials; meshMaterial = model.meshMaterial; + boneCount = model.boneCount; bones = model.bones; bindPose = model.bindPose; diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index 76588db..273ded0 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -43,7 +43,7 @@ class ModelAnimation : public ::ModelAnimation { GETTERSETTER(int, BoneCount, boneCount) GETTERSETTER(::BoneInfo*, Bones, bones) GETTERSETTER(int, FrameCount, frameCount) - GETTERSETTER(Transform**, FramePoses, framePoses) + GETTERSETTER(::Transform**, FramePoses, framePoses) ModelAnimation& operator=(const ::ModelAnimation& model) { set(model); diff --git a/include/Music.hpp b/include/Music.hpp index 7e98d33..703b4bd 100644 --- a/include/Music.hpp +++ b/include/Music.hpp @@ -82,24 +82,30 @@ class Music : public ::Music { ::PauseMusicStream(*this); return *this; } + inline Music& Resume() { ::ResumeMusicStream(*this); return *this; } + inline bool IsPlaying() const { return ::IsMusicPlaying(*this); } + inline Music& SetVolume(float volume) { ::SetMusicVolume(*this, volume); return *this; } + inline Music& SetPitch(float pitch) { ::SetMusicPitch(*this, pitch); return *this; } + inline float GetTimeLength() const { return ::GetMusicTimeLength(*this); } + inline float GetTimePlayed() const { return ::GetMusicTimePlayed(*this); } diff --git a/include/Physics.hpp b/include/Physics.hpp index 5a110f8..ce202fd 100644 --- a/include/Physics.hpp +++ b/include/Physics.hpp @@ -25,10 +25,11 @@ #ifndef RAYLIB_CPP_INCLUDE_PHYSICS_HPP_ #define RAYLIB_CPP_INCLUDE_PHYSICS_HPP_ +#include "./raylib.hpp" + #ifdef __cplusplus extern "C" { #endif -#include "raylib.h" // NOLINT #include "physac.h" // NOLINT #ifdef __cplusplus } @@ -87,47 +88,60 @@ class Physics { inline PhysicsBody CreateBodyCircle(Vector2 pos, float radius, float density) { return ::CreatePhysicsBodyCircle(pos, radius, density); } + inline PhysicsBody CreateBodyRectangle(Vector2 pos, float width, float height, float density) { return ::CreatePhysicsBodyRectangle(pos, width, height, density); } + inline PhysicsBody CreateBodyPolygon(Vector2 pos, float radius, int sides, float density) { return ::CreatePhysicsBodyPolygon(pos, radius, sides, density); } + inline Physics& AddForce(PhysicsBody body, Vector2 force) { ::PhysicsAddForce(body, force); return *this; } + inline Physics& AddTorque(PhysicsBody body, float amount) { ::PhysicsAddTorque(body, amount); return *this; } + inline Physics& Shatter(PhysicsBody body, Vector2 position, float force) { ::PhysicsShatter(body, position, force); return *this; } + inline int GetBodiesCount() const { return ::GetPhysicsBodiesCount(); } + inline PhysicsBody GetBody(int index) const { return ::GetPhysicsBody(index); } + inline int GetShapeType(int index) const { return ::GetPhysicsShapeType(index); } + inline int GetShapeVerticesCount(int index) const { return ::GetPhysicsShapeVerticesCount(index); } + inline Vector2 GetShapeVertex(PhysicsBody body, int vertex) const { return ::GetPhysicsShapeVertex(body, vertex); } + inline Physics& SetBodyRotation(PhysicsBody body, float radians) { ::SetPhysicsBodyRotation(body, radians); return *this; } + inline Physics& DestroyBody(PhysicsBody body) { ::DestroyPhysicsBody(body); return *this; } + inline Physics& Reset() { ::ResetPhysics(); return *this; diff --git a/include/RenderTexture.hpp b/include/RenderTexture.hpp index ba9440b..b48204d 100644 --- a/include/RenderTexture.hpp +++ b/include/RenderTexture.hpp @@ -44,8 +44,8 @@ class RenderTexture : public ::RenderTexture { } GETTERSETTER(unsigned int, Id, id) - GETTERSETTER(Texture2D, Texture, texture) - GETTERSETTER(Texture2D, Depth, depth) + GETTERSETTER(::Texture2D, Texture, texture) + GETTERSETTER(::Texture2D, Depth, depth) RenderTexture& operator=(const ::RenderTexture& texture) { set(texture); diff --git a/include/Texture.hpp b/include/Texture.hpp index e6af9d7..ab667a2 100644 --- a/include/Texture.hpp +++ b/include/Texture.hpp @@ -136,16 +136,19 @@ class Texture : public ::Texture { ::DrawTextureRec(*this, sourceRec, position, tint); return *this; } + inline Texture& Draw(::Vector2 tiling, ::Vector2 offset, ::Rectangle quad, ::Color tint = WHITE) { ::DrawTextureQuad(*this, tiling, offset, quad, tint); return *this; } + inline Texture& Draw(::Rectangle sourceRec, ::Rectangle destRec, ::Vector2 origin, float rotation = 0, ::Color tint = WHITE) { ::DrawTexturePro(*this, sourceRec, destRec, origin, rotation, tint); return *this; } + inline Texture& Draw(::NPatchInfo nPatchInfo, ::Rectangle destRec, ::Vector2 origin, float rotation = 0, ::Color tint = WHITE) { ::DrawTextureNPatch(*this, nPatchInfo, destRec, origin, rotation, tint); diff --git a/include/Vector2.hpp b/include/Vector2.hpp index aff73bb..2806916 100644 --- a/include/Vector2.hpp +++ b/include/Vector2.hpp @@ -25,23 +25,14 @@ #ifndef RAYLIB_CPP_INCLUDE_VECTOR2_HPP_ #define RAYLIB_CPP_INCLUDE_VECTOR2_HPP_ -#ifdef __cplusplus -extern "C" { -#endif -#include "raylib.h" // NOLINT -#ifndef RAYLIB_CPP_NO_MATH -#include "raymath.h" // NOLINT -#endif -#ifdef __cplusplus -} -#endif - -#include "./raylib-cpp-utils.hpp" - #ifndef RAYLIB_CPP_NO_MATH #include #endif +#include "./raylib.hpp" +#include "./raymath.hpp" +#include "./raylib-cpp-utils.hpp" + namespace raylib { class Vector2 : public ::Vector2 { public: diff --git a/include/Vector3.hpp b/include/Vector3.hpp index 80367cc..1fb89ac 100644 --- a/include/Vector3.hpp +++ b/include/Vector3.hpp @@ -25,22 +25,14 @@ #ifndef RAYLIB_CPP_INCLUDE_VECTOR3_HPP_ #define RAYLIB_CPP_INCLUDE_VECTOR3_HPP_ -#ifdef __cplusplus -extern "C" { -#endif -#include "raylib.h" // NOLINT -#ifndef RAYLIB_CPP_NO_MATH -#include "raymath.h" // NOLINT -#endif -#ifdef __cplusplus -} -#endif - -#include "./raylib-cpp-utils.hpp" #ifndef RAYLIB_CPP_NO_MATH #include #endif +#include "./raylib.hpp" +#include "./raymath.hpp" +#include "./raylib-cpp-utils.hpp" + namespace raylib { class Vector3 : public ::Vector3 { public: diff --git a/include/Vector4.hpp b/include/Vector4.hpp index 616504e..4439630 100644 --- a/include/Vector4.hpp +++ b/include/Vector4.hpp @@ -25,23 +25,15 @@ #ifndef RAYLIB_CPP_INCLUDE_VECTOR4_HPP_ #define RAYLIB_CPP_INCLUDE_VECTOR4_HPP_ -#ifdef __cplusplus -extern "C" { -#endif -#include "raylib.h" // NOLINT -#ifndef RAYLIB_CPP_NO_MATH -#include "raymath.h" // NOLINT -#endif -#ifdef __cplusplus -} -#endif - -#include "./raylib-cpp-utils.hpp" #ifndef RAYLIB_CPP_NO_MATH #include #include #endif +#include "./raylib.hpp" +#include "./raymath.hpp" +#include "./raylib-cpp-utils.hpp" + namespace raylib { class Vector4 : public ::Vector4 { public: @@ -171,6 +163,10 @@ class Vector4 : public ::Vector4 { return ::ColorFromNormalized(*this); } + operator Color() { + return ColorFromNormalized(); + } + protected: inline void set(::Vector4 vec4) { x = vec4.x; diff --git a/include/Wave.hpp b/include/Wave.hpp index f40502c..d1c6c08 100644 --- a/include/Wave.hpp +++ b/include/Wave.hpp @@ -110,6 +110,10 @@ class Wave : public ::Wave { return ::LoadSoundFromWave(*this); } + inline operator Sound() { + return LoadSound(); + } + inline float* GetData() { return ::GetWaveData(*this); } diff --git a/include/raymath.hpp b/include/raymath.hpp new file mode 100644 index 0000000..4e17405 --- /dev/null +++ b/include/raymath.hpp @@ -0,0 +1,38 @@ +/* +* LICENSE: zlib/libpng +* +* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified, +* BSD-like license that allows static linking with closed source software: +* +* Copyright (c) 2020 Rob Loach (@RobLoach) +* +* This software is provided "as-is", without any express or implied warranty. In no event +* will the authors be held liable for any damages arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, including commercial +* applications, and to alter it and redistribute it freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not claim that you +* wrote the original software. If you use this software in a product, an acknowledgment +* in the product documentation would be appreciated but is not required. +* +* 2. Altered source versions must be plainly marked as such, and must not be misrepresented +* as being the original software. +* +* 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef RAYLIB_CPP_INCLUDE_RAYMATH_HPP_ +#define RAYLIB_CPP_INCLUDE_RAYMATH_HPP_ + +#ifdef __cplusplus +extern "C" { +#endif +#ifndef RAYLIB_CPP_NO_MATH +#include "raymath.h" // NOLINT +#endif +#ifdef __cplusplus +} +#endif + +#endif // RAYLIB_CPP_INCLUDE_RAYMATH_HPP_