Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
cmake-build-debug
.idea
docs
/.vs
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.11)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project (raylib_cpp
VERSION 5.5.0
VERSION 6.0.0
DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib"
HOMEPAGE_URL "https://github.com/robloach/raylib-cpp"
LANGUAGES C CXX
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![raylib-cpp Logo](projects/Doxygen/raylib-cpp_256x256.png)

# raylib-cpp ![Targeting raylib 5.0](https://img.shields.io/badge/for_raylib-5.0-blue) [![Tests](https://github.com/RobLoach/raylib-cpp/workflows/Tests/badge.svg)](https://github.com/RobLoach/raylib-cpp/actions?query=workflow%3ATests+branch%3Amaster) [![License](https://img.shields.io/badge/license-zlib%2Flibpng-blue.svg)](LICENSE)
# raylib-cpp ![Targeting raylib 6](https://img.shields.io/badge/for_raylib-6-blue) [![Tests](https://github.com/RobLoach/raylib-cpp/workflows/Tests/badge.svg)](https://github.com/RobLoach/raylib-cpp/actions?query=workflow%3ATests+branch%3Amaster) [![License](https://img.shields.io/badge/license-zlib%2Flibpng-blue.svg)](LICENSE)

[raylib-cpp](https://github.com/robloach/raylib-cpp) is a C++ wrapper library for [raylib](https://www.raylib.com), a simple and easy-to-use library to enjoy videogames programming. This C++ header provides object-oriented wrappers around *raylib*'s struct interfaces. *raylib-cpp* is not required to use *raylib* in C++, but the classes do bring using the raylib API more inline with C++'s language paradigm.

Expand Down
2 changes: 1 addition & 1 deletion clib.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raylib-cpp",
"version": "5.5.0",
"version": "6.0.0-alpha1",
"repo": "RobLoach/raylib-cpp",
"description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib",
"homepage": "https://github.com/robloach/raylib-cpp",
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (NOT raylib_FOUND)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG 5.5
GIT_TAG 9ae34d2
GIT_SHALLOW 1
)
FetchContent_GetProperties(raylib)
Expand Down
4 changes: 2 additions & 2 deletions include/Mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Mesh : public MeshUnmanaged {
other.indices = nullptr;
other.animVertices = nullptr;
other.animNormals = nullptr;
other.boneIds = nullptr;
other.boneIndices = nullptr;
other.boneWeights = nullptr;
other.vaoId = 0;
other.vboId = nullptr;
Expand All @@ -73,7 +73,7 @@ class Mesh : public MeshUnmanaged {
other.indices = nullptr;
other.animVertices = nullptr;
other.animNormals = nullptr;
other.boneIds = nullptr;
other.boneIndices = nullptr;
other.boneWeights = nullptr;
other.vaoId = 0;
other.vboId = nullptr;
Expand Down
8 changes: 3 additions & 5 deletions include/MeshUnmanaged.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ class MeshUnmanaged : public ::Mesh {
indices = nullptr;
animVertices = nullptr;
animNormals = nullptr;
boneIds = nullptr;
boneIndices = nullptr;
boneWeights = nullptr;
boneMatrices = nullptr;
boneCount = 0;
vaoId = 0;
vboId = nullptr;
Expand Down Expand Up @@ -130,7 +129,7 @@ class MeshUnmanaged : public ::Mesh {
GETTERSETTER(unsigned short*, Indices, indices) // NOLINT
GETTERSETTER(float*, AnimVertices, animVertices)
GETTERSETTER(float*, AnimNormals, animNormals)
GETTERSETTER(unsigned char*, BoneIds, boneIds)
GETTERSETTER(unsigned char*, BoneIndices, boneIndices)
GETTERSETTER(float*, BoneWeights, boneWeights)
GETTERSETTER(unsigned int, VaoId, vaoId)
GETTERSETTER(unsigned int*, VboId, vboId)
Expand Down Expand Up @@ -242,9 +241,8 @@ class MeshUnmanaged : public ::Mesh {
indices = mesh.indices;
animVertices = mesh.animVertices;
animNormals = mesh.animNormals;
boneIds = mesh.boneIds;
boneIndices = mesh.boneIndices;
boneWeights = mesh.boneWeights;
boneMatrices = mesh.boneMatrices;
vaoId = mesh.vaoId;
vboId = mesh.vboId;
}
Expand Down
40 changes: 25 additions & 15 deletions include/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ class Model : public ::Model {
other.meshes = nullptr;
other.materials = nullptr;
other.meshMaterial = nullptr;
other.boneCount = 0;
other.bones = nullptr;
other.bindPose = nullptr;

other.skeleton.boneCount = 0;
other.skeleton.bones = nullptr;
other.skeleton.bindPose = nullptr;

ModelAnimPose currentPose;
Matrix *boneMatrices;
}

GETTERSETTER(::Matrix, Transform, transform)
Expand All @@ -69,9 +73,11 @@ class Model : public ::Model {
GETTERSETTER(::Mesh*, Meshes, meshes)
GETTERSETTER(::Material*, Materials, materials)
GETTERSETTER(int*, MeshMaterial, meshMaterial)
GETTERSETTER(int, BoneCount, boneCount)
GETTERSETTER(::BoneInfo*, Bones, bones)
GETTERSETTER(::Transform*, BindPose, bindPose)
GETTERSETTER(int, BoneCount, skeleton.boneCount)
GETTERSETTER(::BoneInfo*, Bones, skeleton.bones)
GETTERSETTER(::Transform*, BindPose, skeleton.bindPose)
GETTERSETTER(::ModelAnimPose, CurrentPose, currentPose)
GETTERSETTER(::Matrix*, BoneMatrices, boneMatrices)

Model& operator=(const ::Model& model) {
set(model);
Expand All @@ -93,9 +99,11 @@ class Model : public ::Model {
other.meshes = nullptr;
other.materials = nullptr;
other.meshMaterial = nullptr;
other.boneCount = 0;
other.bones = nullptr;
other.bindPose = nullptr;
other.skeleton.boneCount = 0;
other.skeleton.bones = nullptr;
other.skeleton.bindPose = nullptr;
other.currentPose = nullptr;
other.boneMatrices = nullptr;

return *this;
}
Expand All @@ -122,16 +130,16 @@ class Model : public ::Model {
/**
* Update model animation pose
*/
Model& UpdateAnimation(const ::ModelAnimation& anim, int frame) {
Model& UpdateAnimation(const ::ModelAnimation& anim, float frame) {
::UpdateModelAnimation(*this, anim, frame);
return *this;
}

/**
* Update model animation pose
*/
Model& UpdateAnimationBones(const ::ModelAnimation& anim, int frame) {
::UpdateModelAnimationBones(*this, anim, frame);
Model& UpdateAnimationsEx(const ::ModelAnimation& animA, float frameA, const ::ModelAnimation& animB, float frameB, float blend) {
::UpdateModelAnimationEx(*this, animA, frameA, animB, frameB, blend);
return *this;
}

Expand Down Expand Up @@ -240,9 +248,11 @@ class Model : public ::Model {
materials = model.materials;
meshMaterial = model.meshMaterial;

boneCount = model.boneCount;
bones = model.bones;
bindPose = model.bindPose;
skeleton.boneCount = model.skeleton.boneCount;
skeleton.bones = model.skeleton.bones;
skeleton.bindPose = model.skeleton.bindPose;
currentPose = model.currentPose;
boneMatrices = model.boneMatrices;
}
};

Expand Down
29 changes: 13 additions & 16 deletions include/ModelAnimation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class ModelAnimation : public ::ModelAnimation {
set(other);

other.boneCount = 0;
other.frameCount = 0;
other.bones = nullptr;
other.framePoses = nullptr;
other.keyframeCount = 0;
other.keyframePoses = nullptr;
}

~ModelAnimation() { Unload(); }
// TODO: Implement a way to unload all animations at once, as the current Unload() only unloads one animation.
~ModelAnimation() { Unload(1); }

/**
* Load model animations from file
Expand All @@ -43,9 +43,8 @@ class ModelAnimation : public ::ModelAnimation {
}

GETTERSETTER(int, BoneCount, boneCount)
GETTERSETTER(::BoneInfo*, Bones, bones)
GETTERSETTER(int, FrameCount, frameCount)
GETTERSETTER(::Transform**, FramePoses, framePoses)
GETTERSETTER(int, KeyframeCount, keyframeCount)
GETTERSETTER(::Transform**, KeyframePoses, keyframePoses)

ModelAnimation& operator=(const ::ModelAnimation& model) {
set(model);
Expand All @@ -59,21 +58,20 @@ class ModelAnimation : public ::ModelAnimation {
return *this;
}

Unload();
Unload(1);
set(other);

other.boneCount = 0;
other.frameCount = 0;
other.bones = nullptr;
other.framePoses = nullptr;
other.keyframeCount = 0;
other.keyframePoses = nullptr;

return *this;
}

/**
* Unload animation data
*/
void Unload() { ::UnloadModelAnimation(*this); }
void Unload(int animCount) { ::UnloadModelAnimations(this, animCount); }

/**
* Update model animation pose
Expand All @@ -87,7 +85,7 @@ class ModelAnimation : public ::ModelAnimation {
* Update model animation mesh bone matrices (GPU skinning)
*/
ModelAnimation& UpdateBones(const ::Model& model, int frame) {
::UpdateModelAnimationBones(model, *this, frame);
::UpdateModelAnimation(model, *this, frame);
return *this;
}

Expand All @@ -98,9 +96,8 @@ class ModelAnimation : public ::ModelAnimation {
protected:
void set(const ::ModelAnimation& model) {
boneCount = model.boneCount;
frameCount = model.frameCount;
bones = model.bones;
framePoses = model.framePoses;
keyframeCount = model.keyframeCount;
keyframePoses = model.keyframePoses;

// Duplicate the name. TextCopy() uses the null terminator, which we ignore here.
for (int i = 0; i < 32; i++) {
Expand Down
12 changes: 4 additions & 8 deletions include/raylib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ extern "C" {
#error "raylib-cpp requires raylib >= 5"
#endif

#if RAYLIB_VERSION_MAJOR < 5
#error "raylib-cpp requires raylib >= 5"
#endif

#if RAYLIB_VERSION_MAJOR > 5
#error "raylib-cpp requires raylib ~5.0. Use the `next` branch for the next version of raylib."
#if RAYLIB_VERSION_MAJOR < 6
#error "raylib-cpp requires raylib >= 6"
#endif

#if RAYLIB_VERSION_MINOR < 1
#error "raylib-cpp targets raylib 5.1 or higher."
#if RAYLIB_VERSION_MAJOR > 6
#error "raylib-cpp requires raylib ~6.0. Use the `next` branch for the next version of raylib."
#endif

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raylib-cpp",
"version": "5.5.0",
"version": "6.0.0-alpha1",
"description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib",
"main": "index.js",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion projects/CMake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (NOT raylib_FOUND)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG 5e6cdf3
GIT_TAG 9ae34d2
GIT_SHALLOW 1
)
FetchContent_MakeAvailable(raylib)
Expand Down