Skip to content

Commit 7da7b64

Browse files
committed
Update to raylib 5.0
1 parent 7da9ffa commit 7da7b64

File tree

5 files changed

+70
-16
lines changed

5 files changed

+70
-16
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int main() {
4949

5050
``` c
5151
bool InitPhysFS(); // Initialize the PhysFS file system
52-
bool InitPhysFSEx(const char* newDir, const char* mountPoint); // Initialize the PhysFS file system with the given mount point.
52+
bool InitPhysFSEx(const char* newDir, const char* mountPoint); // Initialize the PhysFS file system with a mount point.
5353
bool ClosePhysFS(); // Close the PhysFS file system
5454
bool IsPhysFSReady(); // Check if PhysFS has been initialized successfully
5555
bool MountPhysFS(const char* newDir, const char* mountPoint); // Mount the given directory or archive as a mount point
@@ -69,9 +69,9 @@ Texture2D LoadTextureFromPhysFS(const char* fileName); // Load a textur
6969
Wave LoadWaveFromPhysFS(const char* fileName); // Load wave data from PhysFS
7070
Music LoadMusicStreamFromPhysFS(const char* fileName); // Load music data from PhysFS
7171
Font LoadFontFromPhysFS(const char* fileName, int fontSize, int *fontChars, int charsCount); // Load a font from PhysFS
72-
Shader LoadShaderFromPhysFS(const char *vsFileName, const char *fsFileName); // Load shader from PhysFS
72+
Shader LoadShaderFromPhysFS(const char* vsFileName, const char* fsFileName); // Load shader from PhysFS
7373
void SetPhysFSCallbacks(); // Set the raylib file loader/saver callbacks to use PhysFS
74-
const char* GetPerfDirectory(const char *org, const char *app); // Get the user's current config directory for the application.
74+
const char* GetPerfDirectory(const char *organization, const char *application); // Get the user's current config directory for the application.
7575
```
7676
7777
### Defines

cmake/FindPhysFS.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set(PHYSFS_ARCHIVE_QPAK OFF CACHE BOOL "" FORCE)
1111
set(PHYSFS_ARCHIVE_SLB OFF CACHE BOOL "" FORCE)
1212
set(PHYSFS_ARCHIVE_ISO9660 OFF CACHE BOOL "" FORCE)
1313
set(PHYSFS_ARCHIVE_VDF OFF CACHE BOOL "" FORCE)
14+
set(PHYSFS_TARGETNAME_UNINSTALL "physfs_uninstall" CACHE STRING "" FORCE)
1415

1516
# library options
1617
set(PHYSFS_BUILD_STATIC ON CACHE BOOL "" FORCE)
@@ -23,7 +24,7 @@ include(FetchContent)
2324
FetchContent_Declare(
2425
physfs
2526
GIT_REPOSITORY https://github.com/icculus/physfs.git
26-
GIT_TAG release-3.2.0
27+
GIT_TAG 31209b7c2ce629dbda0db2329ce469ab9a2b90b9
2728
)
2829
FetchContent_MakeAvailable(physfs)
2930
include_directories(${physfs_SOURCE_DIR}/src)

cmake/FindRaylib.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include(FetchContent)
33
FetchContent_Declare(
44
raylib
55
GIT_REPOSITORY https://github.com/raysan5/raylib.git
6-
GIT_TAG 4.5.0
6+
GIT_TAG 5.0
77
GIT_SHALLOW 1
88
)
99
FetchContent_GetProperties(raylib)

raylib-physfs.h

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**********************************************************************************************
22
*
3-
* raylib-physfs 4.5.0 - Integrate PhysFS with raylib, allowing to load images, audio and fonts from data archives.
3+
* raylib-physfs 5.0.0 - Integrate PhysFS with raylib, allowing to load images, audio and fonts from data archives.
44
*
55
* Copyright 2021 Rob Loach (@RobLoach)
66
*
77
* DEPENDENCIES:
8-
* raylib 4.5+ https://www.raylib.com/
8+
* raylib 5.0+ https://www.raylib.com/
99
* physfs https://github.com/icculus/physfs
1010
*
1111
* LICENSE: zlib/libpng
@@ -54,10 +54,10 @@ RAYLIB_PHYSFS_DEF bool MountPhysFSFromMemory(const unsigned char *fileData, int
5454
RAYLIB_PHYSFS_DEF bool UnmountPhysFS(const char* oldDir); // Unmounts the given directory
5555
RAYLIB_PHYSFS_DEF bool FileExistsInPhysFS(const char* fileName); // Check if the given file exists in PhysFS
5656
RAYLIB_PHYSFS_DEF bool DirectoryExistsInPhysFS(const char* dirPath); // Check if the given directory exists in PhysFS
57-
RAYLIB_PHYSFS_DEF unsigned char* LoadFileDataFromPhysFS(const char* fileName, unsigned int* bytesRead); // Load a data buffer from PhysFS (memory should be freed)
57+
RAYLIB_PHYSFS_DEF unsigned char* LoadFileDataFromPhysFS(const char* fileName, int* bytesRead); // Load a data buffer from PhysFS (memory should be freed)
5858
RAYLIB_PHYSFS_DEF char* LoadFileTextFromPhysFS(const char* fileName); // Load text from a file (memory should be freed)
5959
RAYLIB_PHYSFS_DEF bool SetPhysFSWriteDirectory(const char* newDir); // Set the base directory where PhysFS should write files to (defaults to the current working directory)
60-
RAYLIB_PHYSFS_DEF bool SaveFileDataToPhysFS(const char* fileName, void* data, unsigned int bytesToWrite); // Save the given file data in PhysFS
60+
RAYLIB_PHYSFS_DEF bool SaveFileDataToPhysFS(const char* fileName, void* data, int bytesToWrite); // Save the given file data in PhysFS
6161
RAYLIB_PHYSFS_DEF bool SaveFileTextToPhysFS(const char* fileName, char* text); // Save the given file text in PhysFS
6262
RAYLIB_PHYSFS_DEF FilePathList LoadDirectoryFilesFromPhysFS(const char* dirPath); // Get filenames in a directory path (memory should be freed)
6363
RAYLIB_PHYSFS_DEF long GetFileModTimeFromPhysFS(const char* fileName); // Get file modification time (last write time) from PhysFS
@@ -80,7 +80,7 @@ RAYLIB_PHYSFS_DEF const char* GetPerfDirectory(const char *organization, const c
8080
#ifndef RAYLIB_PHYSFS_IMPLEMENTATION_ONCE
8181
#define RAYLIB_PHYSFS_IMPLEMENTATION_ONCE
8282

83-
// MiniPhysFS
83+
// PhysFS
8484
#define PHYSFS_IMPL
8585
#define PHYSFS_PLATFORM_IMPL
8686
#define PHYSFS_DECL RAYLIB_PHYSFS_DEF
@@ -113,13 +113,13 @@ void TracePhysFSError(const char* detail) {
113113
* Loads the given file as a byte array from PhysFS (read).
114114
*
115115
* @param fileName The file to load.
116-
* @param bytesRead An unsigned integer to save the bytes that were read.
116+
* @param bytesRead An integer to save the bytes that were read.
117117
*
118118
* @return The file data as a pointer. Make sure to use UnloadFileData() when finished using the file data.
119119
*
120120
* @see UnloadFileData()
121121
*/
122-
unsigned char* LoadFileDataFromPhysFS(const char* fileName, unsigned int* bytesRead) {
122+
unsigned char* LoadFileDataFromPhysFS(const char* fileName, int* bytesRead) {
123123
if (!FileExistsInPhysFS(fileName)) {
124124
TraceLog(LOG_WARNING, TextFormat("PHYSFS: Tried to load unexisting file '%s'", fileName));
125125
*bytesRead = 0;
@@ -320,7 +320,7 @@ bool DirectoryExistsInPhysFS(const char* dirPath) {
320320
* @return The loaded image on success. An empty Image otherwise.
321321
*/
322322
Image LoadImageFromPhysFS(const char* fileName) {
323-
unsigned int bytesRead;
323+
int bytesRead;
324324
unsigned char* fileData = LoadFileDataFromPhysFS(fileName, &bytesRead);
325325
if (bytesRead == 0) {
326326
struct Image output;
@@ -371,8 +371,23 @@ Texture2D LoadTextureFromPhysFS(const char* fileName) {
371371
* @see UnloadFileText()
372372
*/
373373
char* LoadFileTextFromPhysFS(const char *fileName) {
374-
unsigned int bytesRead;
375-
return (char*)LoadFileDataFromPhysFS(fileName, &bytesRead);
374+
int bytesRead;
375+
unsigned char* data = LoadFileDataFromPhysFS(fileName, &bytesRead);
376+
if (bytesRead == 0) {
377+
return 0;
378+
}
379+
380+
// Copy the data, and append a null terminator.
381+
char* text = (char*)MemAlloc(bytesRead + 1);
382+
for (int i = 0; i < bytesRead; i++) {
383+
text[i] = (char)data[i];
384+
}
385+
text[bytesRead] = '\0';
386+
387+
// Free the original data, and return the string.
388+
MemFree(data);
389+
390+
return text;
376391
}
377392

378393
/**
@@ -512,7 +527,7 @@ bool SetPhysFSWriteDirectory(const char* newDir) {
512527
*
513528
* @return True on success, false on failure.
514529
*/
515-
bool SaveFileDataToPhysFS(const char* fileName, void* data, unsigned int bytesToWrite) {
530+
bool SaveFileDataToPhysFS(const char* fileName, void* data, int bytesToWrite) {
516531
// Protect against empty writes.
517532
if (bytesToWrite == 0) {
518533
return true;

test/raylib-assert.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@ extern "C" {
188188
*/
189189
#define AssertColorSame(...) RAYLIB_ASSERT_VA_SELECT(AssertColorSame, __VA_ARGS__)
190190

191+
/**
192+
* Assert whether two Vector2s are the same.
193+
*
194+
* @param vector1 The first Vector2 to check.
195+
* @param vector2 The second Vector2 to check.
196+
* @param message (Optional) The message to provide on failed assertions.
197+
* @param p1 (Optional) The first parameter in the message.
198+
* @param p2 (Optional) The second parameter in the message.
199+
* @param p3 (Optional) The third parameter in the message.
200+
* @param p4 (Optional) The fourth parameter in the message.
201+
*/
202+
#define AssertVector2Same(...) RAYLIB_ASSERT_VA_SELECT(AssertVector2Same, __VA_ARGS__)
203+
191204
// Assert()
192205
#ifdef RAYLIB_ASSERT_NDEBUG
193206
#define Assert_0()
@@ -345,6 +358,31 @@ extern "C" {
345358
#define AssertColorSame_7(color1, color2, message, p1, p2, p3, p4) AssertColorSame_3(color1, color2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4))
346359
#endif
347360

361+
// AssertVector2Same()
362+
#ifdef RAYLIB_ASSERT_NDEBUG
363+
#define AssertVector2Same_0()
364+
#define AssertVector2Same_1(vector)
365+
#define AssertVector2Same_2(vector1, vector2)
366+
#define AssertVector2Same_3(vector1, vector2, message)
367+
#define AssertVector2Same_4(vector1, vector2, message, p1)
368+
#define AssertVector2Same_5(vector1, vector2, message, p1, p2)
369+
#define AssertVector2Same_6(vector1, vector2, message, p1, p2, p3)
370+
#define AssertVector2Same_7(vector1, vector2, message, p1, p2, p3, p4)
371+
#else
372+
#define AssertVector2Same_0() AssertFail_1("Vectors not provided to AssertVector2Same()")
373+
#define AssertVector2Same_1(vector) AssertFail_1("Expected two vectors for AssertVector2Same()")
374+
#define AssertVector2Same_2(vector1, vector2) AssertVector2Same_5(vector1, vector2, "AssertVector2Same(%s, %s) - vectors do not match", #vector1, #vector2)
375+
#define AssertVector2Same_3(vector1, vector2, message) do { \
376+
if (vector1.x != vector2.x || vector1.y != vector2.y) { \
377+
AssertFail_1(message); \
378+
}\
379+
} while (0)
380+
#define AssertVector2Same_4(vector1, vector2, message, p1) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1))
381+
#define AssertVector2Same_5(vector1, vector2, message, p1, p2) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2))
382+
#define AssertVector2Same_6(vector1, vector2, message, p1, p2, p3) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3))
383+
#define AssertVector2Same_7(vector1, vector2, message, p1, p2, p3, p4) AssertVector2Same_3(vector1, vector2, RAYLIB_ASSERT_TEXTFORMAT(message, p1, p2, p3, p4))
384+
#endif
385+
348386
#ifdef __cplusplus
349387
}
350388
#endif

0 commit comments

Comments
 (0)