Merge branch 'raysan5:master' into pure

This commit is contained in:
Colleague Riley 2024-06-26 16:00:05 -04:00 • committed by GitHub
commit b097b30337
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 1239 additions and 720 deletions

View file

@ -13,7 +13,6 @@ Some people ported raylib to other languages in the form of bindings or wrappers
| [Raylib-CsLo](https://github.com/NotNotTech/Raylib-CsLo) | 4.2 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | | [Raylib-CsLo](https://github.com/NotNotTech/Raylib-CsLo) | 4.2 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 |
| [Raylib-CSharp-Vinculum](https://github.com/ZeroElectric/Raylib-CSharp-Vinculum) | **5.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | | [Raylib-CSharp-Vinculum](https://github.com/ZeroElectric/Raylib-CSharp-Vinculum) | **5.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 |
| [Raylib-CSharp](https://github.com/MrScautHD/Raylib-CSharp) | **5.1-dev** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MIT | | [Raylib-CSharp](https://github.com/MrScautHD/Raylib-CSharp) | **5.1-dev** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MIT |
| [Raylib.NET](https://github.com/Odex64/Raylib.NET) | **5.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MIT |
| [cl-raylib](https://github.com/longlene/cl-raylib) | 4.0 | [Common Lisp](https://common-lisp.net) | MIT | | [cl-raylib](https://github.com/longlene/cl-raylib) | 4.0 | [Common Lisp](https://common-lisp.net) | MIT |
| [claylib/wrap](https://github.com/defun-games/claylib) | 4.5 | [Common Lisp](https://common-lisp.net) | Zlib | | [claylib/wrap](https://github.com/defun-games/claylib) | 4.5 | [Common Lisp](https://common-lisp.net) | Zlib |
| [claw-raylib](https://github.com/bohonghuang/claw-raylib) | **auto** | [Common Lisp](https://common-lisp.net) | Apache-2.0 | | [claw-raylib](https://github.com/bohonghuang/claw-raylib) | **auto** | [Common Lisp](https://common-lisp.net) | Apache-2.0 |
@ -37,7 +36,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
| [jaylib](https://github.com/janet-lang/jaylib) | **5.0** | [Janet](https://janet-lang.org) | MIT | | [jaylib](https://github.com/janet-lang/jaylib) | **5.0** | [Janet](https://janet-lang.org) | MIT |
| [jaylib](https://github.com/electronstudio/jaylib/) | 4.5 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | GPLv3+CE | | [jaylib](https://github.com/electronstudio/jaylib/) | 4.5 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | GPLv3+CE |
| [raylib-j](https://github.com/CreedVI/Raylib-J) | 4.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | Zlib | | [raylib-j](https://github.com/CreedVI/Raylib-J) | 4.0 | [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) | Zlib |
| [raylib.jl](https://github.com/irishgreencitrus/raylib.jl) | 4.2 | [Julia](https://julialang.org) | Zlib | | [Raylib.jl](https://github.com/chengchingwen/Raylib.jl) | 4.2 | [Julia](https://julialang.org) | Zlib |
| [kaylib](https://github.com/electronstudio/kaylib) | 3.7 | [Kotlin/native](https://kotlinlang.org) | **???** | | [kaylib](https://github.com/electronstudio/kaylib) | 3.7 | [Kotlin/native](https://kotlinlang.org) | **???** |
| [KaylibKit](https://codeberg.org/Kenta/KaylibKit) | 4.5 | [Kotlin/native](https://kotlinlang.org) | Zlib | | [KaylibKit](https://codeberg.org/Kenta/KaylibKit) | 4.5 | [Kotlin/native](https://kotlinlang.org) | Zlib |
| [raylib-lua](https://github.com/TSnake41/raylib-lua) | 4.5 | [Lua](http://www.lua.org) | ISC | | [raylib-lua](https://github.com/TSnake41/raylib-lua) | 4.5 | [Lua](http://www.lua.org) | ISC |

View file

@ -1,4 +1,4 @@
### Config options ### # ## Config options ###
include(CMakeDependentOption) include(CMakeDependentOption)
include(EnumOption) include(EnumOption)
@ -9,14 +9,14 @@ enum_option(OPENGL_VERSION "OFF;4.3;3.3;2.1;1.1;ES 2.0;ES 3.0" "Force a specific
# Configuration options # Configuration options
option(BUILD_EXAMPLES "Build the examples." ${RAYLIB_IS_MAIN}) option(BUILD_EXAMPLES "Build the examples." ${RAYLIB_IS_MAIN})
option(CUSTOMIZE_BUILD "Show options for customizing your Raylib library build." OFF) option(CUSTOMIZE_BUILD "Show options for customizing your Raylib library build." OFF)
option(ENABLE_ASAN "Enable AddressSanitizer (ASAN) for debugging (degrades performance)" OFF) option(ENABLE_ASAN "Enable AddressSanitizer (ASAN) for debugging (degrades performance)" OFF)
option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan) for debugging" OFF) option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan) for debugging" OFF)
option(ENABLE_MSAN "Enable MemorySanitizer (MSan) for debugging (not recommended to run with ASAN)" OFF) option(ENABLE_MSAN "Enable MemorySanitizer (MSan) for debugging (not recommended to run with ASAN)" OFF)
# Shared library is always PIC. Static library should be PIC too if linked into a shared library # Shared library is always PIC. Static library should be PIC too if linked into a shared library
option(WITH_PIC "Compile static library as position-independent code" OFF) option(WITH_PIC "Compile static library as position-independent code" OFF)
option(BUILD_SHARED_LIBS "Build raylib as a shared library" OFF) option(BUILD_SHARED_LIBS "Build raylib as a shared library" OFF)
option(MACOS_FATLIB "Build fat library for both i386 and x86_64 on macOS" OFF) option(MACOS_FATLIB "Build fat library for both i386 and x86_64 on macOS" OFF)
cmake_dependent_option(USE_AUDIO "Build raylib with audio module" ON CUSTOMIZE_BUILD ON) cmake_dependent_option(USE_AUDIO "Build raylib with audio module" ON CUSTOMIZE_BUILD ON)
enum_option(USE_EXTERNAL_GLFW "OFF;IF_POSSIBLE;ON" "Link raylib against system GLFW instead of embedded one") enum_option(USE_EXTERNAL_GLFW "OFF;IF_POSSIBLE;ON" "Link raylib against system GLFW instead of embedded one")
@ -28,77 +28,9 @@ option(GLFW_BUILD_X11 "Build the bundled GLFW with X11 support" ON)
option(INCLUDE_EVERYTHING "Include everything disabled by default (for CI usage" OFF) option(INCLUDE_EVERYTHING "Include everything disabled by default (for CI usage" OFF)
set(OFF ${INCLUDE_EVERYTHING} CACHE INTERNAL "Replace any OFF by default with \${OFF} to have it covered by this option") set(OFF ${INCLUDE_EVERYTHING} CACHE INTERNAL "Replace any OFF by default with \${OFF} to have it covered by this option")
# raylib modules included include(ParseConfigHeader)
cmake_dependent_option(SUPPORT_MODULE_RSHAPES "Include module: rshapes" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_MODULE_RTEXTURES "Include module: rtextures" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_MODULE_RTEXT "Include module: rtext" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_MODULE_RMODELS "Include module: rmodels" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_MODULE_RAUDIO "Include module: raudio" ON CUSTOMIZE_BUILD ON)
# rcore.c foreach(FLAG IN LISTS CONFIG_HEADER_FLAGS)
cmake_dependent_option(SUPPORT_CAMERA_SYSTEM "Provide camera module (rcamera.h) with multiple predefined cameras: free, 1st/3rd person, orbital" ON CUSTOMIZE_BUILD ON) string(REGEX MATCH "([^=]+)=(.+)" _ ${FLAG})
cmake_dependent_option(SUPPORT_GESTURES_SYSTEM "Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag" ON CUSTOMIZE_BUILD ON) cmake_dependent_option(${CMAKE_MATCH_1} "" ${CMAKE_MATCH_2} CUSTOMIZE_BUILD ${CMAKE_MATCH_2})
cmake_dependent_option(SUPPORT_RPRAND_GENERATOR "Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64" ON CUSTOMIZE_BUILD ON) endforeach()
cmake_dependent_option(SUPPORT_MOUSE_GESTURES "Mouse gestures are directly mapped like touches and processed by gestures system" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_SSH_KEYBOARD_RPI "Reconfigure standard input to receive key inputs, works with SSH connection" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_DEFAULT_FONT "Default font is loaded on window initialization to be available for the user to render simple text. If enabled, uses external module functions to load default raylib font (module: text)" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_SCREEN_CAPTURE "Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_GIF_RECORDING "Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_BUSY_WAIT_LOOP "Use busy wait loop for timing sync instead of a high-resolution timer" OFF CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_EVENTS_WAITING "Wait for events passively (sleeping while no events) instead of polling them actively every frame" OFF CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_WINMM_HIGHRES_TIMER "Setting a higher resolution can improve the accuracy of time-out intervals in wait functions" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_COMPRESSION_API "Support for compression API" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_EVENTS_AUTOMATION "Support automatic generated events, loading and recording of those events when required" OFF CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_CUSTOM_FRAME_CONTROL "Enabling this flag allows manual control of the frame processes, use at your own risk" OFF CUSTOMIZE_BUILD OFF)
# rshapes.c
cmake_dependent_option(SUPPORT_QUADS_DRAW_MODE "Use QUADS instead of TRIANGLES for drawing when possible. Some lines-based shapes could still use lines" ON CUSTOMIZE_BUILD ON)
# rtextures.c
cmake_dependent_option(SUPPORT_IMAGE_EXPORT "Support image exporting to file" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_IMAGE_GENERATION "Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_IMAGE_MANIPULATION "Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT()" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_PNG "Support loading PNG as textures" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_DDS "Support loading DDS as textures" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_HDR "Support loading HDR as textures" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_PIC "Support loading PIC as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_PNM "Support loading PNM as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_KTX "Support loading KTX as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_ASTC "Support loading ASTC as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_BMP "Support loading BMP as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_TGA "Support loading TGA as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_JPG "Support loading JPG as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_GIF "Support loading GIF as textures" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_QOI "Support loading QOI as textures" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_PSD "Support loading PSD as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_PKM "Support loading PKM as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_PVR "Support loading PVR as textures" ${OFF} CUSTOMIZE_BUILD OFF)
cmake_dependent_option(SUPPORT_FILEFORMAT_SVG "Support loading SVG as textures" ${OFF} CUSTOMIZE_BUILD OFF)
# rtext.c
cmake_dependent_option(SUPPORT_FILEFORMAT_FNT "Support loading fonts in FNT format" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_TTF "Support loading font in TTF/OTF format" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_TEXT_MANIPULATION "Support text manipulation functions" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FONT_ATLAS_WHITE_REC "Support white rec on font atlas bottom-right corner" ON CUSTOMIZE_BUILD ON)
# rmodels.c
cmake_dependent_option(SUPPORT_MESH_GENERATION "Support procedural mesh generation functions, uses external par_shapes.h library. NOTE: Some generated meshes DO NOT include generated texture coordinates" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_OBJ "Support loading OBJ file format" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_MTL "Support loading MTL file format" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_IQM "Support loading IQM file format" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_GLTF "Support loading GLTF file format" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_VOX "Support loading VOX file format" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_M3D "Support loading M3D file format" ON CUSTOMIZE_BUILD ON)
# raudio.c
cmake_dependent_option(SUPPORT_FILEFORMAT_WAV "Support loading WAV for sound" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_OGG "Support loading OGG for sound" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_XM "Support loading XM for sound" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_MOD "Support loading MOD for sound" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_MP3 "Support loading MP3 for sound" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_QOA "Support loading QOA for sound" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_FILEFORMAT_FLAC "Support loading FLAC for sound" ${OFF} CUSTOMIZE_BUILD OFF)
# utils.c
cmake_dependent_option(SUPPORT_STANDARD_FILEIO "Support standard file io library (stdio.h)" ON CUSTOMIZE_BUILD ON)
cmake_dependent_option(SUPPORT_TRACELOG "Show TraceLog() output messages. NOTE: By default LOG_DEBUG traces not shown" ON CUSTOMIZE_BUILD ON)

View file

@ -3,126 +3,22 @@ target_compile_definitions("raylib" PUBLIC "${PLATFORM_CPP}")
target_compile_definitions("raylib" PUBLIC "${GRAPHICS}") target_compile_definitions("raylib" PUBLIC "${GRAPHICS}")
function(define_if target variable) function(define_if target variable)
if (${${variable}}) if(${${variable}})
message(STATUS "${variable}=${${variable}}") message(STATUS "${variable}=${${variable}}")
target_compile_definitions(${target} PUBLIC "${variable}") target_compile_definitions(${target} PRIVATE "${variable}")
endif () endif()
endfunction() endfunction()
if (${CUSTOMIZE_BUILD}) if(${CUSTOMIZE_BUILD})
target_compile_definitions("raylib" PUBLIC EXTERNAL_CONFIG_FLAGS) target_compile_definitions("raylib" PRIVATE EXTERNAL_CONFIG_FLAGS)
define_if("raylib" USE_AUDIO) define_if("raylib" USE_AUDIO)
define_if("raylib" SUPPORT_MODULE_RSHAPES)
define_if("raylib" SUPPORT_MODULE_RTEXTURES)
define_if("raylib" SUPPORT_MODULE_RTEXT)
define_if("raylib" SUPPORT_MODULE_RMODELS)
define_if("raylib" SUPPORT_MODULE_RAUDIO)
define_if("raylib" SUPPORT_CAMERA_SYSTEM)
define_if("raylib" SUPPORT_GESTURES_SYSTEM)
define_if("raylib" SUPPORT_MOUSE_GESTURES)
define_if("raylib" SUPPORT_SSH_KEYBOARD_RPI)
define_if("raylib" SUPPORT_DEFAULT_FONT)
define_if("raylib" SUPPORT_SCREEN_CAPTURE)
define_if("raylib" SUPPORT_GIF_RECORDING)
define_if("raylib" SUPPORT_BUSY_WAIT_LOOP)
define_if("raylib" SUPPORT_EVENTS_WAITING)
define_if("raylib" SUPPORT_WINMM_HIGHRES_TIMER)
define_if("raylib" SUPPORT_COMPRESSION_API)
define_if("raylib" SUPPORT_EVENTS_AUTOMATION)
define_if("raylib" SUPPORT_CUSTOM_FRAME_CONTROL)
define_if("raylib" SUPPORT_QUADS_DRAW_MODE)
define_if("raylib" SUPPORT_IMAGE_EXPORT)
define_if("raylib" SUPPORT_IMAGE_GENERATION)
define_if("raylib" SUPPORT_IMAGE_MANIPULATION)
define_if("raylib" SUPPORT_FILEFORMAT_PNG)
define_if("raylib" SUPPORT_FILEFORMAT_DDS)
define_if("raylib" SUPPORT_FILEFORMAT_HDR)
define_if("raylib" SUPPORT_FILEFORMAT_PIC)
define_if("raylib" SUPPORT_FILEFORMAT_PNM)
define_if("raylib" SUPPORT_FILEFORMAT_KTX)
define_if("raylib" SUPPORT_FILEFORMAT_ASTC)
define_if("raylib" SUPPORT_FILEFORMAT_BMP)
define_if("raylib" SUPPORT_FILEFORMAT_TGA)
define_if("raylib" SUPPORT_FILEFORMAT_JPG)
define_if("raylib" SUPPORT_FILEFORMAT_GIF)
define_if("raylib" SUPPORT_FILEFORMAT_QOI)
define_if("raylib" SUPPORT_FILEFORMAT_PSD)
define_if("raylib" SUPPORT_FILEFORMAT_PKM)
define_if("raylib" SUPPORT_FILEFORMAT_PVR)
define_if("raylib" SUPPORT_FILEFORMAT_SVG)
define_if("raylib" SUPPORT_FILEFORMAT_FNT)
define_if("raylib" SUPPORT_FILEFORMAT_TTF)
define_if("raylib" SUPPORT_TEXT_MANIPULATION)
define_if("raylib" SUPPORT_MESH_GENERATION)
define_if("raylib" SUPPORT_FILEFORMAT_OBJ)
define_if("raylib" SUPPORT_FILEFORMAT_MTL)
define_if("raylib" SUPPORT_FILEFORMAT_IQM)
define_if("raylib" SUPPORT_FILEFORMAT_GLTF)
define_if("raylib" SUPPORT_FILEFORMAT_VOX)
define_if("raylib" SUPPORT_FILEFORMAT_M3D)
define_if("raylib" SUPPORT_FILEFORMAT_WAV)
define_if("raylib" SUPPORT_FILEFORMAT_OGG)
define_if("raylib" SUPPORT_FILEFORMAT_XM)
define_if("raylib" SUPPORT_FILEFORMAT_MOD)
define_if("raylib" SUPPORT_FILEFORMAT_MP3)
define_if("raylib" SUPPORT_FILEFORMAT_QOA)
define_if("raylib" SUPPORT_FILEFORMAT_FLAC)
define_if("raylib" SUPPORT_STANDARD_FILEIO)
define_if("raylib" SUPPORT_TRACELOG)
if (UNIX AND NOT APPLE) foreach(FLAG IN LISTS CONFIG_HEADER_FLAGS)
target_compile_definitions("raylib" PUBLIC "MAX_FILEPATH_LENGTH=4096") string(REGEX MATCH "([^=]+)=(.+)" _ ${FLAG})
else () define_if("raylib" ${CMAKE_MATCH_1})
target_compile_definitions("raylib" PUBLIC "MAX_FILEPATH_LENGTH=512") endforeach()
endif ()
target_compile_definitions("raylib" PUBLIC "MAX_GAMEPADS=4")
target_compile_definitions("raylib" PUBLIC "MAX_GAMEPAD_AXIS=8")
target_compile_definitions("raylib" PUBLIC "MAX_GAMEPAD_BUTTONS=32")
target_compile_definitions("raylib" PUBLIC "MAX_TOUCH_POINTS=10")
target_compile_definitions("raylib" PUBLIC "MAX_KEY_PRESSED_QUEUE=16")
target_compile_definitions("raylib" PUBLIC "STORAGE_DATA_FILE=\"storage.data\"")
target_compile_definitions("raylib" PUBLIC "MAX_CHAR_PRESSED_QUEUE=16")
target_compile_definitions("raylib" PUBLIC "MAX_DECOMPRESSION_SIZE=64")
if (${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_33" OR ${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_11")
target_compile_definitions("raylib" PUBLIC "DEFAULT_BATCH_BUFFER_ELEMENTS=8192")
elseif (${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_ES2")
target_compile_definitions("raylib" PUBLIC "DEFAULT_BATCH_BUFFER_ELEMENTS=2048")
endif ()
target_compile_definitions("raylib" PUBLIC "DEFAULT_BATCH_DRAWCALLS=256")
target_compile_definitions("raylib" PUBLIC "MAX_MATRIX_STACK_SIZE=32")
target_compile_definitions("raylib" PUBLIC "MAX_SHADER_LOCATIONS=32")
target_compile_definitions("raylib" PUBLIC "MAX_MATERIAL_MAPS=12")
target_compile_definitions("raylib" PUBLIC "RL_CULL_DISTANCE_NEAR=0.01")
target_compile_definitions("raylib" PUBLIC "RL_CULL_DISTANCE_FAR=1000.0")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION=0")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD=1")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL=2")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR=3")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT=4")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2=5")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION=\"vertexPosition\"")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD=\"vertexTexCoord\"")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL=\"vertexNormal\"")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR=\"vertexColor\"")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT=\"vertexTangent\"")
target_compile_definitions("raylib" PUBLIC "RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2=\"vertexTexCoord2\"")
target_compile_definitions("raylib" PUBLIC "MAX_TEXT_BUFFER_LENGTH=1024")
target_compile_definitions("raylib" PUBLIC "MAX_TEXT_UNICODE_CHARS=512")
target_compile_definitions("raylib" PUBLIC "MAX_TEXTSPLIT_COUNT=128")
target_compile_definitions("raylib" PUBLIC "AUDIO_DEVICE_FORMAT=ma_format_f32")
target_compile_definitions("raylib" PUBLIC "AUDIO_DEVICE_CHANNELS=2")
target_compile_definitions("raylib" PUBLIC "AUDIO_DEVICE_SAMPLE_RATE=44100")
target_compile_definitions("raylib" PUBLIC "DEFAULT_AUDIO_BUFFER_SIZE=4096")
target_compile_definitions("raylib" PUBLIC "MAX_TRACELOG_MSG_LENGTH=128")
target_compile_definitions("raylib" PUBLIC "MAX_UWP_MESSAGES=512")
endif ()
foreach(VALUE IN LISTS CONFIG_HEADER_VALUES)
target_compile_definitions("raylib" PRIVATE ${VALUE})
endforeach()
endif()

View file

@ -58,8 +58,9 @@ if (${PLATFORM} MATCHES "Desktop")
elseif (${PLATFORM} MATCHES "Web") elseif (${PLATFORM} MATCHES "Web")
set(PLATFORM_CPP "PLATFORM_WEB") set(PLATFORM_CPP "PLATFORM_WEB")
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2") if(NOT GRAPHICS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 --profiling") set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
endif()
set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
elseif (${PLATFORM} MATCHES "Android") elseif (${PLATFORM} MATCHES "Android")

View file

@ -0,0 +1,17 @@
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/config.h" CONFIG_HEADER_CONTENT)
set(BLANK_OR_BACKSLASH_PATTERN "[ \t\r\n\\]")
set(VALID_IDENTIFIER_PATTERN "[A-Za-z_]+[A-Za-z_0-9]*")
set(VALID_VALUE_PATTERN [=["?[A-Za-z_0-9.-]+"?]=]) # not really correct but does the job since the config.h file hopefully will have been checked by a C preprocessor.
set(MACRO_REGEX "(//${BLANK_OR_BACKSLASH_PATTERN}*)?\#define${BLANK_OR_BACKSLASH_PATTERN}+(${VALID_IDENTIFIER_PATTERN})${BLANK_OR_BACKSLASH_PATTERN}+(${VALID_VALUE_PATTERN})")
string(REGEX MATCHALL ${MACRO_REGEX} MACRO_LIST ${CONFIG_HEADER_CONTENT})
set(CONFIG_HEADER_FLAGS ${MACRO_LIST})
list(FILTER CONFIG_HEADER_FLAGS INCLUDE REGEX "^.+SUPPORT_")
list(TRANSFORM CONFIG_HEADER_FLAGS REPLACE ${MACRO_REGEX} [[\2=OFF]] REGEX "^//")
list(TRANSFORM CONFIG_HEADER_FLAGS REPLACE ${MACRO_REGEX} [[\2=ON]])
set(CONFIG_HEADER_VALUES ${MACRO_LIST})
list(FILTER CONFIG_HEADER_VALUES EXCLUDE REGEX "(^.+SUPPORT_)|(^//)")
list(TRANSFORM CONFIG_HEADER_VALUES REPLACE ${MACRO_REGEX} [[\2=\3]])

View file

@ -96,10 +96,9 @@ if (${PLATFORM} MATCHES "Android")
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_basic_lighting.c) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_basic_lighting.c)
elseif (${PLATFORM} MATCHES "Web") elseif (${PLATFORM} MATCHES "Web")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os")
# Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads # Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s WASM=1 -s ASYNCIFY -s ALLOW_MEMORY_GROWTH=1 --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html")
set(CMAKE_EXECUTABLE_SUFFIX ".html") set(CMAKE_EXECUTABLE_SUFFIX ".html")
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c) list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c)

View file

@ -97,7 +97,7 @@ int main(void)
DrawRectangle(199, 199, 402, 34, LIGHTGRAY); DrawRectangle(199, 199, 402, 34, LIGHTGRAY);
for (int i = 0; i < 400; i++) for (int i = 0; i < 400; i++)
{ {
DrawLine(201 + i, 232 - averageVolume[i] * 32, 201 + i, 232, MAROON); DrawLine(201 + i, 232 - (int)averageVolume[i] * 32, 201 + i, 232, MAROON);
} }
DrawRectangleLines(199, 199, 402, 34, GRAY); DrawRectangleLines(199, 199, 402, 34, GRAY);

View file

@ -75,6 +75,7 @@ fn add_module(comptime module: []const u8, b: *std.Build, target: std.Build.Reso
const install_cmd = b.addInstallArtifact(exe, .{}); const install_cmd = b.addInstallArtifact(exe, .{});
const run_cmd = b.addRunArtifact(exe); const run_cmd = b.addRunArtifact(exe);
run_cmd.cwd = b.path(module);
run_cmd.step.dependOn(&install_cmd.step); run_cmd.step.dependOn(&install_cmd.step);
const run_step = b.step(name, name); const run_step = b.step(name, name);

View file

@ -133,10 +133,10 @@ int main(void)
for (int i = 0; i < envItemsLength; i++) DrawRectangleRec(envItems[i].rect, envItems[i].color); for (int i = 0; i < envItemsLength; i++) DrawRectangleRec(envItems[i].rect, envItems[i].color);
Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40, 40 }; Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40.0f, 40.0f };
DrawRectangleRec(playerRect, RED); DrawRectangleRec(playerRect, RED);
DrawCircle(player.position.x, player.position.y, 5, GOLD); DrawCircleV(player.position, 5.0f, GOLD);
EndMode2D(); EndMode2D();

View file

@ -36,7 +36,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
boxPositionY -= (GetMouseWheelMove()*scrollSpeed); boxPositionY -= (int)(GetMouseWheelMove()*scrollSpeed);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View file

@ -41,7 +41,7 @@ int main(void) {
int rectCount = 20; int rectCount = 20;
float rectSize = (float)screenWidth/rectCount; float rectSize = (float)screenWidth/rectCount;
ColorRect* rectangles = GenerateRandomColorRectSequence(rectCount, rectSize, screenWidth, 0.75f * screenHeight); ColorRect* rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight);
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -62,7 +62,7 @@ int main(void) {
rectCount++; rectCount++;
rectSize = (float)screenWidth/rectCount; rectSize = (float)screenWidth/rectCount;
free(rectangles); free(rectangles);
rectangles = GenerateRandomColorRectSequence(rectCount, rectSize, screenWidth, 0.75f * screenHeight); rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight);
} }
if(IsKeyPressed(KEY_DOWN)) if(IsKeyPressed(KEY_DOWN))
@ -71,7 +71,7 @@ int main(void) {
rectCount--; rectCount--;
rectSize = (float)screenWidth/rectCount; rectSize = (float)screenWidth/rectCount;
free(rectangles); free(rectangles);
rectangles = GenerateRandomColorRectSequence(rectCount, rectSize, screenWidth, 0.75f * screenHeight); rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight);
} }
} }
@ -121,17 +121,17 @@ static Color GenerateRandomColor()
} }
static ColorRect* GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight){ static ColorRect* GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight){
int *seq = LoadRandomSequence(rectCount, 0, rectCount-1); int *seq = LoadRandomSequence((unsigned int)rectCount, 0, (unsigned int)rectCount-1);
ColorRect* rectangles = (ColorRect *)malloc(rectCount*sizeof(ColorRect)); ColorRect* rectangles = (ColorRect *)malloc((int)rectCount*sizeof(ColorRect));
float rectSeqWidth = rectCount * rectWidth; float rectSeqWidth = rectCount * rectWidth;
int startX = (screenWidth - rectSeqWidth) * 0.5f; float startX = (screenWidth - rectSeqWidth) * 0.5f;
for(int x=0;x<rectCount;x++){ for(int x=0;x<rectCount;x++){
int rectHeight = Remap(seq[x], 0, rectCount-1, 0, screenHeight); int rectHeight = (int)Remap((float)seq[x], 0, rectCount-1, 0, screenHeight);
rectangles[x].c = GenerateRandomColor(); rectangles[x].c = GenerateRandomColor();
rectangles[x].r = CLITERAL(Rectangle){ rectangles[x].r = CLITERAL(Rectangle){
startX + x * rectWidth, screenHeight - rectHeight, rectWidth, rectHeight startX + x * rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight
}; };
} }
UnloadRandomSequence(seq); UnloadRandomSequence(seq);

View file

@ -69,18 +69,18 @@ int main(void)
rotation += 60.0f*GetFrameTime(); // Rotate the rectangles, 60 degrees per second rotation += 60.0f*GetFrameTime(); // Rotate the rectangles, 60 degrees per second
// Make the camera move to demonstrate the effect // Make the camera move to demonstrate the effect
cameraX = (sinf(GetTime())*50.0f) - 10.0f; cameraX = (sinf((float)GetTime())*50.0f) - 10.0f;
cameraY = cosf(GetTime())*30.0f; cameraY = cosf((float)GetTime())*30.0f;
// Set the camera's target to the values computed above // Set the camera's target to the values computed above
screenSpaceCamera.target = (Vector2){ cameraX, cameraY }; screenSpaceCamera.target = (Vector2){ cameraX, cameraY };
// Round worldSpace coordinates, keep decimals into screenSpace coordinates // Round worldSpace coordinates, keep decimals into screenSpace coordinates
worldSpaceCamera.target.x = (int)screenSpaceCamera.target.x; worldSpaceCamera.target.x = truncf(screenSpaceCamera.target.x);
screenSpaceCamera.target.x -= worldSpaceCamera.target.x; screenSpaceCamera.target.x -= worldSpaceCamera.target.x;
screenSpaceCamera.target.x *= virtualRatio; screenSpaceCamera.target.x *= virtualRatio;
worldSpaceCamera.target.y = (int)screenSpaceCamera.target.y; worldSpaceCamera.target.y = truncf(screenSpaceCamera.target.y);
screenSpaceCamera.target.y -= worldSpaceCamera.target.y; screenSpaceCamera.target.y -= worldSpaceCamera.target.y;
screenSpaceCamera.target.y *= virtualRatio; screenSpaceCamera.target.y *= virtualRatio;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -177,7 +177,7 @@ int LoadStorageValue(unsigned int position)
if (fileData != NULL) if (fileData != NULL)
{ {
if (dataSize < (position*4)) TraceLog(LOG_WARNING, "FILEIO: [%s] Failed to find storage position: %i", STORAGE_DATA_FILE, position); if (dataSize < ((int)(position*4))) TraceLog(LOG_WARNING, "FILEIO: [%s] Failed to find storage position: %i", STORAGE_DATA_FILE, position);
else else
{ {
int *dataPtr = (int *)fileData; int *dataPtr = (int *)fileData;

View file

@ -67,7 +67,7 @@ int main(void)
DrawCubeTexture(texture, (Vector3){ -2.0f, 2.0f, 0.0f }, 2.0f, 4.0f, 2.0f, WHITE); DrawCubeTexture(texture, (Vector3){ -2.0f, 2.0f, 0.0f }, 2.0f, 4.0f, 2.0f, WHITE);
// Draw cube with an applied texture, but only a defined rectangle piece of the texture // Draw cube with an applied texture, but only a defined rectangle piece of the texture
DrawCubeTextureRec(texture, (Rectangle){ 0, texture.height/2, texture.width/2, texture.height/2 }, DrawCubeTextureRec(texture, (Rectangle){ 0.0f, texture.height/2.0f, texture.width/2.0f, texture.height/2.0f },
(Vector3){ 2.0f, 1.0f, 0.0f }, 2.0f, 2.0f, 2.0f, WHITE); (Vector3){ 2.0f, 1.0f, 0.0f }, 2.0f, 2.0f, 2.0f, WHITE);
DrawGrid(10, 1.0f); // Draw a grid DrawGrid(10, 1.0f); // Draw a grid

View file

@ -89,6 +89,8 @@ int main()
}; };
// Pick a color with a hue depending on cube position for the rainbow color effect // Pick a color with a hue depending on cube position for the rainbow color effect
// NOTE: This function is quite costly to be done per cube and frame,
// pre-catching the results into a separate array could improve performance
Color cubeColor = ColorFromHSV((float)(((x + y + z)*18)%360), 0.75f, 0.9f); Color cubeColor = ColorFromHSV((float)(((x + y + z)*18)%360), 0.75f, 0.9f);
// Calculate cube size // Calculate cube size

View file

@ -22,15 +22,12 @@ out vec3 fragNormal;
void main() void main()
{ {
// Compute MVP for current instance
mat4 mvpi = mvp*instanceTransform;
// Send vertex attributes to fragment shader // Send vertex attributes to fragment shader
fragPosition = vec3(mvpi*vec4(vertexPosition, 1.0)); fragPosition = vec3(instanceTransform*vec4(vertexPosition, 1.0));
fragTexCoord = vertexTexCoord; fragTexCoord = vertexTexCoord;
//fragColor = vertexColor; //fragColor = vertexColor;
fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0))); fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
// Calculate final vertex position // Calculate final vertex position, note that we multiply mvp by instanceTransform
gl_Position = mvpi*vec4(vertexPosition, 1.0); gl_Position = mvp*instanceTransform*vec4(vertexPosition, 1.0);
} }

