Merge branch 'master' of github.com:raysan5/raylib

This commit is contained in:
Jeffery Myers 2024-05-11 15:27:39 -07:00
commit a126ff8c95
13 changed files with 8202 additions and 154 deletions

View File

@ -82,6 +82,7 @@ Some people ported raylib to other languages in form of bindings or wrappers to
| Raylib.lean | 4.5 | [Lean4](https://lean-lang.org/) | BSD-3-Clause | https://github.com/KislyjKisel/Raylib.lean | | Raylib.lean | 4.5 | [Lean4](https://lean-lang.org/) | BSD-3-Clause | https://github.com/KislyjKisel/Raylib.lean |
| Raylib-CSharp-Vinculum | 5.0 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/ZeroElectric/Raylib-CSharp-Vinculum | | Raylib-CSharp-Vinculum | 5.0 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | https://github.com/ZeroElectric/Raylib-CSharp-Vinculum |
| raylib-cobol | **auto** | [COBOL](https://gnucobol.sourceforge.io) | Public domain | https://codeberg.org/glowiak/raylib-cobol | | raylib-cobol | **auto** | [COBOL](https://gnucobol.sourceforge.io) | Public domain | https://codeberg.org/glowiak/raylib-cobol |
| Raylib-CSharp | 5.0 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MIT | https://github.com/MrScautHD/Raylib-CSharp |
### Utility Wrapers ### Utility Wrapers
These are utility wrappers for specific languages, they are not required to use raylib in the language but may adapt the raylib API to be more inline with the language's pardigm. These are utility wrappers for specific languages, they are not required to use raylib in the language but may adapt the raylib API to be more inline with the language's pardigm.

View File

@ -13,6 +13,11 @@
# - Windows (Win32, Win64) # - Windows (Win32, Win64)
# - Linux (X11/Wayland desktop mode) # - Linux (X11/Wayland desktop mode)
# - Others (not tested) # - Others (not tested)
# > PLATFORM_DESKTOP_RGFW (RGFW backend):
# - Windows (Win32, Win64)
# - Linux (X11 desktop mode)
# - macOS/OSX (x64, arm64 (not tested))
# - Others (not tested)
# > PLATFORM_WEB: # > PLATFORM_WEB:
# - HTML5 (WebAssembly) # - HTML5 (WebAssembly)
# > PLATFORM_DRM: # > PLATFORM_DRM:
@ -86,7 +91,7 @@ BUILD_WEB_RESOURCES ?= TRUE
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
# Determine PLATFORM_OS when required # Determine PLATFORM_OS when required
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_DESKTOP_SDL PLATFORM_WEB)) ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_DESKTOP_SDL PLATFORM_WEB PLATFORM_DESKTOP_RGFW))
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows # ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
@ -416,6 +421,31 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP_SDL)
LDLIBS += -latomic LDLIBS += -latomic
endif endif
endif endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation
LDLIBS = ..\src\libraylib.a -lgdi32 -lwinmm -lopengl32
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compipling
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = ../src/libraylib.a -lGL -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -lpthread -ldl -lrt
# Explicit link to libc
ifeq ($(RAYLIB_LIBTYPE),SHARED)
LDLIBS += -lc
endif
# NOTE: On ARM 32bit arch, miniaudio requires atomics library
LDLIBS += -latomic
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = ../src/libraylib.a -lm
LDLIBS += -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo
endif
endif
ifeq ($(PLATFORM),PLATFORM_DRM) ifeq ($(PLATFORM),PLATFORM_DRM)
# Libraries for DRM compiling # Libraries for DRM compiling
# NOTE: Required packages: libasound2-dev (ALSA) # NOTE: Required packages: libasound2-dev (ALSA)

View File

@ -2,7 +2,7 @@
precision mediump float; precision mediump float;
const int colors = 8; const int MAX_INDEXED_COLORS = 8;
// Input vertex attributes (from vertex shader) // Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord; varying vec2 fragTexCoord;
@ -10,7 +10,8 @@ varying vec4 fragColor;
// Input uniform values // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform ivec3 palette[colors]; uniform ivec3 palette[MAX_INDEXED_COLORS];
//uniform sampler2D palette; // Alternative to ivec3, palette provided as a 256x1 texture
void main() void main()
{ {
@ -18,13 +19,13 @@ void main()
vec4 texelColor = texture2D(texture0, fragTexCoord)*fragColor; vec4 texelColor = texture2D(texture0, fragTexCoord)*fragColor;
// Convert the (normalized) texel color RED component (GB would work, too) // Convert the (normalized) texel color RED component (GB would work, too)
// to the palette index by scaling up from [0, 1] to [0, 255]. // to the palette index by scaling up from [0..1] to [0..255]
int index = int(texelColor.r*255.0); int index = int(texelColor.r*255.0);
ivec3 color = ivec3(0); ivec3 color = ivec3(0);
// NOTE: On GLSL 100 we are not allowed to index a uniform array by a variable value, // NOTE: On GLSL 100 we are not allowed to index a uniform array by a variable value,
// a constantmust be used, so this logic... // a constant must be used, so this logic...
if (index == 0) color = palette[0]; if (index == 0) color = palette[0];
else if (index == 1) color = palette[1]; else if (index == 1) color = palette[1];
else if (index == 2) color = palette[2]; else if (index == 2) color = palette[2];
@ -34,8 +35,9 @@ void main()
else if (index == 6) color = palette[6]; else if (index == 6) color = palette[6];
else if (index == 7) color = palette[7]; else if (index == 7) color = palette[7];
//gl_FragColor = texture2D(palette, texelColor.xy); // Alternative to ivec3
// Calculate final fragment color. Note that the palette color components // Calculate final fragment color. Note that the palette color components
// are defined in the range [0, 255] and need to be normalized to [0, 1] // are defined in the range [0..255] and need to be normalized to [0..1]
// for OpenGL to work.
gl_FragColor = vec4(float(color.x)/255.0, float(color.y)/255.0, float(color.z)/255.0, texelColor.a); gl_FragColor = vec4(float(color.x)/255.0, float(color.y)/255.0, float(color.z)/255.0, texelColor.a);
} }

