Skip to content

Commit 6d9d02c

Browse files
authored
Merge pull request #316 from RobLoach/next
Update to raylib 5.5
2 parents 7581b1d + 96aaff5 commit 6d9d02c

28 files changed

+152
-56
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.11)
22
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
33
project (raylib_cpp
4-
VERSION 5.0.2
4+
VERSION 5.5.0
55
DESCRIPTION "raylib-cpp C++ Object Oriented Wrapper for raylib"
66
HOMEPAGE_URL "https://github.com/robloach/raylib-cpp"
77
LANGUAGES C CXX
@@ -41,4 +41,4 @@ if(BUILD_RAYLIB_CPP_EXAMPLES)
4141
${CMAKE_CURRENT_SOURCE_DIR}/tests/raylib_cpp_test.cpp
4242
)
4343
endif()
44-
endif()
44+
endif()

clib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "raylib-cpp",
3-
"version": "5.0.1",
3+
"version": "5.5.0",
44
"repo": "RobLoach/raylib-cpp",
55
"description": "raylib-cpp: C++ Object-Oriented Wrapper for raylib",
66
"homepage": "https://github.com/robloach/raylib-cpp",

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if (NOT raylib_FOUND)
1515
FetchContent_Declare(
1616
raylib
1717
GIT_REPOSITORY https://github.com/raysan5/raylib.git
18-
GIT_TAG ae50bfa2cc569c0f8d5bc4315d39db64005b1b08
18+
GIT_TAG 5.5
1919
GIT_SHALLOW 1
2020
)
2121
FetchContent_GetProperties(raylib)