View file

@ -281,7 +281,7 @@ int main(void)
.id = gBuffer.positionTexture, .id = gBuffer.positionTexture,
.width = screenWidth, .width = screenWidth,
.height = screenHeight, .height = screenHeight,
}, (Rectangle) { 0, 0, screenWidth, -screenHeight }, Vector2Zero(), RAYWHITE); }, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, Vector2Zero(), RAYWHITE);
DrawText("POSITION TEXTURE", 10, screenHeight - 30, 20, DARKGREEN); DrawText("POSITION TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
} break; } break;
@ -291,7 +291,7 @@ int main(void)
.id = gBuffer.normalTexture, .id = gBuffer.normalTexture,
.width = screenWidth, .width = screenWidth,
.height = screenHeight, .height = screenHeight,
}, (Rectangle) { 0, 0, screenWidth, -screenHeight }, Vector2Zero(), RAYWHITE); }, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, Vector2Zero(), RAYWHITE);
DrawText("NORMAL TEXTURE", 10, screenHeight - 30, 20, DARKGREEN); DrawText("NORMAL TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
} break; } break;
@ -301,7 +301,7 @@ int main(void)
.id = gBuffer.albedoSpecTexture, .id = gBuffer.albedoSpecTexture,
.width = screenWidth, .width = screenWidth,
.height = screenHeight, .height = screenHeight,
}, (Rectangle) { 0, 0, screenWidth, -screenHeight }, Vector2Zero(), RAYWHITE); }, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, Vector2Zero(), RAYWHITE);
DrawText("ALBEDO TEXTURE", 10, screenHeight - 30, 20, DARKGREEN); DrawText("ALBEDO TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
} break; } break;

