4 Commits

Author SHA1 Message Date
304e489edd ANDROID: Fix broken LoadMusicStream due to missing fopen redirect in raudio.c (#5589)
* ANDROID: Fix broken LoadMusicStream due to missing fopen macro override in raudio

* ANDROID: Add missing forward declaration before fopen macro override in raudio
2026-02-26 00:44:00 +01:00
b57526d71e update makefile and such (#5591) 2026-02-26 00:38:37 +01:00
006216bfcb [raylib.h] renamed SHADER_LOC_VERTEX_INSTANCETRANSFORMS (#5592)
* renamed SHADER_LOC_VERTEX_INSTANCETRANSFORMS to SHADER_LOC_VERTEX_INSTANCETRANSFORM

* rlparser: update raylib_api.* by CI

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-02-26 00:35:15 +01:00
Ray
ecaa1d3d18 REVIEWED: Attribute name and location, for consistency 2026-02-25 23:22:48 +01:00
14 changed files with 154 additions and 54 deletions

5
.gitignore vendored
View File

@ -132,3 +132,8 @@ tools/rexm/rexm
# CI # CI
emsdk-cache/ emsdk-cache/
raylib.com/ raylib.com/
# Wayland files
src/*protocol.h
src/*protocol-code.h
src/*protocol-code.c

View File

@ -95,6 +95,11 @@ USE_EXTERNAL_GLFW ?= FALSE
GLFW_LINUX_ENABLE_WAYLAND ?= FALSE GLFW_LINUX_ENABLE_WAYLAND ?= FALSE
GLFW_LINUX_ENABLE_X11 ?= TRUE GLFW_LINUX_ENABLE_X11 ?= TRUE
# Enable support for X11 by default on Linux when using GLFW
# NOTE: Wayland is disabled by default, only enable if you are sure
RGFW_LINUX_ENABLE_WAYLAND ?= FALSE
RGFW_LINUX_ENABLE_X11 ?= TRUE
# PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally # PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
# WARNING: Library is not included in raylib, it MUST be configured by users # WARNING: Library is not included in raylib, it MUST be configured by users
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
@ -475,7 +480,15 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
# Libraries for Debian GNU/Linux desktop compipling # Libraries for Debian GNU/Linux desktop compipling
# NOTE: Required packages: libegl1-mesa-dev # NOTE: Required packages: libegl1-mesa-dev
LDFLAGS += -L../src LDFLAGS += -L../src
LDLIBS = -lraylib -lGL -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -lpthread -ldl -lrt LDLIBS = -lraylib -lm
ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE)
LDLIBS += -lGL -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lpthread -ldl -lrt
endif
ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif
# Explicit link to libc # Explicit link to libc
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)

View File

@ -115,6 +115,11 @@ USE_EXTERNAL_GLFW ?= FALSE
GLFW_LINUX_ENABLE_WAYLAND ?= FALSE GLFW_LINUX_ENABLE_WAYLAND ?= FALSE
GLFW_LINUX_ENABLE_X11 ?= TRUE GLFW_LINUX_ENABLE_X11 ?= TRUE
# Enable support for X11 by default on Linux when using GLFW
# NOTE: Wayland is disabled by default, only enable if you are sure
RGFW_LINUX_ENABLE_WAYLAND ?= FALSE
RGFW_LINUX_ENABLE_X11 ?= TRUE
# PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally # PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
# WARNING: Library is not included in raylib, it MUST be configured by users # WARNING: Library is not included in raylib, it MUST be configured by users
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
@ -289,6 +294,17 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
CC = clang CC = clang
endif endif
endif endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(PLATFORM_OS),OSX)
# OSX default compiler
CC = clang
GLFW_OSX = -x objective-c
endif
ifeq ($(PLATFORM_OS),BSD)
# FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
CC = clang
endif
endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
ifeq ($(USE_RPI_CROSSCOMPILER),TRUE) ifeq ($(USE_RPI_CROSSCOMPILER),TRUE)
# Define RPI cross-compiler # Define RPI cross-compiler
@ -450,7 +466,6 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
endif endif
ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE) ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE)
CFLAGS += -D_GLFW_WAYLAND CFLAGS += -D_GLFW_WAYLAND
LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
WL_PROTOCOLS_DIR := external/glfw/deps/wayland WL_PROTOCOLS_DIR := external/glfw/deps/wayland
@ -472,6 +487,33 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
endif endif
endif endif
endif endif
# Use Wayland display on Linux desktop
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(PLATFORM_OS), LINUX)
ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE)
CFLAGS += -DRGFW_X11 -DRGFW_UNIX
endif
ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
CFLAGS += -DRGFW_WAYLAND -DEGLAPIENTRY=
WL_PROTOCOLS_DIR := external/RGFW/deps/wayland
wl_generate = \
$(eval protocol=$(1)) \
$(eval basename=$(2)) \
$(shell wayland-scanner client-header $(protocol) $(RAYLIB_SRC_PATH)/$(basename).h) \
$(shell wayland-scanner private-code $(protocol) $(RAYLIB_SRC_PATH)/$(basename)-code.c)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-constraints-unstable-v1.xml, pointer-constraints-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-warp-v1.xml, pointer-warp-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/relative-pointer-unstable-v1.xml, relative-pointer-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-decoration-unstable-v1.xml, xdg-decoration-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-output-unstable-v1.xml, xdg-output-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-shell.xml, xdg-shell-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-toplevel-icon-v1.xml, xdg-toplevel-icon-v1-client-protocol)
endif
endif
endif
CFLAGS += $(CUSTOM_CFLAGS) CFLAGS += $(CUSTOM_CFLAGS)
@ -583,6 +625,10 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE) ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE)
LDLIBS += -lX11 LDLIBS += -lX11
endif endif
ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE)
LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
endif
# TODO: On ARM 32bit arch, miniaudio requires atomics library # TODO: On ARM 32bit arch, miniaudio requires atomics library
#LDLIBS += -latomic #LDLIBS += -latomic
endif endif
@ -618,7 +664,15 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compipling # Libraries for Debian GNU/Linux desktop compipling
# NOTE: Required packages: libegl1-mesa-dev # NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lGL -lX11 -lXrandr -lXinerama -lXi -lXcursor -lm -lpthread -ldl -lrt LDLIBS = -lm
ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE)
LDLIBS += -lGL -lX11 -lXrandr -lXinerama -lXi -lXcursor -lpthread -ldl -lrt
endif
ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
endif
# Explicit link to libc # Explicit link to libc
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
@ -665,6 +719,21 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
OBJS += rglfw.o OBJS += rglfw.o
endif endif
endif endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
PROTOCOL_CODE_FILES = \
pointer-constraints-unstable-v1-client-protocol-code \
pointer-warp-v1-client-protocol-code \
relative-pointer-unstable-v1-client-protocol-code \
xdg-decoration-unstable-v1-client-protocol-code \
xdg-output-unstable-v1-client-protocol-code \
xdg-shell-client-protocol-code \
xdg-toplevel-icon-v1-client-protocol-code
PROTO_OBJS = $(addsuffix .o, $(PROTOCOL_CODE_FILES))
OBJS += $(PROTO_OBJS)
endif
endif
ifeq ($(RAYLIB_MODULE_MODELS),TRUE) ifeq ($(RAYLIB_MODULE_MODELS),TRUE)
OBJS += rmodels.o OBJS += rmodels.o
endif endif
@ -801,6 +870,17 @@ endif
android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
# Compile Wayland files
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
%-client-protocol-code.o: %-client-protocol-code.c
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)
%-client-protocol-code.h: external/RGFW/deps/wayland/%.xml
wayland-scanner private-code $< $@
endif
endif
# Install generated and needed files to desired directories. # Install generated and needed files to desired directories.
# On GNU/Linux and BSDs, there are some standard directories that contain extra # On GNU/Linux and BSDs, there are some standard directories that contain extra
# libraries and header files. These directories (often /usr/local/lib and # libraries and header files. These directories (often /usr/local/lib and
@ -885,7 +965,7 @@ clean: clean_shell_$(PLATFORM_SHELL)
@echo "removed all generated files!" @echo "removed all generated files!"
clean_shell_sh: clean_shell_sh:
rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* raygui.c $(RAYLIB_RELEASE_PATH)/*-protocol.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.h rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* raygui.c $(RAYLIB_RELEASE_PATH)/*-protocol.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.c
ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o
endif endif

View File

@ -8667,13 +8667,13 @@ struct wl_surface* RGFW_window_getWindow_Wayland(RGFW_window* win) { return win-
/* wayland global garbage (wayland bad, X11 is fine (ish) (not really)) */ /* wayland global garbage (wayland bad, X11 is fine (ish) (not really)) */
#include "xdg-shell.h" #include "xdg-shell-client-protocol.h"
#include "xdg-toplevel-icon-v1.h" #include "xdg-toplevel-icon-v1-client-protocol.h"
#include "xdg-decoration-unstable-v1.h" #include "xdg-decoration-unstable-v1-client-protocol.h"
#include "relative-pointer-unstable-v1.h" #include "relative-pointer-unstable-v1-client-protocol.h"
#include "pointer-constraints-unstable-v1.h" #include "pointer-constraints-unstable-v1-client-protocol.h"
#include "xdg-output-unstable-v1.h" #include "xdg-output-unstable-v1-client-protocol.h"
#include "pointer-warp-v1.h" #include "pointer-warp-v1-client-protocol.h"
void RGFW_toggleWaylandMaximized(RGFW_window* win, RGFW_bool maximized); void RGFW_toggleWaylandMaximized(RGFW_window* win, RGFW_bool maximized);

View File

@ -1691,6 +1691,7 @@ int InitPlatform(void)
// Close platform // Close platform
void ClosePlatform(void) void ClosePlatform(void)
{ {
mg_gamepads_free(&platform.minigamepad);
RGFW_window_close(platform.window); RGFW_window_close(platform.window);
} }

View File

@ -180,6 +180,11 @@ typedef struct tagBITMAPINFOHEADER {
#include <stdio.h> // Required for: FILE, fopen(), fclose(), fread() #include <stdio.h> // Required for: FILE, fopen(), fclose(), fread()
#include <string.h> // Required for: strcmp() [Used in IsFileExtension(), LoadWaveFromMemory(), LoadMusicStreamFromMemory()] #include <string.h> // Required for: strcmp() [Used in IsFileExtension(), LoadWaveFromMemory(), LoadMusicStreamFromMemory()]
#if defined(PLATFORM_ANDROID)
FILE *android_fopen(const char *fileName, const char *mode);
#define fopen(name, mode) android_fopen(name, mode)
#endif
#if defined(RAUDIO_STANDALONE) #if defined(RAUDIO_STANDALONE)
#ifndef TRACELOG #ifndef TRACELOG
#define TRACELOG(level, ...) printf(__VA_ARGS__) #define TRACELOG(level, ...) printf(__VA_ARGS__)

View File

@ -814,7 +814,7 @@ typedef enum {
SHADER_LOC_VERTEX_BONEIDS, // Shader location: vertex attribute: bone indices SHADER_LOC_VERTEX_BONEIDS, // Shader location: vertex attribute: bone indices
SHADER_LOC_VERTEX_BONEWEIGHTS, // Shader location: vertex attribute: bone weights SHADER_LOC_VERTEX_BONEWEIGHTS, // Shader location: vertex attribute: bone weights
SHADER_LOC_MATRIX_BONETRANSFORMS, // Shader location: matrix attribute: bone transforms (animation) SHADER_LOC_MATRIX_BONETRANSFORMS, // Shader location: matrix attribute: bone transforms (animation)
SHADER_LOC_VERTEX_INSTANCETRANSFORMS // Shader location: vertex attribute: instance transforms SHADER_LOC_VERTEX_INSTANCETRANSFORM // Shader location: vertex attribute: instance transforms
} ShaderLocationIndex; } ShaderLocationIndex;
#define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO #define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO

View File

@ -1305,7 +1305,7 @@ Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
shader.locs[SHADER_LOC_VERTEX_COLOR] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR); shader.locs[SHADER_LOC_VERTEX_COLOR] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR);
shader.locs[SHADER_LOC_VERTEX_BONEIDS] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEINDICES); shader.locs[SHADER_LOC_VERTEX_BONEIDS] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEINDICES);
shader.locs[SHADER_LOC_VERTEX_BONEWEIGHTS] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS); shader.locs[SHADER_LOC_VERTEX_BONEWEIGHTS] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS);
shader.locs[SHADER_LOC_VERTEX_INSTANCETRANSFORMS] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORMS); shader.locs[SHADER_LOC_VERTEX_INSTANCETRANSFORM] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORM);
// Get handles to GLSL uniform locations (vertex shader) // Get handles to GLSL uniform locations (vertex shader)
shader.locs[SHADER_LOC_MATRIX_MVP] = rlGetLocationUniform(shader.id, RL_DEFAULT_SHADER_UNIFORM_NAME_MVP); shader.locs[SHADER_LOC_MATRIX_MVP] = rlGetLocationUniform(shader.id, RL_DEFAULT_SHADER_UNIFORM_NAME_MVP);