include/AudioStream.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class AudioStream : public ::AudioStream {
8888
* Unload audio stream and free memory
8989
*/
9090
void Unload() {
91-
if (IsReady()) {
91+
if (IsValid()) {
9292
::UnloadAudioStream(*this);
9393
}
9494
}
@@ -182,7 +182,7 @@ class AudioStream : public ::AudioStream {
182182
/**
183183
* Retrieve whether or not the audio stream is ready.
184184
*/
185-
bool IsReady() const { return ::IsAudioStreamReady(*this); }
185+
bool IsValid() const { return ::IsAudioStreamValid(*this); }
186186

187187
/**
188188
* Load audio stream (to stream raw audio pcm data)
@@ -192,7 +192,7 @@ class AudioStream : public ::AudioStream {
192192
void Load(unsigned int SampleRate, unsigned int SampleSize, unsigned int Channels = 2) {
193193
Unload();
194194
set(::LoadAudioStream(SampleRate, SampleSize, Channels));
195-
if (!IsReady()) {
195+
if (!IsValid()) {
196196
throw RaylibException("Failed to load audio stream");
197197
}
198198
}

include/AutomationEventList.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class AutomationEventList : public ::AutomationEventList {
7171
void Load(const char* fileName) {
7272
Unload();
7373
set(::LoadAutomationEventList(fileName));
74-
if (!IsReady()) {
74+
if (!IsValid()) {
7575
throw RaylibException("Failed to load automation event list");
7676
}
7777
}
@@ -80,7 +80,7 @@ class AutomationEventList : public ::AutomationEventList {
8080
* Update audio stream buffers with data
8181
*/
8282
void Unload() {
83-
if (!IsReady()) {
83+
if (!IsValid()) {
8484
return;
8585
}
8686

@@ -96,7 +96,7 @@ class AutomationEventList : public ::AutomationEventList {
9696
#endif
9797
}
9898

99-
bool IsReady() { return events != nullptr; }
99+
bool IsValid() { return events != nullptr; }
100100

101101
bool Export(const char* fileName) { return ::ExportAutomationEventList(*this, fileName); }
102102

include/Camera3D.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ class Camera3D : public ::Camera3D {
9191
*/
9292
Vector2 GetWorldToScreen(::Vector3 position) const { return ::GetWorldToScreen(position, *this); }
9393

94+
/**
95+
* Get a ray trace from screen position (i.e mouse) in a viewport
96+
*/
97+
Ray GetScreenToWorldRay(::Vector2 position, int width, int height) {
98+
return ::GetScreenToWorldRayEx(position, *this, width, height);
99+
}
100+
94101
/**
95102
* Draw a billboard texture.
96103
*/

include/Color.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ class Color : public ::Color {
181181

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

184+
bool IsEqual(::Color color) {
185+
return ::ColorIsEqual(*this, color);
186+
}
187+
188+
bool operator==(const ::Color& other) const { return ::ColorIsEqual(*this, other); }
189+
bool operator!=(const ::Color& other) const { return !::ColorIsEqual(*this, other); }
190+
184191
/**
185192
* Get color multiplied with another color
186193
*/
@@ -201,6 +208,10 @@ class Color : public ::Color {
201208
*/
202209
Color Alpha(float alpha) const { return ::ColorAlpha(*this, alpha); }
203210

211+
Color Lerp(::Color color2, float factor) {
212+
return ::ColorLerp(*this, color2, factor);
213+
}
214+
204215
/**
205216
* Returns src alpha-blended into dst color with tint
206217
*/

include/Font.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class Font : public ::Font {
158158
*/
159159
void Load(const std::string& fileName) {
160160
set(::LoadFont(fileName.c_str()));
161-
if (!IsReady()) {
161+
if (!IsValid()) {
162162
throw RaylibException("Failed to load Font with from file: " + fileName);
163163
}
164164
}
@@ -175,14 +175,14 @@ class Font : public ::Font {
175175
*/
176176
void Load(const std::string& fileName, int fontSize, int* fontChars, int charCount) {
177177
set(::LoadFontEx(fileName.c_str(), fontSize, fontChars, charCount));
178-
if (!IsReady()) {
178+
if (!IsValid()) {
179179
throw RaylibException("Failed to load Font with from file with font size: " + fileName);
180180
}
181181
}
182182

183183
void Load(const ::Image& image, ::Color key, int firstChar) {
184184
set(::LoadFontFromImage(image, key, firstChar));
185-
if (!IsReady()) {
185+
if (!IsValid()) {
186186
throw RaylibException("Failed to load Font with from image");
187187
}
188188
}
@@ -195,15 +195,15 @@ class Font : public ::Font {
195195
int* fontChars,
196196
int charsCount) {
197197
set(::LoadFontFromMemory(fileType.c_str(), fileData, dataSize, fontSize, fontChars, charsCount));
198-
if (!IsReady()) {
198+
if (!IsValid()) {
199199
throw RaylibException("Failed to load Font " + fileType + " with from file data");
200200
}
201201
}
202202

203203
/**
204204
* Returns if the font is ready to be used.
205205
*/
206-
bool IsReady() const { return ::IsFontReady(*this); }
206+
bool IsValid() const { return ::IsFontValid(*this); }
207207

208208
/**
209209
* Draw text using font and additional parameters.

include/Gamepad.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ class Gamepad {
8585
float GetAxisMovement(int axis) const { return ::GetGamepadAxisMovement(number, axis); }
8686

8787
int SetMappings(const std::string& mappings) { return SetGamepadMappings(mappings.c_str()); }
88+
89+
/**
90+
* Set gamepad vibration for both motors (duration in seconds)
91+
*/
92+
void SetVibration(float leftMotor, float rightMotor, float duration) {
93+
::SetGamepadVibration(number, leftMotor, rightMotor, duration);
94+
}
8895
protected:
8996
void set(int gamepadNumber) { number = gamepadNumber; }
9097
};

include/Image.hpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ class Image : public ::Image {
164164
*/
165165
static ::Image Cellular(int width, int height, int tileSize) { return ::GenImageCellular(width, height, tileSize); }
166166

167+
/**
168+
* Get clipboard image content.
169+
*/
170+
static ::Image GetClipboard() { return ::GetClipboardImage(); }
171+
167172
~Image() { Unload(); }
168173

169174
Image& operator=(const ::Image& image) {
@@ -208,7 +213,7 @@ class Image : public ::Image {
208213
*/
209214
void Load(const std::string& fileName) {
210215
set(::LoadImage(fileName.c_str()));
211-
if (!IsReady()) {
216+
if (!IsValid()) {
212217
throw RaylibException("Failed to load Image from file: " + fileName);
213218
}
214219
}
@@ -222,7 +227,7 @@ class Image : public ::Image {
222227
*/
223228
void Load(const std::string& fileName, int width, int height, int format, int headerSize) {
224229
set(::LoadImageRaw(fileName.c_str(), width, height, format, headerSize));
225-
if (!IsReady()) {
230+
if (!IsValid()) {
226231
throw RaylibException("Failed to load Image from file: " + fileName);
227232
}
228233
}
@@ -236,7 +241,7 @@ class Image : public ::Image {
236241
*/
237242
void Load(const std::string& fileName, int* frames) {
238243
set(::LoadImageAnim(fileName.c_str(), frames));
239-
if (!IsReady()) {
244+
if (!IsValid()) {
240245
throw RaylibException("Failed to load Image from file: " + fileName);
241246
}
242247
}
@@ -250,7 +255,7 @@ class Image : public ::Image {
250255
*/
251256
void Load(const std::string& fileType, const unsigned char* fileData, int dataSize) {
252257
set(::LoadImageFromMemory(fileType.c_str(), fileData, dataSize));
253-
if (!IsReady()) {
258+
if (!IsValid()) {
254259
throw RaylibException("Failed to load Image data with file type: " + fileType);
255260
}
256261
}
@@ -264,7 +269,7 @@ class Image : public ::Image {
264269
*/
265270
void Load(const ::Texture2D& texture) {
266271
set(::LoadImageFromTexture(texture));
267-
if (!IsReady()) {
272+
if (!IsValid()) {
268273
throw RaylibException("Failed to load Image from texture.");
269274
}
270275
}
@@ -605,6 +610,13 @@ class Image : public ::Image {
605610
::ImageDrawLineV(this, start, end, color);
606611
}
607612

613+
/**
614+
* Description: Draw a line defining thickness within an image
615+
*/
616+
void DrawLine(::Vector2 start, ::Vector2 end, int thick, ::Color color = {255, 255, 255, 255}) {
617+
ImageDrawLineEx(this, start, end, thick, color);
618+
}
619+
608620
void DrawCircle(int centerX, int centerY, int radius, ::Color color = {255, 255, 255, 255}) {
609621
::ImageDrawCircle(this, centerX, centerY, radius, color);
610622
}
@@ -629,6 +641,8 @@ class Image : public ::Image {
629641
::ImageDrawRectangleLines(this, rec, thick, color);
630642
}
631643

644+
// TODO: Add ImageDrawTriangle()
645+
632646
void Draw(const ::Image& src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint = {255, 255, 255, 255}) {
633647
::ImageDraw(this, src, srcRec, dstRec, tint);
634648
}
@@ -728,7 +742,19 @@ class Image : public ::Image {
728742
*
729743
* @return True or false depending on whether the Image has been loaded.
730744
*/
731-
bool IsReady() const { return ::IsImageReady(*this); }
745+
bool IsValid() const { return ::IsImageValid(*this); }
746+
747+
/**
748+
* Create an image from a selected channel of another image (GRAYSCALE)
749+
*/
750+
::Image Channel(int selectedChannel) { return ::ImageFromChannel(*this, selectedChannel); }
751+
752+
/**
753+
* Apply custom square convolution kernel to image
754+
*/
755+
void KernelConvolution(const float* kernel, int kernelSize) {
756+
::ImageKernelConvolution(this, kernel, kernelSize);
757+
}
732758
protected:
733759
void set(const ::Image& image) {
734760
data = image.data;

0 commit comments

Comments
 (0)