diff options
| author | Ray <raysan5@gmail.com> | 2017-10-18 00:12:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-18 00:12:27 +0200 |
| commit | 53280a56e3f4ab576fafeb75a68031fcdc4089fa (patch) | |
| tree | 919a4dc7f5623df04ab316c855e43eb32a051cc9 /src | |
| parent | 4a63e5dfb3006483cace85c8161d12057a9e8488 (diff) | |
| parent | 5b71e5b3d1cb87d7ed764d6be82bd6fcb9fa875f (diff) | |
| download | raylib-53280a56e3f4ab576fafeb75a68031fcdc4089fa.tar.gz raylib-53280a56e3f4ab576fafeb75a68031fcdc4089fa.zip | |
Merge pull request #367 from raysan5/develop
Integrate Develop branch
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 348 | ||||
| -rw-r--r-- | src/core.c | 17 | ||||
| -rw-r--r-- | src/external/android/native_app_glue/Android.mk | 10 | ||||
| -rw-r--r-- | src/external/android/native_app_glue/android_native_app_glue.c | 5 | ||||
| -rw-r--r-- | src/external/android/native_app_glue/android_native_app_glue.h | 9 | ||||
| -rw-r--r-- | src/external/glfw3/lib/linux/libglfw3.a | bin | 176482 -> 0 bytes | |||
| -rw-r--r-- | src/external/glfw3/lib/osx/libglfw.3.0.dylib | bin | 127856 -> 0 bytes | |||
| -rw-r--r-- | src/external/glfw3/lib/osx/libglfw.3.dylib | 1 | ||||
| -rw-r--r-- | src/external/glfw3/lib/osx/libglfw.dylib | 1 | ||||
| -rw-r--r-- | src/external/glfw3/lib/win32/glfw3.dll | bin | 305452 -> 0 bytes | |||
| -rw-r--r-- | src/external/glfw3/lib/win32/glfw3.lib | bin | 245676 -> 0 bytes | |||
| -rw-r--r-- | src/external/glfw3/lib/win32/libglfw3.a | bin | 148800 -> 0 bytes | |||
| -rw-r--r-- | src/external/glfw3/lib/win32/libglfw3dll.a | bin | 67426 -> 0 bytes | |||
| -rw-r--r-- | src/external/include/AL/al.h (renamed from src/external/openal_soft/include/AL/al.h) | 0 | ||||
| -rw-r--r-- | src/external/include/AL/alc.h (renamed from src/external/openal_soft/include/AL/alc.h) | 0 | ||||
| -rw-r--r-- | src/external/include/AL/alext.h (renamed from src/external/openal_soft/include/AL/alext.h) | 11 | ||||
| -rw-r--r-- | src/external/include/AL/efx-creative.h (renamed from src/external/openal_soft/include/AL/efx-creative.h) | 0 | ||||
| -rw-r--r-- | src/external/include/AL/efx-presets.h (renamed from src/external/openal_soft/include/AL/efx-presets.h) | 0 | ||||
| -rw-r--r-- | src/external/include/AL/efx.h (renamed from src/external/openal_soft/include/AL/efx.h) | 0 | ||||
| -rw-r--r-- | src/external/include/AL_COPYING (renamed from src/external/openal_soft/COPYING) | 0 | ||||
| -rw-r--r-- | src/external/include/GLFW/glfw3.h (renamed from src/external/glfw3/include/GLFW/glfw3.h) | 0 | ||||
| -rw-r--r-- | src/external/include/GLFW/glfw3native.h (renamed from src/external/glfw3/include/GLFW/glfw3native.h) | 0 | ||||
| -rw-r--r-- | src/external/include/GLFW_COPYING.txt (renamed from src/external/glfw3/COPYING.txt) | 0 | ||||
| -rw-r--r-- | src/external/openal_soft/lib/android/libopenal.so | bin | 2183284 -> 0 bytes | |||
| -rw-r--r-- | src/external/openal_soft/lib/win32/OpenAL32.dll | bin | 845045 -> 0 bytes | |||
| -rw-r--r-- | src/external/openal_soft/lib/win32/libOpenAL32.a | bin | 2226842 -> 0 bytes | |||
| -rw-r--r-- | src/external/openal_soft/lib/win32/libOpenAL32dll.a | bin | 100246 -> 0 bytes | |||
| -rw-r--r-- | src/external/rgif.h (renamed from src/external/gif.h) | 32 | ||||
| -rw-r--r-- | src/raylib.h | 63 | ||||
| -rw-r--r-- | src/rlgl.c | 180 | ||||
| -rw-r--r-- | src/rlgl.h | 26 | ||||
| -rw-r--r-- | src/shader_distortion.h | 4 | ||||
| -rw-r--r-- | src/shapes.c | 28 | ||||
| -rw-r--r-- | src/utils.c | 1 |
34 files changed, 388 insertions, 348 deletions
diff --git a/src/Makefile b/src/Makefile index 72f37b09..3a903cb6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -40,41 +40,33 @@ .PHONY: all clean install uninstall -# define raylib platform to compile for -# possible platforms: PLATFORM_DESKTOP PLATFORM_ANDROID PLATFORM_RPI PLATFORM_WEB +# Define required raylib variables PLATFORM ?= PLATFORM_DESKTOP +RAYLIB_PATH ?= .. -# define raylib default path, required to look for emsdk and android-toolchain -RAYLIB_PATH ?= C:/raylib +# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll) +# NOTE: OpenAL Soft library should be provided in the selected form +RAYLIB_LIBTYPE ?= STATIC +OPENAL_LIBTYPE ?= STATIC -# define YES if you want shared/dynamic version of library instead of static (default) -SHARED_RAYLIB ?= NO - -# use OpenAL Soft as shared library (.so / .dll) -# NOTE: If defined NO, static OpenAL Soft library should be provided -SHARED_OPENAL ?= NO - -# on PLATFORM_WEB force OpenAL Soft shared library +# On PLATFORM_WEB force OpenAL Soft shared library ifeq ($(PLATFORM),PLATFORM_WEB) - SHARED_OPENAL = YES -endif -ifeq ($(PLATFORM),PLATFORM_ANDROID) - SHARED_OPENAL = YES + OPENAL_LIBTYPE = SHARED endif -# determine if the file has root access (only for installing raylib) +# Determine if the file has root access (only for installing raylib) # "whoami" prints the name of the user that calls him (so, if it is the root # user, "whoami" prints "root"). ROOT = $(shell whoami) -# determine PLATFORM_OS in case PLATFORM_DESKTOP selected +# Determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) # No uname.exe on MinGW!, but OS=Windows_NT on Windows! # ifeq ($(UNAME),Msys) -> Windows ifeq ($(OS),Windows_NT) PLATFORM_OS=WINDOWS else - UNAMEOS:=$(shell uname) + UNAMEOS=$(shell uname) ifeq ($(UNAMEOS),Linux) PLATFORM_OS=LINUX else @@ -85,9 +77,14 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) endif endif +ifeq ($(PLATFORM),PLATFORM_RPI) + # RPI cross-compiler + RPI_CROSS_COMPILE ?= NO +endif + ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables - EMSDK_PATH = $(RAYLIB_PATH)/emsdk + EMSDK_PATH = C:/emsdk EMSCRIPTEN_VERSION = 1.37.9 CLANG_VERSION=e1.37.9_64bit PYTHON_VERSION=2.7.5.3_64bit @@ -96,6 +93,33 @@ ifeq ($(PLATFORM),PLATFORM_WEB) EMSCRIPTEN=$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION) endif +# Define output directory for compiled library +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + ifeq ($(PLATFORM_OS),WINDOWS) + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/win32/mingw32 + endif + ifeq ($(PLATFORM_OS),LINUX) + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/linux + endif + ifeq ($(PLATFORM_OS),OSX) + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/osx + endif +endif +ifeq ($(PLATFORM),PLATFORM_RPI) + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/rpi +endif +ifeq ($(PLATFORM),PLATFORM_WEB) + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/html5 +endif +ifeq ($(PLATFORM),PLATFORM_ANDROID) + ifeq ($(ANDROID_ARCH),ARM) + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/android/armeabi-v7a + endif + ifeq ($(ANDROID_ARCH),ARM64) + RAYLIB_RELEASE_PATH = $(RAYLIB_PATH)/release/libs/android/arm64-v8a + endif +endif + ifeq ($(PLATFORM),PLATFORM_ANDROID) # Android required path variables ANDROID_NDK = C:/android-ndk @@ -103,86 +127,66 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID) # Android architecture: ARM or ARM64 ANDROID_ARCH ?= ARM - - # Android compiler: gcc or clang - # NOTE: Define YES to use clang instead of gcc - ANDROID_LLVM ?= NO -endif - -ifeq ($(PLATFORM),PLATFORM_RPI) - # RPI cross-compiler - CROSS_COMPILE ?= NO endif -# define raylib graphics api depending on selected platform +# Define raylib graphics api depending on selected platform ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # by default use OpenGL 3.3 on desktop platforms + # 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 endif + ifeq ($(PLATFORM),PLATFORM_RPI) - # on RPI OpenGL ES 2.0 must be used + # On RPI OpenGL ES 2.0 must be used GRAPHICS = GRAPHICS_API_OPENGL_ES2 endif + ifeq ($(PLATFORM),PLATFORM_WEB) - # on HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0 + # On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0 GRAPHICS = GRAPHICS_API_OPENGL_ES2 endif + ifeq ($(PLATFORM),PLATFORM_ANDROID) - # by default use OpenGL ES 2.0 on Android + # By default use OpenGL ES 2.0 on Android GRAPHICS = GRAPHICS_API_OPENGL_ES2 endif -# NOTE: makefiles targets require tab indentation -# NOTE: define compiler: gcc for C program, define as g++ for C++ - -# default gcc compiler +# Default C compiler: gcc +# NOTE: define g++ compiler if using C++ CC = gcc - -# For OS X ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),OSX) - CC = clang - endif -endif - -# Android toolchain compiler -ifeq ($(PLATFORM),PLATFORM_ANDROID) - ifeq ($(ANDROID_ARCH),ARM) - ifeq ($(ANDROID_LLVM),YES) - CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-clang - else - CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-gcc - endif - endif - ifeq ($(ANDROID_ARCH),ARM64) - ifeq ($(ANDROID_LLVM),YES) - CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-clang - else - CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-gcc - endif + # OSX default compiler + CC = clang endif endif - -# RPI cross-compiler ifeq ($(PLATFORM),PLATFORM_RPI) - ifeq ($(CROSS_COMPILE),YES) - # rpi compiler + ifeq ($(RPI_CROSS_COMPILE),YES) + # RPI cross-compiler CC = armv6j-hardfloat-linux-gnueabi-gcc endif endif - -# HTML5 emscripten compiler ifeq ($(PLATFORM),PLATFORM_WEB) + # HTML5 emscripten compiler CC = emcc endif +ifeq ($(PLATFORM),PLATFORM_ANDROID) + # Android toolchain (must be provided for desired architecture and compiler) + # NOTE: gcc compiler is being deprecated in Android NDK r16 + ifeq ($(ANDROID_ARCH),ARM) + CC = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-gcc + endif + ifeq ($(ANDROID_ARCH),ARM64) + CC = $(ANDROID_TOOLCHAIN)/bin/aarch64-linux-android-gcc + endif +endif -# default archiver program to pack libraries +# Default archiver program to pack libraries AR = ar -# Android archiver +# Android archiver (also depends on desired architecture) ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(ANDROID_ARCH),ARM) AR = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-ar @@ -192,9 +196,10 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID) endif endif -# define compiler flags: +# Define compiler flags: # -O1 defines optimization level # -Og enable debugging +# -s strip unnecessary data from build # -Wall turns on most, but not all, compiler warnings # -std=c99 defines C language mode (standard C from 1999 revision) # -std=gnu99 defines C language mode (GNU C from 1999 revision) @@ -203,109 +208,83 @@ endif # -D_DEFAULT_SOURCE use with -std=c99 CFLAGS += -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces +# Additional flags for compiler (if desired) +#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling --preload-file resources # -O2 # if used, also set --memory-init-file 0 # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s USE_PTHREADS=1 # multithreading support + CFLAGS += -s USE_GLFW=3 -s ASSERTIONS=1 --profiling endif - ifeq ($(PLATFORM),PLATFORM_ANDROID) + # Compiler flags for arquitecture CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 + # Compilation functions attributes options + CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC + # Compiler options for the linker + CFLAGS += -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes + # Preprocessor macro definitions + CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=16 endif -#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes - -# if shared library required, make sure code is compiled as position independent -ifeq ($(SHARED_RAYLIB),YES) - CFLAGS += -fPIC - SHAREDFLAG = BUILDING_DLL -else - SHAREDFLAG = BUILDING_STATIC +# Define required compilation flags for raylib SHARED lib +ifeq ($(RAYLIB_LIBTYPE),SHARED) + # make sure code is compiled as position independent + # BE CAREFUL: It seems that for gcc -fpic si not the same as -fPIC + # MinGW32 just doesn't need -fPIC, it shows warnings + CFLAGS += -fPIC -DBUILD_LIBTYPE_SHARED endif -# if static OpenAL Soft required, define the corresponding flags -ifeq ($(SHARED_OPENAL),NO) - SHAREDLIBS += -lopenal32 -lwinmm - SHAREDOPENALFLAG = AL_LIBTYPE_STATIC -else - SHAREDLIBS += -lopenal32dll - SHAREDOPENALFLAG = SHARED_OPENAL +# Define required compilation flags for OpenAL Soft STATIC lib +ifeq ($(OPENAL_LIBTYPE),STATIC) + ALFLAGS = -DAL_LIBTYPE_STATIC -Wl,-allow-multiple-definition endif -#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes - -# external required libraries (stb and others) -INCLUDES = -I. -Iexternal - -# OpenAL Soft library -INCLUDES += -Iexternal/openal_soft/include +# Define include paths for required headers +# NOTE: Several external required libraries (stb and others) +INCLUDE_PATHS = -I. -Iexternal -Iexternal/include -# define any directories containing required header files -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - # GLFW3 library - INCLUDES += -Iexternal/glfw3/include -endif +# Define additional directories containing required header files ifeq ($(PLATFORM),PLATFORM_RPI) # RPI requried libraries - INCLUDES += -I/opt/vc/include - INCLUDES += -I/opt/vc/include/interface/vmcs_host/linux - INCLUDES += -I/opt/vc/include/interface/vcos/pthreads -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - # GLFW3 library - INCLUDES += -Iexternal/glfw3/include + INCLUDE_PATHS += -I/opt/vc/include + INCLUDE_PATHS += -I/opt/vc/include/interface/vmcs_host/linux + INCLUDE_PATHS += -I/opt/vc/include/interface/vcos/pthreads endif ifeq ($(PLATFORM),PLATFORM_ANDROID) # Android required libraries - INCLUDES += -I$(ANDROID_TOOLCHAIN)/sysroot/usr/include + INCLUDE_PATHS += -I$(ANDROID_TOOLCHAIN)/sysroot/usr/include # Include android_native_app_glue.h - INCLUDES += -Iexternal/android/native_app_glue - #INCLUDES += -I$(ANDROID_NDK)/sources/android/native_app_glue + INCLUDE_PATHS += -Iexternal/android/native_app_glue + #INCLUDE_PATHS += -I$(ANDROID_NDK)/sources/android/native_app_glue endif -# define output directory for compiled library -ifeq ($(PLATFORM),PLATFORM_DESKTOP) - ifeq ($(PLATFORM_OS),WINDOWS) - OUTPUT_PATH = ../release/win32/mingw32 - endif - ifeq ($(PLATFORM_OS),LINUX) - OUTPUT_PATH = ../release/linux - endif - ifeq ($(PLATFORM_OS),OSX) - OUTPUT_PATH = ../release/osx - endif -endif -ifeq ($(PLATFORM),PLATFORM_RPI) - OUTPUT_PATH = ../release/rpi -endif -ifeq ($(PLATFORM),PLATFORM_WEB) - OUTPUT_PATH = ../release/html5 -endif +# Define linker options ifeq ($(PLATFORM),PLATFORM_ANDROID) - ifeq ($(ANDROID_ARCH),ARM) - OUTPUT_PATH = ../release/android/armeabi-v7a - endif - ifeq ($(ANDROID_ARCH),ARM64) - OUTPUT_PATH = ../release/android/arm64-v8a - endif + LDFLAGS = -Wl,-soname,libraylib.so -Wl,--exclude-libs,libatomic.a + LDFLAGS += -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings + # Force linking of library module to define symbol + LDFLAGS += -u ANativeActivity_onCreate + # Library paths containing required libs + LDFLAGS += -L. -Lsrc -L$(RAYLIB_RELEASE_PATH) + + LDLIBS = -lopenal -llog -landroid -lEGL -lGLESv2 -lOpenSLES -latomic -lc -lm endif -# define all object files required with a wildcard -# The wildcard takes all files that finish with ".c", then it replaces the -# extentions with ".o", that are the object files. +# Define all object files required with a wildcard +# The wildcard takes all files that finish with ".c", +# and replaces extentions with ".o", that are the object files OBJS = $(patsubst %.c, %.o, $(wildcard *.c)) -OBJS += external/stb_vorbis.o +OBJS += stb_vorbis.o -# typing 'make' will invoke the default target entry called 'all', -# in this case, the 'default' target entry is raylib +# Default target entry all: raylib -# generate standalone Android toolchain +# Generate standalone Android toolchain # NOTE: Android toolchain could already be provided -toolchain: +generate_android_toolchain: ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(ANDROID_ARCH),ARM) $(ANDROID_NDK)/build/tools/make-standalone-toolchain.sh --platform=android-9 --toolchain=arm-linux-androideabi-4.9 --use-llvm --install-dir=$(ANDROID_TOOLCHAIN) @@ -315,39 +294,39 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID) endif endif -# compile raylib library +# Compile raylib library raylib: $(OBJS) ifeq ($(PLATFORM),PLATFORM_WEB) - # compile raylib for web. - emcc -O1 $(OBJS) -o $(OUTPUT_PATH)/libraylib.bc - @echo "libraylib.bc generated (web version)!" + # Compile raylib for web. + emcc -O1 $(OBJS) -o $(RAYLIB_RELEASE_PATH)/libraylib.bc + @echo "raylib library generated (libraylib.bc)!" else - ifeq ($(SHARED_RAYLIB),YES) + ifeq ($(RAYLIB_LIBTYPE),SHARED) # NOTE: If using OpenAL Soft as static library, all its dependencies must be also linked in the shared library ifeq ($(PLATFORM_OS),WINDOWS) - $(CC) -shared -o $(OUTPUT_PATH)/raylib.dll $(OBJS) $(SHAREDLIBS) -Lexternal/glfw3/lib/win32 -Lexternal/openal_soft/lib/win32 -lglfw3 -lgdi32 -Wl,--out-implib,$(OUTPUT_PATH)/libraylibdll.a + $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/raylib.dll $(OBJS) $(ALLIBS) -Lexternal/glfw3/lib/win32 -Lexternal/openal_soft/lib/win32 -lglfw3 -lgdi32 -Wl,--out-implib,$(RAYLIB_RELEASE_PATH)/libraylibdll.a @echo "raylib dynamic library (raylib.dll) and import library (libraylibdll.a) generated!" endif ifeq ($(PLATFORM_OS),LINUX) - # compile raylib to shared library version for GNU/Linux. + # Compile raylib to shared library version for GNU/Linux. # WARNING: you should type "make clean" before doing this target - $(CC) -shared -o $(OUTPUT_PATH)/libraylib.so $(OBJS) -lglfw -lGL -lopenal -lm -lpthread -ldl + $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/libraylib.so $(OBJS) -lglfw -lGL -lopenal -lm -lpthread -ldl @echo "raylib shared library generated (libraylib.so)!" endif ifeq ($(PLATFORM_OS),OSX) - $(CC) -dynamiclib -o $(OUTPUT_PATH)/libraylib.dylib $(OBJS) -L/usr/local/Cellar/glfw/3.2.1/lib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa - install_name_tool -id "libraylib.dylib" $(OUTPUT_PATH)/libraylib.dylib + $(CC) -dynamiclib -o $(RAYLIB_RELEASE_PATH)/libraylib.dylib $(OBJS) -L/usr/local/Cellar/glfw/3.2.1/lib -lglfw -framework OpenGL -framework OpenAL -framework Cocoa + install_name_tool -id "libraylib.dylib" $(RAYLIB_RELEASE_PATH)/libraylib.dylib @echo "raylib shared library generated (libraylib.dylib)!" endif ifeq ($(PLATFORM),PLATFORM_ANDROID) - $(CC) -shared -o $(OUTPUT_PATH)/libraylib.so $(OBJS) + $(CC) -shared -o $(RAYLIB_RELEASE_PATH)/libraylib.so $(OBJS) $(LDFLAGS) $(LDLIBS) @echo "raylib shared library generated (libraylib.so)!" endif else - # compile raylib static library. - $(AR) rcs $(OUTPUT_PATH)/libraylib.a $(OBJS) + # Compile raylib static library. + $(AR) rcs $(RAYLIB_RELEASE_PATH)/libraylib.a $(OBJS) @echo "raylib static library generated (libraylib.a)!" - ifeq ($(SHARED_OPENAL),NO) + ifeq ($(OPENAL_LIBTYPE),STATIC) @echo "expected OpenAL Soft static library linking" else @echo "expected OpenAL Soft shared library linking" @@ -355,46 +334,45 @@ else endif endif -# compile all modules with their prerequisites +# Compile all modules with their prerequisites -# compile core module +# Compile core module core.o : core.c raylib.h rlgl.h utils.h raymath.h gestures.h - $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(SHAREDFLAG) + $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS) -# compile rlgl module +# Compile rlgl module rlgl.o : rlgl.c rlgl.h raymath.h - $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(GRAPHICS) + $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS) -# compile shapes module +# Compile shapes module shapes.o : shapes.c raylib.h rlgl.h - $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(SHAREDFLAG) + $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS) -# compile textures module +# Compile textures module textures.o : textures.c rlgl.h utils.h - $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(GRAPHICS) -D$(SHAREDFLAG) + $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS) -# compile text module +# Compile text module text.o : text.c raylib.h utils.h - $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(SHAREDFLAG) + $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS) -# compile models module +# Compile models module models.o : models.c raylib.h rlgl.h raymath.h - $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(SHAREDFLAG) + $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -D$(GRAPHICS) -# compile audio module +# Compile audio module audio.o : audio.c raylib.h - $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(SHAREDFLAG) -D$(SHAREDOPENALFLAG) + $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) $(ALFLAGS) -# compile stb_vorbis library -external/stb_vorbis.o: external/stb_vorbis.c external/stb_vorbis.h - $(CC) -c -o $@ $< -O1 $(CFLAGS) $(INCLUDES) -D$(PLATFORM) +# Compile stb_vorbis library +stb_vorbis.o: external/stb_vorbis.c external/stb_vorbis.h + $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -# compile utils module +# Compile utils module utils.o : utils.c utils.h - $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) -D$(SHAREDFLAG) + $(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM) -# It installs generated and needed files to compile projects using raylib. -# The installation works manually. +# Install generated and needed files to required directories # TODO: add other platforms. install : ifeq ($(ROOT),root) @@ -403,11 +381,11 @@ ifeq ($(ROOT),root) # libraries and header files. These directory (/usr/local/lib and # /usr/local/include/) are for libraries that are installed # manually (without a package manager). - ifeq ($(SHARED_RAYLIB),YES) - cp --update $(OUTPUT_PATH)/libraylib.so /usr/local/lib/libraylib.so + ifeq ($(RAYLIB_LIBTYPE),SHARED) + cp --update $(RAYLIB_RELEASE_PATH)/libraylib.so /usr/local/lib/libraylib.so else cp --update raylib.h /usr/local/include/raylib.h - cp --update $(OUTPUT_PATH)/libraylib.a /usr/local/lib/libraylib.a + cp --update $(RAYLIB_RELEASE_PATH)/libraylib.a /usr/local/lib/libraylib.a endif @echo "raylib dev files installed/updated!" else @@ -417,31 +395,31 @@ else @echo "Error: no root permissions" endif -# it removes raylib dev files installed on the system. +# Remove raylib dev files installed on the system # TODO: see 'install' target. uninstall : ifeq ($(ROOT),root) ifeq ($(PLATFORM_OS),LINUX) rm --force /usr/local/include/raylib.h - ifeq ($(SHARED_RAYLIB),YES) + ifeq ($(RAYLIB_LIBTYPE),SHARED) rm --force /usr/local/lib/libraylib.so else rm --force /usr/local/lib/libraylib.a endif - @echo "raylib dev files removed!" + @echo "raylib development files removed!" else - @echo "This function works only on GNU/Linux systems" + @echo "This function works only on GNU/Linux systems" endif else @echo "Error: no root permissions" endif -# clean everything +# Clean everything clean: ifeq ($(PLATFORM_OS),WINDOWS) - del *.o $(OUTPUT_PATH)/libraylib.a $(OUTPUT_PATH)/libraylib.bc $(OUTPUT_PATH)/libraylib.so external/stb_vorbis.o + del *.o $(RAYLIB_RELEASE_PATH)/libraylib.a $(RAYLIB_RELEASE_PATH)/libraylib.bc $(RAYLIB_RELEASE_PATH)/libraylib.so external/stb_vorbis.o else - rm -f *.o $(OUTPUT_PATH)/libraylib.a $(OUTPUT_PATH)/libraylib.bc $(OUTPUT_PATH)/libraylib.so external/stb_vorbis.o + rm -f *.o $(RAYLIB_RELEASE_PATH)/libraylib.a $(RAYLIB_RELEASE_PATH)/libraylib.bc $(RAYLIB_RELEASE_PATH)/libraylib.so external/stb_vorbis.o endif ifeq ($(PLATFORM),PLATFORM_ANDROID) rm -rf $(ANDROID_TOOLCHAIN) @@ -105,8 +105,8 @@ #endif #if defined(SUPPORT_GIF_RECORDING) - #define GIF_IMPLEMENTATION - #include "external/gif.h" // Support GIF recording + #define RGIF_IMPLEMENTATION + #include "external/rgif.h" // Support GIF recording #endif #if defined(__linux__) || defined(PLATFORM_WEB) @@ -314,9 +314,7 @@ static Vector2 mousePosition; // Mouse position on screen static bool toggleCursorLock = false; // Ask for cursor pointer lock on next click #endif -#if defined(SUPPORT_GESTURES_SYSTEM) static Vector2 touchPosition[MAX_TOUCH_POINTS]; // Touch position on screen -#endif #if defined(PLATFORM_DESKTOP) static char **dropFilesPath; // Store dropped files paths as strings @@ -477,8 +475,6 @@ void InitWindow(int width, int height, void *state) { TraceLog(LOG_INFO, "Initializing raylib (v1.8.0)"); - app_dummy(); - screenWidth = width; screenHeight = height; @@ -1495,6 +1491,7 @@ bool IsMouseButtonPressed(int button) { bool pressed = false; +// TODO: Review, gestures could be not supported despite being on Android platform! #if defined(PLATFORM_ANDROID) if (IsGestureDetected(GESTURE_TAP)) pressed = true; #else @@ -2748,6 +2745,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) int32_t action = AMotionEvent_getAction(event); unsigned int flags = action & AMOTION_EVENT_ACTION_MASK; +#if defined(SUPPORT_GESTURES_SYSTEM) GestureEvent gestureEvent; // Register touch actions @@ -2776,8 +2774,13 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) // Gesture data is sent to gestures system for processing ProcessGestureEvent(gestureEvent); +#else + + // TODO: Support only simple touch position + +#endif - return 0; // return 1; + return 0; } #endif diff --git a/src/external/android/native_app_glue/Android.mk b/src/external/android/native_app_glue/Android.mk deleted file mode 100644 index 00252fcb..00000000 --- a/src/external/android/native_app_glue/Android.mk +++ /dev/null @@ -1,10 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE:= android_native_app_glue -LOCAL_SRC_FILES:= android_native_app_glue.c -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_LDLIBS := -llog - -include $(BUILD_STATIC_LIBRARY) diff --git a/src/external/android/native_app_glue/android_native_app_glue.c b/src/external/android/native_app_glue/android_native_app_glue.c index d503d8da..7eada086 100644 --- a/src/external/android/native_app_glue/android_native_app_glue.c +++ b/src/external/android/native_app_glue/android_native_app_glue.c @@ -420,8 +420,9 @@ static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue) android_app_set_input((struct android_app*)activity->instance, NULL); } -void ANativeActivity_onCreate(ANativeActivity* activity, - void* savedState, size_t savedStateSize) { +JNIEXPORT +void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, + size_t savedStateSize) { LOGV("Creating: %p\n", activity); activity->callbacks->onDestroy = onDestroy; activity->callbacks->onStart = onStart; diff --git a/src/external/android/native_app_glue/android_native_app_glue.h b/src/external/android/native_app_glue/android_native_app_glue.h index 97202e09..c99d6e12 100644 --- a/src/external/android/native_app_glue/android_native_app_glue.h +++ b/src/external/android/native_app_glue/android_native_app_glue.h @@ -332,9 +332,14 @@ void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd); void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd); /** - * Dummy function you can call to ensure glue code isn't stripped. + * Dummy function that used to be used to prevent the linker from stripping app + * glue code. No longer necessary, since __attribute__((visibility("default"))) + * does this for us. */ -void app_dummy(); +__attribute__(( + deprecated("Calls to app_dummy are no longer necessary. See " + "https://github.com/android-ndk/ndk/issues/381."))) void +app_dummy(); /** * This is the function that application code must implement, representing diff --git a/src/external/glfw3/lib/linux/libglfw3.a b/src/external/glfw3/lib/linux/libglfw3.a Binary files differdeleted file mode 100644 index 84cc1d20..00000000 --- a/src/external/glfw3/lib/linux/libglfw3.a +++ /dev/null diff --git a/src/external/glfw3/lib/osx/libglfw.3.0.dylib b/src/external/glfw3/lib/osx/libglfw.3.0.dylib Binary files differdeleted file mode 100644 index 15674573..00000000 --- a/src/external/glfw3/lib/osx/libglfw.3.0.dylib +++ /dev/null diff --git a/src/external/glfw3/lib/osx/libglfw.3.dylib b/src/external/glfw3/lib/osx/libglfw.3.dylib deleted file mode 100644 index cd20112e..00000000 --- a/src/external/glfw3/lib/osx/libglfw.3.dylib +++ /dev/null @@ -1 +0,0 @@ -libglfw.3.0.dylib
\ No newline at end of file diff --git a/src/external/glfw3/lib/osx/libglfw.dylib b/src/external/glfw3/lib/osx/libglfw.dylib deleted file mode 100644 index d4bd51e1..00000000 --- a/src/external/glfw3/lib/osx/libglfw.dylib +++ /dev/null @@ -1 +0,0 @@ -libglfw.3.dylib
\ No newline at end of file diff --git a/src/external/glfw3/lib/win32/glfw3.dll b/src/external/glfw3/lib/win32/glfw3.dll Binary files differdeleted file mode 100644 index 9f5d40f6..00000000 --- a/src/external/glfw3/lib/win32/glfw3.dll +++ /dev/null diff --git a/src/external/glfw3/lib/win32/glfw3.lib b/src/external/glfw3/lib/win32/glfw3.lib Binary files differdeleted file mode 100644 index 741756ab..00000000 --- a/src/external/glfw3/lib/win32/glfw3.lib +++ /dev/null diff --git a/src/external/glfw3/lib/win32/libglfw3.a b/src/external/glfw3/lib/win32/libglfw3.a Binary files differdeleted file mode 100644 index d50ffa72..00000000 --- a/src/external/glfw3/lib/win32/libglfw3.a +++ /dev/null diff --git a/src/external/glfw3/lib/win32/libglfw3dll.a b/src/external/glfw3/lib/win32/libglfw3dll.a Binary files differdeleted file mode 100644 index a42a400b..00000000 --- a/src/external/glfw3/lib/win32/libglfw3dll.a +++ /dev/null diff --git a/src/external/openal_soft/include/AL/al.h b/src/external/include/AL/al.h index 413b3833..413b3833 100644 --- a/src/external/openal_soft/include/AL/al.h +++ b/src/external/include/AL/al.h diff --git a/src/external/openal_soft/include/AL/alc.h b/src/external/include/AL/alc.h index 294e8b33..294e8b33 100644 --- a/src/external/openal_soft/include/AL/alc.h +++ b/src/external/include/AL/alc.h diff --git a/src/external/openal_soft/include/AL/alext.h b/src/external/include/AL/alext.h index 50ad10ec..4b9a1553 100644 --- a/src/external/openal_soft/include/AL/alext.h +++ b/src/external/include/AL/alext.h @@ -448,6 +448,17 @@ AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index); #endif #endif +#ifndef AL_SOFT_source_spatialize +#define AL_SOFT_source_spatialize +#define AL_SOURCE_SPATIALIZE_SOFT 0x1214 +#define AL_AUTO_SOFT 0x0002 +#endif + +#ifndef ALC_SOFT_output_limiter +#define ALC_SOFT_output_limiter +#define ALC_OUTPUT_LIMITER_SOFT 0x199A +#endif + #ifdef __cplusplus } #endif diff --git a/src/external/openal_soft/include/AL/efx-creative.h b/src/external/include/AL/efx-creative.h index 0a04c982..0a04c982 100644 --- a/src/external/openal_soft/include/AL/efx-creative.h +++ b/src/external/include/AL/efx-creative.h diff --git a/src/external/openal_soft/include/AL/efx-presets.h b/src/external/include/AL/efx-presets.h index 8539fd51..8539fd51 100644 --- a/src/external/openal_soft/include/AL/efx-presets.h +++ b/src/external/include/AL/efx-presets.h diff --git a/src/external/openal_soft/include/AL/efx.h b/src/external/include/AL/efx.h index 57766983..57766983 100644 --- a/src/external/openal_soft/include/AL/efx.h +++ b/src/external/include/AL/efx.h diff --git a/src/external/openal_soft/COPYING b/src/external/include/AL_COPYING index d0c89786..d0c89786 100644 --- a/src/external/openal_soft/COPYING +++ b/src/external/include/AL_COPYING diff --git a/src/external/glfw3/include/GLFW/glfw3.h b/src/external/include/GLFW/glfw3.h index 5a0c4508..5a0c4508 100644 --- a/src/external/glfw3/include/GLFW/glfw3.h +++ b/src/external/include/GLFW/glfw3.h diff --git a/src/external/glfw3/include/GLFW/glfw3native.h b/src/external/include/GLFW/glfw3native.h index 30e1a570..30e1a570 100644 --- a/src/external/glfw3/include/GLFW/glfw3native.h +++ b/src/external/include/GLFW/glfw3native.h diff --git a/src/external/glfw3/COPYING.txt b/src/external/include/GLFW_COPYING.txt index ad16462a..ad16462a 100644 --- a/src/external/glfw3/COPYING.txt +++ b/src/external/include/GLFW_COPYING.txt diff --git a/src/external/openal_soft/lib/android/libopenal.so b/src/external/openal_soft/lib/android/libopenal.so Binary files differdeleted file mode 100644 index e384d9ad..00000000 --- a/src/external/openal_soft/lib/android/libopenal.so +++ /dev/null diff --git a/src/external/openal_soft/lib/win32/OpenAL32.dll b/src/external/openal_soft/lib/win32/OpenAL32.dll Binary files differdeleted file mode 100644 index 1e3bddd5..00000000 --- a/src/external/openal_soft/lib/win32/OpenAL32.dll +++ /dev/null diff --git a/src/external/openal_soft/lib/win32/libOpenAL32.a b/src/external/openal_soft/lib/win32/libOpenAL32.a Binary files differdeleted file mode 100644 index 3c0df3c7..00000000 --- a/src/external/openal_soft/lib/win32/libOpenAL32.a +++ /dev/null diff --git a/src/external/openal_soft/lib/win32/libOpenAL32dll.a b/src/external/openal_soft/lib/win32/libOpenAL32dll.a Binary files differdeleted file mode 100644 index 1c4c63c8..00000000 --- a/src/external/openal_soft/lib/win32/libOpenAL32dll.a +++ /dev/null diff --git a/src/external/gif.h b/src/external/rgif.h index c38cddb7..f26f67d1 100644 --- a/src/external/gif.h +++ b/src/external/rgif.h @@ -1,7 +1,7 @@ /********************************************************************************************** * -* gif.h by Charlie Tangora [ctangora -at- gmail -dot- com] -* adapted to C99 and reformatted by Ramon Santamaria (@raysan5) +* rgif.h original implementation by Charlie Tangora [ctangora -at- gmail -dot- com] +* adapted to C99, reformatted and renamed by Ramon Santamaria (@raysan5) * * This file offers a simple, very limited way to create animated GIFs directly in code. * @@ -17,7 +17,7 @@ * * CONFIGURATION: * -* #define GIF_IMPLEMENTATION +* #define RGIF_IMPLEMENTATION * Generates the implementation of the library into the included file. * If not defined, the library is in header only mode and can be included in other headers * or source files without problems. But only ONE file should hold the implementation. @@ -56,14 +56,14 @@ #include <stdio.h> // Required for: FILE -//#define GIF_STATIC -#ifdef GIF_STATIC - #define GIFDEF static // Functions just visible to module including this file +//#define RGIF_STATIC +#ifdef RGIF_STATIC + #define RGIFDEF static // Functions just visible to module including this file #else #ifdef __cplusplus - #define GIFDEF extern "C" // Functions visible from other files (no name mangling of functions in C++) + #define RGIFDEF extern "C" // Functions visible from other files (no name mangling of functions in C++) #else - #define GIFDEF extern // Functions visible from other files + #define RGIFDEF extern // Functions visible from other files #endif #endif @@ -72,9 +72,9 @@ //---------------------------------------------------------------------------------- // NOTE: By default use bitDepth = 8, dither = false -GIFDEF bool GifBegin(const char *filename, unsigned int width, unsigned int height, unsigned int delay, unsigned int bitDepth, bool dither); -GIFDEF bool GifWriteFrame(const unsigned char *image, unsigned int width, unsigned int height, unsigned int delay, int bitDepth, bool dither); -GIFDEF bool GifEnd(); +RGIFDEF bool GifBegin(const char *filename, unsigned int width, unsigned int height, unsigned int delay, unsigned int bitDepth, bool dither); +RGIFDEF bool GifWriteFrame(const unsigned char *image, unsigned int width, unsigned int height, unsigned int delay, int bitDepth, bool dither); +RGIFDEF bool GifEnd(); #endif // GIF_H @@ -85,7 +85,7 @@ GIFDEF bool GifEnd(); * ************************************************************************************/ -#if defined(GIF_IMPLEMENTATION) +#if defined(RGIF_IMPLEMENTATION) #include <stdio.h> // Required for: FILE, fopen(), fclose() #include <string.h> // Required for: memcpy() @@ -186,7 +186,7 @@ static void GifWriteLzwImage(FILE *f, unsigned char *image, unsigned int left, u // Creates a gif file // NOTE: Initializes internal file pointer (only one gif recording at a time) // The delay value is the time between frames in hundredths of a second - note that not all viewers pay much attention to this value. -GIFDEF bool GifBegin(const char *filename, unsigned int width, unsigned int height, unsigned int delay, unsigned int bitDepth, bool dither) +RGIFDEF bool GifBegin(const char *filename, unsigned int width, unsigned int height, unsigned int delay, unsigned int bitDepth, bool dither) { #if _MSC_VER >= 1400 gifFile = 0; @@ -248,7 +248,7 @@ GIFDEF bool GifBegin(const char *filename, unsigned int width, unsigned int heig // NOTE: gifFile should have been initialized with GifBegin() // AFAIK, it is legal to use different bit depths for different frames of an image - // this may be handy to save bits in animations that don't change much. -GIFDEF bool GifWriteFrame(const unsigned char *image, unsigned int width, unsigned int height, unsigned int delay, int bitDepth, bool dither) +RGIFDEF bool GifWriteFrame(const unsigned char *image, unsigned int width, unsigned int height, unsigned int delay, int bitDepth, bool dither) { if (!gifFile) return false; @@ -268,7 +268,7 @@ GIFDEF bool GifWriteFrame(const unsigned char *image, unsigned int width, unsign // Writes the EOF code, closes the file handle, and frees temp memory used by a GIF. // Many if not most viewers will still display a GIF properly if the EOF code is missing, // but it's still a good idea to write it out. -GIFDEF bool GifEnd() +RGIFDEF bool GifEnd() { if (!gifFile) return false; @@ -910,4 +910,4 @@ static void GifWriteLzwImage(FILE *f, unsigned char *image, unsigned int left, u GIF_TEMP_FREE(codetree); } -#endif // GIF_IMPLEMENTATION +#endif // RGIF_IMPLEMENTATION diff --git a/src/raylib.h b/src/raylib.h index 07674531..392e0a24 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -5,21 +5,22 @@ * A simple and easy-to-use library to learn videogames programming (www.raylib.com) * * FEATURES: -* - Library written in plain C code (C99) -* - Multiple platforms supported: Windows, Linux, Mac, Android, Raspberry Pi, HTML5. +* - Written in plain C code (C99) in PascalCase/camelCase notation +* - Multiple platforms support: Windows, Linux, Mac, Android, Raspberry Pi and HTML5 * - Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES 2.0) * - Unique OpenGL abstraction layer (usable as standalone module): [rlgl] * - Powerful fonts module with SpriteFonts support (XNA bitmap fonts, AngelCode fonts, TTF) -* - Multiple textures support, including compressed formats and mipmaps generation -* - Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps +* - Outstanding texture formats support, including compressed formats (DXT, ETC, PVRT, ASTC) +* - Basic 3d support for Geometrics, Models, Billboards, Heightmaps and Cubicmaps +* - Flexible Materials system, supporting classic maps and PBR maps +* - Shaders support, including Model shaders and Postprocessing shaders * - Powerful math module for Vector2, Vector3, Matrix and Quaternion operations: [raymath] * - Audio loading and playing with streaming support and mixing channels: [audio] * - VR stereo rendering support with configurable HMD device parameters * - Minimal external dependencies (GLFW3, OpenGL, OpenAL) -* - Complete bindings for Lua, Go and Pascal +* - Complete bindings to LUA (raylib-lua) and Go (raylib-go) * * NOTES: -* 32bit Colors - Any defined Color is always RGBA (4 byte) * One custom font is loaded by default when InitWindow() [core] * If using OpenGL 3.3 or ES2, one default shader is loaded automatically (internally defined) [rlgl] * If using OpenGL 3.3 or ES2, several vertex buffers (VAO/VBO) are created to manage lines-triangles-quads @@ -31,12 +32,16 @@ * * OPTIONAL DEPENDENCIES: * stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA) [textures] +* stb_image_resize (Sean Barret) for image resizing algorythms [textures] * stb_image_write (Sean Barret) for image writting (PNG) [utils] * stb_truetype (Sean Barret) for ttf fonts loading [text] * stb_vorbis (Sean Barret) for ogg audio loading [audio] +* stb_perlin (Sean Barret) for Perlin noise image generation [textures] +* par_shapes (Philip Rideout) for parametric 3d shapes generation [models] * jar_xm (Joshua Reisenauer) for XM audio module loading [audio] * jar_mod (Joshua Reisenauer) for MOD audio module loading [audio] * dr_flac (David Reid) for FLAC audio file loading [audio] +* rgif (Charlie Tangora, Ramon Santamaria) for GIF recording [core] * tinfl for data decompression (DEFLATE algorithm) [rres] * * @@ -74,14 +79,17 @@ //#define PLATFORM_WEB // HTML5 (emscripten, asm.js) // Security check in case no PLATFORM_* defined -#if !defined(PLATFORM_DESKTOP) && !defined(PLATFORM_ANDROID) && !defined(PLATFORM_RPI) && !defined(PLATFORM_WEB) - #define PLATFORM_DESKTOP +#if !defined(PLATFORM_DESKTOP) && \ + !defined(PLATFORM_ANDROID) && \ + !defined(PLATFORM_RPI) && \ + !defined(PLATFORM_WEB) + #define PLATFORM_DESKTOP #endif -#if defined(_WIN32) && defined(BUILDING_DLL) - #define RLAPI __declspec(dllexport) // We are building raylib as a Win32 DLL -#elif defined(_WIN32) && defined(RAYLIB_DLL) - #define RLAPI __declspec(dllimport) // We are using raylib as a Win32 DLL +#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED) + #define RLAPI __declspec(dllexport) // We are building raylib as a Win32 shared library (.dll) +#elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED) + #define RLAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll) #else #define RLAPI // We are building or using raylib as a static library (or Linux shared library) #endif @@ -300,7 +308,7 @@ //---------------------------------------------------------------------------------- #ifndef __cplusplus // Boolean type - #if !defined(_STDBOOL_H) || !defined(__STDBOOL_H) // CLang uses second form + #ifndef bool typedef enum { false, true } bool; #endif #endif @@ -515,6 +523,20 @@ typedef struct RRESData { // RRES type (pointer to RRESData array) typedef struct RRESData *RRES; +// Head-Mounted-Display device parameters +typedef struct VrDeviceInfo { + int hResolution; // HMD horizontal resolution in pixels + int vResolution; // HMD vertical resolution in pixels + float hScreenSize; // HMD horizontal size in meters + float vScreenSize; // HMD vertical size in meters + float vScreenCenter; // HMD screen center in meters + float eyeToScreenDistance; // HMD distance between eye and display in meters + float lensSeparationDistance; // HMD lens separation distance in meters + float interpupillaryDistance; // HMD IPD (distance between pupils) in meters + float lensDistortionValues[4]; // HMD lens distortion constant parameters + float chromaAbCorrection[4]; // HMD chromatic aberration correction parameters +} VrDeviceInfo; + //---------------------------------------------------------------------------------- // Enumerators Definition //---------------------------------------------------------------------------------- @@ -657,13 +679,10 @@ typedef enum { HMD_DEFAULT_DEVICE = 0, HMD_OCULUS_RIFT_DK2, HMD_OCULUS_RIFT_CV1, + HMD_OCULUS_GO, HMD_VALVE_HTC_VIVE, - HMD_SAMSUNG_GEAR_VR, - HMD_GOOGLE_CARDBOARD, - HMD_SONY_PLAYSTATION_VR, - HMD_RAZER_OSVR, - HMD_FOVE_VR, -} VrDevice; + HMD_SONY_PSVR +} VrDeviceType; // RRESData type typedef enum { @@ -856,7 +875,8 @@ RLAPI void DrawCircleLines(int centerX, int centerY, float radius, Color color); RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle RLAPI void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters -RLAPI void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle +RLAPI void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a vertical-gradient-filled rectangle +RLAPI void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);// Draw a horizontal-gradient-filled rectangle RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // Draw a gradient-filled rectangle with custom vertex colors RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version) RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline @@ -1074,7 +1094,8 @@ RLAPI void BeginBlendMode(int mode); // Beg RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending) // VR control functions -RLAPI void InitVrSimulator(int vrDevice); // Init VR simulator for selected device +VrDeviceInfo GetVrDeviceInfo(int vrDeviceType); // Get VR device information for some standard devices +void InitVrSimulator(VrDeviceInfo info); // Init VR simulator for selected device parameters RLAPI void CloseVrSimulator(void); // Close VR simulator for current device RLAPI bool IsVrSimulatorReady(void); // Detect if VR simulator is ready RLAPI void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera @@ -223,20 +223,6 @@ typedef struct DrawCall { } DrawCall; #if defined(SUPPORT_VR_SIMULATOR) -// Head-Mounted-Display device parameters -typedef struct VrDeviceInfo { - int hResolution; // HMD horizontal resolution in pixels - int vResolution; // HMD vertical resolution in pixels - float hScreenSize; // HMD horizontal size in meters - float vScreenSize; // HMD vertical size in meters - float vScreenCenter; // HMD screen center in meters - float eyeToScreenDistance; // HMD distance between eye and display in meters - float lensSeparationDistance; // HMD lens separation distance in meters - float interpupillaryDistance; // HMD IPD (distance between pupils) in meters - float distortionK[4]; // HMD lens distortion constant parameters - float chromaAbCorrection[4]; // HMD chromatic aberration correction parameters -} VrDeviceInfo; - // VR Stereo rendering configuration for simulator typedef struct VrStereoConfig { RenderTexture2D stereoFbo; // VR stereo rendering framebuffer @@ -291,7 +277,6 @@ static bool texCompASTCSupported = false; // ASTC texture compression support #if defined(SUPPORT_VR_SIMULATOR) // VR global variables -static VrDeviceInfo hmd; // Current VR device info static VrStereoConfig vrConfig; // VR stereo configuration for simulator static bool vrSimulatorReady = false; // VR simulator ready flag static bool vrStereoRender = false; // VR stereo rendering enabled/disabled flag @@ -418,6 +403,7 @@ void rlPushMatrix(void) } stack[stackCounter] = *currentMatrix; + rlLoadIdentity(); stackCounter++; if (currentMatrixMode == RL_MODELVIEW) useTempBuffer = true; @@ -1947,7 +1933,7 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform) // Matrices and other values required by shader //----------------------------------------------------- // Calculate and send to shader model matrix (used by PBR shader) - SetShaderValueMatrix(material.shader, material.shader.locs[LOC_MATRIX_MODEL], transform); + if (material.shader.locs[LOC_MATRIX_MODEL] != -1) SetShaderValueMatrix(material.shader, material.shader.locs[LOC_MATRIX_MODEL], transform); // Upload to shader material.colDiffuse if (material.shader.locs[LOC_COLOR_DIFFUSE] != -1) @@ -2829,68 +2815,88 @@ void EndBlendMode(void) } #if defined(SUPPORT_VR_SIMULATOR) -// Init VR simulator for selected device -// NOTE: It modifies the global variable: VrDeviceInfo hmd -void InitVrSimulator(int vrDevice) +// Get VR device information for some standard devices +VrDeviceInfo GetVrDeviceInfo(int vrDeviceType) { -#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) - if (vrDevice == HMD_OCULUS_RIFT_DK2) - { - // Oculus Rift DK2 parameters - hmd.hResolution = 1280; // HMD horizontal resolution in pixels - hmd.vResolution = 800; // HMD vertical resolution in pixels - hmd.hScreenSize = 0.14976f; // HMD horizontal size in meters - hmd.vScreenSize = 0.09356f; // HMD vertical size in meters - hmd.vScreenCenter = 0.04678f; // HMD screen center in meters - hmd.eyeToScreenDistance = 0.041f; // HMD distance between eye and display in meters - hmd.lensSeparationDistance = 0.0635f; // HMD lens separation distance in meters - hmd.interpupillaryDistance = 0.064f; // HMD IPD (distance between pupils) in meters - hmd.distortionK[0] = 1.0f; // HMD lens distortion constant parameter 0 - hmd.distortionK[1] = 0.22f; // HMD lens distortion constant parameter 1 - hmd.distortionK[2] = 0.24f; // HMD lens distortion constant parameter 2 - hmd.distortionK[3] = 0.0f; // HMD lens distortion constant parameter 3 - hmd.chromaAbCorrection[0] = 0.996f; // HMD chromatic aberration correction parameter 0 - hmd.chromaAbCorrection[1] = -0.004f; // HMD chromatic aberration correction parameter 1 - hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2 - hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3 - - TraceLog(LOG_INFO, "Initializing VR Simulator (Oculus Rift DK2)"); - } - else if ((vrDevice == HMD_DEFAULT_DEVICE) || (vrDevice == HMD_OCULUS_RIFT_CV1)) - { - // Oculus Rift CV1 parameters - // NOTE: CV1 represents a complete HMD redesign compared to previous versions, - // new Fresnel-hybrid-asymmetric lenses have been added and, consequently, - // previous parameters (DK2) and distortion shader (DK2) doesn't work any more. - // I just defined a set of parameters for simulator that approximate to CV1 stereo rendering - // but result is not the same obtained with Oculus PC SDK. - hmd.hResolution = 2160; // HMD horizontal resolution in pixels - hmd.vResolution = 1200; // HMD vertical resolution in pixels - hmd.hScreenSize = 0.133793f; // HMD horizontal size in meters - hmd.vScreenSize = 0.0669f; // HMD vertical size in meters - hmd.vScreenCenter = 0.04678f; // HMD screen center in meters - hmd.eyeToScreenDistance = 0.041f; // HMD distance between eye and display in meters - hmd.lensSeparationDistance = 0.07f; // HMD lens separation distance in meters - hmd.interpupillaryDistance = 0.07f; // HMD IPD (distance between pupils) in meters - hmd.distortionK[0] = 1.0f; // HMD lens distortion constant parameter 0 - hmd.distortionK[1] = 0.22f; // HMD lens distortion constant parameter 1 - hmd.distortionK[2] = 0.24f; // HMD lens distortion constant parameter 2 - hmd.distortionK[3] = 0.0f; // HMD lens distortion constant parameter 3 - hmd.chromaAbCorrection[0] = 0.996f; // HMD chromatic aberration correction parameter 0 - hmd.chromaAbCorrection[1] = -0.004f; // HMD chromatic aberration correction parameter 1 - hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2 - hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3 - - TraceLog(LOG_INFO, "Initializing VR Simulator (Oculus Rift CV1)"); - } - else + VrDeviceInfo hmd = { 0 }; // Current VR device info + + switch (vrDeviceType) { - TraceLog(LOG_WARNING, "VR Simulator doesn't support selected device parameters,"); - TraceLog(LOG_WARNING, "using default VR Simulator parameters"); + case HMD_DEFAULT_DEVICE: + case HMD_OCULUS_RIFT_CV1: + { + // Oculus Rift CV1 parameters + // NOTE: CV1 represents a complete HMD redesign compared to previous versions, + // new Fresnel-hybrid-asymmetric lenses have been added and, consequently, + // previous parameters (DK2) and distortion shader (DK2) doesn't work any more. + // I just defined a set of parameters for simulator that approximate to CV1 stereo rendering + // but result is not the same obtained with Oculus PC SDK. + hmd.hResolution = 2160; // HMD horizontal resolution in pixels + hmd.vResolution = 1200; // HMD vertical resolution in pixels + hmd.hScreenSize = 0.133793f; // HMD horizontal size in meters + hmd.vScreenSize = 0.0669f; // HMD vertical size in meters + hmd.vScreenCenter = 0.04678f; // HMD screen center in meters + hmd.eyeToScreenDistance = 0.041f; // HMD distance between eye and display in meters + hmd.lensSeparationDistance = 0.07f; // HMD lens separation distance in meters + hmd.interpupillaryDistance = 0.07f; // HMD IPD (distance between pupils) in meters + hmd.lensDistortionValues[0] = 1.0f; // HMD lens distortion constant parameter 0 + hmd.lensDistortionValues[1] = 0.22f; // HMD lens distortion constant parameter 1 + hmd.lensDistortionValues[2] = 0.24f; // HMD lens distortion constant parameter 2 + hmd.lensDistortionValues[3] = 0.0f; // HMD lens distortion constant parameter 3 + hmd.chromaAbCorrection[0] = 0.996f; // HMD chromatic aberration correction parameter 0 + hmd.chromaAbCorrection[1] = -0.004f; // HMD chromatic aberration correction parameter 1 + hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2 + hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3 + + TraceLog(LOG_INFO, "Initializing VR Simulator (Oculus Rift CV1)"); + } break; + case HMD_OCULUS_RIFT_DK2: + { + // Oculus Rift DK2 parameters + hmd.hResolution = 1280; // HMD horizontal resolution in pixels + hmd.vResolution = 800; // HMD vertical resolution in pixels + hmd.hScreenSize = 0.14976f; // HMD horizontal size in meters + hmd.vScreenSize = 0.09356f; // HMD vertical size in meters + hmd.vScreenCenter = 0.04678f; // HMD screen center in meters + hmd.eyeToScreenDistance = 0.041f; // HMD distance between eye and display in meters + hmd.lensSeparationDistance = 0.0635f; // HMD lens separation distance in meters + hmd.interpupillaryDistance = 0.064f; // HMD IPD (distance between pupils) in meters + hmd.lensDistortionValues[0] = 1.0f; // HMD lens distortion constant parameter 0 + hmd.lensDistortionValues[1] = 0.22f; // HMD lens distortion constant parameter 1 + hmd.lensDistortionValues[2] = 0.24f; // HMD lens distortion constant parameter 2 + hmd.lensDistortionValues[3] = 0.0f; // HMD lens distortion constant parameter 3 + hmd.chromaAbCorrection[0] = 0.996f; // HMD chromatic aberration correction parameter 0 + hmd.chromaAbCorrection[1] = -0.004f; // HMD chromatic aberration correction parameter 1 + hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2 + hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3 + + TraceLog(LOG_INFO, "Initializing VR Simulator (Oculus Rift DK2)"); + } break; + case HMD_OCULUS_GO: + { + // TODO: Provide device display and lens parameters + } + case HMD_VALVE_HTC_VIVE: + { + // TODO: Provide device display and lens parameters + } + case HMD_SONY_PSVR: + { + // TODO: Provide device display and lens parameters + } + default: break; } + + return hmd; +} +// Init VR simulator for selected device parameters +// NOTE: It modifies the global variable: VrStereoConfig vrConfig +void InitVrSimulator(VrDeviceInfo info) +{ +#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) // Initialize framebuffer and textures for stereo rendering - // NOTE: screen size should match HMD aspect ratio + // NOTE: Screen size should match HMD aspect ratio vrConfig.stereoFbo = rlLoadRenderTexture(screenWidth, screenHeight); #if defined(SUPPORT_DISTORTION_SHADER) @@ -2899,7 +2905,7 @@ void InitVrSimulator(int vrDevice) if (vrConfig.distortionShader.id > 0) SetShaderDefaultLocations(&vrConfig.distortionShader); #endif - SetStereoConfig(hmd); + SetStereoConfig(info); vrSimulatorReady = true; #endif @@ -2923,6 +2929,18 @@ void CloseVrSimulator(void) #endif } +// TODO: Review VR system to be more flexible, +// move distortion shader to user side, +// SetStereoConfig() must be reviewed... +/* +// Set VR view distortion shader +void SetVrDistortionShader(Shader shader) +{ + vrConfig.distortionShader = shader; + SetStereoConfig(info); +} +*/ + // Detect if VR simulator is running bool IsVrSimulatorReady(void) { @@ -3345,8 +3363,6 @@ static void SetShaderDefaultLocations(Shader *shader) shader->locs[LOC_MAP_DIFFUSE] = glGetUniformLocation(shader->id, "texture0"); shader->locs[LOC_MAP_NORMAL] = glGetUniformLocation(shader->id, "texture1"); shader->locs[LOC_MAP_SPECULAR] = glGetUniformLocation(shader->id, "texture2"); - - // TODO: Try to find all expected/recognized shader locations (predefined names, must be documented) } // Unload default shader @@ -3941,6 +3957,7 @@ static void GenDrawCube(void) #if defined(SUPPORT_VR_SIMULATOR) // Configure stereo rendering (including distortion shader) with HMD device parameters +// NOTE: It modifies the global variable: VrStereoConfig vrConfig static void SetStereoConfig(VrDeviceInfo hmd) { // Compute aspect ratio @@ -3957,10 +3974,10 @@ static void SetStereoConfig(VrDeviceInfo hmd) // NOTE: To get lens max radius, lensShift must be normalized to [-1..1] float lensRadius = fabsf(-1.0f - 4.0f*lensShift); float lensRadiusSq = lensRadius*lensRadius; - float distortionScale = hmd.distortionK[0] + - hmd.distortionK[1]*lensRadiusSq + - hmd.distortionK[2]*lensRadiusSq*lensRadiusSq + - hmd.distortionK[3]*lensRadiusSq*lensRadiusSq*lensRadiusSq; + float distortionScale = hmd.lensDistortionValues[0] + + hmd.lensDistortionValues[1]*lensRadiusSq + + hmd.lensDistortionValues[2]*lensRadiusSq*lensRadiusSq + + hmd.lensDistortionValues[3]*lensRadiusSq*lensRadiusSq*lensRadiusSq; TraceLog(LOG_DEBUG, "VR: Distortion Scale: %f", distortionScale); @@ -3983,7 +4000,7 @@ static void SetStereoConfig(VrDeviceInfo hmd) SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "scale"), scale, 2); SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "scaleIn"), scaleIn, 2); - SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "hmdWarpParam"), hmd.distortionK, 4); + SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "hmdWarpParam"), hmd.lensDistortionValues, 4); SetShaderValue(vrConfig.distortionShader, GetShaderLocation(vrConfig.distortionShader, "chromaAbParam"), hmd.chromaAbCorrection, 4); #endif @@ -4022,6 +4039,7 @@ static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView) // Apply view offset to modelview matrix eyeModelView = MatrixMultiply(matModelView, vrConfig.eyesViewOffset[eye]); + // Set current eye projection matrix eyeProjection = vrConfig.eyesProjection[eye]; SetMatrixModelview(eyeModelView); @@ -27,7 +27,7 @@ * #define SUPPORT_VR_SIMULATION / SUPPORT_STEREO_RENDERING * Support VR simulation functionality (stereo rendering) * -* #define SUPPORT_SHADER_DISTORTION +* #define SUPPORT_DISTORTION_SHADER * Include stereo rendering distortion shader (shader_distortion.h) * * DEPENDENCIES: @@ -269,6 +269,20 @@ typedef unsigned char byte; float fovy; // Camera field-of-view apperture in Y (degrees) } Camera; + // Head-Mounted-Display device parameters + typedef struct VrDeviceInfo { + int hResolution; // HMD horizontal resolution in pixels + int vResolution; // HMD vertical resolution in pixels + float hScreenSize; // HMD horizontal size in meters + float vScreenSize; // HMD vertical size in meters + float vScreenCenter; // HMD screen center in meters + float eyeToScreenDistance; // HMD distance between eye and display in meters + float lensSeparationDistance; // HMD lens separation distance in meters + float interpupillaryDistance; // HMD IPD (distance between pupils) in meters + float lensDistortionValues[4]; // HMD lens distortion constant parameters + float chromaAbCorrection[4]; // HMD chromatic aberration correction parameters + } VrDeviceInfo; + // TraceLog message types typedef enum { LOG_INFO = 0, @@ -332,12 +346,9 @@ typedef unsigned char byte; HMD_DEFAULT_DEVICE = 0, HMD_OCULUS_RIFT_DK2, HMD_OCULUS_RIFT_CV1, + HMD_OCULUS_GO, HMD_VALVE_HTC_VIVE, - HMD_SAMSUNG_GEAR_VR, - HMD_GOOGLE_CARDBOARD, - HMD_SONY_PLAYSTATION_VR, - HMD_RAZER_OSVR, - HMD_FOVE_VR, + HMD_SONY_PSVR } VrDevice; #endif @@ -457,7 +468,8 @@ void BeginBlendMode(int mode); // Begin blending mode ( void EndBlendMode(void); // End blending mode (reset to default: alpha blending) // VR simulator functionality -void InitVrSimulator(int vrDevice); // Init VR simulator for selected device +VrDeviceInfo GetVrDeviceInfo(int vrDeviceType); // Get VR device information for some standard devices +void InitVrSimulator(VrDeviceInfo info); // Init VR simulator for selected device parameters void CloseVrSimulator(void); // Close VR simulator for current device void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator) diff --git a/src/shader_distortion.h b/src/shader_distortion.h index 75653e12..7a2c994b 100644 --- a/src/shader_distortion.h +++ b/src/shader_distortion.h @@ -20,12 +20,12 @@ static const char vDistortionShaderStr[] = "out vec2 fragTexCoord; \n" "out vec4 fragColor; \n" #endif -"uniform mat4 mvpMatrix; \n" +"uniform mat4 mvp; \n" "void main() \n" "{ \n" " fragTexCoord = vertexTexCoord; \n" " fragColor = vertexColor; \n" -" gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); \n" +" gl_Position = mvp*vec4(vertexPosition, 1.0); \n" "} \n"; // Fragment shader definition to embed, no external file required diff --git a/src/shapes.c b/src/shapes.c index 8c7f2419..0b34f921 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -274,22 +274,22 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color rlDisableTexture(); } -// Draw a gradient-filled rectangle +// Draw a vertical-gradient-filled rectangle // NOTE: Gradient goes from bottom (color1) to top (color2) -void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2) +void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2) { - rlBegin(RL_TRIANGLES); - rlColor4ub(color1.r, color1.g, color1.b, color1.a); rlVertex2i(posX, posY); - rlColor4ub(color2.r, color2.g, color2.b, color2.a); rlVertex2i(posX, posY + height); - rlColor4ub(color2.r, color2.g, color2.b, color2.a); rlVertex2i(posX + width, posY + height); + DrawRectangleGradientEx((Rectangle){ posX, posY, width, height }, color1, color2, color2, color1); +} - rlColor4ub(color1.r, color1.g, color1.b, color1.a); rlVertex2i(posX, posY); - rlColor4ub(color2.r, color2.g, color2.b, color2.a); rlVertex2i(posX + width, posY + height); - rlColor4ub(color1.r, color1.g, color1.b, color1.a); rlVertex2i(posX + width, posY); - rlEnd(); +// Draw a horizontal-gradient-filled rectangle +// NOTE: Gradient goes from bottom (color1) to top (color2) +void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2) +{ + DrawRectangleGradientEx((Rectangle){ posX, posY, width, height }, color1, color1, color2, color2); } // Draw a gradient-filled rectangle +// NOTE: Colors refer to corners, starting at top-lef corner and counter-clockwise void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4) { rlEnableTexture(GetTextureDefault().id); // Default white texture @@ -682,6 +682,8 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2) // NOTE: Required for DrawLineBezier() static float EaseCubicInOut(float t, float b, float c, float d) { - if ((t/=d/2) < 1) return (c/2*t*t*t + b); - return (c/2*((t-=2)*t*t + 2) + b); -}
\ No newline at end of file + if ((t /= 0.5*d) < 1) + return 0.5*c*t*t*t + b; + t -= 2; + return 0.5*c*(t*t*t + 2) + b; +} diff --git a/src/utils.c b/src/utils.c index cd4638af..967ed916 100644 --- a/src/utils.c +++ b/src/utils.c @@ -47,6 +47,7 @@ #define SUPPORT_TRACELOG // Output tracelog messages //#define SUPPORT_TRACELOG_DEBUG // Avoid LOG_DEBUG messages tracing +#include "raylib.h" // WARNING: Required for: LogType enum #include "utils.h" #if defined(PLATFORM_ANDROID) |
