Merge branch 'master' into fix-fullscreen-resolution

This commit is contained in:
Hristo Stamenov 2021-03-08 23:45:37 +02:00 committed by GitHub
commit 633b4bc382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 67 additions and 30 deletions

32
.github/workflows/linux_examples.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: Linux Examples
on:
push:
pull_request:
branches: [ master ]
paths:
- 'examples/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Environment
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev
- name: Build Library
run: |
cd src
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC
cd ..
- name: Build Examples
run: |
cd examples
make PLATFORM=PLATFORM_DESKTOP -B
cd ..

26
.github/workflows/windows_examples.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Windows Examples
on:
push:
pull_request:
branches: [ master ]
paths:
- 'examples/**'
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1
- name: Build Library (MSVC16)
run: |
cd projects/VS2019
msbuild.exe raylib.sln /property:Configuration=Release /property:Platform=x86
cd ../..
shell: cmd

View File

@ -86,4 +86,5 @@ cmake_dependent_option(SUPPORT_FILEFORMAT_MP3 "Support loading MP3 for sound" O
cmake_dependent_option(SUPPORT_FILEFORMAT_FLAC "Support loading FLAC for sound" ${OFF} CUSTOMIZE_BUILD OFF) cmake_dependent_option(SUPPORT_FILEFORMAT_FLAC "Support loading FLAC for sound" ${OFF} CUSTOMIZE_BUILD OFF)
# utils.c # utils.c
cmake_dependent_option(SUPPORT_STANDARD_FILEIO "Support standard file io library (stdio.h)" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_TRACELOG "Show TraceLog() output messages. NOTE: By default LOG_DEBUG traces not shown" ON CUSTOMIZE_BUILD ON) cmake_dependent_option(SUPPORT_TRACELOG "Show TraceLog() output messages. NOTE: By default LOG_DEBUG traces not shown" ON CUSTOMIZE_BUILD ON)

View File

@ -54,6 +54,7 @@ if (${CUSTOMIZE_BUILD})
define_if("raylib" SUPPORT_FILEFORMAT_MOD) define_if("raylib" SUPPORT_FILEFORMAT_MOD)
define_if("raylib" SUPPORT_FILEFORMAT_FLAC) define_if("raylib" SUPPORT_FILEFORMAT_FLAC)
define_if("raylib" SUPPORT_FILEFORMAT_MP3) define_if("raylib" SUPPORT_FILEFORMAT_MP3)
define_if("raylib" SUPPORT_STANDARD_FILEIO)
define_if("raylib" SUPPORT_TRACELOG) define_if("raylib" SUPPORT_TRACELOG)
define_if("raylib" SUPPORT_COMPRESSION_API) define_if("raylib" SUPPORT_COMPRESSION_API)

View File

@ -90,7 +90,7 @@ int main(void)
DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY); DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY);
if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN); if (collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN);
DrawFPS(10, 10); DrawFPS(10, 10);

View File

