Merge branch 'master' into master

This commit is contained in:
JupiterRider 2023-11-18 18:56:48 +01:00 committed by GitHub
commit 43d0a14b92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 168 additions and 82 deletions

View file

@ -1,3 +1,3 @@
module github.com/gen2brain/raylib-go/easings module github.com/gen2brain/raylib-go/easings
go 1.19 go 1.21

View file

@ -6,11 +6,15 @@ replace github.com/gen2brain/raylib-go/raylib => ../raylib
replace github.com/gen2brain/raylib-go/raygui => ../raygui replace github.com/gen2brain/raylib-go/raygui => ../raygui
replace github.com/gen2brain/raylib-go/easings => ../easings
replace github.com/gen2brain/raylib-go/physics => ../physics
require ( require (
github.com/gen2brain/raylib-go/easings v0.0.0-20231021203613-2d673bb5f4b3 github.com/gen2brain/raylib-go/easings v0.0.0-00010101000000-000000000000
github.com/gen2brain/raylib-go/physics v0.0.0-20231021203613-2d673bb5f4b3 github.com/gen2brain/raylib-go/physics v0.0.0-00010101000000-000000000000
github.com/gen2brain/raylib-go/raygui v0.0.0-20231110085703-5830da3d8795 github.com/gen2brain/raylib-go/raygui v0.0.0-00010101000000-000000000000
github.com/gen2brain/raylib-go/raylib v0.0.0-20231110085703-5830da3d8795 github.com/gen2brain/raylib-go/raylib v0.0.0-20231118125650-a1c890e8cbfc
github.com/jakecoffman/cp v1.2.1 github.com/jakecoffman/cp v1.2.1
github.com/neguse/go-box2d-lite v0.0.0-20170921151050-5d8ed9b7272b github.com/neguse/go-box2d-lite v0.0.0-20170921151050-5d8ed9b7272b
) )

View file

@ -1,5 +1,10 @@
module github.com/gen2brain/raylib-go/physics module github.com/gen2brain/raylib-go/physics
go 1.19 go 1.21
require github.com/gen2brain/raylib-go/raylib v0.0.0-20230621091943-a6644da2433f require github.com/gen2brain/raylib-go/raylib v0.0.0-20231118125650-a1c890e8cbfc
require (
github.com/ebitengine/purego v0.5.0 // indirect
golang.org/x/sys v0.14.0 // indirect
)

View file

@ -1,2 +1,6 @@
github.com/gen2brain/raylib-go/raylib v0.0.0-20230621091943-a6644da2433f h1:erUJFP3XPbdiOAxcixPObRpkGMcMyGo5PzG2890hZSo= github.com/ebitengine/purego v0.5.0 h1:JrMGKfRIAM4/QVKaesIIT7m/UVjTj5GYhRSQYwfVdpo=
github.com/gen2brain/raylib-go/raylib v0.0.0-20230621091943-a6644da2433f/go.mod h1:AwtGA3aTtYdezNxEVbfchaLw/z+CuRDh2Mlxy0FbBro= github.com/ebitengine/purego v0.5.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/gen2brain/raylib-go/raylib v0.0.0-20231118125650-a1c890e8cbfc h1:86mVUAyKFVue7oANaYbOysx3oBpnTuLgrE25Obi4A5s=
github.com/gen2brain/raylib-go/raylib v0.0.0-20231118125650-a1c890e8cbfc/go.mod h1:OrILUkoha5TCD4Btbw0YPoxe1sQj3q8xpFBqAoeRWyo=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=

View file

@ -1,5 +1,10 @@
module github.com/gen2brain/raylib-go/raygui module github.com/gen2brain/raylib-go/raygui
go 1.19 go 1.21
require github.com/gen2brain/raylib-go/raylib v0.0.0-20230621091943-a6644da2433f require github.com/gen2brain/raylib-go/raylib v0.0.0-20231118125650-a1c890e8cbfc
require (
github.com/ebitengine/purego v0.5.0 // indirect
golang.org/x/sys v0.14.0 // indirect
)

View file

