3 Commits

4 changed files with 43 additions and 29 deletions

View File

@ -916,6 +916,8 @@ int GetCurrentMonitor(void)
// Get selected monitor position
Vector2 GetMonitorPosition(int monitor)
{
Vector2 position = { 0 };
int monitorCount = 0;
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
@ -925,10 +927,11 @@ Vector2 GetMonitorPosition(int monitor)
int y = 0;
glfwGetMonitorPos(monitors[monitor], &x, &y);
return (Vector2){ (float)x, (float)y };
position = (Vector2){ (float)x, (float)y };
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
return (Vector2){ 0, 0 };
return position;
}
// Get selected monitor width (currently used by monitor)
@ -1018,31 +1021,39 @@ int GetMonitorRefreshRate(int monitor)
// Get the human-readable, UTF-8 encoded name of the selected monitor
const char *GetMonitorName(int monitor)
{
const char *name = NULL;
int monitorCount = 0;
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
if ((monitor >= 0) && (monitor < monitorCount))
{
return glfwGetMonitorName(monitors[monitor]);
name = glfwGetMonitorName(monitors[monitor]);
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
return "";
return name;
}
// Get window position XY on monitor
Vector2 GetWindowPosition(void)
{
Vector2 position = { 0 };
glfwGetWindowPos(platform.handle, &CORE.Window.position.x, &CORE.Window.position.y);
position = (Vector2){ (float)CORE.Window.position.x, (float)CORE.Window.position.y };
return (Vector2){ (float)CORE.Window.position.x, (float)CORE.Window.position.y };
return position;
}
// Get window scale DPI factor for current monitor
Vector2 GetWindowScaleDPI(void)
{
Vector2 scale = { 1.0f, 1.0f };
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) && !FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
glfwGetWindowContentScale(platform.handle, &scale.x, &scale.y);
return scale;
}

View File

@ -810,11 +810,9 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
{
Wave wave = { 0 };
if (fileType == NULL)
{
TRACELOG(LOG_WARNING, "WAVE: Missing file extension");
return wave;
}
// Security checks for input data
if ((fileData == NULL) || (dataSize <= 0)) { TRACELOG(LOG_WARNING, "WAVE: Invalid file data"); return wave; }
if (fileType == NULL) { TRACELOG(LOG_WARNING, "WAVE: Missing file extension"); return wave; }
if (false) { }
#if SUPPORT_FILEFORMAT_WAV
@ -1551,6 +1549,10 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
Music music = { 0 };
bool musicLoaded = false;
// Security checks for input data
if ((data == NULL) || (dataSize <= 0)) { TRACELOG(LOG_WARNING, "MUSIC: Invalid file data"); return music; }
if (fileType == NULL) { TRACELOG(LOG_WARNING, "MUSIC: Missing file extension"); return music; }
if (false) { }
#if SUPPORT_FILEFORMAT_WAV
else if ((strcmp(fileType, ".wav") == 0) || (strcmp(fileType, ".WAV") == 0))

View File

@ -2630,21 +2630,30 @@ RMAPI Vector3 QuaternionToEuler(Quaternion q)
{
Vector3 result = { 0 };
// Roll (x-axis rotation)
float x0 = 2.0f*(q.w*q.x + q.y*q.z);
float x1 = 1.0f - 2.0f*(q.x*q.x + q.y*q.y);
result.x = atan2f(x0, x1);
// Pitch (y-axis rotation)
float y0 = 2.0f*(q.w*q.y - q.z*q.x);
y0 = y0 > 1.0f ? 1.0f : y0;
y0 = y0 < -1.0f ? -1.0f : y0;
result.y = asinf(y0);
// Yaw (z-axis rotation)
float z0 = 2.0f*(q.w*q.z + q.x*q.y);
float z1 = 1.0f - 2.0f*(q.y*q.y + q.z*q.z);
result.z = atan2f(z0, z1);
if (fabsf(y0) >= 0.9999995f)
{
// Gimbal lock: roll and yaw turn about the same axis, keep the whole turn in roll
float sign = (q.w < 0.0f)? -1.0f : 1.0f;
result.x = 2.0f*atan2f(sign*q.x, sign*q.w);
}
else
{
// Roll (x-axis rotation)
float x0 = 2.0f*(q.w*q.x + q.y*q.z);
float x1 = 1.0f - 2.0f*(q.x*q.x + q.y*q.y);
result.x = atan2f(x0, x1);
// Yaw (z-axis rotation)
float z0 = 2.0f*(q.w*q.z + q.x*q.y);
float z1 = 1.0f - 2.0f*(q.y*q.y + q.z*q.z);
result.z = atan2f(z0, z1);
}
return result;
}

View File

@ -423,16 +423,8 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
Image image = { 0 };
// Security checks for input data
if ((fileData == NULL) || (dataSize == 0))
{
TRACELOG(LOG_WARNING, "IMAGE: Invalid file data");
return image;
}
if (fileType == NULL)
{
TRACELOG(LOG_WARNING, "IMAGE: Missing file extension");
return image;
}
if ((fileData == NULL) || (dataSize == 0)) { TRACELOG(LOG_WARNING, "IMAGE: Invalid file data"); return image; }
if (fileType == NULL) { TRACELOG(LOG_WARNING, "IMAGE: Missing file extension"); return image; }
if ((false)
#if SUPPORT_FILEFORMAT_PNG