mirror of
https://github.com/raysan5/raylib.git
synced 2026-04-25 16:23:58 -04:00
Formating review, using imperative mode in comments
This commit is contained in:
@ -479,7 +479,7 @@ void ToggleFullscreen(void)
|
|||||||
if (!FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
|
if (!FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
|
||||||
{
|
{
|
||||||
FLAG_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
|
FLAG_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
|
||||||
// Store previous window position (in case we exit fullscreen)
|
// Store previous window position (in case of exiting fullscreen)
|
||||||
Vector2 currentPosition = GetWindowPosition();
|
Vector2 currentPosition = GetWindowPosition();
|
||||||
CORE.Window.previousPosition.x = currentPosition.x;
|
CORE.Window.previousPosition.x = currentPosition.x;
|
||||||
CORE.Window.previousPosition.y = currentPosition.y;
|
CORE.Window.previousPosition.y = currentPosition.y;
|
||||||
@ -493,7 +493,7 @@ void ToggleFullscreen(void)
|
|||||||
{
|
{
|
||||||
FLAG_CLEAR(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
|
FLAG_CLEAR(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
|
||||||
|
|
||||||
// we update the window position right away
|
// Update the window position right away
|
||||||
CORE.Window.position = CORE.Window.previousPosition;
|
CORE.Window.position = CORE.Window.previousPosition;
|
||||||
RGFW_window_setFullscreen(platform.window, 0);
|
RGFW_window_setFullscreen(platform.window, 0);
|
||||||
RGFW_window_move(platform.window, CORE.Window.position.x, CORE.Window.position.y);
|
RGFW_window_move(platform.window, CORE.Window.position.x, CORE.Window.position.y);
|
||||||
@ -957,17 +957,17 @@ Vector2 GetWindowScaleDPI(void)
|
|||||||
else monitor = RGFW_getPrimaryMonitor();
|
else monitor = RGFW_getPrimaryMonitor();
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
// apple does < 1.0f scaling, example: 0.66f, 0.5f
|
// Apple does < 1.0f scaling, example: 0.66f, 0.5f
|
||||||
// we want to convert this to be consistent
|
// it needs to be convert to be consistent
|
||||||
return (Vector2){ 1.0f / monitor->scaleX, 1.0f / monitor->scaleX };
|
return (Vector2){ 1.0f/monitor->scaleX, 1.0f/monitor->scaleX };
|
||||||
#else
|
#else
|
||||||
// linux and windows do >= 1.0f scaling, example: 1.0f, 1.25f, 2.0f
|
// Linux and Windows do >= 1.0f scaling, example: 1.0f, 1.25f, 2.0f
|
||||||
return (Vector2){ monitor->scaleX, monitor->scaleX };
|
return (Vector2){ monitor->scaleX, monitor->scaleX };
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not part of raylib. Mac has a different pixel ratio for retina displays
|
// Get monitor pixel ratio
|
||||||
// and we want to be able to handle it
|
// WARNING: Function not used, neither exposed by raylib
|
||||||
float GetMonitorPixelRatio(void)
|
float GetMonitorPixelRatio(void)
|
||||||
{
|
{
|
||||||
RGFW_monitor *monitor = NULL;
|
RGFW_monitor *monitor = NULL;
|
||||||
@ -1283,8 +1283,8 @@ void PollInputEvents(void)
|
|||||||
{
|
{
|
||||||
if (CORE.Window.dropFileCount == 0)
|
if (CORE.Window.dropFileCount == 0)
|
||||||
{
|
{
|
||||||
// When a new file is dropped, we reserve a fixed number of slots for all possible dropped files
|
// When a new file is dropped, reserve a fixed number of slots for all possible dropped files
|
||||||
// at the moment we limit the number of drops at once to 1024 files but this behaviour should probably be reviewed
|
// at the moment limiting the number of drops at once to 1024 files but this behaviour should probably be reviewed
|
||||||
// TODO: Pointers should probably be reallocated for any new file added...
|
// TODO: Pointers should probably be reallocated for any new file added...
|
||||||
CORE.Window.dropFilepaths = (char **)RL_CALLOC(1024, sizeof(char *));
|
CORE.Window.dropFilepaths = (char **)RL_CALLOC(1024, sizeof(char *));
|
||||||
|
|
||||||
@ -1331,19 +1331,20 @@ void PollInputEvents(void)
|
|||||||
CORE.Window.currentFbo.width = CORE.Window.render.width;
|
CORE.Window.currentFbo.width = CORE.Window.render.width;
|
||||||
CORE.Window.currentFbo.height = CORE.Window.render.height;
|
CORE.Window.currentFbo.height = CORE.Window.render.height;
|
||||||
#elif defined(PLATFORM_WEB_RGFW)
|
#elif defined(PLATFORM_WEB_RGFW)
|
||||||
// do nothing for web
|
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
SetupViewport(platform.window->w, platform.window->h);
|
SetupViewport(platform.window->w, platform.window->h);
|
||||||
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
|
||||||
|
// Consider content scaling if required
|
||||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||||
{
|
{
|
||||||
Vector2 scaleDpi = GetWindowScaleDPI();
|
Vector2 scaleDpi = GetWindowScaleDPI();
|
||||||
CORE.Window.screen.width = (int)(platform.window->w/scaleDpi.x);
|
CORE.Window.screen.width = (int)(platform.window->w/scaleDpi.x);
|
||||||
CORE.Window.screen.height = (int)(platform.window->h/scaleDpi.y);
|
CORE.Window.screen.height = (int)(platform.window->h/scaleDpi.y);
|
||||||
CORE.Window.screenScale = MatrixScale(scaleDpi.x, scaleDpi.y, 1.0f);
|
CORE.Window.screenScale = MatrixScale(scaleDpi.x, scaleDpi.y, 1.0f);
|
||||||
// mouse scale doesnt seem needed
|
|
||||||
// SetMouseScale(1.0f/scaleDpi.x, 1.0f/scaleDpi.y);
|
// Mouse scale does not seem to be needed
|
||||||
|
//SetMouseScale(1.0f/scaleDpi.x, 1.0f/scaleDpi.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1403,7 +1404,7 @@ void PollInputEvents(void)
|
|||||||
|
|
||||||
case RGFW_keyChar:
|
case RGFW_keyChar:
|
||||||
{
|
{
|
||||||
// NOTE: event.text.text data comes an UTF-8 text sequence but we register codepoints (int)
|
// NOTE: event.text.text data comes an UTF-8 text sequence but registering codepoints (int)
|
||||||
// Check if there is space available in the queue
|
// Check if there is space available in the queue
|
||||||
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
|
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
|
||||||
{
|
{
|
||||||
@ -1664,7 +1665,7 @@ int InitPlatform(void)
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
// If everything work as expected, we can continue
|
// If everything work as expected, continue
|
||||||
CORE.Window.position.x = platform.window->x;
|
CORE.Window.position.x = platform.window->x;
|
||||||
CORE.Window.position.y = platform.window->y;
|
CORE.Window.position.y = platform.window->y;
|
||||||
CORE.Window.render.width = CORE.Window.screen.width;
|
CORE.Window.render.width = CORE.Window.screen.width;
|
||||||
|
|||||||
@ -250,10 +250,10 @@ static const int CursorsLUT[] = {
|
|||||||
//SDL_SYSTEM_CURSOR_WAITARROW, // No equivalent implemented on MouseCursor enum on raylib.h
|
//SDL_SYSTEM_CURSOR_WAITARROW, // No equivalent implemented on MouseCursor enum on raylib.h
|
||||||
};
|
};
|
||||||
|
|
||||||
// SDL3 Migration Layer made to avoid 'ifdefs' inside functions when we can
|
// SDL3 migration layer made to avoid 'ifdefs' inside functions
|
||||||
#if defined(USING_VERSION_SDL3)
|
#if defined(USING_VERSION_SDL3)
|
||||||
|
|
||||||
// SDL3 Migration:
|
// SDL3 migration:
|
||||||
// SDL_WINDOW_FULLSCREEN_DESKTOP has been removed,
|
// SDL_WINDOW_FULLSCREEN_DESKTOP has been removed,
|
||||||
// SDL_GetWindowFullscreenMode() can be called
|
// SDL_GetWindowFullscreenMode() can be called
|
||||||
// to see whether an exclusive fullscreen mode will be used
|
// to see whether an exclusive fullscreen mode will be used
|
||||||
@ -265,10 +265,10 @@ static const int CursorsLUT[] = {
|
|||||||
#define SDL_ENABLE true
|
#define SDL_ENABLE true
|
||||||
|
|
||||||
// SDL3 Migration: SDL_INIT_TIMER - no longer needed before calling SDL_AddTimer()
|
// SDL3 Migration: SDL_INIT_TIMER - no longer needed before calling SDL_AddTimer()
|
||||||
#define SDL_INIT_TIMER 0x0 // It's a flag, so no problem in setting it to zero if we use in a bitor (|)
|
#define SDL_INIT_TIMER 0x0 // It's a flag, so no problem in setting it to zero to be used in a bitor (|)
|
||||||
|
|
||||||
// SDL3 Migration: The SDL_WINDOW_SHOWN flag has been removed. Windows are shown by default and can be created hidden by using the SDL_WINDOW_HIDDEN flag
|
// SDL3 Migration: The SDL_WINDOW_SHOWN flag has been removed. Windows are shown by default and can be created hidden by using the SDL_WINDOW_HIDDEN flag
|
||||||
#define SDL_WINDOW_SHOWN 0x0 // It's a flag, so no problem in setting it to zero if we use in a bitor (|)
|
#define SDL_WINDOW_SHOWN 0x0 // It's a flag, so no problem in setting it to zero to be used in a bitor (|)
|
||||||
|
|
||||||
// SDL3 Migration: Renamed
|
// SDL3 Migration: Renamed
|
||||||
// IMPORTANT: Might need to call SDL_CleanupEvent somewhere see :https://github.com/libsdl-org/SDL/issues/3540#issuecomment-1793449852
|
// IMPORTANT: Might need to call SDL_CleanupEvent somewhere see :https://github.com/libsdl-org/SDL/issues/3540#issuecomment-1793449852
|
||||||
@ -414,13 +414,14 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID)
|
|||||||
|
|
||||||
#else // SDL2 fallback
|
#else // SDL2 fallback
|
||||||
|
|
||||||
// Since SDL2 doesn't have this function we leave a stub
|
// Since SDL2 doesn't have this function, leaving a stub
|
||||||
// SDL_GetClipboardData function is available since SDL 3.1.3. (e.g. SDL3)
|
// SDL_GetClipboardData function is available since SDL 3.1.3. (e.g. SDL3)
|
||||||
void *SDL_GetClipboardData(const char *mime_type, size_t *size)
|
void *SDL_GetClipboardData(const char *mime_type, size_t *size)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "SDL: Getting clipboard data that is not text not available in SDL2");
|
TRACELOG(LOG_WARNING, "SDL: Getting clipboard data that is not text not available in SDL2");
|
||||||
|
|
||||||
// We could possibly implement it ourselves in this case for some easier platforms
|
// TODO: Implement getting clipboard data
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif // USING_VERSION_SDL3
|
#endif // USING_VERSION_SDL3
|
||||||
@ -573,8 +574,6 @@ void SetWindowState(unsigned int flags)
|
|||||||
}
|
}
|
||||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_UNFOCUSED))
|
if (FLAG_IS_SET(flags, FLAG_WINDOW_UNFOCUSED))
|
||||||
{
|
{
|
||||||
// NOTE: To be able to implement this part it seems that we should
|
|
||||||
// do it ourselves, via 'windows.h', 'X11/Xlib.h' or even 'Cocoa.h'
|
|
||||||
TRACELOG(LOG_WARNING, "SetWindowState() - FLAG_WINDOW_UNFOCUSED is not supported on PLATFORM_DESKTOP_SDL");
|
TRACELOG(LOG_WARNING, "SetWindowState() - FLAG_WINDOW_UNFOCUSED is not supported on PLATFORM_DESKTOP_SDL");
|
||||||
}
|
}
|
||||||
if (FLAG_IS_SET(flags, FLAG_WINDOW_TOPMOST))
|
if (FLAG_IS_SET(flags, FLAG_WINDOW_TOPMOST))
|
||||||
@ -856,8 +855,8 @@ void SetWindowMonitor(int monitor)
|
|||||||
// ending up positioned partly outside the target display
|
// ending up positioned partly outside the target display
|
||||||
// NOTE 2: The workaround for that is, previously to moving the window,
|
// NOTE 2: The workaround for that is, previously to moving the window,
|
||||||
// setting the window size to the target display size, so they match
|
// setting the window size to the target display size, so they match
|
||||||
// NOTE 3: It wasn't done here because we can't assume changing the window size automatically
|
// NOTE 3: It wasn't done here because it can not bee assumed that changing
|
||||||
// is acceptable behavior by the user
|
// the window size automatically is acceptable behavior by the user
|
||||||
SDL_SetWindowPosition(platform.window, usableBounds.x, usableBounds.y);
|
SDL_SetWindowPosition(platform.window, usableBounds.x, usableBounds.y);
|
||||||
CORE.Window.position.x = usableBounds.x;
|
CORE.Window.position.x = usableBounds.x;
|
||||||
CORE.Window.position.y = usableBounds.y;
|
CORE.Window.position.y = usableBounds.y;
|
||||||
@ -1261,7 +1260,7 @@ void DisableCursor(void)
|
|||||||
void SwapScreenBuffer(void)
|
void SwapScreenBuffer(void)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
|
||||||
// NOTE: We use a preprocessor condition here because rlCopyFramebuffer() is only declared for software rendering
|
// NOTE: Using a preprocessor condition here because rlCopyFramebuffer() is only declared for software rendering
|
||||||
SDL_Surface *surface = SDL_GetWindowSurface(platform.window);
|
SDL_Surface *surface = SDL_GetWindowSurface(platform.window);
|
||||||
rlCopyFramebuffer(0, 0, CORE.Window.render.width, CORE.Window.render.height, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, surface->pixels);
|
rlCopyFramebuffer(0, 0, CORE.Window.render.width, CORE.Window.render.height, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, surface->pixels);
|
||||||
SDL_UpdateWindowSurface(platform.window);
|
SDL_UpdateWindowSurface(platform.window);
|
||||||
@ -1442,8 +1441,8 @@ void PollInputEvents(void)
|
|||||||
{
|
{
|
||||||
if (CORE.Window.dropFileCount == 0)
|
if (CORE.Window.dropFileCount == 0)
|
||||||
{
|
{
|
||||||
// When a new file is dropped, we reserve a fixed number of slots for all possible dropped files
|
// When a new file is dropped, reserve a fixed number of slots for all possible dropped files
|
||||||
// at the moment we limit the number of drops at once to 1024 files but this behaviour should probably be reviewed
|
// at the moment limit the number of drops at once to 1024 files but this behaviour should probably be reviewed
|
||||||
// TODO: Pointers should probably be reallocated for any new file added...
|
// TODO: Pointers should probably be reallocated for any new file added...
|
||||||
CORE.Window.dropFilepaths = (char **)RL_CALLOC(1024, sizeof(char *));
|
CORE.Window.dropFilepaths = (char **)RL_CALLOC(1024, sizeof(char *));
|
||||||
|
|
||||||
@ -1497,7 +1496,8 @@ void PollInputEvents(void)
|
|||||||
const int width = event.window.data1;
|
const int width = event.window.data1;
|
||||||
const int height = event.window.data2;
|
const int height = event.window.data2;
|
||||||
SetupViewport(width, height);
|
SetupViewport(width, height);
|
||||||
// if we are doing automatic DPI scaling, then the "screen" size is divided by the window scale
|
|
||||||
|
// Consider content scaling if required
|
||||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
|
||||||
{
|
{
|
||||||
CORE.Window.screen.width = (int)(width/GetWindowScaleDPI().x);
|
CORE.Window.screen.width = (int)(width/GetWindowScaleDPI().x);
|
||||||
@ -1622,7 +1622,7 @@ void PollInputEvents(void)
|
|||||||
|
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
{
|
{
|
||||||
// NOTE: event.text.text data comes an UTF-8 text sequence but we register codepoints (int)
|
// NOTE: event.text.text data comes an UTF-8 text sequence but register codepoints (int)
|
||||||
|
|
||||||
// Check if there is space available in the queue
|
// Check if there is space available in the queue
|
||||||
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
|
if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
|
||||||
@ -1885,7 +1885,7 @@ void PollInputEvents(void)
|
|||||||
{
|
{
|
||||||
if (platform.gamepadId[i] == event.jaxis.which)
|
if (platform.gamepadId[i] == event.jaxis.which)
|
||||||
{
|
{
|
||||||
// SDL axis value range is -32768 to 32767, we normalize it to raylib's -1.0 to 1.0f range
|
// SDL axis value range is -32768 to 32767, normalizing it to raylib's -1.0 to 1.0f range
|
||||||
float value = event.jaxis.value/(float)32767;
|
float value = event.jaxis.value/(float)32767;
|
||||||
CORE.Input.Gamepad.axisState[i][axis] = value;
|
CORE.Input.Gamepad.axisState[i][axis] = value;
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@
|
|||||||
#include <linux/joystick.h> // Linux: Joystick support library
|
#include <linux/joystick.h> // Linux: Joystick support library
|
||||||
|
|
||||||
// WARNING: Both 'linux/input.h' and 'raylib.h' define KEY_F12
|
// WARNING: Both 'linux/input.h' and 'raylib.h' define KEY_F12
|
||||||
// To avoid conflict with the capturing code in rcore.c we undefine the macro KEY_F12,
|
// To avoid conflict with the capturing code in rcore.c, undefine the macro KEY_F12,
|
||||||
// so the enum KEY_F12 from raylib is used
|
// so the enum KEY_F12 from raylib is used
|
||||||
#undef KEY_F12
|
#undef KEY_F12
|
||||||
|
|
||||||
@ -97,7 +97,7 @@
|
|||||||
|
|
||||||
#define DEFAULT_EVDEV_PATH "/dev/input/" // Path to the linux input events
|
#define DEFAULT_EVDEV_PATH "/dev/input/" // Path to the linux input events
|
||||||
|
|
||||||
// Actually biggest key is KEY_CNT but we only really map the keys up to KEY_ALS_TOGGLE
|
// Actually biggest key is KEY_CNT but only mapping keys up to KEY_ALS_TOGGLE
|
||||||
#define KEYMAP_SIZE KEY_ALS_TOGGLE
|
#define KEYMAP_SIZE KEY_ALS_TOGGLE
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -489,7 +489,7 @@ int InitPlatform(void)
|
|||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
// If everything work as expected, we can continue
|
// If everything worked as expected, continue
|
||||||
CORE.Window.render.width = CORE.Window.screen.width;
|
CORE.Window.render.width = CORE.Window.screen.width;
|
||||||
CORE.Window.render.height = CORE.Window.screen.height;
|
CORE.Window.render.height = CORE.Window.screen.height;
|
||||||
CORE.Window.currentFbo.width = CORE.Window.render.width;
|
CORE.Window.currentFbo.width = CORE.Window.render.width;
|
||||||
|
|||||||
23
src/raudio.c
23
src/raudio.c
@ -495,8 +495,9 @@ void InitAudioDevice(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mixing happens on a separate thread which means we need to synchronize. I'm using a mutex here to make things simple, but may
|
// Mixing happens on a separate thread which means synchronization is needed
|
||||||
// want to look at something a bit smarter later on to keep everything real-time, if that's necessary
|
// A mutex is used here to make things simple, but may want to look at something
|
||||||
|
// a bit smarter later on to keep everything real-time, if that's necessary
|
||||||
if (ma_mutex_init(&AUDIO.System.lock) != MA_SUCCESS)
|
if (ma_mutex_init(&AUDIO.System.lock) != MA_SUCCESS)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "AUDIO: Failed to create mutex for mixing");
|
TRACELOG(LOG_WARNING, "AUDIO: Failed to create mutex for mixing");
|
||||||
@ -822,7 +823,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
|
|||||||
wave.channels = wav.channels;
|
wave.channels = wav.channels;
|
||||||
wave.data = (short *)RL_MALLOC((size_t)wave.frameCount*wave.channels*sizeof(short));
|
wave.data = (short *)RL_MALLOC((size_t)wave.frameCount*wave.channels*sizeof(short));
|
||||||
|
|
||||||
// NOTE: We are forcing conversion to 16bit sample size on reading
|
// NOTE: Forcing conversion to 16bit sample size on reading
|
||||||
drwav_read_pcm_frames_s16(&wav, wave.frameCount, (drwav_int16 *)wave.data);
|
drwav_read_pcm_frames_s16(&wav, wave.frameCount, (drwav_int16 *)wave.data);
|
||||||
}
|
}
|
||||||
else TRACELOG(LOG_WARNING, "WAVE: Failed to load WAV data");
|
else TRACELOG(LOG_WARNING, "WAVE: Failed to load WAV data");
|
||||||
@ -845,7 +846,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
|
|||||||
wave.frameCount = (unsigned int)stb_vorbis_stream_length_in_samples(oggData); // NOTE: It returns frames!
|
wave.frameCount = (unsigned int)stb_vorbis_stream_length_in_samples(oggData); // NOTE: It returns frames!
|
||||||
wave.data = (short *)RL_MALLOC(wave.frameCount*wave.channels*sizeof(short));
|
wave.data = (short *)RL_MALLOC(wave.frameCount*wave.channels*sizeof(short));
|
||||||
|
|
||||||
// NOTE: Get the number of samples to process (be careful! we ask for number of shorts, not bytes!)
|
// NOTE: Get the number of samples to process (be careful! asking for number of shorts, not bytes!)
|
||||||
stb_vorbis_get_samples_short_interleaved(oggData, info.channels, (short *)wave.data, wave.frameCount*wave.channels);
|
stb_vorbis_get_samples_short_interleaved(oggData, info.channels, (short *)wave.data, wave.frameCount*wave.channels);
|
||||||
stb_vorbis_close(oggData);
|
stb_vorbis_close(oggData);
|
||||||
}
|
}
|
||||||
@ -858,7 +859,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
|
|||||||
drmp3_config config = { 0 };
|
drmp3_config config = { 0 };
|
||||||
unsigned long long int totalFrameCount = 0;
|
unsigned long long int totalFrameCount = 0;
|
||||||
|
|
||||||
// NOTE: We are forcing conversion to 32bit float sample size on reading
|
// NOTE: Forcing conversion to 32bit float sample size on reading
|
||||||
wave.data = drmp3_open_memory_and_read_pcm_frames_f32(fileData, dataSize, &config, &totalFrameCount, NULL);
|
wave.data = drmp3_open_memory_and_read_pcm_frames_f32(fileData, dataSize, &config, &totalFrameCount, NULL);
|
||||||
wave.sampleSize = 32;
|
wave.sampleSize = 32;
|
||||||
|
|
||||||
@ -896,7 +897,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
|
|||||||
{
|
{
|
||||||
unsigned long long int totalFrameCount = 0;
|
unsigned long long int totalFrameCount = 0;
|
||||||
|
|
||||||
// NOTE: We are forcing conversion to 16bit sample size on reading
|
// NOTE: Forcing conversion to 16bit sample size on reading
|
||||||
wave.data = drflac_open_memory_and_read_pcm_frames_s16(fileData, dataSize, &wave.channels, &wave.sampleRate, &totalFrameCount, NULL);
|
wave.data = drflac_open_memory_and_read_pcm_frames_s16(fileData, dataSize, &wave.channels, &wave.sampleRate, &totalFrameCount, NULL);
|
||||||
wave.sampleSize = 16;
|
wave.sampleSize = 16;
|
||||||
|
|
||||||
@ -933,7 +934,7 @@ Sound LoadSound(const char *fileName)
|
|||||||
|
|
||||||
Sound sound = LoadSoundFromWave(wave);
|
Sound sound = LoadSoundFromWave(wave);
|
||||||
|
|
||||||
UnloadWave(wave); // Sound is loaded, we can unload wave
|
UnloadWave(wave); // Sound is loaded, wave can be unloaded
|
||||||
|
|
||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
@ -2656,7 +2657,7 @@ static void MixAudioFrames(float *framesOut, const float *framesIn, ma_uint32 fr
|
|||||||
const float localVolume = buffer->volume;
|
const float localVolume = buffer->volume;
|
||||||
const ma_uint32 channels = AUDIO.System.device.playback.channels;
|
const ma_uint32 channels = AUDIO.System.device.playback.channels;
|
||||||
|
|
||||||
if (channels == 2) // We consider panning
|
if (channels == 2) // Consider panning
|
||||||
{
|
{
|
||||||
const float right = (buffer->pan + 1.0f)/2.0f; // Normalize: [-1..1] -> [0..1]
|
const float right = (buffer->pan + 1.0f)/2.0f; // Normalize: [-1..1] -> [0..1]
|
||||||
const float left = 1.0f - right;
|
const float left = 1.0f - right;
|
||||||
@ -2676,7 +2677,7 @@ static void MixAudioFrames(float *framesOut, const float *framesIn, ma_uint32 fr
|
|||||||
frameIn += 2;
|
frameIn += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // We do not consider panning
|
else // Do not consider panning
|
||||||
{
|
{
|
||||||
for (ma_uint32 frame = 0; frame < frameCount; frame++)
|
for (ma_uint32 frame = 0; frame < frameCount; frame++)
|
||||||
{
|
{
|
||||||
@ -2831,7 +2832,7 @@ static const char *GetFileNameWithoutExt(const char *filePath)
|
|||||||
{
|
{
|
||||||
if (fileName[i] == '.')
|
if (fileName[i] == '.')
|
||||||
{
|
{
|
||||||
// NOTE: We break on first '.' found
|
// NOTE: Break on first '.' found
|
||||||
fileName[i] = '\0';
|
fileName[i] = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2862,7 +2863,7 @@ static unsigned char *LoadFileData(const char *fileName, int *dataSize)
|
|||||||
{
|
{
|
||||||
data = (unsigned char *)RL_MALLOC(size*sizeof(unsigned char));
|
data = (unsigned char *)RL_MALLOC(size*sizeof(unsigned char));
|
||||||
|
|
||||||
// NOTE: fread() returns number of read elements instead of bytes, so we read [1 byte, size elements]
|
// NOTE: fread() returns number of read elements instead of bytes, so reading [1 byte, size elements]
|
||||||
unsigned int count = (unsigned int)fread(data, sizeof(unsigned char), size, file);
|
unsigned int count = (unsigned int)fread(data, sizeof(unsigned char), size, file);
|
||||||
*dataSize = count;
|
*dataSize = count;
|
||||||
|
|
||||||
|
|||||||
@ -1167,7 +1167,7 @@ RLAPI bool IsFileDropped(void); // Check if
|
|||||||
RLAPI FilePathList LoadDroppedFiles(void); // Load dropped filepaths
|
RLAPI FilePathList LoadDroppedFiles(void); // Load dropped filepaths
|
||||||
RLAPI void UnloadDroppedFiles(FilePathList files); // Unload dropped filepaths
|
RLAPI void UnloadDroppedFiles(FilePathList files); // Unload dropped filepaths
|
||||||
RLAPI unsigned int GetDirectoryFileCount(const char *dirPath); // Get the file count in a directory
|
RLAPI unsigned int GetDirectoryFileCount(const char *dirPath); // Get the file count in a directory
|
||||||
RLAPI unsigned int GetDirectoryFileCountEx(const char *basePath, const char *filter, bool scanSubdirs);// Get the file count in a directory with extension filtering and recursive directory scan. Use 'DIR' in the filter string to include directories in the result
|
RLAPI unsigned int GetDirectoryFileCountEx(const char *basePath, const char *filter, bool scanSubdirs); // Get the file count in a directory with extension filtering and recursive directory scan. Use 'DIR' in the filter string to include directories in the result
|
||||||
|
|
||||||
// Compression/Encoding functionality
|
// Compression/Encoding functionality
|
||||||
RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); // Compress data (DEFLATE algorithm), memory must be MemFree()
|
RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); // Compress data (DEFLATE algorithm), memory must be MemFree()
|
||||||
|
|||||||
@ -54,9 +54,9 @@
|
|||||||
#if defined(__TINYC__)
|
#if defined(__TINYC__)
|
||||||
#define __declspec(x) __attribute__((x))
|
#define __declspec(x) __attribute__((x))
|
||||||
#endif
|
#endif
|
||||||
#define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)
|
#define RLAPI __declspec(dllexport) // Building the library as a Win32 shared library (.dll)
|
||||||
#elif defined(USE_LIBTYPE_SHARED)
|
#elif defined(USE_LIBTYPE_SHARED)
|
||||||
#define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)
|
#define RLAPI __declspec(dllimport) // Using the library as a Win32 shared library (.dll)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -364,7 +364,7 @@ void CameraPitch(Camera *camera, float angle, bool lockView, bool rotateAroundTa
|
|||||||
|
|
||||||
if (lockView)
|
if (lockView)
|
||||||
{
|
{
|
||||||
// In these camera modes we clamp the Pitch angle
|
// In these camera modes, clamp the Pitch angle
|
||||||
// to allow only viewing straight up or down.
|
// to allow only viewing straight up or down.
|
||||||
|
|
||||||
// Clamp view up
|
// Clamp view up
|
||||||
|
|||||||
56
src/rcore.c
56
src/rcore.c
@ -517,7 +517,7 @@ static void RecordAutomationEvent(void); // Record frame events (to internal eve
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(PLATFORM_DESKTOP_RGFW)
|
#if defined(_WIN32) && !defined(PLATFORM_DESKTOP_RGFW)
|
||||||
// NOTE: We declare Sleep() function symbol to avoid including windows.h (kernel32.lib linkage required)
|
// NOTE: Declaring Sleep() function symbol to avoid including windows.h (kernel32.lib linkage required)
|
||||||
__declspec(dllimport) void __stdcall Sleep(unsigned long msTimeout); // Required for: WaitTime()
|
__declspec(dllimport) void __stdcall Sleep(unsigned long msTimeout); // Required for: WaitTime()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -701,12 +701,12 @@ void InitWindow(int width, int height, const char *title)
|
|||||||
Rectangle rec = GetFontDefault().recs[95];
|
Rectangle rec = GetFontDefault().recs[95];
|
||||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
|
||||||
{
|
{
|
||||||
// NOTE: We try to maxime rec padding to avoid pixel bleeding on MSAA filtering
|
// NOTE: Try to maxime rec padding to avoid pixel bleeding on MSAA filtering
|
||||||
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 2, rec.y + 2, 1, 1 });
|
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 2, rec.y + 2, 1, 1 });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// NOTE: We set up a 1px padding on char rectangle to avoid pixel bleeding
|
// NOTE: Set up a 1px padding on char rectangle to avoid pixel bleeding
|
||||||
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 1, rec.y + 1, rec.width - 2, rec.height - 2 });
|
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 1, rec.y + 1, rec.width - 2, rec.height - 2 });
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1042,7 +1042,7 @@ void EndTextureMode(void)
|
|||||||
// Set viewport to default framebuffer size
|
// Set viewport to default framebuffer size
|
||||||
SetupViewport(CORE.Window.render.width, CORE.Window.render.height);
|
SetupViewport(CORE.Window.render.width, CORE.Window.render.height);
|
||||||
|
|
||||||
// Go back to the modelview state from BeginDrawing since we are back to the default FBO
|
// Go back to the modelview state from BeginDrawing, back to the main framebuffer
|
||||||
rlMatrixMode(RL_MODELVIEW); // Switch back to modelview matrix
|
rlMatrixMode(RL_MODELVIEW); // Switch back to modelview matrix
|
||||||
rlLoadIdentity(); // Reset current matrix (modelview)
|
rlLoadIdentity(); // Reset current matrix (modelview)
|
||||||
rlMultMatrixf(MatrixToFloat(CORE.Window.screenScale)); // Apply screen scaling if required
|
rlMultMatrixf(MatrixToFloat(CORE.Window.screenScale)); // Apply screen scaling if required
|
||||||
@ -1079,7 +1079,7 @@ void EndBlendMode(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Begin scissor mode (define screen area for following drawing)
|
// Begin scissor mode (define screen area for following drawing)
|
||||||
// NOTE: Scissor rec refers to bottom-left corner, we change it to upper-left
|
// NOTE: Scissor rec refers to bottom-left corner, changing it to upper-left
|
||||||
void BeginScissorMode(int x, int y, int width, int height)
|
void BeginScissorMode(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
rlDrawRenderBatchActive(); // Update and draw internal render batch
|
rlDrawRenderBatchActive(); // Update and draw internal render batch
|
||||||
@ -1182,9 +1182,9 @@ VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device)
|
|||||||
config.projection[1] = MatrixMultiply(proj, MatrixTranslate(-projOffset, 0.0f, 0.0f));
|
config.projection[1] = MatrixMultiply(proj, MatrixTranslate(-projOffset, 0.0f, 0.0f));
|
||||||
|
|
||||||
// Compute camera transformation matrices
|
// Compute camera transformation matrices
|
||||||
// NOTE: Camera movement might seem more natural if we model the head
|
// NOTE: Camera movement might seem more natural if modelling the head
|
||||||
// Our axis of rotation is the base of our head, so we might want to add
|
// Axis of rotation is the base of the head, so adding some y (base of head to eye level
|
||||||
// some y (base of head to eye level) and -z (center of head to eye protrusion) to the camera positions
|
// and -z (center of head to eye protrusion) to the camera positions
|
||||||
config.viewOffset[0] = MatrixTranslate(device.interpupillaryDistance*0.5f, 0.075f, 0.045f);
|
config.viewOffset[0] = MatrixTranslate(device.interpupillaryDistance*0.5f, 0.075f, 0.045f);
|
||||||
config.viewOffset[1] = MatrixTranslate(-device.interpupillaryDistance*0.5f, 0.075f, 0.045f);
|
config.viewOffset[1] = MatrixTranslate(-device.interpupillaryDistance*0.5f, 0.075f, 0.045f);
|
||||||
|
|
||||||
@ -1247,15 +1247,15 @@ Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
|
|||||||
|
|
||||||
if (shader.id == 0)
|
if (shader.id == 0)
|
||||||
{
|
{
|
||||||
// Shader could not be loaded but we still load the location points to avoid potential crashes
|
// Shader could not be loaded but still loading the location points to avoid potential crashes
|
||||||
// NOTE: All locations set to -1 (no location)
|
// NOTE: All locations set to -1 (no location found)
|
||||||
shader.locs = (int *)RL_CALLOC(RL_MAX_SHADER_LOCATIONS, sizeof(int));
|
shader.locs = (int *)RL_CALLOC(RL_MAX_SHADER_LOCATIONS, sizeof(int));
|
||||||
for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1;
|
for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1;
|
||||||
}
|
}
|
||||||
else if (shader.id == rlGetShaderIdDefault()) shader.locs = rlGetShaderLocsDefault();
|
else if (shader.id == rlGetShaderIdDefault()) shader.locs = rlGetShaderLocsDefault();
|
||||||
else if (shader.id > 0)
|
else if (shader.id > 0)
|
||||||
{
|
{
|
||||||
// After custom shader loading, we TRY to set default location names
|
// After custom shader loading, trying to set default location names
|
||||||
// Default shader attribute locations have been binded before linking:
|
// Default shader attribute locations have been binded before linking:
|
||||||
// - vertex position location = 0
|
// - vertex position location = 0
|
||||||
// - vertex texcoord location = 1
|
// - vertex texcoord location = 1
|
||||||
@ -1448,7 +1448,7 @@ Ray GetScreenToWorldRayEx(Vector2 position, Camera camera, int width, int height
|
|||||||
Vector3 farPoint = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView);
|
Vector3 farPoint = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView);
|
||||||
|
|
||||||
// Unproject the mouse cursor in the near plane
|
// Unproject the mouse cursor in the near plane
|
||||||
// We need this as the source position because orthographic projects,
|
// It is needed as the source position because orthographic projects,
|
||||||
// compared to perspective doesn't have a convergence point,
|
// compared to perspective doesn't have a convergence point,
|
||||||
// meaning that the "eye" of the camera is more like a plane than a point
|
// meaning that the "eye" of the camera is more like a plane than a point
|
||||||
Vector3 cameraPlanePointerPos = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, -1.0f }, matProj, matView);
|
Vector3 cameraPlanePointerPos = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, -1.0f }, matProj, matView);
|
||||||
@ -1484,7 +1484,7 @@ Matrix GetCameraMatrix2D(Camera2D camera)
|
|||||||
// not for the camera getting bigger, hence the invert. Same deal with rotation
|
// not for the camera getting bigger, hence the invert. Same deal with rotation
|
||||||
// 3. Move it by (-offset);
|
// 3. Move it by (-offset);
|
||||||
// Offset defines target transform relative to screen, but since effectively "moving" screen (camera)
|
// Offset defines target transform relative to screen, but since effectively "moving" screen (camera)
|
||||||
// we need to do it into opposite direction (inverse transform)
|
// it needs to be moved into opposite direction (inverse transform)
|
||||||
|
|
||||||
// Having camera transform in world-space, inverse of it gives the modelview transform
|
// Having camera transform in world-space, inverse of it gives the modelview transform
|
||||||
// Since (A*B*C)' = C'*B'*A', the modelview is
|
// Since (A*B*C)' = C'*B'*A', the modelview is
|
||||||
@ -1586,7 +1586,7 @@ void SetTargetFPS(int fps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get current FPS
|
// Get current FPS
|
||||||
// NOTE: We calculate an average framerate
|
// NOTE: Calculating an average framerate
|
||||||
int GetFPS(void)
|
int GetFPS(void)
|
||||||
{
|
{
|
||||||
int fps = 0;
|
int fps = 0;
|
||||||
@ -1601,7 +1601,7 @@ int GetFPS(void)
|
|||||||
static float average = 0, last = 0;
|
static float average = 0, last = 0;
|
||||||
float fpsFrame = GetFrameTime();
|
float fpsFrame = GetFrameTime();
|
||||||
|
|
||||||
// if we reset the window, reset the FPS info
|
// If reseting the window, reset the FPS info
|
||||||
if (CORE.Time.frameCounter == 0)
|
if (CORE.Time.frameCounter == 0)
|
||||||
{
|
{
|
||||||
average = 0;
|
average = 0;
|
||||||
@ -1644,7 +1644,7 @@ float GetFrameTime(void)
|
|||||||
|
|
||||||
// Wait for some time (stop program execution)
|
// Wait for some time (stop program execution)
|
||||||
// NOTE: Sleep() granularity could be around 10 ms, it means, Sleep() could
|
// NOTE: Sleep() granularity could be around 10 ms, it means, Sleep() could
|
||||||
// take longer than expected... for that reason we use the busy wait loop
|
// take longer than expected... for that reason a busy wait loop is used
|
||||||
// REF: http://stackoverflow.com/questions/43057578/c-programming-win32-games-sleep-taking-longer-than-expected
|
// REF: http://stackoverflow.com/questions/43057578/c-programming-win32-games-sleep-taking-longer-than-expected
|
||||||
// REF: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timing on Win32!
|
// REF: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timing on Win32!
|
||||||
void WaitTime(double seconds)
|
void WaitTime(double seconds)
|
||||||
@ -1659,7 +1659,7 @@ void WaitTime(double seconds)
|
|||||||
while (GetTime() < destinationTime) { }
|
while (GetTime() < destinationTime) { }
|
||||||
#else
|
#else
|
||||||
#if SUPPORT_PARTIALBUSY_WAIT_LOOP
|
#if SUPPORT_PARTIALBUSY_WAIT_LOOP
|
||||||
double sleepSeconds = seconds - seconds*0.05; // NOTE: We reserve a percentage of the time for busy waiting
|
double sleepSeconds = seconds - seconds*0.05; // NOTE: Reserve a percentage of the time for busy waiting
|
||||||
#else
|
#else
|
||||||
double sleepSeconds = seconds;
|
double sleepSeconds = seconds;
|
||||||
#endif
|
#endif
|
||||||
@ -1818,7 +1818,7 @@ void TakeScreenshot(const char *fileName)
|
|||||||
// Security check to (partially) avoid malicious code
|
// Security check to (partially) avoid malicious code
|
||||||
if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; }
|
if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; }
|
||||||
|
|
||||||
// Apply a scale if we are doing HIGHDPI auto-scaling
|
// Apply content scaling if required
|
||||||
Vector2 scale = { 1.0f, 1.0f };
|
Vector2 scale = { 1.0f, 1.0f };
|
||||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI)) scale = GetWindowScaleDPI();
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI)) scale = GetWindowScaleDPI();
|
||||||
|
|
||||||
@ -1973,11 +1973,11 @@ unsigned char *LoadFileData(const char *fileName, int *dataSize)
|
|||||||
|
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
{
|
{
|
||||||
// NOTE: fread() returns number of read elements instead of bytes, so we read [1 byte, size elements]
|
// NOTE: fread() returns number of read elements instead of bytes, so reading [1 byte, size elements]
|
||||||
size_t count = fread(data, sizeof(unsigned char), size, file);
|
size_t count = fread(data, sizeof(unsigned char), size, file);
|
||||||
|
|
||||||
// WARNING: fread() returns a size_t value, usually 'unsigned int' (32bit compilation) and 'unsigned long long' (64bit compilation)
|
// WARNING: fread() returns a size_t value, usually 'unsigned int' (32bit compilation) and 'unsigned long long' (64bit compilation)
|
||||||
// dataSize is unified along raylib as a 'int' type, so, for file-sizes > INT_MAX (2147483647 bytes) we have a limitation
|
// dataSize is unified along raylib as a 'int' type, so, for file-sizes > INT_MAX (2147483647 bytes) there is a limitation
|
||||||
if (count > 2147483647)
|
if (count > 2147483647)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "FILEIO: [%s] File is bigger than 2147483647 bytes, avoid using LoadFileData()", fileName);
|
TRACELOG(LOG_WARNING, "FILEIO: [%s] File is bigger than 2147483647 bytes, avoid using LoadFileData()", fileName);
|
||||||
@ -2456,7 +2456,7 @@ long GetFileModTime(const char *fileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get pointer to extension for a filename string (includes the dot: .png)
|
// Get pointer to extension for a filename string (includes the dot: .png)
|
||||||
// WARNING: We just get the ptr but not the extension as a separate string
|
// WARNING: Getting the pointer to the input string extension position (not a string copy)
|
||||||
const char *GetFileExtension(const char *fileName)
|
const char *GetFileExtension(const char *fileName)
|
||||||
{
|
{
|
||||||
const char *dot = strrchr(fileName, '.');
|
const char *dot = strrchr(fileName, '.');
|
||||||
@ -2505,7 +2505,7 @@ const char *GetFileNameWithoutExt(const char *filePath)
|
|||||||
{
|
{
|
||||||
if (fileName[i] == '.')
|
if (fileName[i] == '.')
|
||||||
{
|
{
|
||||||
// NOTE: We break on first '.' found
|
// NOTE: Break on first '.' found
|
||||||
fileName[i] = '\0';
|
fileName[i] = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2531,11 +2531,11 @@ const char *GetDirectoryPath(const char *filePath)
|
|||||||
static char dirPath[MAX_FILEPATH_LENGTH] = { 0 };
|
static char dirPath[MAX_FILEPATH_LENGTH] = { 0 };
|
||||||
memset(dirPath, 0, MAX_FILEPATH_LENGTH);
|
memset(dirPath, 0, MAX_FILEPATH_LENGTH);
|
||||||
|
|
||||||
// In case provided path does not contain a root drive letter (C:\, D:\) nor leading path separator (\, /),
|
// In case provided path does not contain a root drive letter (C:\, D:\)
|
||||||
// we add the current directory path to dirPath
|
// nor leading path separator (\, /), add the current directory path to dirPath
|
||||||
if ((filePath[1] != ':') && (filePath[0] != '\\') && (filePath[0] != '/'))
|
if ((filePath[1] != ':') && (filePath[0] != '\\') && (filePath[0] != '/'))
|
||||||
{
|
{
|
||||||
// For security, we set starting path to current directory,
|
// For security, set starting path to current directory,
|
||||||
// obtained path will be concatenated to this
|
// obtained path will be concatenated to this
|
||||||
dirPath[0] = '.';
|
dirPath[0] = '.';
|
||||||
dirPath[1] = '/';
|
dirPath[1] = '/';
|
||||||
@ -2934,7 +2934,7 @@ unsigned int GetDirectoryFileCountEx(const char *basePath, const char *filter, b
|
|||||||
{
|
{
|
||||||
while ((entity = readdir(dir)) != NULL)
|
while ((entity = readdir(dir)) != NULL)
|
||||||
{
|
{
|
||||||
// NOTE: We skip '.' (current dir) and '..' (parent dir) filepaths
|
// NOTE: Skipping '.' (current dir) and '..' (parent dir) filepaths
|
||||||
if ((strcmp(entity->d_name, ".") != 0) && (strcmp(entity->d_name, "..") != 0))
|
if ((strcmp(entity->d_name, ".") != 0) && (strcmp(entity->d_name, "..") != 0))
|
||||||
{
|
{
|
||||||
// Construct new path from our base path
|
// Construct new path from our base path
|
||||||
@ -3004,7 +3004,7 @@ unsigned char *DecompressData(const unsigned char *compData, int compDataSize, i
|
|||||||
|
|
||||||
// WARNING: RL_REALLOC can make (and leave) data copies in memory,
|
// WARNING: RL_REALLOC can make (and leave) data copies in memory,
|
||||||
// that can be a security concern in case of compression of sensitive data
|
// that can be a security concern in case of compression of sensitive data
|
||||||
// So, we use a second buffer to copy data manually, wiping original buffer memory
|
// So, using a second buffer to copy data manually, wiping original buffer memory
|
||||||
data = (unsigned char *)RL_CALLOC(size, 1);
|
data = (unsigned char *)RL_CALLOC(size, 1);
|
||||||
memcpy(data, data0, size);
|
memcpy(data, data0, size);
|
||||||
memset(data0, 0, MAX_DECOMPRESSION_SIZE*1024*1024); // Wipe memory, is memset() safe?
|
memset(data0, 0, MAX_DECOMPRESSION_SIZE*1024*1024); // Wipe memory, is memset() safe?
|
||||||
@ -4578,7 +4578,7 @@ const char *TextFormat(const char *text, ...)
|
|||||||
#define MAX_TEXT_BUFFER_LENGTH 1024 // Maximum size of static text buffer
|
#define MAX_TEXT_BUFFER_LENGTH 1024 // Maximum size of static text buffer
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We create an array of buffers so strings don't expire until MAX_TEXTFORMAT_BUFFERS invocations
|
// Define an array of buffers, so strings don't expire until MAX_TEXTFORMAT_BUFFERS invocations
|
||||||
static char buffers[MAX_TEXTFORMAT_BUFFERS][MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
static char buffers[MAX_TEXTFORMAT_BUFFERS][MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
||||||
static int index = 0;
|
static int index = 0;
|
||||||
|
|
||||||
|
|||||||
@ -3257,6 +3257,7 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
|
|||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
#if defined(GRAPHICS_API_OPENGL_11)
|
||||||
if (format >= RL_PIXELFORMAT_COMPRESSED_DXT1_RGB)
|
if (format >= RL_PIXELFORMAT_COMPRESSED_DXT1_RGB)
|
||||||
{
|
{
|
||||||
|
// TODO: Support texture data decompression
|
||||||
TRACELOG(RL_LOG_WARNING, "GL: OpenGL 1.1 does not support GPU compressed texture formats");
|
TRACELOG(RL_LOG_WARNING, "GL: OpenGL 1.1 does not support GPU compressed texture formats");
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -3828,8 +3829,8 @@ unsigned int rlLoadFramebuffer(void)
|
|||||||
if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return fboId; }
|
if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return fboId; }
|
||||||
|
|
||||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
|
||||||
glGenFramebuffers(1, &fboId); // Create the framebuffer object
|
glGenFramebuffers(1, &fboId); // Create the framebuffer object
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0); // Unbind any framebuffer
|
glBindFramebuffer(GL_FRAMEBUFFER, 0); // Unbind any framebuffer
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return fboId;
|
return fboId;
|
||||||
|
|||||||
Reference in New Issue
Block a user