View File

@ -1,6 +1,6 @@
#version 330 #version 330
const int colors = 8; const int MAX_INDEXED_COLORS = 8;
// Input fragment attributes (from fragment shader) // Input fragment attributes (from fragment shader)
in vec2 fragTexCoord; in vec2 fragTexCoord;
@ -8,7 +8,8 @@ in vec4 fragColor;
// Input uniform values // Input uniform values
uniform sampler2D texture0; uniform sampler2D texture0;
uniform ivec3 palette[colors]; uniform ivec3 palette[MAX_INDEXED_COLORS];
//uniform sampler2D palette; // Alternative to ivec3, palette provided as a 256x1 texture
// Output fragment color // Output fragment color
out vec4 finalColor; out vec4 finalColor;
@ -16,15 +17,17 @@ out vec4 finalColor;
void main() void main()
{ {
// Texel color fetching from texture sampler // Texel color fetching from texture sampler
// NOTE: The texel is actually the a GRAYSCALE index color
vec4 texelColor = texture(texture0, fragTexCoord)*fragColor; vec4 texelColor = texture(texture0, fragTexCoord)*fragColor;
// Convert the (normalized) texel color RED component (GB would work, too) // Convert the (normalized) texel color RED component (GB would work, too)
// to the palette index by scaling up from [0, 1] to [0, 255]. // to the palette index by scaling up from [0..1] to [0..255]
int index = int(texelColor.r*255.0); int index = int(texelColor.r*255.0);
ivec3 color = palette[index]; ivec3 color = palette[index];
//finalColor = texture(palette, texelColor.xy); // Alternative to ivec3
// Calculate final fragment color. Note that the palette color components // Calculate final fragment color. Note that the palette color components
// are defined in the range [0, 255] and need to be normalized to [0, 1] // are defined in the range [0..255] and need to be normalized to [0..1]
// for OpenGL to work.
finalColor = vec4(color/255.0, texelColor.a); finalColor = vec4(color/255.0, texelColor.a);
} }

View File

@ -13,6 +13,11 @@
# - Windows (Win32, Win64) # - Windows (Win32, Win64)
# - Linux (X11/Wayland desktop mode) # - Linux (X11/Wayland desktop mode)
# - Others (not tested) # - Others (not tested)
# > PLATFORM_DESKTOP_RGFW (RGFW backend):
# - Windows (Win32, Win64)
# - Linux (X11 desktop mode)
# - macOS/OSX (x64, arm64 (not tested))
# - Others (not tested)
# > PLATFORM_WEB: # > PLATFORM_WEB:
# - HTML5 (WebAssembly) # - HTML5 (WebAssembly)
# > PLATFORM_DRM: # > PLATFORM_DRM:
@ -114,7 +119,7 @@ HOST_PLATFORM_OS ?= WINDOWS
PLATFORM_OS ?= WINDOWS PLATFORM_OS ?= WINDOWS
# Determine PLATFORM_OS when required # Determine PLATFORM_OS when required
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_DESKTOP_SDL PLATFORM_WEB PLATFORM_ANDROID)) ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_DESKTOP_SDL PLATFORM_WEB PLATFORM_ANDROID PLATFORM_DESKTOP_RGFW))
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows # ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
@ -224,6 +229,14 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
#GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3 #GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
#GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE) #GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
endif endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP_RGFW)
# By default use OpenGL 3.3 on desktop platforms
GRAPHICS ?= GRAPHICS_API_OPENGL_33
#GRAPHICS = GRAPHICS_API_OPENGL_11 # Uncomment to use OpenGL 1.1
#GRAPHICS = GRAPHICS_API_OPENGL_21 # Uncomment to use OpenGL 2.1
#GRAPHICS = GRAPHICS_API_OPENGL_43 # Uncomment to use OpenGL 4.3
#GRAPHICS = GRAPHICS_API_OPENGL_ES2 # Uncomment to use OpenGL ES 2.0 (ANGLE)
endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP_SDL) ifeq ($(PLATFORM),PLATFORM_DESKTOP_SDL)
# By default use OpenGL 3.3 on desktop platform with SDL backend # By default use OpenGL 3.3 on desktop platform with SDL backend
GRAPHICS ?= GRAPHICS_API_OPENGL_33 GRAPHICS ?= GRAPHICS_API_OPENGL_33
@ -576,6 +589,30 @@ endif
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_ANDROID)
LDLIBS = -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm LDLIBS = -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm
endif endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation
LDLIBS = -lgdi32 -lwinmm -lopengl32
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compipling
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lGL -lX11 -lXrandr -lXinerama -lXi -lXcursor -lm -lpthread -ldl -lrt
# Explicit link to libc
ifeq ($(RAYLIB_LIBTYPE),SHARED)
LDLIBS += -lc
endif
# NOTE: On ARM 32bit arch, miniaudio requires atomics library
LDLIBS += -latomic
endif
ifeq ($(PLATFORM_OS),OSX)
# Libraries for Debian MacOS desktop compiling
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS += -lm -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo
endif
endif
# Define source code object files required # Define source code object files required
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
@ -585,6 +622,7 @@ OBJS = rcore.o \
rtext.o \ rtext.o \
utils.o utils.o
ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM),PLATFORM_DESKTOP)
ifeq ($(USE_EXTERNAL_GLFW),FALSE) ifeq ($(USE_EXTERNAL_GLFW),FALSE)
OBJS += rglfw.o OBJS += rglfw.o
@ -619,7 +657,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
@echo "raylib library generated (lib$(RAYLIB_LIB_NAME).a)!" @echo "raylib library generated (lib$(RAYLIB_LIB_NAME).a)!"
else else
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_DESKTOP_SDL)) ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW))
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# NOTE: Linking with provided resource file # NOTE: Linking with provided resource file
$(CC) -shared -o $(RAYLIB_RELEASE_PATH)/$(RAYLIB_LIB_NAME).dll $(OBJS) $(RAYLIB_RES_FILE) $(LDFLAGS) $(LDLIBS) $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/$(RAYLIB_LIB_NAME).dll $(OBJS) $(RAYLIB_RES_FILE) $(LDFLAGS) $(LDLIBS)