View File

@ -345,16 +345,14 @@
#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6
#endif #endif
#ifdef SUPPORT_GPU_SKINNING #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES
#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES 7
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES 7
#endif
#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8
#endif
#endif #endif
#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORMS #ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORMS 9 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8
#endif
#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORM
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORM 9
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -1018,8 +1016,8 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
#ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_BONEMATRICES #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_BONEMATRICES
#define RL_DEFAULT_SHADER_UNIFORM_NAME_BONEMATRICES "boneMatrices" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEMATRICES #define RL_DEFAULT_SHADER_UNIFORM_NAME_BONEMATRICES "boneMatrices" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEMATRICES
#endif #endif
#ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORMS #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORM
#define RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORMS "instanceTransform" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORMS #define RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORM "instanceTransform" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORM
#endif #endif
#ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_MVP #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_MVP
@ -4335,20 +4333,18 @@ unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId)
glAttachShader(programId, vShaderId); glAttachShader(programId, vShaderId);
glAttachShader(programId, fShaderId); glAttachShader(programId, fShaderId);
// NOTE: Default attribute shader locations must be Bound before linking // Default attribute shader locations must be bound before linking
// NOTE: There is no problem with binding a generic attribute index to an attribute variable name
// that is never used; if some attrib name is no found on the shader, it locations becomes -1
glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION, RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION); glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION, RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION);
glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD); glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD);
glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL, RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL); glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL, RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL);
glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR, RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR); glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR, RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR);
glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT, RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT); glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT, RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT);
glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2); glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2);
glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORMS, RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORMS); glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORM, RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORM);
#ifdef SUPPORT_GPU_SKINNING
glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEINDICES); glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEINDICES);
glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS); glBindAttribLocation(programId, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS);
#endif
// NOTE: If some attrib name is no found on the shader, it locations becomes -1
glLinkProgram(programId); glLinkProgram(programId);

