Skip to content

Update to raylib 5.0.0 #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Nov 18, 2023
Merged
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
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 4.5.2
VERSION 5.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 4.5](https://img.shields.io/badge/for_raylib-4.5-blue)](https://raylib.com) [![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 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](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": "4.5.2",
"version": "5.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 4.5.0
GIT_TAG ae50bfa2cc569c0f8d5bc4315d39db64005b1b08
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
Expand Down
21 changes: 21 additions & 0 deletions include/Color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,27 @@ class Color : public ::Color {
::DrawRectangleLinesEx(rec, lineThick, *this);
}

/**
* Get color multiplied with another color
*/
inline Color Tint(::Color tint) {
return ::ColorTint(*this, tint);
}

/**
* Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
*/
inline Color Brightness(float factor) {
return ::ColorBrightness(*this, factor);
}

/**
* Get color with contrast correction, contrast values between -1.0f and 1.0f
*/
inline Color Contrast(float contrast) {
return ::ColorContrast(*this, contrast);
}

/**
* Returns color with alpha applied, alpha goes from 0.0f to 1.0f
*/
Expand Down
28 changes: 18 additions & 10 deletions include/Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,10 @@ class Image : public ::Image {
}

/**
* Generate image: vertical gradient
* Generate image: linear gradient
*/
static ::Image GradientV(int width, int height, ::Color top, ::Color bottom) {
return ::GenImageGradientV(width, height, top, bottom);
}

/**
* Generate image: horizontal gradient
*/
static ::Image GradientH(int width, int height, ::Color left, ::Color right) {
return ::GenImageGradientH(width, height, left, right);
static ::Image GradientLinear(int width, int height, int direction, ::Color start, ::Color end) {
return ::GenImageGradientLinear(width, height, direction, start, end);
}

/**
Expand Down Expand Up @@ -305,6 +298,13 @@ class Image : public ::Image {
}
}

/**
* Export image to memory buffer
*/
inline unsigned char* ExportToMemory(const char *fileType, int *fileSize) {
return ::ExportImageToMemory(*this, fileType, fileSize);
}

/**
* Export image as code file defining an array of bytes, returns true on success
*
Expand Down Expand Up @@ -484,6 +484,14 @@ class Image : public ::Image {
return *this;
}

/**
* Rotate image by input angle in degrees (-359 to 359)
*/
inline Image& Rotate(int degrees) {
::ImageRotate(this, degrees);
return *this;
}

/**
* Rotate image clockwise 90deg
*/
Expand Down
2 changes: 1 addition & 1 deletion include/ModelAnimation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ModelAnimation : public ::ModelAnimation {
* Load model animations from file
*/
static std::vector<ModelAnimation> Load(const std::string& fileName) {
unsigned int count = 0;
int count = 0;
::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &count);
std::vector<ModelAnimation> mats(modelAnimations, modelAnimations + count);

Expand Down
11 changes: 0 additions & 11 deletions include/Vector2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,17 +354,6 @@ class Vector2 : public ::Vector2 {
::DrawLineBezier(*this, endPos, thick, color);
}

/**
* Draw line using quadratic bezier curves with a control point.
*/
inline void DrawLineBezierQuad(
::Vector2 endPos,
::Vector2 controlPos,
float thick,
::Color color = {0, 0, 0, 255}) const {
::DrawLineBezierQuad(*this, endPos, controlPos, thick, color);
}

/**
* Draw a color-filled circle (Vector version)
*/
Expand Down
24 changes: 24 additions & 0 deletions include/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ class Window {
return *this;
}

/**
* Toggle window state: borderless/windowed
*/
inline Window& ToggleBorderless() {
::ToggleBorderlessWindowed();
return *this;
}

/**
* Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
*/
Expand Down Expand Up @@ -222,6 +230,14 @@ class Window {
return *this;
}

/**
* Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
*/
inline Window& SetIcons(Image* images, int count) {
::SetWindowIcons(images, count);
return *this;
}

/**
* Set title for window
*/
Expand Down Expand Up @@ -285,6 +301,14 @@ class Window {
return *this;
}

/**
* Set window focused (only PLATFORM_DESKTOP)
*/
inline Window& SetFocused() {
::SetWindowFocused();
return *this;
}

/**
* Set window dimensions
*/
Expand Down
10 changes: 6 additions & 4 deletions include/raylib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ extern "C" {

#include RAYLIB_H_FILE // NOLINT

#if !defined(RAYLIB_VERSION_MAJOR) || !defined(RAYLIB_VERSION_MINOR) || RAYLIB_VERSION_MAJOR < 4 || RAYLIB_VERSION_MINOR < 5
#error "raylib-cpp requires at least raylib 4.5.0"
#if !defined(RAYLIB_VERSION_MAJOR) || !defined(RAYLIB_VERSION_MINOR)
#if RAYLIB_VERSION_MAJOR < 5
#error "raylib-cpp requires at least raylib 5.0.0"
#endif
#endif

#if RAYLIB_VERSION_MINOR > 5
#error "raylib-cpp targets raylib 4.5. Use the `next` branch for the next version of raylib."
#if RAYLIB_VERSION_MAJOR > 5
#error "raylib-cpp targets raylib 5. 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": "4.5.2",
"version": "5.0.0-alpha1",
"description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib",
"main": "index.js",
"private": true,
Expand Down
4 changes: 2 additions & 2 deletions 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 4.5.0
GIT_TAG 5.0
)
FetchContent_MakeAvailable(raylib)
endif()
Expand All @@ -20,7 +20,7 @@ if (NOT raylib_cpp_FOUND)
FetchContent_Declare(
raylib_cpp
GIT_REPOSITORY https://github.com/RobLoach/raylib-cpp.git
GIT_TAG v4.5.1
GIT_TAG v5.0.0
)
FetchContent_MakeAvailable(raylib_cpp)
endif()
Expand Down