6348
src/external/RGFW.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -229,7 +229,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
} }
} }
} }
else if (header->ddspf.flags == 0x40 && header->ddspf.rgb_bit_count == 24) // DDS_RGB, no compressed else if ((header->ddspf.flags == 0x40) && (header->ddspf.rgb_bit_count == 24)) // DDS_RGB, no compressed
{ {
int data_size = image_pixel_size*3*sizeof(unsigned char); int data_size = image_pixel_size*3*sizeof(unsigned char);
image_data = RL_MALLOC(data_size); image_data = RL_MALLOC(data_size);
@ -238,7 +238,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
*format = PIXELFORMAT_UNCOMPRESSED_R8G8B8; *format = PIXELFORMAT_UNCOMPRESSED_R8G8B8;
} }
else if (header->ddspf.flags == 0x41 && header->ddspf.rgb_bit_count == 32) // DDS_RGBA, no compressed else if ((header->ddspf.flags == 0x41) && (header->ddspf.rgb_bit_count == 32)) // DDS_RGBA, no compressed
{ {
int data_size = image_pixel_size*4*sizeof(unsigned char); int data_size = image_pixel_size*4*sizeof(unsigned char);
image_data = RL_MALLOC(data_size); image_data = RL_MALLOC(data_size);

View File

@ -1218,6 +1218,19 @@ void PollInputEvents(void)
// Module Internal Functions Definition // Module Internal Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static void SetDimensionsFromMonitor(GLFWmonitor *monitor)
{
const GLFWvidmode *mode = glfwGetVideoMode(monitor);
// Default display resolution to that of the current mode
CORE.Window.display.width = mode->width;
CORE.Window.display.height = mode->height;
// Set screen width/height to the display width/height if they are 0
if (CORE.Window.screen.width == 0) CORE.Window.screen.width = CORE.Window.display.width;
if (CORE.Window.screen.height == 0) CORE.Window.screen.height = CORE.Window.display.height;
}
// Initialize platform: graphics, inputs and more // Initialize platform: graphics, inputs and more
int InitPlatform(void) int InitPlatform(void)
{ {
@ -1358,26 +1371,22 @@ int InitPlatform(void)
// REF: https://github.com/raysan5/raylib/issues/1554 // REF: https://github.com/raysan5/raylib/issues/1554
glfwSetJoystickCallback(NULL); glfwSetJoystickCallback(NULL);
// Find monitor resolution GLFWmonitor *monitor = NULL;
GLFWmonitor *monitor = glfwGetPrimaryMonitor(); if (CORE.Window.fullscreen)
{
// According to glfwCreateWindow(), if the user does not have a choice, fullscreen applications
// should default to the primary monitor.
monitor = glfwGetPrimaryMonitor();
if (!monitor) if (!monitor)
{ {
TRACELOG(LOG_WARNING, "GLFW: Failed to get primary monitor"); TRACELOG(LOG_WARNING, "GLFW: Failed to get primary monitor");
return -1; return -1;
} }
const GLFWvidmode *mode = glfwGetVideoMode(monitor); SetDimensionsFromMonitor(monitor);
CORE.Window.display.width = mode->width; // Remember center for switching from fullscreen to window
CORE.Window.display.height = mode->height;
// Set screen width/height to the display width/height if they are 0
if (CORE.Window.screen.width == 0) CORE.Window.screen.width = CORE.Window.display.width;
if (CORE.Window.screen.height == 0) CORE.Window.screen.height = CORE.Window.display.height;
if (CORE.Window.fullscreen)
{
// 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, we can't calculate the window pos for toggling full-screened/windowed. // If screen width/height equal to the display, we can't calculate the window pos for toggling full-screened/windowed.
@ -1396,7 +1405,7 @@ int InitPlatform(void)
// Obtain recommended CORE.Window.display.width/CORE.Window.display.height from a valid videomode for the monitor // Obtain recommended CORE.Window.display.width/CORE.Window.display.height from a valid videomode for the monitor
int count = 0; int count = 0;
const GLFWvidmode *modes = glfwGetVideoModes(glfwGetPrimaryMonitor(), &count); const GLFWvidmode *modes = glfwGetVideoModes(monitor, &count);
// Get closest video mode to desired CORE.Window.screen.width/CORE.Window.screen.height // Get closest video mode to desired CORE.Window.screen.width/CORE.Window.screen.height
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@ -1426,21 +1435,55 @@ int InitPlatform(void)
// HighDPI monitors are properly considered in a following similar function: SetupViewport() // HighDPI monitors are properly considered in a following similar function: SetupViewport()
SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height); SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height);
platform.handle = glfwCreateWindow(CORE.Window.display.width, CORE.Window.display.height, (CORE.Window.title != 0)? CORE.Window.title : " ", glfwGetPrimaryMonitor(), NULL); platform.handle = glfwCreateWindow(CORE.Window.display.width, CORE.Window.display.height, (CORE.Window.title != 0)? CORE.Window.title : " ", monitor, NULL);
// NOTE: Full-screen change, not working properly... // NOTE: Full-screen change, not working properly...
//glfwSetWindowMonitor(platform.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); //glfwSetWindowMonitor(platform.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
} }
else else
{ {
// If we are windowed fullscreen, ensures that window does not minimize when focus is lost // No-fullscreen window creation
if ((CORE.Window.screen.height == CORE.Window.display.height) && (CORE.Window.screen.width == CORE.Window.display.width)) bool wantWindowedFullscreen = (CORE.Window.screen.height == 0) && (CORE.Window.screen.width == 0);
// If we are windowed fullscreen, ensures that window does not minimize when focus is lost.
// This hinting code will not work if the user already specified the correct monitor dimensions;
// at this point we don't know the monitor's dimensions. (Though, how did the user then?)
if (wantWindowedFullscreen)
{ {
glfwWindowHint(GLFW_AUTO_ICONIFY, 0); glfwWindowHint(GLFW_AUTO_ICONIFY, 0);
} }
// No-fullscreen window creation // Default to at least one pixel in size, as creation with a zero dimension is not allowed.
platform.handle = glfwCreateWindow(CORE.Window.screen.width, CORE.Window.screen.height, (CORE.Window.title != 0)? CORE.Window.title : " ", NULL, NULL); int creationWidth = CORE.Window.screen.width != 0 ? CORE.Window.screen.width : 1;
int creationHeight = CORE.Window.screen.height != 0 ? CORE.Window.screen.height : 1;
platform.handle = glfwCreateWindow(creationWidth, creationHeight, (CORE.Window.title != 0)? CORE.Window.title : " ", NULL, NULL);
// After the window was created, determine the monitor that the window manager assigned.
// Derive display sizes, and, if possible, window size in case it was zero at beginning.
int monitorCount = 0;
int monitorIndex = GetCurrentMonitor();
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
if (monitorIndex < monitorCount)
{
monitor = monitors[monitorIndex];
SetDimensionsFromMonitor(monitor);
TRACELOG(LOG_INFO, "wantWindowed: %d, size: %dx%d", wantWindowedFullscreen, CORE.Window.screen.width, CORE.Window.screen.height);
if (wantWindowedFullscreen)
{
glfwSetWindowSize(platform.handle, CORE.Window.screen.width, CORE.Window.screen.height);
}
}
else
{
// The monitor for the window-manager-created window can not be determined, so it can not be centered.
glfwTerminate();
TRACELOG(LOG_WARNING, "GLFW: Failed to determine Monitor to center Window");
return -1;
}
if (platform.handle) if (platform.handle)
{ {
@ -1524,8 +1567,8 @@ int InitPlatform(void)
int monitorHeight = 0; int monitorHeight = 0;
glfwGetMonitorWorkarea(monitor, &monitorX, &monitorY, &monitorWidth, &monitorHeight); glfwGetMonitorWorkarea(monitor, &monitorX, &monitorY, &monitorWidth, &monitorHeight);
int posX = monitorX + (monitorWidth - CORE.Window.screen.width)/2; int posX = monitorX + (monitorWidth - (int)CORE.Window.screen.width)/2;
int posY = monitorY + (monitorHeight - CORE.Window.screen.height)/2; int posY = monitorY + (monitorHeight - (int)CORE.Window.screen.height)/2;
if (posX < monitorX) posX = monitorX; if (posX < monitorX) posX = monitorX;
if (posY < monitorY) posY = monitorY; if (posY < monitorY) posY = monitorY;
SetWindowPosition(posX, posY); SetWindowPosition(posX, posY);

File diff suppressed because it is too large Load Diff

View File

@ -388,29 +388,69 @@ Vector2 GetMonitorPosition(int monitor)
// Get selected monitor width (currently used by monitor) // Get selected monitor width (currently used by monitor)
int GetMonitorWidth(int monitor) int GetMonitorWidth(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorWidth() not implemented on target platform"); int width = 0;
return 0;
if (monitor != 0)
{
TRACELOG(LOG_WARNING, "GetMonitorWidth() implemented for first monitor only");
}
else if ((platform.connector) && (platform.modeIndex >= 0))
{
width = platform.connector->modes[platform.modeIndex].hdisplay;
}
return width;
} }
// Get selected monitor height (currently used by monitor) // Get selected monitor height (currently used by monitor)
int GetMonitorHeight(int monitor) int GetMonitorHeight(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorHeight() not implemented on target platform"); int height = 0;
return 0;
if (monitor != 0)
{
TRACELOG(LOG_WARNING, "GetMonitorHeight() implemented for first monitor only");
}
else if ((platform.connector) && (platform.modeIndex >= 0))
{
height = platform.connector->modes[platform.modeIndex].vdisplay;
}
return height;
} }
// Get selected monitor physical width in millimetres // Get selected monitor physical width in millimetres
int GetMonitorPhysicalWidth(int monitor) int GetMonitorPhysicalWidth(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth() not implemented on target platform"); int physicalWidth = 0;
return 0;
if (monitor != 0)
{
TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth() implemented for first monitor only");
}
else if ((platform.connector) && (platform.modeIndex >= 0))
{
physicalWidth = platform.connector->mmWidth;
}
return physicalWidth;
} }
// Get selected monitor physical height in millimetres // Get selected monitor physical height in millimetres
int GetMonitorPhysicalHeight(int monitor) int GetMonitorPhysicalHeight(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight() not implemented on target platform"); int physicalHeight = 0;
return 0;
if (monitor != 0)
{
TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight() implemented for first monitor only");
}
else if ((platform.connector) && (platform.modeIndex >= 0))
{
physicalHeight = platform.connector->mmHeight;
}
return physicalHeight;
} }
// Get selected monitor refresh rate // Get selected monitor refresh rate
@ -429,8 +469,18 @@ int GetMonitorRefreshRate(int monitor)
// Get the human-readable, UTF-8 encoded name of the selected monitor // Get the human-readable, UTF-8 encoded name of the selected monitor
const char *GetMonitorName(int monitor) const char *GetMonitorName(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorName() not implemented on target platform"); const char *name = "";
return "";
if (monitor != 0)
{
TRACELOG(LOG_WARNING, "GetMonitorName() implemented for first monitor only");
}
else if ((platform.connector) && (platform.modeIndex >= 0))
{
name = platform.connector->modes[platform.modeIndex].name;
}
return name;
} }
// Get window position XY on monitor // Get window position XY on monitor

View File

@ -1334,11 +1334,10 @@ Music LoadMusicStream(const char *fileName)
drwav *ctxWav = RL_CALLOC(1, sizeof(drwav)); drwav *ctxWav = RL_CALLOC(1, sizeof(drwav));
bool success = drwav_init_file(ctxWav, fileName, NULL); bool success = drwav_init_file(ctxWav, fileName, NULL);
music.ctxType = MUSIC_AUDIO_WAV;
music.ctxData = ctxWav;
if (success) if (success)
{ {
music.ctxType = MUSIC_AUDIO_WAV;
music.ctxData = ctxWav;
int sampleSize = ctxWav->bitsPerSample; int sampleSize = ctxWav->bitsPerSample;
if (ctxWav->bitsPerSample == 24) sampleSize = 16; // Forcing conversion to s16 on UpdateMusicStream() if (ctxWav->bitsPerSample == 24) sampleSize = 16; // Forcing conversion to s16 on UpdateMusicStream()
@ -1347,17 +1346,23 @@ Music LoadMusicStream(const char *fileName)
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
} }
else
{
drwav_uninit(ctxWav);
RL_FREE(ctxWav);
}
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_OGG) #if defined(SUPPORT_FILEFORMAT_OGG)
else if (IsFileExtension(fileName, ".ogg")) else if (IsFileExtension(fileName, ".ogg"))
{ {
// Open ogg audio stream // Open ogg audio stream
music.ctxType = MUSIC_AUDIO_OGG; stb_vorbis *ctxOgg = stb_vorbis_open_filename(fileName, NULL, NULL);
music.ctxData = stb_vorbis_open_filename(fileName, NULL, NULL);
if (music.ctxData != NULL) if (ctxOgg != NULL)
{ {
music.ctxType = MUSIC_AUDIO_OGG;
music.ctxData = ctxOgg;
stb_vorbis_info info = stb_vorbis_get_info((stb_vorbis *)music.ctxData); // Get Ogg file info stb_vorbis_info info = stb_vorbis_get_info((stb_vorbis *)music.ctxData); // Get Ogg file info
// OGG bit rate defaults to 16 bit, it's enough for compressed format // OGG bit rate defaults to 16 bit, it's enough for compressed format
@ -1368,6 +1373,10 @@ Music LoadMusicStream(const char *fileName)
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
} }
else
{
stb_vorbis_close(ctxOgg);
}
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MP3) #if defined(SUPPORT_FILEFORMAT_MP3)
@ -1376,27 +1385,30 @@ Music LoadMusicStream(const char *fileName)
drmp3 *ctxMp3 = RL_CALLOC(1, sizeof(drmp3)); drmp3 *ctxMp3 = RL_CALLOC(1, sizeof(drmp3));
int result = drmp3_init_file(ctxMp3, fileName, NULL); int result = drmp3_init_file(ctxMp3, fileName, NULL);
music.ctxType = MUSIC_AUDIO_MP3;
music.ctxData = ctxMp3;
if (result > 0) if (result > 0)
{ {
music.ctxType = MUSIC_AUDIO_MP3;
music.ctxData = ctxMp3;
music.stream = LoadAudioStream(ctxMp3->sampleRate, 32, ctxMp3->channels); music.stream = LoadAudioStream(ctxMp3->sampleRate, 32, ctxMp3->channels);
music.frameCount = (unsigned int)drmp3_get_pcm_frame_count(ctxMp3); music.frameCount = (unsigned int)drmp3_get_pcm_frame_count(ctxMp3);
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
} }
else
{
RL_FREE(ctxMp3);
}
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOA) #if defined(SUPPORT_FILEFORMAT_QOA)
else if (IsFileExtension(fileName, ".qoa")) else if (IsFileExtension(fileName, ".qoa"))
{ {
qoaplay_desc *ctxQoa = qoaplay_open(fileName); qoaplay_desc *ctxQoa = qoaplay_open(fileName);
if (ctxQoa != NULL)
{
music.ctxType = MUSIC_AUDIO_QOA; music.ctxType = MUSIC_AUDIO_QOA;
music.ctxData = ctxQoa; music.ctxData = ctxQoa;
if (ctxQoa->file != NULL)
{
// NOTE: We are loading samples are 32bit float normalized data, so, // NOTE: We are loading samples are 32bit float normalized data, so,
// we configure the output audio stream to also use float 32bit // we configure the output audio stream to also use float 32bit
music.stream = LoadAudioStream(ctxQoa->info.samplerate, 32, ctxQoa->info.channels); music.stream = LoadAudioStream(ctxQoa->info.samplerate, 32, ctxQoa->info.channels);
@ -1404,23 +1416,27 @@ Music LoadMusicStream(const char *fileName)
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
} }
else{} //No uninit required
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FLAC) #if defined(SUPPORT_FILEFORMAT_FLAC)
else if (IsFileExtension(fileName, ".flac")) else if (IsFileExtension(fileName, ".flac"))
{ {
music.ctxType = MUSIC_AUDIO_FLAC; drflac *ctxFlac = drflac_open_file(fileName, NULL);
music.ctxData = drflac_open_file(fileName, NULL);
if (music.ctxData != NULL) if (ctxFlac != NULL)
{ {
drflac *ctxFlac = (drflac *)music.ctxData; music.ctxType = MUSIC_AUDIO_FLAC;
music.ctxData = ctxFlac;
music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels); music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
music.frameCount = (unsigned int)ctxFlac->totalPCMFrameCount; music.frameCount = (unsigned int)ctxFlac->totalPCMFrameCount;
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
} }
else
{
drflac_free(ctxFlac, NULL);
}
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_XM) #if defined(SUPPORT_FILEFORMAT_XM)
@ -1429,11 +1445,10 @@ Music LoadMusicStream(const char *fileName)
jar_xm_context_t *ctxXm = NULL; jar_xm_context_t *ctxXm = NULL;
int result = jar_xm_create_context_from_file(&ctxXm, AUDIO.System.device.sampleRate, fileName); int result = jar_xm_create_context_from_file(&ctxXm, AUDIO.System.device.sampleRate, fileName);
music.ctxType = MUSIC_MODULE_XM;
music.ctxData = ctxXm;
if (result == 0) // XM AUDIO.System.context created successfully if (result == 0) // XM AUDIO.System.context created successfully
{ {
music.ctxType = MUSIC_MODULE_XM;
music.ctxData = ctxXm;
jar_xm_set_max_loop_count(ctxXm, 0); // Set infinite number of loops jar_xm_set_max_loop_count(ctxXm, 0); // Set infinite number of loops
unsigned int bits = 32; unsigned int bits = 32;
@ -1447,6 +1462,10 @@ Music LoadMusicStream(const char *fileName)
jar_xm_reset(ctxXm); // Make sure we start at the beginning of the song jar_xm_reset(ctxXm); // Make sure we start at the beginning of the song
musicLoaded = true; musicLoaded = true;
} }
else
{
jar_xm_free_context(ctxXm);
}
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MOD) #if defined(SUPPORT_FILEFORMAT_MOD)
@ -1456,48 +1475,27 @@ Music LoadMusicStream(const char *fileName)
jar_mod_init(ctxMod); jar_mod_init(ctxMod);
int result = jar_mod_load_file(ctxMod, fileName); int result = jar_mod_load_file(ctxMod, fileName);
music.ctxType = MUSIC_MODULE_MOD;
music.ctxData = ctxMod;
if (result > 0) if (result > 0)
{ {
music.ctxType = MUSIC_MODULE_MOD;
music.ctxData = ctxMod;
// NOTE: Only stereo is supported for MOD // NOTE: Only stereo is supported for MOD
music.stream = LoadAudioStream(AUDIO.System.device.sampleRate, 16, AUDIO_DEVICE_CHANNELS); music.stream = LoadAudioStream(AUDIO.System.device.sampleRate, 16, AUDIO_DEVICE_CHANNELS);
music.frameCount = (unsigned int)jar_mod_max_samples(ctxMod); // NOTE: Always 2 channels (stereo) music.frameCount = (unsigned int)jar_mod_max_samples(ctxMod); // NOTE: Always 2 channels (stereo)
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
} }
else
{
jar_mod_unload(ctxMod);
RL_FREE(ctxMod);
}
} }
#endif #endif
else TRACELOG(LOG_WARNING, "STREAM: [%s] File format not supported", fileName); else TRACELOG(LOG_WARNING, "STREAM: [%s] File format not supported", fileName);
if (!musicLoaded) if (!musicLoaded)
{ {
if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV)
else if (music.ctxType == MUSIC_AUDIO_WAV) drwav_uninit((drwav *)music.ctxData);
#endif
#if defined(SUPPORT_FILEFORMAT_OGG)
else if (music.ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close((stb_vorbis *)music.ctxData);
#endif
#if defined(SUPPORT_FILEFORMAT_MP3)
else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); }
#endif
#if defined(SUPPORT_FILEFORMAT_QOA)
else if (music.ctxType == MUSIC_AUDIO_QOA) qoaplay_close((qoaplay_desc *)music.ctxData);
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
else if (music.ctxType == MUSIC_AUDIO_FLAC) drflac_free((drflac *)music.ctxData, NULL);
#endif
#if defined(SUPPORT_FILEFORMAT_XM)
else if (music.ctxType == MUSIC_MODULE_XM) jar_xm_free_context((jar_xm_context_t *)music.ctxData);
#endif
#if defined(SUPPORT_FILEFORMAT_MOD)
else if (music.ctxType == MUSIC_MODULE_MOD) { jar_mod_unload((jar_mod_context_t *)music.ctxData); RL_FREE(music.ctxData); }
#endif
music.ctxData = NULL;
music.ctxType = MUSIC_AUDIO_NONE;
TRACELOG(LOG_WARNING, "FILEIO: [%s] Music file could not be opened", fileName); TRACELOG(LOG_WARNING, "FILEIO: [%s] Music file could not be opened", fileName);
} }
else else
@ -1528,11 +1526,10 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
bool success = drwav_init_memory(ctxWav, (const void *)data, dataSize, NULL); bool success = drwav_init_memory(ctxWav, (const void *)data, dataSize, NULL);
music.ctxType = MUSIC_AUDIO_WAV;
music.ctxData = ctxWav;
if (success) if (success)
{ {
music.ctxType = MUSIC_AUDIO_WAV;
music.ctxData = ctxWav;
int sampleSize = ctxWav->bitsPerSample; int sampleSize = ctxWav->bitsPerSample;
if (ctxWav->bitsPerSample == 24) sampleSize = 16; // Forcing conversion to s16 on UpdateMusicStream() if (ctxWav->bitsPerSample == 24) sampleSize = 16; // Forcing conversion to s16 on UpdateMusicStream()
@ -1541,18 +1538,22 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
} }
else {
drwav_uninit(ctxWav);
RL_FREE(ctxWav);
}
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_OGG) #if defined(SUPPORT_FILEFORMAT_OGG)
else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0)) else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0))
{ {
// Open ogg audio stream // Open ogg audio stream
music.ctxType = MUSIC_AUDIO_OGG; stb_vorbis* ctxOgg = stb_vorbis_open_memory((const unsigned char*)data, dataSize, NULL, NULL);
//music.ctxData = stb_vorbis_open_filename(fileName, NULL, NULL);
music.ctxData = stb_vorbis_open_memory((const unsigned char *)data, dataSize, NULL, NULL);
if (music.ctxData != NULL) if (ctxOgg != NULL)
{ {
music.ctxType = MUSIC_AUDIO_OGG;
music.ctxData = ctxOgg;
stb_vorbis_info info = stb_vorbis_get_info((stb_vorbis *)music.ctxData); // Get Ogg file info stb_vorbis_info info = stb_vorbis_get_info((stb_vorbis *)music.ctxData); // Get Ogg file info
// OGG bit rate defaults to 16 bit, it's enough for compressed format // OGG bit rate defaults to 16 bit, it's enough for compressed format
@ -1563,6 +1564,10 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
} }
else
{
stb_vorbis_close(ctxOgg);
}
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MP3) #if defined(SUPPORT_FILEFORMAT_MP3)
@ -1571,27 +1576,35 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
drmp3 *ctxMp3 = RL_CALLOC(1, sizeof(drmp3)); drmp3 *ctxMp3 = RL_CALLOC(1, sizeof(drmp3));
int success = drmp3_init_memory(ctxMp3, (const void*)data, dataSize, NULL); int success = drmp3_init_memory(ctxMp3, (const void*)data, dataSize, NULL);
music.ctxType = MUSIC_AUDIO_MP3;
music.ctxData = ctxMp3;
if (success) if (success)
{ {
music.ctxType = MUSIC_AUDIO_MP3;
music.ctxData = ctxMp3;
music.stream = LoadAudioStream(ctxMp3->sampleRate, 32, ctxMp3->channels); music.stream = LoadAudioStream(ctxMp3->sampleRate, 32, ctxMp3->channels);
music.frameCount = (unsigned int)drmp3_get_pcm_frame_count(ctxMp3); music.frameCount = (unsigned int)drmp3_get_pcm_frame_count(ctxMp3);
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
} }
else
{
drmp3_uninit(ctxMp3);
RL_FREE(ctxMp3);
}
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOA) #if defined(SUPPORT_FILEFORMAT_QOA)
else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0)) else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0))
{ {
qoaplay_desc *ctxQoa = qoaplay_open_memory(data, dataSize); qoaplay_desc *ctxQoa = NULL;
if ((data != NULL) && (dataSize > 0))
{
ctxQoa = qoaplay_open_memory(data, dataSize);
}
if (ctxQoa != NULL)
{
music.ctxType = MUSIC_AUDIO_QOA; music.ctxType = MUSIC_AUDIO_QOA;
music.ctxData = ctxQoa; music.ctxData = ctxQoa;
if ((ctxQoa->file_data != NULL) && (ctxQoa->file_data_size != 0))
{
// NOTE: We are loading samples are 32bit float normalized data, so, // NOTE: We are loading samples are 32bit float normalized data, so,
// we configure the output audio stream to also use float 32bit // we configure the output audio stream to also use float 32bit
music.stream = LoadAudioStream(ctxQoa->info.samplerate, 32, ctxQoa->info.channels); music.stream = LoadAudioStream(ctxQoa->info.samplerate, 32, ctxQoa->info.channels);
@ -1599,23 +1612,27 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
} }
else{} //No uninit required
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FLAC) #if defined(SUPPORT_FILEFORMAT_FLAC)
else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0)) else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0))
{ {
music.ctxType = MUSIC_AUDIO_FLAC; drflac *ctxFlac = drflac_open_memory((const void*)data, dataSize, NULL);
music.ctxData = drflac_open_memory((const void*)data, dataSize, NULL);
if (music.ctxData != NULL) if (ctxFlac != NULL)
{ {
drflac *ctxFlac = (drflac *)music.ctxData; music.ctxType = MUSIC_AUDIO_FLAC;
music.ctxData = ctxFlac;
music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels); music.stream = LoadAudioStream(ctxFlac->sampleRate, ctxFlac->bitsPerSample, ctxFlac->channels);
music.frameCount = (unsigned int)ctxFlac->totalPCMFrameCount; music.frameCount = (unsigned int)ctxFlac->totalPCMFrameCount;
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
} }
else
{
drflac_free(ctxFlac, NULL);
}
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_XM) #if defined(SUPPORT_FILEFORMAT_XM)
@ -1626,6 +1643,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
if (result == 0) // XM AUDIO.System.context created successfully if (result == 0) // XM AUDIO.System.context created successfully
{ {
music.ctxType = MUSIC_MODULE_XM; music.ctxType = MUSIC_MODULE_XM;
music.ctxData = ctxXm;
jar_xm_set_max_loop_count(ctxXm, 0); // Set infinite number of loops jar_xm_set_max_loop_count(ctxXm, 0); // Set infinite number of loops
unsigned int bits = 32; unsigned int bits = 32;
@ -1638,9 +1656,12 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
jar_xm_reset(ctxXm); // Make sure we start at the beginning of the song jar_xm_reset(ctxXm); // Make sure we start at the beginning of the song
music.ctxData = ctxXm;
musicLoaded = true; musicLoaded = true;
} }
else
{
jar_xm_free_context(ctxXm);
}
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MOD) #if defined(SUPPORT_FILEFORMAT_MOD)
@ -1667,15 +1688,18 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
if (result > 0) if (result > 0)
{ {
music.ctxType = MUSIC_MODULE_MOD; music.ctxType = MUSIC_MODULE_MOD;
music.ctxData = ctxMod;
// NOTE: Only stereo is supported for MOD // NOTE: Only stereo is supported for MOD
music.stream = LoadAudioStream(AUDIO.System.device.sampleRate, 16, 2); music.stream = LoadAudioStream(AUDIO.System.device.sampleRate, 16, 2);
music.frameCount = (unsigned int)jar_mod_max_samples(ctxMod); // NOTE: Always 2 channels (stereo) music.frameCount = (unsigned int)jar_mod_max_samples(ctxMod); // NOTE: Always 2 channels (stereo)
music.looping = true; // Looping enabled by default music.looping = true; // Looping enabled by default
musicLoaded = true; musicLoaded = true;
}
music.ctxData = ctxMod; else
musicLoaded = true; {
jar_mod_unload(ctxMod);
RL_FREE(ctxMod);
} }
} }
#endif #endif
@ -1683,31 +1707,6 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
if (!musicLoaded) if (!musicLoaded)
{ {
if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV)
else if (music.ctxType == MUSIC_AUDIO_WAV) drwav_uninit((drwav *)music.ctxData);
#endif
#if defined(SUPPORT_FILEFORMAT_OGG)
else if (music.ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close((stb_vorbis *)music.ctxData);
#endif
#if defined(SUPPORT_FILEFORMAT_MP3)
else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); }
#endif
#if defined(SUPPORT_FILEFORMAT_QOA)
else if (music.ctxType == MUSIC_AUDIO_QOA) qoaplay_close((qoaplay_desc *)music.ctxData);
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
else if (music.ctxType == MUSIC_AUDIO_FLAC) drflac_free((drflac *)music.ctxData, NULL);
#endif
#if defined(SUPPORT_FILEFORMAT_XM)
else if (music.ctxType == MUSIC_MODULE_XM) jar_xm_free_context((jar_xm_context_t *)music.ctxData);
#endif
#if defined(SUPPORT_FILEFORMAT_MOD)
else if (music.ctxType == MUSIC_MODULE_MOD) { jar_mod_unload((jar_mod_context_t *)music.ctxData); RL_FREE(music.ctxData); }
#endif
music.ctxData = NULL;
music.ctxType = MUSIC_AUDIO_NONE;
TRACELOG(LOG_WARNING, "FILEIO: Music data could not be loaded"); TRACELOG(LOG_WARNING, "FILEIO: Music data could not be loaded");
} }
else else

