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:
@ -60,7 +60,7 @@
|
|||||||
#define SUPPORT_TRACELOG 1
|
#define SUPPORT_TRACELOG 1
|
||||||
#endif
|
#endif
|
||||||
#ifndef SUPPORT_CAMERA_SYSTEM
|
#ifndef SUPPORT_CAMERA_SYSTEM
|
||||||
// Camera module is included (rcamera.h) and multiple predefined
|
// Camera module is included (rcamera.h) and multiple predefined
|
||||||
// cameras are available: free, 1st/3rd person, orbital
|
// cameras are available: free, 1st/3rd person, orbital
|
||||||
#define SUPPORT_CAMERA_SYSTEM 1
|
#define SUPPORT_CAMERA_SYSTEM 1
|
||||||
#endif
|
#endif
|
||||||
@ -90,7 +90,7 @@
|
|||||||
#define SUPPORT_BUSY_WAIT_LOOP 0 // Disabled by default
|
#define SUPPORT_BUSY_WAIT_LOOP 0 // Disabled by default
|
||||||
#endif
|
#endif
|
||||||
#if !SUPPORT_PARTIALBUSY_WAIT_LOOP && !SUPPORT_BUSY_WAIT_LOOP
|
#if !SUPPORT_PARTIALBUSY_WAIT_LOOP && !SUPPORT_BUSY_WAIT_LOOP
|
||||||
// Use a partial-busy wait loop, in this case frame sleeps for most of the time,
|
// Use a partial-busy wait loop, in this case frame sleeps for most of the time,
|
||||||
// but then runs a busy loop at the end for accuracy
|
// but then runs a busy loop at the end for accuracy
|
||||||
#define SUPPORT_PARTIALBUSY_WAIT_LOOP 1
|
#define SUPPORT_PARTIALBUSY_WAIT_LOOP 1
|
||||||
#endif
|
#endif
|
||||||
@ -267,7 +267,7 @@
|
|||||||
|
|
||||||
#ifndef SUPPORT_IMAGE_EXPORT
|
#ifndef SUPPORT_IMAGE_EXPORT
|
||||||
// Support image export functionality (.png, .bmp, .tga, .jpg, .qoi)
|
// Support image export functionality (.png, .bmp, .tga, .jpg, .qoi)
|
||||||
// NOTE: Image export requires stb_image_write.h library
|
// NOTE: Image export requires stb_image_write.h library
|
||||||
#define SUPPORT_IMAGE_EXPORT 1
|
#define SUPPORT_IMAGE_EXPORT 1
|
||||||
#endif
|
#endif
|
||||||
#ifndef SUPPORT_IMAGE_GENERATION
|
#ifndef SUPPORT_IMAGE_GENERATION
|
||||||
@ -319,7 +319,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#ifndef SUPPORT_GPU_SKINNING
|
#ifndef SUPPORT_GPU_SKINNING
|
||||||
// GPU skinning disabled by default, some GPUs do not support more than 8 VBOs
|
// GPU skinning disabled by default, some GPUs do not support more than 8 VBOs
|
||||||
#define SUPPORT_GPU_SKINNING 0
|
#define SUPPORT_GPU_SKINNING 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|||||||
18
src/external/win32_clipboard.h
vendored
18
src/external/win32_clipboard.h
vendored
@ -181,7 +181,7 @@ typedef struct tagRGBQUAD {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BI_ALPHABITFIELDS
|
#ifndef BI_ALPHABITFIELDS
|
||||||
// Bitmap not compressed and that the color table consists of four DWORD color masks,
|
// Bitmap not compressed and that the color table consists of four DWORD color masks,
|
||||||
// that specify the red, green, blue, and alpha components of each pixel
|
// that specify the red, green, blue, and alpha components of each pixel
|
||||||
#define BI_ALPHABITFIELDS 0x0006
|
#define BI_ALPHABITFIELDS 0x0006
|
||||||
#endif
|
#endif
|
||||||
@ -216,7 +216,7 @@ static int GetPixelDataOffset(BITMAPINFOHEADER bih); // Get pixel data offset fr
|
|||||||
unsigned char *Win32GetClipboardImageData(int *width, int *height, unsigned long long int *dataSize)
|
unsigned char *Win32GetClipboardImageData(int *width, int *height, unsigned long long int *dataSize)
|
||||||
{
|
{
|
||||||
unsigned char *bmpData = NULL;
|
unsigned char *bmpData = NULL;
|
||||||
|
|
||||||
if (OpenClipboardRetrying(NULL))
|
if (OpenClipboardRetrying(NULL))
|
||||||
{
|
{
|
||||||
HGLOBAL clipHandle = (HGLOBAL)GetClipboardData(CF_DIB);
|
HGLOBAL clipHandle = (HGLOBAL)GetClipboardData(CF_DIB);
|
||||||
@ -231,7 +231,7 @@ unsigned char *Win32GetClipboardImageData(int *width, int *height, unsigned long
|
|||||||
if (clipDataSize >= sizeof(BITMAPINFOHEADER))
|
if (clipDataSize >= sizeof(BITMAPINFOHEADER))
|
||||||
{
|
{
|
||||||
int pixelOffset = GetPixelDataOffset(*bmpInfoHeader);
|
int pixelOffset = GetPixelDataOffset(*bmpInfoHeader);
|
||||||
|
|
||||||
// Create the bytes for a correct BMP file and copy the data to a pointer
|
// Create the bytes for a correct BMP file and copy the data to a pointer
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
BITMAPFILEHEADER bmpFileHeader = { 0 };
|
BITMAPFILEHEADER bmpFileHeader = { 0 };
|
||||||
@ -245,10 +245,10 @@ unsigned char *Win32GetClipboardImageData(int *width, int *height, unsigned long
|
|||||||
bmpData = (unsigned char *)RL_MALLOC(sizeof(bmpFileHeader) + clipDataSize);
|
bmpData = (unsigned char *)RL_MALLOC(sizeof(bmpFileHeader) + clipDataSize);
|
||||||
memcpy(bmpData, &bmpFileHeader, sizeof(bmpFileHeader)); // Add BMP file header data
|
memcpy(bmpData, &bmpFileHeader, sizeof(bmpFileHeader)); // Add BMP file header data
|
||||||
memcpy(bmpData + sizeof(bmpFileHeader), bmpInfoHeader, clipDataSize); // Add BMP info header data
|
memcpy(bmpData + sizeof(bmpFileHeader), bmpInfoHeader, clipDataSize); // Add BMP info header data
|
||||||
|
|
||||||
GlobalUnlock(clipHandle);
|
GlobalUnlock(clipHandle);
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "Clipboad image acquired successfully");
|
TRACELOG(LOG_INFO, "Clipboad image acquired successfully");
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
@ -259,14 +259,14 @@ unsigned char *Win32GetClipboardImageData(int *width, int *height, unsigned long
|
|||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "Clipboard data failed to be locked");
|
TRACELOG(LOG_WARNING, "Clipboard data failed to be locked");
|
||||||
GlobalUnlock(clipHandle);
|
GlobalUnlock(clipHandle);
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_WARNING, "Clipboard data is not an image");
|
TRACELOG(LOG_WARNING, "Clipboard data is not an image");
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
@ -286,7 +286,7 @@ static BOOL OpenClipboardRetrying(HWND hWnd)
|
|||||||
{
|
{
|
||||||
static const int maxTries = 20;
|
static const int maxTries = 20;
|
||||||
static const int sleepTimeMS = 60;
|
static const int sleepTimeMS = 60;
|
||||||
|
|
||||||
for (int i = 0; i < maxTries; i++)
|
for (int i = 0; i < maxTries; i++)
|
||||||
{
|
{
|
||||||
// Might be being hold by another process
|
// Might be being hold by another process
|
||||||
@ -295,7 +295,7 @@ static BOOL OpenClipboardRetrying(HWND hWnd)
|
|||||||
|
|
||||||
Sleep(sleepTimeMS);
|
Sleep(sleepTimeMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1522,7 +1522,7 @@ int InitPlatform(void)
|
|||||||
glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_FALSE);
|
glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_FALSE);
|
||||||
#endif
|
#endif
|
||||||
#if defined(_GLFW_WAYLAND) && !defined(_GLFW_X11)
|
#if defined(_GLFW_WAYLAND) && !defined(_GLFW_X11)
|
||||||
// GLFW 3.4+ defaults GLFW_SCALE_FRAMEBUFFER to TRUE,
|
// GLFW 3.4+ defaults GLFW_SCALE_FRAMEBUFFER to TRUE,
|
||||||
// causing framebuffer/window size mismatch on Wayland with display scaling
|
// causing framebuffer/window size mismatch on Wayland with display scaling
|
||||||
glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_FALSE);
|
glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_FALSE);
|
||||||
#endif
|
#endif
|
||||||
@ -1727,12 +1727,12 @@ int InitPlatform(void)
|
|||||||
#if !defined(__APPLE__)
|
#if !defined(__APPLE__)
|
||||||
if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND)
|
if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND)
|
||||||
{
|
{
|
||||||
// On Wayland, GLFW_SCALE_FRAMEBUFFER handles scaling; read actual framebuffer size
|
// On Wayland, GLFW_SCALE_FRAMEBUFFER handles scaling; read actual framebuffer size
|
||||||
// instead of resizing the window (which would double-scale)
|
// instead of resizing the window (which would double-scale)
|
||||||
int fbWidth = 0;
|
int fbWidth = 0;
|
||||||
int fbHeight = 0;
|
int fbHeight = 0;
|
||||||
glfwGetFramebufferSize(platform.handle, &fbWidth, &fbHeight);
|
glfwGetFramebufferSize(platform.handle, &fbWidth, &fbHeight);
|
||||||
|
|
||||||
CORE.Window.render.width = fbWidth;
|
CORE.Window.render.width = fbWidth;
|
||||||
CORE.Window.render.height = fbHeight;
|
CORE.Window.render.height = fbHeight;
|
||||||
}
|
}
|
||||||
@ -1751,7 +1751,7 @@ int InitPlatform(void)
|
|||||||
// Current active framebuffer size is main framebuffer size
|
// Current active framebuffer size is main framebuffer size
|
||||||
CORE.Window.currentFbo = CORE.Window.render;
|
CORE.Window.currentFbo = CORE.Window.render;
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully %s",
|
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully %s",
|
||||||
FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI)? "(HighDPI)" : "");
|
FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI)? "(HighDPI)" : "");
|
||||||
TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
|
TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
|
||||||
TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
|
TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
|
||||||
@ -1935,14 +1935,14 @@ static void FramebufferSizeCallback(GLFWwindow *window, int width, int height)
|
|||||||
int winWidth = 0;
|
int winWidth = 0;
|
||||||
int winHeight = 0;
|
int winHeight = 0;
|
||||||
glfwGetWindowSize(platform.handle, &winWidth, &winHeight);
|
glfwGetWindowSize(platform.handle, &winWidth, &winHeight);
|
||||||
|
|
||||||
if ((winWidth != width) || (winHeight != height))
|
if ((winWidth != width) || (winHeight != height))
|
||||||
{
|
{
|
||||||
CORE.Window.screen.width = winWidth;
|
CORE.Window.screen.width = winWidth;
|
||||||
CORE.Window.screen.height = winHeight;
|
CORE.Window.screen.height = winHeight;
|
||||||
float scaleX = (float)width/winWidth;
|
float scaleX = (float)width/winWidth;
|
||||||
float scaleY = (float)height/winHeight;
|
float scaleY = (float)height/winHeight;
|
||||||
|
|
||||||
CORE.Window.screenScale = MatrixScale(scaleX, scaleY, 1.0f);
|
CORE.Window.screenScale = MatrixScale(scaleX, scaleY, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
@ -534,7 +534,7 @@ void ToggleBorderlessWindowed(void)
|
|||||||
{
|
{
|
||||||
FLAG_CLEAR(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE);
|
FLAG_CLEAR(CORE.Window.flags, FLAG_BORDERLESS_WINDOWED_MODE);
|
||||||
RGFW_window_setBorder(platform.window, 1);
|
RGFW_window_setBorder(platform.window, 1);
|
||||||
|
|
||||||
CORE.Window.position = CORE.Window.previousPosition;
|
CORE.Window.position = CORE.Window.previousPosition;
|
||||||
|
|
||||||
RGFW_window_resize(platform.window, CORE.Window.previousScreen.width, CORE.Window.previousScreen.height);
|
RGFW_window_resize(platform.window, CORE.Window.previousScreen.width, CORE.Window.previousScreen.height);
|
||||||
@ -821,7 +821,7 @@ void SetWindowSize(int width, int height)
|
|||||||
CORE.Window.screen.width = width;
|
CORE.Window.screen.width = width;
|
||||||
CORE.Window.screen.height = height;
|
CORE.Window.screen.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
RGFW_window_resize(platform.window, CORE.Window.screen.width, CORE.Window.screen.height);
|
RGFW_window_resize(platform.window, CORE.Window.screen.width, CORE.Window.screen.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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;
|
||||||
@ -1009,7 +1009,7 @@ const char *GetClipboardText(void)
|
|||||||
Image GetClipboardImage(void)
|
Image GetClipboardImage(void)
|
||||||
{
|
{
|
||||||
Image image = { 0 };
|
Image image = { 0 };
|
||||||
|
|
||||||
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES
|
#if SUPPORT_CLIPBOARD_IMAGE && SUPPORT_MODULE_RTEXTURES
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
@ -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;
|
||||||
|
|
||||||
@ -2032,7 +2032,7 @@ int InitPlatform(void)
|
|||||||
platform.window = SDL_CreateWindow(CORE.Window.title, CORE.Window.screen.width, CORE.Window.screen.height, flags);
|
platform.window = SDL_CreateWindow(CORE.Window.title, CORE.Window.screen.width, CORE.Window.screen.height, flags);
|
||||||
|
|
||||||
|
|
||||||
// NOTE: SDL3 no longer enables text input by default,
|
// NOTE: SDL3 no longer enables text input by default,
|
||||||
// it is needed to be enabled manually to keep GetCharPressed() working
|
// it is needed to be enabled manually to keep GetCharPressed() working
|
||||||
// REF: https://github.com/libsdl-org/SDL/commit/72fc6f86e5d605a3787222bc7dc18c5379047f4a
|
// REF: https://github.com/libsdl-org/SDL/commit/72fc6f86e5d605a3787222bc7dc18c5379047f4a
|
||||||
const char *enableOSK = SDL_GetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD);
|
const char *enableOSK = SDL_GetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD);
|
||||||
|
|||||||
@ -995,7 +995,7 @@ void SetWindowMaxSize(int width, int height)
|
|||||||
|
|
||||||
CORE.Window.screenMax.width = width;
|
CORE.Window.screenMax.width = width;
|
||||||
CORE.Window.screenMax.height = height;
|
CORE.Window.screenMax.height = height;
|
||||||
|
|
||||||
SetWindowSize(platform.appScreenWidth, platform.appScreenHeight);
|
SetWindowSize(platform.appScreenWidth, platform.appScreenHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1771,7 +1771,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
|
|||||||
SIZE maxWindowSize = CalcWindowSize(96, maxClientSize, style);
|
SIZE maxWindowSize = CalcWindowSize(96, maxClientSize, style);
|
||||||
SIZE minClientSize = { CORE.Window.screenMin.width, CORE.Window.screenMin.height };
|
SIZE minClientSize = { CORE.Window.screenMin.width, CORE.Window.screenMin.height };
|
||||||
SIZE minWindowSize = CalcWindowSize(96, minClientSize, style);
|
SIZE minWindowSize = CalcWindowSize(96, minClientSize, style);
|
||||||
|
|
||||||
LPMINMAXINFO lpmmi = (LPMINMAXINFO) lparam;
|
LPMINMAXINFO lpmmi = (LPMINMAXINFO) lparam;
|
||||||
lpmmi->ptMaxSize.x = maxWindowSize.cx;
|
lpmmi->ptMaxSize.x = maxWindowSize.cx;
|
||||||
lpmmi->ptMaxSize.y = maxWindowSize.cy;
|
lpmmi->ptMaxSize.y = maxWindowSize.cy;
|
||||||
@ -1865,7 +1865,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
|
|||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
// WARNING: Don't trust the docs, they say this message can not be obtained if not calling DefWindowProc()
|
// WARNING: Don't trust the docs, they say this message can not be obtained if not calling DefWindowProc()
|
||||||
// in response to WM_WINDOWPOSCHANGED but looks like when a window is created,
|
// in response to WM_WINDOWPOSCHANGED but looks like when a window is created,
|
||||||
// this message can be obtained without getting WM_WINDOWPOSCHANGED
|
// this message can be obtained without getting WM_WINDOWPOSCHANGED
|
||||||
HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
|
HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
|
||||||
} break;
|
} break;
|
||||||
@ -1880,7 +1880,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
|
|||||||
SIZE *inoutSize = (SIZE *)lparam;
|
SIZE *inoutSize = (SIZE *)lparam;
|
||||||
UINT newDpi = (UINT)wparam; // TODO: WARNING: Converting from WPARAM = UINT_PTR
|
UINT newDpi = (UINT)wparam; // TODO: WARNING: Converting from WPARAM = UINT_PTR
|
||||||
|
|
||||||
// For the following flag changes, a window resize event should be posted,
|
// For the following flag changes, a window resize event should be posted,
|
||||||
// TODO: Should it be done after dpi changes?
|
// TODO: Should it be done after dpi changes?
|
||||||
if (CORE.Window.flags & FLAG_WINDOW_MINIMIZED) return TRUE;
|
if (CORE.Window.flags & FLAG_WINDOW_MINIMIZED) return TRUE;
|
||||||
if (CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) return TRUE;
|
if (CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) return TRUE;
|
||||||
@ -2188,7 +2188,7 @@ static unsigned SanitizeFlags(int mode, unsigned flags)
|
|||||||
// the state continues to change
|
// the state continues to change
|
||||||
//
|
//
|
||||||
// This design takes care of many odd corner cases. For example, in case of restoring
|
// This design takes care of many odd corner cases. For example, in case of restoring
|
||||||
// a window that was previously maximized AND minimized and those two flags need to be removed,
|
// a window that was previously maximized AND minimized and those two flags need to be removed,
|
||||||
// ShowWindow with SW_RESTORE twice need to bee actually calleed. Another example is
|
// ShowWindow with SW_RESTORE twice need to bee actually calleed. Another example is
|
||||||
// wheen having a maximized window, if the undecorated flag is modified then the window style
|
// wheen having a maximized window, if the undecorated flag is modified then the window style
|
||||||
// needs to be updated, but updating the style would mean the window size would change
|
// needs to be updated, but updating the style would mean the window size would change
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
@ -1428,7 +1428,7 @@ int InitPlatform(void)
|
|||||||
if ((eglClientExtensions != NULL) && (strstr(eglClientExtensions, "EGL_EXT_platform_base") != NULL))
|
if ((eglClientExtensions != NULL) && (strstr(eglClientExtensions, "EGL_EXT_platform_base") != NULL))
|
||||||
{
|
{
|
||||||
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
|
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||||
|
|
||||||
if (eglGetPlatformDisplayEXT != NULL) platform.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, platform.gbmDevice, NULL);
|
if (eglGetPlatformDisplayEXT != NULL) platform.device = eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, platform.gbmDevice, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -341,7 +341,7 @@ void SwapScreenBuffer(void)
|
|||||||
double GetTime(void)
|
double GetTime(void)
|
||||||
{
|
{
|
||||||
double time = 0.0;
|
double time = 0.0;
|
||||||
|
|
||||||
struct timespec ts = { 0 };
|
struct timespec ts = { 0 };
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
|
unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
|
||||||
@ -459,7 +459,7 @@ int InitPlatform(void)
|
|||||||
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
|
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
|
||||||
{
|
{
|
||||||
// TODO: Enable MSAA
|
// TODO: Enable MSAA
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4");
|
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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;
|
||||||
|
|||||||
@ -1255,7 +1255,7 @@ int InitPlatform(void)
|
|||||||
// Remember center for switchinging from fullscreen to window
|
// Remember center for switchinging from fullscreen to window
|
||||||
if ((CORE.Window.screen.height == CORE.Window.display.height) && (CORE.Window.screen.width == CORE.Window.display.width))
|
if ((CORE.Window.screen.height == CORE.Window.display.height) && (CORE.Window.screen.width == CORE.Window.display.width))
|
||||||
{
|
{
|
||||||
// If screen width/height equal to the display, it's not possible to
|
// If screen width/height equal to the display, it's not possible to
|
||||||
// calculate the window position for toggling full-screened/windowed
|
// calculate the window position for toggling full-screened/windowed
|
||||||
CORE.Window.position.x = CORE.Window.display.width/4;
|
CORE.Window.position.x = CORE.Window.display.width/4;
|
||||||
CORE.Window.position.y = CORE.Window.display.height/4;
|
CORE.Window.position.y = CORE.Window.display.height/4;
|
||||||
|
|||||||
33
src/raudio.c
33
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;
|
||||||
}
|
}
|
||||||
@ -2475,20 +2476,20 @@ static ma_uint32 ReadAudioBufferFramesInInternalFormat(AudioBuffer *audioBuffer,
|
|||||||
// Reads audio data from an AudioBuffer object in device format, returned data will be in a format appropriate for mixing
|
// Reads audio data from an AudioBuffer object in device format, returned data will be in a format appropriate for mixing
|
||||||
static ma_uint32 ReadAudioBufferFramesInMixingFormat(AudioBuffer *audioBuffer, float *framesOut, ma_uint32 frameCount)
|
static ma_uint32 ReadAudioBufferFramesInMixingFormat(AudioBuffer *audioBuffer, float *framesOut, ma_uint32 frameCount)
|
||||||
{
|
{
|
||||||
// NOTE: Continuously converting data from the AudioBuffer's internal format to the mixing format,
|
// NOTE: Continuously converting data from the AudioBuffer's internal format to the mixing format,
|
||||||
// which should be defined by the output format of the data converter.
|
// which should be defined by the output format of the data converter.
|
||||||
// This is done until frameCount frames have been output.
|
// This is done until frameCount frames have been output.
|
||||||
ma_uint32 bpf = ma_get_bytes_per_frame(audioBuffer->converter.formatIn, audioBuffer->converter.channelsIn);
|
ma_uint32 bpf = ma_get_bytes_per_frame(audioBuffer->converter.formatIn, audioBuffer->converter.channelsIn);
|
||||||
ma_uint8 inputBuffer[4096] = { 0 };
|
ma_uint8 inputBuffer[4096] = { 0 };
|
||||||
ma_uint32 inputBufferFrameCap = sizeof(inputBuffer)/bpf;
|
ma_uint32 inputBufferFrameCap = sizeof(inputBuffer)/bpf;
|
||||||
|
|
||||||
ma_uint32 totalOutputFramesProcessed = 0;
|
ma_uint32 totalOutputFramesProcessed = 0;
|
||||||
while (totalOutputFramesProcessed < frameCount)
|
while (totalOutputFramesProcessed < frameCount)
|
||||||
{
|
{
|
||||||
float *runningFramesOut = framesOut + (totalOutputFramesProcessed*audioBuffer->converter.channelsOut);
|
float *runningFramesOut = framesOut + (totalOutputFramesProcessed*audioBuffer->converter.channelsOut);
|
||||||
ma_uint64 outputFramesToProcessThisIteration = frameCount - totalOutputFramesProcessed;
|
ma_uint64 outputFramesToProcessThisIteration = frameCount - totalOutputFramesProcessed;
|
||||||
//ma_uint64 inputFramesToProcessThisIteration = 0;
|
//ma_uint64 inputFramesToProcessThisIteration = 0;
|
||||||
|
|
||||||
// Process any residual input frames from the previous read first.
|
// Process any residual input frames from the previous read first.
|
||||||
if (audioBuffer->converterResidualCount > 0)
|
if (audioBuffer->converterResidualCount > 0)
|
||||||
{
|
{
|
||||||
@ -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;
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
* - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2)
|
* - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2)
|
||||||
*
|
*
|
||||||
* DEPENDENCIES:
|
* DEPENDENCIES:
|
||||||
* [rcore] Depends on the selected platform backend, check rcore.c header for details
|
* [rcore] Depends on the selected platform backend, check rcore.c header for details
|
||||||
* [rlgl] glad/glad_gles2 (David Herberth - github.com/Dav1dde/glad) for OpenGL extensions loading
|
* [rlgl] glad/glad_gles2 (David Herberth - github.com/Dav1dde/glad) for OpenGL extensions loading
|
||||||
* [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management
|
* [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management
|
||||||
*
|
*
|
||||||
@ -39,7 +39,7 @@
|
|||||||
* [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG)
|
* [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG)
|
||||||
* [rtextures] stb_image_resize2 (Sean Barret) for image resizing algorithms
|
* [rtextures] stb_image_resize2 (Sean Barret) for image resizing algorithms
|
||||||
* [rtextures] stb_perlin (Sean Barret) for Perlin Noise image generation
|
* [rtextures] stb_perlin (Sean Barret) for Perlin Noise image generation
|
||||||
* [rtextures] rl_gputex (Ramon Santamaria) for GPU-compressed texture formats
|
* [rtextures] rl_gputex (Ramon Santamaria) for GPU-compressed texture formats
|
||||||
* [rtext] stb_truetype (Sean Barret) for ttf fonts loading
|
* [rtext] stb_truetype (Sean Barret) for ttf fonts loading
|
||||||
* [rtext] stb_rect_pack (Sean Barret) for rectangles packing
|
* [rtext] stb_rect_pack (Sean Barret) for rectangles packing
|
||||||
* [rmodels] par_shapes (Philip Rideout) for parametric 3d shapes generation
|
* [rmodels] par_shapes (Philip Rideout) for parametric 3d shapes generation
|
||||||
@ -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()
|
||||||
|
|||||||
@ -1523,7 +1523,7 @@ RMAPI float MatrixDeterminant(Matrix mat)
|
|||||||
a20*a01*a12*a33 - a00*a21*a12*a33 - a10*a01*a22*a33 + a00*a11*a22*a33;
|
a20*a01*a12*a33 - a00*a21*a12*a33 - a10*a01*a22*a33 + a00*a11*a22*a33;
|
||||||
*/
|
*/
|
||||||
// Using Laplace expansion (https://en.wikipedia.org/wiki/Laplace_expansion),
|
// Using Laplace expansion (https://en.wikipedia.org/wiki/Laplace_expansion),
|
||||||
// previous operation can be simplified to 40 multiplications, decreasing matrix
|
// previous operation can be simplified to 40 multiplications, decreasing matrix
|
||||||
// size from 4x4 to 2x2 using minors
|
// size from 4x4 to 2x2 using minors
|
||||||
|
|
||||||
// Cache the matrix values (speed optimization)
|
// Cache the matrix values (speed optimization)
|
||||||
@ -1686,20 +1686,20 @@ RMAPI Matrix MatrixSubtract(Matrix left, Matrix right)
|
|||||||
RMAPI Matrix MatrixMultiply(Matrix left, Matrix right)
|
RMAPI Matrix MatrixMultiply(Matrix left, Matrix right)
|
||||||
{
|
{
|
||||||
Matrix result = { 0 };
|
Matrix result = { 0 };
|
||||||
|
|
||||||
#if defined(RAYMATH_SSE_ENABLED)
|
#if defined(RAYMATH_SSE_ENABLED)
|
||||||
// Load left side and right side
|
// Load left side and right side
|
||||||
__m128 c0 = _mm_set_ps(right.m12, right.m8, right.m4, right.m0);
|
__m128 c0 = _mm_set_ps(right.m12, right.m8, right.m4, right.m0);
|
||||||
__m128 c1 = _mm_set_ps(right.m13, right.m9, right.m5, right.m1);
|
__m128 c1 = _mm_set_ps(right.m13, right.m9, right.m5, right.m1);
|
||||||
__m128 c2 = _mm_set_ps(right.m14, right.m10, right.m6, right.m2);
|
__m128 c2 = _mm_set_ps(right.m14, right.m10, right.m6, right.m2);
|
||||||
__m128 c3 = _mm_set_ps(right.m15, right.m11, right.m7, right.m3);
|
__m128 c3 = _mm_set_ps(right.m15, right.m11, right.m7, right.m3);
|
||||||
|
|
||||||
// Transpose so c0..c3 become *rows* of the right matrix in semantic order
|
// Transpose so c0..c3 become *rows* of the right matrix in semantic order
|
||||||
_MM_TRANSPOSE4_PS(c0, c1, c2, c3);
|
_MM_TRANSPOSE4_PS(c0, c1, c2, c3);
|
||||||
|
|
||||||
float tmp[4] = { 0 };
|
float tmp[4] = { 0 };
|
||||||
__m128 row;
|
__m128 row;
|
||||||
|
|
||||||
// Row 0 of result: [m0, m1, m2, m3]
|
// Row 0 of result: [m0, m1, m2, m3]
|
||||||
row = _mm_mul_ps(_mm_set1_ps(left.m0), c0);
|
row = _mm_mul_ps(_mm_set1_ps(left.m0), c0);
|
||||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m1), c1));
|
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m1), c1));
|
||||||
@ -1768,9 +1768,9 @@ RMAPI Matrix MatrixMultiply(Matrix left, Matrix right)
|
|||||||
RMAPI Matrix MatrixMultiplyValue(Matrix left, float value)
|
RMAPI Matrix MatrixMultiplyValue(Matrix left, float value)
|
||||||
{
|
{
|
||||||
Matrix result = {
|
Matrix result = {
|
||||||
left.m0 * value, left.m4 * value, left.m8 * value, left.m12 * value,
|
left.m0 * value, left.m4 * value, left.m8 * value, left.m12 * value,
|
||||||
left.m1 * value, left.m5 * value, left.m9 * value, left.m13 * value,
|
left.m1 * value, left.m5 * value, left.m9 * value, left.m13 * value,
|
||||||
left.m2 * value, left.m6 * value, left.m10 * value, left.m14 * value,
|
left.m2 * value, left.m6 * value, left.m10 * value, left.m14 * value,
|
||||||
left.m3 * value, left.m7 * value, left.m11 * value, left.m15 * value
|
left.m3 * value, left.m7 * value, left.m11 * value, left.m15 * value
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2679,7 +2679,7 @@ RMAPI Matrix MatrixCompose(Vector3 translation, Quaternion rotation, Vector3 sca
|
|||||||
right = Vector3RotateByQuaternion(right, rotation);
|
right = Vector3RotateByQuaternion(right, rotation);
|
||||||
up = Vector3RotateByQuaternion(up, rotation);
|
up = Vector3RotateByQuaternion(up, rotation);
|
||||||
forward = Vector3RotateByQuaternion(forward, rotation);
|
forward = Vector3RotateByQuaternion(forward, rotation);
|
||||||
|
|
||||||
// Set result matrix output
|
// Set result matrix output
|
||||||
Matrix result = {
|
Matrix result = {
|
||||||
right.x, up.x, forward.x, translation.x,
|
right.x, up.x, forward.x, translation.x,
|
||||||
@ -3091,9 +3091,9 @@ inline const Quaternion& operator *= (Quaternion& lhs, const Matrix& rhs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Matrix operators
|
// Matrix operators
|
||||||
static constexpr Matrix MatrixUnit = { 1, 0, 0, 0,
|
static constexpr Matrix MatrixUnit = { 1, 0, 0, 0,
|
||||||
0, 1, 0, 0,
|
0, 1, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
0, 0, 0, 1 };
|
0, 0, 0, 1 };
|
||||||
|
|
||||||
inline Matrix operator + (const Matrix& lhs, const Matrix& rhs)
|
inline Matrix operator + (const Matrix& lhs, const Matrix& rhs)
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ RLAPI Matrix GetCameraProjectionMatrix(Camera *camera, float aspect);
|
|||||||
// IsKeyDown()
|
// IsKeyDown()
|
||||||
// IsKeyPressed()
|
// IsKeyPressed()
|
||||||
// GetFrameTime()
|
// GetFrameTime()
|
||||||
|
|
||||||
#include <math.h> // Required for: fabsf()
|
#include <math.h> // Required for: fabsf()
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
@ -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
|
||||||
|
|||||||
58
src/rcore.c
58
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?
|
||||||
@ -3534,7 +3534,7 @@ AutomationEventList LoadAutomationEventList(const char *fileName)
|
|||||||
// Allocate and empty automation event list, ready to record new events
|
// Allocate and empty automation event list, ready to record new events
|
||||||
list.events = (AutomationEvent *)RL_CALLOC(MAX_AUTOMATION_EVENTS, sizeof(AutomationEvent));
|
list.events = (AutomationEvent *)RL_CALLOC(MAX_AUTOMATION_EVENTS, sizeof(AutomationEvent));
|
||||||
list.capacity = MAX_AUTOMATION_EVENTS;
|
list.capacity = MAX_AUTOMATION_EVENTS;
|
||||||
|
|
||||||
if (fileName == NULL) TRACELOG(LOG_INFO, "AUTOMATION: New empty events list loaded successfully");
|
if (fileName == NULL) TRACELOG(LOG_INFO, "AUTOMATION: New empty events list loaded successfully");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -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;
|
||||||
|
|
||||||
|
|||||||
@ -2982,7 +2982,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
|
|||||||
{
|
{
|
||||||
// Activate elements VAO
|
// Activate elements VAO
|
||||||
if (RLGL.ExtSupported.vao) glBindVertexArray(batch->vertexBuffer[batch->currentBuffer].vaoId);
|
if (RLGL.ExtSupported.vao) glBindVertexArray(batch->vertexBuffer[batch->currentBuffer].vaoId);
|
||||||
|
|
||||||
// TODO: If no data changed on the CPU arrays there is no need to re-upload data to GPU,
|
// TODO: If no data changed on the CPU arrays there is no need to re-upload data to GPU,
|
||||||
// a flag can be used to detect changes but it would imply keeping a copy buffer and memcmp() both, does it worth it?
|
// a flag can be used to detect changes but it would imply keeping a copy buffer and memcmp() both, does it worth it?
|
||||||
|
|
||||||
@ -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;
|
||||||
@ -4744,7 +4745,7 @@ Matrix rlGetMatrixTransform(void)
|
|||||||
// TODO: Consider possible transform matrices in the RLGL.State.stack
|
// TODO: Consider possible transform matrices in the RLGL.State.stack
|
||||||
//Matrix matStackTransform = rlMatrixIdentity();
|
//Matrix matStackTransform = rlMatrixIdentity();
|
||||||
//for (int i = RLGL.State.stackCounter; i > 0; i--) matStackTransform = rlMatrixMultiply(RLGL.State.stack[i], matStackTransform);
|
//for (int i = RLGL.State.stackCounter; i > 0; i--) matStackTransform = rlMatrixMultiply(RLGL.State.stack[i], matStackTransform);
|
||||||
|
|
||||||
mat = RLGL.State.transform;
|
mat = RLGL.State.transform;
|
||||||
#endif
|
#endif
|
||||||
return mat;
|
return mat;
|
||||||
|
|||||||
@ -2400,7 +2400,7 @@ void UpdateModelAnimationEx(Model model, ModelAnimation animA, float frameA, Mod
|
|||||||
Vector3 frameBScale = Vector3Lerp(
|
Vector3 frameBScale = Vector3Lerp(
|
||||||
animB.keyframePoses[currentFrameB][boneIndex].scale,
|
animB.keyframePoses[currentFrameB][boneIndex].scale,
|
||||||
animB.keyframePoses[nextFrameB][boneIndex].scale, blendB);
|
animB.keyframePoses[nextFrameB][boneIndex].scale, blendB);
|
||||||
|
|
||||||
// Compute interpolated pose between both animations frames
|
// Compute interpolated pose between both animations frames
|
||||||
// NOTE: Storing animation frame data in model.currentPose
|
// NOTE: Storing animation frame data in model.currentPose
|
||||||
model.currentPose[boneIndex].translation = Vector3Lerp(frameATranslation, frameBTranslation, blend);
|
model.currentPose[boneIndex].translation = Vector3Lerp(frameATranslation, frameBTranslation, blend);
|
||||||
@ -2435,20 +2435,20 @@ void UpdateModelAnimationEx(Model model, ModelAnimation animA, float frameA, Mod
|
|||||||
|
|
||||||
// Invert bind pose transformation
|
// Invert bind pose transformation
|
||||||
Vector3 invBindTranslation = Vector3RotateByQuaternion(
|
Vector3 invBindTranslation = Vector3RotateByQuaternion(
|
||||||
Vector3Negate(model.skeleton.bindPose[boneIndex].translation),
|
Vector3Negate(model.skeleton.bindPose[boneIndex].translation),
|
||||||
QuaternionInvert(model.skeleton.bindPose[boneIndex].rotation));
|
QuaternionInvert(model.skeleton.bindPose[boneIndex].rotation));
|
||||||
Quaternion invBindRotation = QuaternionInvert(model.skeleton.bindPose[boneIndex].rotation);
|
Quaternion invBindRotation = QuaternionInvert(model.skeleton.bindPose[boneIndex].rotation);
|
||||||
Vector3 invBindScale = Vector3Divide((Vector3){ 1.0f, 1.0f, 1.0f }, model.skeleton.bindPose[boneIndex].scale);
|
Vector3 invBindScale = Vector3Divide((Vector3){ 1.0f, 1.0f, 1.0f }, model.skeleton.bindPose[boneIndex].scale);
|
||||||
|
|
||||||
Vector3 boneTranslation = Vector3Add(Vector3RotateByQuaternion(
|
Vector3 boneTranslation = Vector3Add(Vector3RotateByQuaternion(
|
||||||
Vector3Multiply(model.currentPose[boneIndex].scale, invBindTranslation),
|
Vector3Multiply(model.currentPose[boneIndex].scale, invBindTranslation),
|
||||||
model.currentPose[boneIndex].rotation),
|
model.currentPose[boneIndex].rotation),
|
||||||
model.currentPose[boneIndex].translation);
|
model.currentPose[boneIndex].translation);
|
||||||
Quaternion boneRotation = QuaternionMultiply(model.currentPose[boneIndex].rotation, invBindRotation);
|
Quaternion boneRotation = QuaternionMultiply(model.currentPose[boneIndex].rotation, invBindRotation);
|
||||||
Vector3 boneScale = Vector3Multiply(model.currentPose[boneIndex].scale, invBindScale);
|
Vector3 boneScale = Vector3Multiply(model.currentPose[boneIndex].scale, invBindScale);
|
||||||
|
|
||||||
model.boneMatrices[boneIndex] = MatrixMultiply(
|
model.boneMatrices[boneIndex] = MatrixMultiply(
|
||||||
MatrixMultiply(QuaternionToMatrix(boneRotation),
|
MatrixMultiply(QuaternionToMatrix(boneRotation),
|
||||||
MatrixTranslate(boneTranslation.x, boneTranslation.y, boneTranslation.z)),
|
MatrixTranslate(boneTranslation.x, boneTranslation.y, boneTranslation.z)),
|
||||||
MatrixScale(boneScale.x, boneScale.y, boneScale.z));
|
MatrixScale(boneScale.x, boneScale.y, boneScale.z));
|
||||||
*/
|
*/
|
||||||
@ -2470,14 +2470,14 @@ static void UpdateModelAnimationVertexBuffers(Model model)
|
|||||||
Vector3 animVertex = { 0 };
|
Vector3 animVertex = { 0 };
|
||||||
Vector3 animNormal = { 0 };
|
Vector3 animNormal = { 0 };
|
||||||
const int vertexValuesCount = mesh.vertexCount*3;
|
const int vertexValuesCount = mesh.vertexCount*3;
|
||||||
|
|
||||||
int boneIndex = 0;
|
int boneIndex = 0;
|
||||||
int boneCounter = 0;
|
int boneCounter = 0;
|
||||||
float boneWeight = 0.0f;
|
float boneWeight = 0.0f;
|
||||||
bool bufferUpdateRequired = false; // Flag to check when anim vertex information is updated
|
bool bufferUpdateRequired = false; // Flag to check when anim vertex information is updated
|
||||||
|
|
||||||
// Skip if missing bone data or missing anim buffers initialization
|
// Skip if missing bone data or missing anim buffers initialization
|
||||||
if ((mesh.boneWeights == NULL) || (mesh.boneIndices == NULL) ||
|
if ((mesh.boneWeights == NULL) || (mesh.boneIndices == NULL) ||
|
||||||
(mesh.animVertices == NULL) || (mesh.animNormals == NULL)) continue;
|
(mesh.animVertices == NULL) || (mesh.animNormals == NULL)) continue;
|
||||||
|
|
||||||
for (int vCounter = 0; vCounter < vertexValuesCount; vCounter += 3)
|
for (int vCounter = 0; vCounter < vertexValuesCount; vCounter += 3)
|
||||||
@ -2534,7 +2534,7 @@ void UnloadModelAnimations(ModelAnimation *animations, int animCount)
|
|||||||
{
|
{
|
||||||
for (int a = 0; a < animCount; a++)
|
for (int a = 0; a < animCount; a++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < animations[a].keyframeCount; i++)
|
for (int i = 0; i < animations[a].keyframeCount; i++)
|
||||||
RL_FREE(animations[a].keyframePoses[i]);
|
RL_FREE(animations[a].keyframePoses[i]);
|
||||||
|
|
||||||
RL_FREE(animations[a].keyframePoses);
|
RL_FREE(animations[a].keyframePoses);
|
||||||
@ -4560,7 +4560,7 @@ static Model LoadOBJ(const char *fileName)
|
|||||||
model.meshes[i].texcoords = (float *)MemAlloc(sizeof(float)*vertexCount*2);
|
model.meshes[i].texcoords = (float *)MemAlloc(sizeof(float)*vertexCount*2);
|
||||||
model.meshes[i].colors = (unsigned char *)MemAlloc(sizeof(unsigned char)*vertexCount*4);
|
model.meshes[i].colors = (unsigned char *)MemAlloc(sizeof(unsigned char)*vertexCount*4);
|
||||||
#else
|
#else
|
||||||
if (objAttributes.texcoords != NULL && objAttributes.num_texcoords > 0)
|
if (objAttributes.texcoords != NULL && objAttributes.num_texcoords > 0)
|
||||||
model.meshes[i].texcoords = (float *)MemAlloc(sizeof(float)*vertexCount*2);
|
model.meshes[i].texcoords = (float *)MemAlloc(sizeof(float)*vertexCount*2);
|
||||||
else model.meshes[i].texcoords = NULL;
|
else model.meshes[i].texcoords = NULL;
|
||||||
model.meshes[i].colors = NULL;
|
model.meshes[i].colors = NULL;
|
||||||
@ -5159,7 +5159,7 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCou
|
|||||||
//else memcpy(bones[j].name, "ANIMJOINTNAME", 13); // Default bone name otherwise
|
//else memcpy(bones[j].name, "ANIMJOINTNAME", 13); // Default bone name otherwise
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int j = 0; j < anim[a].num_frames; j++)
|
for (unsigned int j = 0; j < anim[a].num_frames; j++)
|
||||||
animations[a].keyframePoses[j] = (Transform *)RL_MALLOC(iqmHeader->num_poses*sizeof(Transform));
|
animations[a].keyframePoses[j] = (Transform *)RL_MALLOC(iqmHeader->num_poses*sizeof(Transform));
|
||||||
|
|
||||||
int dcounter = anim[a].first_frame*iqmHeader->num_framechannels;
|
int dcounter = anim[a].first_frame*iqmHeader->num_framechannels;
|
||||||
@ -6166,9 +6166,9 @@ static Model LoadGLTF(const char *fileName)
|
|||||||
worldTransform[3], worldTransform[7], worldTransform[11], worldTransform[15]
|
worldTransform[3], worldTransform[7], worldTransform[11], worldTransform[15]
|
||||||
};
|
};
|
||||||
|
|
||||||
MatrixDecompose(worldMatrix,
|
MatrixDecompose(worldMatrix,
|
||||||
&(model.skeleton.bindPose[i].translation),
|
&(model.skeleton.bindPose[i].translation),
|
||||||
&(model.skeleton.bindPose[i].rotation),
|
&(model.skeleton.bindPose[i].rotation),
|
||||||
&(model.skeleton.bindPose[i].scale));
|
&(model.skeleton.bindPose[i].scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2387,11 +2387,11 @@ bool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2,
|
|||||||
{
|
{
|
||||||
collisionPoint->x = startPos1.x + t*rx;
|
collisionPoint->x = startPos1.x + t*rx;
|
||||||
collisionPoint->y = startPos1.y + t*ry;
|
collisionPoint->y = startPos1.y + t*ry;
|
||||||
|
|
||||||
collision = true;
|
collision = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return collision;
|
return collision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
src/rtext.c
24
src/rtext.c
@ -128,7 +128,7 @@
|
|||||||
static Font defaultFont = { 0 };
|
static Font defaultFont = { 0 };
|
||||||
|
|
||||||
// Text vertical line spacing in pixels (between lines)
|
// Text vertical line spacing in pixels (between lines)
|
||||||
static int textLineSpacing = 2;
|
static int textLineSpacing = 2;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Other Modules Functions Declaration (required by text)
|
// Other Modules Functions Declaration (required by text)
|
||||||
@ -729,7 +729,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
|
|||||||
{
|
{
|
||||||
stbtt_GetCodepointHMetrics(&fontInfo, cp, &glyphs[k].advanceX, NULL);
|
stbtt_GetCodepointHMetrics(&fontInfo, cp, &glyphs[k].advanceX, NULL);
|
||||||
glyphs[k].advanceX = (int)((float)glyphs[k].advanceX*scaleFactor);
|
glyphs[k].advanceX = (int)((float)glyphs[k].advanceX*scaleFactor);
|
||||||
|
|
||||||
Image imSpace = {
|
Image imSpace = {
|
||||||
.data = NULL,
|
.data = NULL,
|
||||||
.width = glyphs[k].advanceX,
|
.width = glyphs[k].advanceX,
|
||||||
@ -863,7 +863,7 @@ Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyp
|
|||||||
int updatedAtlasHeight = atlas.height*2;
|
int updatedAtlasHeight = atlas.height*2;
|
||||||
int updatedAtlasDataSize = atlas.width*updatedAtlasHeight;
|
int updatedAtlasDataSize = atlas.width*updatedAtlasHeight;
|
||||||
unsigned char *updatedAtlasData = (unsigned char *)RL_CALLOC(updatedAtlasDataSize, 1);
|
unsigned char *updatedAtlasData = (unsigned char *)RL_CALLOC(updatedAtlasDataSize, 1);
|
||||||
|
|
||||||
memcpy(updatedAtlasData, atlas.data, atlasDataSize);
|
memcpy(updatedAtlasData, atlas.data, atlasDataSize);
|
||||||
RL_FREE(atlas.data);
|
RL_FREE(atlas.data);
|
||||||
atlas.data = updatedAtlasData;
|
atlas.data = updatedAtlasData;
|
||||||
@ -1023,7 +1023,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
|
|||||||
// Get file name from path
|
// Get file name from path
|
||||||
char fileNamePascal[256] = { 0 };
|
char fileNamePascal[256] = { 0 };
|
||||||
strncpy(fileNamePascal, TextToPascal(GetFileNameWithoutExt(fileName)), 256 - 1);
|
strncpy(fileNamePascal, TextToPascal(GetFileNameWithoutExt(fileName)), 256 - 1);
|
||||||
|
|
||||||
// Get font atlas image and size, required to estimate code file size
|
// Get font atlas image and size, required to estimate code file size
|
||||||
// NOTE: This mechanism is highly coupled to raylib
|
// NOTE: This mechanism is highly coupled to raylib
|
||||||
Image image = LoadImageFromTexture(font.texture);
|
Image image = LoadImageFromTexture(font.texture);
|
||||||
@ -1032,13 +1032,13 @@ bool ExportFontAsCode(Font font, const char *fileName)
|
|||||||
|
|
||||||
// Image data is usually GRAYSCALE + ALPHA and can be reduced to GRAYSCALE
|
// Image data is usually GRAYSCALE + ALPHA and can be reduced to GRAYSCALE
|
||||||
//ImageFormat(&image, PIXELFORMAT_UNCOMPRESSED_GRAYSCALE);
|
//ImageFormat(&image, PIXELFORMAT_UNCOMPRESSED_GRAYSCALE);
|
||||||
|
|
||||||
// Estimate text code size
|
// Estimate text code size
|
||||||
// - Image data is stored as "0x%02x", so it requires at least 4 char per byte, let's use 6
|
// - Image data is stored as "0x%02x", so it requires at least 4 char per byte, let's use 6
|
||||||
// - font.recs[] data is stored as "{ %1.0f, %1.0f, %1.0f , %1.0f }", let's reserve 64 per rec
|
// - font.recs[] data is stored as "{ %1.0f, %1.0f, %1.0f , %1.0f }", let's reserve 64 per rec
|
||||||
// - font.glyphs[] data is stored as "{ %i, %i, %i, %i, { 0 }},\n", let's reserve 64 per glyph
|
// - font.glyphs[] data is stored as "{ %i, %i, %i, %i, { 0 }},\n", let's reserve 64 per glyph
|
||||||
// - Comments and additional code, let's reserve 32KB
|
// - Comments and additional code, let's reserve 32KB
|
||||||
int txtDataSize = imageDataSize*6 + font.glyphCount*64 + font.glyphCount*64 + 32768;
|
int txtDataSize = imageDataSize*6 + font.glyphCount*64 + font.glyphCount*64 + 32768;
|
||||||
char *txtData = (char *)RL_CALLOC(txtDataSize, sizeof(char));
|
char *txtData = (char *)RL_CALLOC(txtDataSize, sizeof(char));
|
||||||
|
|
||||||
int byteCount = 0;
|
int byteCount = 0;
|
||||||
@ -1493,7 +1493,7 @@ unsigned int TextLength(const char *text)
|
|||||||
unsigned int length = 0;
|
unsigned int length = 0;
|
||||||
|
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
{
|
{
|
||||||
while (text[length] != '\0') length++;
|
while (text[length] != '\0') length++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1707,7 +1707,7 @@ char *TextReplace(const char *text, const char *search, const char *replacement)
|
|||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
if ((text != NULL) && (search != NULL) && (search[0] != '\0'))
|
if ((text != NULL) && (search != NULL) && (search[0] != '\0'))
|
||||||
{
|
{
|
||||||
if (replacement == NULL) replacement = "";
|
if (replacement == NULL) replacement = "";
|
||||||
|
|
||||||
char *insertPoint = NULL; // Next insert point
|
char *insertPoint = NULL; // Next insert point
|
||||||
@ -1740,18 +1740,18 @@ char *TextReplace(const char *text, const char *search, const char *replacement)
|
|||||||
{
|
{
|
||||||
insertPoint = (char *)strstr(text, search);
|
insertPoint = (char *)strstr(text, search);
|
||||||
lastReplacePos = (int)(insertPoint - text);
|
lastReplacePos = (int)(insertPoint - text);
|
||||||
|
|
||||||
memcpy(temp, text, lastReplacePos);
|
memcpy(temp, text, lastReplacePos);
|
||||||
temp += lastReplacePos;
|
temp += lastReplacePos;
|
||||||
|
|
||||||
if (replaceLen > 0)
|
if (replaceLen > 0)
|
||||||
{
|
{
|
||||||
memcpy(temp, replacement, replaceLen);
|
memcpy(temp, replacement, replaceLen);
|
||||||
temp += replaceLen;
|
temp += replaceLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
text += (lastReplacePos + searchLen); // Move to next "end of replace"
|
text += (lastReplacePos + searchLen); // Move to next "end of replace"
|
||||||
|
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user