@ -1,2 +1,6 @@
github.com/gen2brain/raylib-go/raylib v0.0.0-20230621091943-a6644da2433f h1:erUJFP3XPbdiOAxcixPObRpkGMcMyGo5PzG2890hZSo= github.com/ebitengine/purego v0.5.0 h1:JrMGKfRIAM4/QVKaesIIT7m/UVjTj5GYhRSQYwfVdpo=
github.com/gen2brain/raylib-go/raylib v0.0.0-20230621091943-a6644da2433f/go.mod h1:AwtGA3aTtYdezNxEVbfchaLw/z+CuRDh2Mlxy0FbBro= github.com/ebitengine/purego v0.5.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/gen2brain/raylib-go/raylib v0.0.0-20231118125650-a1c890e8cbfc h1:86mVUAyKFVue7oANaYbOysx3oBpnTuLgrE25Obi4A5s=
github.com/gen2brain/raylib-go/raylib v0.0.0-20231118125650-a1c890e8cbfc/go.mod h1:OrILUkoha5TCD4Btbw0YPoxe1sQj3q8xpFBqAoeRWyo=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=

View file

@ -1,6 +1,6 @@
/* /*
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file. Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
miniaudio - v0.11.19 - 2023-11-04 miniaudio - v0.11.21 - 2023-11-15
David Reid - mackron@gmail.com David Reid - mackron@gmail.com
@ -3723,7 +3723,7 @@ extern "C" {
#define MA_VERSION_MAJOR 0 #define MA_VERSION_MAJOR 0
#define MA_VERSION_MINOR 11 #define MA_VERSION_MINOR 11
#define MA_VERSION_REVISION 19 #define MA_VERSION_REVISION 21
#define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION) #define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
#if defined(_MSC_VER) && !defined(__clang__) #if defined(_MSC_VER) && !defined(__clang__)
@ -6716,7 +6716,8 @@ typedef enum
ma_device_notification_type_stopped, ma_device_notification_type_stopped,
ma_device_notification_type_rerouted, ma_device_notification_type_rerouted,
ma_device_notification_type_interruption_began, ma_device_notification_type_interruption_began,
ma_device_notification_type_interruption_ended ma_device_notification_type_interruption_ended,
ma_device_notification_type_unlocked
} ma_device_notification_type; } ma_device_notification_type;
typedef struct typedef struct
@ -17820,7 +17821,7 @@ MA_API ma_handle ma_dlopen(ma_log* pLog, const char* filename)
#ifdef MA_WIN32 #ifdef MA_WIN32
/* From MSDN: Desktop applications cannot use LoadPackagedLibrary; if a desktop application calls this function it fails with APPMODEL_ERROR_NO_PACKAGE.*/ /* From MSDN: Desktop applications cannot use LoadPackagedLibrary; if a desktop application calls this function it fails with APPMODEL_ERROR_NO_PACKAGE.*/
#if !defined(MA_WIN32_UWP) #if !defined(MA_WIN32_UWP) || !(defined(WINAPI_FAMILY) && ((defined(WINAPI_FAMILY_PHONE_APP) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)))
handle = (ma_handle)LoadLibraryA(filename); handle = (ma_handle)LoadLibraryA(filename);
#else #else
/* *sigh* It appears there is no ANSI version of LoadPackagedLibrary()... */ /* *sigh* It appears there is no ANSI version of LoadPackagedLibrary()... */
@ -18668,16 +18669,11 @@ static void ma_device__on_notification_rerouted(ma_device* pDevice)
} }
#endif #endif
/* Interruptions are only used on some platforms. */ #if defined(MA_EMSCRIPTEN)
#if defined(MA_APPLE_MOBILE) EMSCRIPTEN_KEEPALIVE
static void ma_device__on_notification_interruption_began(ma_device* pDevice) void ma_device__on_notification_unlocked(ma_device* pDevice)
{ {
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_began)); ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_unlocked));
}
static void ma_device__on_notification_interruption_ended(ma_device* pDevice)
{
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_ended));
} }
#endif #endif
@ -23511,6 +23507,39 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_
MA_ZERO_OBJECT(&pContext->wasapi); MA_ZERO_OBJECT(&pContext->wasapi);
#if defined(MA_WIN32_UWP)
{
/* Link to mmdevapi so we can get access to ActivateAudioInterfaceAsync(). */
pContext->wasapi.hMMDevapi = ma_dlopen(ma_context_get_log(pContext), "mmdevapi.dll");
if (pContext->wasapi.hMMDevapi) {
pContext->wasapi.ActivateAudioInterfaceAsync = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi, "ActivateAudioInterfaceAsync");
if (pContext->wasapi.ActivateAudioInterfaceAsync == NULL) {
ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi);
return MA_NO_BACKEND; /* ActivateAudioInterfaceAsync() could not be loaded. */
}
} else {
return MA_NO_BACKEND; /* Failed to load mmdevapi.dll which is required for ActivateAudioInterfaceAsync() */
}
}
#endif
/* Optionally use the Avrt API to specify the audio thread's latency sensitivity requirements */
pContext->wasapi.hAvrt = ma_dlopen(ma_context_get_log(pContext), "avrt.dll");
if (pContext->wasapi.hAvrt) {
pContext->wasapi.AvSetMmThreadCharacteristicsA = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hAvrt, "AvSetMmThreadCharacteristicsA");
pContext->wasapi.AvRevertMmThreadcharacteristics = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hAvrt, "AvRevertMmThreadCharacteristics");
/* If either function could not be found, disable use of avrt entirely. */
if (!pContext->wasapi.AvSetMmThreadCharacteristicsA || !pContext->wasapi.AvRevertMmThreadcharacteristics) {
pContext->wasapi.AvSetMmThreadCharacteristicsA = NULL;
pContext->wasapi.AvRevertMmThreadcharacteristics = NULL;
ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hAvrt);
pContext->wasapi.hAvrt = NULL;
}
}
/* /*
Annoyingly, WASAPI does not allow you to release an IAudioClient object from a different thread Annoyingly, WASAPI does not allow you to release an IAudioClient object from a different thread
than the one that retrieved it with GetService(). This can result in a deadlock in two than the one that retrieved it with GetService(). This can result in a deadlock in two
@ -23554,41 +23583,6 @@ static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_
ma_mutex_uninit(&pContext->wasapi.commandLock); ma_mutex_uninit(&pContext->wasapi.commandLock);
return result; return result;
} }
#if defined(MA_WIN32_UWP)
{
/* Link to mmdevapi so we can get access to ActivateAudioInterfaceAsync(). */
pContext->wasapi.hMMDevapi = ma_dlopen(ma_context_get_log(pContext), "mmdevapi.dll");
if (pContext->wasapi.hMMDevapi) {
pContext->wasapi.ActivateAudioInterfaceAsync = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi, "ActivateAudioInterfaceAsync");
if (pContext->wasapi.ActivateAudioInterfaceAsync == NULL) {
ma_semaphore_uninit(&pContext->wasapi.commandSem);
ma_mutex_uninit(&pContext->wasapi.commandLock);
ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hMMDevapi);
return MA_NO_BACKEND; /* ActivateAudioInterfaceAsync() could not be loaded. */
}
} else {
ma_semaphore_uninit(&pContext->wasapi.commandSem);
ma_mutex_uninit(&pContext->wasapi.commandLock);
return MA_NO_BACKEND; /* Failed to load mmdevapi.dll which is required for ActivateAudioInterfaceAsync() */
}
}
#endif
/* Optionally use the Avrt API to specify the audio thread's latency sensitivity requirements */
pContext->wasapi.hAvrt = ma_dlopen(ma_context_get_log(pContext), "avrt.dll");
if (pContext->wasapi.hAvrt) {
pContext->wasapi.AvSetMmThreadCharacteristicsA = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hAvrt, "AvSetMmThreadCharacteristicsA");
pContext->wasapi.AvRevertMmThreadcharacteristics = ma_dlsym(ma_context_get_log(pContext), pContext->wasapi.hAvrt, "AvRevertMmThreadCharacteristics");
/* If either function could not be found, disable use of avrt entirely. */
if (!pContext->wasapi.AvSetMmThreadCharacteristicsA || !pContext->wasapi.AvRevertMmThreadcharacteristics) {
pContext->wasapi.AvSetMmThreadCharacteristicsA = NULL;
pContext->wasapi.AvRevertMmThreadcharacteristics = NULL;
ma_dlclose(ma_context_get_log(pContext), pContext->wasapi.hAvrt);
pContext->wasapi.hAvrt = NULL;
}
}
} }
@ -31884,6 +31878,18 @@ size, allocate a block of memory of that size and then call AudioObjectGetProper
AudioDeviceID's so just do "dataSize/sizeof(AudioDeviceID)" to know the device count. AudioDeviceID's so just do "dataSize/sizeof(AudioDeviceID)" to know the device count.
*/ */
#if defined(MA_APPLE_MOBILE)
static void ma_device__on_notification_interruption_began(ma_device* pDevice)
{
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_began));
}
static void ma_device__on_notification_interruption_ended(ma_device* pDevice)
{
ma_device__on_notification(ma_device_notification_init(pDevice, ma_device_notification_type_interruption_ended));
}
#endif
static ma_result ma_result_from_OSStatus(OSStatus status) static ma_result ma_result_from_OSStatus(OSStatus status)
{ {
switch (status) switch (status)
@ -32800,9 +32806,9 @@ static ma_result ma_find_best_format__coreaudio(ma_context* pContext, AudioObjec
hasSupportedFormat = MA_FALSE; hasSupportedFormat = MA_FALSE;
for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) { for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) {
ma_format format; ma_format formatFromDescription;
ma_result formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &format); ma_result formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &formatFromDescription);
if (formatResult == MA_SUCCESS && format != ma_format_unknown) { if (formatResult == MA_SUCCESS && formatFromDescription != ma_format_unknown) {
hasSupportedFormat = MA_TRUE; hasSupportedFormat = MA_TRUE;
bestDeviceFormatSoFar = pDeviceFormatDescriptions[iFormat].mFormat; bestDeviceFormatSoFar = pDeviceFormatDescriptions[iFormat].mFormat;
break; break;
@ -39803,6 +39809,7 @@ static ma_result ma_device_uninit__webaudio(ma_device* pDevice)
*/ */
device.webaudio.close(); device.webaudio.close();
device.webaudio = undefined; device.webaudio = undefined;
device.pDevice = undefined;
}, pDevice->webaudio.deviceIndex); }, pDevice->webaudio.deviceIndex);
} }
#endif #endif
@ -39826,6 +39833,10 @@ static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__webaudio(co
*/ */
ma_uint32 periodSizeInFrames; ma_uint32 periodSizeInFrames;
if (nativeSampleRate == 0) {
nativeSampleRate = MA_DEFAULT_SAMPLE_RATE;
}
if (pDescriptor->periodSizeInFrames == 0) { if (pDescriptor->periodSizeInFrames == 0) {
if (pDescriptor->periodSizeInMilliseconds == 0) { if (pDescriptor->periodSizeInMilliseconds == 0) {
if (performanceProfile == ma_performance_profile_low_latency) { if (performanceProfile == ma_performance_profile_low_latency) {
@ -40298,6 +40309,8 @@ static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_co
device.scriptNode.connect(device.webaudio.destination); device.scriptNode.connect(device.webaudio.destination);
} }
device.pDevice = pDevice;
return miniaudio.track_device(device); return miniaudio.track_device(device);
}, pConfig->deviceType, channels, sampleRate, periodSizeInFrames, pDevice->webaudio.pIntermediaryBuffer, pDevice); }, pConfig->deviceType, channels, sampleRate, periodSizeInFrames, pDevice->webaudio.pIntermediaryBuffer, pDevice);
@ -40470,8 +40483,15 @@ static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_contex
miniaudio.unlock = function() { miniaudio.unlock = function() {
for(var i = 0; i < miniaudio.devices.length; ++i) { for(var i = 0; i < miniaudio.devices.length; ++i) {
var device = miniaudio.devices[i]; var device = miniaudio.devices[i];
if (device != null && device.webaudio != null && device.state === 2 /* ma_device_state_started */) { if (device != null &&
device.webaudio.resume(); device.webaudio != null &&
device.state === window.miniaudio.device_state.started) {
device.webaudio.resume().then(() => {
Module._ma_device__on_notification_unlocked(device.pDevice);
},
(error) => {console.error("Failed to resume audiocontext", error);
});
} }
} }
miniaudio.unlock_event_types.map(function(event_type) { miniaudio.unlock_event_types.map(function(event_type) {

View file

@ -73,7 +73,7 @@ static PlatformData platform = { 0 }; // Platform specific data
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Local Variables Definition // Local Variables Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#define SCANCODE_MAPPED_NUM 100 #define SCANCODE_MAPPED_NUM 232
static const KeyboardKey ScancodeToKey[SCANCODE_MAPPED_NUM] = { static const KeyboardKey ScancodeToKey[SCANCODE_MAPPED_NUM] = {
KEY_NULL, // SDL_SCANCODE_UNKNOWN KEY_NULL, // SDL_SCANCODE_UNKNOWN
0, 0,
@ -174,7 +174,28 @@ static const KeyboardKey ScancodeToKey[SCANCODE_MAPPED_NUM] = {
KEY_KP_8, // SDL_SCANCODE_KP_8 KEY_KP_8, // SDL_SCANCODE_KP_8
KEY_KP_9, // SDL_SCANCODE_KP_9 KEY_KP_9, // SDL_SCANCODE_KP_9
KEY_KP_0, // SDL_SCANCODE_KP_0 KEY_KP_0, // SDL_SCANCODE_KP_0
KEY_KP_DECIMAL // SDL_SCANCODE_KP_PERIOD KEY_KP_DECIMAL, // SDL_SCANCODE_KP_PERIOD
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
KEY_LEFT_CONTROL, //SDL_SCANCODE_LCTRL
KEY_LEFT_SHIFT, //SDL_SCANCODE_LSHIFT
KEY_LEFT_ALT, //SDL_SCANCODE_LALT
KEY_LEFT_SUPER, //SDL_SCANCODE_LGUI
KEY_RIGHT_CONTROL, //SDL_SCANCODE_RCTRL
KEY_RIGHT_SHIFT, //SDL_SCANCODE_RSHIFT
KEY_RIGHT_ALT, //SDL_SCANCODE_RALT
KEY_RIGHT_SUPER //SDL_SCANCODE_RGUI
}; };
static const int CursorsLUT[] = { static const int CursorsLUT[] = {
@ -1084,14 +1105,26 @@ void PollInputEvents(void)
// Check mouse events // Check mouse events
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
{ {
CORE.Input.Mouse.currentButtonState[event.button.button - 1] = 1; // NOTE: SDL2 mouse button order is LEFT, MIDDLE, RIGHT, but raylib uses LEFT, RIGHT, MIDDLE like GLFW
// The following conditions align SDL with raylib.h MouseButton enum order
int btn = event.button.button - 1;
if (btn == 2) btn = 1;
else if (btn == 1) btn = 2;
CORE.Input.Mouse.currentButtonState[btn] = 1;
touchAction = 1; touchAction = 1;
gestureUpdate = true; gestureUpdate = true;
} break; } break;
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
{ {
CORE.Input.Mouse.currentButtonState[event.button.button - 1] = 0; // NOTE: SDL2 mouse button order is LEFT, MIDDLE, RIGHT, but raylib uses LEFT, RIGHT, MIDDLE like GLFW
// The following conditions align SDL with raylib.h MouseButton enum order
int btn = event.button.button - 1;
if (btn == 2) btn = 1;
else if (btn == 1) btn = 2;
CORE.Input.Mouse.currentButtonState[btn] = 0;
touchAction = 0; touchAction = 0;
gestureUpdate = true; gestureUpdate = true;

View file

@ -1725,14 +1725,14 @@ int *LoadRandomSequence(unsigned int count, int min, int max)
#if defined(SUPPORT_RPRAND_GENERATOR) #if defined(SUPPORT_RPRAND_GENERATOR)
values = rprand_load_sequence(count, min, max); values = rprand_load_sequence(count, min, max);
#else #else
if (count > (abs(max - min) + 1)) return values; if (count > ((unsigned int)abs(max - min) + 1)) return values;
values = (int *)RL_CALLOC(count, sizeof(int)); values = (int *)RL_CALLOC(count, sizeof(int));
int value = 0; int value = 0;
bool dupValue = false; bool dupValue = false;
for (int i = 0; i < count;) for (int i = 0; i < (int)count;)
{ {
value = (rand()%(abs(max - min) + 1) + min); value = (rand()%(abs(max - min) + 1) + min);
dupValue = false; dupValue = false;
@ -1766,7 +1766,8 @@ void UnloadRandomSequence(int *sequence)
#endif #endif
} }
// Takes a screenshot of current screen (saved a .png) // Takes a screenshot of current screen
// NOTE: Provided fileName should not contain paths, saving to working directory
void TakeScreenshot(const char *fileName) void TakeScreenshot(const char *fileName)
{ {
#if defined(SUPPORT_MODULE_RTEXTURES) #if defined(SUPPORT_MODULE_RTEXTURES)
@ -1778,12 +1779,13 @@ void TakeScreenshot(const char *fileName)
Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
char path[512] = { 0 }; char path[512] = { 0 };
strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, fileName)); strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, GetFileName(fileName)));
ExportImage(image, path); // WARNING: Module required: rtextures ExportImage(image, path); // WARNING: Module required: rtextures
RL_FREE(imgData); RL_FREE(imgData);
TRACELOG(LOG_INFO, "SYSTEM: [%s] Screenshot taken successfully", path); if (FileExists(path)) TRACELOG(LOG_INFO, "SYSTEM: [%s] Screenshot taken successfully", path);
else TRACELOG(LOG_WARNING, "SYSTEM: [%s] Screenshot could not be saved", path);
#else #else
TRACELOG(LOG_WARNING,"IMAGE: ExportImage() requires module: rtextures"); TRACELOG(LOG_WARNING,"IMAGE: ExportImage() requires module: rtextures");
#endif #endif
@ -1836,10 +1838,10 @@ bool IsFileExtension(const char *fileName, const char *ext)
{ {
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_TEXT_MANIPULATION) #if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_TEXT_MANIPULATION)
int extCount = 0; int extCount = 0;
const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext
char fileExtLower[MAX_FILE_EXTENSION_SIZE + 1] = { 0 }; char fileExtLower[MAX_FILE_EXTENSION_SIZE + 1] = { 0 };
strncpy(fileExtLower, TextToLower(fileExt), MAX_FILE_EXTENSION_SIZE); // WARNING: Module required: rtext strncpy(fileExtLower, TextToLower(fileExt), MAX_FILE_EXTENSION_SIZE); // WARNING: Module required: rtext
for (int i = 0; i < extCount; i++) for (int i = 0; i < extCount; i++)
{ {

View file

@ -1,5 +1,10 @@
module github.com/gen2brain/raylib-go/rres module github.com/gen2brain/raylib-go/rres
go 1.19 go 1.21
require github.com/gen2brain/raylib-go/raylib v0.0.0-20230621091943-a6644da2433f require github.com/gen2brain/raylib-go/raylib v0.0.0-20231118125650-a1c890e8cbfc
require (
github.com/ebitengine/purego v0.5.0 // indirect
golang.org/x/sys v0.14.0 // indirect
)

View file

@ -1,2 +1,6 @@
github.com/gen2brain/raylib-go/raylib v0.0.0-20230621091943-a6644da2433f h1:erUJFP3XPbdiOAxcixPObRpkGMcMyGo5PzG2890hZSo= github.com/ebitengine/purego v0.5.0 h1:JrMGKfRIAM4/QVKaesIIT7m/UVjTj5GYhRSQYwfVdpo=
github.com/gen2brain/raylib-go/raylib v0.0.0-20230621091943-a6644da2433f/go.mod h1:AwtGA3aTtYdezNxEVbfchaLw/z+CuRDh2Mlxy0FbBro= github.com/ebitengine/purego v0.5.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/gen2brain/raylib-go/raylib v0.0.0-20231118125650-a1c890e8cbfc h1:86mVUAyKFVue7oANaYbOysx3oBpnTuLgrE25Obi4A5s=
github.com/gen2brain/raylib-go/raylib v0.0.0-20231118125650-a1c890e8cbfc/go.mod h1:OrILUkoha5TCD4Btbw0YPoxe1sQj3q8xpFBqAoeRWyo=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=