View File

@ -154,13 +154,15 @@
#endif #endif
// Platform specific defines to handle GetApplicationDirectory() // Platform specific defines to handle GetApplicationDirectory()
#if defined(_WIN32) #if (defined(_WIN32) && !defined(PLATFORM_DESKTOP_RGFW)) || (defined(_MSC_VER) && defined(PLATFORM_DESKTOP_RGFW))
#ifndef MAX_PATH #ifndef MAX_PATH
#define MAX_PATH 1025 #define MAX_PATH 1025
#endif #endif
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(void *hModule, void *lpFilename, unsigned long nSize); __declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(void *hModule, void *lpFilename, unsigned long nSize);
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameW(void *hModule, void *lpFilename, unsigned long nSize); __declspec(dllimport) unsigned long __stdcall GetModuleFileNameW(void *hModule, void *lpFilename, unsigned long nSize);
__declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, void *widestr, int cchwide, void *str, int cbmb, void *defchar, int *used_default); __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, void *widestr, int cchwide, void *str, int cbmb, void *defchar, int *used_default);
unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
#elif defined(__linux__) #elif defined(__linux__)
#include <unistd.h> #include <unistd.h>
#elif defined(__APPLE__) #elif defined(__APPLE__)
@ -482,7 +484,7 @@ static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *li
static void RecordAutomationEvent(void); // Record frame events (to internal events array) static void RecordAutomationEvent(void); // Record frame events (to internal events array)
#endif #endif
#if defined(_WIN32) #if defined(_WIN32) && !defined(PLATFORM_DESKTOP_RGFW)
// NOTE: We declare Sleep() function symbol to avoid including windows.h (kernel32.lib linkage required) // NOTE: We declare Sleep() function symbol to avoid including windows.h (kernel32.lib linkage required)
void __stdcall Sleep(unsigned long msTimeout); // Required for: WaitTime() void __stdcall Sleep(unsigned long msTimeout); // Required for: WaitTime()
#endif #endif
@ -496,6 +498,8 @@ const char *TextFormat(const char *text, ...); // Formatting of tex
#include "platforms/rcore_desktop.c" #include "platforms/rcore_desktop.c"
#elif defined(PLATFORM_DESKTOP_SDL) #elif defined(PLATFORM_DESKTOP_SDL)
#include "platforms/rcore_desktop_sdl.c" #include "platforms/rcore_desktop_sdl.c"
#elif defined(PLATFORM_DESKTOP_RGFW)
#include "platforms/rcore_desktop_rgfw.c"
#elif defined(PLATFORM_WEB) #elif defined(PLATFORM_WEB)
#include "platforms/rcore_web.c" #include "platforms/rcore_web.c"
#elif defined(PLATFORM_DRM) #elif defined(PLATFORM_DRM)

View File

@ -1296,7 +1296,7 @@ void rlMultMatrixf(const float *matf)
matf[2], matf[6], matf[10], matf[14], matf[2], matf[6], matf[10], matf[14],
matf[3], matf[7], matf[11], matf[15] }; matf[3], matf[7], matf[11], matf[15] };
*RLGL.State.currentMatrix = rlMatrixMultiply(*RLGL.State.currentMatrix, mat); *RLGL.State.currentMatrix = rlMatrixMultiply(mat, *RLGL.State.currentMatrix);
} }
// Multiply the current matrix by a perspective matrix generated by parameters // Multiply the current matrix by a perspective matrix generated by parameters