@ -876,11 +876,6 @@ typedef enum {
// Callbacks to hook some internal functions // Callbacks to hook some internal functions
// WARNING: This callbacks are intended for advance users // WARNING: This callbacks are intended for advance users
typedef void (*TraceLogCallback)(int logType, const char *text, va_list args); // Logging: Redirect trace log messages typedef void (*TraceLogCallback)(int logType, const char *text, va_list args); // Logging: Redirect trace log messages
typedef void *(*MemAllocCallback)(int size); // Memory: Custom allocator
typedef void *(*MemReallocCallback)(void *ptr, int size); // Memory: Custom re-allocator
typedef void (*MemFreeCallback)(void *ptr); // Memory: Custom free
typedef unsigned char* (*LoadFileDataCallback)(const char* fileName, unsigned int* bytesRead); // FileIO: Load binary data typedef unsigned char* (*LoadFileDataCallback)(const char* fileName, unsigned int* bytesRead); // FileIO: Load binary data
typedef void (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data typedef void (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data
typedef char *(*LoadFileTextCallback)(const char* fileName); // FileIO: Load text data typedef char *(*LoadFileTextCallback)(const char* fileName); // FileIO: Load text data
@ -991,9 +986,6 @@ RLAPI void MemFree(void *ptr); // Internal me
// Set custom callbacks // Set custom callbacks
// WARNING: Callbacks setup is intended for advance users // WARNING: Callbacks setup is intended for advance users
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log
RLAPI void SetMemAllocCallback(MemAllocCallback callback); // Set custom memory allocator
RLAPI void SetMemReallocCallback(MemReallocCallback callback); // Set custom memory reallocator
RLAPI void SetMemFreeCallback(MemFreeCallback callback); // Set custom memory free
RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader
RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver
RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader

View File

@ -63,26 +63,18 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Log types messages
static int logTypeLevel = LOG_INFO; // Minimum log type level static int logTypeLevel = LOG_INFO; // Minimum log type level
static TraceLogCallback traceLog = NULL; // TraceLog callback function pointer static TraceLogCallback traceLog = NULL; // TraceLog callback function pointer
static MemAllocCallback memAlloc = NULL; // MemAlloc callback function pointer
static MemReallocCallback memRealloc = NULL; // MemRealloc callback funtion pointer
static MemFreeCallback memFree = NULL; // MemFree callback funtion pointer
static LoadFileDataCallback loadFileData = NULL; // LoadFileData callback funtion pointer static LoadFileDataCallback loadFileData = NULL; // LoadFileData callback funtion pointer
static SaveFileDataCallback saveFileData = NULL; // SaveFileText callback funtion pointer static SaveFileDataCallback saveFileData = NULL; // SaveFileText callback funtion pointer
static LoadFileTextCallback loadFileText = NULL; // LoadFileText callback funtion pointer static LoadFileTextCallback loadFileText = NULL; // LoadFileText callback funtion pointer
static SaveFileTextCallback saveFileText = NULL; // SaveFileText callback funtion pointer static SaveFileTextCallback saveFileText = NULL; // SaveFileText callback funtion pointer
//void *MemAllocDefault(unsigned int size) { return RL_MALLOC(size); } //----------------------------------------------------------------------------------
//void MemFreeDefault(void *ptr) { RL_FREE(ptr); } // Functions to set internal callbacks
//----------------------------------------------------------------------------------
void SetTraceLogCallback(TraceLogCallback callback) { traceLog = callback; } // Set custom trace log void SetTraceLogCallback(TraceLogCallback callback) { traceLog = callback; } // Set custom trace log
void SetMemAllocCallback(MemAllocCallback callback) { memAlloc = callback; } // Set custom memory allocator
void SetMemReallocCallback(MemReallocCallback callback) { memRealloc = callback; } // Set custom memory reallocator
void SetMemFreeCallback(MemFreeCallback callback) { memFree = callback; } // Set custom memory free
void SetLoadFileDataCallback(LoadFileDataCallback callback) { loadFileData = callback; } // Set custom file data loader void SetLoadFileDataCallback(LoadFileDataCallback callback) { loadFileData = callback; } // Set custom file data loader
void SetSaveFileDataCallback(SaveFileDataCallback callback) { saveFileData = callback; } // Set custom file data saver void SetSaveFileDataCallback(SaveFileDataCallback callback) { saveFileData = callback; } // Set custom file data saver
void SetLoadFileTextCallback(LoadFileTextCallback callback) { loadFileText = callback; } // Set custom file text loader void SetLoadFileTextCallback(LoadFileTextCallback callback) { loadFileText = callback; } // Set custom file text loader
@ -172,28 +164,21 @@ void TraceLog(int logType, const char *text, ...)
// NOTE: Initializes to zero by default // NOTE: Initializes to zero by default
void *MemAlloc(int size) void *MemAlloc(int size)
{ {
// WARNING: This implementation allows changing memAlloc at any void *ptr = RL_CALLOC(size, 1);
// point during program execution, it could be a security risk
void *ptr = NULL;
if (memAlloc) ptr = memAlloc(size);
else ptr = RL_CALLOC(size, 1);
return ptr; return ptr;
} }
// Internal memory reallocator // Internal memory reallocator
void *MemRealloc(void *ptr, int size) void *MemRealloc(void *ptr, int size)
{ {
void *ret = NULL; void *ret = RL_REALLOC(ptr, size);
if (memRealloc) ret = memRealloc(ptr, size);
else ret = RL_REALLOC(ptr, size);
return ret; return ret;
} }
// Internal memory free // Internal memory free
void MemFree(void *ptr) void MemFree(void *ptr)
{ {
if (memFree) memFree(ptr); RL_FREE(ptr);
else RL_FREE(ptr);
} }
// Load data from file into a buffer // Load data from file into a buffer