diff --git a/CHANGELOG.md b/CHANGELOG.md index 458fa30..f2f1a08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.0.3] - Unreleased +### Changed +- CMake now used for raylib dependency, rather than git submodules +- Standardized functions across: + - Color + - Material + - Mesh + - Model + - ModelAnimation + - Physics + - Ray + - Rectangle + - Texture + - Window + ## [4.0.2] - 2021-12-24 ### Added - `Image::IsLoaded()` diff --git a/CMakeLists.txt b/CMakeLists.txt index 4eb2226..939eb93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.11) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") project (raylib-cpp - VERSION 4.0.2 + VERSION 4.0.3 DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib" HOMEPAGE_URL "https://github.com/robloach/raylib-cpp" LANGUAGES C CXX) diff --git a/examples/physics/physics_demo.cpp b/examples/physics/physics_demo.cpp index de0397d..73fdccd 100644 --- a/examples/physics/physics_demo.cpp +++ b/examples/physics/physics_demo.cpp @@ -55,7 +55,7 @@ int main(void) // Update //---------------------------------------------------------------------------------- // Delay initialization of variables due to physics reset async - physics.UpdateStep(); + physics.Update(); if (needsReset) { diff --git a/include/Color.hpp b/include/Color.hpp index 9c0b749..8f51910 100644 --- a/include/Color.hpp +++ b/include/Color.hpp @@ -162,7 +162,7 @@ class Color : public ::Color { } inline Color& DrawText( - const ::Font font, + const ::Font& font, const std::string& text, ::Vector2 position, ::Vector2 origin, diff --git a/include/Material.hpp b/include/Material.hpp index c4b3d42..fbb5dfe 100644 --- a/include/Material.hpp +++ b/include/Material.hpp @@ -91,6 +91,22 @@ class Material : public ::Material { return *this; } + /** + * Draw a 3d mesh with material and transform + */ + inline const Material& DrawMesh(const ::Mesh& mesh, ::Matrix transform) const { + ::DrawMesh(mesh, *this, transform); + return *this; + } + + /** + * Draw multiple mesh instances with material and different transforms + */ + inline const Material& DrawMesh(const ::Mesh& mesh, ::Matrix* transforms, int instances) const { + ::DrawMeshInstanced(mesh, *this, transforms, instances); + return *this; + } + private: inline void set(const ::Material& material) { shader = material.shader; diff --git a/include/Mesh.hpp b/include/Mesh.hpp index 0000388..9e7ae93 100644 --- a/include/Mesh.hpp +++ b/include/Mesh.hpp @@ -206,11 +206,17 @@ class Mesh : public ::Mesh { ::UpdateMeshBuffer(*this, index, data, dataSize, offset); } + /** + * Draw a 3d mesh with material and transform + */ inline void Draw(const ::Material& material, const ::Matrix& transform) { ::DrawMesh(*this, material, transform); } - inline void DrawInstanced(const ::Material& material, ::Matrix* transforms, int instances) { + /** + * Draw multiple mesh instances with material and different transforms + */ + inline void Draw(const ::Material& material, ::Matrix* transforms, int instances) { ::DrawMeshInstanced(*this, material, transforms, instances); } @@ -249,7 +255,7 @@ class Mesh : public ::Mesh { /** * Compute mesh tangents */ - inline Mesh& Tangents() { + inline Mesh& GenTangents() { ::GenMeshTangents(this); return *this; } @@ -257,7 +263,7 @@ class Mesh : public ::Mesh { /** * Compute mesh binormals (aka bitangent) */ - inline Mesh& Binormals() { + inline Mesh& GenBinormals() { ::GenMeshBinormals(this); return *this; } diff --git a/include/Model.hpp b/include/Model.hpp index 6a9f2b8..9f146f1 100644 --- a/include/Model.hpp +++ b/include/Model.hpp @@ -174,6 +174,20 @@ class Model : public ::Model { return *this; } + /** + * Compute model bounding box limits (considers all meshes) + */ + inline BoundingBox GetBoundingBox() const { + return ::GetModelBoundingBox(*this); + } + + /** + * Compute model bounding box limits (considers all meshes) + */ + operator BoundingBox() const { + return ::GetModelBoundingBox(*this); + } + private: inline void set(const ::Model& model) { transform = model.transform; diff --git a/include/ModelAnimation.hpp b/include/ModelAnimation.hpp index 5adbbd8..91f46c8 100644 --- a/include/ModelAnimation.hpp +++ b/include/ModelAnimation.hpp @@ -56,7 +56,6 @@ class ModelAnimation : public ::ModelAnimation { return *this; } - ModelAnimation& operator=(const ModelAnimation&) = delete; ModelAnimation& operator=(ModelAnimation&& other) { diff --git a/include/Physics.hpp b/include/Physics.hpp index 7d1c5e3..c9feb17 100644 --- a/include/Physics.hpp +++ b/include/Physics.hpp @@ -34,13 +34,18 @@ class Physics { return *this; } - inline Physics& Close() { - ::ClosePhysics(); + inline Physics& Update() { + ::UpdatePhysics(); return *this; } - inline Physics& UpdateStep() { - ::UpdatePhysicsStep(); + inline Physics& Reset() { + ::ResetPhysics(); + return *this; + } + + inline Physics& Close() { + ::ClosePhysics(); return *this; } @@ -66,6 +71,11 @@ class Physics { return ::CreatePhysicsBodyPolygon(pos, radius, sides, density); } + inline Physics& DestroyBody(PhysicsBody body) { + ::DestroyPhysicsBody(body); + return *this; + } + inline Physics& AddForce(PhysicsBody body, Vector2 force) { ::PhysicsAddForce(body, force); return *this; @@ -81,6 +91,11 @@ class Physics { return *this; } + inline Physics& SetBodyRotation(PhysicsBody body, float radians) { + ::SetPhysicsBodyRotation(body, radians); + return *this; + } + inline int GetBodiesCount() const { return ::GetPhysicsBodiesCount(); } @@ -100,21 +115,6 @@ class Physics { 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; - } }; } // namespace raylib diff --git a/include/Ray.hpp b/include/Ray.hpp index 92331a2..dcc94ff 100644 --- a/include/Ray.hpp +++ b/include/Ray.hpp @@ -47,7 +47,7 @@ class Ray : public ::Ray { /** * Get collision information between ray and sphere */ - inline RayCollision GetCollisionSphere(::Vector3 center, float radius) const { + inline RayCollision GetCollision(::Vector3 center, float radius) const { return GetRayCollisionSphere(*this, center, radius); } @@ -58,13 +58,6 @@ class Ray : public ::Ray { return GetRayCollisionBox(*this, box).hit; } - /** - * Get collision information between ray and box - */ - inline RayCollision GetCollision(const ::BoundingBox& box) const { - return GetRayCollisionBox(*this, box); - } - /** * Get collision info between ray and model */ @@ -72,13 +65,27 @@ class Ray : public ::Ray { return GetRayCollisionModel(*this, model); } + /** + * Get collision information between ray and mesh + */ + inline RayCollision GetCollision(const ::Mesh& mesh, const ::Matrix& transform) const { + return GetRayCollisionMesh(*this, mesh, transform); + } + /** * Get collision info between ray and triangle */ - inline RayCollision GetCollisionTriangle(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) const { + inline RayCollision GetCollision(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) const { return GetRayCollisionTriangle(*this, p1, p2, p3); } + /** + * Get collision info between ray and quad + */ + inline RayCollision GetCollision(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4) const { + return GetRayCollisionQuad(*this, p1, p2, p3, p4); + } + private: inline void set(const ::Ray& ray) { position = ray.position; diff --git a/include/Rectangle.hpp b/include/Rectangle.hpp index 4283894..54b5f29 100644 --- a/include/Rectangle.hpp +++ b/include/Rectangle.hpp @@ -139,6 +139,11 @@ class Rectangle : public ::Rectangle { return SetSize(size.x, size.y); } + inline Rectangle& SetShapesTexture(const ::Texture2D& texture) { + ::SetShapesTexture(texture, *this); + return *this; + } + inline ::Vector2 GetPosition() { return {x, y}; } diff --git a/include/Texture.hpp b/include/Texture.hpp index 8a52c5b..a4ab2da 100644 --- a/include/Texture.hpp +++ b/include/Texture.hpp @@ -130,7 +130,7 @@ class Texture : public ::Texture { /** * Update GPU texture rectangle with new data */ - inline Texture& UpdateRec(::Rectangle rec, const void *pixels) { + inline Texture& Update(::Rectangle rec, const void *pixels) { UpdateTextureRec(*this, rec, pixels); return *this; } @@ -263,6 +263,14 @@ class Texture : public ::Texture { return *this; } + /** + * Set shader uniform value for texture (sampler2d) + */ + inline Texture& SetShaderValue(const ::Shader& shader, int locIndex) { + ::SetShaderValueTexture(shader, locIndex, *this); + return *this; + } + private: inline void set(const ::Texture& texture) { id = texture.id; diff --git a/include/Window.hpp b/include/Window.hpp index 8352f78..e8d6313 100644 --- a/include/Window.hpp +++ b/include/Window.hpp @@ -229,6 +229,14 @@ class Window { return *this; } + /** + * Set window minimum dimensions + */ + inline Window& SetMinSize(const ::Vector2& size) { + ::SetWindowMinSize(static_cast(size.x), static_cast(size.y)); + return *this; + } + /** * Set window dimensions */ @@ -247,7 +255,7 @@ class Window { /** * Get the screen's width and height. */ - inline ::Vector2 GetSize() { + inline Vector2 GetSize() { return {static_cast(GetWidth()), static_cast(GetHeight())}; } diff --git a/package.json b/package.json index 8f626d3..48c2662 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "raylib-cpp", - "version": "4.0.2", + "version": "4.0.3", "description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib", "homepage": "https://github.com/robloach/raylib-cpp", "bugs": {