Skip to content

Commit

Permalink
Update to raylib 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLoach committed Nov 18, 2024
1 parent 3a6e7bb commit 96aaff5
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 12 deletions.
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.0.1",
"version": "5.5.0",
"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 5e6cdf3
GIT_TAG 5.5
GIT_SHALLOW 1
)
FetchContent_GetProperties(raylib)
Expand Down
7 changes: 7 additions & 0 deletions include/Camera3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ class Camera3D : public ::Camera3D {
*/
Vector2 GetWorldToScreen(::Vector3 position) const { return ::GetWorldToScreen(position, *this); }

/**
* Get a ray trace from screen position (i.e mouse) in a viewport
*/
Ray GetScreenToWorldRay(::Vector2 position, int width, int height) {
return ::GetScreenToWorldRayEx(position, *this, width, height);
}

/**
* Draw a billboard texture.
*/
Expand Down
11 changes: 11 additions & 0 deletions include/Color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ class Color : public ::Color {

void DrawRectangleLines(::Rectangle rec, float lineThick) const { ::DrawRectangleLinesEx(rec, lineThick, *this); }

bool IsEqual(::Color color) {
return ::ColorIsEqual(*this, color);
}

bool operator==(const ::Color& other) const { return ::ColorIsEqual(*this, other); }
bool operator!=(const ::Color& other) const { return !::ColorIsEqual(*this, other); }

/**
* Get color multiplied with another color
*/
Expand All @@ -201,6 +208,10 @@ class Color : public ::Color {
*/
Color Alpha(float alpha) const { return ::ColorAlpha(*this, alpha); }

Color Lerp(::Color color2, float factor) {
return ::ColorLerp(*this, color2, factor);
}

/**
* Returns src alpha-blended into dst color with tint
*/
Expand Down
7 changes: 7 additions & 0 deletions include/Gamepad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ class Gamepad {
float GetAxisMovement(int axis) const { return ::GetGamepadAxisMovement(number, axis); }

int SetMappings(const std::string& mappings) { return SetGamepadMappings(mappings.c_str()); }

/**
* Set gamepad vibration for both motors (duration in seconds)
*/
void SetVibration(float leftMotor, float rightMotor, float duration) {
::SetGamepadVibration(number, leftMotor, rightMotor, duration);
}
protected:
void set(int gamepadNumber) { number = gamepadNumber; }
};
Expand Down
26 changes: 26 additions & 0 deletions include/Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ class Image : public ::Image {
*/
static ::Image Cellular(int width, int height, int tileSize) { return ::GenImageCellular(width, height, tileSize); }

/**
* Get clipboard image content.
*/
static ::Image GetClipboard() { return ::GetClipboardImage(); }

~Image() { Unload(); }

Image& operator=(const ::Image& image) {
Expand Down Expand Up @@ -605,6 +610,13 @@ class Image : public ::Image {
::ImageDrawLineV(this, start, end, color);
}

/**
* Description: Draw a line defining thickness within an image
*/
void DrawLine(::Vector2 start, ::Vector2 end, int thick, ::Color color = {255, 255, 255, 255}) {
ImageDrawLineEx(this, start, end, thick, color);
}

void DrawCircle(int centerX, int centerY, int radius, ::Color color = {255, 255, 255, 255}) {
::ImageDrawCircle(this, centerX, centerY, radius, color);
}
Expand All @@ -629,6 +641,8 @@ class Image : public ::Image {
::ImageDrawRectangleLines(this, rec, thick, color);
}

// TODO: Add ImageDrawTriangle()

void Draw(const ::Image& src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint = {255, 255, 255, 255}) {
::ImageDraw(this, src, srcRec, dstRec, tint);
}
Expand Down Expand Up @@ -729,6 +743,18 @@ class Image : public ::Image {
* @return True or false depending on whether the Image has been loaded.
*/
bool IsValid() const { return ::IsImageValid(*this); }

/**
* Create an image from a selected channel of another image (GRAYSCALE)
*/
::Image Channel(int selectedChannel) { return ::ImageFromChannel(*this, selectedChannel); }

/**
* Apply custom square convolution kernel to image
*/
void KernelConvolution(const float* kernel, int kernelSize) {
::ImageKernelConvolution(this, kernel, kernelSize);
}
protected:
void set(const ::Image& image) {
data = image.data;
Expand Down
11 changes: 11 additions & 0 deletions include/MeshUnmanaged.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ class MeshUnmanaged : public ::Mesh {
}
}

/**
* Export mesh as code file (.h) defining multiple arrays of vertex attributes
*
* @throws raylib::RaylibException Throws if failed to export the Mesh.
*/
void ExportCode(const std::string& fileName) {
if (!::ExportMeshAsCode(*this, fileName.c_str())) {
throw RaylibException("Failed to export the Mesh");
}
}

/**
* Compute mesh bounding box limits
*/
Expand Down
22 changes: 22 additions & 0 deletions include/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ class Model : public ::Model {
return *this;
}

/**
* Update model animation pose
*/
Model& UpdateAnimationBones(const ::ModelAnimation& anim, int frame) {
::UpdateModelAnimationBones(*this, anim, frame);
return *this;
}

/**
* Check model animation skeleton match
*/
Expand Down Expand Up @@ -170,6 +178,20 @@ class Model : public ::Model {
::DrawModelWiresEx(*this, position, rotationAxis, rotationAngle, scale, tint);
}

/**
* Draw a model as points
*/
void DrawPoints(::Vector3 position, float scale = 1.0f, ::Color tint = {255, 255, 255, 255}) {
::DrawModelPoints(*this, position, scale, tint);
}

/**
* Draw a model as points
*/
void DrawPoints(::Vector3 position, ::Vector3 rotationAxis, float rotationAngle = 0.0f, ::Vector3 scale = {1.0f, 1.0f, 1.0f}, ::Color tint = {255, 255, 255, 255}) {
::DrawModelPointsEx(*this, position, rotationAxis, rotationAngle, scale, tint);
}

/**
* Compute model bounding box limits (considers all meshes)
*/
Expand Down
8 changes: 8 additions & 0 deletions include/ModelAnimation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ class ModelAnimation : public ::ModelAnimation {
return *this;
}

/**
* Update model animation mesh bone matrices (GPU skinning)
*/
ModelAnimation& UpdateBones(const ::Model& model, int frame) {
::UpdateModelAnimationBones(model, *this, frame);
return *this;
}

/**
* Check model animation skeleton match
*/
Expand Down
12 changes: 2 additions & 10 deletions include/Rectangle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class Rectangle : public ::Rectangle {
color2);
}

void DrawGradient(::Color col1, ::Color col2, ::Color col3, ::Color col4) const {
::DrawRectangleGradientEx(*this, col1, col2, col3, col4);
void DrawGradient(::Color topLeft, ::Color bottomLeft, ::Color topRight, ::Color bottomRight) const {
::DrawRectangleGradientEx(*this, topLeft, bottomLeft, topRight, bottomRight);
}

void DrawLines(::Color color) const {
Expand All @@ -86,19 +86,11 @@ class Rectangle : public ::Rectangle {
}

void DrawRoundedLines(float roundness, int segments, ::Color color) const {
#if RAYLIB_VERSION_MAJOR == 5 && RAYLIB_VERSION_MINOR == 0
::DrawRectangleRoundedLines(*this, roundness, segments, 1.0f, color);
#else
::DrawRectangleRoundedLines(*this, roundness, segments, color);
#endif
}

void DrawRoundedLines(float roundness, int segments, float lineThick, ::Color color) const {
#if RAYLIB_VERSION_MAJOR == 5 && RAYLIB_VERSION_MINOR == 0
::DrawRectangleRoundedLines(*this, roundness, segments, lineThick, color);
#else
DrawRectangleRoundedLinesEx(*this, roundness, segments, lineThick, color);
#endif
}

/**
Expand Down

0 comments on commit 96aaff5

Please sign in to comment.