View file

@ -69,8 +69,8 @@ int main(void)
DrawLineBezier(startPoint, endPoint, 4.0f, BLUE); DrawLineBezier(startPoint, endPoint, 4.0f, BLUE);
// Draw start-end spline circles with some details // Draw start-end spline circles with some details
DrawCircleV(startPoint, CheckCollisionPointCircle(mouse, startPoint, 10.0f)? 14 : 8, moveStartPoint? RED : BLUE); DrawCircleV(startPoint, CheckCollisionPointCircle(mouse, startPoint, 10.0f)? 14.0f : 8.0f, moveStartPoint? RED : BLUE);
DrawCircleV(endPoint, CheckCollisionPointCircle(mouse, endPoint, 10.0f)? 14 : 8, moveEndPoint? RED : BLUE); DrawCircleV(endPoint, CheckCollisionPointCircle(mouse, endPoint, 10.0f)? 14.0f : 8.0f, moveEndPoint? RED : BLUE);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -56,6 +56,10 @@ int main(void)
{ 710.0f, 260.0f }, { 710.0f, 260.0f },
}; };
// Array required for spline bezier-cubic,
// including control points interleaved with start-end segment points
Vector2 pointsInterleaved[3*(MAX_SPLINE_POINTS - 1) + 1] = { 0 };
int pointCount = 5; int pointCount = 5;
int selectedPoint = -1; int selectedPoint = -1;
int focusedPoint = -1; int focusedPoint = -1;
@ -63,7 +67,7 @@ int main(void)
Vector2 *focusedControlPoint = NULL; Vector2 *focusedControlPoint = NULL;
// Cubic Bezier control points initialization // Cubic Bezier control points initialization
ControlPoint control[MAX_SPLINE_POINTS] = { 0 }; ControlPoint control[MAX_SPLINE_POINTS-1] = { 0 };
for (int i = 0; i < pointCount - 1; i++) for (int i = 0; i < pointCount - 1; i++)
{ {
control[i].start = (Vector2){ points[i].x + 50, points[i].y }; control[i].start = (Vector2){ points[i].x + 50, points[i].y };
@ -88,6 +92,9 @@ int main(void)
if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON) && (pointCount < MAX_SPLINE_POINTS)) if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON) && (pointCount < MAX_SPLINE_POINTS))
{ {
points[pointCount] = GetMousePosition(); points[pointCount] = GetMousePosition();
int i = pointCount - 1;
control[i].start = (Vector2){ points[i].x + 50, points[i].y };
control[i].end = (Vector2){ points[i + 1].x - 50, points[i + 1].y };
pointCount++; pointCount++;
} }
@ -114,7 +121,7 @@ int main(void)
if ((splineTypeActive == SPLINE_BEZIER) && (focusedPoint == -1)) if ((splineTypeActive == SPLINE_BEZIER) && (focusedPoint == -1))
{ {
// Spline control point focus and selection logic // Spline control point focus and selection logic
for (int i = 0; i < pointCount; i++) for (int i = 0; i < pointCount - 1; i++)
{ {
if (CheckCollisionPointCircle(GetMousePosition(), control[i].start, 6.0f)) if (CheckCollisionPointCircle(GetMousePosition(), control[i].start, 6.0f))
{ {
@ -185,13 +192,32 @@ int main(void)
} }
else if (splineTypeActive == SPLINE_BEZIER) else if (splineTypeActive == SPLINE_BEZIER)
{ {
// NOTE: Cubic-bezier spline requires the 2 control points of each segnment to be
// provided interleaved with the start and end point of every segment
for (int i = 0; i < (pointCount - 1); i++)
{
pointsInterleaved[3*i] = points[i];
pointsInterleaved[3*i + 1] = control[i].start;
pointsInterleaved[3*i + 2] = control[i].end;
}
pointsInterleaved[3*(pointCount - 1)] = points[pointCount - 1];
// Draw spline: cubic-bezier (with control points) // Draw spline: cubic-bezier (with control points)
for (int i = 0; i < pointCount - 1; i++) DrawSplineBezierCubic(pointsInterleaved, 3*(pointCount - 1) + 1, splineThickness, RED);
/*
for (int i = 0; i < 3*(pointCount - 1); i += 3)
{ {
// Drawing individual segments, not considering thickness connection compensation // Drawing individual segments, not considering thickness connection compensation
DrawSplineSegmentBezierCubic(points[i], control[i].start, control[i].end, points[i + 1], splineThickness, RED); DrawSplineSegmentBezierCubic(pointsInterleaved[i], pointsInterleaved[i + 1], pointsInterleaved[i + 2], pointsInterleaved[i + 3], splineThickness, MAROON);
}
*/
// Every cubic bezier point should have two control points // Draw spline control points
for (int i = 0; i < pointCount - 1; i++)
{
// Every cubic bezier point have two control points
DrawCircleV(control[i].start, 6, GOLD); DrawCircleV(control[i].start, 6, GOLD);
DrawCircleV(control[i].end, 6, GOLD); DrawCircleV(control[i].end, 6, GOLD);
if (focusedControlPoint == &control[i].start) DrawCircleV(control[i].start, 8, GREEN); if (focusedControlPoint == &control[i].start) DrawCircleV(control[i].start, 8, GREEN);
@ -216,7 +242,7 @@ int main(void)
(splineTypeActive != SPLINE_BEZIER) && (splineTypeActive != SPLINE_BEZIER) &&
(i < pointCount - 1)) DrawLineV(points[i], points[i + 1], GRAY); (i < pointCount - 1)) DrawLineV(points[i], points[i + 1], GRAY);
DrawText(TextFormat("[%.0f, %.0f]", points[i].x, points[i].y), points[i].x, points[i].y + 10, 10, BLACK); DrawText(TextFormat("[%.0f, %.0f]", points[i].x, points[i].y), (int)points[i].x, (int)points[i].y + 10, 10, BLACK);
} }
} }
@ -244,4 +270,4 @@ int main(void)
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View file

@ -5345,7 +5345,7 @@
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {
"type": "Vector2 *", "type": "const Vector2 *",
"name": "points" "name": "points"
}, },
{ {
@ -6022,7 +6022,7 @@
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {
"type": "Vector2 *", "type": "const Vector2 *",
"name": "points" "name": "points"
}, },
{ {
@ -6041,7 +6041,7 @@
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {
"type": "Vector2 *", "type": "const Vector2 *",
"name": "points" "name": "points"
}, },
{ {
@ -6145,7 +6145,7 @@
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {
"type": "Vector2 *", "type": "const Vector2 *",
"name": "points" "name": "points"
}, },
{ {
@ -6168,7 +6168,7 @@
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {
"type": "Vector2 *", "type": "const Vector2 *",
"name": "points" "name": "points"
}, },
{ {
@ -6191,7 +6191,7 @@
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {
"type": "Vector2 *", "type": "const Vector2 *",
"name": "points" "name": "points"
}, },
{ {
@ -6214,7 +6214,7 @@
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {
"type": "Vector2 *", "type": "const Vector2 *",
"name": "points" "name": "points"
}, },
{ {
@ -6237,7 +6237,7 @@
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {
"type": "Vector2 *", "type": "const Vector2 *",
"name": "points" "name": "points"
}, },
{ {
@ -6644,7 +6644,7 @@
"name": "point" "name": "point"
}, },
{ {
"type": "Vector2 *", "type": "const Vector2 *",
"name": "points" "name": "points"
}, },
{ {
@ -7351,7 +7351,7 @@
}, },
{ {
"name": "ImageKernelConvolution", "name": "ImageKernelConvolution",
"description": "Apply Custom Square image convolution kernel", "description": "Apply custom square convolution kernel to image",
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {
@ -7359,7 +7359,7 @@
"name": "image" "name": "image"
}, },
{ {
"type": "float*", "type": "const float *",
"name": "kernel" "name": "kernel"
}, },
{ {
@ -7817,6 +7817,33 @@
} }
] ]
}, },
{
"name": "ImageDrawLineEx",
"description": "Draw a line defining thickness within an image",
"returnType": "void",
"params": [
{
"type": "Image *",
"name": "dst"
},
{
"type": "Vector2",
"name": "start"
},
{
"type": "Vector2",
"name": "end"
},
{
"type": "int",
"name": "thick"
},
{
"type": "Color",
"name": "color"
}
]
},
{ {
"name": "ImageDrawCircle", "name": "ImageDrawCircle",
"description": "Draw a filled circle within an image", "description": "Draw a filled circle within an image",
@ -8013,6 +8040,141 @@
} }
] ]
}, },
{
"name": "ImageDrawTriangle",
"description": "Draw triangle within an image",
"returnType": "void",
"params": [
{
"type": "Image *",
"name": "dst"
},
{
"type": "Vector2",
"name": "v1"
},
{
"type": "Vector2",
"name": "v2"
},
{
"type": "Vector2",
"name": "v3"
},
{
"type": "Color",
"name": "color"
}
]
},
{
"name": "ImageDrawTriangleEx",
"description": "Draw triangle with interpolated colors within an image",
"returnType": "void",
"params": [
{
"type": "Image *",
"name": "dst"
},
{
"type": "Vector2",
"name": "v1"
},
{
"type": "Vector2",
"name": "v2"
},
{
"type": "Vector2",
"name": "v3"
},
{
"type": "Color",
"name": "c1"
},
{
"type": "Color",
"name": "c2"
},
{
"type": "Color",
"name": "c3"
}
]
},
{
"name": "ImageDrawTriangleLines",
"description": "Draw triangle outline within an image",
"returnType": "void",
"params": [
{
"type": "Image *",
"name": "dst"
},
{
"type": "Vector2",
"name": "v1"
},
{
"type": "Vector2",
"name": "v2"
},
{
"type": "Vector2",
"name": "v3"
},
{
"type": "Color",
"name": "color"
}
]
},
{
"name": "ImageDrawTriangleFan",
"description": "Draw a triangle fan defined by points within an image (first vertex is the center)",
"returnType": "void",
"params": [
{
"type": "Image *",
"name": "dst"
},
{
"type": "Vector2 *",
"name": "points"
},
{
"type": "int",
"name": "pointCount"
},
{
"type": "Color",
"name": "color"
}
]
},
{
"name": "ImageDrawTriangleStrip",
"description": "Draw a triangle strip defined by points within an image",
"returnType": "void",
"params": [
{
"type": "Image *",
"name": "dst"
},
{
"type": "Vector2 *",
"name": "points"
},
{
"type": "int",
"name": "pointCount"
},
{
"type": "Color",
"name": "color"
}
]
},
{ {
"name": "ImageDraw", "name": "ImageDraw",
"description": "Draw a source image within a destination image (tint applied to source)", "description": "Draw a source image within a destination image (tint applied to source)",
@ -9613,7 +9775,7 @@
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {
"type": "Vector3 *", "type": "const Vector3 *",
"name": "points" "name": "points"
}, },
{ {

Some files were not shown because too many files have changed in this diff Show more