View File

@ -1688,7 +1688,7 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
{ {
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
// Instancing required variables // Instancing required variables
float16 *instanceTransforms = NULL; float16 *instanceTransform = NULL;
unsigned int instancesVboId = 0; unsigned int instancesVboId = 0;
// Bind shader program // Bind shader program
@ -1737,10 +1737,10 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
if (material.shader.locs[SHADER_LOC_MATRIX_PROJECTION] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_PROJECTION], matProjection); if (material.shader.locs[SHADER_LOC_MATRIX_PROJECTION] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_PROJECTION], matProjection);
// Create instances buffer // Create instances buffer
instanceTransforms = (float16 *)RL_CALLOC(instances, sizeof(float16)); instanceTransform = (float16 *)RL_CALLOC(instances, sizeof(float16));
// Fill buffer with instances transformations as float16 arrays // Fill buffer with instances transformations as float16 arrays
for (int i = 0; i < instances; i++) instanceTransforms[i] = MatrixToFloatV(transforms[i]); for (int i = 0; i < instances; i++) instanceTransform[i] = MatrixToFloatV(transforms[i]);
// Enable mesh VAO to attach new buffer // Enable mesh VAO to attach new buffer
rlEnableVertexArray(mesh.vaoId); rlEnableVertexArray(mesh.vaoId);
@ -1749,16 +1749,16 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
// It isn't clear which would be reliably faster in all cases and on all platforms, // It isn't clear which would be reliably faster in all cases and on all platforms,
// anecdotally glMapBuffer() seems very slow (syncs) while glBufferSubData() seems // anecdotally glMapBuffer() seems very slow (syncs) while glBufferSubData() seems
// no faster, since all the transform matrices are transferred anyway // no faster, since all the transform matrices are transferred anyway
instancesVboId = rlLoadVertexBuffer(instanceTransforms, instances*sizeof(float16), false); instancesVboId = rlLoadVertexBuffer(instanceTransform, instances*sizeof(float16), false);
// Instances transformation matrices are sent to shader attribute location: SHADER_LOC_VERTEX_INSTANCETRANSFORMS // Instances transformation matrices are sent to shader attribute location: SHADER_LOC_VERTEX_INSTANCETRANSFORM
if (material.shader.locs[SHADER_LOC_VERTEX_INSTANCETRANSFORMS] != -1) if (material.shader.locs[SHADER_LOC_VERTEX_INSTANCETRANSFORM] != -1)
{ {
for (unsigned int i = 0; i < 4; i++) for (unsigned int i = 0; i < 4; i++)
{ {
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_INSTANCETRANSFORMS] + i); rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_INSTANCETRANSFORM] + i);
rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_INSTANCETRANSFORMS] + i, 4, RL_FLOAT, 0, sizeof(Matrix), i*sizeof(Vector4)); rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_INSTANCETRANSFORM] + i, 4, RL_FLOAT, 0, sizeof(Matrix), i*sizeof(Vector4));
rlSetVertexAttributeDivisor(material.shader.locs[SHADER_LOC_VERTEX_INSTANCETRANSFORMS] + i, 1); rlSetVertexAttributeDivisor(material.shader.locs[SHADER_LOC_VERTEX_INSTANCETRANSFORM] + i, 1);
} }
} }
@ -1918,7 +1918,7 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
// Remove instance transforms buffer // Remove instance transforms buffer
rlUnloadVertexBuffer(instancesVboId); rlUnloadVertexBuffer(instancesVboId);
RL_FREE(instanceTransforms); RL_FREE(instanceTransform);
#endif #endif
} }
@ -4404,11 +4404,10 @@ static void BuildPoseFromParentJoints(BoneInfo *bones, int boneCount, Transform
#if defined(SUPPORT_FILEFORMAT_OBJ) #if defined(SUPPORT_FILEFORMAT_OBJ)
// Load OBJ mesh data // Load OBJ mesh data
// // Notes to keep in mind:
// Keep the following information in mind when reading this
// - A mesh is created for every material present in the obj file // - A mesh is created for every material present in the obj file
// - the model.meshCount is therefore the materialCount returned from tinyobj // - The model.meshCount is therefore the materialCount returned from tinyobj
// - the mesh is automatically triangulated by tinyobj // - The mesh is automatically triangulated by tinyobj
static Model LoadOBJ(const char *fileName) static Model LoadOBJ(const char *fileName)
{ {
tinyobj_attrib_t objAttributes = { 0 }; tinyobj_attrib_t objAttributes = { 0 };
@ -4555,7 +4554,8 @@ 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) model.meshes[i].texcoords = (float *)MemAlloc(sizeof(float)*vertexCount*2); if (objAttributes.texcoords != NULL && objAttributes.num_texcoords > 0)
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;
#endif #endif
@ -4657,12 +4657,12 @@ static Model LoadOBJ(const char *fileName)
// Load IQM mesh data // Load IQM mesh data
static Model LoadIQM(const char *fileName) static Model LoadIQM(const char *fileName)
{ {
#define IQM_MAGIC "INTERQUAKEMODEL" // IQM file magic number #define IQM_MAGIC "INTERQUAKEMODEL" // IQM file magic number
#define IQM_VERSION 2 // only IQM version 2 supported #define IQM_VERSION 2 // Only IQM version 2 supported
#define BONE_NAME_LENGTH 32 // BoneInfo name string length #define BONE_NAME_LENGTH 32 // BoneInfo name string length
#define MESH_NAME_LENGTH 32 // Mesh name string length #define MESH_NAME_LENGTH 32 // Mesh name string length
#define MATERIAL_NAME_LENGTH 32 // Material name string length #define MATERIAL_NAME_LENGTH 32 // Material name string length
int dataSize = 0; int dataSize = 0;
unsigned char *fileData = LoadFileData(fileName, &dataSize); unsigned char *fileData = LoadFileData(fileName, &dataSize);

View File

@ -2556,7 +2556,7 @@
"description": "Shader location: matrix attribute: bone transforms (animation)" "description": "Shader location: matrix attribute: bone transforms (animation)"
}, },
{ {
"name": "SHADER_LOC_VERTEX_INSTANCETRANSFORMS", "name": "SHADER_LOC_VERTEX_INSTANCETRANSFORM",
"value": 29, "value": 29,
"description": "Shader location: vertex attribute: instance transforms" "description": "Shader location: vertex attribute: instance transforms"
} }

View File

@ -2556,7 +2556,7 @@ return {
description = "Shader location: matrix attribute: bone transforms (animation)" description = "Shader location: matrix attribute: bone transforms (animation)"
}, },
{ {
name = "SHADER_LOC_VERTEX_INSTANCETRANSFORMS", name = "SHADER_LOC_VERTEX_INSTANCETRANSFORM",
value = 29, value = 29,
description = "Shader location: vertex attribute: instance transforms" description = "Shader location: vertex attribute: instance transforms"
} }

View File

@ -834,7 +834,7 @@ Enum 09: ShaderLocationIndex (30 values)
Value[SHADER_LOC_VERTEX_BONEIDS]: 26 Value[SHADER_LOC_VERTEX_BONEIDS]: 26
Value[SHADER_LOC_VERTEX_BONEWEIGHTS]: 27 Value[SHADER_LOC_VERTEX_BONEWEIGHTS]: 27
Value[SHADER_LOC_MATRIX_BONETRANSFORMS]: 28 Value[SHADER_LOC_MATRIX_BONETRANSFORMS]: 28
Value[SHADER_LOC_VERTEX_INSTANCETRANSFORMS]: 29 Value[SHADER_LOC_VERTEX_INSTANCETRANSFORM]: 29
Enum 10: ShaderUniformDataType (13 values) Enum 10: ShaderUniformDataType (13 values)
Name: ShaderUniformDataType Name: ShaderUniformDataType
Description: Shader uniform data type Description: Shader uniform data type

View File

@ -540,7 +540,7 @@
<Value name="SHADER_LOC_VERTEX_BONEIDS" integer="26" desc="Shader location: vertex attribute: bone indices" /> <Value name="SHADER_LOC_VERTEX_BONEIDS" integer="26" desc="Shader location: vertex attribute: bone indices" />
<Value name="SHADER_LOC_VERTEX_BONEWEIGHTS" integer="27" desc="Shader location: vertex attribute: bone weights" /> <Value name="SHADER_LOC_VERTEX_BONEWEIGHTS" integer="27" desc="Shader location: vertex attribute: bone weights" />
<Value name="SHADER_LOC_MATRIX_BONETRANSFORMS" integer="28" desc="Shader location: matrix attribute: bone transforms (animation)" /> <Value name="SHADER_LOC_MATRIX_BONETRANSFORMS" integer="28" desc="Shader location: matrix attribute: bone transforms (animation)" />
<Value name="SHADER_LOC_VERTEX_INSTANCETRANSFORMS" integer="29" desc="Shader location: vertex attribute: instance transforms" /> <Value name="SHADER_LOC_VERTEX_INSTANCETRANSFORM" integer="29" desc="Shader location: vertex attribute: instance transforms" />
</Enum> </Enum>
<Enum name="ShaderUniformDataType" valueCount="13" desc="Shader uniform data type"> <Enum name="ShaderUniformDataType" valueCount="13" desc="Shader uniform data type">
<Value name="SHADER_UNIFORM_FLOAT" integer="0" desc="Shader uniform type: float" /> <Value name="SHADER_UNIFORM_FLOAT" integer="0" desc="Shader uniform type: float" />