diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 39759dae8..dbbe050d2 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -16,8 +16,13 @@ on: release: types: [published] +permissions: + contents: read + jobs: build: + permissions: + contents: write # for actions/upload-release-asset to upload release asset runs-on: windows-latest strategy: fail-fast: false @@ -62,7 +67,7 @@ jobs: cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include cp -v ./src/raymath.h ./build/${{ env.RELEASE_NAME }}/include cp -v ./src/rlgl.h ./build/${{ env.RELEASE_NAME }}/include - cp -v ./src/extras/raygui.h ./build/${{ env.RELEASE_NAME }}/include + cp -v ./CHANGELOG ./build/${{ env.RELEASE_NAME }}/CHANGELOG cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE cd build diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 6e2b11e81..fc2885a94 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -23,6 +23,9 @@ env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release +permissions: + contents: read + jobs: build_windows: name: Windows Build diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 15109e904..59cbfe334 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -15,8 +15,13 @@ on: release: types: [published] +permissions: + contents: read + jobs: build: + permissions: + contents: write # for actions/upload-release-asset to upload release asset runs-on: ubuntu-latest strategy: fail-fast: false @@ -82,7 +87,7 @@ jobs: cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include cp -v ./src/raymath.h ./build/${{ env.RELEASE_NAME }}/include cp -v ./src/rlgl.h ./build/${{ env.RELEASE_NAME }}/include - cp -v ./src/extras/raygui.h ./build/${{ env.RELEASE_NAME }}/include + cp -v ./CHANGELOG ./build/${{ env.RELEASE_NAME }}/CHANGELOG cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE cd build diff --git a/.github/workflows/linux_examples.yml b/.github/workflows/linux_examples.yml index fc56b4ada..3084af05c 100644 --- a/.github/workflows/linux_examples.yml +++ b/.github/workflows/linux_examples.yml @@ -14,6 +14,9 @@ on: - 'examples/**' - '.github/workflows/linux_examples.yml' +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index c98c3a4dc..e971a8101 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -15,8 +15,13 @@ on: release: types: [published] +permissions: + contents: read + jobs: build: + permissions: + contents: write # for actions/upload-release-asset to upload release asset runs-on: macos-latest env: @@ -67,7 +72,7 @@ jobs: cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include cp -v ./src/raymath.h ./build/${{ env.RELEASE_NAME }}/include cp -v ./src/rlgl.h ./build/${{ env.RELEASE_NAME }}/include - cp -v ./src/extras/raygui.h ./build/${{ env.RELEASE_NAME }}/include + cp -v ./CHANGELOG ./build/${{ env.RELEASE_NAME }}/CHANGELOG cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE cd build diff --git a/.github/workflows/webassembly.yml b/.github/workflows/webassembly.yml index 9b15c34e9..b5d2ba6ca 100644 --- a/.github/workflows/webassembly.yml +++ b/.github/workflows/webassembly.yml @@ -60,7 +60,7 @@ jobs: copy /Y .\src\raylib.h .\build\${{ env.RELEASE_NAME }}\include\raylib.h copy /Y .\src\raymath.h .\build\${{ env.RELEASE_NAME }}\include\raymath.h copy /Y .\src\rlgl.h .\build\${{ env.RELEASE_NAME }}\include\rlgl.h - copy /Y .\src\extras\raygui.h .\build\${{ env.RELEASE_NAME }}\include\raygui.h + copy /Y .\CHANGELOG .\build/${{ env.RELEASE_NAME }}\CHANGELOG copy /Y .\README.md .\build\${{ env.RELEASE_NAME }}\README.md copy /Y .\LICENSE .\build\${{ env.RELEASE_NAME }}\LICENSE cd build diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 34d2db5fc..d7d59b6aa 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -15,8 +15,13 @@ on: release: types: [published] +permissions: + contents: read + jobs: build: + permissions: + contents: write # for actions/upload-release-asset to upload release asset runs-on: windows-latest strategy: fail-fast: false @@ -104,7 +109,7 @@ jobs: copy /Y .\src\raylib.h .\build\${{ env.RELEASE_NAME }}\include\raylib.h copy /Y .\src\raymath.h .\build\${{ env.RELEASE_NAME }}\include\raymath.h copy /Y .\src\rlgl.h .\build\${{ env.RELEASE_NAME }}\include\rlgl.h - copy /Y .\src\extras\raygui.h .\build\${{ env.RELEASE_NAME }}\include\raygui.h + copy /Y .\CHANGELOG .\build\${{ env.RELEASE_NAME }}\CHANGELOG copy /Y .\README.md .\build\${{ env.RELEASE_NAME }}\README.md copy /Y .\LICENSE .\build\${{ env.RELEASE_NAME }}\LICENSE cd build diff --git a/.github/workflows/windows_examples.yml b/.github/workflows/windows_examples.yml index 0309a5661..136273991 100644 --- a/.github/workflows/windows_examples.yml +++ b/.github/workflows/windows_examples.yml @@ -14,6 +14,9 @@ on: - 'examples/**' - '.github/workflows/windows_examples.yml' +permissions: + contents: read + jobs: build: runs-on: windows-latest diff --git a/BINDINGS.md b/BINDINGS.md index fb0938c05..320e0a9d6 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -31,9 +31,9 @@ Some people ported raylib to other languages in form of bindings or wrappers to | node-raylib | **4.0** | [Node.js](https://nodejs.org/en/) | Zlib | https://github.com/RobLoach/node-raylib | | raylib-php | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib | https://github.com/joseph-montanez/raylib-php | | raylib-phpcpp | 3.5 | [PHP](https://en.wikipedia.org/wiki/PHP) | Zlib | https://github.com/oraoto/raylib-phpcpp | -| raylib-factor | 3.5 | [Factor](https://factorcode.org/) | MIT | https://github.com/ArnautDaniel/raylib-factor | +| raylib-factor | **4.0** | [Factor](https://factorcode.org/) | BSD | https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor | | gforth-raylib | 3.5 | [Gforth](https://gforth.org/) | MIT | https://github.com/ArnautDaniel/gforth-raylib | -| hxRaylib | 4.0 | [Haxe](https://haxe.org/) | Zlib | https://github.com/ForeignSasquatch/hxRaylib | +| raylib-hx | 4.0 | [Haxe](https://haxe.org/) | Zlib | https://github.com/foreignsasquatch/raylib-hx | | raylib-wren | **4.0** | [Wren](http://wren.io/) | ISC | https://github.com/TSnake41/raylib-wren | | raylib_odin_bindings | 4.0-dev | [Odin](https://odin-lang.org/) | MIT | https://github.com/Deathbat2190/raylib_odin_bindings | | raylib-odin | **4.0** | [Odin](https://odin-lang.org/) | BSD-3Clause | https://github.com/odin-lang/Odin/tree/master/vendor/raylib | @@ -44,13 +44,16 @@ Some people ported raylib to other languages in form of bindings or wrappers to | Relib | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | ? | https://github.com/RedCubeDev-ByteSpace/Relib | | rayex | 3.7 | [elixir](https://elixir-lang.org/) | Apache-2.0 | https://github.com/shiryel/rayex | | kaylib | 3.7 | [Kotlin/native](https://kotlinlang.org) | ? | https://github.com/electronstudio/kaylib | -| dlang_raylib | 3.7 | [D](https://dlang.org) | ? |https://github.com/rc-05/dlang_raylib | +| dlang_raylib | **4.0** | [D](https://dlang.org) | MPL-2.0 |https://github.com/rc-05/dlang_raylib | | raylib-freebasic | **4.0** | [FreeBASIC](https://www.freebasic.net/) | MIT | https://github.com/WIITD/raylib-freebasic | | raylib-cr | **4.0** | [Crystal](https://crystal-lang.org/) | Apache-2.0 | https://github.com/sol-vin/raylib-cr | | dart-raylib | **4.0** | [Dart](https://dart.dev/) | MIT | https://gitlab.com/wolfenrain/dart-raylib | | raylib-scopes | auto | [Scopes](http://scopes.rocks) | MIT | https://github.com/salotz/raylib-scopes | | raylib-smallBasic | 4.1-dev | [SmallBASIC](https://github.com/smallbasic/SmallBASIC) | GPLv3 | https://github.com/smallbasic/smallbasic.plugins/tree/master/raylib | | raylib-zig | **4.0** | [Zig](https://ziglang.org/) | MIT | https://github.com/Not-Nik/raylib-zig | +| raylib.zig | **4.1-dev** | [Zig](https://ziglang.org/) | MIT | https://github.com/ryupold/raylib.zig | +| racket-raylib | **4.0** | [Racket](https://racket-lang.org/) | MIT/Apache-2.0 | https://github.com/eutro/racket-raylib | +| cl-raylib | **4.0** | [Common Lisp](https://common-lisp.net/) | MIT | https://github.com/longlene/cl-raylib | ### Utility Wrapers These are utility wrappers for specific languages, they are not required to use raylib in the language but may adapt the raylib API to be more inline with the language's pardigm. @@ -101,14 +104,13 @@ These are older raylib bindings that are more than 2 versions old or have not be | raylib-php-ffi | 2.4-dev | [PHP](https://en.wikipedia.org/wiki/PHP) | https://github.com/oraoto/raylib-php-ffi | | raylib-haxe | 2.4 | [Haxe](https://haxe.org/) | https://github.com/ibilon/raylib-haxe | | ringraylib | 2.6 | [Ring](http://ring-lang.sourceforge.net/) | https://github.com/ringpackages/ringraylib | -| cl-raylib | 3.0 | [Common Lisp](https://common-lisp.net/) | https://github.com/longlene/cl-raylib | | raylib-scm | 2.5 | [Chicken Scheme](https://www.call-cc.org/) | https://github.com/yashrk/raylib-scm | | raylib-chibi | 2.5 | [Chibi-Scheme](https://github.com/ashinn/chibi-scheme) | https://github.com/VincentToups/raylib-chibi | | raylib-gambit-scheme | 3.1-dev | [Gambit Scheme](https://github.com/gambit/gambit) | https://github.com/georgjz/raylib-gambit-scheme | | Euraylib | 3.0 | [Euphoria](https://openeuphoria.org/) | https://github.com/gAndy50/Euraylib | | raylib-odin | 3.0 | [Odin](https://odin-lang.org/) | https://github.com/kevinw/raylib-odin | | vraylib | 3.5 | [V](https://vlang.io/) | https://github.com/waotzi/vraylib | -| raylib-jai | 3.1-dev | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | https://github.com/kevinw/raylib-jai | +| raylib-jai | 3.1-dev | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | https://github.com/kujukuju/raylib-jai | | ray.zig | 2.5 | [Zig](https://ziglang.org/) | https://github.com/BitPuffin/zig-raylib-experiments | | raylib-Ada | 3.0 | [Ada](https://www.adacore.com/about-ada) | https://github.com/mimo/raylib-Ada | | jaylib | 3.0 | [Janet](https://janet-lang.org/) | https://github.com/janet-lang/jaylib | diff --git a/CHANGELOG b/CHANGELOG index dd54f2d6d..9623780e9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,11 +3,191 @@ changelog Current Release: raylib 4.0.0 (05 November 2021) +------------------------------------------------------------------------- +Release: raylib 4.2 (July 2022) +------------------------------------------------------------------------- +KEY CHANGES: + - rres 1.0 + - raygui 3.2 + - raylib_parser... + - REMOVED extras libraries + +Detailed changes: +[multi] REVIEWED: Multiple trace log messages +[multi] REVIEWED: Avoid some float to double promotions +[multi] REVIEWED: Some functions input parametes that should be const +[multi] REVIEWED: Variables initialization, all variables are initialized on declaration +[multi] REVIEWED: Static array buffers are always re-initialized with memset() +[multi] `WARNING`: RENAMED: Some function input parameters from "length" to "size" +[core] ADDED: GetApplicatonDirectory() (#2256, #2285, #2290) by @JeffM2501 +[core] ADDED: raylibVersion symbol, it could be required by some bindings (#2190) +[core] ADDED: SetWindowOpacity() (#2254) by @tusharsingh09 +[core] ADDED: GetRenderWidth() and GetRenderHeight() by @ArnaudValensi +[core] ADDED: EnableEventWaiting() and DisableEventWaiting() +[core] ADDED: GetFileLength() +[core] ADDED: Modules info at initialization +[core] ADDED: Support clipboard copy/paste on web +[core] ADDED: Support OpenURL() on Android platform (#2396) by @futureapricot +[core] ADDED: Support MOUSE_PASSTHROUGH (#2516) +[core] ADDED: GetMouseWheelMoveV() (#2517) by @schveiguy +[core] `WARNING`: RENAMED: GetDirectoryFiles() to LoadDirectoryFiles() +[core] `WARNING`: RENAMED: `ClearDroppedFiles()` to `UnloadDroppedFiles()` +[core] `WARNING`: RENAMED: GetDroppedFiles() to LoadDroppedFiles() +[core] `WARNING`: RENAMED: `ClearDirectoryFiles()` to `UnloadDirectoryFiles()` +[core] `WARNING`: REDESIGNED: WaitTime() argument from milliseconds to seconds (#2506) by @flashback-fx +[core] REVIEWED: GetMonitorWidth()/GetMonitorHeight() by @gulrak +[core] REVIEWED: GetDirectoryFiles(), maximum files allocation (#2126) by @ampers0x26 +[core] REVIEWED: Expose MAX_KEYBOARD_KEYS and MAX_MOUSE_BUTTONS (#2127) +[core] REVIEWED: ExportMesh() (#2138) +[core] REVIEWED: Fullscreen switch on PLATFORM_WEB +[core] REVIEWED: GetMouseWheelMove(), fixed bug +[core] REVIEWED: GetApplicationDirectory() on macOS (#2304) +[core] REVIEWED: ToggleFullscreen() +[core] REVIEWED: Initialize/reset CORE.inputs global state (#2360) +[core] REVIEWED: MouseScrollCallback() (#2371) +[core] REVIEWED: SwapScreenBuffers() for PLATFORM_DRM +[core] REVIEWED: WaitTime(), fix regression causing video stuttering (#2503) by @flashback-fx +[core] REVIEWED: Mouse device support on PLATFORM_DRM (#2381) +[core] REVIEWED: Support OpenBSD timming functions +[core] REVIEWED: Improved boolean definitions (#2485) by @noodlecollie +[core] REVIEWED: TakeScreenshot(), use GetWindowScaleDPI() to calculate size in screenshot/recording (#2446) by @gulrak +[core] REVIEWED: Remove fps requirement for drm connector selection (#2468) by @Crydsch +[core] REVIEWED: IsFileExtension() #2530 +[rlgl] ADDED: Premultiplied alpha blend mode (#2342) by @megagrump +[rlgl] REVIEWED: VR rendering not taking render target size into account (#2424) by @FireFlyForLife +[rlgl] REVIEWED: Set rlgl internal framebuffer (#2420) +[rlgl] REVIEWED: rlGetCompressedFormatName() +[rlgl] REVIEWED: Display OpenGL 4.3 capabilities with a compile flag (#2124) by @GithubPrankster +[rlgl] REVIEWED: rlUpdateTexture() +[rlgl] REVIEWED: Minimize buffer overflow probability +[rlgl] REVIEWED: Fix scissor mode on macOS (#2170) by @ArnaudValensi +[rlgl] REVIEWED: Clear SSBO buffers on loading (#2185) +[rlgl] REVIEWED: rlLoadShaderCode(), improved shader loading code +[rlgl] REVIEWED: Comment notes about custom blend modes (#2260) by @glorantq +[rlgl] REVIEWED: rlGenTextureMipmaps() +[rlgl] REVIEWED: rlTextureParameters() +[raymath] ADDED: Wrap() (#2522) by @Tekkitslime +[raymath] ADDED: Vector2Transform() +[raymath] ADDED: Vector2DistanceSqr() (#2376) by @AnilBK +[raymath] ADDED: Vector3DistanceSqr() (#2376) by @AnilBK +[raymath] ADDED: Vector2ClampValue(), Vector3ClampValue() (#2428) by @saccharineboi +[raymath] `WARNING`: REDESIGNED: Vector2Angle() returns radians instead of degrees (#2193) by @schveiguy +[raymath] `WARNING`: REMOVED: MatrixNormalize() (#2412) +[raymath] REVIEWED: Fix inverse length in Vector2Normalize() (#2189) by @HarriP +[raymath] REVIEWED: Vector2Angle() not working as expected (#2196) by @jdeokkim +[raymath] REVIEWED: Vector2Angle() and Vector3Angle() (#2203) by @trikko +[raymath] REVIEWED: QuaternionInvert(), code simplified (#2324) by @megagrump +[raymath] REVIEWED: QuaternionScale() (#2419) by @tana +[raymath] REVIEWED: Vector2Rotate(), optimized (#2340) by @jdeokkim +[shapes] REVIEWED: CheckCollision*() consistency +[shapes] REVIEWED: DrawRectanglePro(), support TRIANGLES drawing +[textures] ADDED: Support for QOI image format +[textures] REVIEWED: ImageColorTint(), GetImageColor(), ImageDrawRectangleRec(), optimized functions (#2429) by @AnilBK +[textures] REVIEWED: LoadTextureFromImage(), allow texture loading with no data transfer +[textures] REVIEWED: ImageDraw(), comment to note that f32bit is not supported (#2222) +[textures] REVIEWED: DrawTextureNPatch(), avoid batch overflow (#2401) by @JeffM2501 +[textures] REVIEWED: DrawTextureTiled() (#2173) +[textures] REVIEWED: GenImageCellular() (#2178) +[textures] REVIEWED: LoadTextureCubemap() (#2223, #2224) +[textures] REVIEWED: Export format for float 32bit +[textures] REVIEWED: ExportImage(), support export ".jpeg" files +[textures] REVIEWED: ColorAlphaBlend() (#2524) by @royqh1979 +[text] ADDED: ExportFontAsCode() +[text] ADDED: DrawTextCodepoints() (#2308) by @siddharthroy12 +[text] REVIEWED: TextIsEqual(), protect from NULLs (#2121) by @lukekras +[text] REVIEWED: LoadFontEx(), comment to specify how to get the default character set (#2221) by @JeffM2501 +[text] REVIEWED: GenImageFontAtlas(), increase atlas size guesstimate by @megagrump +[text] REVIEWED: GetCodepoint() (#2201) +[text] REVIEWED: ExportFontAsCode() to use given font padding (#2525) by @TheTophatDemon +[models] ADDED: Reference code to load bones id and weight data for animations +[models] `WARNING`: REMOVED: GetRayCollisionModel() (#2405) +[models] REVIEWED: External library: vox_loader.h, 64bit issue (#2186) +[models] REVIEWED: Material color loading when no texture material is available (#2298) by @royqh1979 +[models] REVIEWED: Fix Undefined Symbol _ftelli64 in cgltf (#2319) by @audinue +[models] REVIEWED: LoadGLTF(), fix memory leak (#2441, #2442) by @leomonta +[models] REVIEWED: DrawTriangle3D() batch limits check (#2489) +[models] REVIEWED: DrawBillboardPro() (#2494) +[models] REVIEWED: DrawMesh*() issue (#2211) +[models] REVIEWED: ExportMesh() (#2220) +[models] REVIEWED: GenMeshCylinder() (#2225) +[audio] `WARNING`: ADDED: rAudioProcessor pointer to AudioStream struct (used by Sound and Music structs) +[audio] ADDED: SetSoundPan(), SetMusicPan(), SetAudioStreamPan(), panning support (#2205) by ptarabbia +[audio] ADDED: Audio stream input callback (#2212) by ptarabbia +[audio] ADDED: Audio stream processors support (#2212) by ptarabbia +[audio] REVIEWED: GetMusicTimePlayed(), incorrect value after the stream restarted for XM audio (#2092 #2215) by @ptarabbia +[audio] REVIEWED: Turn on interpolation for XM playback (#2216) by @ptarabbia +[audio] REVIEWED: Fix crash with delay example (#2472) by @ptarabbia +[audio] REVIEWED: PlaySoundMulti() (#2231) +[audio] REVIEWED: ExportWaveAsCode() +[audio] REVIEWED: UpdateMusicStream(), reduce dynamic allocations (#2532) by @dbechrd +[utils] ADDED: ExportDataAsCode() +[utils] REVIEWED: Force flush stdout after trace messages (#2465) by @nagy +[easings] ADDED: Function descriptions (#2471) by @RobLoach +[camera] REVIEWED: Fix free camera panning in the wrong direction (#2347) by @DavidLyhedDanielsson +[examples] ADDED: shapes_top_down_lights (#2199) by JeffM2501 +[examples] REVIEWED: core_input_gamepad, improve joystick visualisation (#2390) by @kristianlm +[examples] REVIEWED: textures_draw_tiled +[examples] REVIEWED: shaders_mesh_instancing, free allocated matrices (#2425) by @AnilBK +[examples] REVIEWED: shaders_raymarching +[examples] REVIEWED: audio_raw_stream (#2205) by ptarabbia +[examples] REVIEWED: audio_music_stream +[examples] REVIEWED: shaders_mesh_instancing, simplified +[examples] REVIEWED: shaders_basic_lighting, rlights.h simplified +[parser] ADDED: Defines to parser (#2269) by @iskolbin +[parser] ADDED: Aliases to parser (#2444) by @lazaray +[parser] ADDED: Parse struct descriptions (#2214) by @eutro +[parser] ADDED: Parse enum descriptions and value descriptions (#2208) by @eutro +[parser] ADDED: Lua output format for parser by @iskolbin +[parser] ADDED: Makefile for raylib_parser by @iskolbin +[parser] ADDED: Support for truncating parser input (#2464) by @lazaray +[parser] ADDED: Support for calculated defines to parser (#2463) by @lazaray +[parser] REVIEWED: Update parser files (#2125) by @catmanl +[parser] REVIEWED: Fix memory leak in parser (#2136) by @ronnieholm +[parser] REVIEWED: EscapeBackslashes() +[parser] REVIEWED: Parser improvements (#2461 #2462) by @lazaray +[bindings] ADDED: License details for BINDINGS +[bindings] ADDED: dart-raylib (#2149) by @wolfenrain +[bindings] ADDED: raylib-cslo (#2169) by @jasonswearingen +[bindings] ADDED: raylib-d (#2194) by @schveiguy +[bindings] ADDED: raylib-guile (#2202) by @petelliott +[bindings] ADDED: raylib-scopes (#2238) by @salotz +[bindings] ADDED: naylib (Nim) (#2386) by @planetis-m +[bindings] ADDED: raylib.jl (Julia) (#2403) by @irishgreencitrus +[bindings] ADDED: raylib.zig (#2449) by @ryupold +[bindings] ADDED: racket-raylib (#2454) by @eutro +[bindings] REVIEWED: Multiple bindings updated to raylib 4.0 +[build] ADDED: VS2022 project +[build] ADDED: Support macOS by zig build system (#2175) +[build] ADDED: Support custom modules selection on compilation +[build] ADDED: Minimal web shell for WebAssembly compilation +[build] ADDED: BSD support for zig builds (#2332) by @zigster64 +[build] ADDED: Repology badge (#2367) by @jubalh +[build] REVIEWED: Fixed RPi make install (#2217) by @wereii +[build] REVIEWED: Fix build results path on Linux and RPi (#2218) by @wereii +[build] REVIEWED: Makefiles debug flag +[build] REVIEWED: Fixed cross-compilation from x86-64 to RPi (#2233) by @pitpit +[build] REVIEWED: All Makefiles, simplified +[build] REVIEWED: All Makefiles, improve organization +[build] REVIEWED: All Makefiles, support CUSTOM_CFLAGS +[build] REVIEWED: Fixed compiling for Android using CMake (#2270) by @hero2002 +[build] REVIEWED: Make zig build functionality available to zig programs (#2271) by @Not-Nik +[build] REVIEWED: Update CMake project template with docs and web (#2274) by @RobLoach +[build] REVIEWED: Update VSCode project to work with latest makefile and web (#2296) by @phil-shenk +[build] REVIEWED: Support audio examples compilation with external glfw (#2329) by @locriacyber +[build] REVIEWED: Fix "make clean" target failing when shell is not cmd (#2338) by @Peter0x44 +[build] REVIEWED: Makefile linkage -latomic, required by miniaudio on ARM 32bit #2452 +[build] REVIEWED: Update raylib-config.cmake (#2374) by @marcogmaia +[build] REVIEWED: Simplify build.zig to not require user to specify raylib path (#2383) by @Hejsil +[build] REVIEWED: Fix OpenGL 4.3 graphics option in CMake (#2427) by @GoldenThumbs +[misc] `WARNING`: REMOVED: physac from raylib sources/examples, use github.com/raysan5/physac +[misc] `WARNING`: REMOVED: raygui from raylib/src/extras, use github.com/raysan5/raygui +[misc] REVIEWED: Update external libraries to latest version released + ------------------------------------------------------------------------- Release: raylib 4.0 - 8th Anniversary Edition (05 November 2021) ------------------------------------------------------------------------- KEY CHANGES: - - Naming consistency and coherency: Complete review of the library: sintax, naming, comments, decriptions, logs... + - Naming consistency and coherency: Complete review of the library: syntax, naming, comments, decriptions, logs... - Event Automation System: Support for input events recording and automatic re-playing, useful for automated testing and more! - Custom game-loop control: Intended for advance users that want to control the events polling and the timming mechanisms - rlgl 4.0: Completely decoupling from platform layer and raylib, intended for standalone usage as single-file header-only diff --git a/CONVENTIONS.md b/CONVENTIONS.md index e47a1e841..37db230e5 100644 --- a/CONVENTIONS.md +++ b/CONVENTIONS.md @@ -19,7 +19,7 @@ Operators | value1 - value2 | `int res = value - 5;` Enum | TitleCase | `enum TextureFormat` Enum members | ALL_CAPS | `PIXELFORMAT_UNCOMPRESSED_R8G8B8` Struct | TitleCase | `struct Texture2D`, `struct Material` -Struct members |lowerCase | `texture.width`, `color.r` +Struct members | lowerCase | `texture.width`, `color.r` Functions | TitleCase | `InitWindow()`, `LoadImageFromMemory()` Functions params | lowerCase | `width`, `height` Ternary Operator | (condition)? result1 : result2 | `printf("Value is 0: %s", (value == 0)? "yes" : "no");` @@ -52,7 +52,7 @@ switch (value) ``` - All conditions checks are **always between parenthesis** but not boolean values: ```c -if ((value > 1) && (value < 50) && valueActive)) +if ((value > 1) && (value < 50) && valueActive) { } @@ -92,4 +92,3 @@ resources/characters/enemy_slime.png resources/common/font_arial.ttf resources/common/gui.png ``` - diff --git a/README.md b/README.md index 34677a7ae..df5b5b984 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ raylib is also available via multiple [package managers](https://github.com/rays - [Working for Web (HTML5)](https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5)) - [Working anywhere with CMake](https://github.com/raysan5/raylib/wiki/Working-with-CMake) -*Note that Wiki is open for edit, if you find some issue while building raylib for your target platform, feel free to edit the Wiki or open and issue related to it.* +*Note that the Wiki is open for edit, if you find some issues while building raylib for your target platform, feel free to edit the Wiki or open an issue related to it.* #### Setup raylib with multiple IDEs @@ -109,14 +109,14 @@ raylib has been developed on Windows platform using [Notepad++](https://notepad- [Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs. -*Note that there are lots of IDEs supported, some of the provided templates could require some review, please, if you find some issue with some template or you think they could be improved, feel free to send a PR or open a related issue.* +*Note that there are lots of IDEs supported, some of the provided templates could require some review, so please, if you find some issue with a template or you think they could be improved, feel free to send a PR or open a related issue.* learning and docs ------------------ -raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library and a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works. +raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works. -Some additional documentation about raylib design can be found in raylib GitHub Wiki. Here the more relevant links: +Some additional documentation about raylib design can be found in raylib GitHub Wiki. Here are the relevant links: - [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html) - [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture) diff --git a/ROADMAP.md b/ROADMAP.md index 724ad5fee..879b8dd80 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,19 +1,19 @@ # raylib roadmap -Here it is a wish-list with features and ideas to improve the library. Note that features listed here are usually long term improvements or just describe a route to follow for the library. There are also some additional places to look for raylib improvements of ideas: +Here it is a wishlist with features and ideas to improve the library. Note that features listed here are usually long term improvements or just describe a route to follow for the library. There are also some additional places to look for raylib improvements and ideas: - [GitHub Issues](https://github.com/raysan5/raylib/issues) has several open issues for possible improvements or bugs to fix. - [raylib source code](https://github.com/raysan5/raylib/tree/master/src) has multiple *TODO* comments around code with pending things to review or improve. - - [raylib wishlist](https://github.com/raysan5/raylib/discussions/1502) is open to everyone to ask for improvements, feel free to check and comment. + - raylib wishlists discussions (https://github.com/raysan5/raylib/discussions/1502, https://github.com/raysan5/raylib/discussions/2272) are open to everyone to ask for improvements, feel free to check and comment. -_Current version of raylib is complete and functional but, as always, there is lot of room for improvement._ +_Current version of raylib is complete and functional but there is always room for improvements._ **raylib 4.x** - - [ ] Redesign camera module (more flexible) ([#1143](https://github.com/raysan5/raylib/issues/1143)) + - [ ] Redesign camera module (more flexible) ([#1143](https://github.com/raysan5/raylib/issues/1143), https://github.com/raysan5/raylib/discussions/2507) - [ ] Redesign gestures system, improve touch inputs management - [ ] Better documentation and improved examples - - [ ] Focus on HTML5 and embedded platforms - - [ ] Additional support libraries: [raygui](https://github.com/raysan5/raygui), [rres](https://github.com/raysan5/rres)... + - [ ] Focus on HTML5 ([raylib 5k gamejam](https://itch.io/jam/raylib-5k-gamejam)) and embedded platforms (RPI and similar SOCs) + - [x] Additional support libraries: [raygui](https://github.com/raysan5/raygui), [rres](https://github.com/raysan5/rres) **raylib 4.0** - [x] Improved consistency and coherency in raylib API diff --git a/cmake/GlfwImport.cmake b/cmake/GlfwImport.cmake index 1b94cdf80..d0c23ca52 100644 --- a/cmake/GlfwImport.cmake +++ b/cmake/GlfwImport.cmake @@ -28,6 +28,8 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT list(APPEND raylib_sources $) include_directories(BEFORE SYSTEM external/glfw/include) +elseif("${PLATFORM}" STREQUAL "DRM") + MESSAGE(STATUS "No GLFW required on PLATFORM_DRM") else() MESSAGE(STATUS "Using external GLFW") set(GLFW_PKG_DEPS glfw3) diff --git a/cmake/LibraryConfigurations.cmake b/cmake/LibraryConfigurations.cmake index 105b502e2..7d7d4c8c0 100644 --- a/cmake/LibraryConfigurations.cmake +++ b/cmake/LibraryConfigurations.cmake @@ -27,7 +27,7 @@ if (${PLATFORM} MATCHES "Desktop") find_library(OSS_LIBRARY ossaudio) endif () - set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY}) + set(LIBS_PRIVATE m atomic pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY}) if (USE_AUDIO) set(LIBS_PRIVATE ${LIBS_PRIVATE} dl) @@ -44,7 +44,7 @@ elseif (${PLATFORM} MATCHES "Android") set(PLATFORM_CPP "PLATFORM_ANDROID") set(GRAPHICS "GRAPHICS_API_OPENGL_ES2") set(CMAKE_POSITION_INDEPENDENT_CODE ON) - set(raylib_sources "${raylib_sources} ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c") + list(APPEND raylib_sources ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) add_definitions(-DANDROID -D__ANDROID_API__=21) include_directories(${ANDROID_NDK}/sources/android/native_app_glue) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -u ANativeActivity_onCreate -Wl,-undefined,dynamic_lookup") @@ -81,7 +81,7 @@ elseif (${PLATFORM} MATCHES "DRM") if (NOT CMAKE_CROSSCOMPILING) include_directories(/usr/include/libdrm) endif () - set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} pthread m dl) + set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} atomic pthread m dl) endif () diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6ade96861..e2ef87422 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -106,6 +106,11 @@ elseif (${PLATFORM} MATCHES "Web") # does not generate HTML+JS+WASM files, only a non-working # and fat HTML string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}") + +elseif (${PLATFORM} STREQUAL "DRM") + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c) + endif () include_directories(BEFORE SYSTEM others/external/include) diff --git a/examples/Makefile b/examples/Makefile index 50a12e5c1..9fe9b1ae2 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -226,9 +226,9 @@ ifeq ($(PLATFORM),PLATFORM_DRM) endif # Define include paths for required headers: INCLUDE_PATHS -# NOTE: Some external/extras libraries could be required (stb, physac, easings...) +# NOTE: Some external/extras libraries could be required (stb, easings...) #------------------------------------------------------------------------------------------------ -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras +INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external # Define additional directories containing required header files ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -306,8 +306,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # Libraries for Windows desktop compilation # NOTE: WinMM library required to set high-res timer resolution LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread endif ifeq ($(PLATFORM_OS),LINUX) # Libraries for Debian GNU/Linux desktop compiling @@ -349,7 +347,7 @@ endif ifeq ($(PLATFORM),PLATFORM_RPI) # Libraries for Raspberry Pi compiling # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl + LDLIBS = -lraylib -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl -latomic ifeq ($(USE_RPI_CROSS_COMPILER),TRUE) LDLIBS += -lvchiq_arm -lvcos endif @@ -357,7 +355,7 @@ endif ifeq ($(PLATFORM),PLATFORM_DRM) # Libraries for DRM compiling # NOTE: Required packages: libasound2-dev (ALSA) - LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl + LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic endif ifeq ($(PLATFORM),PLATFORM_WEB) # Libraries for web (HTML5) compiling @@ -494,20 +492,12 @@ AUDIO = \ audio/audio_sound_loading \ audio/audio_multichannel_sound -PHYSICS = \ - physics/physics_demo \ - physics/physics_friction \ - physics/physics_movement \ - physics/physics_restitution \ - physics/physics_shatter - - CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST)) # Define processes to execute #------------------------------------------------------------------------------------------------ # Default target entry -all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(PHYSICS) +all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) core: $(CORE) shapes: $(SHAPES) @@ -516,7 +506,6 @@ text: $(TEXT) models: $(MODELS) shaders: $(SHADERS) audio: $(AUDIO) -physics: $(PHYSICS) # Generic compilation pattern # NOTE: Examples must be ready for Android compilation! diff --git a/examples/Makefile.Web b/examples/Makefile.Web index 642527d17..4ee6652c3 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -238,8 +238,8 @@ ifeq ($(PLATFORM),PLATFORM_DRM) endif # Define include paths for required headers -# NOTE: Some external/extras libraries could be required (stb, physac, easings...) -INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras +# NOTE: Some external/extras libraries could be required (stb, easings...) +INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external # Define additional directories containing required header files ifeq ($(PLATFORM),PLATFORM_RPI) @@ -324,8 +324,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # Libraries for Windows desktop compilation # NOTE: WinMM library required to set high-res timer resolution LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - LDLIBS += -static -lpthread endif ifeq ($(PLATFORM_OS),LINUX) # Libraries for Debian GNU/Linux desktop compiling @@ -508,17 +506,10 @@ AUDIO = \ audio/audio_sound_loading \ audio/audio_multichannel_sound -PHYSICS = \ - physics/physics_demo \ - physics/physics_friction \ - physics/physics_movement \ - physics/physics_restitution \ - physics/physics_shatter - CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST)) # Default target entry -all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(PHYSICS) +all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) core: $(CORE) shapes: $(SHAPES) @@ -527,7 +518,6 @@ text: $(TEXT) models: $(MODELS) shaders: $(SHADERS) audio: $(AUDIO) -physics: $(PHYSICS) # Compile CORE examples core/core_basic_window: core/core_basic_window.c @@ -1007,23 +997,6 @@ audio/audio_multichannel_sound: audio/audio_multichannel_sound.c --preload-file audio/resources/sound.wav@resources/sound.wav \ --preload-file audio/resources/target.ogg@resources/target.ogg -# Compile PHYSICS examples -physics/physics_demo: physics/physics_demo.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -DPHYSAC_AVOID_TIMMING_SYSTEM - -physics/physics_friction: physics/physics_friction.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -DPHYSAC_AVOID_TIMMING_SYSTEM - -physics/physics_movement: physics/physics_movement.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -DPHYSAC_AVOID_TIMMING_SYSTEM - -physics/physics_restitution: physics/physics_restitution.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -DPHYSAC_AVOID_TIMMING_SYSTEM - -physics/physics_shatter: physics/physics_shatter.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -DPHYSAC_AVOID_TIMMING_SYSTEM - - # Clean everything clean: ifeq ($(PLATFORM),PLATFORM_DESKTOP) diff --git a/examples/README.md b/examples/README.md index 4fffb462e..3a54629ff 100644 --- a/examples/README.md +++ b/examples/README.md @@ -138,7 +138,6 @@ Examples using raylib models functionality, including models loading/generation | 82 | [models_yaw_pitch_roll](models/models_yaw_pitch_roll.c) | models_yaw_pitch_roll | [Berni](https://github.com/Berni8k) | ⭐️ | | 83 | [models_heightmap](models/models_heightmap.c) | models_heightmap | ray | | | 84 | [models_waving_cubes](models/models_waving_cubes.c) | models_waving_cubes | [codecat](https://github.com/codecat) | | -| -- | [models_gltf_model](models/models_gltf_model.c) | models_gltf_model | [object71](https://github.com/object71) | ⭐️ | ### category: shaders @@ -176,18 +175,6 @@ Examples using raylib audio functionality, including sound/music loading and pla | 105 | [audio_sound_loading](audio/audio_sound_loading.c) | audio_sound_loading | ray | | | 106 | [audio_multichannel_sound](audio/audio_multichannel_sound.c) | audio_multichannel_sound | [Chris Camacho](https://github.com/codifies) | ⭐️ | -### category: physics - -Examples showing physics functionality with raylib. This functionality is provided by [physac](https://github.com/victorfisac/Physac) library, included with raylib [sources](../src/physac.h). Note this library is not linked with raylib by default, it should be manually included in user code. - -| ## | example | image | developer | new | -|----|----------|--------|:----------:|:---:| -| 107 | [physics_demo](physics/physics_demo.c) | physics_demo | [Victor Fisac](https://github.com/victorfisac) | | -| 108 | [physics_friction](physics/physics_friction.c) | physics_friction | [Victor Fisac](https://github.com/victorfisac) | | -| 109 | [physics_movement](physics/physics_movement.c) | physics_movement | [Victor Fisac](https://github.com/victorfisac) | | -| 110 | [physics_restitution](physics/physics_restitution.c) | physics_restitution | [Victor Fisac](https://github.com/victorfisac) | | -| 111 | [physics_shatter](physics/physics_shatter.c) | physics_shatter | [Victor Fisac](https://github.com/victorfisac) | | - ### category: others Examples showing raylib misc functionality that does not fit in other categories, like standalone modules usage or examples integrating external libraries. diff --git a/examples/audio/audio_module_playing.c b/examples/audio/audio_module_playing.c index 33a43a8c1..50d3b8093 100644 --- a/examples/audio/audio_module_playing.c +++ b/examples/audio/audio_module_playing.c @@ -21,6 +21,9 @@ typedef struct { Color color; } CircleWave; +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/audio/audio_multichannel_sound.c b/examples/audio/audio_multichannel_sound.c index 438cff96c..1a892e668 100644 --- a/examples/audio/audio_multichannel_sound.c +++ b/examples/audio/audio_multichannel_sound.c @@ -13,6 +13,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/audio/audio_music_stream.c b/examples/audio/audio_music_stream.c index 143503360..f132e3dd6 100644 --- a/examples/audio/audio_music_stream.c +++ b/examples/audio/audio_music_stream.c @@ -54,6 +54,9 @@ static void AudioProcessEffectDelay(void *buffer, unsigned int frames) } } +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization @@ -68,15 +71,16 @@ int main(void) Music music = LoadMusicStream("resources/country.mp3"); // Allocate buffer for the delay effect - delayBuffer = (float *)RL_CALLOC(48000*2, sizeof(float)); // 1 second delay (device sampleRate*channels) + delayBufferSize = 48000 * 2; + delayBuffer = (float *)RL_CALLOC(delayBufferSize, sizeof(float)); // 1 second delay (device sampleRate*channels) PlayMusicStream(music); float timePlayed = 0.0f; bool pause = false; - bool hasFilter = false; - bool hasDelay = false; + bool hasFilter = true; + bool hasDelay = true; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- diff --git a/examples/audio/audio_raw_stream.c b/examples/audio/audio_raw_stream.c index 9599339f3..cd6ddb9fe 100644 --- a/examples/audio/audio_raw_stream.c +++ b/examples/audio/audio_raw_stream.c @@ -49,7 +49,9 @@ void AudioInputCallback(void *buffer, unsigned int frames) } } - +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/audio/audio_sound_loading.c b/examples/audio/audio_sound_loading.c index 2ccf23fea..9759d393e 100644 --- a/examples/audio/audio_sound_loading.c +++ b/examples/audio/audio_sound_loading.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/build.zig b/examples/build.zig index 5c3a69d29..5be56eda7 100644 --- a/examples/build.zig +++ b/examples/build.zig @@ -93,7 +93,6 @@ pub fn build(b: *std.build.Builder) !void { all.dependOn(try add_module("core", b, target)); all.dependOn(try add_module("models", b, target)); all.dependOn(try add_module("others", b, target)); - all.dependOn(try add_module("physics", b, target)); all.dependOn(try add_module("shaders", b, target)); all.dependOn(try add_module("shapes", b, target)); all.dependOn(try add_module("text", b, target)); diff --git a/examples/core/core_2d_camera.c b/examples/core/core_2d_camera.c index 7336bbbd7..1c7c8a303 100644 --- a/examples/core/core_2d_camera.c +++ b/examples/core/core_2d_camera.c @@ -13,6 +13,9 @@ #define MAX_BUILDINGS 100 +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_2d_camera_platformer.c b/examples/core/core_2d_camera_platformer.c index 9ab204924..1ebb8e8b3 100644 --- a/examples/core/core_2d_camera_platformer.c +++ b/examples/core/core_2d_camera_platformer.c @@ -30,16 +30,19 @@ typedef struct EnvItem { Color color; } EnvItem; - +//---------------------------------------------------------------------------------- +// Module functions declaration +//---------------------------------------------------------------------------------- void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float delta); - void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height); void UpdateCameraCenterInsideMap(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height); void UpdateCameraCenterSmoothFollow(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height); void UpdateCameraEvenOutOnLanding(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height); void UpdateCameraPlayerBoundsPush(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height); - +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_3d_camera_first_person.c b/examples/core/core_3d_camera_first_person.c index 59fc8307c..4f5652351 100644 --- a/examples/core/core_3d_camera_first_person.c +++ b/examples/core/core_3d_camera_first_person.c @@ -13,6 +13,9 @@ #define MAX_COLUMNS 20 +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_3d_camera_free.c b/examples/core/core_3d_camera_free.c index f469d121d..7ee12d72d 100644 --- a/examples/core/core_3d_camera_free.c +++ b/examples/core/core_3d_camera_free.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_3d_camera_mode.c b/examples/core/core_3d_camera_mode.c index 654fc2dba..5d63ccc80 100644 --- a/examples/core/core_3d_camera_mode.c +++ b/examples/core/core_3d_camera_mode.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_3d_picking.c b/examples/core/core_3d_picking.c index 1c42de79f..f20cefaf8 100644 --- a/examples/core/core_3d_picking.c +++ b/examples/core/core_3d_picking.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_basic_screen_manager.c b/examples/core/core_basic_screen_manager.c index 6051f1752..009dd014a 100644 --- a/examples/core/core_basic_screen_manager.c +++ b/examples/core/core_basic_screen_manager.c @@ -18,9 +18,9 @@ //------------------------------------------------------------------------------------------ typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen; -//------------------------------------------------------------------------------------------ -// Main entry point -//------------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_basic_window.c b/examples/core/core_basic_window.c index 3c103a5f2..d354cb2e2 100644 --- a/examples/core/core_basic_window.c +++ b/examples/core/core_basic_window.c @@ -21,6 +21,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_basic_window_web.c b/examples/core/core_basic_window_web.c index 119d4b002..cdd44c4c7 100644 --- a/examples/core/core_basic_window_web.c +++ b/examples/core/core_basic_window_web.c @@ -28,14 +28,14 @@ const int screenWidth = 800; const int screenHeight = 450; //---------------------------------------------------------------------------------- -// Module Functions Declaration +// Module functions declaration //---------------------------------------------------------------------------------- void UpdateDrawFrame(void); // Update and Draw one frame -//---------------------------------------------------------------------------------- -// Main Enry Point -//---------------------------------------------------------------------------------- -int main() +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main(void) { // Initialization //-------------------------------------------------------------------------------------- diff --git a/examples/core/core_custom_frame_control.c b/examples/core/core_custom_frame_control.c index 93181e763..208e131bf 100644 --- a/examples/core/core_custom_frame_control.c +++ b/examples/core/core_custom_frame_control.c @@ -26,6 +26,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_custom_logging.c b/examples/core/core_custom_logging.c index 56e168eed..5b39f4286 100644 --- a/examples/core/core_custom_logging.c +++ b/examples/core/core_custom_logging.c @@ -17,7 +17,7 @@ #include // Required for: time_t, tm, time(), localtime(), strftime() // Custom logging funtion -void LogCustom(int msgType, const char *text, va_list args) +void CustomLog(int msgType, const char *text, va_list args) { char timeStr[64] = { 0 }; time_t now = time(NULL); @@ -39,16 +39,18 @@ void LogCustom(int msgType, const char *text, va_list args) printf("\n"); } -int main(int argc, char* argv[]) +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; - // First thing we do is setting our custom logger to ensure everything raylib logs - // will use our own logger instead of its internal one - SetTraceLogCallback(LogCustom); + // Set custom logger + SetTraceLogCallback(CustomLog); InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging"); diff --git a/examples/core/core_drop_files.c b/examples/core/core_drop_files.c index 5c3af6ab2..8ac5c265a 100644 --- a/examples/core/core_drop_files.c +++ b/examples/core/core_drop_files.c @@ -13,6 +13,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization @@ -22,8 +25,7 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files"); - int count = 0; - char **droppedFiles = { 0 }; + FilePathList droppedFiles = { 0 }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -35,7 +37,11 @@ int main(void) //---------------------------------------------------------------------------------- if (IsFileDropped()) { - droppedFiles = GetDroppedFiles(&count); + // Is some files have been previously loaded, unload them + if (droppedFiles.count > 0) UnloadDroppedFiles(droppedFiles); + + // Load new dropped files + droppedFiles = LoadDroppedFiles(); } //---------------------------------------------------------------------------------- @@ -45,20 +51,20 @@ int main(void) ClearBackground(RAYWHITE); - if (count == 0) DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY); + if (droppedFiles.count == 0) DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY); else { DrawText("Dropped files:", 100, 40, 20, DARKGRAY); - for (int i = 0; i < count; i++) + for (int i = 0; i < droppedFiles.count; i++) { if (i%2 == 0) DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f)); else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f)); - DrawText(droppedFiles[i], 120, 100 + 40*i, 10, GRAY); + DrawText(droppedFiles.paths[i], 120, 100 + 40*i, 10, GRAY); } - DrawText("Drop new files...", 100, 110 + 40*count, 20, DARKGRAY); + DrawText("Drop new files...", 100, 110 + 40*droppedFiles.count, 20, DARKGRAY); } EndDrawing(); @@ -67,7 +73,7 @@ int main(void) // De-Initialization //-------------------------------------------------------------------------------------- - ClearDroppedFiles(); // Clear internal buffers + UnloadDroppedFiles(droppedFiles); // Unload files memory CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/core/core_input_gamepad.c b/examples/core/core_input_gamepad.c index 405f78e80..6c54ba6b9 100644 --- a/examples/core/core_input_gamepad.c +++ b/examples/core/core_input_gamepad.c @@ -27,6 +27,9 @@ #define PS3_NAME_ID "PLAYSTATION(R)3 Controller" #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_input_gestures.c b/examples/core/core_input_gestures.c index 50bbff7ef..89c7e72eb 100644 --- a/examples/core/core_input_gestures.c +++ b/examples/core/core_input_gestures.c @@ -10,10 +10,14 @@ ********************************************************************************************/ #include "raylib.h" + #include #define MAX_GESTURE_STRINGS 20 +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_input_keys.c b/examples/core/core_input_keys.c index bbb71ee38..5313d5afd 100644 --- a/examples/core/core_input_keys.c +++ b/examples/core/core_input_keys.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_input_mouse.c b/examples/core/core_input_mouse.c index c3415e8b7..bad1ce2e3 100644 --- a/examples/core/core_input_mouse.c +++ b/examples/core/core_input_mouse.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_input_mouse_wheel.c b/examples/core/core_input_mouse_wheel.c index 232d62c1e..9080aafb4 100644 --- a/examples/core/core_input_mouse_wheel.c +++ b/examples/core/core_input_mouse_wheel.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_input_multitouch.c b/examples/core/core_input_multitouch.c index ef15a9663..69f45bd89 100644 --- a/examples/core/core_input_multitouch.c +++ b/examples/core/core_input_multitouch.c @@ -15,6 +15,9 @@ #define MAX_TOUCH_POINTS 10 +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_loading_thread.c b/examples/core/core_loading_thread.c index 773ad2eae..20e032b42 100644 --- a/examples/core/core_loading_thread.c +++ b/examples/core/core_loading_thread.c @@ -27,6 +27,9 @@ static void *LoadDataThread(void *arg); // Loading data thread function decl static int dataProgress = 0; // Data progress accumulator +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_quat_conversion.c b/examples/core/core_quat_conversion.c index a60e40007..a2cf93387 100644 --- a/examples/core/core_quat_conversion.c +++ b/examples/core/core_quat_conversion.c @@ -18,6 +18,9 @@ #include "raymath.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_random_values.c b/examples/core/core_random_values.c index b44b5faf4..986014b5c 100644 --- a/examples/core/core_random_values.c +++ b/examples/core/core_random_values.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_scissor_test.c b/examples/core/core_scissor_test.c index 56eb84f80..162cc7bc0 100644 --- a/examples/core/core_scissor_test.c +++ b/examples/core/core_scissor_test.c @@ -13,6 +13,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_smooth_pixelperfect.c b/examples/core/core_smooth_pixelperfect.c index e0c6d1976..a49d5b4c6 100644 --- a/examples/core/core_smooth_pixelperfect.c +++ b/examples/core/core_smooth_pixelperfect.c @@ -16,6 +16,9 @@ #include // Required for: sinf(), cosf() +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_split_screen.c b/examples/core/core_split_screen.c index c05c0b32d..2f7cc2df3 100644 --- a/examples/core/core_split_screen.c +++ b/examples/core/core_split_screen.c @@ -40,6 +40,9 @@ void DrawScene(void) DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE); } +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_storage_values.c b/examples/core/core_storage_values.c index 2ae1cc393..41173d26e 100644 --- a/examples/core/core_storage_values.c +++ b/examples/core/core_storage_values.c @@ -17,6 +17,9 @@ typedef enum { STORAGE_POSITION_HISCORE = 1 } StorageData; +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_vr_simulator.c b/examples/core/core_vr_simulator.c index 65f0dec65..c39f2df76 100644 --- a/examples/core/core_vr_simulator.c +++ b/examples/core/core_vr_simulator.c @@ -17,6 +17,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization @@ -78,7 +81,11 @@ int main(void) // Initialize framebuffer for stereo rendering // NOTE: Screen size should match HMD aspect ratio - RenderTexture2D target = LoadRenderTexture(GetScreenWidth(), GetScreenHeight()); + RenderTexture2D target = LoadRenderTexture(device.hResolution, device.vResolution); + + // The target's height is flipped (in the source Rectangle), due to OpenGL reasons + Rectangle sourceRec = { 0.0f, 0.0f, (float)target.texture.width, -(float)target.texture.height }; + Rectangle destRec = { 0.0f, 0.0f, (float)GetScreenWidth(), (float)GetScreenHeight() }; // Define the camera to look into our 3d world Camera camera = { 0 }; @@ -121,8 +128,7 @@ int main(void) BeginDrawing(); ClearBackground(RAYWHITE); BeginShaderMode(distortion); - DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, - (float)-target.texture.height }, (Vector2){ 0.0f, 0.0f }, WHITE); + DrawTexturePro(target.texture, sourceRec, destRec, (Vector2){ 0.0f, 0.0f }, 0.0f, WHITE); EndShaderMode(); DrawFPS(10, 10); EndDrawing(); diff --git a/examples/core/core_window_flags.c b/examples/core/core_window_flags.c index 4b20066f0..534a18788 100644 --- a/examples/core/core_window_flags.c +++ b/examples/core/core_window_flags.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/core/core_window_letterbox.c b/examples/core/core_window_letterbox.c index 1e0765163..7c17c8c59 100644 --- a/examples/core/core_window_letterbox.c +++ b/examples/core/core_window_letterbox.c @@ -13,21 +13,14 @@ #include "raylib.h" -#define max(a, b) ((a)>(b)? (a) : (b)) -#define min(a, b) ((a)<(b)? (a) : (b)) +#include "raymath.h" // Required for: Vector2Clamp() -// Clamp Vector2 value with min and max and return a new vector2 -// NOTE: Required for virtual mouse, to clamp inside virtual game size -Vector2 ClampValue(Vector2 value, Vector2 min, Vector2 max) -{ - Vector2 result = value; - result.x = (result.x > max.x)? max.x : result.x; - result.x = (result.x < min.x)? min.x : result.x; - result.y = (result.y > max.y)? max.y : result.y; - result.y = (result.y < min.y)? min.y : result.y; - return result; -} +#define MAX(a, b) ((a)>(b)? (a) : (b)) +#define MIN(a, b) ((a)<(b)? (a) : (b)) +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { const int windowWidth = 800; @@ -57,7 +50,7 @@ int main(void) // Update //---------------------------------------------------------------------------------- // Compute required framebuffer scaling - float scale = min((float)GetScreenWidth()/gameScreenWidth, (float)GetScreenHeight()/gameScreenHeight); + float scale = MIN((float)GetScreenWidth()/gameScreenWidth, (float)GetScreenHeight()/gameScreenHeight); if (IsKeyPressed(KEY_SPACE)) { @@ -70,7 +63,7 @@ int main(void) Vector2 virtualMouse = { 0 }; virtualMouse.x = (mouse.x - (GetScreenWidth() - (gameScreenWidth*scale))*0.5f)/scale; virtualMouse.y = (mouse.y - (GetScreenHeight() - (gameScreenHeight*scale))*0.5f)/scale; - virtualMouse = ClampValue(virtualMouse, (Vector2){ 0, 0 }, (Vector2){ (float)gameScreenWidth, (float)gameScreenHeight }); + virtualMouse = Vector2Clamp(virtualMouse, (Vector2){ 0, 0 }, (Vector2){ (float)gameScreenWidth, (float)gameScreenHeight }); // Apply the same transformation as the virtual mouse to the real mouse (i.e. to work with raygui) //SetMouseOffset(-(GetScreenWidth() - (gameScreenWidth*scale))*0.5f, -(GetScreenHeight() - (gameScreenHeight*scale))*0.5f); diff --git a/examples/core/core_world_screen.c b/examples/core/core_world_screen.c index fe13b1b4c..cd380a30a 100644 --- a/examples/core/core_world_screen.c +++ b/examples/core/core_world_screen.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/examples_template.c b/examples/examples_template.c index f17411045..3d4701349 100644 --- a/examples/examples_template.c +++ b/examples/examples_template.c @@ -52,6 +52,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_animation.c b/examples/models/models_animation.c index 2f5ae2669..8055d64f8 100644 --- a/examples/models/models_animation.c +++ b/examples/models/models_animation.c @@ -21,7 +21,9 @@ #include - +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_billboard.c b/examples/models/models_billboard.c index 0a7e878ba..30c328f26 100644 --- a/examples/models/models_billboard.c +++ b/examples/models/models_billboard.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_box_collisions.c b/examples/models/models_box_collisions.c index 7a937ea7e..f451119a4 100644 --- a/examples/models/models_box_collisions.c +++ b/examples/models/models_box_collisions.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_cubicmap.c b/examples/models/models_cubicmap.c index 0a566581e..24c6dd7bd 100644 --- a/examples/models/models_cubicmap.c +++ b/examples/models/models_cubicmap.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_first_person_maze.c b/examples/models/models_first_person_maze.c index 08a9b5cf3..e4689f594 100644 --- a/examples/models/models_first_person_maze.c +++ b/examples/models/models_first_person_maze.c @@ -13,6 +13,9 @@ #include // Required for: free() +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_geometric_shapes.c b/examples/models/models_geometric_shapes.c index c1feb8027..0ac61f2db 100644 --- a/examples/models/models_geometric_shapes.c +++ b/examples/models/models_geometric_shapes.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_heightmap.c b/examples/models/models_heightmap.c index 03479a9bc..2a365c718 100644 --- a/examples/models/models_heightmap.c +++ b/examples/models/models_heightmap.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_loading.c b/examples/models/models_loading.c index f13b11ef6..c691b7c54 100644 --- a/examples/models/models_loading.c +++ b/examples/models/models_loading.c @@ -22,6 +22,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization @@ -67,35 +70,34 @@ int main(void) // Load new models/textures on drag&drop if (IsFileDropped()) { - int count = 0; - char **droppedFiles = GetDroppedFiles(&count); + FilePathList droppedFiles = LoadDroppedFiles(); - if (count == 1) // Only support one file dropped + if (droppedFiles.count == 1) // Only support one file dropped { - if (IsFileExtension(droppedFiles[0], ".obj") || - IsFileExtension(droppedFiles[0], ".gltf") || - IsFileExtension(droppedFiles[0], ".glb") || - IsFileExtension(droppedFiles[0], ".vox") || - IsFileExtension(droppedFiles[0], ".iqm")) // Model file formats supported + if (IsFileExtension(droppedFiles.paths[0], ".obj") || + IsFileExtension(droppedFiles.paths[0], ".gltf") || + IsFileExtension(droppedFiles.paths[0], ".glb") || + IsFileExtension(droppedFiles.paths[0], ".vox") || + IsFileExtension(droppedFiles.paths[0], ".iqm")) // Model file formats supported { - UnloadModel(model); // Unload previous model - model = LoadModel(droppedFiles[0]); // Load new model + UnloadModel(model); // Unload previous model + model = LoadModel(droppedFiles.paths[0]); // Load new model model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set current map diffuse texture bounds = GetMeshBoundingBox(model.meshes[0]); // TODO: Move camera position from target enough distance to visualize model properly } - else if (IsFileExtension(droppedFiles[0], ".png")) // Texture file formats supported + else if (IsFileExtension(droppedFiles.paths[0], ".png")) // Texture file formats supported { // Unload current model texture and load new one UnloadTexture(texture); - texture = LoadTexture(droppedFiles[0]); + texture = LoadTexture(droppedFiles.paths[0]); model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; } } - ClearDroppedFiles(); // Clear internal buffers + UnloadDroppedFiles(droppedFiles); // Unload filepaths from memory } // Select model on mouse click diff --git a/examples/models/models_loading_gltf.c b/examples/models/models_loading_gltf.c index fe79afecc..364006750 100644 --- a/examples/models/models_loading_gltf.c +++ b/examples/models/models_loading_gltf.c @@ -1,25 +1,19 @@ /******************************************************************************************* * -* raylib [models] example - Load models gltf +* raylib [models] example - loading gltf * -* This example has been created using raylib 3.5 (www.raylib.com) +* This example has been created using raylib 4.2 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* NOTE: To export a model from Blender, make sure it is not posed, the vertices need to be -* in the same position as they would be in edit mode. -* Also make sure the scale parameter of your models is set to 0.0, -* scaling can be applied from the export menu. -* -* Example contributed by Hristo Stamenov (@object71) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2021 Hristo Stamenov (@object71) and Ramon Santamaria (@raysan5) +* Copyright (c) 2022 Ramon Santamaria (@raysan5) * ********************************************************************************************/ #include "raylib.h" -#define MAX_GLTF_MODELS 8 - +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization @@ -27,7 +21,7 @@ int main(void) const int screenWidth = 800; const int screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib [models] example - model"); + InitWindow(screenWidth, screenHeight, "raylib [models] example - loading gltf"); // Define the camera to look into our 3d world Camera camera = { 0 }; @@ -37,18 +31,8 @@ int main(void) camera.fovy = 45.0f; // Camera field-of-view Y camera.projection = CAMERA_PERSPECTIVE; // Camera mode type - // Load some models - Model model[MAX_GLTF_MODELS] = { 0 }; - model[0] = LoadModel("resources/models/gltf/raylib_32x32.glb"); - model[1] = LoadModel("resources/models/gltf/rigged_figure.glb"); - model[2] = LoadModel("resources/models/gltf/GearboxAssy.glb"); - model[3] = LoadModel("resources/models/gltf/BoxAnimated.glb"); - model[4] = LoadModel("resources/models/gltf/AnimatedTriangle.gltf"); - model[5] = LoadModel("resources/models/gltf/AnimatedMorphCube.glb"); - model[6] = LoadModel("resources/models/gltf/vertex_colored_object.glb"); - model[7] = LoadModel("resources/models/gltf/girl.glb"); - - int currentModel = 0; + // Loaf gltf model + Model model = LoadModel("resources/models/gltf/robot.glb"); Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position @@ -63,18 +47,6 @@ int main(void) // Update //---------------------------------------------------------------------------------- UpdateCamera(&camera); // Update our camera with inputs - - if (IsKeyReleased(KEY_RIGHT)) - { - currentModel++; - if (currentModel == MAX_GLTF_MODELS) currentModel = 0; - } - - if (IsKeyReleased(KEY_LEFT)) - { - currentModel--; - if (currentModel < 0) currentModel = MAX_GLTF_MODELS - 1; - } //---------------------------------------------------------------------------------- // Draw @@ -85,7 +57,7 @@ int main(void) BeginMode3D(camera); - DrawModel(model[currentModel], position, 1.0f, WHITE); + DrawModel(model, position, 1.0f, WHITE); DrawGrid(10, 1.0f); // Draw a grid EndMode3D(); @@ -96,8 +68,8 @@ int main(void) // De-Initialization //-------------------------------------------------------------------------------------- - for (int i = 0; i < MAX_GLTF_MODELS; i++) UnloadModel(model[i]); // Unload models - + UnloadModel(model); // Unload model and meshes/material + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/models/models_loading_vox.c b/examples/models/models_loading_vox.c index dca17590f..6144a513e 100644 --- a/examples/models/models_loading_vox.c +++ b/examples/models/models_loading_vox.c @@ -17,6 +17,9 @@ #define MAX_VOX_FILES 3 +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_mesh_generation.c b/examples/models/models_mesh_generation.c index 7213f58d9..2d9afcca8 100644 --- a/examples/models/models_mesh_generation.c +++ b/examples/models/models_mesh_generation.c @@ -15,6 +15,9 @@ static Mesh GenMeshCustom(void); // Generate a simple triangle mesh from code +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_mesh_picking.c b/examples/models/models_mesh_picking.c index 38378bc4c..7cd51d98d 100644 --- a/examples/models/models_mesh_picking.c +++ b/examples/models/models_mesh_picking.c @@ -16,6 +16,9 @@ #define FLT_MAX 340282346638528859811704183484516925440.0f // Maximum value of a float, from bit pattern 01111111011111111111111111111111 +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_orthographic_projection.c b/examples/models/models_orthographic_projection.c index 7dd5fde25..c38d18161 100644 --- a/examples/models/models_orthographic_projection.c +++ b/examples/models/models_orthographic_projection.c @@ -18,6 +18,9 @@ #define FOVY_PERSPECTIVE 45.0f #define WIDTH_ORTHOGRAPHIC 10.0f +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/models_skybox.c b/examples/models/models_skybox.c index dd202617e..6567cf25c 100644 --- a/examples/models/models_skybox.c +++ b/examples/models/models_skybox.c @@ -23,6 +23,9 @@ // Generate cubemap (6 faces) from equirectangular (panorama) texture static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int size, int format); +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization @@ -97,18 +100,17 @@ int main(void) // Load new cubemap texture on drag&drop if (IsFileDropped()) { - int count = 0; - char **droppedFiles = GetDroppedFiles(&count); + FilePathList droppedFiles = LoadDroppedFiles(); - if (count == 1) // Only support one file dropped + if (droppedFiles.count == 1) // Only support one file dropped { - if (IsFileExtension(droppedFiles[0], ".png;.jpg;.hdr;.bmp;.tga")) + if (IsFileExtension(droppedFiles.paths[0], ".png;.jpg;.hdr;.bmp;.tga")) { // Unload current cubemap texture and load new one UnloadTexture(skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture); if (useHDR) { - Texture2D panorama = LoadTexture(droppedFiles[0]); + Texture2D panorama = LoadTexture(droppedFiles.paths[0]); // Generate cubemap from panorama texture skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8); @@ -116,16 +118,16 @@ int main(void) } else { - Image img = LoadImage(droppedFiles[0]); + Image img = LoadImage(droppedFiles.paths[0]); skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = LoadTextureCubemap(img, CUBEMAP_LAYOUT_AUTO_DETECT); UnloadImage(img); } - TextCopy(skyboxFileName, droppedFiles[0]); + TextCopy(skyboxFileName, droppedFiles.paths[0]); } } - ClearDroppedFiles(); // Clear internal buffers + UnloadDroppedFiles(droppedFiles); // Unload filepaths from memory } //---------------------------------------------------------------------------------- diff --git a/examples/models/models_waving_cubes.c b/examples/models/models_waving_cubes.c index 13f098b9d..e21db1021 100644 --- a/examples/models/models_waving_cubes.c +++ b/examples/models/models_waving_cubes.c @@ -13,8 +13,11 @@ #include "raylib.h" -#include +#include // Required for: sinf() +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main() { // Initialization diff --git a/examples/models/models_yaw_pitch_roll.c b/examples/models/models_yaw_pitch_roll.c index d9d4b9c70..009a825f4 100644 --- a/examples/models/models_yaw_pitch_roll.c +++ b/examples/models/models_yaw_pitch_roll.c @@ -15,6 +15,9 @@ #include "raymath.h" // Required for: MatrixRotateXYZ() +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/models/resources/LICENSE.md b/examples/models/resources/LICENSE.md index 6fdeaa5a2..d7f85c0f4 100644 --- a/examples/models/resources/LICENSE.md +++ b/examples/models/resources/LICENSE.md @@ -1,16 +1,15 @@ | resource | author | licence | notes | | :------------------- | :---------: | :------ | :---- | -| models/obj/castle.obj,
models/castle_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | -| models/obj/bridge.obj,
models/bridge_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | -| models/obj/house.obj,
models/house_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | -| models/obj/market.obj,
models/market_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | -| models/obj/turret.obj,
models/turret_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | -| models/obj/well.obj,
models/well_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | -| models/obj/cube.obj,
models/cube_diffuse.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | -| models/obj/plane.gltf,
models/gltf/plane/plane.bin,
models/gltf/plane/plane_diffuse.png | [GiaHanLam](https://sketchfab.com/GiaHanLam) | [CC-BY](https://creativecommons.org/licenses/by/4.0/) | Used by: [`models_yaw_pitch_roll.c`](https://github.com/raysan5/raylib/blob/master/examples/models/models_yaw_pitch_roll.c) +| models/obj/castle.obj,
models/obj/castle_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | +| models/obj/bridge.obj,
models/obj/bridge_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | +| models/obj/house.obj,
models/obj/house_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | +| models/obj/market.obj,
models/obj/market_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | +| models/obj/turret.obj,
models/obj/turret_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | +| models/obj/well.obj,
models/obj/well_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | +| models/obj/cube.obj,
models/obj/cube_diffuse.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | +| models/obj/plane.obj,
models/obj/plane_diffuse.png | [GiaHanLam](https://sketchfab.com/GiaHanLam) | [CC-BY](https://creativecommons.org/licenses/by/4.0/) | Used by: [`models_yaw_pitch_roll.c`](https://github.com/raysan5/raylib/blob/master/examples/models/models_yaw_pitch_roll.c) | models/iqm/guy.iqm,
models/iqm/guyanim.iqm,
models/iqm/guytex.png,
models/iqm/guy.blend | [@culacant](https://github.com/culacant) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | -| models/iqm/vertex_colored_object.iqm | ❔ | ❔ | - | -| models/gltf/... | _various_ | Check [LICENSE](https://github.com/raysan5/raylib/blob/master/examples/models/resources/models/gltf/LICENSE) | - | +| models/gltf/robot.glb,
models/gltf/robot.blend | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | | models/vox/chr_knight.vox | ❔ | ❔ | - | | models/vox/chr_sword.vox | ❔ | ❔ | - | | models/vox/monu9.vox | ❔ | ❔ | - | diff --git a/examples/models/resources/models/gltf/AnimatedMorphCube.glb b/examples/models/resources/models/gltf/AnimatedMorphCube.glb deleted file mode 100644 index 219d2ac52..000000000 Binary files a/examples/models/resources/models/gltf/AnimatedMorphCube.glb and /dev/null differ diff --git a/examples/models/resources/models/gltf/AnimatedTriangle.gltf b/examples/models/resources/models/gltf/AnimatedTriangle.gltf deleted file mode 100644 index d5c095492..000000000 --- a/examples/models/resources/models/gltf/AnimatedTriangle.gltf +++ /dev/null @@ -1,118 +0,0 @@ -{ - "scene" : 0, - "scenes" : [ - { - "nodes" : [ 0 ] - } - ], - - "nodes" : [ - { - "mesh" : 0, - "rotation" : [ 0.0, 0.0, 0.0, 1.0 ] - } - ], - - "meshes" : [ - { - "primitives" : [ { - "attributes" : { - "POSITION" : 1 - }, - "indices" : 0 - } ] - } - ], - - "animations": [ - { - "samplers" : [ - { - "input" : 2, - "interpolation" : "LINEAR", - "output" : 3 - } - ], - "channels" : [ { - "sampler" : 0, - "target" : { - "node" : 0, - "path" : "rotation" - } - } ] - } - ], - - "buffers" : [ - { - "uri" : "data:application/octet-stream;base64,AAABAAIAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAA=", - "byteLength" : 44 - }, - { - "uri" : "data:application/octet-stream;base64,AAAAAAAAgD4AAAA/AABAPwAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAD0/TQ/9P00PwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAPT9ND/0/TS/AAAAAAAAAAAAAAAAAACAPw==", - "byteLength" : 100 - } - ], - "bufferViews" : [ - { - "buffer" : 0, - "byteOffset" : 0, - "byteLength" : 6, - "target" : 34963 - }, - { - "buffer" : 0, - "byteOffset" : 8, - "byteLength" : 36, - "target" : 34962 - }, - { - "buffer" : 1, - "byteOffset" : 0, - "byteLength" : 100 - } - ], - "accessors" : [ - { - "bufferView" : 0, - "byteOffset" : 0, - "componentType" : 5123, - "count" : 3, - "type" : "SCALAR", - "max" : [ 2 ], - "min" : [ 0 ] - }, - { - "bufferView" : 1, - "byteOffset" : 0, - "componentType" : 5126, - "count" : 3, - "type" : "VEC3", - "max" : [ 1.0, 1.0, 0.0 ], - "min" : [ 0.0, 0.0, 0.0 ] - }, - { - "bufferView" : 2, - "byteOffset" : 0, - "componentType" : 5126, - "count" : 5, - "type" : "SCALAR", - "max" : [ 1.0 ], - "min" : [ 0.0 ] - }, - { - "bufferView" : 2, - "byteOffset" : 20, - "componentType" : 5126, - "count" : 5, - "type" : "VEC4", - "max" : [ 0.0, 0.0, 1.0, 1.0 ], - "min" : [ 0.0, 0.0, 0.0, -0.707 ] - } - ], - - "asset" : { - "version" : "2.0" - } - -} \ No newline at end of file diff --git a/examples/models/resources/models/gltf/BoxAnimated.glb b/examples/models/resources/models/gltf/BoxAnimated.glb deleted file mode 100644 index 69481ec3c..000000000 Binary files a/examples/models/resources/models/gltf/BoxAnimated.glb and /dev/null differ diff --git a/examples/models/resources/models/gltf/LICENSE b/examples/models/resources/models/gltf/LICENSE index 305079cfb..3c9a38dee 100644 --- a/examples/models/resources/models/gltf/LICENSE +++ b/examples/models/resources/models/gltf/LICENSE @@ -1,23 +1,2 @@ -Rigged Figure model has been created by Cesium (https://cesium.com/cesiumjs/), -and licensed as Creative Commons Attribution 4.0 International License. - -Box Animated model has been created by Cesium (https://cesium.com/cesiumjs/) -and is licensed as Creative Commons Attribution 4.0 International License - -Avocado model is provided by Microsoft -and licensed as CC0 Universal Public Domain - -Animated Morph Cube model is provided by Microsoft -and licensed as CC0 Universal Public Domain - -Animated Triangle model is licensed as CC0 Universal Public Domain - -Gearbox Assy model has been provided by Okino Computer Graphics, using Okino Polytrans Software. -no license information was provided - -Girl model has been provided by Hristo Stamenov (https://thatonegamedev.com/) -and licensed as CC0 Universal Public Domain - -Check for details on CC0: https://creativecommons.org/publicdomain/zero/1.0/ -Check for details on CC4: http://creativecommons.org/licenses/by/4.0/ -GLTF sample models for testing are taken from: https://github.com/KhronosGroup/glTF-Sample-Models/ +robot.glb model by @Quaternius (https://www.patreon.com/quaternius) +Licensed under CC0 1.0 Universal (CC0 1.0) - Public Domain Dedication (https://creativecommons.org/publicdomain/zero/1.0/) \ No newline at end of file diff --git a/examples/models/resources/models/gltf/girl.glb b/examples/models/resources/models/gltf/girl.glb deleted file mode 100644 index c368590c8..000000000 Binary files a/examples/models/resources/models/gltf/girl.glb and /dev/null differ diff --git a/examples/models/resources/models/gltf/raylib_32x32.glb b/examples/models/resources/models/gltf/raylib_logo_3d.glb similarity index 100% rename from examples/models/resources/models/gltf/raylib_32x32.glb rename to examples/models/resources/models/gltf/raylib_logo_3d.glb diff --git a/examples/models/resources/models/gltf/rigged_figure.glb b/examples/models/resources/models/gltf/rigged_figure.glb deleted file mode 100644 index c505a33df..000000000 Binary files a/examples/models/resources/models/gltf/rigged_figure.glb and /dev/null differ diff --git a/examples/models/resources/models/gltf/robot.blend b/examples/models/resources/models/gltf/robot.blend new file mode 100644 index 000000000..d3bdac237 Binary files /dev/null and b/examples/models/resources/models/gltf/robot.blend differ diff --git a/examples/models/resources/models/gltf/robot.glb b/examples/models/resources/models/gltf/robot.glb new file mode 100644 index 000000000..73f5bf44e Binary files /dev/null and b/examples/models/resources/models/gltf/robot.glb differ diff --git a/examples/models/resources/models/gltf/vertex_colored_object.glb b/examples/models/resources/models/gltf/vertex_colored_object.glb deleted file mode 100644 index 0b57eddbd..000000000 Binary files a/examples/models/resources/models/gltf/vertex_colored_object.glb and /dev/null differ diff --git a/examples/models/resources/models/iqm/vertex_colored_object.iqm b/examples/models/resources/models/iqm/vertex_colored_object.iqm deleted file mode 100644 index ad0db07eb..000000000 Binary files a/examples/models/resources/models/iqm/vertex_colored_object.iqm and /dev/null differ diff --git a/examples/models/rlights.h b/examples/models/rlights.h index a1b298881..4a5677bc9 100644 --- a/examples/models/rlights.h +++ b/examples/models/rlights.h @@ -11,7 +11,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2017-2020 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) +* Copyright (c) 2017-2022 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. @@ -36,7 +36,7 @@ //---------------------------------------------------------------------------------- // Defines and Macros //---------------------------------------------------------------------------------- -#define MAX_LIGHTS 4 // Max dynamic lights supported by shader +#define MAX_LIGHTS 4 // Max dynamic lights supported by shader //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -45,22 +45,22 @@ // Light data typedef struct { int type; + bool enabled; Vector3 position; Vector3 target; Color color; - bool enabled; // Shader locations int enabledLoc; int typeLoc; - int posLoc; + int positionLoc; int targetLoc; int colorLoc; } Light; // Light type typedef enum { - LIGHT_DIRECTIONAL, + LIGHT_DIRECTIONAL = 0, LIGHT_POINT } LightType; @@ -128,27 +128,12 @@ Light CreateLight(int type, Vector3 position, Vector3 target, Color color, Shade light.target = target; light.color = color; - // TODO: Below code doesn't look good to me, - // it assumes a specific shader naming and structure - // Probably this implementation could be improved - char enabledName[32] = "lights[x].enabled\0"; - char typeName[32] = "lights[x].type\0"; - char posName[32] = "lights[x].position\0"; - char targetName[32] = "lights[x].target\0"; - char colorName[32] = "lights[x].color\0"; - - // Set location name [x] depending on lights count - enabledName[7] = '0' + lightsCount; - typeName[7] = '0' + lightsCount; - posName[7] = '0' + lightsCount; - targetName[7] = '0' + lightsCount; - colorName[7] = '0' + lightsCount; - - light.enabledLoc = GetShaderLocation(shader, enabledName); - light.typeLoc = GetShaderLocation(shader, typeName); - light.posLoc = GetShaderLocation(shader, posName); - light.targetLoc = GetShaderLocation(shader, targetName); - light.colorLoc = GetShaderLocation(shader, colorName); + // NOTE: Lighting shader naming must be the provided ones + light.enabledLoc = GetShaderLocation(shader, TextFormat("lights[%i].enabled", lightsCount)); + light.typeLoc = GetShaderLocation(shader, TextFormat("lights[%i].type", lightsCount)); + light.positionLoc = GetShaderLocation(shader, TextFormat("lights[%i].position", lightsCount)); + light.targetLoc = GetShaderLocation(shader, TextFormat("lights[%i].target", lightsCount)); + light.colorLoc = GetShaderLocation(shader, TextFormat("lights[%i].color", lightsCount)); UpdateLightValues(shader, light); @@ -168,7 +153,7 @@ void UpdateLightValues(Shader shader, Light light) // Send to shader light position values float position[3] = { light.position.x, light.position.y, light.position.z }; - SetShaderValue(shader, light.posLoc, position, SHADER_UNIFORM_VEC3); + SetShaderValue(shader, light.positionLoc, position, SHADER_UNIFORM_VEC3); // Send to shader light target position values float target[3] = { light.target.x, light.target.y, light.target.z }; diff --git a/examples/others/easings.h b/examples/others/easings.h index 216178260..fb723d83a 100644 --- a/examples/others/easings.h +++ b/examples/others/easings.h @@ -90,7 +90,7 @@ #define EASEDEF extern #endif -#include // Required for: sinf(), cosf(), sqrt(), pow() +#include // Required for: sinf(), cosf(), sqrtf(), powf() #ifndef PI #define PI 3.14159265358979323846f //Required as PI is not always defined in math.h @@ -101,71 +101,71 @@ extern "C" { // Prevents name mangling of functions #endif // Linear Easing functions -EASEDEF float EaseLinearNone(float t, float b, float c, float d) { return (c*t/d + b); } -EASEDEF float EaseLinearIn(float t, float b, float c, float d) { return (c*t/d + b); } -EASEDEF float EaseLinearOut(float t, float b, float c, float d) { return (c*t/d + b); } -EASEDEF float EaseLinearInOut(float t,float b, float c, float d) { return (c*t/d + b); } +EASEDEF float EaseLinearNone(float t, float b, float c, float d) { return (c*t/d + b); } // Ease: Linear +EASEDEF float EaseLinearIn(float t, float b, float c, float d) { return (c*t/d + b); } // Ease: Linear In +EASEDEF float EaseLinearOut(float t, float b, float c, float d) { return (c*t/d + b); } // Ease: Linear Out +EASEDEF float EaseLinearInOut(float t, float b, float c, float d) { return (c*t/d + b); } // Ease: Linear In Out // Sine Easing functions -EASEDEF float EaseSineIn(float t, float b, float c, float d) { return (-c*cosf(t/d*(PI/2.0f)) + c + b); } -EASEDEF float EaseSineOut(float t, float b, float c, float d) { return (c*sinf(t/d*(PI/2.0f)) + b); } -EASEDEF float EaseSineInOut(float t, float b, float c, float d) { return (-c/2.0f*(cosf(PI*t/d) - 1.0f) + b); } +EASEDEF float EaseSineIn(float t, float b, float c, float d) { return (-c*cosf(t/d*(PI/2.0f)) + c + b); } // Ease: Sine In +EASEDEF float EaseSineOut(float t, float b, float c, float d) { return (c*sinf(t/d*(PI/2.0f)) + b); } // Ease: Sine Out +EASEDEF float EaseSineInOut(float t, float b, float c, float d) { return (-c/2.0f*(cosf(PI*t/d) - 1.0f) + b); } // Ease: Sine Out // Circular Easing functions -EASEDEF float EaseCircIn(float t, float b, float c, float d) { t /= d; return (-c*(sqrtf(1.0f - t*t) - 1.0f) + b); } -EASEDEF float EaseCircOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*sqrtf(1.0f - t*t) + b); } -EASEDEF float EaseCircInOut(float t, float b, float c, float d) +EASEDEF float EaseCircIn(float t, float b, float c, float d) { t /= d; return (-c*(sqrtf(1.0f - t*t) - 1.0f) + b); } // Ease: Circular In +EASEDEF float EaseCircOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*sqrtf(1.0f - t*t) + b); } // Ease: Circular Out +EASEDEF float EaseCircInOut(float t, float b, float c, float d) // Ease: Circular In Out { if ((t/=d/2.0f) < 1.0f) return (-c/2.0f*(sqrtf(1.0f - t*t) - 1.0f) + b); t -= 2.0f; return (c/2.0f*(sqrtf(1.0f - t*t) + 1.0f) + b); } // Cubic Easing functions -EASEDEF float EaseCubicIn(float t, float b, float c, float d) { t /= d; return (c*t*t*t + b); } -EASEDEF float EaseCubicOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*(t*t*t + 1.0f) + b); } -EASEDEF float EaseCubicInOut(float t, float b, float c, float d) +EASEDEF float EaseCubicIn(float t, float b, float c, float d) { t /= d; return (c*t*t*t + b); } // Ease: Cubic In +EASEDEF float EaseCubicOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*(t*t*t + 1.0f) + b); } // Ease: Cubic Out +EASEDEF float EaseCubicInOut(float t, float b, float c, float d) // Ease: Cubic In Out { if ((t/=d/2.0f) < 1.0f) return (c/2.0f*t*t*t + b); t -= 2.0f; return (c/2.0f*(t*t*t + 2.0f) + b); } // Quadratic Easing functions -EASEDEF float EaseQuadIn(float t, float b, float c, float d) { t /= d; return (c*t*t + b); } -EASEDEF float EaseQuadOut(float t, float b, float c, float d) { t /= d; return (-c*t*(t - 2.0f) + b); } -EASEDEF float EaseQuadInOut(float t, float b, float c, float d) +EASEDEF float EaseQuadIn(float t, float b, float c, float d) { t /= d; return (c*t*t + b); } // Ease: Quadratic In +EASEDEF float EaseQuadOut(float t, float b, float c, float d) { t /= d; return (-c*t*(t - 2.0f) + b); } // Ease: Quadratic Out +EASEDEF float EaseQuadInOut(float t, float b, float c, float d) // Ease: Quadratic In Out { if ((t/=d/2) < 1) return (((c/2)*(t*t)) + b); return (-c/2.0f*(((t - 1.0f)*(t - 3.0f)) - 1.0f) + b); } // Exponential Easing functions -EASEDEF float EaseExpoIn(float t, float b, float c, float d) { return (t == 0.0f) ? b : (c * powf(2.0f, 10.0f*(t/d - 1.0f)) + b); } -EASEDEF float EaseExpoOut(float t, float b, float c, float d) { return (t == d) ? (b + c) : (c * (-powf(2.0f, -10.0f*t/d) + 1.0f) + b); } -EASEDEF float EaseExpoInOut(float t, float b, float c, float d) +EASEDEF float EaseExpoIn(float t, float b, float c, float d) { return (t == 0.0f) ? b : (c*powf(2.0f, 10.0f*(t/d - 1.0f)) + b); } // Ease: Exponential In +EASEDEF float EaseExpoOut(float t, float b, float c, float d) { return (t == d) ? (b + c) : (c*(-powf(2.0f, -10.0f*t/d) + 1.0f) + b); } // Ease: Exponential Out +EASEDEF float EaseExpoInOut(float t, float b, float c, float d) // Ease: Exponential In Out { if (t == 0.0f) return b; if (t == d) return (b + c); - if ((t/=d/2.0f) < 1.0f) return (c/2.0f* powf(2.0f, 10.0f*(t - 1.0f)) + b); + if ((t/=d/2.0f) < 1.0f) return (c/2.0f*powf(2.0f, 10.0f*(t - 1.0f)) + b); return (c/2.0f*(-powf(2.0f, -10.0f*(t - 1.0f)) + 2.0f) + b); } // Back Easing functions -EASEDEF float EaseBackIn(float t, float b, float c, float d) +EASEDEF float EaseBackIn(float t, float b, float c, float d) // Ease: Back In { float s = 1.70158f; float postFix = t/=d; return (c*(postFix)*t*((s + 1.0f)*t - s) + b); } -EASEDEF float EaseBackOut(float t, float b, float c, float d) +EASEDEF float EaseBackOut(float t, float b, float c, float d) // Ease: Back Out { float s = 1.70158f; t = t/d - 1.0f; return (c*(t*t*((s + 1.0f)*t + s) + 1.0f) + b); } -EASEDEF float EaseBackInOut(float t, float b, float c, float d) +EASEDEF float EaseBackInOut(float t, float b, float c, float d) // Ease: Back In Out { float s = 1.70158f; if ((t/=d/2.0f) < 1.0f) @@ -180,7 +180,7 @@ EASEDEF float EaseBackInOut(float t, float b, float c, float d) } // Bounce Easing functions -EASEDEF float EaseBounceOut(float t, float b, float c, float d) +EASEDEF float EaseBounceOut(float t, float b, float c, float d) // Ease: Bounce Out { if ((t/=d) < (1.0f/2.75f)) { @@ -203,15 +203,15 @@ EASEDEF float EaseBounceOut(float t, float b, float c, float d) } } -EASEDEF float EaseBounceIn(float t, float b, float c, float d) { return (c - EaseBounceOut(d - t, 0.0f, c, d) + b); } -EASEDEF float EaseBounceInOut(float t, float b, float c, float d) +EASEDEF float EaseBounceIn(float t, float b, float c, float d) { return (c - EaseBounceOut(d - t, 0.0f, c, d) + b); } // Ease: Bounce In +EASEDEF float EaseBounceInOut(float t, float b, float c, float d) // Ease: Bounce In Out { if (t < d/2.0f) return (EaseBounceIn(t*2.0f, 0.0f, c, d)*0.5f + b); else return (EaseBounceOut(t*2.0f - d, 0.0f, c, d)*0.5f + c*0.5f + b); } // Elastic Easing functions -EASEDEF float EaseElasticIn(float t, float b, float c, float d) +EASEDEF float EaseElasticIn(float t, float b, float c, float d) // Ease: Elastic In { if (t == 0.0f) return b; if ((t/=d) == 1.0f) return (b + c); @@ -224,7 +224,7 @@ EASEDEF float EaseElasticIn(float t, float b, float c, float d) return (-(postFix*sinf((t*d-s)*(2.0f*PI)/p )) + b); } -EASEDEF float EaseElasticOut(float t, float b, float c, float d) +EASEDEF float EaseElasticOut(float t, float b, float c, float d) // Ease: Elastic Out { if (t == 0.0f) return b; if ((t/=d) == 1.0f) return (b + c); @@ -236,7 +236,7 @@ EASEDEF float EaseElasticOut(float t, float b, float c, float d) return (a*powf(2.0f,-10.0f*t)*sinf((t*d-s)*(2.0f*PI)/p) + c + b); } -EASEDEF float EaseElasticInOut(float t, float b, float c, float d) +EASEDEF float EaseElasticInOut(float t, float b, float c, float d) // Ease: Elastic In Out { if (t == 0.0f) return b; if ((t/=d/2.0f) == 2.0f) return (b + c); diff --git a/examples/others/easings_testbed.c b/examples/others/easings_testbed.c index 19c3b4578..fbd71751c 100644 --- a/examples/others/easings_testbed.c +++ b/examples/others/easings_testbed.c @@ -56,10 +56,8 @@ enum EasingTypes { EASING_NONE = NUM_EASING_TYPES }; - static float NoEase(float t, float b, float c, float d); // NoEase function declaration, function used when "no easing" is selected for any axis - // Easing functions reference data static const struct { const char *name; @@ -96,7 +94,9 @@ static const struct { [EASING_NONE] = { .name = "None", .func = NoEase }, }; - +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/others/embedded_files_loading.c b/examples/others/embedded_files_loading.c index 5923a9acd..70864c732 100644 --- a/examples/others/embedded_files_loading.c +++ b/examples/others/embedded_files_loading.c @@ -16,6 +16,9 @@ #include "resources/audio_data.h" // Wave file exported with ExportWaveAsCode() #include "resources/image_data.h" // Image file exported with ExportImageAsCode() +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/others/raylib_opengl_interop.c b/examples/others/raylib_opengl_interop.c index 695910839..e55a0d389 100644 --- a/examples/others/raylib_opengl_interop.c +++ b/examples/others/raylib_opengl_interop.c @@ -49,7 +49,10 @@ typedef struct Particle { float period; } Particle; -int main() +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main(void) { // Initialization //-------------------------------------------------------------------------------------- diff --git a/examples/others/rlgl_compute_shader.c b/examples/others/rlgl_compute_shader.c index abc589348..9b82cfb7b 100644 --- a/examples/others/rlgl_compute_shader.c +++ b/examples/others/rlgl_compute_shader.c @@ -40,6 +40,9 @@ typedef struct GolUpdateSSBO { GolUpdateCmd commands[MAX_BUFFERED_TRANSFERTS]; } GolUpdateSSBO; +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/others/rlgl_standalone.c b/examples/others/rlgl_standalone.c index cc0eda2db..3796ea3cb 100644 --- a/examples/others/rlgl_standalone.c +++ b/examples/others/rlgl_standalone.c @@ -113,9 +113,9 @@ static void DrawRectangleV(Vector2 position, Vector2 size, Color color); //static Matrix MatrixPerspective(double fovy, double aspect, double near, double far); //static Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up); -//---------------------------------------------------------------------------------- -// Main Entry point -//---------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/physics/physics_demo.c b/examples/physics/physics_demo.c deleted file mode 100644 index dd7a216f7..000000000 --- a/examples/physics/physics_demo.c +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************************* -* -* raylib [physac] example - physics demo -* -* This example has been created using raylib 1.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* This example uses physac 1.1 (https://github.com/raysan5/raylib/blob/master/src/physac.h) -* -* Copyright (c) 2016-2021 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define PHYSAC_IMPLEMENTATION -#include "extras/physac.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "raylib [physac] example - physics demo"); - - // Physac logo drawing position - int logoX = screenWidth - MeasureText("Physac", 30) - 10; - int logoY = 15; - - // Initialize physics and default physics bodies - InitPhysics(); - - // Create floor rectangle physics body - PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, (float)screenHeight }, 500, 100, 10); - floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - - // Create obstacle circle physics body - PhysicsBody circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, 45, 10); - circle->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdatePhysics(); // Update physics system - - if (IsKeyPressed(KEY_R)) // Reset physics system - { - ResetPhysics(); - - floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, (float)screenHeight }, 500, 100, 10); - floor->enabled = false; - - circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, 45, 10); - circle->enabled = false; - } - - // Physics body creation inputs - if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) CreatePhysicsBodyPolygon(GetMousePosition(), (float)GetRandomValue(20, 80), GetRandomValue(3, 8), 10); - else if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) CreatePhysicsBodyCircle(GetMousePosition(), (float)GetRandomValue(10, 45), 10); - - // Destroy falling physics bodies - int bodiesCount = GetPhysicsBodiesCount(); - for (int i = bodiesCount - 1; i >= 0; i--) - { - PhysicsBody body = GetPhysicsBody(i); - if (body != NULL && (body->position.y > screenHeight*2)) DestroyPhysicsBody(body); - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(BLACK); - - DrawFPS(screenWidth - 90, screenHeight - 30); - - // Draw created physics bodies - bodiesCount = GetPhysicsBodiesCount(); - for (int i = 0; i < bodiesCount; i++) - { - PhysicsBody body = GetPhysicsBody(i); - - if (body != NULL) - { - int vertexCount = GetPhysicsShapeVerticesCount(i); - for (int j = 0; j < vertexCount; j++) - { - // Get physics bodies shape vertices to draw lines - // Note: GetPhysicsShapeVertex() already calculates rotation transformations - Vector2 vertexA = GetPhysicsShapeVertex(body, j); - - int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape - Vector2 vertexB = GetPhysicsShapeVertex(body, jj); - - DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions - } - } - } - - DrawText("Left mouse button to create a polygon", 10, 10, 10, WHITE); - DrawText("Right mouse button to create a circle", 10, 25, 10, WHITE); - DrawText("Press 'R' to reset example", 10, 40, 10, WHITE); - - DrawText("Physac", logoX, logoY, 30, WHITE); - DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClosePhysics(); // Unitialize physics - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/physics/physics_demo.png b/examples/physics/physics_demo.png deleted file mode 100644 index 12dc7e724..000000000 Binary files a/examples/physics/physics_demo.png and /dev/null differ diff --git a/examples/physics/physics_friction.c b/examples/physics/physics_friction.c deleted file mode 100644 index 544b9931d..000000000 --- a/examples/physics/physics_friction.c +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************************* -* -* raylib [physac] example - physics friction -* -* This example has been created using raylib 1.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* This example uses physac 1.1 (https://github.com/raysan5/raylib/blob/master/src/physac.h) -* -* Copyright (c) 2016-2021 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define PHYSAC_IMPLEMENTATION -#include "extras/physac.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "raylib [physac] example - physics friction"); - - // Physac logo drawing position - int logoX = screenWidth - MeasureText("Physac", 30) - 10; - int logoY = 15; - - // Initialize physics and default physics bodies - InitPhysics(); - - // Create floor rectangle physics body - PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, (float)screenHeight }, (float)screenWidth, 100, 10); - floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - PhysicsBody wall = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, screenHeight*0.8f }, 10, 80, 10); - wall->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - - // Create left ramp physics body - PhysicsBody rectLeft = CreatePhysicsBodyRectangle((Vector2){ 25, (float)screenHeight - 5 }, 250, 250, 10); - rectLeft->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - SetPhysicsBodyRotation(rectLeft, 30*DEG2RAD); - - // Create right ramp physics body - PhysicsBody rectRight = CreatePhysicsBodyRectangle((Vector2){ (float)screenWidth - 25, (float)screenHeight - 5 }, 250, 250, 10); - rectRight->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - SetPhysicsBodyRotation(rectRight, 330*DEG2RAD); - - // Create dynamic physics bodies - PhysicsBody bodyA = CreatePhysicsBodyRectangle((Vector2){ 35, screenHeight*0.6f }, 40, 40, 10); - bodyA->staticFriction = 0.1f; - bodyA->dynamicFriction = 0.1f; - SetPhysicsBodyRotation(bodyA, 30*DEG2RAD); - - PhysicsBody bodyB = CreatePhysicsBodyRectangle((Vector2){ (float)screenWidth - 35, (float)screenHeight*0.6f }, 40, 40, 10); - bodyB->staticFriction = 1.0f; - bodyB->dynamicFriction = 1.0f; - SetPhysicsBodyRotation(bodyB, 330*DEG2RAD); - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdatePhysics(); // Update physics system - - if (IsKeyPressed(KEY_R)) // Reset physics system - { - // Reset dynamic physics bodies position, velocity and rotation - bodyA->position = (Vector2){ 35, screenHeight*0.6f }; - bodyA->velocity = (Vector2){ 0, 0 }; - bodyA->angularVelocity = 0; - SetPhysicsBodyRotation(bodyA, 30*DEG2RAD); - - bodyB->position = (Vector2){ (float)screenWidth - 35, screenHeight * 0.6f }; - bodyB->velocity = (Vector2){ 0, 0 }; - bodyB->angularVelocity = 0; - SetPhysicsBodyRotation(bodyB, 330*DEG2RAD); - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(BLACK); - - DrawFPS(screenWidth - 90, screenHeight - 30); - - // Draw created physics bodies - int bodiesCount = GetPhysicsBodiesCount(); - for (int i = 0; i < bodiesCount; i++) - { - PhysicsBody body = GetPhysicsBody(i); - - if (body != NULL) - { - int vertexCount = GetPhysicsShapeVerticesCount(i); - for (int j = 0; j < vertexCount; j++) - { - // Get physics bodies shape vertices to draw lines - // Note: GetPhysicsShapeVertex() already calculates rotation transformations - Vector2 vertexA = GetPhysicsShapeVertex(body, j); - - int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape - Vector2 vertexB = GetPhysicsShapeVertex(body, jj); - - DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions - } - } - } - - DrawRectangle(0, screenHeight - 49, screenWidth, 49, BLACK); - - DrawText("Friction amount", (screenWidth - MeasureText("Friction amount", 30))/2.0f, 75, 30, WHITE); - DrawText("0.1", (int)bodyA->position.x - MeasureText("0.1", 20)/2, (int)bodyA->position.y - 7, 20, WHITE); - DrawText("1", (int)bodyB->position.x - MeasureText("1", 20)/2, (int)bodyB->position.y - 7, 20, WHITE); - - DrawText("Press 'R' to reset example", 10, 10, 10, WHITE); - - DrawText("Physac", logoX, logoY, 30, WHITE); - DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClosePhysics(); // Unitialize physics - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/physics/physics_friction.png b/examples/physics/physics_friction.png deleted file mode 100644 index e791ec2b9..000000000 Binary files a/examples/physics/physics_friction.png and /dev/null differ diff --git a/examples/physics/physics_movement.c b/examples/physics/physics_movement.c deleted file mode 100644 index 068611adb..000000000 --- a/examples/physics/physics_movement.c +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************************* -* -* raylib [physac] example - physics movement -* -* This example has been created using raylib 1.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* This example uses physac 1.1 (https://github.com/raysan5/raylib/blob/master/src/physac.h) -* -* Copyright (c) 2016-2021 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define PHYSAC_IMPLEMENTATION -#include "extras/physac.h" - -#define VELOCITY 0.5f - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "raylib [physac] example - physics movement"); - - // Physac logo drawing position - int logoX = screenWidth - MeasureText("Physac", 30) - 10; - int logoY = 15; - - // Initialize physics and default physics bodies - InitPhysics(); - - // Create floor and walls rectangle physics body - PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, (float)screenHeight }, (float)screenWidth, 100, 10); - PhysicsBody platformLeft = CreatePhysicsBodyRectangle((Vector2){ screenWidth*0.25f, screenHeight*0.6f }, screenWidth*0.25f, 10, 10); - PhysicsBody platformRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth*0.75f, screenHeight*0.6f }, screenWidth*0.25f, 10, 10); - PhysicsBody wallLeft = CreatePhysicsBodyRectangle((Vector2){ -5, screenHeight/2.0f }, 10, (float)screenHeight, 10); - PhysicsBody wallRight = CreatePhysicsBodyRectangle((Vector2){ (float)screenWidth + 5, screenHeight/2.0f }, 10, (float)screenHeight, 10); - - // Disable dynamics to floor and walls physics bodies - floor->enabled = false; - platformLeft->enabled = false; - platformRight->enabled = false; - wallLeft->enabled = false; - wallRight->enabled = false; - - // Create movement physics body - PhysicsBody body = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, 50, 50, 1); - body->freezeOrient = true; // Constrain body rotation to avoid little collision torque amounts - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdatePhysics(); // Update physics system - - if (IsKeyPressed(KEY_R)) // Reset physics input - { - // Reset movement physics body position, velocity and rotation - body->position = (Vector2){ screenWidth/2.0f, screenHeight/2.0f }; - body->velocity = (Vector2){ 0, 0 }; - SetPhysicsBodyRotation(body, 0); - } - - // Horizontal movement input - if (IsKeyDown(KEY_RIGHT)) body->velocity.x = VELOCITY; - else if (IsKeyDown(KEY_LEFT)) body->velocity.x = -VELOCITY; - - // Vertical movement input checking if player physics body is grounded - if (IsKeyDown(KEY_UP) && body->isGrounded) body->velocity.y = -VELOCITY*4; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(BLACK); - - DrawFPS(screenWidth - 90, screenHeight - 30); - - // Draw created physics bodies - int bodiesCount = GetPhysicsBodiesCount(); - for (int i = 0; i < bodiesCount; i++) - { - PhysicsBody body = GetPhysicsBody(i); - - int vertexCount = GetPhysicsShapeVerticesCount(i); - for (int j = 0; j < vertexCount; j++) - { - // Get physics bodies shape vertices to draw lines - // Note: GetPhysicsShapeVertex() already calculates rotation transformations - Vector2 vertexA = GetPhysicsShapeVertex(body, j); - - int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape - Vector2 vertexB = GetPhysicsShapeVertex(body, jj); - - DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions - } - } - - DrawText("Use 'ARROWS' to move player", 10, 10, 10, WHITE); - DrawText("Press 'R' to reset example", 10, 30, 10, WHITE); - - DrawText("Physac", logoX, logoY, 30, WHITE); - DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClosePhysics(); // Unitialize physics - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/physics/physics_movement.png b/examples/physics/physics_movement.png deleted file mode 100644 index a88a7d79f..000000000 Binary files a/examples/physics/physics_movement.png and /dev/null differ diff --git a/examples/physics/physics_restitution.c b/examples/physics/physics_restitution.c deleted file mode 100644 index 27241b685..000000000 --- a/examples/physics/physics_restitution.c +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************************* -* -* raylib [physac] example - physics restitution -* -* This example has been created using raylib 1.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* This example uses physac 1.1 (https://github.com/raysan5/raylib/blob/master/src/physac.h) -* -* Copyright (c) 2016-2021 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define PHYSAC_IMPLEMENTATION -#include "extras/physac.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "raylib [physac] example - physics restitution"); - - // Physac logo drawing position - int logoX = screenWidth - MeasureText("Physac", 30) - 10; - int logoY = 15; - - // Initialize physics and default physics bodies - InitPhysics(); - - // Create floor rectangle physics body - PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2.0f, (float)screenHeight }, (float)screenWidth, 100, 10); - floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - floor->restitution = 1; - - // Create circles physics body - PhysicsBody circleA = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.25f, screenHeight/2.0f }, 30, 10); - circleA->restitution = 0; - PhysicsBody circleB = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.5f, screenHeight/2.0f }, 30, 10); - circleB->restitution = 0.5f; - PhysicsBody circleC = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.75f, screenHeight/2.0f }, 30, 10); - circleC->restitution = 1; - - // Restitution demo needs a very tiny physics time step for a proper simulation - SetPhysicsTimeStep(1.0/60.0/100*1000); - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdatePhysics(); // Update physics system - - if (IsKeyPressed(KEY_R)) // Reset physics input - { - // Reset circles physics bodies position and velocity - circleA->position = (Vector2){ screenWidth*0.25f, screenHeight/2.0f }; - circleA->velocity = (Vector2){ 0, 0 }; - circleB->position = (Vector2){ screenWidth*0.5f, screenHeight/2.0f }; - circleB->velocity = (Vector2){ 0, 0 }; - circleC->position = (Vector2){ screenWidth*0.75f, screenHeight/2.0f }; - circleC->velocity = (Vector2){ 0, 0 }; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(BLACK); - - DrawFPS(screenWidth - 90, screenHeight - 30); - - // Draw created physics bodies - int bodiesCount = GetPhysicsBodiesCount(); - for (int i = 0; i < bodiesCount; i++) - { - PhysicsBody body = GetPhysicsBody(i); - - int vertexCount = GetPhysicsShapeVerticesCount(i); - for (int j = 0; j < vertexCount; j++) - { - // Get physics bodies shape vertices to draw lines - // Note: GetPhysicsShapeVertex() already calculates rotation transformations - Vector2 vertexA = GetPhysicsShapeVertex(body, j); - - int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape - Vector2 vertexB = GetPhysicsShapeVertex(body, jj); - - DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions - } - } - - DrawText("Restitution amount", (screenWidth - MeasureText("Restitution amount", 30))/2, 75, 30, WHITE); - DrawText("0", (int)circleA->position.x - MeasureText("0", 20)/2, circleA->position.y - 7, 20, WHITE); - DrawText("0.5", (int)circleB->position.x - MeasureText("0.5", 20)/2, circleB->position.y - 7, 20, WHITE); - DrawText("1", (int)circleC->position.x - MeasureText("1", 20)/2, circleC->position.y - 7, 20, WHITE); - - DrawText("Press 'R' to reset example", 10, 10, 10, WHITE); - - DrawText("Physac", logoX, logoY, 30, WHITE); - DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - DestroyPhysicsBody(circleA); - DestroyPhysicsBody(circleB); - DestroyPhysicsBody(circleC); - DestroyPhysicsBody(floor); - - ClosePhysics(); // Unitialize physics - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/physics/physics_restitution.png b/examples/physics/physics_restitution.png deleted file mode 100644 index 8ec4b3f32..000000000 Binary files a/examples/physics/physics_restitution.png and /dev/null differ diff --git a/examples/physics/physics_shatter.c b/examples/physics/physics_shatter.c deleted file mode 100644 index 809227eea..000000000 --- a/examples/physics/physics_shatter.c +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************************* -* -* raylib [physac] example - physics shatter -* -* This example has been created using raylib 1.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* This example uses physac 1.1 (https://github.com/raysan5/raylib/blob/master/src/physac.h) -* -* Copyright (c) 2016-2021 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define PHYSAC_IMPLEMENTATION -#include "extras/physac.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "raylib [physac] example - physics shatter"); - - // Physac logo drawing position - int logoX = screenWidth - MeasureText("Physac", 30) - 10; - int logoY = 15; - - // Initialize physics and default physics bodies - InitPhysics(); - SetPhysicsGravity(0, 0); - - // Create random polygon physics body to shatter - CreatePhysicsBodyPolygon((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, (float)GetRandomValue(80, 200), GetRandomValue(3, 8), 10); - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - //---------------------------------------------------------------------------------- - UpdatePhysics(); // Update physics system - - if (IsKeyPressed(KEY_R)) // Reset physics input - { - ResetPhysics(); - - CreatePhysicsBodyPolygon((Vector2){ screenWidth/2.0f, screenHeight/2.0f }, (float)GetRandomValue(80, 200), GetRandomValue(3, 8), 10); - } - - if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) // Physics shatter input - { - int count = GetPhysicsBodiesCount(); - for (int i = count - 1; i >= 0; i--) - { - PhysicsBody currentBody = GetPhysicsBody(i); - - if (currentBody != NULL) PhysicsShatter(currentBody, GetMousePosition(), 10/currentBody->inverseMass); - } - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(BLACK); - - // Draw created physics bodies - int bodiesCount = GetPhysicsBodiesCount(); - for (int i = 0; i < bodiesCount; i++) - { - PhysicsBody currentBody = GetPhysicsBody(i); - - int vertexCount = GetPhysicsShapeVerticesCount(i); - for (int j = 0; j < vertexCount; j++) - { - // Get physics bodies shape vertices to draw lines - // Note: GetPhysicsShapeVertex() already calculates rotation transformations - Vector2 vertexA = GetPhysicsShapeVertex(currentBody, j); - - int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape - Vector2 vertexB = GetPhysicsShapeVertex(currentBody, jj); - - DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions - } - } - - DrawText("Left mouse button in polygon area to shatter body\nPress 'R' to reset example", 10, 10, 10, WHITE); - - DrawText("Physac", logoX, logoY, 30, WHITE); - DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClosePhysics(); // Unitialize physics - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/physics/physics_shatter.png b/examples/physics/physics_shatter.png deleted file mode 100644 index 68f9a1b7d..000000000 Binary files a/examples/physics/physics_shatter.png and /dev/null differ diff --git a/examples/shaders/resources/shaders/glsl330/base_lighting_instanced.vs b/examples/shaders/resources/shaders/glsl330/lighting_instancing.vs similarity index 100% rename from examples/shaders/resources/shaders/glsl330/base_lighting_instanced.vs rename to examples/shaders/resources/shaders/glsl330/lighting_instancing.vs diff --git a/examples/shaders/rlights.h b/examples/shaders/rlights.h index a1b298881..cf0f7629a 100644 --- a/examples/shaders/rlights.h +++ b/examples/shaders/rlights.h @@ -11,7 +11,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2017-2020 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) +* Copyright (c) 2017-2022 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. @@ -36,7 +36,7 @@ //---------------------------------------------------------------------------------- // Defines and Macros //---------------------------------------------------------------------------------- -#define MAX_LIGHTS 4 // Max dynamic lights supported by shader +#define MAX_LIGHTS 4 // Max dynamic lights supported by shader //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -45,22 +45,24 @@ // Light data typedef struct { int type; + bool enabled; Vector3 position; Vector3 target; Color color; - bool enabled; + float attenuation; // Shader locations int enabledLoc; int typeLoc; - int posLoc; + int positionLoc; int targetLoc; int colorLoc; + int attenuationLoc; } Light; // Light type typedef enum { - LIGHT_DIRECTIONAL, + LIGHT_DIRECTIONAL = 0, LIGHT_POINT } LightType; @@ -128,27 +130,12 @@ Light CreateLight(int type, Vector3 position, Vector3 target, Color color, Shade light.target = target; light.color = color; - // TODO: Below code doesn't look good to me, - // it assumes a specific shader naming and structure - // Probably this implementation could be improved - char enabledName[32] = "lights[x].enabled\0"; - char typeName[32] = "lights[x].type\0"; - char posName[32] = "lights[x].position\0"; - char targetName[32] = "lights[x].target\0"; - char colorName[32] = "lights[x].color\0"; - - // Set location name [x] depending on lights count - enabledName[7] = '0' + lightsCount; - typeName[7] = '0' + lightsCount; - posName[7] = '0' + lightsCount; - targetName[7] = '0' + lightsCount; - colorName[7] = '0' + lightsCount; - - light.enabledLoc = GetShaderLocation(shader, enabledName); - light.typeLoc = GetShaderLocation(shader, typeName); - light.posLoc = GetShaderLocation(shader, posName); - light.targetLoc = GetShaderLocation(shader, targetName); - light.colorLoc = GetShaderLocation(shader, colorName); + // NOTE: Lighting shader naming must be the provided ones + light.enabledLoc = GetShaderLocation(shader, TextFormat("lights[%i].enabled", lightsCount)); + light.typeLoc = GetShaderLocation(shader, TextFormat("lights[%i].type", lightsCount)); + light.positionLoc = GetShaderLocation(shader, TextFormat("lights[%i].position", lightsCount)); + light.targetLoc = GetShaderLocation(shader, TextFormat("lights[%i].target", lightsCount)); + light.colorLoc = GetShaderLocation(shader, TextFormat("lights[%i].color", lightsCount)); UpdateLightValues(shader, light); @@ -168,7 +155,7 @@ void UpdateLightValues(Shader shader, Light light) // Send to shader light position values float position[3] = { light.position.x, light.position.y, light.position.z }; - SetShaderValue(shader, light.posLoc, position, SHADER_UNIFORM_VEC3); + SetShaderValue(shader, light.positionLoc, position, SHADER_UNIFORM_VEC3); // Send to shader light target position values float target[3] = { light.target.x, light.target.y, light.target.z }; diff --git a/examples/shaders/shaders_basic_lighting.c b/examples/shaders/shaders_basic_lighting.c index 347096fd7..d9a9e7f1d 100644 --- a/examples/shaders/shaders_basic_lighting.c +++ b/examples/shaders/shaders_basic_lighting.c @@ -30,6 +30,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization @@ -52,10 +55,10 @@ int main(void) Model model = LoadModelFromMesh(GenMeshPlane(10.0f, 10.0f, 3, 3)); Model cube = LoadModelFromMesh(GenMeshCube(2.0f, 4.0f, 2.0f)); + // Load basic lighting shader Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting.vs", GLSL_VERSION), TextFormat("resources/shaders/glsl%i/lighting.fs", GLSL_VERSION)); - - // Get some required shader loactions + // Get some required shader locations shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos"); // NOTE: "matModel" location name is automatically assigned on shader loading, // no need to get the location again if using that uniform name @@ -69,7 +72,7 @@ int main(void) model.materials[0].shader = shader; cube.materials[0].shader = shader; - // Using 4 point lights: gold, red, green and blue + // Create lights Light lights[MAX_LIGHTS] = { 0 }; lights[0] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, -2 }, Vector3Zero(), YELLOW, shader); lights[1] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, 2 }, Vector3Zero(), RED, shader); @@ -87,6 +90,10 @@ int main(void) // Update //---------------------------------------------------------------------------------- UpdateCamera(&camera); // Update camera + + // Update the shader with the camera view vector (points towards { 0.0f, 0.0f, 0.0f }) + float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z }; + SetShaderValue(shader, shader.locs[SHADER_LOC_VECTOR_VIEW], cameraPos, SHADER_UNIFORM_VEC3); // Check key inputs to enable/disable lights if (IsKeyPressed(KEY_Y)) { lights[0].enabled = !lights[0].enabled; } @@ -95,14 +102,7 @@ int main(void) if (IsKeyPressed(KEY_B)) { lights[3].enabled = !lights[3].enabled; } // Update light values (actually, only enable/disable them) - UpdateLightValues(shader, lights[0]); - UpdateLightValues(shader, lights[1]); - UpdateLightValues(shader, lights[2]); - UpdateLightValues(shader, lights[3]); - - // Update the shader with the camera view vector (points towards { 0.0f, 0.0f, 0.0f }) - float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z }; - SetShaderValue(shader, shader.locs[SHADER_LOC_VECTOR_VIEW], cameraPos, SHADER_UNIFORM_VEC3); + for (int i = 0; i < MAX_LIGHTS; i++) UpdateLightValues(shader, lights[i]); //---------------------------------------------------------------------------------- // Draw @@ -116,15 +116,12 @@ int main(void) DrawModel(model, Vector3Zero(), 1.0f, WHITE); DrawModel(cube, Vector3Zero(), 1.0f, WHITE); - // Draw markers to show where the lights are - if (lights[0].enabled) DrawSphereEx(lights[0].position, 0.2f, 8, 8, YELLOW); - else DrawSphereWires(lights[0].position, 0.2f, 8, 8, ColorAlpha(YELLOW, 0.3f)); - if (lights[1].enabled) DrawSphereEx(lights[1].position, 0.2f, 8, 8, RED); - else DrawSphereWires(lights[1].position, 0.2f, 8, 8, ColorAlpha(RED, 0.3f)); - if (lights[2].enabled) DrawSphereEx(lights[2].position, 0.2f, 8, 8, GREEN); - else DrawSphereWires(lights[2].position, 0.2f, 8, 8, ColorAlpha(GREEN, 0.3f)); - if (lights[3].enabled) DrawSphereEx(lights[3].position, 0.2f, 8, 8, BLUE); - else DrawSphereWires(lights[3].position, 0.2f, 8, 8, ColorAlpha(BLUE, 0.3f)); + // Draw spheres to show where the lights are + for (int i = 0; i < MAX_LIGHTS; i++) + { + if (lights[i].enabled) DrawSphereEx(lights[i].position, 0.2f, 8, 8, lights[i].color); + else DrawSphereWires(lights[i].position, 0.2f, 8, 8, ColorAlpha(lights[i].color, 0.3f)); + } DrawGrid(10, 1.0f); diff --git a/examples/shaders/shaders_custom_uniform.c b/examples/shaders/shaders_custom_uniform.c index 60516c110..065f48dfb 100644 --- a/examples/shaders/shaders_custom_uniform.c +++ b/examples/shaders/shaders_custom_uniform.c @@ -24,6 +24,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_eratosthenes.c b/examples/shaders/shaders_eratosthenes.c index 65fd9f980..7e9794fd4 100644 --- a/examples/shaders/shaders_eratosthenes.c +++ b/examples/shaders/shaders_eratosthenes.c @@ -31,6 +31,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_fog.c b/examples/shaders/shaders_fog.c index fef311c41..ebad7f2c9 100644 --- a/examples/shaders/shaders_fog.c +++ b/examples/shaders/shaders_fog.c @@ -38,6 +38,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_hot_reloading.c b/examples/shaders/shaders_hot_reloading.c index b6ca8b68b..6815d40cf 100644 --- a/examples/shaders/shaders_hot_reloading.c +++ b/examples/shaders/shaders_hot_reloading.c @@ -23,6 +23,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_julia_set.c b/examples/shaders/shaders_julia_set.c index 90c44cf58..5f609d8c7 100644 --- a/examples/shaders/shaders_julia_set.c +++ b/examples/shaders/shaders_julia_set.c @@ -35,6 +35,9 @@ const float pointsOfInterest[6][2] = { -0.70176f, -0.3842f }, }; +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_mesh_instancing.c b/examples/shaders/shaders_mesh_instancing.c index 8be576720..c1e48c021 100644 --- a/examples/shaders/shaders_mesh_instancing.c +++ b/examples/shaders/shaders_mesh_instancing.c @@ -7,7 +7,7 @@ * * Example contributed by @seanpringle and reviewed by Max (@moliad) and Ramon Santamaria (@raysan5) * -* Copyright (c) 2020-2021 @seanpringle, Max (@moliad) and Ramon Santamaria (@raysan5) +* Copyright (c) 2020-2022 @seanpringle, Max (@moliad) and Ramon Santamaria (@raysan5) * ********************************************************************************************/ @@ -18,8 +18,8 @@ #define RLIGHTS_IMPLEMENTATION #include "rlights.h" -#include -#include +#include // Required for: calloc(), free() +#include // Required for: #if defined(PLATFORM_DESKTOP) #define GLSL_VERSION 330 @@ -27,7 +27,7 @@ #define GLSL_VERSION 100 #endif -#define MAX_INSTANCES 10000 +#define MAX_INSTANCES 8000 //------------------------------------------------------------------------------------ // Program main entry point @@ -38,18 +38,9 @@ int main(void) //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 450; - const int fps = 60; - SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) InitWindow(screenWidth, screenHeight, "raylib [shaders] example - mesh instancing"); - int speed = 30; // Speed of jump animation - int groups = 2; // Count of separate groups jumping around - float amp = 10; // Maximum amplitude of jump - float variance = 0.8f; // Global variance in jump height - float loop = 0.0f; // Individual cube's computed loop timer - float x = 0.0f, y = 0.0f, z = 0.0f; // Used for various 3D coordinate & vector ops - // Define the camera to look into our 3d world Camera camera = { 0 }; camera.position = (Vector3){ -125.0f, 125.0f, -125.0f }; @@ -58,113 +49,64 @@ int main(void) camera.fovy = 45.0f; camera.projection = CAMERA_PERSPECTIVE; + // Define mesh to be instanced Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f); - Matrix *rotations = RL_MALLOC(MAX_INSTANCES*sizeof(Matrix)); // Rotation state of instances - Matrix *rotationsInc = RL_MALLOC(MAX_INSTANCES*sizeof(Matrix)); // Per-frame rotation animation of instances - Matrix *translations = RL_MALLOC(MAX_INSTANCES*sizeof(Matrix)); // Locations of instances + // Define transforms to be uploaded to GPU for instances + Matrix *transforms = (Matrix *)RL_CALLOC(MAX_INSTANCES, sizeof(Matrix)); // Pre-multiplied transformations passed to rlgl - // Scatter random cubes around + // Translate and rotate cubes randomly for (int i = 0; i < MAX_INSTANCES; i++) { - x = (float)GetRandomValue(-50, 50); - y = (float)GetRandomValue(-50, 50); - z = (float)GetRandomValue(-50, 50); - translations[i] = MatrixTranslate(x, y, z); - - x = (float)GetRandomValue(0, 360); - y = (float)GetRandomValue(0, 360); - z = (float)GetRandomValue(0, 360); - Vector3 axis = Vector3Normalize((Vector3){ x, y, z }); + Matrix translation = MatrixTranslate((float)GetRandomValue(-50, 50), (float)GetRandomValue(-50, 50), (float)GetRandomValue(-50, 50)); + Vector3 axis = Vector3Normalize((Vector3){ (float)GetRandomValue(0, 360), (float)GetRandomValue(0, 360), (float)GetRandomValue(0, 360) }); float angle = (float)GetRandomValue(0, 10)*DEG2RAD; - - rotationsInc[i] = MatrixRotate(axis, angle); - rotations[i] = MatrixIdentity(); + Matrix rotation = MatrixRotate(axis, angle); + + transforms[i] = MatrixMultiply(rotation, translation); } - Matrix *transforms = RL_MALLOC(MAX_INSTANCES*sizeof(Matrix)); // Pre-multiplied transformations passed to rlgl - - Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting_instanced.vs", GLSL_VERSION), + // Load lighting shader + Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/lighting_instancing.vs", GLSL_VERSION), TextFormat("resources/shaders/glsl%i/lighting.fs", GLSL_VERSION)); - - // Get some shader loactions + // Get shader locations shader.locs[SHADER_LOC_MATRIX_MVP] = GetShaderLocation(shader, "mvp"); shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos"); shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocationAttrib(shader, "instanceTransform"); - // Ambient light level + // Set shader value: ambient light level int ambientLoc = GetShaderLocation(shader, "ambient"); SetShaderValue(shader, ambientLoc, (float[4]){ 0.2f, 0.2f, 0.2f, 1.0f }, SHADER_UNIFORM_VEC4); + // Create one light CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 50.0f, 50.0f, 0.0f }, Vector3Zero(), WHITE, shader); // NOTE: We are assigning the intancing shader to material.shader // to be used on mesh drawing with DrawMeshInstanced() - Material material = LoadMaterialDefault(); - material.shader = shader; - material.maps[MATERIAL_MAP_DIFFUSE].color = RED; + Material matInstances = LoadMaterialDefault(); + matInstances.shader = shader; + matInstances.maps[MATERIAL_MAP_DIFFUSE].color = RED; - SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode + // Create a defult material with default internal shader for non-instanced mesh drawing + Material matDefault = LoadMaterialDefault(); + matDefault.maps[MATERIAL_MAP_DIFFUSE].color = BLUE; - int textPositionY = 300; - int framesCounter = 0; // Simple frames counter to manage animation + // Set an orbital camera mode + SetCameraMode(camera, CAMERA_ORBITAL); - SetTargetFPS(fps); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { - // Update //---------------------------------------------------------------------------------- - textPositionY = 300; - framesCounter++; - - if (IsKeyDown(KEY_UP)) amp += 0.5f; - if (IsKeyDown(KEY_DOWN)) amp = (amp <= 1)? 1.0f : (amp - 1.0f); - if (IsKeyDown(KEY_LEFT)) variance = (variance <= 0.0f)? 0.0f : (variance - 0.01f); - if (IsKeyDown(KEY_RIGHT)) variance = (variance >= 1.0f)? 1.0f : (variance + 0.01f); - if (IsKeyDown(KEY_ONE)) groups = 1; - if (IsKeyDown(KEY_TWO)) groups = 2; - if (IsKeyDown(KEY_THREE)) groups = 3; - if (IsKeyDown(KEY_FOUR)) groups = 4; - if (IsKeyDown(KEY_FIVE)) groups = 5; - if (IsKeyDown(KEY_SIX)) groups = 6; - if (IsKeyDown(KEY_SEVEN)) groups = 7; - if (IsKeyDown(KEY_EIGHT)) groups = 8; - if (IsKeyDown(KEY_NINE)) groups = 9; - if (IsKeyDown(KEY_W)) { groups = 7; amp = 25; speed = 18; variance = 0.70f; } - - if (IsKeyDown(KEY_EQUAL)) speed = (speed <= (fps*0.25f))? (int)(fps*0.25f) : (int)(speed*0.95f); - if (IsKeyDown(KEY_KP_ADD)) speed = (speed <= (fps*0.25f))? (int)(fps*0.25f) : (int)(speed*0.95f); - - if (IsKeyDown(KEY_MINUS)) speed = (int)fmaxf(speed*1.02f, speed + 1); - if (IsKeyDown(KEY_KP_SUBTRACT)) speed = (int)fmaxf(speed*1.02f, speed + 1); + UpdateCamera(&camera); // Update the light shader with the camera view position float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z }; SetShaderValue(shader, shader.locs[SHADER_LOC_VECTOR_VIEW], cameraPos, SHADER_UNIFORM_VEC3); - - // Apply per-instance transformations - for (int i = 0; i < MAX_INSTANCES; i++) - { - rotations[i] = MatrixMultiply(rotations[i], rotationsInc[i]); - transforms[i] = MatrixMultiply(rotations[i], translations[i]); - - // Get the animation cycle's framesCounter for this instance - loop = (float)((framesCounter + (int)(((float)(i%groups)/groups)*speed))%speed)/speed; - - // Calculate the y according to loop cycle - y = (sinf(loop*PI*2))*amp*((1 - variance) + (variance*(float)(i%(groups*10))/(groups*10))); - - // Clamp to floor - y = (y < 0)? 0.0f : y; - - transforms[i] = MatrixMultiply(transforms[i], MatrixTranslate(0.0f, y, 0.0f)); - } - - UpdateCamera(&camera); //---------------------------------------------------------------------------------- // Draw @@ -174,41 +116,20 @@ int main(void) ClearBackground(RAYWHITE); BeginMode3D(camera); - //DrawMesh(cube, material, MatrixIdentity()); - DrawMeshInstanced(cube, material, transforms, MAX_INSTANCES); + + // Draw cube mesh with default material (BLUE) + DrawMesh(cube, matDefault, MatrixTranslate(-10.0f, 0.0f, 0.0f)); + + // Draw meshes instanced using material containing instancing shader (RED + lighting), + // transforms[] for the instances should be provided, they are dynamically + // updated in GPU every frame, so we can animate the different mesh instances + DrawMeshInstanced(cube, matInstances, transforms, MAX_INSTANCES); + + // Draw cube mesh with default material (BLUE) + DrawMesh(cube, matDefault, MatrixTranslate(10.0f, 0.0f, 0.0f)); + EndMode3D(); - DrawText("A CUBE OF DANCING CUBES!", 490, 10, 20, MAROON); - DrawText("PRESS KEYS:", 10, textPositionY, 20, BLACK); - - DrawText("1 - 9", 10, textPositionY += 25, 10, BLACK); - DrawText(": Number of groups", 50, textPositionY , 10, BLACK); - DrawText(TextFormat(": %d", groups), 160, textPositionY , 10, BLACK); - - DrawText("UP", 10, textPositionY += 15, 10, BLACK); - DrawText(": increase amplitude", 50, textPositionY, 10, BLACK); - DrawText(TextFormat(": %.2f", amp), 160, textPositionY , 10, BLACK); - - DrawText("DOWN", 10, textPositionY += 15, 10, BLACK); - DrawText(": decrease amplitude", 50, textPositionY, 10, BLACK); - - DrawText("LEFT", 10, textPositionY += 15, 10, BLACK); - DrawText(": decrease variance", 50, textPositionY, 10, BLACK); - DrawText(TextFormat(": %.2f", variance), 160, textPositionY , 10, BLACK); - - DrawText("RIGHT", 10, textPositionY += 15, 10, BLACK); - DrawText(": increase variance", 50, textPositionY, 10, BLACK); - - DrawText("+/=", 10, textPositionY += 15, 10, BLACK); - DrawText(": increase speed", 50, textPositionY, 10, BLACK); - DrawText(TextFormat(": %d = %f loops/sec", speed, ((float)fps / speed)), 160, textPositionY , 10, BLACK); - - DrawText("-", 10, textPositionY += 15, 10, BLACK); - DrawText(": decrease speed", 50, textPositionY, 10, BLACK); - - DrawText("W", 10, textPositionY += 15, 10, BLACK); - DrawText(": Wild setup!", 50, textPositionY, 10, BLACK); - DrawFPS(10, 10); EndDrawing(); @@ -217,13 +138,9 @@ int main(void) // De-Initialization //-------------------------------------------------------------------------------------- - // Free allocated matrices - RL_FREE(rotations); - RL_FREE(rotationsInc); - RL_FREE(translations); - RL_FREE(transforms); + RL_FREE(transforms); // Free transforms - CloseWindow(); // Close window and OpenGL context + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; diff --git a/examples/shaders/shaders_model_shader.c b/examples/shaders/shaders_model_shader.c index 5c53b43e6..a55d70153 100644 --- a/examples/shaders/shaders_model_shader.c +++ b/examples/shaders/shaders_model_shader.c @@ -24,6 +24,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_multi_sample2d.c b/examples/shaders/shaders_multi_sample2d.c index fbe75085c..748d205df 100644 --- a/examples/shaders/shaders_multi_sample2d.c +++ b/examples/shaders/shaders_multi_sample2d.c @@ -24,6 +24,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_palette_switch.c b/examples/shaders/shaders_palette_switch.c index 43578fceb..2c6096b4e 100644 --- a/examples/shaders/shaders_palette_switch.c +++ b/examples/shaders/shaders_palette_switch.c @@ -69,6 +69,9 @@ static const char *paletteText[] = { "RKBV (2-strip film)" }; +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_postprocessing.c b/examples/shaders/shaders_postprocessing.c index ebe5fcdb4..67bd1f09e 100644 --- a/examples/shaders/shaders_postprocessing.c +++ b/examples/shaders/shaders_postprocessing.c @@ -58,6 +58,9 @@ static const char *postproShaderText[] = { //"FXAA" }; +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_raymarching.c b/examples/shaders/shaders_raymarching.c index 68fbd30ca..0cf300cc0 100644 --- a/examples/shaders/shaders_raymarching.c +++ b/examples/shaders/shaders_raymarching.c @@ -20,6 +20,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_shapes_textures.c b/examples/shaders/shaders_shapes_textures.c index 4d4c964c7..11b2a1387 100644 --- a/examples/shaders/shaders_shapes_textures.c +++ b/examples/shaders/shaders_shapes_textures.c @@ -24,6 +24,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_simple_mask.c b/examples/shaders/shaders_simple_mask.c index 981e64863..678e0f9d6 100644 --- a/examples/shaders/shaders_simple_mask.c +++ b/examples/shaders/shaders_simple_mask.c @@ -27,6 +27,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_spotlight.c b/examples/shaders/shaders_spotlight.c index e0a9ac5b9..94dfac479 100644 --- a/examples/shaders/shaders_spotlight.c +++ b/examples/shaders/shaders_spotlight.c @@ -64,6 +64,9 @@ typedef struct Star { void UpdateStar(Star *s); void ResetStar(Star *s); +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_texture_drawing.c b/examples/shaders/shaders_texture_drawing.c index a8cd5abfb..b070e61e6 100644 --- a/examples/shaders/shaders_texture_drawing.c +++ b/examples/shaders/shaders_texture_drawing.c @@ -21,6 +21,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_texture_outline.c b/examples/shaders/shaders_texture_outline.c index c40abf950..97ef4843e 100644 --- a/examples/shaders/shaders_texture_outline.c +++ b/examples/shaders/shaders_texture_outline.c @@ -22,6 +22,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shaders/shaders_texture_waves.c b/examples/shaders/shaders_texture_waves.c index 7d396fd12..d212d0b93 100644 --- a/examples/shaders/shaders_texture_waves.c +++ b/examples/shaders/shaders_texture_waves.c @@ -26,6 +26,9 @@ #define GLSL_VERSION 100 #endif +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/src/extras/raygui.h b/examples/shapes/raygui.h similarity index 67% rename from src/extras/raygui.h rename to examples/shapes/raygui.h index dfb7792c4..3e7dea442 100644 --- a/src/extras/raygui.h +++ b/examples/shapes/raygui.h @@ -1,6 +1,6 @@ /******************************************************************************************* * -* raygui v3.0 - A simple and easy-to-use immediate-mode gui library +* raygui v3.2 - A simple and easy-to-use immediate-mode gui library * * DESCRIPTION: * @@ -10,10 +10,11 @@ * Controls provided: * * # Container/separators Controls -* - WindowBox -* - GroupBox +* - WindowBox --> StatusBar, Panel +* - GroupBox --> Line * - Line -* - Panel +* - Panel --> StatusBar +* - ScrollPanel --> StatusBar * * # Basic Controls * - Label @@ -32,8 +33,6 @@ * - SliderBar --> Slider * - ProgressBar * - StatusBar -* - ScrollBar -* - ScrollPanel * - DummyRec * - Grid * @@ -46,7 +45,7 @@ * It also provides a set of functions for styling the controls based on its properties (size, color). * * -* GUI STYLE (guiStyle): +* RAYGUI STYLE (guiStyle): * * raygui uses a global data array for all gui style properties (allocated on data segment by default), * when a new style is loaded, it is loaded over the global style... but a default gui style could always be @@ -71,11 +70,11 @@ * TOOL: rGuiStyler is a visual tool to customize raygui style. * * -* GUI ICONS (guiIcons): +* RAYGUI ICONS (guiIcons): * * raygui could use a global array containing icons data (allocated on data segment by default), * a custom icons set could be loaded over this array using GuiLoadIcons(), but loaded icons set -* must be same RICON_SIZE and no more than RICON_MAX_ICONS will be loaded +* must be same RAYGUI_ICON_SIZE and no more than RAYGUI_ICON_MAX_ICONS will be loaded * * Every icon is codified in binary form, using 1 bit per pixel, so, every 16x16 icon * requires 8 integers (16*16/32) to be stored in memory. @@ -84,7 +83,7 @@ * * The global icons array size is fixed and depends on the number of icons and size: * -* static unsigned int guiIcons[RICON_MAX_ICONS*RICON_DATA_ELEMENTS]; +* static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS]; * * guiIcons size is by default: 256*(16*16/32) = 2048*4 = 8192 bytes = 8 KB * @@ -103,17 +102,32 @@ * internally in the library and input management and drawing functions must be provided by * the user (check library implementation for further details). * -* #define RAYGUI_NO_RICONS +* #define RAYGUI_NO_ICONS * Avoid including embedded ricons data (256 icons, 16x16 pixels, 1-bit per pixel, 2KB) * -* #define RAYGUI_CUSTOM_RICONS +* #define RAYGUI_CUSTOM_ICONS * Includes custom ricons.h header defining a set of custom icons, * this file can be generated using rGuiIcons tool * * * VERSIONS HISTORY: -* -* 3.0 (xx-Sep-2021) Integrated ricons data to avoid external file +* 3.2 (22-May-2022) RENAMED: Some enum values, for unification, avoiding prefixes +* REMOVED: GuiScrollBar(), only internal +* REDESIGNED: GuiPanel() to support text parameter +* REDESIGNED: GuiScrollPanel() to support text parameter +* REDESIGNED: GuiColorPicker() to support text parameter +* REDESIGNED: GuiColorPanel() to support text parameter +* REDESIGNED: GuiColorBarAlpha() to support text parameter +* REDESIGNED: GuiColorBarHue() to support text parameter +* REDESIGNED: GuiTextInputBox() to support password +* 3.1 (12-Jan-2022) REVIEWED: Default style for consistency (aligned with rGuiLayout v2.5 tool) +* REVIEWED: GuiLoadStyle() to support compressed font atlas image data and unload previous textures +* REVIEWED: External icons usage logic +* REVIEWED: GuiLine() for centered alignment when including text +* RENAMED: Multiple controls properties definitions to prepend RAYGUI_ +* RENAMED: RICON_ references to RAYGUI_ICON_ for library consistency +* Projects updated and multiple tweaks +* 3.0 (04-Nov-2021) Integrated ricons data to avoid external file * REDESIGNED: GuiTextBoxMulti() * REMOVED: GuiImageButton*() * Multiple minor tweaks and bugs corrected @@ -160,7 +174,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2021 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. @@ -182,7 +196,7 @@ #ifndef RAYGUI_H #define RAYGUI_H -#define RAYGUI_VERSION "3.0" +#define RAYGUI_VERSION "3.2" #if !defined(RAYGUI_STANDALONE) #include "raylib.h" @@ -206,7 +220,6 @@ //---------------------------------------------------------------------------------- // Defines and Macros //---------------------------------------------------------------------------------- - // Allow custom memory allocators #ifndef RAYGUI_MALLOC #define RAYGUI_MALLOC(sz) malloc(sz) @@ -218,8 +231,14 @@ #define RAYGUI_FREE(p) free(p) #endif -// TODO: Implement custom TraceLog() -#define TRACELOG(level, ...) (void)0 +// Simple log system to avoid printf() calls if required +// NOTE: Avoiding those calls, also avoids const strings memory usage +#define RAYGUI_SUPPORT_LOG_INFO +#if defined(RAYGUI_SUPPORT_LOG_INFO) + #define RAYGUI_LOG(...) printf(__VA_ARGS__) +#else + #define RAYGUI_LOG(...) +#endif //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -296,27 +315,29 @@ typedef struct GuiStyleProp { unsigned short controlId; unsigned short propertyId; - int propertyValue; + unsigned int propertyValue; } GuiStyleProp; // Gui control state typedef enum { - GUI_STATE_NORMAL = 0, - GUI_STATE_FOCUSED, - GUI_STATE_PRESSED, - GUI_STATE_DISABLED, -} GuiControlState; + STATE_NORMAL = 0, + STATE_FOCUSED, + STATE_PRESSED, + STATE_DISABLED, +} GuiState; // Gui control text alignment typedef enum { - GUI_TEXT_ALIGN_LEFT = 0, - GUI_TEXT_ALIGN_CENTER, - GUI_TEXT_ALIGN_RIGHT, + TEXT_ALIGN_LEFT = 0, + TEXT_ALIGN_CENTER, + TEXT_ALIGN_RIGHT, } GuiTextAlignment; // Gui controls typedef enum { - DEFAULT = 0, // Generic control -> populates to all controls when set + // Default -> populates to all controls when set + DEFAULT = 0, + // Basic controls LABEL, // Used also for: LABELBUTTON BUTTON, TOGGLE, // Used also for: TOGGLEGROUP @@ -327,7 +348,7 @@ typedef enum { DROPDOWNBOX, TEXTBOX, // Used also for: TEXTBOXMULTI VALUEBOX, - SPINNER, + SPINNER, // Uses: BUTTON, VALUEBOX LISTVIEW, COLORPICKER, SCROLLBAR, @@ -357,102 +378,98 @@ typedef enum { // Gui extended properties depend on control // NOTE: RAYGUI_MAX_PROPS_EXTENDED properties (by default 8 properties) +//---------------------------------------------------------------------------------- // DEFAULT extended properties -// NOTE: Those properties are actually common to all controls +// NOTE: Those properties are common to all controls or global typedef enum { - TEXT_SIZE = 16, - TEXT_SPACING, - LINE_COLOR, - BACKGROUND_COLOR, + TEXT_SIZE = 16, // Text size (glyphs max height) + TEXT_SPACING, // Text spacing between glyphs + LINE_COLOR, // Line control color + BACKGROUND_COLOR, // Background color } GuiDefaultProperty; // Label //typedef enum { } GuiLabelProperty; -// Button +// Button/Spinner //typedef enum { } GuiButtonProperty; // Toggle/ToggleGroup typedef enum { - GROUP_PADDING = 16, + GROUP_PADDING = 16, // ToggleGroup separation between toggles } GuiToggleProperty; // Slider/SliderBar typedef enum { - SLIDER_WIDTH = 16, - SLIDER_PADDING + SLIDER_WIDTH = 16, // Slider size of internal bar + SLIDER_PADDING // Slider/SliderBar internal bar padding } GuiSliderProperty; // ProgressBar typedef enum { - PROGRESS_PADDING = 16, + PROGRESS_PADDING = 16, // ProgressBar internal padding } GuiProgressBarProperty; -// CheckBox -typedef enum { - CHECK_PADDING = 16 -} GuiCheckBoxProperty; - -// ComboBox -typedef enum { - COMBO_BUTTON_WIDTH = 16, - COMBO_BUTTON_PADDING -} GuiComboBoxProperty; - -// DropdownBox -typedef enum { - ARROW_PADDING = 16, - DROPDOWN_ITEMS_PADDING -} GuiDropdownBoxProperty; - -// TextBox/TextBoxMulti/ValueBox/Spinner -typedef enum { - TEXT_INNER_PADDING = 16, - TEXT_LINES_PADDING, - COLOR_SELECTED_FG, - COLOR_SELECTED_BG -} GuiTextBoxProperty; - -// Spinner -typedef enum { - SPIN_BUTTON_WIDTH = 16, - SPIN_BUTTON_PADDING, -} GuiSpinnerProperty; - // ScrollBar typedef enum { ARROWS_SIZE = 16, ARROWS_VISIBLE, - SCROLL_SLIDER_PADDING, + SCROLL_SLIDER_PADDING, // (SLIDERBAR, SLIDER_PADDING) SCROLL_SLIDER_SIZE, SCROLL_PADDING, SCROLL_SPEED, } GuiScrollBarProperty; -// ScrollBar side +// CheckBox typedef enum { - SCROLLBAR_LEFT_SIDE = 0, - SCROLLBAR_RIGHT_SIDE -} GuiScrollBarSide; + CHECK_PADDING = 16 // CheckBox internal check padding +} GuiCheckBoxProperty; + +// ComboBox +typedef enum { + COMBO_BUTTON_WIDTH = 16, // ComboBox right button width + COMBO_BUTTON_SPACING // ComboBox button separation +} GuiComboBoxProperty; + +// DropdownBox +typedef enum { + ARROW_PADDING = 16, // DropdownBox arrow separation from border and items + DROPDOWN_ITEMS_SPACING // DropdownBox items separation +} GuiDropdownBoxProperty; + +// TextBox/TextBoxMulti/ValueBox/Spinner +typedef enum { + TEXT_INNER_PADDING = 16, // TextBox/TextBoxMulti/ValueBox/Spinner inner text padding + TEXT_LINES_SPACING, // TextBoxMulti lines separation +} GuiTextBoxProperty; + +// Spinner +typedef enum { + SPIN_BUTTON_WIDTH = 16, // Spinner left/right buttons width + SPIN_BUTTON_SPACING, // Spinner buttons separation +} GuiSpinnerProperty; // ListView typedef enum { - LIST_ITEMS_HEIGHT = 16, - LIST_ITEMS_PADDING, - SCROLLBAR_WIDTH, - SCROLLBAR_SIDE, + LIST_ITEMS_HEIGHT = 16, // ListView items height + LIST_ITEMS_SPACING, // ListView items separation + SCROLLBAR_WIDTH, // ListView scrollbar size (usually width) + SCROLLBAR_SIDE, // ListView scrollbar side (0-left, 1-right) } GuiListViewProperty; // ColorPicker typedef enum { COLOR_SELECTOR_SIZE = 16, - HUEBAR_WIDTH, // Right hue bar width - HUEBAR_PADDING, // Right hue bar separation from panel - HUEBAR_SELECTOR_HEIGHT, // Right hue bar selector height - HUEBAR_SELECTOR_OVERFLOW // Right hue bar selector overflow + HUEBAR_WIDTH, // ColorPicker right hue bar width + HUEBAR_PADDING, // ColorPicker right hue bar separation from panel + HUEBAR_SELECTOR_HEIGHT, // ColorPicker right hue bar selector height + HUEBAR_SELECTOR_OVERFLOW // ColorPicker right hue bar selector overflow } GuiColorPickerProperty; +#define SCROLLBAR_LEFT_SIDE 0 +#define SCROLLBAR_RIGHT_SIDE 1 + //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- @@ -488,8 +505,8 @@ RAYGUIAPI int GuiGetStyle(int control, int property); // Get o RAYGUIAPI bool GuiWindowBox(Rectangle bounds, const char *title); // Window Box control, shows a window that can be closed RAYGUIAPI void GuiGroupBox(Rectangle bounds, const char *text); // Group Box control with text name RAYGUIAPI void GuiLine(Rectangle bounds, const char *text); // Line separator control, could contain text -RAYGUIAPI void GuiPanel(Rectangle bounds); // Panel control, useful to group controls -RAYGUIAPI Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll); // Scroll Panel control +RAYGUIAPI void GuiPanel(Rectangle bounds, const char *text); // Panel control, useful to group controls +RAYGUIAPI Rectangle GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content, Vector2 *scroll); // Scroll Panel control // Basic controls set RAYGUIAPI void GuiLabel(Rectangle bounds, const char *text); // Label control, shows text @@ -509,43 +526,301 @@ RAYGUIAPI float GuiSliderBar(Rectangle bounds, const char *textLeft, const char RAYGUIAPI float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Progress Bar control, shows current progress value RAYGUIAPI void GuiStatusBar(Rectangle bounds, const char *text); // Status Bar control, shows info text RAYGUIAPI void GuiDummyRec(Rectangle bounds, const char *text); // Dummy control for placeholders -RAYGUIAPI int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue); // Scroll Bar control -RAYGUIAPI Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs); // Grid control - +RAYGUIAPI Vector2 GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs); // Grid control, returns mouse cell position // Advance controls set RAYGUIAPI int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active); // List View control, returns selected list item index RAYGUIAPI int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active); // List View with extended parameters RAYGUIAPI int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons); // Message Box control, displays a message -RAYGUIAPI int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text); // Text Input Box control, ask for text -RAYGUIAPI Color GuiColorPicker(Rectangle bounds, Color color); // Color Picker control (multiple color controls) -RAYGUIAPI Color GuiColorPanel(Rectangle bounds, Color color); // Color Panel control -RAYGUIAPI float GuiColorBarAlpha(Rectangle bounds, float alpha); // Color Bar Alpha control -RAYGUIAPI float GuiColorBarHue(Rectangle bounds, float value); // Color Bar Hue control +RAYGUIAPI int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text, int textMaxSize, int *secretViewActive); // Text Input Box control, ask for text, supports secret +RAYGUIAPI Color GuiColorPicker(Rectangle bounds, const char *text, Color color); // Color Picker control (multiple color controls) +RAYGUIAPI Color GuiColorPanel(Rectangle bounds, const char *text, Color color); // Color Panel control +RAYGUIAPI float GuiColorBarAlpha(Rectangle bounds, const char *text, float alpha); // Color Bar Alpha control +RAYGUIAPI float GuiColorBarHue(Rectangle bounds, const char *text, float value); // Color Bar Hue control // Styles loading functions RAYGUIAPI void GuiLoadStyle(const char *fileName); // Load style file over global style variable (.rgs) RAYGUIAPI void GuiLoadStyleDefault(void); // Load style default over global style -/* -typedef GuiStyle (unsigned int *) -RAYGUIAPI GuiStyle LoadGuiStyle(const char *fileName); // Load style from file (.rgs) -RAYGUIAPI void UnloadGuiStyle(GuiStyle style); // Unload style -*/ - +// Icons functionality RAYGUIAPI const char *GuiIconText(int iconId, const char *text); // Get text with icon id prepended (if supported) -#if !defined(RAYGUI_NO_RICONS) -// Gui icons functionality +#if !defined(RAYGUI_NO_ICONS) RAYGUIAPI void GuiDrawIcon(int iconId, int posX, int posY, int pixelSize, Color color); RAYGUIAPI unsigned int *GuiGetIcons(void); // Get full icons data pointer RAYGUIAPI unsigned int *GuiGetIconData(int iconId); // Get icon bit data RAYGUIAPI void GuiSetIconData(int iconId, unsigned int *data); // Set icon bit data +RAYGUIAPI void GuiSetIconScale(unsigned int scale); // Set icon scale (1 by default) RAYGUIAPI void GuiSetIconPixel(int iconId, int x, int y); // Set icon pixel value RAYGUIAPI void GuiClearIconPixel(int iconId, int x, int y); // Clear icon pixel value RAYGUIAPI bool GuiCheckIconPixel(int iconId, int x, int y); // Check icon pixel value + +#if !defined(RAYGUI_CUSTOM_ICONS) +//---------------------------------------------------------------------------------- +// Icons enumeration +//---------------------------------------------------------------------------------- +typedef enum { + ICON_NONE = 0, + ICON_FOLDER_FILE_OPEN = 1, + ICON_FILE_SAVE_CLASSIC = 2, + ICON_FOLDER_OPEN = 3, + ICON_FOLDER_SAVE = 4, + ICON_FILE_OPEN = 5, + ICON_FILE_SAVE = 6, + ICON_FILE_EXPORT = 7, + ICON_FILE_ADD = 8, + ICON_FILE_DELETE = 9, + ICON_FILETYPE_TEXT = 10, + ICON_FILETYPE_AUDIO = 11, + ICON_FILETYPE_IMAGE = 12, + ICON_FILETYPE_PLAY = 13, + ICON_FILETYPE_VIDEO = 14, + ICON_FILETYPE_INFO = 15, + ICON_FILE_COPY = 16, + ICON_FILE_CUT = 17, + ICON_FILE_PASTE = 18, + ICON_CURSOR_HAND = 19, + ICON_CURSOR_POINTER = 20, + ICON_CURSOR_CLASSIC = 21, + ICON_PENCIL = 22, + ICON_PENCIL_BIG = 23, + ICON_BRUSH_CLASSIC = 24, + ICON_BRUSH_PAINTER = 25, + ICON_WATER_DROP = 26, + ICON_COLOR_PICKER = 27, + ICON_RUBBER = 28, + ICON_COLOR_BUCKET = 29, + ICON_TEXT_T = 30, + ICON_TEXT_A = 31, + ICON_SCALE = 32, + ICON_RESIZE = 33, + ICON_FILTER_POINT = 34, + ICON_FILTER_BILINEAR = 35, + ICON_CROP = 36, + ICON_CROP_ALPHA = 37, + ICON_SQUARE_TOGGLE = 38, + ICON_SYMMETRY = 39, + ICON_SYMMETRY_HORIZONTAL = 40, + ICON_SYMMETRY_VERTICAL = 41, + ICON_LENS = 42, + ICON_LENS_BIG = 43, + ICON_EYE_ON = 44, + ICON_EYE_OFF = 45, + ICON_FILTER_TOP = 46, + ICON_FILTER = 47, + ICON_TARGET_POINT = 48, + ICON_TARGET_SMALL = 49, + ICON_TARGET_BIG = 50, + ICON_TARGET_MOVE = 51, + ICON_CURSOR_MOVE = 52, + ICON_CURSOR_SCALE = 53, + ICON_CURSOR_SCALE_RIGHT = 54, + ICON_CURSOR_SCALE_LEFT = 55, + ICON_UNDO = 56, + ICON_REDO = 57, + ICON_REREDO = 58, + ICON_MUTATE = 59, + ICON_ROTATE = 60, + ICON_REPEAT = 61, + ICON_SHUFFLE = 62, + ICON_EMPTYBOX = 63, + ICON_TARGET = 64, + ICON_TARGET_SMALL_FILL = 65, + ICON_TARGET_BIG_FILL = 66, + ICON_TARGET_MOVE_FILL = 67, + ICON_CURSOR_MOVE_FILL = 68, + ICON_CURSOR_SCALE_FILL = 69, + ICON_CURSOR_SCALE_RIGHT_FILL = 70, + ICON_CURSOR_SCALE_LEFT_FILL = 71, + ICON_UNDO_FILL = 72, + ICON_REDO_FILL = 73, + ICON_REREDO_FILL = 74, + ICON_MUTATE_FILL = 75, + ICON_ROTATE_FILL = 76, + ICON_REPEAT_FILL = 77, + ICON_SHUFFLE_FILL = 78, + ICON_EMPTYBOX_SMALL = 79, + ICON_BOX = 80, + ICON_BOX_TOP = 81, + ICON_BOX_TOP_RIGHT = 82, + ICON_BOX_RIGHT = 83, + ICON_BOX_BOTTOM_RIGHT = 84, + ICON_BOX_BOTTOM = 85, + ICON_BOX_BOTTOM_LEFT = 86, + ICON_BOX_LEFT = 87, + ICON_BOX_TOP_LEFT = 88, + ICON_BOX_CENTER = 89, + ICON_BOX_CIRCLE_MASK = 90, + ICON_POT = 91, + ICON_ALPHA_MULTIPLY = 92, + ICON_ALPHA_CLEAR = 93, + ICON_DITHERING = 94, + ICON_MIPMAPS = 95, + ICON_BOX_GRID = 96, + ICON_GRID = 97, + ICON_BOX_CORNERS_SMALL = 98, + ICON_BOX_CORNERS_BIG = 99, + ICON_FOUR_BOXES = 100, + ICON_GRID_FILL = 101, + ICON_BOX_MULTISIZE = 102, + ICON_ZOOM_SMALL = 103, + ICON_ZOOM_MEDIUM = 104, + ICON_ZOOM_BIG = 105, + ICON_ZOOM_ALL = 106, + ICON_ZOOM_CENTER = 107, + ICON_BOX_DOTS_SMALL = 108, + ICON_BOX_DOTS_BIG = 109, + ICON_BOX_CONCENTRIC = 110, + ICON_BOX_GRID_BIG = 111, + ICON_OK_TICK = 112, + ICON_CROSS = 113, + ICON_ARROW_LEFT = 114, + ICON_ARROW_RIGHT = 115, + ICON_ARROW_DOWN = 116, + ICON_ARROW_UP = 117, + ICON_ARROW_LEFT_FILL = 118, + ICON_ARROW_RIGHT_FILL = 119, + ICON_ARROW_DOWN_FILL = 120, + ICON_ARROW_UP_FILL = 121, + ICON_AUDIO = 122, + ICON_FX = 123, + ICON_WAVE = 124, + ICON_WAVE_SINUS = 125, + ICON_WAVE_SQUARE = 126, + ICON_WAVE_TRIANGULAR = 127, + ICON_CROSS_SMALL = 128, + ICON_PLAYER_PREVIOUS = 129, + ICON_PLAYER_PLAY_BACK = 130, + ICON_PLAYER_PLAY = 131, + ICON_PLAYER_PAUSE = 132, + ICON_PLAYER_STOP = 133, + ICON_PLAYER_NEXT = 134, + ICON_PLAYER_RECORD = 135, + ICON_MAGNET = 136, + ICON_LOCK_CLOSE = 137, + ICON_LOCK_OPEN = 138, + ICON_CLOCK = 139, + ICON_TOOLS = 140, + ICON_GEAR = 141, + ICON_GEAR_BIG = 142, + ICON_BIN = 143, + ICON_HAND_POINTER = 144, + ICON_LASER = 145, + ICON_COIN = 146, + ICON_EXPLOSION = 147, + ICON_1UP = 148, + ICON_PLAYER = 149, + ICON_PLAYER_JUMP = 150, + ICON_KEY = 151, + ICON_DEMON = 152, + ICON_TEXT_POPUP = 153, + ICON_GEAR_EX = 154, + ICON_CRACK = 155, + ICON_CRACK_POINTS = 156, + ICON_STAR = 157, + ICON_DOOR = 158, + ICON_EXIT = 159, + ICON_MODE_2D = 160, + ICON_MODE_3D = 161, + ICON_CUBE = 162, + ICON_CUBE_FACE_TOP = 163, + ICON_CUBE_FACE_LEFT = 164, + ICON_CUBE_FACE_FRONT = 165, + ICON_CUBE_FACE_BOTTOM = 166, + ICON_CUBE_FACE_RIGHT = 167, + ICON_CUBE_FACE_BACK = 168, + ICON_CAMERA = 169, + ICON_SPECIAL = 170, + ICON_LINK_NET = 171, + ICON_LINK_BOXES = 172, + ICON_LINK_MULTI = 173, + ICON_LINK = 174, + ICON_LINK_BROKE = 175, + ICON_TEXT_NOTES = 176, + ICON_NOTEBOOK = 177, + ICON_SUITCASE = 178, + ICON_SUITCASE_ZIP = 179, + ICON_MAILBOX = 180, + ICON_MONITOR = 181, + ICON_PRINTER = 182, + ICON_PHOTO_CAMERA = 183, + ICON_PHOTO_CAMERA_FLASH = 184, + ICON_HOUSE = 185, + ICON_HEART = 186, + ICON_CORNER = 187, + ICON_VERTICAL_BARS = 188, + ICON_VERTICAL_BARS_FILL = 189, + ICON_LIFE_BARS = 190, + ICON_INFO = 191, + ICON_CROSSLINE = 192, + ICON_HELP = 193, + ICON_FILETYPE_ALPHA = 194, + ICON_FILETYPE_HOME = 195, + ICON_LAYERS_VISIBLE = 196, + ICON_LAYERS = 197, + ICON_WINDOW = 198, + ICON_HIDPI = 199, + ICON_FILETYPE_BINARY = 200, + ICON_HEX = 201, + ICON_SHIELD = 202, + ICON_FILE_NEW = 203, + ICON_FOLDER_ADD = 204, + ICON_ALARM = 205, + ICON_206 = 206, + ICON_207 = 207, + ICON_208 = 208, + ICON_209 = 209, + ICON_210 = 210, + ICON_211 = 211, + ICON_212 = 212, + ICON_213 = 213, + ICON_214 = 214, + ICON_215 = 215, + ICON_216 = 216, + ICON_217 = 217, + ICON_218 = 218, + ICON_219 = 219, + ICON_220 = 220, + ICON_221 = 221, + ICON_222 = 222, + ICON_223 = 223, + ICON_224 = 224, + ICON_225 = 225, + ICON_226 = 226, + ICON_227 = 227, + ICON_228 = 228, + ICON_229 = 229, + ICON_230 = 230, + ICON_231 = 231, + ICON_232 = 232, + ICON_233 = 233, + ICON_234 = 234, + ICON_235 = 235, + ICON_236 = 236, + ICON_237 = 237, + ICON_238 = 238, + ICON_239 = 239, + ICON_240 = 240, + ICON_241 = 241, + ICON_242 = 242, + ICON_243 = 243, + ICON_244 = 244, + ICON_245 = 245, + ICON_246 = 246, + ICON_247 = 247, + ICON_248 = 248, + ICON_249 = 249, + ICON_250 = 250, + ICON_251 = 251, + ICON_252 = 252, + ICON_253 = 253, + ICON_254 = 254, + ICON_255 = 255, +} GuiIconName; +#endif + #endif #if defined(__cplusplus) @@ -574,286 +849,19 @@ RAYGUIAPI bool GuiCheckIconPixel(int iconId, int x, int y); // Check icon pi #define RAYGUI_CLITERAL(name) (name) #endif -#if !defined(RAYGUI_NO_RICONS) +#if !defined(RAYGUI_NO_ICONS) && !defined(RAYGUI_CUSTOM_ICONS) -#if defined(RAYGUI_CUSTOM_RICONS) - -#define RICONS_IMPLEMENTATION -#include "ricons.h" // External icons data provided, it can be generated with rGuiIcons tool - -#else // Embedded raygui icons, no external file provided - -#define RICON_SIZE 16 // Size of icons (squared) -#define RICON_MAX_ICONS 256 // Maximum number of icons -#define RICON_MAX_NAME_LENGTH 32 // Maximum length of icon name id +// Embedded icons, no external file provided +#define RAYGUI_ICON_SIZE 16 // Size of icons in pixels (squared) +#define RAYGUI_ICON_MAX_ICONS 256 // Maximum number of icons +#define RAYGUI_ICON_MAX_NAME_LENGTH 32 // Maximum length of icon name id // Icons data is defined by bit array (every bit represents one pixel) -// Those arrays are stored as unsigned int data arrays, so every array -// element defines 32 pixels (bits) of information -// Number of elemens depend on RICON_SIZE (by default 16x16 pixels) -#define RICON_DATA_ELEMENTS (RICON_SIZE*RICON_SIZE/32) - -//---------------------------------------------------------------------------------- -// Icons enumeration -//---------------------------------------------------------------------------------- -typedef enum { - RICON_NONE = 0, - RICON_FOLDER_FILE_OPEN = 1, - RICON_FILE_SAVE_CLASSIC = 2, - RICON_FOLDER_OPEN = 3, - RICON_FOLDER_SAVE = 4, - RICON_FILE_OPEN = 5, - RICON_FILE_SAVE = 6, - RICON_FILE_EXPORT = 7, - RICON_FILE_NEW = 8, - RICON_FILE_DELETE = 9, - RICON_FILETYPE_TEXT = 10, - RICON_FILETYPE_AUDIO = 11, - RICON_FILETYPE_IMAGE = 12, - RICON_FILETYPE_PLAY = 13, - RICON_FILETYPE_VIDEO = 14, - RICON_FILETYPE_INFO = 15, - RICON_FILE_COPY = 16, - RICON_FILE_CUT = 17, - RICON_FILE_PASTE = 18, - RICON_CURSOR_HAND = 19, - RICON_CURSOR_POINTER = 20, - RICON_CURSOR_CLASSIC = 21, - RICON_PENCIL = 22, - RICON_PENCIL_BIG = 23, - RICON_BRUSH_CLASSIC = 24, - RICON_BRUSH_PAINTER = 25, - RICON_WATER_DROP = 26, - RICON_COLOR_PICKER = 27, - RICON_RUBBER = 28, - RICON_COLOR_BUCKET = 29, - RICON_TEXT_T = 30, - RICON_TEXT_A = 31, - RICON_SCALE = 32, - RICON_RESIZE = 33, - RICON_FILTER_POINT = 34, - RICON_FILTER_BILINEAR = 35, - RICON_CROP = 36, - RICON_CROP_ALPHA = 37, - RICON_SQUARE_TOGGLE = 38, - RICON_SYMMETRY = 39, - RICON_SYMMETRY_HORIZONTAL = 40, - RICON_SYMMETRY_VERTICAL = 41, - RICON_LENS = 42, - RICON_LENS_BIG = 43, - RICON_EYE_ON = 44, - RICON_EYE_OFF = 45, - RICON_FILTER_TOP = 46, - RICON_FILTER = 47, - RICON_TARGET_POINT = 48, - RICON_TARGET_SMALL = 49, - RICON_TARGET_BIG = 50, - RICON_TARGET_MOVE = 51, - RICON_CURSOR_MOVE = 52, - RICON_CURSOR_SCALE = 53, - RICON_CURSOR_SCALE_RIGHT = 54, - RICON_CURSOR_SCALE_LEFT = 55, - RICON_UNDO = 56, - RICON_REDO = 57, - RICON_REREDO = 58, - RICON_MUTATE = 59, - RICON_ROTATE = 60, - RICON_REPEAT = 61, - RICON_SHUFFLE = 62, - RICON_EMPTYBOX = 63, - RICON_TARGET = 64, - RICON_TARGET_SMALL_FILL = 65, - RICON_TARGET_BIG_FILL = 66, - RICON_TARGET_MOVE_FILL = 67, - RICON_CURSOR_MOVE_FILL = 68, - RICON_CURSOR_SCALE_FILL = 69, - RICON_CURSOR_SCALE_RIGHT_FILL = 70, - RICON_CURSOR_SCALE_LEFT_FILL = 71, - RICON_UNDO_FILL = 72, - RICON_REDO_FILL = 73, - RICON_REREDO_FILL = 74, - RICON_MUTATE_FILL = 75, - RICON_ROTATE_FILL = 76, - RICON_REPEAT_FILL = 77, - RICON_SHUFFLE_FILL = 78, - RICON_EMPTYBOX_SMALL = 79, - RICON_BOX = 80, - RICON_BOX_TOP = 81, - RICON_BOX_TOP_RIGHT = 82, - RICON_BOX_RIGHT = 83, - RICON_BOX_BOTTOM_RIGHT = 84, - RICON_BOX_BOTTOM = 85, - RICON_BOX_BOTTOM_LEFT = 86, - RICON_BOX_LEFT = 87, - RICON_BOX_TOP_LEFT = 88, - RICON_BOX_CENTER = 89, - RICON_BOX_CIRCLE_MASK = 90, - RICON_POT = 91, - RICON_ALPHA_MULTIPLY = 92, - RICON_ALPHA_CLEAR = 93, - RICON_DITHERING = 94, - RICON_MIPMAPS = 95, - RICON_BOX_GRID = 96, - RICON_GRID = 97, - RICON_BOX_CORNERS_SMALL = 98, - RICON_BOX_CORNERS_BIG = 99, - RICON_FOUR_BOXES = 100, - RICON_GRID_FILL = 101, - RICON_BOX_MULTISIZE = 102, - RICON_ZOOM_SMALL = 103, - RICON_ZOOM_MEDIUM = 104, - RICON_ZOOM_BIG = 105, - RICON_ZOOM_ALL = 106, - RICON_ZOOM_CENTER = 107, - RICON_BOX_DOTS_SMALL = 108, - RICON_BOX_DOTS_BIG = 109, - RICON_BOX_CONCENTRIC = 110, - RICON_BOX_GRID_BIG = 111, - RICON_OK_TICK = 112, - RICON_CROSS = 113, - RICON_ARROW_LEFT = 114, - RICON_ARROW_RIGHT = 115, - RICON_ARROW_DOWN = 116, - RICON_ARROW_UP = 117, - RICON_ARROW_LEFT_FILL = 118, - RICON_ARROW_RIGHT_FILL = 119, - RICON_ARROW_DOWN_FILL = 120, - RICON_ARROW_UP_FILL = 121, - RICON_AUDIO = 122, - RICON_FX = 123, - RICON_WAVE = 124, - RICON_WAVE_SINUS = 125, - RICON_WAVE_SQUARE = 126, - RICON_WAVE_TRIANGULAR = 127, - RICON_CROSS_SMALL = 128, - RICON_PLAYER_PREVIOUS = 129, - RICON_PLAYER_PLAY_BACK = 130, - RICON_PLAYER_PLAY = 131, - RICON_PLAYER_PAUSE = 132, - RICON_PLAYER_STOP = 133, - RICON_PLAYER_NEXT = 134, - RICON_PLAYER_RECORD = 135, - RICON_MAGNET = 136, - RICON_LOCK_CLOSE = 137, - RICON_LOCK_OPEN = 138, - RICON_CLOCK = 139, - RICON_TOOLS = 140, - RICON_GEAR = 141, - RICON_GEAR_BIG = 142, - RICON_BIN = 143, - RICON_HAND_POINTER = 144, - RICON_LASER = 145, - RICON_COIN = 146, - RICON_EXPLOSION = 147, - RICON_1UP = 148, - RICON_PLAYER = 149, - RICON_PLAYER_JUMP = 150, - RICON_KEY = 151, - RICON_DEMON = 152, - RICON_TEXT_POPUP = 153, - RICON_GEAR_EX = 154, - RICON_CRACK = 155, - RICON_CRACK_POINTS = 156, - RICON_STAR = 157, - RICON_DOOR = 158, - RICON_EXIT = 159, - RICON_MODE_2D = 160, - RICON_MODE_3D = 161, - RICON_CUBE = 162, - RICON_CUBE_FACE_TOP = 163, - RICON_CUBE_FACE_LEFT = 164, - RICON_CUBE_FACE_FRONT = 165, - RICON_CUBE_FACE_BOTTOM = 166, - RICON_CUBE_FACE_RIGHT = 167, - RICON_CUBE_FACE_BACK = 168, - RICON_CAMERA = 169, - RICON_SPECIAL = 170, - RICON_LINK_NET = 171, - RICON_LINK_BOXES = 172, - RICON_LINK_MULTI = 173, - RICON_LINK = 174, - RICON_LINK_BROKE = 175, - RICON_TEXT_NOTES = 176, - RICON_NOTEBOOK = 177, - RICON_SUITCASE = 178, - RICON_SUITCASE_ZIP = 179, - RICON_MAILBOX = 180, - RICON_MONITOR = 181, - RICON_PRINTER = 182, - RICON_PHOTO_CAMERA = 183, - RICON_PHOTO_CAMERA_FLASH = 184, - RICON_HOUSE = 185, - RICON_HEART = 186, - RICON_CORNER = 187, - RICON_VERTICAL_BARS = 188, - RICON_VERTICAL_BARS_FILL = 189, - RICON_LIFE_BARS = 190, - RICON_INFO = 191, - RICON_CROSSLINE = 192, - RICON_HELP = 193, - RICON_FILETYPE_ALPHA = 194, - RICON_FILETYPE_HOME = 195, - RICON_LAYERS_VISIBLE = 196, - RICON_LAYERS = 197, - RICON_WINDOW = 198, - RICON_HIDPI = 199, - RICON_200 = 200, - RICON_201 = 201, - RICON_202 = 202, - RICON_203 = 203, - RICON_204 = 204, - RICON_205 = 205, - RICON_206 = 206, - RICON_207 = 207, - RICON_208 = 208, - RICON_209 = 209, - RICON_210 = 210, - RICON_211 = 211, - RICON_212 = 212, - RICON_213 = 213, - RICON_214 = 214, - RICON_215 = 215, - RICON_216 = 216, - RICON_217 = 217, - RICON_218 = 218, - RICON_219 = 219, - RICON_220 = 220, - RICON_221 = 221, - RICON_222 = 222, - RICON_223 = 223, - RICON_224 = 224, - RICON_225 = 225, - RICON_226 = 226, - RICON_227 = 227, - RICON_228 = 228, - RICON_229 = 229, - RICON_230 = 230, - RICON_231 = 231, - RICON_232 = 232, - RICON_233 = 233, - RICON_234 = 234, - RICON_235 = 235, - RICON_236 = 236, - RICON_237 = 237, - RICON_238 = 238, - RICON_239 = 239, - RICON_240 = 240, - RICON_241 = 241, - RICON_242 = 242, - RICON_243 = 243, - RICON_244 = 244, - RICON_245 = 245, - RICON_246 = 246, - RICON_247 = 247, - RICON_248 = 248, - RICON_249 = 249, - RICON_250 = 250, - RICON_251 = 251, - RICON_252 = 252, - RICON_253 = 253, - RICON_254 = 254, - RICON_255 = 255, -} guiIconName; +// Those arrays are stored as unsigned int data arrays, so, +// every array element defines 32 pixels (bits) of information +// One icon is defined by 8 int, (8 int * 32 bit = 256 bit = 16*16 pixels) +// NOTE: Number of elemens depend on RAYGUI_ICON_SIZE (by default 16x16 pixels) +#define RAYGUI_ICON_DATA_ELEMENTS (RAYGUI_ICON_SIZE*RAYGUI_ICON_SIZE/32) //---------------------------------------------------------------------------------- // Icons data for all gui possible icons (allocated on data segment by default) @@ -861,276 +869,274 @@ typedef enum { // NOTE 1: Every icon is codified in binary form, using 1 bit per pixel, so, // every 16x16 icon requires 8 integers (16*16/32) to be stored // -// NOTE 2: A new icon set could be loaded over this array using GuiLoadIcons(), -// but loaded icons set must be same RICON_SIZE and no more than RICON_MAX_ICONS +// NOTE 2: A different icon set could be loaded over this array using GuiLoadIcons(), +// but loaded icons set must be same RAYGUI_ICON_SIZE and no more than RAYGUI_ICON_MAX_ICONS // // guiIcons size is by default: 256*(16*16/32) = 2048*4 = 8192 bytes = 8 KB //---------------------------------------------------------------------------------- -static unsigned int guiIcons[RICON_MAX_ICONS*RICON_DATA_ELEMENTS] = { - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_NONE - 0x3ff80000, 0x2f082008, 0x2042207e, 0x40027fc2, 0x40024002, 0x40024002, 0x40024002, 0x00007ffe, // RICON_FOLDER_FILE_OPEN - 0x3ffe0000, 0x44226422, 0x400247e2, 0x5ffa4002, 0x57ea500a, 0x500a500a, 0x40025ffa, 0x00007ffe, // RICON_FILE_SAVE_CLASSIC - 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024002, 0x44424282, 0x793e4102, 0x00000100, // RICON_FOLDER_OPEN - 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024102, 0x44424102, 0x793e4282, 0x00000000, // RICON_FOLDER_SAVE - 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x24442284, 0x21042104, 0x20042104, 0x00003ffc, // RICON_FILE_OPEN - 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x21042104, 0x22842444, 0x20042104, 0x00003ffc, // RICON_FILE_SAVE - 0x3ff00000, 0x201c2010, 0x00042004, 0x20041004, 0x20844784, 0x00841384, 0x20042784, 0x00003ffc, // RICON_FILE_EXPORT - 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x22042204, 0x22042f84, 0x20042204, 0x00003ffc, // RICON_FILE_NEW - 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x25042884, 0x25042204, 0x20042884, 0x00003ffc, // RICON_FILE_DELETE - 0x3ff00000, 0x201c2010, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // RICON_FILETYPE_TEXT - 0x3ff00000, 0x201c2010, 0x27042004, 0x244424c4, 0x26442444, 0x20642664, 0x20042004, 0x00003ffc, // RICON_FILETYPE_AUDIO - 0x3ff00000, 0x201c2010, 0x26042604, 0x20042004, 0x35442884, 0x2414222c, 0x20042004, 0x00003ffc, // RICON_FILETYPE_IMAGE - 0x3ff00000, 0x201c2010, 0x20c42004, 0x22442144, 0x22442444, 0x20c42144, 0x20042004, 0x00003ffc, // RICON_FILETYPE_PLAY - 0x3ff00000, 0x3ffc2ff0, 0x3f3c2ff4, 0x3dbc2eb4, 0x3dbc2bb4, 0x3f3c2eb4, 0x3ffc2ff4, 0x00002ff4, // RICON_FILETYPE_VIDEO - 0x3ff00000, 0x201c2010, 0x21842184, 0x21842004, 0x21842184, 0x21842184, 0x20042184, 0x00003ffc, // RICON_FILETYPE_INFO - 0x0ff00000, 0x381c0810, 0x28042804, 0x28042804, 0x28042804, 0x28042804, 0x20102ffc, 0x00003ff0, // RICON_FILE_COPY - 0x00000000, 0x701c0000, 0x079c1e14, 0x55a000f0, 0x079c00f0, 0x701c1e14, 0x00000000, 0x00000000, // RICON_FILE_CUT - 0x01c00000, 0x13e41bec, 0x3f841004, 0x204420c4, 0x20442044, 0x20442044, 0x207c2044, 0x00003fc0, // RICON_FILE_PASTE - 0x00000000, 0x3aa00fe0, 0x2abc2aa0, 0x2aa42aa4, 0x20042aa4, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_CURSOR_HAND - 0x00000000, 0x003c000c, 0x030800c8, 0x30100c10, 0x10202020, 0x04400840, 0x01800280, 0x00000000, // RICON_CURSOR_POINTER - 0x00000000, 0x00180000, 0x01f00078, 0x03e007f0, 0x07c003e0, 0x04000e40, 0x00000000, 0x00000000, // RICON_CURSOR_CLASSIC - 0x00000000, 0x04000000, 0x11000a00, 0x04400a80, 0x01100220, 0x00580088, 0x00000038, 0x00000000, // RICON_PENCIL - 0x04000000, 0x15000a00, 0x50402880, 0x14102820, 0x05040a08, 0x015c028c, 0x007c00bc, 0x00000000, // RICON_PENCIL_BIG - 0x01c00000, 0x01400140, 0x01400140, 0x0ff80140, 0x0ff80808, 0x0aa80808, 0x0aa80aa8, 0x00000ff8, // RICON_BRUSH_CLASSIC - 0x1ffc0000, 0x5ffc7ffe, 0x40004000, 0x00807f80, 0x01c001c0, 0x01c001c0, 0x01c001c0, 0x00000080, // RICON_BRUSH_PAINTER - 0x00000000, 0x00800000, 0x01c00080, 0x03e001c0, 0x07f003e0, 0x036006f0, 0x000001c0, 0x00000000, // RICON_WATER_DROP - 0x00000000, 0x3e003800, 0x1f803f80, 0x0c201e40, 0x02080c10, 0x00840104, 0x00380044, 0x00000000, // RICON_COLOR_PICKER - 0x00000000, 0x07800300, 0x1fe00fc0, 0x3f883fd0, 0x0e021f04, 0x02040402, 0x00f00108, 0x00000000, // RICON_RUBBER - 0x00c00000, 0x02800140, 0x08200440, 0x20081010, 0x2ffe3004, 0x03f807fc, 0x00e001f0, 0x00000040, // RICON_COLOR_BUCKET - 0x00000000, 0x21843ffc, 0x01800180, 0x01800180, 0x01800180, 0x01800180, 0x03c00180, 0x00000000, // RICON_TEXT_T - 0x00800000, 0x01400180, 0x06200340, 0x0c100620, 0x1ff80c10, 0x380c1808, 0x70067004, 0x0000f80f, // RICON_TEXT_A - 0x78000000, 0x50004000, 0x00004800, 0x03c003c0, 0x03c003c0, 0x00100000, 0x0002000a, 0x0000000e, // RICON_SCALE - 0x75560000, 0x5e004002, 0x54001002, 0x41001202, 0x408200fe, 0x40820082, 0x40820082, 0x00006afe, // RICON_RESIZE - 0x00000000, 0x3f003f00, 0x3f003f00, 0x3f003f00, 0x00400080, 0x001c0020, 0x001c001c, 0x00000000, // RICON_FILTER_POINT - 0x6d800000, 0x00004080, 0x40804080, 0x40800000, 0x00406d80, 0x001c0020, 0x001c001c, 0x00000000, // RICON_FILTER_BILINEAR - 0x40080000, 0x1ffe2008, 0x14081008, 0x11081208, 0x10481088, 0x10081028, 0x10047ff8, 0x00001002, // RICON_CROP - 0x00100000, 0x3ffc0010, 0x2ab03550, 0x22b02550, 0x20b02150, 0x20302050, 0x2000fff0, 0x00002000, // RICON_CROP_ALPHA - 0x40000000, 0x1ff82000, 0x04082808, 0x01082208, 0x00482088, 0x00182028, 0x35542008, 0x00000002, // RICON_SQUARE_TOGGLE - 0x00000000, 0x02800280, 0x06c006c0, 0x0ea00ee0, 0x1e901eb0, 0x3e883e98, 0x7efc7e8c, 0x00000000, // RICON_SIMMETRY - 0x01000000, 0x05600100, 0x1d480d50, 0x7d423d44, 0x3d447d42, 0x0d501d48, 0x01000560, 0x00000100, // RICON_SIMMETRY_HORIZONTAL - 0x01800000, 0x04200240, 0x10080810, 0x00001ff8, 0x00007ffe, 0x0ff01ff8, 0x03c007e0, 0x00000180, // RICON_SIMMETRY_VERTICAL - 0x00000000, 0x010800f0, 0x02040204, 0x02040204, 0x07f00308, 0x1c000e00, 0x30003800, 0x00000000, // RICON_LENS - 0x00000000, 0x061803f0, 0x08240c0c, 0x08040814, 0x0c0c0804, 0x23f01618, 0x18002400, 0x00000000, // RICON_LENS_BIG - 0x00000000, 0x00000000, 0x1c7007c0, 0x638e3398, 0x1c703398, 0x000007c0, 0x00000000, 0x00000000, // RICON_EYE_ON - 0x00000000, 0x10002000, 0x04700fc0, 0x610e3218, 0x1c703098, 0x001007a0, 0x00000008, 0x00000000, // RICON_EYE_OFF - 0x00000000, 0x00007ffc, 0x40047ffc, 0x10102008, 0x04400820, 0x02800280, 0x02800280, 0x00000100, // RICON_FILTER_TOP - 0x00000000, 0x40027ffe, 0x10082004, 0x04200810, 0x02400240, 0x02400240, 0x01400240, 0x000000c0, // RICON_FILTER - 0x00800000, 0x00800080, 0x00000080, 0x3c9e0000, 0x00000000, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_POINT - 0x00800000, 0x00800080, 0x00800080, 0x3f7e01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_SMALL - 0x00800000, 0x00800080, 0x03e00080, 0x3e3e0220, 0x03e00220, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_BIG - 0x01000000, 0x04400280, 0x01000100, 0x43842008, 0x43849ab2, 0x01002008, 0x04400100, 0x01000280, // RICON_TARGET_MOVE - 0x01000000, 0x04400280, 0x01000100, 0x41042108, 0x41049ff2, 0x01002108, 0x04400100, 0x01000280, // RICON_CURSOR_MOVE - 0x781e0000, 0x500a4002, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x4002500a, 0x0000781e, // RICON_CURSOR_SCALE - 0x00000000, 0x20003c00, 0x24002800, 0x01000200, 0x00400080, 0x00140024, 0x003c0004, 0x00000000, // RICON_CURSOR_SCALE_RIGHT - 0x00000000, 0x0004003c, 0x00240014, 0x00800040, 0x02000100, 0x28002400, 0x3c002000, 0x00000000, // RICON_CURSOR_SCALE_LEFT - 0x00000000, 0x00100020, 0x10101fc8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // RICON_UNDO - 0x00000000, 0x08000400, 0x080813f8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // RICON_REDO - 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3f902020, 0x00400020, 0x00000000, // RICON_REREDO - 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3fc82010, 0x00200010, 0x00000000, // RICON_MUTATE - 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18101020, 0x00100fc8, 0x00000020, // RICON_ROTATE - 0x00000000, 0x04000200, 0x240429fc, 0x20042204, 0x20442004, 0x3f942024, 0x00400020, 0x00000000, // RICON_REPEAT - 0x00000000, 0x20001000, 0x22104c0e, 0x00801120, 0x11200040, 0x4c0e2210, 0x10002000, 0x00000000, // RICON_SHUFFLE - 0x7ffe0000, 0x50024002, 0x44024802, 0x41024202, 0x40424082, 0x40124022, 0x4002400a, 0x00007ffe, // RICON_EMPTYBOX - 0x00800000, 0x03e00080, 0x08080490, 0x3c9e0808, 0x08080808, 0x03e00490, 0x00800080, 0x00000000, // RICON_TARGET - 0x00800000, 0x00800080, 0x00800080, 0x3ffe01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_SMALL_FILL - 0x00800000, 0x00800080, 0x03e00080, 0x3ffe03e0, 0x03e003e0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_BIG_FILL - 0x01000000, 0x07c00380, 0x01000100, 0x638c2008, 0x638cfbbe, 0x01002008, 0x07c00100, 0x01000380, // RICON_TARGET_MOVE_FILL - 0x01000000, 0x07c00380, 0x01000100, 0x610c2108, 0x610cfffe, 0x01002108, 0x07c00100, 0x01000380, // RICON_CURSOR_MOVE_FILL - 0x781e0000, 0x6006700e, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x700e6006, 0x0000781e, // RICON_CURSOR_SCALE_FILL - 0x00000000, 0x38003c00, 0x24003000, 0x01000200, 0x00400080, 0x000c0024, 0x003c001c, 0x00000000, // RICON_CURSOR_SCALE_RIGHT - 0x00000000, 0x001c003c, 0x0024000c, 0x00800040, 0x02000100, 0x30002400, 0x3c003800, 0x00000000, // RICON_CURSOR_SCALE_LEFT - 0x00000000, 0x00300020, 0x10301ff8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // RICON_UNDO_FILL - 0x00000000, 0x0c000400, 0x0c081ff8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // RICON_REDO_FILL - 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3ff02060, 0x00400060, 0x00000000, // RICON_REREDO_FILL - 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3ff82030, 0x00200030, 0x00000000, // RICON_MUTATE_FILL - 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18301020, 0x00300ff8, 0x00000020, // RICON_ROTATE_FILL - 0x00000000, 0x06000200, 0x26042ffc, 0x20042204, 0x20442004, 0x3ff42064, 0x00400060, 0x00000000, // RICON_REPEAT_FILL - 0x00000000, 0x30001000, 0x32107c0e, 0x00801120, 0x11200040, 0x7c0e3210, 0x10003000, 0x00000000, // RICON_SHUFFLE_FILL - 0x00000000, 0x30043ffc, 0x24042804, 0x21042204, 0x20442084, 0x20142024, 0x3ffc200c, 0x00000000, // RICON_EMPTYBOX_SMALL - 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX - 0x00000000, 0x23c43ffc, 0x23c423c4, 0x200423c4, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP - 0x00000000, 0x3e043ffc, 0x3e043e04, 0x20043e04, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP_RIGHT - 0x00000000, 0x20043ffc, 0x20042004, 0x3e043e04, 0x3e043e04, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_RIGHT - 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x3e042004, 0x3e043e04, 0x3ffc3e04, 0x00000000, // RICON_BOX_BOTTOM_RIGHT - 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x23c42004, 0x23c423c4, 0x3ffc23c4, 0x00000000, // RICON_BOX_BOTTOM - 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x207c2004, 0x207c207c, 0x3ffc207c, 0x00000000, // RICON_BOX_BOTTOM_LEFT - 0x00000000, 0x20043ffc, 0x20042004, 0x207c207c, 0x207c207c, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_LEFT - 0x00000000, 0x207c3ffc, 0x207c207c, 0x2004207c, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP_LEFT - 0x00000000, 0x20043ffc, 0x20042004, 0x23c423c4, 0x23c423c4, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_CIRCLE_MASK - 0x7ffe0000, 0x40024002, 0x47e24182, 0x4ff247e2, 0x47e24ff2, 0x418247e2, 0x40024002, 0x00007ffe, // RICON_BOX_CENTER - 0x7fff0000, 0x40014001, 0x40014001, 0x49555ddd, 0x4945495d, 0x400149c5, 0x40014001, 0x00007fff, // RICON_POT - 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x404e40ce, 0x48125432, 0x4006540e, 0x00007ffe, // RICON_ALPHA_MULTIPLY - 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x5c4e40ce, 0x44124432, 0x40065c0e, 0x00007ffe, // RICON_ALPHA_CLEAR - 0x7ffe0000, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x00007ffe, // RICON_DITHERING - 0x07fe0000, 0x1ffa0002, 0x7fea000a, 0x402a402a, 0x5b2a512a, 0x5128552a, 0x40205128, 0x00007fe0, // RICON_MIPMAPS - 0x00000000, 0x1ff80000, 0x12481248, 0x12481ff8, 0x1ff81248, 0x12481248, 0x00001ff8, 0x00000000, // RICON_BOX_GRID - 0x12480000, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x00001248, // RICON_GRID - 0x00000000, 0x1c380000, 0x1c3817e8, 0x08100810, 0x08100810, 0x17e81c38, 0x00001c38, 0x00000000, // RICON_BOX_CORNERS_SMALL - 0x700e0000, 0x700e5ffa, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x5ffa700e, 0x0000700e, // RICON_BOX_CORNERS_BIG - 0x3f7e0000, 0x21422142, 0x21422142, 0x00003f7e, 0x21423f7e, 0x21422142, 0x3f7e2142, 0x00000000, // RICON_FOUR_BOXES - 0x00000000, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x00000000, // RICON_GRID_FILL - 0x7ffe0000, 0x7ffe7ffe, 0x77fe7000, 0x77fe77fe, 0x777e7700, 0x777e777e, 0x777e777e, 0x0000777e, // RICON_BOX_MULTISIZE - 0x781e0000, 0x40024002, 0x00004002, 0x01800000, 0x00000180, 0x40020000, 0x40024002, 0x0000781e, // RICON_ZOOM_SMALL - 0x781e0000, 0x40024002, 0x00004002, 0x03c003c0, 0x03c003c0, 0x40020000, 0x40024002, 0x0000781e, // RICON_ZOOM_MEDIUM - 0x781e0000, 0x40024002, 0x07e04002, 0x07e007e0, 0x07e007e0, 0x400207e0, 0x40024002, 0x0000781e, // RICON_ZOOM_BIG - 0x781e0000, 0x5ffa4002, 0x1ff85ffa, 0x1ff81ff8, 0x1ff81ff8, 0x5ffa1ff8, 0x40025ffa, 0x0000781e, // RICON_ZOOM_ALL - 0x00000000, 0x2004381c, 0x00002004, 0x00000000, 0x00000000, 0x20040000, 0x381c2004, 0x00000000, // RICON_ZOOM_CENTER - 0x00000000, 0x1db80000, 0x10081008, 0x10080000, 0x00001008, 0x10081008, 0x00001db8, 0x00000000, // RICON_BOX_DOTS_SMALL - 0x35560000, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x35562002, 0x00000000, // RICON_BOX_DOTS_BIG - 0x7ffe0000, 0x40024002, 0x48124ff2, 0x49924812, 0x48124992, 0x4ff24812, 0x40024002, 0x00007ffe, // RICON_BOX_CONCENTRIC - 0x00000000, 0x10841ffc, 0x10841084, 0x1ffc1084, 0x10841084, 0x10841084, 0x00001ffc, 0x00000000, // RICON_BOX_GRID_BIG - 0x00000000, 0x00000000, 0x10000000, 0x04000800, 0x01040200, 0x00500088, 0x00000020, 0x00000000, // RICON_OK_TICK - 0x00000000, 0x10080000, 0x04200810, 0x01800240, 0x02400180, 0x08100420, 0x00001008, 0x00000000, // RICON_CROSS - 0x00000000, 0x02000000, 0x00800100, 0x00200040, 0x00200010, 0x00800040, 0x02000100, 0x00000000, // RICON_ARROW_LEFT - 0x00000000, 0x00400000, 0x01000080, 0x04000200, 0x04000800, 0x01000200, 0x00400080, 0x00000000, // RICON_ARROW_RIGHT - 0x00000000, 0x00000000, 0x00000000, 0x08081004, 0x02200410, 0x00800140, 0x00000000, 0x00000000, // RICON_ARROW_DOWN - 0x00000000, 0x00000000, 0x01400080, 0x04100220, 0x10040808, 0x00000000, 0x00000000, 0x00000000, // RICON_ARROW_UP - 0x00000000, 0x02000000, 0x03800300, 0x03e003c0, 0x03e003f0, 0x038003c0, 0x02000300, 0x00000000, // RICON_ARROW_LEFT_FILL - 0x00000000, 0x00400000, 0x01c000c0, 0x07c003c0, 0x07c00fc0, 0x01c003c0, 0x004000c0, 0x00000000, // RICON_ARROW_RIGHT_FILL - 0x00000000, 0x00000000, 0x00000000, 0x0ff81ffc, 0x03e007f0, 0x008001c0, 0x00000000, 0x00000000, // RICON_ARROW_DOWN_FILL - 0x00000000, 0x00000000, 0x01c00080, 0x07f003e0, 0x1ffc0ff8, 0x00000000, 0x00000000, 0x00000000, // RICON_ARROW_UP_FILL - 0x00000000, 0x18a008c0, 0x32881290, 0x24822686, 0x26862482, 0x12903288, 0x08c018a0, 0x00000000, // RICON_AUDIO - 0x00000000, 0x04800780, 0x004000c0, 0x662000f0, 0x08103c30, 0x130a0e18, 0x0000318e, 0x00000000, // RICON_FX - 0x00000000, 0x00800000, 0x08880888, 0x2aaa0a8a, 0x0a8a2aaa, 0x08880888, 0x00000080, 0x00000000, // RICON_WAVE - 0x00000000, 0x00600000, 0x01080090, 0x02040108, 0x42044204, 0x24022402, 0x00001800, 0x00000000, // RICON_WAVE_SINUS - 0x00000000, 0x07f80000, 0x04080408, 0x04080408, 0x04080408, 0x7c0e0408, 0x00000000, 0x00000000, // RICON_WAVE_SQUARE - 0x00000000, 0x00000000, 0x00a00040, 0x22084110, 0x08021404, 0x00000000, 0x00000000, 0x00000000, // RICON_WAVE_TRIANGULAR - 0x00000000, 0x00000000, 0x04200000, 0x01800240, 0x02400180, 0x00000420, 0x00000000, 0x00000000, // RICON_CROSS_SMALL - 0x00000000, 0x18380000, 0x12281428, 0x10a81128, 0x112810a8, 0x14281228, 0x00001838, 0x00000000, // RICON_PLAYER_PREVIOUS - 0x00000000, 0x18000000, 0x11801600, 0x10181060, 0x10601018, 0x16001180, 0x00001800, 0x00000000, // RICON_PLAYER_PLAY_BACK - 0x00000000, 0x00180000, 0x01880068, 0x18080608, 0x06081808, 0x00680188, 0x00000018, 0x00000000, // RICON_PLAYER_PLAY - 0x00000000, 0x1e780000, 0x12481248, 0x12481248, 0x12481248, 0x12481248, 0x00001e78, 0x00000000, // RICON_PLAYER_PAUSE - 0x00000000, 0x1ff80000, 0x10081008, 0x10081008, 0x10081008, 0x10081008, 0x00001ff8, 0x00000000, // RICON_PLAYER_STOP - 0x00000000, 0x1c180000, 0x14481428, 0x15081488, 0x14881508, 0x14281448, 0x00001c18, 0x00000000, // RICON_PLAYER_NEXT - 0x00000000, 0x03c00000, 0x08100420, 0x10081008, 0x10081008, 0x04200810, 0x000003c0, 0x00000000, // RICON_PLAYER_RECORD - 0x00000000, 0x0c3007e0, 0x13c81818, 0x14281668, 0x14281428, 0x1c381c38, 0x08102244, 0x00000000, // RICON_MAGNET - 0x07c00000, 0x08200820, 0x3ff80820, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // RICON_LOCK_CLOSE - 0x07c00000, 0x08000800, 0x3ff80800, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // RICON_LOCK_OPEN - 0x01c00000, 0x0c180770, 0x3086188c, 0x60832082, 0x60034781, 0x30062002, 0x0c18180c, 0x01c00770, // RICON_CLOCK - 0x0a200000, 0x1b201b20, 0x04200e20, 0x04200420, 0x04700420, 0x0e700e70, 0x0e700e70, 0x04200e70, // RICON_TOOLS - 0x01800000, 0x3bdc318c, 0x0ff01ff8, 0x7c3e1e78, 0x1e787c3e, 0x1ff80ff0, 0x318c3bdc, 0x00000180, // RICON_GEAR - 0x01800000, 0x3ffc318c, 0x1c381ff8, 0x781e1818, 0x1818781e, 0x1ff81c38, 0x318c3ffc, 0x00000180, // RICON_GEAR_BIG - 0x00000000, 0x08080ff8, 0x08081ffc, 0x0aa80aa8, 0x0aa80aa8, 0x0aa80aa8, 0x08080aa8, 0x00000ff8, // RICON_BIN - 0x00000000, 0x00000000, 0x20043ffc, 0x08043f84, 0x04040f84, 0x04040784, 0x000007fc, 0x00000000, // RICON_HAND_POINTER - 0x00000000, 0x24400400, 0x00001480, 0x6efe0e00, 0x00000e00, 0x24401480, 0x00000400, 0x00000000, // RICON_LASER - 0x00000000, 0x03c00000, 0x08300460, 0x11181118, 0x11181118, 0x04600830, 0x000003c0, 0x00000000, // RICON_COIN - 0x00000000, 0x10880080, 0x06c00810, 0x366c07e0, 0x07e00240, 0x00001768, 0x04200240, 0x00000000, // RICON_EXPLOSION - 0x00000000, 0x3d280000, 0x2528252c, 0x3d282528, 0x05280528, 0x05e80528, 0x00000000, 0x00000000, // RICON_1UP - 0x01800000, 0x03c003c0, 0x018003c0, 0x0ff007e0, 0x0bd00bd0, 0x0a500bd0, 0x02400240, 0x02400240, // RICON_PLAYER - 0x01800000, 0x03c003c0, 0x118013c0, 0x03c81ff8, 0x07c003c8, 0x04400440, 0x0c080478, 0x00000000, // RICON_PLAYER_JUMP - 0x3ff80000, 0x30183ff8, 0x30183018, 0x3ff83ff8, 0x03000300, 0x03c003c0, 0x03e00300, 0x000003e0, // RICON_KEY - 0x3ff80000, 0x3ff83ff8, 0x33983ff8, 0x3ff83398, 0x3ff83ff8, 0x00000540, 0x0fe00aa0, 0x00000fe0, // RICON_DEMON - 0x00000000, 0x0ff00000, 0x20041008, 0x25442004, 0x10082004, 0x06000bf0, 0x00000300, 0x00000000, // RICON_TEXT_POPUP - 0x00000000, 0x11440000, 0x07f00be8, 0x1c1c0e38, 0x1c1c0c18, 0x07f00e38, 0x11440be8, 0x00000000, // RICON_GEAR_EX - 0x00000000, 0x20080000, 0x0c601010, 0x07c00fe0, 0x07c007c0, 0x0c600fe0, 0x20081010, 0x00000000, // RICON_CRACK - 0x00000000, 0x20080000, 0x0c601010, 0x04400fe0, 0x04405554, 0x0c600fe0, 0x20081010, 0x00000000, // RICON_CRACK_POINTS - 0x00000000, 0x00800080, 0x01c001c0, 0x1ffc3ffe, 0x03e007f0, 0x07f003e0, 0x0c180770, 0x00000808, // RICON_STAR - 0x0ff00000, 0x08180810, 0x08100818, 0x0a100810, 0x08180810, 0x08100818, 0x08100810, 0x00001ff8, // RICON_DOOR - 0x0ff00000, 0x08100810, 0x08100810, 0x10100010, 0x4f902010, 0x10102010, 0x08100010, 0x00000ff0, // RICON_EXIT - 0x00040000, 0x001f000e, 0x0ef40004, 0x12f41284, 0x0ef41214, 0x10040004, 0x7ffc3004, 0x10003000, // RICON_MODE_2D - 0x78040000, 0x501f600e, 0x0ef44004, 0x12f41284, 0x0ef41284, 0x10140004, 0x7ffc300c, 0x10003000, // RICON_MODE_3D - 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // RICON_CUBE - 0x7fe00000, 0x5ff87ff0, 0x47fe4ffc, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // RICON_CUBE_FACE_TOP - 0x7fe00000, 0x50386030, 0x47fe483c, 0x443e443e, 0x443e443e, 0x241e75fe, 0x0c06140e, 0x000007fe, // RICON_CUBE_FACE_LEFT - 0x7fe00000, 0x50286030, 0x47fe4804, 0x47fe47fe, 0x47fe47fe, 0x27fe77fe, 0x0ffe17fe, 0x000007fe, // RICON_CUBE_FACE_FRONT - 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x3ff27fe2, 0x0ffe1ffa, 0x000007fe, // RICON_CUBE_FACE_BOTTOM - 0x7fe00000, 0x70286030, 0x7ffe7804, 0x7c227c02, 0x7c227c22, 0x3c127de2, 0x0c061c0a, 0x000007fe, // RICON_CUBE_FACE_RIGHT - 0x7fe00000, 0x7fe87ff0, 0x7ffe7fe4, 0x7fe27fe2, 0x7fe27fe2, 0x24127fe2, 0x0c06140a, 0x000007fe, // RICON_CUBE_FACE_BACK - 0x00000000, 0x2a0233fe, 0x22022602, 0x22022202, 0x2a022602, 0x00a033fe, 0x02080110, 0x00000000, // RICON_CAMERA - 0x00000000, 0x200c3ffc, 0x000c000c, 0x3ffc000c, 0x30003000, 0x30003000, 0x3ffc3004, 0x00000000, // RICON_SPECIAL - 0x00000000, 0x0022003e, 0x012201e2, 0x0100013e, 0x01000100, 0x79000100, 0x4f004900, 0x00007800, // RICON_LINK_NET - 0x00000000, 0x44007c00, 0x45004600, 0x00627cbe, 0x00620022, 0x45007cbe, 0x44004600, 0x00007c00, // RICON_LINK_BOXES - 0x00000000, 0x0044007c, 0x0010007c, 0x3f100010, 0x3f1021f0, 0x3f100010, 0x3f0021f0, 0x00000000, // RICON_LINK_MULTI - 0x00000000, 0x0044007c, 0x00440044, 0x0010007c, 0x00100010, 0x44107c10, 0x440047f0, 0x00007c00, // RICON_LINK - 0x00000000, 0x0044007c, 0x00440044, 0x0000007c, 0x00000010, 0x44007c10, 0x44004550, 0x00007c00, // RICON_LINK_BROKE - 0x02a00000, 0x22a43ffc, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // RICON_TEXT_NOTES - 0x3ffc0000, 0x20042004, 0x245e27c4, 0x27c42444, 0x2004201e, 0x201e2004, 0x20042004, 0x00003ffc, // RICON_NOTEBOOK - 0x00000000, 0x07e00000, 0x04200420, 0x24243ffc, 0x24242424, 0x24242424, 0x3ffc2424, 0x00000000, // RICON_SUITCASE - 0x00000000, 0x0fe00000, 0x08200820, 0x40047ffc, 0x7ffc5554, 0x40045554, 0x7ffc4004, 0x00000000, // RICON_SUITCASE_ZIP - 0x00000000, 0x20043ffc, 0x3ffc2004, 0x13c81008, 0x100813c8, 0x10081008, 0x1ff81008, 0x00000000, // RICON_MAILBOX - 0x00000000, 0x40027ffe, 0x5ffa5ffa, 0x5ffa5ffa, 0x40025ffa, 0x03c07ffe, 0x1ff81ff8, 0x00000000, // RICON_MONITOR - 0x0ff00000, 0x6bfe7ffe, 0x7ffe7ffe, 0x68167ffe, 0x08106816, 0x08100810, 0x0ff00810, 0x00000000, // RICON_PRINTER - 0x3ff80000, 0xfffe2008, 0x870a8002, 0x904a888a, 0x904a904a, 0x870a888a, 0xfffe8002, 0x00000000, // RICON_PHOTO_CAMERA - 0x0fc00000, 0xfcfe0cd8, 0x8002fffe, 0x84428382, 0x84428442, 0x80028382, 0xfffe8002, 0x00000000, // RICON_PHOTO_CAMERA_FLASH - 0x00000000, 0x02400180, 0x08100420, 0x20041008, 0x23c42004, 0x22442244, 0x3ffc2244, 0x00000000, // RICON_HOUSE - 0x00000000, 0x1c700000, 0x3ff83ef8, 0x3ff83ff8, 0x0fe01ff0, 0x038007c0, 0x00000100, 0x00000000, // RICON_HEART - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x80000000, 0xe000c000, // RICON_CORNER - 0x00000000, 0x14001c00, 0x15c01400, 0x15401540, 0x155c1540, 0x15541554, 0x1ddc1554, 0x00000000, // RICON_VERTICAL_BARS - 0x00000000, 0x03000300, 0x1b001b00, 0x1b601b60, 0x1b6c1b60, 0x1b6c1b6c, 0x1b6c1b6c, 0x00000000, // RICON_VERTICAL_BARS_FILL - 0x00000000, 0x00000000, 0x403e7ffe, 0x7ffe403e, 0x7ffe0000, 0x43fe43fe, 0x00007ffe, 0x00000000, // RICON_LIFE_BARS - 0x7ffc0000, 0x43844004, 0x43844284, 0x43844004, 0x42844284, 0x42844284, 0x40044384, 0x00007ffc, // RICON_INFO - 0x40008000, 0x10002000, 0x04000800, 0x01000200, 0x00400080, 0x00100020, 0x00040008, 0x00010002, // RICON_CROSSLINE - 0x00000000, 0x1ff01ff0, 0x18301830, 0x1f001830, 0x03001f00, 0x00000300, 0x03000300, 0x00000000, // RICON_HELP - 0x3ff00000, 0x2abc3550, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x00003ffc, // RICON_FILETYPE_ALPHA - 0x3ff00000, 0x201c2010, 0x22442184, 0x28142424, 0x29942814, 0x2ff42994, 0x20042004, 0x00003ffc, // RICON_FILETYPE_HOME - 0x07fe0000, 0x04020402, 0x7fe20402, 0x44224422, 0x44224422, 0x402047fe, 0x40204020, 0x00007fe0, // RICON_LAYERS_VISIBLE - 0x07fe0000, 0x04020402, 0x7c020402, 0x44024402, 0x44024402, 0x402047fe, 0x40204020, 0x00007fe0, // RICON_LAYERS - 0x00000000, 0x40027ffe, 0x7ffe4002, 0x40024002, 0x40024002, 0x40024002, 0x7ffe4002, 0x00000000, // RICON_WINDOW - 0x09100000, 0x09f00910, 0x09100910, 0x00000910, 0x24a2779e, 0x27a224a2, 0x709e20a2, 0x00000000, // RICON_HIDPI - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_200 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_201 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_202 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_203 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_204 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_205 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_206 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_207 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_208 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_209 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_210 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_211 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_212 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_213 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_214 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_215 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_216 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_217 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_218 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_219 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_220 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_221 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_222 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_223 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_224 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_225 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_226 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_227 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_228 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_229 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_230 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_231 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_232 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_233 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_234 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_235 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_236 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_237 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_238 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_239 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_240 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_241 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_242 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_243 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_244 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_245 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_246 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_247 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_248 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_249 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_250 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_251 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_252 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_253 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_254 - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_255 +static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_NONE + 0x3ff80000, 0x2f082008, 0x2042207e, 0x40027fc2, 0x40024002, 0x40024002, 0x40024002, 0x00007ffe, // ICON_FOLDER_FILE_OPEN + 0x3ffe0000, 0x44226422, 0x400247e2, 0x5ffa4002, 0x57ea500a, 0x500a500a, 0x40025ffa, 0x00007ffe, // ICON_FILE_SAVE_CLASSIC + 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024002, 0x44424282, 0x793e4102, 0x00000100, // ICON_FOLDER_OPEN + 0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024102, 0x44424102, 0x793e4282, 0x00000000, // ICON_FOLDER_SAVE + 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x24442284, 0x21042104, 0x20042104, 0x00003ffc, // ICON_FILE_OPEN + 0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x21042104, 0x22842444, 0x20042104, 0x00003ffc, // ICON_FILE_SAVE + 0x3ff00000, 0x201c2010, 0x00042004, 0x20041004, 0x20844784, 0x00841384, 0x20042784, 0x00003ffc, // ICON_FILE_EXPORT + 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x22042204, 0x22042f84, 0x20042204, 0x00003ffc, // ICON_FILE_ADD + 0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x25042884, 0x25042204, 0x20042884, 0x00003ffc, // ICON_FILE_DELETE + 0x3ff00000, 0x201c2010, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // ICON_FILETYPE_TEXT + 0x3ff00000, 0x201c2010, 0x27042004, 0x244424c4, 0x26442444, 0x20642664, 0x20042004, 0x00003ffc, // ICON_FILETYPE_AUDIO + 0x3ff00000, 0x201c2010, 0x26042604, 0x20042004, 0x35442884, 0x2414222c, 0x20042004, 0x00003ffc, // ICON_FILETYPE_IMAGE + 0x3ff00000, 0x201c2010, 0x20c42004, 0x22442144, 0x22442444, 0x20c42144, 0x20042004, 0x00003ffc, // ICON_FILETYPE_PLAY + 0x3ff00000, 0x3ffc2ff0, 0x3f3c2ff4, 0x3dbc2eb4, 0x3dbc2bb4, 0x3f3c2eb4, 0x3ffc2ff4, 0x00002ff4, // ICON_FILETYPE_VIDEO + 0x3ff00000, 0x201c2010, 0x21842184, 0x21842004, 0x21842184, 0x21842184, 0x20042184, 0x00003ffc, // ICON_FILETYPE_INFO + 0x0ff00000, 0x381c0810, 0x28042804, 0x28042804, 0x28042804, 0x28042804, 0x20102ffc, 0x00003ff0, // ICON_FILE_COPY + 0x00000000, 0x701c0000, 0x079c1e14, 0x55a000f0, 0x079c00f0, 0x701c1e14, 0x00000000, 0x00000000, // ICON_FILE_CUT + 0x01c00000, 0x13e41bec, 0x3f841004, 0x204420c4, 0x20442044, 0x20442044, 0x207c2044, 0x00003fc0, // ICON_FILE_PASTE + 0x00000000, 0x3aa00fe0, 0x2abc2aa0, 0x2aa42aa4, 0x20042aa4, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_CURSOR_HAND + 0x00000000, 0x003c000c, 0x030800c8, 0x30100c10, 0x10202020, 0x04400840, 0x01800280, 0x00000000, // ICON_CURSOR_POINTER + 0x00000000, 0x00180000, 0x01f00078, 0x03e007f0, 0x07c003e0, 0x04000e40, 0x00000000, 0x00000000, // ICON_CURSOR_CLASSIC + 0x00000000, 0x04000000, 0x11000a00, 0x04400a80, 0x01100220, 0x00580088, 0x00000038, 0x00000000, // ICON_PENCIL + 0x04000000, 0x15000a00, 0x50402880, 0x14102820, 0x05040a08, 0x015c028c, 0x007c00bc, 0x00000000, // ICON_PENCIL_BIG + 0x01c00000, 0x01400140, 0x01400140, 0x0ff80140, 0x0ff80808, 0x0aa80808, 0x0aa80aa8, 0x00000ff8, // ICON_BRUSH_CLASSIC + 0x1ffc0000, 0x5ffc7ffe, 0x40004000, 0x00807f80, 0x01c001c0, 0x01c001c0, 0x01c001c0, 0x00000080, // ICON_BRUSH_PAINTER + 0x00000000, 0x00800000, 0x01c00080, 0x03e001c0, 0x07f003e0, 0x036006f0, 0x000001c0, 0x00000000, // ICON_WATER_DROP + 0x00000000, 0x3e003800, 0x1f803f80, 0x0c201e40, 0x02080c10, 0x00840104, 0x00380044, 0x00000000, // ICON_COLOR_PICKER + 0x00000000, 0x07800300, 0x1fe00fc0, 0x3f883fd0, 0x0e021f04, 0x02040402, 0x00f00108, 0x00000000, // ICON_RUBBER + 0x00c00000, 0x02800140, 0x08200440, 0x20081010, 0x2ffe3004, 0x03f807fc, 0x00e001f0, 0x00000040, // ICON_COLOR_BUCKET + 0x00000000, 0x21843ffc, 0x01800180, 0x01800180, 0x01800180, 0x01800180, 0x03c00180, 0x00000000, // ICON_TEXT_T + 0x00800000, 0x01400180, 0x06200340, 0x0c100620, 0x1ff80c10, 0x380c1808, 0x70067004, 0x0000f80f, // ICON_TEXT_A + 0x78000000, 0x50004000, 0x00004800, 0x03c003c0, 0x03c003c0, 0x00100000, 0x0002000a, 0x0000000e, // ICON_SCALE + 0x75560000, 0x5e004002, 0x54001002, 0x41001202, 0x408200fe, 0x40820082, 0x40820082, 0x00006afe, // ICON_RESIZE + 0x00000000, 0x3f003f00, 0x3f003f00, 0x3f003f00, 0x00400080, 0x001c0020, 0x001c001c, 0x00000000, // ICON_FILTER_POINT + 0x6d800000, 0x00004080, 0x40804080, 0x40800000, 0x00406d80, 0x001c0020, 0x001c001c, 0x00000000, // ICON_FILTER_BILINEAR + 0x40080000, 0x1ffe2008, 0x14081008, 0x11081208, 0x10481088, 0x10081028, 0x10047ff8, 0x00001002, // ICON_CROP + 0x00100000, 0x3ffc0010, 0x2ab03550, 0x22b02550, 0x20b02150, 0x20302050, 0x2000fff0, 0x00002000, // ICON_CROP_ALPHA + 0x40000000, 0x1ff82000, 0x04082808, 0x01082208, 0x00482088, 0x00182028, 0x35542008, 0x00000002, // ICON_SQUARE_TOGGLE + 0x00000000, 0x02800280, 0x06c006c0, 0x0ea00ee0, 0x1e901eb0, 0x3e883e98, 0x7efc7e8c, 0x00000000, // ICON_SYMMETRY + 0x01000000, 0x05600100, 0x1d480d50, 0x7d423d44, 0x3d447d42, 0x0d501d48, 0x01000560, 0x00000100, // ICON_SYMMETRY_HORIZONTAL + 0x01800000, 0x04200240, 0x10080810, 0x00001ff8, 0x00007ffe, 0x0ff01ff8, 0x03c007e0, 0x00000180, // ICON_SYMMETRY_VERTICAL + 0x00000000, 0x010800f0, 0x02040204, 0x02040204, 0x07f00308, 0x1c000e00, 0x30003800, 0x00000000, // ICON_LENS + 0x00000000, 0x061803f0, 0x08240c0c, 0x08040814, 0x0c0c0804, 0x23f01618, 0x18002400, 0x00000000, // ICON_LENS_BIG + 0x00000000, 0x00000000, 0x1c7007c0, 0x638e3398, 0x1c703398, 0x000007c0, 0x00000000, 0x00000000, // ICON_EYE_ON + 0x00000000, 0x10002000, 0x04700fc0, 0x610e3218, 0x1c703098, 0x001007a0, 0x00000008, 0x00000000, // ICON_EYE_OFF + 0x00000000, 0x00007ffc, 0x40047ffc, 0x10102008, 0x04400820, 0x02800280, 0x02800280, 0x00000100, // ICON_FILTER_TOP + 0x00000000, 0x40027ffe, 0x10082004, 0x04200810, 0x02400240, 0x02400240, 0x01400240, 0x000000c0, // ICON_FILTER + 0x00800000, 0x00800080, 0x00000080, 0x3c9e0000, 0x00000000, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_POINT + 0x00800000, 0x00800080, 0x00800080, 0x3f7e01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_SMALL + 0x00800000, 0x00800080, 0x03e00080, 0x3e3e0220, 0x03e00220, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_BIG + 0x01000000, 0x04400280, 0x01000100, 0x43842008, 0x43849ab2, 0x01002008, 0x04400100, 0x01000280, // ICON_TARGET_MOVE + 0x01000000, 0x04400280, 0x01000100, 0x41042108, 0x41049ff2, 0x01002108, 0x04400100, 0x01000280, // ICON_CURSOR_MOVE + 0x781e0000, 0x500a4002, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x4002500a, 0x0000781e, // ICON_CURSOR_SCALE + 0x00000000, 0x20003c00, 0x24002800, 0x01000200, 0x00400080, 0x00140024, 0x003c0004, 0x00000000, // ICON_CURSOR_SCALE_RIGHT + 0x00000000, 0x0004003c, 0x00240014, 0x00800040, 0x02000100, 0x28002400, 0x3c002000, 0x00000000, // ICON_CURSOR_SCALE_LEFT + 0x00000000, 0x00100020, 0x10101fc8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // ICON_UNDO + 0x00000000, 0x08000400, 0x080813f8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // ICON_REDO + 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3f902020, 0x00400020, 0x00000000, // ICON_REREDO + 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3fc82010, 0x00200010, 0x00000000, // ICON_MUTATE + 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18101020, 0x00100fc8, 0x00000020, // ICON_ROTATE + 0x00000000, 0x04000200, 0x240429fc, 0x20042204, 0x20442004, 0x3f942024, 0x00400020, 0x00000000, // ICON_REPEAT + 0x00000000, 0x20001000, 0x22104c0e, 0x00801120, 0x11200040, 0x4c0e2210, 0x10002000, 0x00000000, // ICON_SHUFFLE + 0x7ffe0000, 0x50024002, 0x44024802, 0x41024202, 0x40424082, 0x40124022, 0x4002400a, 0x00007ffe, // ICON_EMPTYBOX + 0x00800000, 0x03e00080, 0x08080490, 0x3c9e0808, 0x08080808, 0x03e00490, 0x00800080, 0x00000000, // ICON_TARGET + 0x00800000, 0x00800080, 0x00800080, 0x3ffe01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_SMALL_FILL + 0x00800000, 0x00800080, 0x03e00080, 0x3ffe03e0, 0x03e003e0, 0x00800080, 0x00800080, 0x00000000, // ICON_TARGET_BIG_FILL + 0x01000000, 0x07c00380, 0x01000100, 0x638c2008, 0x638cfbbe, 0x01002008, 0x07c00100, 0x01000380, // ICON_TARGET_MOVE_FILL + 0x01000000, 0x07c00380, 0x01000100, 0x610c2108, 0x610cfffe, 0x01002108, 0x07c00100, 0x01000380, // ICON_CURSOR_MOVE_FILL + 0x781e0000, 0x6006700e, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x700e6006, 0x0000781e, // ICON_CURSOR_SCALE_FILL + 0x00000000, 0x38003c00, 0x24003000, 0x01000200, 0x00400080, 0x000c0024, 0x003c001c, 0x00000000, // ICON_CURSOR_SCALE_RIGHT_FILL + 0x00000000, 0x001c003c, 0x0024000c, 0x00800040, 0x02000100, 0x30002400, 0x3c003800, 0x00000000, // ICON_CURSOR_SCALE_LEFT_FILL + 0x00000000, 0x00300020, 0x10301ff8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // ICON_UNDO_FILL + 0x00000000, 0x0c000400, 0x0c081ff8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // ICON_REDO_FILL + 0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3ff02060, 0x00400060, 0x00000000, // ICON_REREDO_FILL + 0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3ff82030, 0x00200030, 0x00000000, // ICON_MUTATE_FILL + 0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18301020, 0x00300ff8, 0x00000020, // ICON_ROTATE_FILL + 0x00000000, 0x06000200, 0x26042ffc, 0x20042204, 0x20442004, 0x3ff42064, 0x00400060, 0x00000000, // ICON_REPEAT_FILL + 0x00000000, 0x30001000, 0x32107c0e, 0x00801120, 0x11200040, 0x7c0e3210, 0x10003000, 0x00000000, // ICON_SHUFFLE_FILL + 0x00000000, 0x30043ffc, 0x24042804, 0x21042204, 0x20442084, 0x20142024, 0x3ffc200c, 0x00000000, // ICON_EMPTYBOX_SMALL + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX + 0x00000000, 0x23c43ffc, 0x23c423c4, 0x200423c4, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_TOP + 0x00000000, 0x3e043ffc, 0x3e043e04, 0x20043e04, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_TOP_RIGHT + 0x00000000, 0x20043ffc, 0x20042004, 0x3e043e04, 0x3e043e04, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_RIGHT + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x3e042004, 0x3e043e04, 0x3ffc3e04, 0x00000000, // ICON_BOX_BOTTOM_RIGHT + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x23c42004, 0x23c423c4, 0x3ffc23c4, 0x00000000, // ICON_BOX_BOTTOM + 0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x207c2004, 0x207c207c, 0x3ffc207c, 0x00000000, // ICON_BOX_BOTTOM_LEFT + 0x00000000, 0x20043ffc, 0x20042004, 0x207c207c, 0x207c207c, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_LEFT + 0x00000000, 0x207c3ffc, 0x207c207c, 0x2004207c, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_TOP_LEFT + 0x00000000, 0x20043ffc, 0x20042004, 0x23c423c4, 0x23c423c4, 0x20042004, 0x3ffc2004, 0x00000000, // ICON_BOX_CENTER + 0x7ffe0000, 0x40024002, 0x47e24182, 0x4ff247e2, 0x47e24ff2, 0x418247e2, 0x40024002, 0x00007ffe, // ICON_BOX_CIRCLE_MASK + 0x7fff0000, 0x40014001, 0x40014001, 0x49555ddd, 0x4945495d, 0x400149c5, 0x40014001, 0x00007fff, // ICON_POT + 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x404e40ce, 0x48125432, 0x4006540e, 0x00007ffe, // ICON_ALPHA_MULTIPLY + 0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x5c4e40ce, 0x44124432, 0x40065c0e, 0x00007ffe, // ICON_ALPHA_CLEAR + 0x7ffe0000, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x00007ffe, // ICON_DITHERING + 0x07fe0000, 0x1ffa0002, 0x7fea000a, 0x402a402a, 0x5b2a512a, 0x5128552a, 0x40205128, 0x00007fe0, // ICON_MIPMAPS + 0x00000000, 0x1ff80000, 0x12481248, 0x12481ff8, 0x1ff81248, 0x12481248, 0x00001ff8, 0x00000000, // ICON_BOX_GRID + 0x12480000, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x00001248, // ICON_GRID + 0x00000000, 0x1c380000, 0x1c3817e8, 0x08100810, 0x08100810, 0x17e81c38, 0x00001c38, 0x00000000, // ICON_BOX_CORNERS_SMALL + 0x700e0000, 0x700e5ffa, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x5ffa700e, 0x0000700e, // ICON_BOX_CORNERS_BIG + 0x3f7e0000, 0x21422142, 0x21422142, 0x00003f7e, 0x21423f7e, 0x21422142, 0x3f7e2142, 0x00000000, // ICON_FOUR_BOXES + 0x00000000, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x00000000, // ICON_GRID_FILL + 0x7ffe0000, 0x7ffe7ffe, 0x77fe7000, 0x77fe77fe, 0x777e7700, 0x777e777e, 0x777e777e, 0x0000777e, // ICON_BOX_MULTISIZE + 0x781e0000, 0x40024002, 0x00004002, 0x01800000, 0x00000180, 0x40020000, 0x40024002, 0x0000781e, // ICON_ZOOM_SMALL + 0x781e0000, 0x40024002, 0x00004002, 0x03c003c0, 0x03c003c0, 0x40020000, 0x40024002, 0x0000781e, // ICON_ZOOM_MEDIUM + 0x781e0000, 0x40024002, 0x07e04002, 0x07e007e0, 0x07e007e0, 0x400207e0, 0x40024002, 0x0000781e, // ICON_ZOOM_BIG + 0x781e0000, 0x5ffa4002, 0x1ff85ffa, 0x1ff81ff8, 0x1ff81ff8, 0x5ffa1ff8, 0x40025ffa, 0x0000781e, // ICON_ZOOM_ALL + 0x00000000, 0x2004381c, 0x00002004, 0x00000000, 0x00000000, 0x20040000, 0x381c2004, 0x00000000, // ICON_ZOOM_CENTER + 0x00000000, 0x1db80000, 0x10081008, 0x10080000, 0x00001008, 0x10081008, 0x00001db8, 0x00000000, // ICON_BOX_DOTS_SMALL + 0x35560000, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x35562002, 0x00000000, // ICON_BOX_DOTS_BIG + 0x7ffe0000, 0x40024002, 0x48124ff2, 0x49924812, 0x48124992, 0x4ff24812, 0x40024002, 0x00007ffe, // ICON_BOX_CONCENTRIC + 0x00000000, 0x10841ffc, 0x10841084, 0x1ffc1084, 0x10841084, 0x10841084, 0x00001ffc, 0x00000000, // ICON_BOX_GRID_BIG + 0x00000000, 0x00000000, 0x10000000, 0x04000800, 0x01040200, 0x00500088, 0x00000020, 0x00000000, // ICON_OK_TICK + 0x00000000, 0x10080000, 0x04200810, 0x01800240, 0x02400180, 0x08100420, 0x00001008, 0x00000000, // ICON_CROSS + 0x00000000, 0x02000000, 0x00800100, 0x00200040, 0x00200010, 0x00800040, 0x02000100, 0x00000000, // ICON_ARROW_LEFT + 0x00000000, 0x00400000, 0x01000080, 0x04000200, 0x04000800, 0x01000200, 0x00400080, 0x00000000, // ICON_ARROW_RIGHT + 0x00000000, 0x00000000, 0x00000000, 0x08081004, 0x02200410, 0x00800140, 0x00000000, 0x00000000, // ICON_ARROW_DOWN + 0x00000000, 0x00000000, 0x01400080, 0x04100220, 0x10040808, 0x00000000, 0x00000000, 0x00000000, // ICON_ARROW_UP + 0x00000000, 0x02000000, 0x03800300, 0x03e003c0, 0x03e003f0, 0x038003c0, 0x02000300, 0x00000000, // ICON_ARROW_LEFT_FILL + 0x00000000, 0x00400000, 0x01c000c0, 0x07c003c0, 0x07c00fc0, 0x01c003c0, 0x004000c0, 0x00000000, // ICON_ARROW_RIGHT_FILL + 0x00000000, 0x00000000, 0x00000000, 0x0ff81ffc, 0x03e007f0, 0x008001c0, 0x00000000, 0x00000000, // ICON_ARROW_DOWN_FILL + 0x00000000, 0x00000000, 0x01c00080, 0x07f003e0, 0x1ffc0ff8, 0x00000000, 0x00000000, 0x00000000, // ICON_ARROW_UP_FILL + 0x00000000, 0x18a008c0, 0x32881290, 0x24822686, 0x26862482, 0x12903288, 0x08c018a0, 0x00000000, // ICON_AUDIO + 0x00000000, 0x04800780, 0x004000c0, 0x662000f0, 0x08103c30, 0x130a0e18, 0x0000318e, 0x00000000, // ICON_FX + 0x00000000, 0x00800000, 0x08880888, 0x2aaa0a8a, 0x0a8a2aaa, 0x08880888, 0x00000080, 0x00000000, // ICON_WAVE + 0x00000000, 0x00600000, 0x01080090, 0x02040108, 0x42044204, 0x24022402, 0x00001800, 0x00000000, // ICON_WAVE_SINUS + 0x00000000, 0x07f80000, 0x04080408, 0x04080408, 0x04080408, 0x7c0e0408, 0x00000000, 0x00000000, // ICON_WAVE_SQUARE + 0x00000000, 0x00000000, 0x00a00040, 0x22084110, 0x08021404, 0x00000000, 0x00000000, 0x00000000, // ICON_WAVE_TRIANGULAR + 0x00000000, 0x00000000, 0x04200000, 0x01800240, 0x02400180, 0x00000420, 0x00000000, 0x00000000, // ICON_CROSS_SMALL + 0x00000000, 0x18380000, 0x12281428, 0x10a81128, 0x112810a8, 0x14281228, 0x00001838, 0x00000000, // ICON_PLAYER_PREVIOUS + 0x00000000, 0x18000000, 0x11801600, 0x10181060, 0x10601018, 0x16001180, 0x00001800, 0x00000000, // ICON_PLAYER_PLAY_BACK + 0x00000000, 0x00180000, 0x01880068, 0x18080608, 0x06081808, 0x00680188, 0x00000018, 0x00000000, // ICON_PLAYER_PLAY + 0x00000000, 0x1e780000, 0x12481248, 0x12481248, 0x12481248, 0x12481248, 0x00001e78, 0x00000000, // ICON_PLAYER_PAUSE + 0x00000000, 0x1ff80000, 0x10081008, 0x10081008, 0x10081008, 0x10081008, 0x00001ff8, 0x00000000, // ICON_PLAYER_STOP + 0x00000000, 0x1c180000, 0x14481428, 0x15081488, 0x14881508, 0x14281448, 0x00001c18, 0x00000000, // ICON_PLAYER_NEXT + 0x00000000, 0x03c00000, 0x08100420, 0x10081008, 0x10081008, 0x04200810, 0x000003c0, 0x00000000, // ICON_PLAYER_RECORD + 0x00000000, 0x0c3007e0, 0x13c81818, 0x14281668, 0x14281428, 0x1c381c38, 0x08102244, 0x00000000, // ICON_MAGNET + 0x07c00000, 0x08200820, 0x3ff80820, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // ICON_LOCK_CLOSE + 0x07c00000, 0x08000800, 0x3ff80800, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // ICON_LOCK_OPEN + 0x01c00000, 0x0c180770, 0x3086188c, 0x60832082, 0x60034781, 0x30062002, 0x0c18180c, 0x01c00770, // ICON_CLOCK + 0x0a200000, 0x1b201b20, 0x04200e20, 0x04200420, 0x04700420, 0x0e700e70, 0x0e700e70, 0x04200e70, // ICON_TOOLS + 0x01800000, 0x3bdc318c, 0x0ff01ff8, 0x7c3e1e78, 0x1e787c3e, 0x1ff80ff0, 0x318c3bdc, 0x00000180, // ICON_GEAR + 0x01800000, 0x3ffc318c, 0x1c381ff8, 0x781e1818, 0x1818781e, 0x1ff81c38, 0x318c3ffc, 0x00000180, // ICON_GEAR_BIG + 0x00000000, 0x08080ff8, 0x08081ffc, 0x0aa80aa8, 0x0aa80aa8, 0x0aa80aa8, 0x08080aa8, 0x00000ff8, // ICON_BIN + 0x00000000, 0x00000000, 0x20043ffc, 0x08043f84, 0x04040f84, 0x04040784, 0x000007fc, 0x00000000, // ICON_HAND_POINTER + 0x00000000, 0x24400400, 0x00001480, 0x6efe0e00, 0x00000e00, 0x24401480, 0x00000400, 0x00000000, // ICON_LASER + 0x00000000, 0x03c00000, 0x08300460, 0x11181118, 0x11181118, 0x04600830, 0x000003c0, 0x00000000, // ICON_COIN + 0x00000000, 0x10880080, 0x06c00810, 0x366c07e0, 0x07e00240, 0x00001768, 0x04200240, 0x00000000, // ICON_EXPLOSION + 0x00000000, 0x3d280000, 0x2528252c, 0x3d282528, 0x05280528, 0x05e80528, 0x00000000, 0x00000000, // ICON_1UP + 0x01800000, 0x03c003c0, 0x018003c0, 0x0ff007e0, 0x0bd00bd0, 0x0a500bd0, 0x02400240, 0x02400240, // ICON_PLAYER + 0x01800000, 0x03c003c0, 0x118013c0, 0x03c81ff8, 0x07c003c8, 0x04400440, 0x0c080478, 0x00000000, // ICON_PLAYER_JUMP + 0x3ff80000, 0x30183ff8, 0x30183018, 0x3ff83ff8, 0x03000300, 0x03c003c0, 0x03e00300, 0x000003e0, // ICON_KEY + 0x3ff80000, 0x3ff83ff8, 0x33983ff8, 0x3ff83398, 0x3ff83ff8, 0x00000540, 0x0fe00aa0, 0x00000fe0, // ICON_DEMON + 0x00000000, 0x0ff00000, 0x20041008, 0x25442004, 0x10082004, 0x06000bf0, 0x00000300, 0x00000000, // ICON_TEXT_POPUP + 0x00000000, 0x11440000, 0x07f00be8, 0x1c1c0e38, 0x1c1c0c18, 0x07f00e38, 0x11440be8, 0x00000000, // ICON_GEAR_EX + 0x00000000, 0x20080000, 0x0c601010, 0x07c00fe0, 0x07c007c0, 0x0c600fe0, 0x20081010, 0x00000000, // ICON_CRACK + 0x00000000, 0x20080000, 0x0c601010, 0x04400fe0, 0x04405554, 0x0c600fe0, 0x20081010, 0x00000000, // ICON_CRACK_POINTS + 0x00000000, 0x00800080, 0x01c001c0, 0x1ffc3ffe, 0x03e007f0, 0x07f003e0, 0x0c180770, 0x00000808, // ICON_STAR + 0x0ff00000, 0x08180810, 0x08100818, 0x0a100810, 0x08180810, 0x08100818, 0x08100810, 0x00001ff8, // ICON_DOOR + 0x0ff00000, 0x08100810, 0x08100810, 0x10100010, 0x4f902010, 0x10102010, 0x08100010, 0x00000ff0, // ICON_EXIT + 0x00040000, 0x001f000e, 0x0ef40004, 0x12f41284, 0x0ef41214, 0x10040004, 0x7ffc3004, 0x10003000, // ICON_MODE_2D + 0x78040000, 0x501f600e, 0x0ef44004, 0x12f41284, 0x0ef41284, 0x10140004, 0x7ffc300c, 0x10003000, // ICON_MODE_3D + 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // ICON_CUBE + 0x7fe00000, 0x5ff87ff0, 0x47fe4ffc, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // ICON_CUBE_FACE_TOP + 0x7fe00000, 0x50386030, 0x47fe483c, 0x443e443e, 0x443e443e, 0x241e75fe, 0x0c06140e, 0x000007fe, // ICON_CUBE_FACE_LEFT + 0x7fe00000, 0x50286030, 0x47fe4804, 0x47fe47fe, 0x47fe47fe, 0x27fe77fe, 0x0ffe17fe, 0x000007fe, // ICON_CUBE_FACE_FRONT + 0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x3ff27fe2, 0x0ffe1ffa, 0x000007fe, // ICON_CUBE_FACE_BOTTOM + 0x7fe00000, 0x70286030, 0x7ffe7804, 0x7c227c02, 0x7c227c22, 0x3c127de2, 0x0c061c0a, 0x000007fe, // ICON_CUBE_FACE_RIGHT + 0x7fe00000, 0x7fe87ff0, 0x7ffe7fe4, 0x7fe27fe2, 0x7fe27fe2, 0x24127fe2, 0x0c06140a, 0x000007fe, // ICON_CUBE_FACE_BACK + 0x00000000, 0x2a0233fe, 0x22022602, 0x22022202, 0x2a022602, 0x00a033fe, 0x02080110, 0x00000000, // ICON_CAMERA + 0x00000000, 0x200c3ffc, 0x000c000c, 0x3ffc000c, 0x30003000, 0x30003000, 0x3ffc3004, 0x00000000, // ICON_SPECIAL + 0x00000000, 0x0022003e, 0x012201e2, 0x0100013e, 0x01000100, 0x79000100, 0x4f004900, 0x00007800, // ICON_LINK_NET + 0x00000000, 0x44007c00, 0x45004600, 0x00627cbe, 0x00620022, 0x45007cbe, 0x44004600, 0x00007c00, // ICON_LINK_BOXES + 0x00000000, 0x0044007c, 0x0010007c, 0x3f100010, 0x3f1021f0, 0x3f100010, 0x3f0021f0, 0x00000000, // ICON_LINK_MULTI + 0x00000000, 0x0044007c, 0x00440044, 0x0010007c, 0x00100010, 0x44107c10, 0x440047f0, 0x00007c00, // ICON_LINK + 0x00000000, 0x0044007c, 0x00440044, 0x0000007c, 0x00000010, 0x44007c10, 0x44004550, 0x00007c00, // ICON_LINK_BROKE + 0x02a00000, 0x22a43ffc, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // ICON_TEXT_NOTES + 0x3ffc0000, 0x20042004, 0x245e27c4, 0x27c42444, 0x2004201e, 0x201e2004, 0x20042004, 0x00003ffc, // ICON_NOTEBOOK + 0x00000000, 0x07e00000, 0x04200420, 0x24243ffc, 0x24242424, 0x24242424, 0x3ffc2424, 0x00000000, // ICON_SUITCASE + 0x00000000, 0x0fe00000, 0x08200820, 0x40047ffc, 0x7ffc5554, 0x40045554, 0x7ffc4004, 0x00000000, // ICON_SUITCASE_ZIP + 0x00000000, 0x20043ffc, 0x3ffc2004, 0x13c81008, 0x100813c8, 0x10081008, 0x1ff81008, 0x00000000, // ICON_MAILBOX + 0x00000000, 0x40027ffe, 0x5ffa5ffa, 0x5ffa5ffa, 0x40025ffa, 0x03c07ffe, 0x1ff81ff8, 0x00000000, // ICON_MONITOR + 0x0ff00000, 0x6bfe7ffe, 0x7ffe7ffe, 0x68167ffe, 0x08106816, 0x08100810, 0x0ff00810, 0x00000000, // ICON_PRINTER + 0x3ff80000, 0xfffe2008, 0x870a8002, 0x904a888a, 0x904a904a, 0x870a888a, 0xfffe8002, 0x00000000, // ICON_PHOTO_CAMERA + 0x0fc00000, 0xfcfe0cd8, 0x8002fffe, 0x84428382, 0x84428442, 0x80028382, 0xfffe8002, 0x00000000, // ICON_PHOTO_CAMERA_FLASH + 0x00000000, 0x02400180, 0x08100420, 0x20041008, 0x23c42004, 0x22442244, 0x3ffc2244, 0x00000000, // ICON_HOUSE + 0x00000000, 0x1c700000, 0x3ff83ef8, 0x3ff83ff8, 0x0fe01ff0, 0x038007c0, 0x00000100, 0x00000000, // ICON_HEART + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x80000000, 0xe000c000, // ICON_CORNER + 0x00000000, 0x14001c00, 0x15c01400, 0x15401540, 0x155c1540, 0x15541554, 0x1ddc1554, 0x00000000, // ICON_VERTICAL_BARS + 0x00000000, 0x03000300, 0x1b001b00, 0x1b601b60, 0x1b6c1b60, 0x1b6c1b6c, 0x1b6c1b6c, 0x00000000, // ICON_VERTICAL_BARS_FILL + 0x00000000, 0x00000000, 0x403e7ffe, 0x7ffe403e, 0x7ffe0000, 0x43fe43fe, 0x00007ffe, 0x00000000, // ICON_LIFE_BARS + 0x7ffc0000, 0x43844004, 0x43844284, 0x43844004, 0x42844284, 0x42844284, 0x40044384, 0x00007ffc, // ICON_INFO + 0x40008000, 0x10002000, 0x04000800, 0x01000200, 0x00400080, 0x00100020, 0x00040008, 0x00010002, // ICON_CROSSLINE + 0x00000000, 0x1ff01ff0, 0x18301830, 0x1f001830, 0x03001f00, 0x00000300, 0x03000300, 0x00000000, // ICON_HELP + 0x3ff00000, 0x2abc3550, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x00003ffc, // ICON_FILETYPE_ALPHA + 0x3ff00000, 0x201c2010, 0x22442184, 0x28142424, 0x29942814, 0x2ff42994, 0x20042004, 0x00003ffc, // ICON_FILETYPE_HOME + 0x07fe0000, 0x04020402, 0x7fe20402, 0x44224422, 0x44224422, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_LAYERS_VISIBLE + 0x07fe0000, 0x04020402, 0x7c020402, 0x44024402, 0x44024402, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_LAYERS + 0x00000000, 0x40027ffe, 0x7ffe4002, 0x40024002, 0x40024002, 0x40024002, 0x7ffe4002, 0x00000000, // ICON_WINDOW + 0x09100000, 0x09f00910, 0x09100910, 0x00000910, 0x24a2779e, 0x27a224a2, 0x709e20a2, 0x00000000, // ICON_HIDPI + 0x3ff00000, 0x201c2010, 0x2a842e84, 0x2e842a84, 0x2ba42004, 0x2aa42aa4, 0x20042ba4, 0x00003ffc, // ICON_FILETYPE_BINARY + 0x00000000, 0x00000000, 0x00120012, 0x4a5e4bd2, 0x485233d2, 0x00004bd2, 0x00000000, 0x00000000, // ICON_HEX + 0x01800000, 0x381c0660, 0x23c42004, 0x23c42044, 0x13c82204, 0x08101008, 0x02400420, 0x00000180, // ICON_SHIELD + 0x007e0000, 0x20023fc2, 0x40227fe2, 0x400a403a, 0x400a400a, 0x400a400a, 0x4008400e, 0x00007ff8, // ICON_FILE_NEW + 0x00000000, 0x0042007e, 0x40027fc2, 0x44024002, 0x5f024402, 0x44024402, 0x7ffe4002, 0x00000000, // ICON_FOLDER_ADD + 0x44220000, 0x12482244, 0xf3cf0000, 0x14280420, 0x48122424, 0x08100810, 0x1ff81008, 0x03c00420, // ICON_ALARM + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_206 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_207 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_208 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_209 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_210 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_211 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_212 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_213 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_214 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_215 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_216 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_217 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_218 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_219 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_220 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_221 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_222 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_223 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_224 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_225 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_226 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_227 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_228 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_229 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_230 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_231 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_232 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_233 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_234 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_235 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_236 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_237 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_238 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_239 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_240 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_241 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_242 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_243 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_244 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_245 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_246 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_247 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_248 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_249 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_250 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_251 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_252 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_253 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_254 + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_255 }; -#endif // RAYGUI_CUSTOM_RICONS +#endif // !RAYGUI_NO_ICONS && !RAYGUI_CUSTOM_ICONS -#endif // !RAYGUI_NO_RICONS - -#ifndef RICON_SIZE - #define RICON_SIZE 0 +#ifndef RAYGUI_ICON_SIZE + #define RAYGUI_ICON_SIZE 0 #endif #define RAYGUI_MAX_CONTROLS 16 // Maximum number of standard controls @@ -1146,11 +1152,13 @@ typedef enum { BORDER = 0, BASE, TEXT, OTHER } GuiPropertyElement; //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- -static GuiControlState guiState = GUI_STATE_NORMAL; +static GuiState guiState = STATE_NORMAL; // Gui global state, if !STATE_NORMAL, forces defined state -static Font guiFont = { 0 }; // Gui current font (WARNING: highly coupled to raylib) -static bool guiLocked = false; // Gui lock state (no inputs processed) -static float guiAlpha = 1.0f; // Gui element transpacency on drawing +static Font guiFont = { 0 }; // Gui current font (WARNING: highly coupled to raylib) +static bool guiLocked = false; // Gui lock state (no inputs processed) +static float guiAlpha = 1.0f; // Gui element transpacency on drawing + +static unsigned int guiIconScale = 1; // Gui icon default scale (if icons enabled) //---------------------------------------------------------------------------------- // Style data array for all gui style properties (allocated on data segment by default) @@ -1166,7 +1174,7 @@ static float guiAlpha = 1.0f; // Gui element transpacency on drawing //---------------------------------------------------------------------------------- static unsigned int guiStyle[RAYGUI_MAX_CONTROLS*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED)] = { 0 }; -static bool guiStyleLoaded = false; // Style loaded flag for lazy style initialization +static bool guiStyleLoaded = false; // Style loaded flag for lazy style initialization //---------------------------------------------------------------------------------- // Standalone Mode Functions Declaration @@ -1245,18 +1253,22 @@ static const char *GetTextIcon(const char *text, int *iconId); // Get text icon static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color tint); // Gui draw text using default font static void GuiDrawRectangle(Rectangle rec, int borderWidth, Color borderColor, Color color); // Gui draw rectangle using default raygui style -static const char **GuiTextSplit(const char *text, int *count, int *textRow); // Split controls text into multiple strings +static const char **GuiTextSplit(const char *text, int *count, int *textRow); // Split controls text into multiple strings static Vector3 ConvertHSVtoRGB(Vector3 hsv); // Convert color data from HSV to RGB static Vector3 ConvertRGBtoHSV(Vector3 rgb); // Convert color data from RGB to HSV +static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue); // Scroll bar control, used by GuiScrollPanel() + //---------------------------------------------------------------------------------- // Gui Setup Functions Definition //---------------------------------------------------------------------------------- // Enable gui global state -void GuiEnable(void) { guiState = GUI_STATE_NORMAL; } +// NOTE: We check for STATE_DISABLED to avoid messing custom global state setups +void GuiEnable(void) { if (guiState == STATE_DISABLED) guiState = STATE_NORMAL; } // Disable gui global state -void GuiDisable(void) { guiState = GUI_STATE_DISABLED; } +// NOTE: We check for STATE_NORMAL to avoid messing custom global state setups +void GuiDisable(void) { if (guiState == STATE_NORMAL) guiState = STATE_DISABLED; } // Lock gui global state void GuiLock(void) { guiLocked = true; } @@ -1277,7 +1289,7 @@ void GuiFade(float alpha) } // Set gui state (global state) -void GuiSetState(int state) { guiState = (GuiControlState)state; } +void GuiSetState(int state) { guiState = (GuiState)state; } // Get gui state (global state) int GuiGetState(void) { return guiState; } @@ -1331,19 +1343,21 @@ int GuiGetStyle(int control, int property) // Window Box control bool GuiWindowBox(Rectangle bounds, const char *title) { + // Window title bar height (including borders) // NOTE: This define is also used by GuiMessageBox() and GuiTextInputBox() - #define WINDOW_STATUSBAR_HEIGHT 22 + #if !defined(RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT) + #define RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT 24 + #endif - //GuiControlState state = guiState; + //GuiState state = guiState; bool clicked = false; - int statusBarHeight = WINDOW_STATUSBAR_HEIGHT + 2*GuiGetStyle(STATUSBAR, BORDER_WIDTH); - statusBarHeight += (statusBarHeight%2); + int statusBarHeight = RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT; Rectangle statusBar = { bounds.x, bounds.y, bounds.width, (float)statusBarHeight }; if (bounds.height < statusBarHeight*2.0f) bounds.height = statusBarHeight*2.0f; - Rectangle windowPanel = { bounds.x, bounds.y + (float)statusBarHeight - 1, bounds.width, bounds.height - (float)statusBarHeight }; + Rectangle windowPanel = { bounds.x, bounds.y + (float)statusBarHeight - 1, bounds.width, bounds.height - (float)statusBarHeight + 1 }; Rectangle closeButtonRec = { statusBar.x + statusBar.width - GuiGetStyle(STATUSBAR, BORDER_WIDTH) - 20, statusBar.y + statusBarHeight/2.0f - 18.0f/2.0f, 18, 18 }; @@ -1355,17 +1369,17 @@ bool GuiWindowBox(Rectangle bounds, const char *title) // Draw control //-------------------------------------------------------------------- GuiStatusBar(statusBar, title); // Draw window header as status bar - GuiPanel(windowPanel); // Draw window base + GuiPanel(windowPanel, NULL); // Draw window base // Draw window close button int tempBorderWidth = GuiGetStyle(BUTTON, BORDER_WIDTH); int tempTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT); GuiSetStyle(BUTTON, BORDER_WIDTH, 1); - GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); -#if defined(RAYGUI_NO_RICONS) + GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); +#if defined(RAYGUI_NO_ICONS) clicked = GuiButton(closeButtonRec, "x"); #else - clicked = GuiButton(closeButtonRec, GuiIconText(RICON_CROSS_SMALL, NULL)); + clicked = GuiButton(closeButtonRec, GuiIconText(ICON_CROSS_SMALL, NULL)); #endif GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth); GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlignment); @@ -1377,29 +1391,35 @@ bool GuiWindowBox(Rectangle bounds, const char *title) // Group Box control with text name void GuiGroupBox(Rectangle bounds, const char *text) { - #define GROUPBOX_LINE_THICK 1 - #define GROUPBOX_TEXT_PADDING 10 + #if !defined(RAYGUI_GROUPBOX_LINE_THICK) + #define RAYGUI_GROUPBOX_LINE_THICK 1 + #endif - GuiControlState state = guiState; + GuiState state = guiState; // Draw control //-------------------------------------------------------------------- - GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y, GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, Fade(GetColor(GuiGetStyle(DEFAULT, (state == GUI_STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)), guiAlpha)); - GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + bounds.height - 1, bounds.width, GROUPBOX_LINE_THICK }, 0, BLANK, Fade(GetColor(GuiGetStyle(DEFAULT, (state == GUI_STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)), guiAlpha)); - GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x + bounds.width - 1, bounds.y, GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, Fade(GetColor(GuiGetStyle(DEFAULT, (state == GUI_STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)), guiAlpha)); + GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y, RAYGUI_GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, Fade(GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)), guiAlpha)); + GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + bounds.height - 1, bounds.width, RAYGUI_GROUPBOX_LINE_THICK }, 0, BLANK, Fade(GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)), guiAlpha)); + GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x + bounds.width - 1, bounds.y, RAYGUI_GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, Fade(GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)), guiAlpha)); - GuiLine(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y, bounds.width, 1 }, text); + GuiLine(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y - GuiGetStyle(DEFAULT, TEXT_SIZE)/2, bounds.width, (float)GuiGetStyle(DEFAULT, TEXT_SIZE) }, text); //-------------------------------------------------------------------- } // Line control void GuiLine(Rectangle bounds, const char *text) { - #define LINE_TEXT_PADDING 10 + #if !defined(RAYGUI_LINE_ORIGIN_SIZE) + #define RAYGUI_LINE_MARGIN_TEXT 12 + #endif + #if !defined(RAYGUI_LINE_TEXT_PADDING) + #define RAYGUI_LINE_TEXT_PADDING 4 + #endif - GuiControlState state = guiState; + GuiState state = guiState; - Color color = Fade(GetColor(GuiGetStyle(DEFAULT, (state == GUI_STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)), guiAlpha); + Color color = Fade(GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)), guiAlpha); // Draw control //-------------------------------------------------------------------- @@ -1408,40 +1428,66 @@ void GuiLine(Rectangle bounds, const char *text) { Rectangle textBounds = { 0 }; textBounds.width = (float)GetTextWidth(text); - textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE); - textBounds.x = bounds.x + LINE_TEXT_PADDING; - textBounds.y = bounds.y - (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/2; + textBounds.height = bounds.height; + textBounds.x = bounds.x + RAYGUI_LINE_MARGIN_TEXT; + textBounds.y = bounds.y; // Draw line with embedded text label: "--- text --------------" - GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y, LINE_TEXT_PADDING - 2, 1 }, 0, BLANK, color); - GuiLabel(textBounds, text); - GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x + LINE_TEXT_PADDING + textBounds.width + 4, bounds.y, bounds.width - textBounds.width - LINE_TEXT_PADDING - 4, 1 }, 0, BLANK, color); + GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + bounds.height/2, RAYGUI_LINE_MARGIN_TEXT - RAYGUI_LINE_TEXT_PADDING, 1 }, 0, BLANK, color); + GuiDrawText(text, textBounds, TEXT_ALIGN_LEFT, color); + GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x + 12 + textBounds.width + 4, bounds.y + bounds.height/2, bounds.width - textBounds.width - RAYGUI_LINE_MARGIN_TEXT - RAYGUI_LINE_TEXT_PADDING, 1 }, 0, BLANK, color); } //-------------------------------------------------------------------- } // Panel control -void GuiPanel(Rectangle bounds) +void GuiPanel(Rectangle bounds, const char *text) { - #define PANEL_BORDER_WIDTH 1 + #if !defined(RAYGUI_PANEL_BORDER_WIDTH) + #define RAYGUI_PANEL_BORDER_WIDTH 1 + #endif - GuiControlState state = guiState; + GuiState state = guiState; + + // Text will be drawn as a header bar (if provided) + Rectangle statusBar = { bounds.x, bounds.y, bounds.width, (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT }; + if ((text != NULL) && (bounds.height < RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT*2.0f)) bounds.height = RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT*2.0f; + + if (text != NULL) + { + // Move panel bounds after the header bar + bounds.y += (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - 1; + bounds.height -= (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + 1; + } // Draw control //-------------------------------------------------------------------- - GuiDrawRectangle(bounds, PANEL_BORDER_WIDTH, Fade(GetColor(GuiGetStyle(DEFAULT, (state == GUI_STATE_DISABLED)? BORDER_COLOR_DISABLED: LINE_COLOR)), guiAlpha), - Fade(GetColor(GuiGetStyle(DEFAULT, (state == GUI_STATE_DISABLED)? BASE_COLOR_DISABLED : BACKGROUND_COLOR)), guiAlpha)); + if (text != NULL) GuiStatusBar(statusBar, text); // Draw panel header as status bar + + GuiDrawRectangle(bounds, RAYGUI_PANEL_BORDER_WIDTH, Fade(GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED: LINE_COLOR)), guiAlpha), + Fade(GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BASE_COLOR_DISABLED : BACKGROUND_COLOR)), guiAlpha)); //-------------------------------------------------------------------- } // Scroll Panel control -Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll) +Rectangle GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content, Vector2 *scroll) { - GuiControlState state = guiState; + GuiState state = guiState; Vector2 scrollPos = { 0.0f, 0.0f }; if (scroll != NULL) scrollPos = *scroll; + // Text will be drawn as a header bar (if provided) + Rectangle statusBar = { bounds.x, bounds.y, bounds.width, (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT }; + if (bounds.height < RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT*2.0f) bounds.height = RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT*2.0f; + + if (text != NULL) + { + // Move panel bounds after the header bar + bounds.y += (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - 1; + bounds.height -= (float)RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + 1; + } + bool hasHorizontalScrollBar = (content.width > bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH))? true : false; bool hasVerticalScrollBar = (content.height > bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH))? true : false; @@ -1449,10 +1495,10 @@ Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll) if (!hasHorizontalScrollBar) hasHorizontalScrollBar = (hasVerticalScrollBar && (content.width > (bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH))))? true : false; if (!hasVerticalScrollBar) hasVerticalScrollBar = (hasHorizontalScrollBar && (content.height > (bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH))))? true : false; - const int horizontalScrollBarWidth = hasHorizontalScrollBar? GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH) : 0; - const int verticalScrollBarWidth = hasVerticalScrollBar? GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH) : 0; - const Rectangle horizontalScrollBar = { (float)((GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)bounds.x + verticalScrollBarWidth : (float)bounds.x) + GuiGetStyle(DEFAULT, BORDER_WIDTH), (float)bounds.y + bounds.height - horizontalScrollBarWidth - GuiGetStyle(DEFAULT, BORDER_WIDTH), (float)bounds.width - verticalScrollBarWidth - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH), (float)horizontalScrollBarWidth }; - const Rectangle verticalScrollBar = { (float)((GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)bounds.x + GuiGetStyle(DEFAULT, BORDER_WIDTH) : (float)bounds.x + bounds.width - verticalScrollBarWidth - GuiGetStyle(DEFAULT, BORDER_WIDTH)), (float)bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), (float)verticalScrollBarWidth, (float)bounds.height - horizontalScrollBarWidth - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) }; + int horizontalScrollBarWidth = hasHorizontalScrollBar? GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH) : 0; + int verticalScrollBarWidth = hasVerticalScrollBar? GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH) : 0; + Rectangle horizontalScrollBar = { (float)((GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)bounds.x + verticalScrollBarWidth : (float)bounds.x) + GuiGetStyle(DEFAULT, BORDER_WIDTH), (float)bounds.y + bounds.height - horizontalScrollBarWidth - GuiGetStyle(DEFAULT, BORDER_WIDTH), (float)bounds.width - verticalScrollBarWidth - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH), (float)horizontalScrollBarWidth }; + Rectangle verticalScrollBar = { (float)((GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)bounds.x + GuiGetStyle(DEFAULT, BORDER_WIDTH) : (float)bounds.x + bounds.width - verticalScrollBarWidth - GuiGetStyle(DEFAULT, BORDER_WIDTH)), (float)bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), (float)verticalScrollBarWidth, (float)bounds.height - horizontalScrollBarWidth - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) }; // Calculate view area (area without the scrollbars) Rectangle view = (GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? @@ -1463,23 +1509,24 @@ Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll) if (view.width > content.width) view.width = content.width; if (view.height > content.height) view.height = content.height; - const float horizontalMin = hasHorizontalScrollBar? ((GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)-verticalScrollBarWidth : 0) - (float)GuiGetStyle(DEFAULT, BORDER_WIDTH) : (((float)GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)-verticalScrollBarWidth : 0) - (float)GuiGetStyle(DEFAULT, BORDER_WIDTH); - const float horizontalMax = hasHorizontalScrollBar? content.width - bounds.width + (float)verticalScrollBarWidth + GuiGetStyle(DEFAULT, BORDER_WIDTH) - (((float)GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)verticalScrollBarWidth : 0) : (float)-GuiGetStyle(DEFAULT, BORDER_WIDTH); - const float verticalMin = hasVerticalScrollBar? (float)-GuiGetStyle(DEFAULT, BORDER_WIDTH) : (float)-GuiGetStyle(DEFAULT, BORDER_WIDTH); - const float verticalMax = hasVerticalScrollBar? content.height - bounds.height + (float)horizontalScrollBarWidth + (float)GuiGetStyle(DEFAULT, BORDER_WIDTH) : (float)-GuiGetStyle(DEFAULT, BORDER_WIDTH); + float horizontalMin = hasHorizontalScrollBar? ((GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)-verticalScrollBarWidth : 0) - (float)GuiGetStyle(DEFAULT, BORDER_WIDTH) : (((float)GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)-verticalScrollBarWidth : 0) - (float)GuiGetStyle(DEFAULT, BORDER_WIDTH); + float horizontalMax = hasHorizontalScrollBar? content.width - bounds.width + (float)verticalScrollBarWidth + GuiGetStyle(DEFAULT, BORDER_WIDTH) - (((float)GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (float)verticalScrollBarWidth : 0) : (float)-GuiGetStyle(DEFAULT, BORDER_WIDTH); + float verticalMin = hasVerticalScrollBar? 0 : -1; + float verticalMax = hasVerticalScrollBar? content.height - bounds.height + (float)horizontalScrollBarWidth + (float)GuiGetStyle(DEFAULT, BORDER_WIDTH) : (float)-GuiGetStyle(DEFAULT, BORDER_WIDTH); // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); // Check button state if (CheckCollisionPointRec(mousePoint, bounds)) { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED; - else state = GUI_STATE_FOCUSED; + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED; + else state = STATE_FOCUSED; +#if defined(SUPPORT_SCROLLBAR_KEY_INPUT) if (hasHorizontalScrollBar) { if (IsKeyDown(KEY_RIGHT)) scrollPos.x -= GuiGetStyle(SCROLLBAR, SCROLL_SPEED); @@ -1491,11 +1538,11 @@ Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll) if (IsKeyDown(KEY_DOWN)) scrollPos.y -= GuiGetStyle(SCROLLBAR, SCROLL_SPEED); if (IsKeyDown(KEY_UP)) scrollPos.y += GuiGetStyle(SCROLLBAR, SCROLL_SPEED); } - +#endif float wheelMove = GetMouseWheelMove(); // Horizontal scroll (Shift + Mouse wheel) - if (hasHorizontalScrollBar && (IsKeyDown(KEY_LEFT_SHIFT) || IsKeyDown(KEY_RIGHT_SHIFT))) scrollPos.x += wheelMove*20; + if (hasHorizontalScrollBar && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_SHIFT))) scrollPos.x += wheelMove*20; else scrollPos.y += wheelMove*20; // Vertical scroll } } @@ -1509,6 +1556,8 @@ Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll) // Draw control //-------------------------------------------------------------------- + if (text != NULL) GuiStatusBar(statusBar, text); // Draw panel header as status bar + GuiDrawRectangle(bounds, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR))); // Draw background // Save size of the scrollbar slider @@ -1521,6 +1570,7 @@ Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll) GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, (int)(((bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth)/(int)content.width)*((int)bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth))); scrollPos.x = (float)-GuiScrollBar(horizontalScrollBar, (int)-scrollPos.x, (int)horizontalMin, (int)horizontalMax); } + else scrollPos.x = 0.0f; // Draw vertical scrollbar if visible if (hasVerticalScrollBar) @@ -1529,11 +1579,12 @@ Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll) GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, (int)(((bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth)/(int)content.height)*((int)bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth))); scrollPos.y = (float)-GuiScrollBar(verticalScrollBar, (int)-scrollPos.y, (int)verticalMin, (int)verticalMax); } + else scrollPos.y = 0.0f; // Draw detail corner rectangle if both scroll bars are visible if (hasHorizontalScrollBar && hasVerticalScrollBar) { - Rectangle corner = { (GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE) ? (bounds.x + GuiGetStyle(DEFAULT, BORDER_WIDTH) + 2) : (horizontalScrollBar.x + horizontalScrollBar.width + 2), verticalScrollBar.y + verticalScrollBar.height + 2, (float)horizontalScrollBarWidth - 4, (float)verticalScrollBarWidth - 4 }; + Rectangle corner = { (GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)? (bounds.x + GuiGetStyle(DEFAULT, BORDER_WIDTH) + 2) : (horizontalScrollBar.x + horizontalScrollBar.width + 2), verticalScrollBar.y + verticalScrollBar.height + 2, (float)horizontalScrollBarWidth - 4, (float)verticalScrollBarWidth - 4 }; GuiDrawRectangle(corner, 0, BLANK, Fade(GetColor(GuiGetStyle(LISTVIEW, TEXT + (state*3))), guiAlpha)); } @@ -1552,7 +1603,7 @@ Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll) // Label control void GuiLabel(Rectangle bounds, const char *text) { - GuiControlState state = guiState; + GuiState state = guiState; // Update control //-------------------------------------------------------------------- @@ -1561,27 +1612,27 @@ void GuiLabel(Rectangle bounds, const char *text) // Draw control //-------------------------------------------------------------------- - GuiDrawText(text, GetTextBounds(LABEL, bounds), GuiGetStyle(LABEL, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(LABEL, (state == GUI_STATE_DISABLED)? TEXT_COLOR_DISABLED : TEXT_COLOR_NORMAL)), guiAlpha)); + GuiDrawText(text, GetTextBounds(LABEL, bounds), GuiGetStyle(LABEL, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); //-------------------------------------------------------------------- } // Button control, returns true when clicked bool GuiButton(Rectangle bounds, const char *text) { - GuiControlState state = guiState; + GuiState state = guiState; bool pressed = false; // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); // Check button state if (CheckCollisionPointRec(mousePoint, bounds)) { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED; - else state = GUI_STATE_FOCUSED; + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED; + else state = STATE_FOCUSED; if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) pressed = true; } @@ -1600,7 +1651,7 @@ bool GuiButton(Rectangle bounds, const char *text) // Label button control bool GuiLabelButton(Rectangle bounds, const char *text) { - GuiControlState state = guiState; + GuiState state = guiState; bool pressed = false; // NOTE: We force bounds.width to be all text @@ -1609,15 +1660,15 @@ bool GuiLabelButton(Rectangle bounds, const char *text) // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); // Check checkbox state if (CheckCollisionPointRec(mousePoint, bounds)) { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED; - else state = GUI_STATE_FOCUSED; + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED; + else state = STATE_FOCUSED; if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) pressed = true; } @@ -1635,31 +1686,31 @@ bool GuiLabelButton(Rectangle bounds, const char *text) // Toggle Button control, returns true when active bool GuiToggle(Rectangle bounds, const char *text, bool active) { - GuiControlState state = guiState; + GuiState state = guiState; // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); // Check toggle button state if (CheckCollisionPointRec(mousePoint, bounds)) { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED; + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED; else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) { - state = GUI_STATE_NORMAL; + state = STATE_NORMAL; active = !active; } - else state = GUI_STATE_FOCUSED; + else state = STATE_FOCUSED; } } //-------------------------------------------------------------------- // Draw control //-------------------------------------------------------------------- - if (state == GUI_STATE_NORMAL) + if (state == STATE_NORMAL) { GuiDrawRectangle(bounds, GuiGetStyle(TOGGLE, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TOGGLE, (active? BORDER_COLOR_PRESSED : (BORDER + state*3)))), guiAlpha), Fade(GetColor(GuiGetStyle(TOGGLE, (active? BASE_COLOR_PRESSED : (BASE + state*3)))), guiAlpha)); GuiDrawText(text, GetTextBounds(TOGGLE, bounds), GuiGetStyle(TOGGLE, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(TOGGLE, (active? TEXT_COLOR_PRESSED : (TEXT + state*3)))), guiAlpha)); @@ -1677,14 +1728,14 @@ bool GuiToggle(Rectangle bounds, const char *text, bool active) // Toggle Group control, returns toggled button index int GuiToggleGroup(Rectangle bounds, const char *text, int active) { - #if !defined(TOGGLEGROUP_MAX_ELEMENTS) - #define TOGGLEGROUP_MAX_ELEMENTS 32 + #if !defined(RAYGUI_TOGGLEGROUP_MAX_ITEMS) + #define RAYGUI_TOGGLEGROUP_MAX_ITEMS 32 #endif float initBoundsX = bounds.x; // Get substrings items from text (items pointers) - int rows[TOGGLEGROUP_MAX_ELEMENTS] = { 0 }; + int rows[RAYGUI_TOGGLEGROUP_MAX_ITEMS] = { 0 }; int itemCount = 0; const char **items = GuiTextSplit(text, &itemCount, rows); @@ -1711,7 +1762,7 @@ int GuiToggleGroup(Rectangle bounds, const char *text, int active) // Check Box control, returns true when active bool GuiCheckBox(Rectangle bounds, const char *text, bool checked) { - GuiControlState state = guiState; + GuiState state = guiState; Rectangle textBounds = { 0 }; @@ -1721,17 +1772,17 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked) textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE); textBounds.x = bounds.x + bounds.width + GuiGetStyle(CHECKBOX, TEXT_PADDING); textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2; - if (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_LEFT) textBounds.x = bounds.x - textBounds.width - GuiGetStyle(CHECKBOX, TEXT_PADDING); + if (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_LEFT) textBounds.x = bounds.x - textBounds.width - GuiGetStyle(CHECKBOX, TEXT_PADDING); } // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); Rectangle totalBounds = { - (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_LEFT)? textBounds.x : bounds.x, + (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_LEFT)? textBounds.x : bounds.x, bounds.y, bounds.width + textBounds.width + GuiGetStyle(CHECKBOX, TEXT_PADDING), bounds.height, @@ -1740,8 +1791,8 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked) // Check checkbox state if (CheckCollisionPointRec(mousePoint, totalBounds)) { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED; - else state = GUI_STATE_FOCUSED; + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED; + else state = STATE_FOCUSED; if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) checked = !checked; } @@ -1761,7 +1812,7 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked) GuiDrawRectangle(check, 0, BLANK, Fade(GetColor(GuiGetStyle(CHECKBOX, TEXT + state*3)), guiAlpha)); } - GuiDrawText(text, textBounds, (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); + GuiDrawText(text, textBounds, (GuiGetStyle(CHECKBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT)? TEXT_ALIGN_LEFT : TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); //-------------------------------------------------------------------- return checked; @@ -1770,11 +1821,11 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked) // Combo Box control, returns selected item index int GuiComboBox(Rectangle bounds, const char *text, int active) { - GuiControlState state = guiState; + GuiState state = guiState; - bounds.width -= (GuiGetStyle(COMBOBOX, COMBO_BUTTON_WIDTH) + GuiGetStyle(COMBOBOX, COMBO_BUTTON_PADDING)); + bounds.width -= (GuiGetStyle(COMBOBOX, COMBO_BUTTON_WIDTH) + GuiGetStyle(COMBOBOX, COMBO_BUTTON_SPACING)); - Rectangle selector = { (float)bounds.x + bounds.width + GuiGetStyle(COMBOBOX, COMBO_BUTTON_PADDING), + Rectangle selector = { (float)bounds.x + bounds.width + GuiGetStyle(COMBOBOX, COMBO_BUTTON_SPACING), (float)bounds.y, (float)GuiGetStyle(COMBOBOX, COMBO_BUTTON_WIDTH), (float)bounds.height }; // Get substrings items from text (items pointers, lengths and count) @@ -1786,7 +1837,7 @@ int GuiComboBox(Rectangle bounds, const char *text, int active) // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked && (itemCount > 1)) + if ((state != STATE_DISABLED) && !guiLocked && (itemCount > 1)) { Vector2 mousePoint = GetMousePosition(); @@ -1799,8 +1850,8 @@ int GuiComboBox(Rectangle bounds, const char *text, int active) if (active >= itemCount) active = 0; } - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED; - else state = GUI_STATE_FOCUSED; + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED; + else state = STATE_FOCUSED; } } //-------------------------------------------------------------------- @@ -1816,7 +1867,7 @@ int GuiComboBox(Rectangle bounds, const char *text, int active) int tempBorderWidth = GuiGetStyle(BUTTON, BORDER_WIDTH); int tempTextAlign = GuiGetStyle(BUTTON, TEXT_ALIGNMENT); GuiSetStyle(BUTTON, BORDER_WIDTH, 1); - GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); + GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); GuiButton(selector, TextFormat("%i/%i", active + 1, itemCount)); @@ -1831,7 +1882,7 @@ int GuiComboBox(Rectangle bounds, const char *text, int active) // NOTE: Returns mouse click bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMode) { - GuiControlState state = guiState; + GuiState state = guiState; int itemSelected = *active; int itemFocused = -1; @@ -1840,7 +1891,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo const char **items = GuiTextSplit(text, &itemCount, NULL); Rectangle boundsOpen = bounds; - boundsOpen.height = (itemCount + 1)*(bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING)); + boundsOpen.height = (itemCount + 1)*(bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING)); Rectangle itemBounds = bounds; @@ -1848,13 +1899,13 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && (editMode || !guiLocked) && (itemCount > 1)) + if ((state != STATE_DISABLED) && (editMode || !guiLocked) && (itemCount > 1)) { Vector2 mousePoint = GetMousePosition(); if (editMode) { - state = GUI_STATE_PRESSED; + state = STATE_PRESSED; // Check if mouse has been pressed or released outside limits if (!CheckCollisionPointRec(mousePoint, boundsOpen)) @@ -1869,7 +1920,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo for (int i = 0; i < itemCount; i++) { // Update item rectangle y position for next item - itemBounds.y += (bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING)); + itemBounds.y += (bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING)); if (CheckCollisionPointRec(mousePoint, itemBounds)) { @@ -1892,9 +1943,9 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { pressed = true; - state = GUI_STATE_PRESSED; + state = STATE_PRESSED; } - else state = GUI_STATE_FOCUSED; + else state = STATE_FOCUSED; } } } @@ -1902,7 +1953,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo // Draw control //-------------------------------------------------------------------- - if (editMode) GuiPanel(boundsOpen); + if (editMode) GuiPanel(boundsOpen, NULL); GuiDrawRectangle(bounds, GuiGetStyle(DROPDOWNBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(DROPDOWNBOX, BORDER + state*3)), guiAlpha), Fade(GetColor(GuiGetStyle(DROPDOWNBOX, BASE + state*3)), guiAlpha)); GuiDrawText(items[itemSelected], GetTextBounds(DEFAULT, bounds), GuiGetStyle(DROPDOWNBOX, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + state*3)), guiAlpha)); @@ -1913,7 +1964,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo for (int i = 0; i < itemCount; i++) { // Update item rectangle y position for next item - itemBounds.y += (bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING)); + itemBounds.y += (bounds.height + GuiGetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING)); if (i == itemSelected) { @@ -1930,12 +1981,12 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo } // Draw arrows (using icon if available) -#if defined(RAYGUI_NO_RICONS) +#if defined(RAYGUI_NO_ICONS) GuiDrawText("v", RAYGUI_CLITERAL(Rectangle){ bounds.x + bounds.width - GuiGetStyle(DROPDOWNBOX, ARROW_PADDING), bounds.y + bounds.height/2 - 2, 10, 10 }, - GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))), guiAlpha)); + TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))), guiAlpha)); #else GuiDrawText("#120#", RAYGUI_CLITERAL(Rectangle){ bounds.x + bounds.width - GuiGetStyle(DROPDOWNBOX, ARROW_PADDING), bounds.y + bounds.height/2 - 6, 10, 10 }, - GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))), guiAlpha)); // RICON_ARROW_DOWN_FILL + TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))), guiAlpha)); // ICON_ARROW_DOWN_FILL #endif //-------------------------------------------------------------------- @@ -1947,7 +1998,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo // NOTE 2: Returns if KEY_ENTER pressed (useful for data validation) bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) { - GuiControlState state = guiState; + GuiState state = guiState; bool pressed = false; Rectangle cursor = { @@ -1957,31 +2008,31 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) (float)GuiGetStyle(DEFAULT, TEXT_SIZE)*2 }; - if (cursor.height > bounds.height) cursor.height = bounds.height - GuiGetStyle(TEXTBOX, BORDER_WIDTH)*2; + if (cursor.height >= bounds.height) cursor.height = bounds.height - GuiGetStyle(TEXTBOX, BORDER_WIDTH)*2; + if (cursor.y < (bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH))) cursor.y = bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH); // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); if (editMode) { - state = GUI_STATE_PRESSED; + state = STATE_PRESSED; int key = GetCharPressed(); // Returns codepoint as Unicode int keyCount = (int)strlen(text); + int byteSize = 0; + const char *textUTF8 = CodepointToUTF8(key, &byteSize); // Only allow keys in range [32..125] - if (keyCount < (textSize - 1)) + if ((keyCount + byteSize) < textSize) { float maxWidth = (bounds.width - (GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING)*2)); if ((GetTextWidth(text) < (maxWidth - GuiGetStyle(DEFAULT, TEXT_SIZE))) && (key >= 32)) { - int byteSize = 0; - const char *textUTF8 = CodepointToUTF8(key, &byteSize); - for (int i = 0; i < byteSize; i++) { text[keyCount] = textUTF8[i]; @@ -1997,9 +2048,8 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) { if (IsKeyPressed(KEY_BACKSPACE)) { - keyCount--; + while ((keyCount > 0) && ((text[--keyCount] & 0xc0) == 0x80)); text[keyCount] = '\0'; - if (keyCount < 0) keyCount = 0; } } @@ -2007,14 +2057,14 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) // Check text alignment to position cursor properly int textAlignment = GuiGetStyle(TEXTBOX, TEXT_ALIGNMENT); - if (textAlignment == GUI_TEXT_ALIGN_CENTER) cursor.x = bounds.x + GetTextWidth(text)/2 + bounds.width/2 + 1; - else if (textAlignment == GUI_TEXT_ALIGN_RIGHT) cursor.x = bounds.x + bounds.width - GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING); + if (textAlignment == TEXT_ALIGN_CENTER) cursor.x = bounds.x + GetTextWidth(text)/2 + bounds.width/2 + 1; + else if (textAlignment == TEXT_ALIGN_RIGHT) cursor.x = bounds.x + bounds.width - GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING); } else { if (CheckCollisionPointRec(mousePoint, bounds)) { - state = GUI_STATE_FOCUSED; + state = STATE_FOCUSED; if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true; } } @@ -2023,11 +2073,11 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) // Draw control //-------------------------------------------------------------------- - if (state == GUI_STATE_PRESSED) + if (state == STATE_PRESSED) { GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_PRESSED)), guiAlpha)); } - else if (state == GUI_STATE_DISABLED) + else if (state == STATE_DISABLED) { GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_DISABLED)), guiAlpha)); } @@ -2045,13 +2095,13 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode) // Spinner control, returns selected value bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode) { - GuiControlState state = guiState; + GuiState state = guiState; bool pressed = false; int tempValue = *value; - Rectangle spinner = { bounds.x + GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_PADDING), bounds.y, - bounds.width - 2*(GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_PADDING)), bounds.height }; + Rectangle spinner = { bounds.x + GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_SPACING), bounds.y, + bounds.width - 2*(GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_SPACING)), bounds.height }; Rectangle leftButtonBound = { (float)bounds.x, (float)bounds.y, (float)GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.height }; Rectangle rightButtonBound = { (float)bounds.x + bounds.width - GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.y, (float)GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.height }; @@ -2062,23 +2112,31 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE); textBounds.x = bounds.x + bounds.width + GuiGetStyle(SPINNER, TEXT_PADDING); textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2; - if (GuiGetStyle(SPINNER, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_LEFT) textBounds.x = bounds.x - textBounds.width - GuiGetStyle(SPINNER, TEXT_PADDING); + if (GuiGetStyle(SPINNER, TEXT_ALIGNMENT) == TEXT_ALIGN_LEFT) textBounds.x = bounds.x - textBounds.width - GuiGetStyle(SPINNER, TEXT_PADDING); } // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); // Check spinner state if (CheckCollisionPointRec(mousePoint, bounds)) { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED; - else state = GUI_STATE_FOCUSED; + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED; + else state = STATE_FOCUSED; } } +#if defined(RAYGUI_NO_ICONS) + if (GuiButton(leftButtonBound, "<")) tempValue--; + if (GuiButton(rightButtonBound, ">")) tempValue++; +#else + if (GuiButton(leftButtonBound, GuiIconText(ICON_ARROW_LEFT_FILL, NULL))) tempValue--; + if (GuiButton(rightButtonBound, GuiIconText(ICON_ARROW_RIGHT_FILL, NULL))) tempValue++; +#endif + if (!editMode) { if (tempValue < minValue) tempValue = minValue; @@ -2096,21 +2154,13 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in int tempBorderWidth = GuiGetStyle(BUTTON, BORDER_WIDTH); int tempTextAlign = GuiGetStyle(BUTTON, TEXT_ALIGNMENT); GuiSetStyle(BUTTON, BORDER_WIDTH, GuiGetStyle(SPINNER, BORDER_WIDTH)); - GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); - -#if defined(RAYGUI_NO_RICONS) - if (GuiButton(leftButtonBound, "<")) tempValue--; - if (GuiButton(rightButtonBound, ">")) tempValue++; -#else - if (GuiButton(leftButtonBound, GuiIconText(RICON_ARROW_LEFT_FILL, NULL))) tempValue--; - if (GuiButton(rightButtonBound, GuiIconText(RICON_ARROW_RIGHT_FILL, NULL))) tempValue++; -#endif + GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlign); GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth); // Draw text label if provided - GuiDrawText(text, textBounds, (GuiGetStyle(SPINNER, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); + GuiDrawText(text, textBounds, (GuiGetStyle(SPINNER, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT)? TEXT_ALIGN_LEFT : TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); //-------------------------------------------------------------------- *value = tempValue; @@ -2121,14 +2171,14 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in // NOTE: Requires static variables: frameCounter bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode) { - #if !defined(VALUEBOX_MAX_CHARS) - #define VALUEBOX_MAX_CHARS 32 + #if !defined(RAYGUI_VALUEBOX_MAX_CHARS) + #define RAYGUI_VALUEBOX_MAX_CHARS 32 #endif - GuiControlState state = guiState; + GuiState state = guiState; bool pressed = false; - char textValue[VALUEBOX_MAX_CHARS + 1] = "\0"; + char textValue[RAYGUI_VALUEBOX_MAX_CHARS + 1] = "\0"; sprintf(textValue, "%i", *value); Rectangle textBounds = { 0 }; @@ -2138,12 +2188,12 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE); textBounds.x = bounds.x + bounds.width + GuiGetStyle(VALUEBOX, TEXT_PADDING); textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2; - if (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_LEFT) textBounds.x = bounds.x - textBounds.width - GuiGetStyle(VALUEBOX, TEXT_PADDING); + if (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_LEFT) textBounds.x = bounds.x - textBounds.width - GuiGetStyle(VALUEBOX, TEXT_PADDING); } // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); @@ -2151,12 +2201,12 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i if (editMode) { - state = GUI_STATE_PRESSED; + state = STATE_PRESSED; int keyCount = (int)strlen(textValue); // Only allow keys in range [48..57] - if (keyCount < VALUEBOX_MAX_CHARS) + if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS) { if (GetTextWidth(textValue) < bounds.width) { @@ -2177,13 +2227,16 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i { keyCount--; textValue[keyCount] = '\0'; - if (keyCount < 0) keyCount = 0; valueHasChanged = true; } } if (valueHasChanged) *value = TextToInteger(textValue); + // NOTE: We are not clamp values until user input finishes + //if (*value > maxValue) *value = maxValue; + //else if (*value < minValue) *value = minValue; + if (IsKeyPressed(KEY_ENTER) || (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) pressed = true; } else @@ -2193,7 +2246,7 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i if (CheckCollisionPointRec(mousePoint, bounds)) { - state = GUI_STATE_FOCUSED; + state = STATE_FOCUSED; if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true; } } @@ -2203,12 +2256,12 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i // Draw control //-------------------------------------------------------------------- Color baseColor = BLANK; - if (state == GUI_STATE_PRESSED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_PRESSED)); - else if (state == GUI_STATE_DISABLED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_DISABLED)); + if (state == STATE_PRESSED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_PRESSED)); + else if (state == STATE_DISABLED) baseColor = GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_DISABLED)); // WARNING: BLANK color does not work properly with Fade() GuiDrawRectangle(bounds, GuiGetStyle(VALUEBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER + (state*3))), guiAlpha), baseColor); - GuiDrawText(textValue, GetTextBounds(VALUEBOX, bounds), GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(VALUEBOX, TEXT + (state*3))), guiAlpha)); + GuiDrawText(textValue, GetTextBounds(VALUEBOX, bounds), TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(VALUEBOX, TEXT + (state*3))), guiAlpha)); // Draw cursor if (editMode) @@ -2219,7 +2272,7 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i } // Draw text label if provided - GuiDrawText(text, textBounds, (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT)? GUI_TEXT_ALIGN_LEFT : GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); + GuiDrawText(text, textBounds, (GuiGetStyle(VALUEBOX, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT)? TEXT_ALIGN_LEFT : TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(LABEL, TEXT + (state*3))), guiAlpha)); //-------------------------------------------------------------------- return pressed; @@ -2228,7 +2281,7 @@ bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, i // Text Box control with multiple lines bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) { - GuiControlState state = guiState; + GuiState state = guiState; bool pressed = false; Rectangle textAreaBounds = { @@ -2245,13 +2298,13 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); if (editMode) { - state = GUI_STATE_PRESSED; + state = STATE_PRESSED; // We get an Unicode codepoint int codepoint = GetCharPressed(); @@ -2305,7 +2358,7 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) { if (CheckCollisionPointRec(mousePoint, bounds)) { - state = GUI_STATE_FOCUSED; + state = STATE_FOCUSED; if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true; } } @@ -2314,11 +2367,11 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) // Draw control //-------------------------------------------------------------------- - if (state == GUI_STATE_PRESSED) + if (state == STATE_PRESSED) { GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_PRESSED)), guiAlpha)); } - else if (state == GUI_STATE_DISABLED) + else if (state == STATE_DISABLED) { GuiDrawRectangle(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_DISABLED)), guiAlpha)); } @@ -2340,7 +2393,7 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) if ((codepointLength == 1) && (codepoint == '\n')) { - cursorPos.y += (guiFont.baseSize*scaleFactor + GuiGetStyle(TEXTBOX, TEXT_LINES_PADDING)); // Line feed + cursorPos.y += (guiFont.baseSize*scaleFactor + GuiGetStyle(TEXTBOX, TEXT_LINES_SPACING)); // Line feed cursorPos.x = textAreaBounds.x; // Carriage return } else @@ -2349,12 +2402,12 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) { int glyphWidth = 0; if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX; - else glyphWidth += (atlasRec.width + glyphInfo.offsetX); + else glyphWidth += (int)(atlasRec.width + glyphInfo.offsetX); // Jump line if the end of the text box area has been reached if ((cursorPos.x + (glyphWidth*scaleFactor)) > (textAreaBounds.x + textAreaBounds.width)) { - cursorPos.y += (guiFont.baseSize*scaleFactor + GuiGetStyle(TEXTBOX, TEXT_LINES_PADDING)); // Line feed + cursorPos.y += (guiFont.baseSize*scaleFactor + GuiGetStyle(TEXTBOX, TEXT_LINES_SPACING)); // Line feed cursorPos.x = textAreaBounds.x; // Carriage return } } @@ -2382,7 +2435,7 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) int glyphWidth = 0; if (glyphInfo.advanceX != 0) glyphWidth += glyphInfo.advanceX; - else glyphWidth += (atlasRec.width + glyphInfo.offsetX); + else glyphWidth += (int)(atlasRec.width + glyphInfo.offsetX); cursorPos.x += (glyphWidth*scaleFactor + (float)GuiGetStyle(DEFAULT, TEXT_SPACING)); //if (i > lastSpacePos) lastSpaceWidth += (atlasRec.width + (float)GuiGetStyle(DEFAULT, TEXT_SPACING)); @@ -2403,7 +2456,7 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode) // NOTE: Other GuiSlider*() controls use this one float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue, int sliderWidth) { - GuiControlState state = guiState; + GuiState state = guiState; int sliderValue = (int)(((value - minValue)/(maxValue - minValue))*(bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH))); @@ -2423,7 +2476,7 @@ float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); @@ -2431,7 +2484,7 @@ float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight { if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) { - state = GUI_STATE_PRESSED; + state = STATE_PRESSED; // Get equivalent value and slider position from mousePoint.x value = ((maxValue - minValue)*(mousePoint.x - (float)(bounds.x + sliderWidth/2)))/(float)(bounds.width - sliderWidth) + minValue; @@ -2439,7 +2492,7 @@ float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight if (sliderWidth > 0) slider.x = mousePoint.x - slider.width/2; // Slider else if (sliderWidth == 0) slider.width = (float)sliderValue; // SliderBar } - else state = GUI_STATE_FOCUSED; + else state = STATE_FOCUSED; } if (value > maxValue) value = maxValue; @@ -2460,11 +2513,11 @@ float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight // Draw control //-------------------------------------------------------------------- - GuiDrawRectangle(bounds, GuiGetStyle(SLIDER, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(SLIDER, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(SLIDER, (state != GUI_STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)), guiAlpha)); + GuiDrawRectangle(bounds, GuiGetStyle(SLIDER, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(SLIDER, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(SLIDER, (state != STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)), guiAlpha)); // Draw slider internal bar (depends on state) - if ((state == GUI_STATE_NORMAL) || (state == GUI_STATE_PRESSED)) GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, BASE_COLOR_PRESSED)), guiAlpha)); - else if (state == GUI_STATE_FOCUSED) GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, TEXT_COLOR_FOCUSED)), guiAlpha)); + if ((state == STATE_NORMAL) || (state == STATE_PRESSED)) GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, BASE_COLOR_PRESSED)), guiAlpha)); + else if (state == STATE_FOCUSED) GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, TEXT_COLOR_FOCUSED)), guiAlpha)); // Draw left/right text if provided if (textLeft != NULL) @@ -2475,7 +2528,7 @@ float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight textBounds.x = bounds.x - textBounds.width - GuiGetStyle(SLIDER, TEXT_PADDING); textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2; - GuiDrawText(textLeft, textBounds, GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(SLIDER, TEXT + (state*3))), guiAlpha)); + GuiDrawText(textLeft, textBounds, TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(SLIDER, TEXT + (state*3))), guiAlpha)); } if (textRight != NULL) @@ -2486,7 +2539,7 @@ float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight textBounds.x = bounds.x + bounds.width + GuiGetStyle(SLIDER, TEXT_PADDING); textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2; - GuiDrawText(textRight, textBounds, GUI_TEXT_ALIGN_LEFT, Fade(GetColor(GuiGetStyle(SLIDER, TEXT + (state*3))), guiAlpha)); + GuiDrawText(textRight, textBounds, TEXT_ALIGN_LEFT, Fade(GetColor(GuiGetStyle(SLIDER, TEXT + (state*3))), guiAlpha)); } //-------------------------------------------------------------------- @@ -2508,7 +2561,7 @@ float GuiSliderBar(Rectangle bounds, const char *textLeft, const char *textRight // Progress Bar control extended, shows current progress value float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue) { - GuiControlState state = guiState; + GuiState state = guiState; Rectangle progress = { bounds.x + GuiGetStyle(PROGRESSBAR, BORDER_WIDTH), bounds.y + GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) + GuiGetStyle(PROGRESSBAR, PROGRESS_PADDING), 0, @@ -2516,7 +2569,9 @@ float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRig // Update control //-------------------------------------------------------------------- - if (state != GUI_STATE_DISABLED) progress.width = ((float)(value/(maxValue - minValue))*(float)(bounds.width - 2*GuiGetStyle(PROGRESSBAR, BORDER_WIDTH))); + if (value > maxValue) value = maxValue; + + if (state != STATE_DISABLED) progress.width = ((float)(value/(maxValue - minValue))*(float)(bounds.width - 2*GuiGetStyle(PROGRESSBAR, BORDER_WIDTH))); //-------------------------------------------------------------------- // Draw control @@ -2524,8 +2579,8 @@ float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRig GuiDrawRectangle(bounds, GuiGetStyle(PROGRESSBAR, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(PROGRESSBAR, BORDER + (state*3))), guiAlpha), BLANK); // Draw slider internal progress bar (depends on state) - if ((state == GUI_STATE_NORMAL) || (state == GUI_STATE_PRESSED)) GuiDrawRectangle(progress, 0, BLANK, Fade(GetColor(GuiGetStyle(PROGRESSBAR, BASE_COLOR_PRESSED)), guiAlpha)); - else if (state == GUI_STATE_FOCUSED) GuiDrawRectangle(progress, 0, BLANK, Fade(GetColor(GuiGetStyle(PROGRESSBAR, TEXT_COLOR_FOCUSED)), guiAlpha)); + if ((state == STATE_NORMAL) || (state == STATE_PRESSED)) GuiDrawRectangle(progress, 0, BLANK, Fade(GetColor(GuiGetStyle(PROGRESSBAR, BASE_COLOR_PRESSED)), guiAlpha)); + else if (state == STATE_FOCUSED) GuiDrawRectangle(progress, 0, BLANK, Fade(GetColor(GuiGetStyle(PROGRESSBAR, TEXT_COLOR_FOCUSED)), guiAlpha)); // Draw left/right text if provided if (textLeft != NULL) @@ -2536,7 +2591,7 @@ float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRig textBounds.x = bounds.x - textBounds.width - GuiGetStyle(PROGRESSBAR, TEXT_PADDING); textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2; - GuiDrawText(textLeft, textBounds, GUI_TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(PROGRESSBAR, TEXT + (state*3))), guiAlpha)); + GuiDrawText(textLeft, textBounds, TEXT_ALIGN_RIGHT, Fade(GetColor(GuiGetStyle(PROGRESSBAR, TEXT + (state*3))), guiAlpha)); } if (textRight != NULL) @@ -2547,7 +2602,7 @@ float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRig textBounds.x = bounds.x + bounds.width + GuiGetStyle(PROGRESSBAR, TEXT_PADDING); textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2; - GuiDrawText(textRight, textBounds, GUI_TEXT_ALIGN_LEFT, Fade(GetColor(GuiGetStyle(PROGRESSBAR, TEXT + (state*3))), guiAlpha)); + GuiDrawText(textRight, textBounds, TEXT_ALIGN_LEFT, Fade(GetColor(GuiGetStyle(PROGRESSBAR, TEXT + (state*3))), guiAlpha)); } //-------------------------------------------------------------------- @@ -2557,158 +2612,43 @@ float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRig // Status Bar control void GuiStatusBar(Rectangle bounds, const char *text) { - GuiControlState state = guiState; + GuiState state = guiState; // Draw control //-------------------------------------------------------------------- - GuiDrawRectangle(bounds, GuiGetStyle(STATUSBAR, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(STATUSBAR, (state != GUI_STATE_DISABLED)? BORDER_COLOR_NORMAL : BORDER_COLOR_DISABLED)), guiAlpha), - Fade(GetColor(GuiGetStyle(STATUSBAR, (state != GUI_STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)), guiAlpha)); - GuiDrawText(text, GetTextBounds(STATUSBAR, bounds), GuiGetStyle(STATUSBAR, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(STATUSBAR, (state != GUI_STATE_DISABLED)? TEXT_COLOR_NORMAL : TEXT_COLOR_DISABLED)), guiAlpha)); + GuiDrawRectangle(bounds, GuiGetStyle(STATUSBAR, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(STATUSBAR, (state != STATE_DISABLED)? BORDER_COLOR_NORMAL : BORDER_COLOR_DISABLED)), guiAlpha), + Fade(GetColor(GuiGetStyle(STATUSBAR, (state != STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)), guiAlpha)); + GuiDrawText(text, GetTextBounds(STATUSBAR, bounds), GuiGetStyle(STATUSBAR, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(STATUSBAR, (state != STATE_DISABLED)? TEXT_COLOR_NORMAL : TEXT_COLOR_DISABLED)), guiAlpha)); //-------------------------------------------------------------------- } // Dummy rectangle control, intended for placeholding void GuiDummyRec(Rectangle bounds, const char *text) { - GuiControlState state = guiState; + GuiState state = guiState; // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); // Check button state if (CheckCollisionPointRec(mousePoint, bounds)) { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED; - else state = GUI_STATE_FOCUSED; + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED; + else state = STATE_FOCUSED; } } //-------------------------------------------------------------------- // Draw control //-------------------------------------------------------------------- - GuiDrawRectangle(bounds, 0, BLANK, Fade(GetColor(GuiGetStyle(DEFAULT, (state != GUI_STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)), guiAlpha)); - GuiDrawText(text, GetTextBounds(DEFAULT, bounds), GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(BUTTON, (state != GUI_STATE_DISABLED)? TEXT_COLOR_NORMAL : TEXT_COLOR_DISABLED)), guiAlpha)); + GuiDrawRectangle(bounds, 0, BLANK, Fade(GetColor(GuiGetStyle(DEFAULT, (state != STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)), guiAlpha)); + GuiDrawText(text, GetTextBounds(DEFAULT, bounds), TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(BUTTON, (state != STATE_DISABLED)? TEXT_COLOR_NORMAL : TEXT_COLOR_DISABLED)), guiAlpha)); //------------------------------------------------------------------ } -// Scroll Bar control -int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue) -{ - GuiControlState state = guiState; - - // Is the scrollbar horizontal or vertical? - bool isVertical = (bounds.width > bounds.height)? false : true; - - // The size (width or height depending on scrollbar type) of the spinner buttons - const int spinnerSize = GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE)? (isVertical? (int)bounds.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) : (int)bounds.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH)) : 0; - - // Arrow buttons [<] [>] [∧] [∨] - Rectangle arrowUpLeft = { 0 }; - Rectangle arrowDownRight = { 0 }; - - // Actual area of the scrollbar excluding the arrow buttons - Rectangle scrollbar = { 0 }; - - // Slider bar that moves --[///]----- - Rectangle slider = { 0 }; - - // Normalize value - if (value > maxValue) value = maxValue; - if (value < minValue) value = minValue; - - const int range = maxValue - minValue; - int sliderSize = GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE); - - // Calculate rectangles for all of the components - arrowUpLeft = RAYGUI_CLITERAL(Rectangle){ (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (float)spinnerSize }; - - if (isVertical) - { - arrowDownRight = RAYGUI_CLITERAL(Rectangle){ (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + bounds.height - spinnerSize - GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (float)spinnerSize}; - scrollbar = RAYGUI_CLITERAL(Rectangle){ bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING), arrowUpLeft.y + arrowUpLeft.height, bounds.width - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING)), bounds.height - arrowUpLeft.height - arrowDownRight.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) }; - sliderSize = (sliderSize >= scrollbar.height)? ((int)scrollbar.height - 2) : sliderSize; // Make sure the slider won't get outside of the scrollbar - slider = RAYGUI_CLITERAL(Rectangle){ (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING), (float)scrollbar.y + (int)(((float)(value - minValue)/range)*(scrollbar.height - sliderSize)), (float)bounds.width - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING)), (float)sliderSize }; - } - else - { - arrowDownRight = RAYGUI_CLITERAL(Rectangle){ (float)bounds.x + bounds.width - spinnerSize - GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (float)spinnerSize}; - scrollbar = RAYGUI_CLITERAL(Rectangle){ arrowUpLeft.x + arrowUpLeft.width, bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING), bounds.width - arrowUpLeft.width - arrowDownRight.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH), bounds.height - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING))}; - sliderSize = (sliderSize >= scrollbar.width)? ((int)scrollbar.width - 2) : sliderSize; // Make sure the slider won't get outside of the scrollbar - slider = RAYGUI_CLITERAL(Rectangle){ (float)scrollbar.x + (int)(((float)(value - minValue)/range)*(scrollbar.width - sliderSize)), (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING), (float)sliderSize, (float)bounds.height - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING)) }; - } - - // Update control - //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) - { - Vector2 mousePoint = GetMousePosition(); - - if (CheckCollisionPointRec(mousePoint, bounds)) - { - state = GUI_STATE_FOCUSED; - - // Handle mouse wheel - int wheel = (int)GetMouseWheelMove(); - if (wheel != 0) value += wheel; - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - if (CheckCollisionPointRec(mousePoint, arrowUpLeft)) value -= range/GuiGetStyle(SCROLLBAR, SCROLL_SPEED); - else if (CheckCollisionPointRec(mousePoint, arrowDownRight)) value += range/GuiGetStyle(SCROLLBAR, SCROLL_SPEED); - - state = GUI_STATE_PRESSED; - } - else if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) - { - if (!isVertical) - { - Rectangle scrollArea = { arrowUpLeft.x + arrowUpLeft.width, arrowUpLeft.y, scrollbar.width, bounds.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH)}; - if (CheckCollisionPointRec(mousePoint, scrollArea)) value = (int)(((float)(mousePoint.x - scrollArea.x - slider.width/2)*range)/(scrollArea.width - slider.width) + minValue); - } - else - { - Rectangle scrollArea = { arrowUpLeft.x, arrowUpLeft.y+arrowUpLeft.height, bounds.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH), scrollbar.height}; - if (CheckCollisionPointRec(mousePoint, scrollArea)) value = (int)(((float)(mousePoint.y - scrollArea.y - slider.height/2)*range)/(scrollArea.height - slider.height) + minValue); - } - } - } - - // Normalize value - if (value > maxValue) value = maxValue; - if (value < minValue) value = minValue; - } - //-------------------------------------------------------------------- - - // Draw control - //-------------------------------------------------------------------- - GuiDrawRectangle(bounds, GuiGetStyle(SCROLLBAR, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(LISTVIEW, BORDER + state*3)), guiAlpha), Fade(GetColor(GuiGetStyle(DEFAULT, BORDER_COLOR_DISABLED)), guiAlpha)); // Draw the background - - GuiDrawRectangle(scrollbar, 0, BLANK, Fade(GetColor(GuiGetStyle(BUTTON, BASE_COLOR_NORMAL)), guiAlpha)); // Draw the scrollbar active area background - GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, BORDER + state*3)), guiAlpha)); // Draw the slider bar - - // Draw arrows (using icon if available) - if (GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE)) - { -#if defined(RAYGUI_NO_RICONS) - GuiDrawText(isVertical? "^" : "<", RAYGUI_CLITERAL(Rectangle){ arrowUpLeft.x, arrowUpLeft.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height }, - GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))), guiAlpha)); - GuiDrawText(isVertical? "v" : ">", RAYGUI_CLITERAL(Rectangle){ arrowDownRight.x, arrowDownRight.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height }, - GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))), guiAlpha)); -#else - GuiDrawText(isVertical? "#121#" : "#118#", RAYGUI_CLITERAL(Rectangle){ arrowUpLeft.x, arrowUpLeft.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height }, - GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(SCROLLBAR, TEXT + state*3)), guiAlpha)); // RICON_ARROW_UP_FILL / RICON_ARROW_LEFT_FILL - GuiDrawText(isVertical? "#120#" : "#119#", RAYGUI_CLITERAL(Rectangle){ arrowDownRight.x, arrowDownRight.y, isVertical? bounds.width : bounds.height, isVertical? bounds.width : bounds.height }, - GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(SCROLLBAR, TEXT + state*3)), guiAlpha)); // RICON_ARROW_DOWN_FILL / RICON_ARROW_RIGHT_FILL -#endif - } - //-------------------------------------------------------------------- - - return value; -} - // List View control int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active) { @@ -2723,24 +2663,24 @@ int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active // List View control with extended parameters int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active) { - GuiControlState state = guiState; + GuiState state = guiState; int itemFocused = (focus == NULL)? -1 : *focus; int itemSelected = active; // Check if we need a scroll bar bool useScrollBar = false; - if ((GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING))*count > bounds.height) useScrollBar = true; + if ((GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING))*count > bounds.height) useScrollBar = true; // Define base item rectangle [0] Rectangle itemBounds = { 0 }; - itemBounds.x = bounds.x + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING); - itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH); - itemBounds.width = bounds.width - 2*GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) - GuiGetStyle(DEFAULT, BORDER_WIDTH); + itemBounds.x = bounds.x + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING); + itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING) + GuiGetStyle(DEFAULT, BORDER_WIDTH); + itemBounds.width = bounds.width - 2*GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING) - GuiGetStyle(DEFAULT, BORDER_WIDTH); itemBounds.height = (float)GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT); if (useScrollBar) itemBounds.width -= GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH); // Get items on the list - int visibleItems = (int)bounds.height/(GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING)); + int visibleItems = (int)bounds.height/(GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING)); if (visibleItems > count) visibleItems = count; int startIndex = (scrollIndex == NULL)? 0 : *scrollIndex; @@ -2749,14 +2689,14 @@ int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, in // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); // Check mouse inside list view if (CheckCollisionPointRec(mousePoint, bounds)) { - state = GUI_STATE_FOCUSED; + state = STATE_FOCUSED; // Check focused and selected item for (int i = 0; i < visibleItems; i++) @@ -2773,7 +2713,7 @@ int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, in } // Update item rectangle y position for next item - itemBounds.y += (GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING)); + itemBounds.y += (GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING)); } if (useScrollBar) @@ -2791,7 +2731,7 @@ int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, in else itemFocused = -1; // Reset item rectangle y to [0] - itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH); + itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING) + GuiGetStyle(DEFAULT, BORDER_WIDTH); } //-------------------------------------------------------------------- @@ -2802,7 +2742,7 @@ int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, in // Draw visible items for (int i = 0; ((i < visibleItems) && (text != NULL)); i++) { - if (state == GUI_STATE_DISABLED) + if (state == STATE_DISABLED) { if ((startIndex + i) == itemSelected) GuiDrawRectangle(itemBounds, GuiGetStyle(LISTVIEW, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(LISTVIEW, BORDER_COLOR_DISABLED)), guiAlpha), Fade(GetColor(GuiGetStyle(LISTVIEW, BASE_COLOR_DISABLED)), guiAlpha)); @@ -2830,7 +2770,7 @@ int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, in } // Update item rectangle y position for next item - itemBounds.y += (GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING)); + itemBounds.y += (GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_SPACING)); } if (useScrollBar) @@ -2864,12 +2804,12 @@ int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, in } // Color Panel control -Color GuiColorPanel(Rectangle bounds, Color color) +Color GuiColorPanel(Rectangle bounds, const char *text, Color color) { const Color colWhite = { 255, 255, 255, 255 }; const Color colBlack = { 0, 0, 0, 255 }; - GuiControlState state = guiState; + GuiState state = guiState; Vector2 pickerSelector = { 0 }; Vector3 vcolor = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f }; @@ -2887,7 +2827,7 @@ Color GuiColorPanel(Rectangle bounds, Color color) // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); @@ -2895,7 +2835,7 @@ Color GuiColorPanel(Rectangle bounds, Color color) { if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) { - state = GUI_STATE_PRESSED; + state = STATE_PRESSED; pickerSelector = mousePoint; // Calculate color from picker @@ -2916,14 +2856,14 @@ Color GuiColorPanel(Rectangle bounds, Color color) (unsigned char)(255.0f*(float)color.a/255.0f) }; } - else state = GUI_STATE_FOCUSED; + else state = STATE_FOCUSED; } } //-------------------------------------------------------------------- // Draw control //-------------------------------------------------------------------- - if (state != GUI_STATE_DISABLED) + if (state != STATE_DISABLED) { DrawRectangleGradientEx(bounds, Fade(colWhite, guiAlpha), Fade(colWhite, guiAlpha), Fade(maxHueCol, guiAlpha), Fade(maxHueCol, guiAlpha)); DrawRectangleGradientEx(bounds, Fade(colBlack, 0), Fade(colBlack, guiAlpha), Fade(colBlack, guiAlpha), Fade(colBlack, 0)); @@ -2945,16 +2885,18 @@ Color GuiColorPanel(Rectangle bounds, Color color) // Color Bar Alpha control // NOTE: Returns alpha value normalized [0..1] -float GuiColorBarAlpha(Rectangle bounds, float alpha) +float GuiColorBarAlpha(Rectangle bounds, const char *text, float alpha) { - #define COLORBARALPHA_CHECKED_SIZE 10 + #if !defined(RAYGUI_COLORBARALPHA_CHECKED_SIZE) + #define RAYGUI_COLORBARALPHA_CHECKED_SIZE 10 + #endif - GuiControlState state = guiState; + GuiState state = guiState; Rectangle selector = { (float)bounds.x + alpha*bounds.width - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT)/2, (float)bounds.y - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW), (float)GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT), (float)bounds.height + GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW)*2 }; // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); @@ -2963,14 +2905,14 @@ float GuiColorBarAlpha(Rectangle bounds, float alpha) { if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) { - state = GUI_STATE_PRESSED; + state = STATE_PRESSED; alpha = (mousePoint.x - bounds.x)/bounds.width; if (alpha <= 0.0f) alpha = 0.0f; if (alpha >= 1.0f) alpha = 1.0f; //selector.x = bounds.x + (int)(((alpha - 0)/(100 - 0))*(bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH))) - selector.width/2; } - else state = GUI_STATE_FOCUSED; + else state = STATE_FOCUSED; } } //-------------------------------------------------------------------- @@ -2979,16 +2921,16 @@ float GuiColorBarAlpha(Rectangle bounds, float alpha) //-------------------------------------------------------------------- // Draw alpha bar: checked background - if (state != GUI_STATE_DISABLED) + if (state != STATE_DISABLED) { - int checksX = (int)bounds.width/COLORBARALPHA_CHECKED_SIZE; - int checksY = (int)bounds.height/COLORBARALPHA_CHECKED_SIZE; + int checksX = (int)bounds.width/RAYGUI_COLORBARALPHA_CHECKED_SIZE; + int checksY = (int)bounds.height/RAYGUI_COLORBARALPHA_CHECKED_SIZE; for (int x = 0; x < checksX; x++) { for (int y = 0; y < checksY; y++) { - Rectangle check = { bounds.x + x*COLORBARALPHA_CHECKED_SIZE, bounds.y + y*COLORBARALPHA_CHECKED_SIZE, COLORBARALPHA_CHECKED_SIZE, COLORBARALPHA_CHECKED_SIZE }; + Rectangle check = { bounds.x + x*RAYGUI_COLORBARALPHA_CHECKED_SIZE, bounds.y + y*RAYGUI_COLORBARALPHA_CHECKED_SIZE, RAYGUI_COLORBARALPHA_CHECKED_SIZE, RAYGUI_COLORBARALPHA_CHECKED_SIZE }; GuiDrawRectangle(check, 0, BLANK, ((x + y)%2)? Fade(Fade(GetColor(GuiGetStyle(COLORPICKER, BORDER_COLOR_DISABLED)), 0.4f), guiAlpha) : Fade(Fade(GetColor(GuiGetStyle(COLORPICKER, BASE_COLOR_DISABLED)), 0.4f), guiAlpha)); } } @@ -3012,14 +2954,14 @@ float GuiColorBarAlpha(Rectangle bounds, float alpha) // Color GuiColorBarSat() [WHITE->color] // Color GuiColorBarValue() [BLACK->color], HSV/HSL // float GuiColorBarLuminance() [BLACK->WHITE] -float GuiColorBarHue(Rectangle bounds, float hue) +float GuiColorBarHue(Rectangle bounds, const char *text, float hue) { - GuiControlState state = guiState; + GuiState state = guiState; Rectangle selector = { (float)bounds.x - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW), (float)bounds.y + hue/360.0f*bounds.height - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT)/2, (float)bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW)*2, (float)GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT) }; // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { Vector2 mousePoint = GetMousePosition(); @@ -3028,14 +2970,14 @@ float GuiColorBarHue(Rectangle bounds, float hue) { if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) { - state = GUI_STATE_PRESSED; + state = STATE_PRESSED; hue = (mousePoint.y - bounds.y)*360/bounds.height; if (hue <= 0.0f) hue = 0.0f; if (hue >= 359.0f) hue = 359.0f; } - else state = GUI_STATE_FOCUSED; + else state = STATE_FOCUSED; /*if (IsKeyDown(KEY_UP)) { @@ -3053,14 +2995,14 @@ float GuiColorBarHue(Rectangle bounds, float hue) // Draw control //-------------------------------------------------------------------- - if (state != GUI_STATE_DISABLED) + if (state != STATE_DISABLED) { // Draw hue bar:color bars - DrawRectangleGradientV((int)bounds.x, (int)(bounds.y), (int)bounds.width, ceil(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 255, 0, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 255, 255, 0, 255 }, guiAlpha)); - DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + bounds.height/6), (int)bounds.width, ceil(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 255, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 0, 255 }, guiAlpha)); - DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 2*(bounds.height/6)), (int)bounds.width, ceil(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 255, 255 }, guiAlpha)); - DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 3*(bounds.height/6)), (int)bounds.width, ceil(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 0, 0, 255, 255 }, guiAlpha)); - DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 4*(bounds.height/6)), (int)bounds.width, ceil(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 0, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 255, 0, 255, 255 }, guiAlpha)); + DrawRectangleGradientV((int)bounds.x, (int)(bounds.y), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 255, 0, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 255, 255, 0, 255 }, guiAlpha)); + DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + bounds.height/6), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 255, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 0, 255 }, guiAlpha)); + DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 2*(bounds.height/6)), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 0, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 255, 255 }, guiAlpha)); + DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 3*(bounds.height/6)), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 0, 255, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 0, 0, 255, 255 }, guiAlpha)); + DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 4*(bounds.height/6)), (int)bounds.width, (int)ceilf(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 0, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 255, 0, 255, 255 }, guiAlpha)); DrawRectangleGradientV((int)bounds.x, (int)(bounds.y + 5*(bounds.height/6)), (int)bounds.width, (int)(bounds.height/6), Fade(RAYGUI_CLITERAL(Color) { 255, 0, 255, 255 }, guiAlpha), Fade(RAYGUI_CLITERAL(Color) { 255, 0, 0, 255 }, guiAlpha)); } else DrawRectangleGradientV((int)bounds.x, (int)bounds.y, (int)bounds.width, (int)bounds.height, Fade(Fade(GetColor(GuiGetStyle(COLORPICKER, BASE_COLOR_DISABLED)), 0.1f), guiAlpha), Fade(GetColor(GuiGetStyle(COLORPICKER, BORDER_COLOR_DISABLED)), guiAlpha)); @@ -3080,15 +3022,15 @@ float GuiColorBarHue(Rectangle bounds, float hue) // float GuiColorBarAlpha(Rectangle bounds, float alpha) // float GuiColorBarHue(Rectangle bounds, float value) // NOTE: bounds define GuiColorPanel() size -Color GuiColorPicker(Rectangle bounds, Color color) +Color GuiColorPicker(Rectangle bounds, const char *text, Color color) { - color = GuiColorPanel(bounds, color); + color = GuiColorPanel(bounds, NULL, color); Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height }; //Rectangle boundsAlpha = { bounds.x, bounds.y + bounds.height + GuiGetStyle(COLORPICKER, BARS_PADDING), bounds.width, GuiGetStyle(COLORPICKER, BARS_THICK) }; Vector3 hsv = ConvertRGBtoHSV(RAYGUI_CLITERAL(Vector3){ color.r/255.0f, color.g/255.0f, color.b/255.0f }); - hsv.x = GuiColorBarHue(boundsHue, hsv.x); + hsv.x = GuiColorBarHue(boundsHue, NULL, hsv.x); //color.a = (unsigned char)(GuiColorBarAlpha(boundsAlpha, (float)color.a/255.0f)*255.0f); Vector3 rgb = ConvertHSVtoRGB(hsv); @@ -3100,43 +3042,47 @@ Color GuiColorPicker(Rectangle bounds, Color color) // Message Box control int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons) { - #define MESSAGEBOX_BUTTON_HEIGHT 24 - #define MESSAGEBOX_BUTTON_PADDING 10 + #if !defined(RAYGUI_MESSAGEBOX_BUTTON_HEIGHT) + #define RAYGUI_MESSAGEBOX_BUTTON_HEIGHT 24 + #endif + #if !defined(RAYGUI_MESSAGEBOX_BUTTON_PADDING) + #define RAYGUI_MESSAGEBOX_BUTTON_PADDING 12 + #endif int clicked = -1; // Returns clicked button from buttons list, 0 refers to closed window button int buttonCount = 0; const char **buttonsText = GuiTextSplit(buttons, &buttonCount, NULL); Rectangle buttonBounds = { 0 }; - buttonBounds.x = bounds.x + MESSAGEBOX_BUTTON_PADDING; - buttonBounds.y = bounds.y + bounds.height - MESSAGEBOX_BUTTON_HEIGHT - MESSAGEBOX_BUTTON_PADDING; - buttonBounds.width = (bounds.width - MESSAGEBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount; - buttonBounds.height = MESSAGEBOX_BUTTON_HEIGHT; + buttonBounds.x = bounds.x + RAYGUI_MESSAGEBOX_BUTTON_PADDING; + buttonBounds.y = bounds.y + bounds.height - RAYGUI_MESSAGEBOX_BUTTON_HEIGHT - RAYGUI_MESSAGEBOX_BUTTON_PADDING; + buttonBounds.width = (bounds.width - RAYGUI_MESSAGEBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount; + buttonBounds.height = RAYGUI_MESSAGEBOX_BUTTON_HEIGHT; Vector2 textSize = MeasureTextEx(guiFont, message, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), 1); Rectangle textBounds = { 0 }; textBounds.x = bounds.x + bounds.width/2 - textSize.x/2; - textBounds.y = bounds.y + WINDOW_STATUSBAR_HEIGHT + (bounds.height - WINDOW_STATUSBAR_HEIGHT - MESSAGEBOX_BUTTON_HEIGHT - MESSAGEBOX_BUTTON_PADDING)/2 - textSize.y/2; + textBounds.y = bounds.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + RAYGUI_MESSAGEBOX_BUTTON_PADDING; textBounds.width = textSize.x; - textBounds.height = textSize.y; + textBounds.height = bounds.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - 3*RAYGUI_MESSAGEBOX_BUTTON_PADDING - RAYGUI_MESSAGEBOX_BUTTON_HEIGHT; // Draw control //-------------------------------------------------------------------- if (GuiWindowBox(bounds, title)) clicked = 0; int prevTextAlignment = GuiGetStyle(LABEL, TEXT_ALIGNMENT); - GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); + GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); GuiLabel(textBounds, message); GuiSetStyle(LABEL, TEXT_ALIGNMENT, prevTextAlignment); prevTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT); - GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); + GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); for (int i = 0; i < buttonCount; i++) { if (GuiButton(buttonBounds, buttonsText[i])) clicked = i + 1; - buttonBounds.x += (buttonBounds.width + MESSAGEBOX_BUTTON_PADDING); + buttonBounds.x += (buttonBounds.width + RAYGUI_MESSAGEBOX_BUTTON_PADDING); } GuiSetStyle(BUTTON, TEXT_ALIGNMENT, prevTextAlignment); @@ -3146,13 +3092,17 @@ int GuiMessageBox(Rectangle bounds, const char *title, const char *message, cons } // Text Input Box control, ask for text -int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text) +int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text, int textMaxSize, int *secretViewActive) { - #define TEXTINPUTBOX_BUTTON_HEIGHT 24 - #define TEXTINPUTBOX_BUTTON_PADDING 10 - #define TEXTINPUTBOX_HEIGHT 30 - - #define TEXTINPUTBOX_MAX_TEXT_LENGTH 256 + #if !defined(RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT) + #define RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT 28 + #endif + #if !defined(RAYGUI_TEXTINPUTBOX_BUTTON_PADDING) + #define RAYGUI_TEXTINPUTBOX_BUTTON_PADDING 12 + #endif + #if !defined(RAYGUI_TEXTINPUTBOX_HEIGHT) + #define RAYGUI_TEXTINPUTBOX_HEIGHT 28 + #endif // Used to enable text edit mode // WARNING: No more than one GuiTextInputBox() should be open at the same time @@ -3163,12 +3113,12 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co int buttonCount = 0; const char **buttonsText = GuiTextSplit(buttons, &buttonCount, NULL); Rectangle buttonBounds = { 0 }; - buttonBounds.x = bounds.x + TEXTINPUTBOX_BUTTON_PADDING; - buttonBounds.y = bounds.y + bounds.height - TEXTINPUTBOX_BUTTON_HEIGHT - TEXTINPUTBOX_BUTTON_PADDING; - buttonBounds.width = (bounds.width - TEXTINPUTBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount; - buttonBounds.height = TEXTINPUTBOX_BUTTON_HEIGHT; + buttonBounds.x = bounds.x + RAYGUI_TEXTINPUTBOX_BUTTON_PADDING; + buttonBounds.y = bounds.y + bounds.height - RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT - RAYGUI_TEXTINPUTBOX_BUTTON_PADDING; + buttonBounds.width = (bounds.width - RAYGUI_TEXTINPUTBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount; + buttonBounds.height = RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT; - int messageInputHeight = (int)bounds.height - WINDOW_STATUSBAR_HEIGHT - GuiGetStyle(STATUSBAR, BORDER_WIDTH) - TEXTINPUTBOX_BUTTON_HEIGHT - 2*TEXTINPUTBOX_BUTTON_PADDING; + int messageInputHeight = (int)bounds.height - RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - GuiGetStyle(STATUSBAR, BORDER_WIDTH) - RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT - 2*RAYGUI_TEXTINPUTBOX_BUTTON_PADDING; Rectangle textBounds = { 0 }; if (message != NULL) @@ -3176,18 +3126,18 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co Vector2 textSize = MeasureTextEx(guiFont, message, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), 1); textBounds.x = bounds.x + bounds.width/2 - textSize.x/2; - textBounds.y = bounds.y + WINDOW_STATUSBAR_HEIGHT + messageInputHeight/4 - textSize.y/2; + textBounds.y = bounds.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT + messageInputHeight/4 - textSize.y/2; textBounds.width = textSize.x; textBounds.height = textSize.y; } Rectangle textBoxBounds = { 0 }; - textBoxBounds.x = bounds.x + TEXTINPUTBOX_BUTTON_PADDING; - textBoxBounds.y = bounds.y + WINDOW_STATUSBAR_HEIGHT - TEXTINPUTBOX_HEIGHT/2; - if (message == NULL) textBoxBounds.y += messageInputHeight/2; + textBoxBounds.x = bounds.x + RAYGUI_TEXTINPUTBOX_BUTTON_PADDING; + textBoxBounds.y = bounds.y + RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT - RAYGUI_TEXTINPUTBOX_HEIGHT/2; + if (message == NULL) textBoxBounds.y = bounds.y + 24 + RAYGUI_TEXTINPUTBOX_BUTTON_PADDING; else textBoxBounds.y += (messageInputHeight/2 + messageInputHeight/4); - textBoxBounds.width = bounds.width - TEXTINPUTBOX_BUTTON_PADDING*2; - textBoxBounds.height = TEXTINPUTBOX_HEIGHT; + textBoxBounds.width = bounds.width - RAYGUI_TEXTINPUTBOX_BUTTON_PADDING*2; + textBoxBounds.height = RAYGUI_TEXTINPUTBOX_HEIGHT; // Draw control //-------------------------------------------------------------------- @@ -3197,20 +3147,31 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co if (message != NULL) { int prevTextAlignment = GuiGetStyle(LABEL, TEXT_ALIGNMENT); - GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); + GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); GuiLabel(textBounds, message); GuiSetStyle(LABEL, TEXT_ALIGNMENT, prevTextAlignment); } - if (GuiTextBox(textBoxBounds, text, TEXTINPUTBOX_MAX_TEXT_LENGTH, textEditMode)) textEditMode = !textEditMode; + if (secretViewActive != NULL) + { + static char stars[] = "****************"; + if (GuiTextBox(RAYGUI_CLITERAL(Rectangle){ textBoxBounds.x, textBoxBounds.y, textBoxBounds.width - 4 - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.height }, + ((*secretViewActive == 1) || textEditMode)? text : stars, textMaxSize, textEditMode)) textEditMode = !textEditMode; + + *secretViewActive = GuiToggle(RAYGUI_CLITERAL(Rectangle){ textBoxBounds.x + textBoxBounds.width - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.y, RAYGUI_TEXTINPUTBOX_HEIGHT, RAYGUI_TEXTINPUTBOX_HEIGHT }, (*secretViewActive == 1)? "#44#" : "#45#", *secretViewActive); + } + else + { + if (GuiTextBox(textBoxBounds, text, textMaxSize, textEditMode)) textEditMode = !textEditMode; + } int prevBtnTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT); - GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); + GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); for (int i = 0; i < buttonCount; i++) { if (GuiButton(buttonBounds, buttonsText[i])) btnIndex = i + 1; - buttonBounds.x += (buttonBounds.width + MESSAGEBOX_BUTTON_PADDING); + buttonBounds.x += (buttonBounds.width + RAYGUI_MESSAGEBOX_BUTTON_PADDING); } GuiSetStyle(BUTTON, TEXT_ALIGNMENT, prevBtnTextAlignment); @@ -3223,13 +3184,14 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co // NOTE: Returns grid mouse-hover selected cell // About drawing lines at subpixel spacing, simple put, not easy solution: // https://stackoverflow.com/questions/4435450/2d-opengl-drawing-lines-that-dont-exactly-fit-pixel-raster -Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs) +Vector2 GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs) { - #if !defined(GRID_COLOR_ALPHA) - #define GRID_COLOR_ALPHA 0.15f // Grid lines alpha amount + // Grid lines alpha amount + #if !defined(RAYGUI_GRID_ALPHA) + #define RAYGUI_GRID_ALPHA 0.15f #endif - GuiControlState state = guiState; + GuiState state = guiState; Vector2 mousePoint = GetMousePosition(); Vector2 currentCell = { -1, -1 }; @@ -3238,21 +3200,25 @@ Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs) // Update control //-------------------------------------------------------------------- - if ((state != GUI_STATE_DISABLED) && !guiLocked) + if ((state != STATE_DISABLED) && !guiLocked) { if (CheckCollisionPointRec(mousePoint, bounds)) { - currentCell.x = (mousePoint.x - bounds.x)/spacing; - currentCell.y = (mousePoint.y - bounds.y)/spacing; + // NOTE: Cell values must be rounded to int + currentCell.x = (int)((mousePoint.x - bounds.x)/spacing); + currentCell.y = (int)((mousePoint.y - bounds.y)/spacing); } } //-------------------------------------------------------------------- // Draw control //-------------------------------------------------------------------- + + // TODO: Draw background panel? + switch (state) { - case GUI_STATE_NORMAL: + case STATE_NORMAL: { if (subdivs > 0) { @@ -3260,14 +3226,14 @@ Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs) for (int i = 0; i < linesV; i++) { Rectangle lineV = { bounds.x + spacing*i/subdivs, bounds.y, 1, bounds.height }; - GuiDrawRectangle(lineV, 0, BLANK, ((i%subdivs) == 0) ? Fade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), GRID_COLOR_ALPHA*4) : Fade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), GRID_COLOR_ALPHA)); + GuiDrawRectangle(lineV, 0, BLANK, ((i%subdivs) == 0) ? Fade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), RAYGUI_GRID_ALPHA*4) : Fade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), RAYGUI_GRID_ALPHA)); } // Draw horizontal grid lines for (int i = 0; i < linesH; i++) { Rectangle lineH = { bounds.x, bounds.y + spacing*i/subdivs, bounds.width, 1 }; - GuiDrawRectangle(lineH, 0, BLANK, ((i%subdivs) == 0) ? Fade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), GRID_COLOR_ALPHA*4) : Fade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), GRID_COLOR_ALPHA)); + GuiDrawRectangle(lineH, 0, BLANK, ((i%subdivs) == 0) ? Fade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), RAYGUI_GRID_ALPHA*4) : Fade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), RAYGUI_GRID_ALPHA)); } } } break; @@ -3282,8 +3248,12 @@ Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs) //---------------------------------------------------------------------------------- // Load raygui style file (.rgs) +// NOTE: By default a binary file is expected, that file could contain a custom font, +// in that case, custom font image atlas is GRAY+ALPHA and pixel data can be compressed (DEFLATE) void GuiLoadStyle(const char *fileName) { + #define MAX_LINE_BUFFER_SIZE 256 + bool tryBinary = false; // Try reading the files as text file first @@ -3291,8 +3261,8 @@ void GuiLoadStyle(const char *fileName) if (rgsFile != NULL) { - char buffer[256] = { 0 }; - fgets(buffer, 256, rgsFile); + char buffer[MAX_LINE_BUFFER_SIZE] = { 0 }; + fgets(buffer, MAX_LINE_BUFFER_SIZE, rgsFile); if (buffer[0] == '#') { @@ -3309,7 +3279,6 @@ void GuiLoadStyle(const char *fileName) // Style property: p sscanf(buffer, "p %d %d 0x%x", &controlId, &propertyId, &propertyValue); - GuiSetStyle(controlId, propertyId, (int)propertyValue); } break; @@ -3337,12 +3306,19 @@ void GuiLoadStyle(const char *fileName) int *values = (int *)RAYGUI_MALLOC(glyphCount*sizeof(int)); for (int i = 0; i < glyphCount; i++) values[i] = TextToInteger(chars[i]); + if (font.texture.id != GetFontDefault().texture.id) UnloadTexture(font.texture); font = LoadFontEx(TextFormat("%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, values, glyphCount); + if (font.texture.id == 0) font = GetFontDefault(); RAYGUI_FREE(values); } } - else font = LoadFontEx(TextFormat("%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, NULL, 0); + else + { + if (font.texture.id != GetFontDefault().texture.id) UnloadTexture(font.texture); + font = LoadFontEx(TextFormat("%s/%s", GetDirectoryPath(fileName), fontFileName), fontSize, NULL, 0); + if (font.texture.id == 0) font = GetFontDefault(); + } if ((font.texture.id > 0) && (font.glyphCount > 0)) GuiSetFont(font); @@ -3350,7 +3326,7 @@ void GuiLoadStyle(const char *fileName) default: break; } - fgets(buffer, 256, rgsFile); + fgets(buffer, MAX_LINE_BUFFER_SIZE, rgsFile); } } else tryBinary = true; @@ -3364,7 +3340,7 @@ void GuiLoadStyle(const char *fileName) if (rgsFile == NULL) return; - char signature[5] = ""; + char signature[5] = { 0 }; short version = 0; short reserved = 0; int propertyCount = 0; @@ -3381,13 +3357,13 @@ void GuiLoadStyle(const char *fileName) { short controlId = 0; short propertyId = 0; - int propertyValue = 0; + unsigned int propertyValue = 0; for (int i = 0; i < propertyCount; i++) { fread(&controlId, 1, sizeof(short), rgsFile); fread(&propertyId, 1, sizeof(short), rgsFile); - fread(&propertyValue, 1, sizeof(int), rgsFile); + fread(&propertyValue, 1, sizeof(unsigned int), rgsFile); if (controlId == 0) // DEFAULT control { @@ -3420,24 +3396,42 @@ void GuiLoadStyle(const char *fileName) fread(&whiteRec, 1, sizeof(Rectangle), rgsFile); // Load font image parameters - int fontImageSize = 0; - fread(&fontImageSize, 1, sizeof(int), rgsFile); + int fontImageUncompSize = 0; + int fontImageCompSize = 0; + fread(&fontImageUncompSize, 1, sizeof(int), rgsFile); + fread(&fontImageCompSize, 1, sizeof(int), rgsFile); - if (fontImageSize > 0) + Image imFont = { 0 }; + imFont.mipmaps = 1; + fread(&imFont.width, 1, sizeof(int), rgsFile); + fread(&imFont.height, 1, sizeof(int), rgsFile); + fread(&imFont.format, 1, sizeof(int), rgsFile); + + if (fontImageCompSize < fontImageUncompSize) { - Image imFont = { 0 }; - imFont.mipmaps = 1; - fread(&imFont.width, 1, sizeof(int), rgsFile); - fread(&imFont.height, 1, sizeof(int), rgsFile); - fread(&imFont.format, 1, sizeof(int), rgsFile); + // Compressed font atlas image data (DEFLATE), it requires DecompressData() + int dataUncompSize = 0; + unsigned char *compData = (unsigned char *)RAYGUI_MALLOC(fontImageCompSize); + fread(compData, 1, fontImageCompSize, rgsFile); + imFont.data = DecompressData(compData, fontImageCompSize, &dataUncompSize); - imFont.data = (unsigned char *)RAYGUI_MALLOC(fontImageSize); - fread(imFont.data, 1, fontImageSize, rgsFile); + // Security check, dataUncompSize must match the provided fontImageUncompSize + if (dataUncompSize != fontImageUncompSize) RAYGUI_LOG("WARNING: Uncompressed font atlas image data could be corrupted"); - font.texture = LoadTextureFromImage(imFont); - - RAYGUI_FREE(imFont.data); + RAYGUI_FREE(compData); } + else + { + // Font atlas image data is not compressed + imFont.data = (unsigned char *)RAYGUI_MALLOC(fontImageUncompSize); + fread(imFont.data, 1, fontImageUncompSize, rgsFile); + } + + if (font.texture.id != GetFontDefault().texture.id) UnloadTexture(font.texture); + font.texture = LoadTextureFromImage(imFont); + if (font.texture.id == 0) font = GetFontDefault(); + + RAYGUI_FREE(imFont.data); // Load font recs data font.recs = (Rectangle *)RAYGUI_CALLOC(font.glyphCount, sizeof(Rectangle)); @@ -3488,23 +3482,23 @@ void GuiLoadStyleDefault(void) GuiSetStyle(DEFAULT, TEXT_COLOR_DISABLED, 0xaeb7b8ff); GuiSetStyle(DEFAULT, BORDER_WIDTH, 1); // WARNING: Some controls use other values GuiSetStyle(DEFAULT, TEXT_PADDING, 0); // WARNING: Some controls use other values - GuiSetStyle(DEFAULT, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); // WARNING: Some controls use other values + GuiSetStyle(DEFAULT, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER); // WARNING: Some controls use other values // Initialize control-specific property values // NOTE: Those properties are in default list but require specific values by control type - GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT); + GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); GuiSetStyle(BUTTON, BORDER_WIDTH, 2); - GuiSetStyle(SLIDER, TEXT_PADDING, 5); - GuiSetStyle(CHECKBOX, TEXT_PADDING, 5); - GuiSetStyle(CHECKBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_RIGHT); - GuiSetStyle(TEXTBOX, TEXT_PADDING, 5); - GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT); + GuiSetStyle(SLIDER, TEXT_PADDING, 4); + GuiSetStyle(CHECKBOX, TEXT_PADDING, 4); + GuiSetStyle(CHECKBOX, TEXT_ALIGNMENT, TEXT_ALIGN_RIGHT); + GuiSetStyle(TEXTBOX, TEXT_PADDING, 4); + GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); GuiSetStyle(VALUEBOX, TEXT_PADDING, 4); - GuiSetStyle(VALUEBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT); + GuiSetStyle(VALUEBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); GuiSetStyle(SPINNER, TEXT_PADDING, 4); - GuiSetStyle(SPINNER, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT); - GuiSetStyle(STATUSBAR, TEXT_PADDING, 6); - GuiSetStyle(STATUSBAR, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT); + GuiSetStyle(SPINNER, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); + GuiSetStyle(STATUSBAR, TEXT_PADDING, 8); + GuiSetStyle(STATUSBAR, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); // Initialize extended property values // NOTE: By default, extended property values are initialized to 0 @@ -3513,35 +3507,33 @@ void GuiLoadStyleDefault(void) GuiSetStyle(DEFAULT, LINE_COLOR, 0x90abb5ff); // DEFAULT specific property GuiSetStyle(DEFAULT, BACKGROUND_COLOR, 0xf5f5f5ff); // DEFAULT specific property GuiSetStyle(TOGGLE, GROUP_PADDING, 2); - GuiSetStyle(SLIDER, SLIDER_WIDTH, 15); + GuiSetStyle(SLIDER, SLIDER_WIDTH, 16); GuiSetStyle(SLIDER, SLIDER_PADDING, 1); GuiSetStyle(PROGRESSBAR, PROGRESS_PADDING, 1); GuiSetStyle(CHECKBOX, CHECK_PADDING, 1); - GuiSetStyle(COMBOBOX, COMBO_BUTTON_WIDTH, 30); - GuiSetStyle(COMBOBOX, COMBO_BUTTON_PADDING, 2); + GuiSetStyle(COMBOBOX, COMBO_BUTTON_WIDTH, 32); + GuiSetStyle(COMBOBOX, COMBO_BUTTON_SPACING, 2); GuiSetStyle(DROPDOWNBOX, ARROW_PADDING, 16); - GuiSetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_PADDING, 2); - GuiSetStyle(TEXTBOX, TEXT_LINES_PADDING, 5); + GuiSetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING, 2); + GuiSetStyle(TEXTBOX, TEXT_LINES_SPACING, 4); GuiSetStyle(TEXTBOX, TEXT_INNER_PADDING, 4); - GuiSetStyle(TEXTBOX, COLOR_SELECTED_FG, 0xf0fffeff); - GuiSetStyle(TEXTBOX, COLOR_SELECTED_BG, 0x839affe0); - GuiSetStyle(SPINNER, SPIN_BUTTON_WIDTH, 20); - GuiSetStyle(SPINNER, SPIN_BUTTON_PADDING, 2); + GuiSetStyle(SPINNER, SPIN_BUTTON_WIDTH, 24); + GuiSetStyle(SPINNER, SPIN_BUTTON_SPACING, 2); GuiSetStyle(SCROLLBAR, BORDER_WIDTH, 0); GuiSetStyle(SCROLLBAR, ARROWS_VISIBLE, 0); GuiSetStyle(SCROLLBAR, ARROWS_SIZE, 6); GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING, 0); GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, 16); GuiSetStyle(SCROLLBAR, SCROLL_PADDING, 0); - GuiSetStyle(SCROLLBAR, SCROLL_SPEED, 10); - GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, 0x1e); - GuiSetStyle(LISTVIEW, LIST_ITEMS_PADDING, 2); - GuiSetStyle(LISTVIEW, SCROLLBAR_WIDTH, 10); + GuiSetStyle(SCROLLBAR, SCROLL_SPEED, 12); + GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, 24); + GuiSetStyle(LISTVIEW, LIST_ITEMS_SPACING, 2); + GuiSetStyle(LISTVIEW, SCROLLBAR_WIDTH, 12); GuiSetStyle(LISTVIEW, SCROLLBAR_SIDE, SCROLLBAR_RIGHT_SIDE); - GuiSetStyle(COLORPICKER, COLOR_SELECTOR_SIZE, 6); - GuiSetStyle(COLORPICKER, HUEBAR_WIDTH, 0x14); - GuiSetStyle(COLORPICKER, HUEBAR_PADDING, 0xa); - GuiSetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT, 6); + GuiSetStyle(COLORPICKER, COLOR_SELECTOR_SIZE, 8); + GuiSetStyle(COLORPICKER, HUEBAR_WIDTH, 16); + GuiSetStyle(COLORPICKER, HUEBAR_PADDING, 8); + GuiSetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT, 8); GuiSetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW, 2); guiFont = GetFontDefault(); // Initialize default font @@ -3552,35 +3544,42 @@ void GuiLoadStyleDefault(void) // a number that can change between ricon versions const char *GuiIconText(int iconId, const char *text) { -#if defined(RAYGUI_NO_RICONS) +#if defined(RAYGUI_NO_ICONS) return NULL; #else static char buffer[1024] = { 0 }; - memset(buffer, 0, 1024); - - sprintf(buffer, "#%03i#", iconId); + static char iconBuffer[6] = { 0 }; if (text != NULL) { + memset(buffer, 0, 1024); + sprintf(buffer, "#%03i#", iconId); + for (int i = 5; i < 1024; i++) { buffer[i] = text[i - 5]; if (text[i - 5] == '\0') break; } + + return buffer; + } + else + { + sprintf(iconBuffer, "#%03i#", iconId & 0x1ff); + + return iconBuffer; } - - return buffer; #endif } -#if !defined(RAYGUI_NO_RICONS) +#if !defined(RAYGUI_NO_ICONS) // Get full icons data pointer unsigned int *GuiGetIcons(void) { return guiIcons; } // Load raygui icons file (.rgi) // NOTE: In case nameIds are required, they can be requested with loadIconsName, -// they are returned as a guiIconsName[iconCount][RICON_MAX_NAME_LENGTH], +// they are returned as a guiIconsName[iconCount][RAYGUI_ICON_MAX_NAME_LENGTH], // WARNING: guiIconsName[]][] memory should be manually freed! char **GuiLoadIcons(const char *fileName, bool loadIconsName) { @@ -3614,7 +3613,7 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName) if (rgiFile != NULL) { - char signature[5] = ""; + char signature[5] = { 0 }; short version = 0; short reserved = 0; short iconCount = 0; @@ -3636,11 +3635,11 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName) guiIconsName = (char **)RAYGUI_MALLOC(iconCount*sizeof(char **)); for (int i = 0; i < iconCount; i++) { - guiIconsName[i] = (char *)RAYGUI_MALLOC(RICON_MAX_NAME_LENGTH); - fread(guiIconsName[i], RICON_MAX_NAME_LENGTH, 1, rgiFile); + guiIconsName[i] = (char *)RAYGUI_MALLOC(RAYGUI_ICON_MAX_NAME_LENGTH); + fread(guiIconsName[i], RAYGUI_ICON_MAX_NAME_LENGTH, 1, rgiFile); } } - else fseek(rgiFile, iconCount*RICON_MAX_NAME_LENGTH, SEEK_CUR); + else fseek(rgiFile, iconCount*RAYGUI_ICON_MAX_NAME_LENGTH, SEEK_CUR); // Read icons data directly over guiIcons data array fread(guiIcons, iconCount*(iconSize*iconSize/32), sizeof(unsigned int), rgiFile); @@ -3655,16 +3654,16 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName) // Draw selected icon using rectangles pixel-by-pixel void GuiDrawIcon(int iconId, int posX, int posY, int pixelSize, Color color) { - #define BIT_CHECK(a,b) ((a) & (1<<(b))) + #define BIT_CHECK(a,b) ((a) & (1u<<(b))) - for (int i = 0, y = 0; i < RICON_SIZE*RICON_SIZE/32; i++) + for (int i = 0, y = 0; i < RAYGUI_ICON_SIZE*RAYGUI_ICON_SIZE/32; i++) { for (int k = 0; k < 32; k++) { - if (BIT_CHECK(guiIcons[iconId*RICON_DATA_ELEMENTS + i], k)) + if (BIT_CHECK(guiIcons[iconId*RAYGUI_ICON_DATA_ELEMENTS + i], k)) { #if !defined(RAYGUI_STANDALONE) - DrawRectangle(posX + (k%RICON_SIZE)*pixelSize, posY + y*pixelSize, pixelSize, pixelSize, color); + DrawRectangle(posX + (k%RAYGUI_ICON_SIZE)*pixelSize, posY + y*pixelSize, pixelSize, pixelSize, color); #endif } @@ -3674,65 +3673,91 @@ void GuiDrawIcon(int iconId, int posX, int posY, int pixelSize, Color color) } // Get icon bit data -// NOTE: Bit data array grouped as unsigned int (ICON_SIZE*ICON_SIZE/32 elements) +// NOTE: Bit data array grouped as unsigned int (RAYGUI_ICON_SIZE*RAYGUI_ICON_SIZE/32 elements) unsigned int *GuiGetIconData(int iconId) { - static unsigned int iconData[RICON_DATA_ELEMENTS] = { 0 }; - memset(iconData, 0, RICON_DATA_ELEMENTS*sizeof(unsigned int)); + static unsigned int iconData[RAYGUI_ICON_DATA_ELEMENTS] = { 0 }; + memset(iconData, 0, RAYGUI_ICON_DATA_ELEMENTS*sizeof(unsigned int)); - if (iconId < RICON_MAX_ICONS) memcpy(iconData, &guiIcons[iconId*RICON_DATA_ELEMENTS], RICON_DATA_ELEMENTS*sizeof(unsigned int)); + if (iconId < RAYGUI_ICON_MAX_ICONS) memcpy(iconData, &guiIcons[iconId*RAYGUI_ICON_DATA_ELEMENTS], RAYGUI_ICON_DATA_ELEMENTS*sizeof(unsigned int)); return iconData; } // Set icon bit data -// NOTE: Data must be provided as unsigned int array (ICON_SIZE*ICON_SIZE/32 elements) +// NOTE: Data must be provided as unsigned int array (RAYGUI_ICON_SIZE*RAYGUI_ICON_SIZE/32 elements) void GuiSetIconData(int iconId, unsigned int *data) { - if (iconId < RICON_MAX_ICONS) memcpy(&guiIcons[iconId*RICON_DATA_ELEMENTS], data, RICON_DATA_ELEMENTS*sizeof(unsigned int)); + if (iconId < RAYGUI_ICON_MAX_ICONS) memcpy(&guiIcons[iconId*RAYGUI_ICON_DATA_ELEMENTS], data, RAYGUI_ICON_DATA_ELEMENTS*sizeof(unsigned int)); +} + +// Set icon scale (1 by default) +void GuiSetIconScale(unsigned int scale) +{ + guiIconScale = (scale < 1)? 1 : scale; } // Set icon pixel value void GuiSetIconPixel(int iconId, int x, int y) { - #define BIT_SET(a,b) ((a) |= (1<<(b))) + #define BIT_SET(a,b) ((a) |= (1u<<(b))) - // This logic works for any RICON_SIZE pixels icons, + // This logic works for any RAYGUI_ICON_SIZE pixels icons, // For example, in case of 16x16 pixels, every 2 lines fit in one unsigned int data element - BIT_SET(guiIcons[iconId*RICON_DATA_ELEMENTS + y/(sizeof(unsigned int)*8/RICON_SIZE)], x + (y%(sizeof(unsigned int)*8/RICON_SIZE)*RICON_SIZE)); + BIT_SET(guiIcons[iconId*RAYGUI_ICON_DATA_ELEMENTS + y/(sizeof(unsigned int)*8/RAYGUI_ICON_SIZE)], x + (y%(sizeof(unsigned int)*8/RAYGUI_ICON_SIZE)*RAYGUI_ICON_SIZE)); } // Clear icon pixel value void GuiClearIconPixel(int iconId, int x, int y) { - #define BIT_CLEAR(a,b) ((a) &= ~((1)<<(b))) + #define BIT_CLEAR(a,b) ((a) &= ~((1u)<<(b))) - // This logic works for any RICON_SIZE pixels icons, + // This logic works for any RAYGUI_ICON_SIZE pixels icons, // For example, in case of 16x16 pixels, every 2 lines fit in one unsigned int data element - BIT_CLEAR(guiIcons[iconId*RICON_DATA_ELEMENTS + y/(sizeof(unsigned int)*8/RICON_SIZE)], x + (y%(sizeof(unsigned int)*8/RICON_SIZE)*RICON_SIZE)); + BIT_CLEAR(guiIcons[iconId*RAYGUI_ICON_DATA_ELEMENTS + y/(sizeof(unsigned int)*8/RAYGUI_ICON_SIZE)], x + (y%(sizeof(unsigned int)*8/RAYGUI_ICON_SIZE)*RAYGUI_ICON_SIZE)); } // Check icon pixel value bool GuiCheckIconPixel(int iconId, int x, int y) { - #define BIT_CHECK(a,b) ((a) & (1<<(b))) + #define BIT_CHECK(a,b) ((a) & (1u<<(b))) return (BIT_CHECK(guiIcons[iconId*8 + y/2], x + (y%2*16))); } -#endif // !RAYGUI_NO_RICONS +#endif // !RAYGUI_NO_ICONS //---------------------------------------------------------------------------------- // Module specific Functions Definition //---------------------------------------------------------------------------------- -// Gui get text width using default font -// NOTE: Icon is not considered here +// Gui get text width considering icon static int GetTextWidth(const char *text) { + #if !defined(ICON_TEXT_PADDING) + #define ICON_TEXT_PADDING 4 + #endif + Vector2 size = { 0 }; + int textIconOffset = 0; if ((text != NULL) && (text[0] != '\0')) { - size = MeasureTextEx(guiFont, text, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING)); + if (text[0] == '#') + { + for (int i = 1; (text[i] != '\0') && (i < 5); i++) + { + if (text[i] == '#') + { + textIconOffset = i; + break; + } + } + } + + // Make sure guiFont is set, GuiGetStyle() initializes it lazynessly + float fontSize = (float)GuiGetStyle(DEFAULT, TEXT_SIZE); + + size = MeasureTextEx(guiFont, text + textIconOffset, fontSize, (float)GuiGetStyle(DEFAULT, TEXT_SPACING)); + if (textIconOffset > 0) size.x += (RAYGUI_ICON_SIZE - ICON_TEXT_PADDING); } return (int)size.x; @@ -3751,11 +3776,11 @@ static Rectangle GetTextBounds(int control, Rectangle bounds) // Consider TEXT_PADDING properly, depends on control type and TEXT_ALIGNMENT switch (control) { - case COMBOBOX: bounds.width -= (GuiGetStyle(control, COMBO_BUTTON_WIDTH) + GuiGetStyle(control, COMBO_BUTTON_PADDING)); break; + case COMBOBOX: bounds.width -= (GuiGetStyle(control, COMBO_BUTTON_WIDTH) + GuiGetStyle(control, COMBO_BUTTON_SPACING)); break; case VALUEBOX: break; // NOTE: ValueBox text value always centered, text padding applies to label default: { - if (GuiGetStyle(control, TEXT_ALIGNMENT) == GUI_TEXT_ALIGN_RIGHT) textBounds.x -= GuiGetStyle(control, TEXT_PADDING); + if (GuiGetStyle(control, TEXT_ALIGNMENT) == TEXT_ALIGN_RIGHT) textBounds.x -= GuiGetStyle(control, TEXT_PADDING); else textBounds.x += GuiGetStyle(control, TEXT_PADDING); } break; } @@ -3770,7 +3795,7 @@ static Rectangle GetTextBounds(int control, Rectangle bounds) // NOTE: We support up to 999 values for iconId static const char *GetTextIcon(const char *text, int *iconId) { -#if !defined(RAYGUI_NO_RICONS) +#if !defined(RAYGUI_NO_ICONS) *iconId = -1; if (text[0] == '#') // Maybe we have an icon! { @@ -3802,6 +3827,10 @@ static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color { #define TEXT_VALIGN_PIXEL_OFFSET(h) ((int)h%2) // Vertical alignment for pixel perfect + #if !defined(ICON_TEXT_PADDING) + #define ICON_TEXT_PADDING 4 + #endif + if ((text != NULL) && (text[0] != '\0')) { int iconId = 0; @@ -3809,40 +3838,40 @@ static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color // Get text position depending on alignment and iconId //--------------------------------------------------------------------------------- - #define RICON_TEXT_PADDING 4 - Vector2 position = { bounds.x, bounds.y }; // NOTE: We get text size after icon has been processed - int textWidth = GetTextWidth(text); - int textHeight = GuiGetStyle(DEFAULT, TEXT_SIZE); + // TODO: REVIEW: We consider text size in case of line breaks! -> MeasureTextEx() depends on raylib! + Vector2 textSize = MeasureTextEx(GuiGetFont(), text, GuiGetStyle(DEFAULT, TEXT_SIZE), GuiGetStyle(DEFAULT, TEXT_SPACING)); + //int textWidth = GetTextWidth(text); + //int textHeight = GuiGetStyle(DEFAULT, TEXT_SIZE); // If text requires an icon, add size to measure if (iconId >= 0) { - textWidth += RICON_SIZE; + textSize.x += RAYGUI_ICON_SIZE*guiIconScale; // WARNING: If only icon provided, text could be pointing to EOF character: '\0' - if ((text != NULL) && (text[0] != '\0')) textWidth += RICON_TEXT_PADDING; + if ((text != NULL) && (text[0] != '\0')) textSize.x += ICON_TEXT_PADDING; } // Check guiTextAlign global variables switch (alignment) { - case GUI_TEXT_ALIGN_LEFT: + case TEXT_ALIGN_LEFT: { position.x = bounds.x; - position.y = bounds.y + bounds.height/2 - textHeight/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height); + position.y = bounds.y + bounds.height/2 - textSize.y/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height); } break; - case GUI_TEXT_ALIGN_CENTER: + case TEXT_ALIGN_CENTER: { - position.x = bounds.x + bounds.width/2 - textWidth/2; - position.y = bounds.y + bounds.height/2 - textHeight/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height); + position.x = bounds.x + bounds.width/2 - textSize.x/2; + position.y = bounds.y + bounds.height/2 - textSize.y/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height); } break; - case GUI_TEXT_ALIGN_RIGHT: + case TEXT_ALIGN_RIGHT: { - position.x = bounds.x + bounds.width - textWidth; - position.y = bounds.y + bounds.height/2 - textHeight/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height); + position.x = bounds.x + bounds.width - textSize.x; + position.y = bounds.y + bounds.height/2 - textSize.y/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height); } break; default: break; } @@ -3855,12 +3884,12 @@ static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color // Draw text (with icon if available) //--------------------------------------------------------------------------------- -#if !defined(RAYGUI_NO_RICONS) +#if !defined(RAYGUI_NO_ICONS) if (iconId >= 0) { // NOTE: We consider icon height, probably different than text size - GuiDrawIcon(iconId, (int)position.x, (int)(bounds.y + bounds.height/2 - RICON_SIZE/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height)), 1, tint); - position.x += (RICON_SIZE + RICON_TEXT_PADDING); + GuiDrawIcon(iconId, (int)position.x, (int)(bounds.y + bounds.height/2 - RAYGUI_ICON_SIZE*guiIconScale/2 + TEXT_VALIGN_PIXEL_OFFSET(bounds.height)), guiIconScale, tint); + position.x += (RAYGUI_ICON_SIZE*guiIconScale + ICON_TEXT_PADDING); } #endif DrawTextEx(guiFont, text, position, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), tint); @@ -3894,21 +3923,20 @@ static const char **GuiTextSplit(const char *text, int *count, int *textRow) // NOTE: Current implementation returns a copy of the provided string with '\0' (string end delimiter) // inserted between strings defined by "delimiter" parameter. No memory is dynamically allocated, // all used memory is static... it has some limitations: - // 1. Maximum number of possible split strings is set by TEXTSPLIT_MAX_TEXT_ELEMENTS - // 2. Maximum size of text to split is TEXTSPLIT_MAX_TEXT_LENGTH + // 1. Maximum number of possible split strings is set by RAYGUI_TEXTSPLIT_MAX_ITEMS + // 2. Maximum size of text to split is RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE // NOTE: Those definitions could be externally provided if required - #if !defined(TEXTSPLIT_MAX_TEXT_LENGTH) - #define TEXTSPLIT_MAX_TEXT_LENGTH 1024 + #if !defined(RAYGUI_TEXTSPLIT_MAX_ITEMS) + #define RAYGUI_TEXTSPLIT_MAX_ITEMS 128 + #endif + #if !defined(RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE) + #define RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE 1024 #endif - #if !defined(TEXTSPLIT_MAX_TEXT_ELEMENTS) - #define TEXTSPLIT_MAX_TEXT_ELEMENTS 128 - #endif - - static const char *result[TEXTSPLIT_MAX_TEXT_ELEMENTS] = { NULL }; - static char buffer[TEXTSPLIT_MAX_TEXT_LENGTH] = { 0 }; - memset(buffer, 0, TEXTSPLIT_MAX_TEXT_LENGTH); + static const char *result[RAYGUI_TEXTSPLIT_MAX_ITEMS] = { NULL }; + static char buffer[RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE] = { 0 }; + memset(buffer, 0, RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE); result[0] = buffer; int counter = 1; @@ -3916,7 +3944,7 @@ static const char **GuiTextSplit(const char *text, int *count, int *textRow) if (textRow != NULL) textRow[0] = 0; // Count how many substrings we have on text and point to every one - for (int i = 0; i < TEXTSPLIT_MAX_TEXT_LENGTH; i++) + for (int i = 0; i < RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE; i++) { buffer[i] = text[i]; if (buffer[i] == '\0') break; @@ -3933,7 +3961,7 @@ static const char **GuiTextSplit(const char *text, int *count, int *textRow) buffer[i] = '\0'; // Set an end of string at this point counter++; - if (counter == TEXTSPLIT_MAX_TEXT_ELEMENTS) break; + if (counter == RAYGUI_TEXTSPLIT_MAX_ITEMS) break; } } @@ -4066,6 +4094,121 @@ static Vector3 ConvertHSVtoRGB(Vector3 hsv) return rgb; } +// Scroll bar control (used by GuiScrollPanel()) +static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue) +{ + GuiState state = guiState; + + // Is the scrollbar horizontal or vertical? + bool isVertical = (bounds.width > bounds.height) ? false : true; + + // The size (width or height depending on scrollbar type) of the spinner buttons + const int spinnerSize = GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE) ? (isVertical ? (int)bounds.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) : (int)bounds.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH)) : 0; + + // Arrow buttons [<] [>] [∧] [∨] + Rectangle arrowUpLeft = { 0 }; + Rectangle arrowDownRight = { 0 }; + + // Actual area of the scrollbar excluding the arrow buttons + Rectangle scrollbar = { 0 }; + + // Slider bar that moves --[///]----- + Rectangle slider = { 0 }; + + // Normalize value + if (value > maxValue) value = maxValue; + if (value < minValue) value = minValue; + + const int range = maxValue - minValue; + int sliderSize = GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE); + + // Calculate rectangles for all of the components + arrowUpLeft = RAYGUI_CLITERAL(Rectangle) { (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (float)spinnerSize }; + + if (isVertical) + { + arrowDownRight = RAYGUI_CLITERAL(Rectangle) { (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + bounds.height - spinnerSize - GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (float)spinnerSize }; + scrollbar = RAYGUI_CLITERAL(Rectangle) { bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING), arrowUpLeft.y + arrowUpLeft.height, bounds.width - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING)), bounds.height - arrowUpLeft.height - arrowDownRight.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) }; + sliderSize = (sliderSize >= scrollbar.height) ? ((int)scrollbar.height - 2) : sliderSize; // Make sure the slider won't get outside of the scrollbar + slider = RAYGUI_CLITERAL(Rectangle) { (float)bounds.x + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING), (float)scrollbar.y + (int)(((float)(value - minValue)/range)*(scrollbar.height - sliderSize)), (float)bounds.width - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING)), (float)sliderSize }; + } + else + { + arrowDownRight = RAYGUI_CLITERAL(Rectangle) { (float)bounds.x + bounds.width - spinnerSize - GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH), (float)spinnerSize, (float)spinnerSize }; + scrollbar = RAYGUI_CLITERAL(Rectangle) { arrowUpLeft.x + arrowUpLeft.width, bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING), bounds.width - arrowUpLeft.width - arrowDownRight.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH), bounds.height - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_PADDING)) }; + sliderSize = (sliderSize >= scrollbar.width) ? ((int)scrollbar.width - 2) : sliderSize; // Make sure the slider won't get outside of the scrollbar + slider = RAYGUI_CLITERAL(Rectangle) { (float)scrollbar.x + (int)(((float)(value - minValue)/range)*(scrollbar.width - sliderSize)), (float)bounds.y + GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING), (float)sliderSize, (float)bounds.height - 2*(GuiGetStyle(SCROLLBAR, BORDER_WIDTH) + GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING)) }; + } + + // Update control + //-------------------------------------------------------------------- + if ((state != STATE_DISABLED) && !guiLocked) + { + Vector2 mousePoint = GetMousePosition(); + + if (CheckCollisionPointRec(mousePoint, bounds)) + { + state = STATE_FOCUSED; + + // Handle mouse wheel + int wheel = (int)GetMouseWheelMove(); + if (wheel != 0) value += wheel; + + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + { + if (CheckCollisionPointRec(mousePoint, arrowUpLeft)) value -= range/GuiGetStyle(SCROLLBAR, SCROLL_SPEED); + else if (CheckCollisionPointRec(mousePoint, arrowDownRight)) value += range/GuiGetStyle(SCROLLBAR, SCROLL_SPEED); + + state = STATE_PRESSED; + } + else if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) + { + if (!isVertical) + { + Rectangle scrollArea = { arrowUpLeft.x + arrowUpLeft.width, arrowUpLeft.y, scrollbar.width, bounds.height - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH) }; + if (CheckCollisionPointRec(mousePoint, scrollArea)) value = (int)(((float)(mousePoint.x - scrollArea.x - slider.width/2)*range)/(scrollArea.width - slider.width) + minValue); + } + else + { + Rectangle scrollArea = { arrowUpLeft.x, arrowUpLeft.y+arrowUpLeft.height, bounds.width - 2*GuiGetStyle(SCROLLBAR, BORDER_WIDTH), scrollbar.height }; + if (CheckCollisionPointRec(mousePoint, scrollArea)) value = (int)(((float)(mousePoint.y - scrollArea.y - slider.height/2)*range)/(scrollArea.height - slider.height) + minValue); + } + } + } + + // Normalize value + if (value > maxValue) value = maxValue; + if (value < minValue) value = minValue; + } + //-------------------------------------------------------------------- + + // Draw control + //-------------------------------------------------------------------- + GuiDrawRectangle(bounds, GuiGetStyle(SCROLLBAR, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(LISTVIEW, BORDER + state*3)), guiAlpha), Fade(GetColor(GuiGetStyle(DEFAULT, BORDER_COLOR_DISABLED)), guiAlpha)); // Draw the background + + GuiDrawRectangle(scrollbar, 0, BLANK, Fade(GetColor(GuiGetStyle(BUTTON, BASE_COLOR_NORMAL)), guiAlpha)); // Draw the scrollbar active area background + GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, BORDER + state*3)), guiAlpha)); // Draw the slider bar + + // Draw arrows (using icon if available) + if (GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE)) + { +#if defined(RAYGUI_NO_ICONS) + GuiDrawText(isVertical ? "^" : "<", RAYGUI_CLITERAL(Rectangle){ arrowUpLeft.x, arrowUpLeft.y, isVertical ? bounds.width : bounds.height, isVertical ? bounds.width : bounds.height }, + TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))), guiAlpha)); + GuiDrawText(isVertical ? "v" : ">", RAYGUI_CLITERAL(Rectangle){ arrowDownRight.x, arrowDownRight.y, isVertical ? bounds.width : bounds.height, isVertical ? bounds.width : bounds.height }, + TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(DROPDOWNBOX, TEXT + (state*3))), guiAlpha)); +#else + GuiDrawText(isVertical ? "#121#" : "#118#", RAYGUI_CLITERAL(Rectangle){ arrowUpLeft.x, arrowUpLeft.y, isVertical ? bounds.width : bounds.height, isVertical ? bounds.width : bounds.height }, + TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(SCROLLBAR, TEXT + state*3)), guiAlpha)); // ICON_ARROW_UP_FILL / ICON_ARROW_LEFT_FILL + GuiDrawText(isVertical ? "#120#" : "#119#", RAYGUI_CLITERAL(Rectangle){ arrowDownRight.x, arrowDownRight.y, isVertical ? bounds.width : bounds.height, isVertical ? bounds.width : bounds.height }, + TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(SCROLLBAR, TEXT + state*3)), guiAlpha)); // ICON_ARROW_DOWN_FILL / ICON_ARROW_RIGHT_FILL +#endif + } + //-------------------------------------------------------------------- + + return value; +} + #if defined(RAYGUI_STANDALONE) // Returns a Color struct from hexadecimal value static Color GetColor(int hexValue) @@ -4111,9 +4254,11 @@ static Color Fade(Color color, float alpha) // Formatting of text with variables to 'embed' static const char *TextFormat(const char *text, ...) { - #define MAX_FORMATTEXT_LENGTH 64 + #if !defined(RAYGUI_TEXTFORMAT_MAX_SIZE) + #define RAYGUI_TEXTFORMAT_MAX_SIZE 256 + #endif - static char buffer[MAX_FORMATTEXT_LENGTH]; + static char buffer[RAYGUI_TEXTFORMAT_MAX_SIZE]; va_list args; va_start(args, text); @@ -4131,21 +4276,25 @@ static void DrawRectangleGradientV(int posX, int posY, int width, int height, Co DrawRectangleGradientEx(bounds, color1, color2, color2, color1); } -#define TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH 1024 // Size of static buffer: TextSplit() -#define TEXTSPLIT_MAX_SUBSTRINGS_COUNT 128 // Size of static pointers array: TextSplit() - // Split string into multiple strings const char **TextSplit(const char *text, char delimiter, int *count) { // NOTE: Current implementation returns a copy of the provided string with '\0' (string end delimiter) // inserted between strings defined by "delimiter" parameter. No memory is dynamically allocated, // all used memory is static... it has some limitations: - // 1. Maximum number of possible split strings is set by TEXTSPLIT_MAX_SUBSTRINGS_COUNT - // 2. Maximum size of text to split is TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH + // 1. Maximum number of possible split strings is set by RAYGUI_TEXTSPLIT_MAX_ITEMS + // 2. Maximum size of text to split is RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE - static const char *result[TEXTSPLIT_MAX_SUBSTRINGS_COUNT] = { NULL }; - static char buffer[TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH] = { 0 }; - memset(buffer, 0, TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH); + #if !defined(RAYGUI_TEXTSPLIT_MAX_ITEMS) + #define RAYGUI_TEXTSPLIT_MAX_ITEMS 128 + #endif + #if !defined(RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE) + #define RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE 1024 + #endif + + static const char *result[RAYGUI_TEXTSPLIT_MAX_ITEMS] = { NULL }; + static char buffer[RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE] = { 0 }; + memset(buffer, 0, RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE); result[0] = buffer; int counter = 0; @@ -4155,7 +4304,7 @@ const char **TextSplit(const char *text, char delimiter, int *count) counter = 1; // Count how many substrings we have on text and point to every one - for (int i = 0; i < TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH; i++) + for (int i = 0; i < RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE; i++) { buffer[i] = text[i]; if (buffer[i] == '\0') break; @@ -4165,7 +4314,7 @@ const char **TextSplit(const char *text, char delimiter, int *count) result[counter] = buffer + i + 1; counter++; - if (counter == TEXTSPLIT_MAX_SUBSTRINGS_COUNT) break; + if (counter == RAYGUI_TEXTSPLIT_MAX_ITEMS) break; } } } diff --git a/examples/shapes/shapes_basic_shapes.c b/examples/shapes/shapes_basic_shapes.c index 7b48d4361..c939765c5 100644 --- a/examples/shapes/shapes_basic_shapes.c +++ b/examples/shapes/shapes_basic_shapes.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_bouncing_ball.c b/examples/shapes/shapes_bouncing_ball.c index 1f8ab8d9f..81817d779 100644 --- a/examples/shapes/shapes_bouncing_ball.c +++ b/examples/shapes/shapes_bouncing_ball.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_collision_area.c b/examples/shapes/shapes_collision_area.c index c5946b639..a8a7fb97c 100644 --- a/examples/shapes/shapes_collision_area.c +++ b/examples/shapes/shapes_collision_area.c @@ -10,8 +10,12 @@ ********************************************************************************************/ #include "raylib.h" -#include // Required for abs() +#include // Required for: abs() + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_colors_palette.c b/examples/shapes/shapes_colors_palette.c index e9bbad76d..f5fa9b95a 100644 --- a/examples/shapes/shapes_colors_palette.c +++ b/examples/shapes/shapes_colors_palette.c @@ -13,6 +13,9 @@ #define MAX_COLORS_COUNT 21 // Number of colors available +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_draw_circle_sector.c b/examples/shapes/shapes_draw_circle_sector.c index 101c5378e..9b3160b95 100644 --- a/examples/shapes/shapes_draw_circle_sector.c +++ b/examples/shapes/shapes_draw_circle_sector.c @@ -14,8 +14,11 @@ #include #define RAYGUI_IMPLEMENTATION -#include "extras/raygui.h" // Required for GUI controls +#include "raygui.h" // Required for GUI controls +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_draw_rectangle_rounded.c b/examples/shapes/shapes_draw_rectangle_rounded.c index d02b1328f..f8e4aab50 100644 --- a/examples/shapes/shapes_draw_rectangle_rounded.c +++ b/examples/shapes/shapes_draw_rectangle_rounded.c @@ -14,8 +14,11 @@ #include #define RAYGUI_IMPLEMENTATION -#include "extras/raygui.h" // Required for GUI controls +#include "raygui.h" // Required for GUI controls +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_draw_ring.c b/examples/shapes/shapes_draw_ring.c index de97a0145..e7974a7d4 100644 --- a/examples/shapes/shapes_draw_ring.c +++ b/examples/shapes/shapes_draw_ring.c @@ -14,8 +14,11 @@ #include #define RAYGUI_IMPLEMENTATION -#include "extras/raygui.h" // Required for GUI controls +#include "raygui.h" // Required for GUI controls +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_easings_ball_anim.c b/examples/shapes/shapes_easings_ball_anim.c index 7e1d081e1..cebded7e2 100644 --- a/examples/shapes/shapes_easings_ball_anim.c +++ b/examples/shapes/shapes_easings_ball_anim.c @@ -11,8 +11,11 @@ #include "raylib.h" -#include "extras/easings.h" // Required for easing functions +#include "easings.h" // Required for easing functions +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_easings_box_anim.c b/examples/shapes/shapes_easings_box_anim.c index e7024f418..62d051172 100644 --- a/examples/shapes/shapes_easings_box_anim.c +++ b/examples/shapes/shapes_easings_box_anim.c @@ -11,8 +11,11 @@ #include "raylib.h" -#include "extras/easings.h" // Required for easing functions +#include "easings.h" // Required for easing functions +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_easings_rectangle_array.c b/examples/shapes/shapes_easings_rectangle_array.c index bdd459496..70de753d4 100644 --- a/examples/shapes/shapes_easings_rectangle_array.c +++ b/examples/shapes/shapes_easings_rectangle_array.c @@ -14,7 +14,7 @@ #include "raylib.h" -#include "extras/easings.h" // Required for easing functions +#include "easings.h" // Required for easing functions #define RECS_WIDTH 50 #define RECS_HEIGHT 50 @@ -24,6 +24,9 @@ #define PLAY_TIME_IN_FRAMES 240 // At 60 fps = 4 seconds +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_following_eyes.c b/examples/shapes/shapes_following_eyes.c index 9ded4feb5..955121ae8 100644 --- a/examples/shapes/shapes_following_eyes.c +++ b/examples/shapes/shapes_following_eyes.c @@ -13,6 +13,9 @@ #include // Required for: atan2f() +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_lines_bezier.c b/examples/shapes/shapes_lines_bezier.c index 634eb2847..68e5c6a66 100644 --- a/examples/shapes/shapes_lines_bezier.c +++ b/examples/shapes/shapes_lines_bezier.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_logo_raylib.c b/examples/shapes/shapes_logo_raylib.c index 3e2d343f1..bdf105ebd 100644 --- a/examples/shapes/shapes_logo_raylib.c +++ b/examples/shapes/shapes_logo_raylib.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_logo_raylib_anim.c b/examples/shapes/shapes_logo_raylib_anim.c index f91b6c7d3..0cf90b002 100644 --- a/examples/shapes/shapes_logo_raylib_anim.c +++ b/examples/shapes/shapes_logo_raylib_anim.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_rectangle_scaling.c b/examples/shapes/shapes_rectangle_scaling.c index 76b54c093..61154c818 100644 --- a/examples/shapes/shapes_rectangle_scaling.c +++ b/examples/shapes/shapes_rectangle_scaling.c @@ -15,6 +15,9 @@ #define MOUSE_SCALE_MARK_SIZE 12 +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/shapes/shapes_top_down_lights.c b/examples/shapes/shapes_top_down_lights.c index 5234c28c0..74bb2c60b 100644 --- a/examples/shapes/shapes_top_down_lights.c +++ b/examples/shapes/shapes_top_down_lights.c @@ -206,6 +206,9 @@ void SetupBoxes(Rectangle *boxes, int *count) *count = MAX_BOXES; } +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/text/text_draw_3d.c b/examples/text/text_draw_3d.c index a140b1194..d4b057ec4 100644 --- a/examples/text/text_draw_3d.c +++ b/examples/text/text_draw_3d.c @@ -47,7 +47,7 @@ bool SHOW_TEXT_BOUNDRY = false; //-------------------------------------------------------------------------------------- // Configuration structure for waving the text -typedef struct { +typedef struct WaveTextConfig { Vector3 waveRange; Vector3 waveSpeed; Vector3 waveOffset; @@ -57,19 +57,19 @@ typedef struct { // Module Functions Declaration //-------------------------------------------------------------------------------------- // Draw a codepoint in 3D space -void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, float fontSize, bool backface, Color tint); +static void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, float fontSize, bool backface, Color tint); // Draw a 2D text in 3D space -void DrawText3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, Color tint); +static void DrawText3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, Color tint); // Measure a text in 3D. For some reason `MeasureTextEx()` just doesn't seem to work so i had to use this instead. -Vector3 MeasureText3D(Font font, const char* text, float fontSize, float fontSpacing, float lineSpacing); +static Vector3 MeasureText3D(Font font, const char *text, float fontSize, float fontSpacing, float lineSpacing); // Draw a 2D text in 3D space and wave the parts that start with `~~` and end with `~~`. // This is a modified version of the original code by @Nighten found here https://github.com/NightenDushi/Raylib_DrawTextStyle -void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig* config, float time, Color tint); +static void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig *config, float time, Color tint); // Measure a text in 3D ignoring the `~~` chars. -Vector3 MeasureTextWave3D(Font font, const char* text, float fontSize, float fontSpacing, float lineSpacing); +static Vector3 MeasureTextWave3D(Font font, const char *text, float fontSize, float fontSpacing, float lineSpacing); // Generates a nice color with a random hue -Color GenerateRandomColor(float s, float v); +static Color GenerateRandomColor(float s, float v); //------------------------------------------------------------------------------------ // Program main entry point @@ -141,22 +141,22 @@ int main(void) // Handle font files dropped if (IsFileDropped()) { - int count = 0; - char **droppedFiles = GetDroppedFiles(&count); + FilePathList droppedFiles = LoadDroppedFiles(); // NOTE: We only support first ttf file dropped - if (IsFileExtension(droppedFiles[0], ".ttf")) + if (IsFileExtension(droppedFiles.paths[0], ".ttf")) { UnloadFont(font); - font = LoadFontEx(droppedFiles[0], fontSize, 0, 0); + font = LoadFontEx(droppedFiles.paths[0], fontSize, 0, 0); } - else if (IsFileExtension(droppedFiles[0], ".fnt")) + else if (IsFileExtension(droppedFiles.paths[0], ".fnt")) { UnloadFont(font); - font = LoadFont(droppedFiles[0]); + font = LoadFont(droppedFiles.paths[0]); fontSize = font.baseSize; } - ClearDroppedFiles(); + + UnloadDroppedFiles(droppedFiles); // Unload filepaths from memory } // Handle Events @@ -445,7 +445,7 @@ int main(void) // Module Functions Definitions //-------------------------------------------------------------------------------------- // Draw codepoint at specified position in 3D space -void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, float fontSize, bool backface, Color tint) +static void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, float fontSize, bool backface, Color tint) { // Character index position in sprite font // NOTE: In case a codepoint is not available in the font, index returned points to '?' @@ -511,7 +511,8 @@ void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, float fontS } } -void DrawText3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, Color tint) +// Draw a 2D text in 3D space +static void DrawText3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, Color tint) { int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop @@ -553,7 +554,8 @@ void DrawText3D(Font font, const char *text, Vector3 position, float fontSize, f } } -Vector3 MeasureText3D(Font font, const char* text, float fontSize, float fontSpacing, float lineSpacing) +// Measure a text in 3D. For some reason `MeasureTextEx()` just doesn't seem to work so i had to use this instead. +static Vector3 MeasureText3D(Font font, const char* text, float fontSize, float fontSpacing, float lineSpacing) { int len = TextLength(text); int tempLen = 0; // Used to count longer text line num chars @@ -607,8 +609,9 @@ Vector3 MeasureText3D(Font font, const char* text, float fontSize, float fontSpa return vec; } - -void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig* config, float time, Color tint) +// Draw a 2D text in 3D space and wave the parts that start with `~~` and end with `~~`. +// This is a modified version of the original code by @Nighten found here https://github.com/NightenDushi/Raylib_DrawTextStyle +static void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig* config, float time, Color tint) { int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop @@ -669,7 +672,8 @@ void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSiz } } -Vector3 MeasureTextWave3D(Font font, const char* text, float fontSize, float fontSpacing, float lineSpacing) +// Measure a text in 3D ignoring the `~~` chars. +static Vector3 MeasureTextWave3D(Font font, const char* text, float fontSize, float fontSpacing, float lineSpacing) { int len = TextLength(text); int tempLen = 0; // Used to count longer text line num chars @@ -730,7 +734,8 @@ Vector3 MeasureTextWave3D(Font font, const char* text, float fontSize, float fon return vec; } -Color GenerateRandomColor(float s, float v) +// Generates a nice color with a random hue +static Color GenerateRandomColor(float s, float v) { const float Phi = 0.618033988749895f; // Golden ratio conjugate float h = GetRandomValue(0, 360); diff --git a/examples/text/text_font_filters.c b/examples/text/text_font_filters.c index 71213ced9..f9895e16c 100644 --- a/examples/text/text_font_filters.c +++ b/examples/text/text_font_filters.c @@ -15,6 +15,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization @@ -79,16 +82,16 @@ int main(void) // Load a dropped TTF file dynamically (at current fontSize) if (IsFileDropped()) { - int count = 0; - char **droppedFiles = GetDroppedFiles(&count); + FilePathList droppedFiles = LoadDroppedFiles(); // NOTE: We only support first ttf file dropped - if (IsFileExtension(droppedFiles[0], ".ttf")) + if (IsFileExtension(droppedFiles.paths[0], ".ttf")) { UnloadFont(font); - font = LoadFontEx(droppedFiles[0], (int)fontSize, 0, 0); - ClearDroppedFiles(); + font = LoadFontEx(droppedFiles.paths[0], (int)fontSize, 0, 0); } + + UnloadDroppedFiles(droppedFiles); // Unload filepaths from memory } //---------------------------------------------------------------------------------- @@ -123,8 +126,6 @@ int main(void) // De-Initialization //-------------------------------------------------------------------------------------- - ClearDroppedFiles(); // Clear internal buffers - UnloadFont(font); // Font unloading CloseWindow(); // Close window and OpenGL context diff --git a/examples/text/text_font_loading.c b/examples/text/text_font_loading.c index 2f8225db3..629901ad2 100644 --- a/examples/text/text_font_loading.c +++ b/examples/text/text_font_loading.c @@ -20,6 +20,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/text/text_font_sdf.c b/examples/text/text_font_sdf.c index 8a2c0d773..e567d19bd 100644 --- a/examples/text/text_font_sdf.c +++ b/examples/text/text_font_sdf.c @@ -19,6 +19,9 @@ #include +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/text/text_font_spritefont.c b/examples/text/text_font_spritefont.c index 87ce48cf8..9c45f0ed0 100644 --- a/examples/text/text_font_spritefont.c +++ b/examples/text/text_font_spritefont.c @@ -20,6 +20,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/text/text_format_text.c b/examples/text/text_format_text.c index 63408eb94..11a2ed2fa 100644 --- a/examples/text/text_format_text.c +++ b/examples/text/text_format_text.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/text/text_input_box.c b/examples/text/text_input_box.c index 2e7d9a55a..eb136eab4 100644 --- a/examples/text/text_input_box.c +++ b/examples/text/text_input_box.c @@ -13,6 +13,9 @@ #define MAX_INPUT_CHARS 9 +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/text/text_raylib_fonts.c b/examples/text/text_raylib_fonts.c index 7bcfb7f69..988e809ac 100644 --- a/examples/text/text_raylib_fonts.c +++ b/examples/text/text_raylib_fonts.c @@ -16,6 +16,9 @@ #define MAX_FONTS 8 +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/text/text_rectangle_bounds.c b/examples/text/text_rectangle_bounds.c index b4884fb36..728a2b84f 100644 --- a/examples/text/text_rectangle_bounds.c +++ b/examples/text/text_rectangle_bounds.c @@ -16,7 +16,9 @@ static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection -// Main entry point +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/text/text_unicode.c b/examples/text/text_unicode.c index c1521996f..87769372e 100644 --- a/examples/text/text_unicode.c +++ b/examples/text/text_unicode.c @@ -148,9 +148,9 @@ struct { static int hovered = -1, selected = -1; -//-------------------------------------------------------------------------------------- -// Main entry point -//-------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(int argc, char **argv) { // Initialization diff --git a/examples/text/text_writing_anim.c b/examples/text/text_writing_anim.c index 2cf2eaa23..30e6ac42a 100644 --- a/examples/text/text_writing_anim.c +++ b/examples/text/text_writing_anim.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_background_scrolling.c b/examples/textures/textures_background_scrolling.c index c2e5ac80e..aeb2cc255 100644 --- a/examples/textures/textures_background_scrolling.c +++ b/examples/textures/textures_background_scrolling.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_blend_modes.c b/examples/textures/textures_blend_modes.c index 646bceaa4..f451a945d 100644 --- a/examples/textures/textures_blend_modes.c +++ b/examples/textures/textures_blend_modes.c @@ -15,6 +15,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_bunnymark.c b/examples/textures/textures_bunnymark.c index 9be7c5964..15f948800 100644 --- a/examples/textures/textures_bunnymark.c +++ b/examples/textures/textures_bunnymark.c @@ -25,6 +25,9 @@ typedef struct Bunny { Color color; } Bunny; +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_draw_tiled.c b/examples/textures/textures_draw_tiled.c index 42f72d079..9abf8d512 100644 --- a/examples/textures/textures_draw_tiled.c +++ b/examples/textures/textures_draw_tiled.c @@ -15,6 +15,9 @@ #define MARGIN_SIZE 8 // Size for the margins #define COLOR_SIZE 16 // Size of the color select buttons +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(int argc, char **argv) { // Initialization diff --git a/examples/textures/textures_image_drawing.c b/examples/textures/textures_image_drawing.c index 2707746ce..19ed4e990 100644 --- a/examples/textures/textures_image_drawing.c +++ b/examples/textures/textures_image_drawing.c @@ -13,6 +13,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_image_generation.c b/examples/textures/textures_image_generation.c index d138d3c7b..da578997c 100644 --- a/examples/textures/textures_image_generation.c +++ b/examples/textures/textures_image_generation.c @@ -13,6 +13,9 @@ #define NUM_TEXTURES 6 // Currently we have 7 generation algorithms +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_image_loading.c b/examples/textures/textures_image_loading.c index 8babce693..40f007f72 100644 --- a/examples/textures/textures_image_loading.c +++ b/examples/textures/textures_image_loading.c @@ -13,6 +13,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_image_processing.c b/examples/textures/textures_image_processing.c index bb47330b7..dca669dc4 100644 --- a/examples/textures/textures_image_processing.c +++ b/examples/textures/textures_image_processing.c @@ -39,6 +39,9 @@ static const char *processText[] = { "FLIP HORIZONTAL" }; +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_image_text.c b/examples/textures/textures_image_text.c index 7b19cd3ef..5badb09e5 100644 --- a/examples/textures/textures_image_text.c +++ b/examples/textures/textures_image_text.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_logo_raylib.c b/examples/textures/textures_logo_raylib.c index de8bb2aee..12c9ebe2f 100644 --- a/examples/textures/textures_logo_raylib.c +++ b/examples/textures/textures_logo_raylib.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_mouse_painting.c b/examples/textures/textures_mouse_painting.c index 3d6fdf10c..b1e668ce1 100644 --- a/examples/textures/textures_mouse_painting.c +++ b/examples/textures/textures_mouse_painting.c @@ -15,6 +15,9 @@ #define MAX_COLORS_COUNT 23 // Number of colors available +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_npatch_drawing.c b/examples/textures/textures_npatch_drawing.c index 170b992f3..63fc80588 100644 --- a/examples/textures/textures_npatch_drawing.c +++ b/examples/textures/textures_npatch_drawing.c @@ -15,6 +15,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_particles_blending.c b/examples/textures/textures_particles_blending.c index 4d1fbf4c3..9acc67d14 100644 --- a/examples/textures/textures_particles_blending.c +++ b/examples/textures/textures_particles_blending.c @@ -23,6 +23,9 @@ typedef struct { bool active; // NOTE: Use it to activate/deactive particle } Particle; +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_polygon.c b/examples/textures/textures_polygon.c index 9d26505e2..f3f74ae49 100644 --- a/examples/textures/textures_polygon.c +++ b/examples/textures/textures_polygon.c @@ -17,6 +17,9 @@ #define MAX_POINTS 11 // 10 points and back to the start +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_raw_data.c b/examples/textures/textures_raw_data.c index 615e57934..7fb56f2a0 100644 --- a/examples/textures/textures_raw_data.c +++ b/examples/textures/textures_raw_data.c @@ -15,6 +15,9 @@ #include // Required for: malloc() and free() +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_rectangle.c b/examples/textures/textures_rectangle.c index f0d5105ba..eb9f818b5 100644 --- a/examples/textures/textures_rectangle.c +++ b/examples/textures/textures_rectangle.c @@ -14,6 +14,9 @@ #define MAX_FRAME_SPEED 15 #define MIN_FRAME_SPEED 1 +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_sprite_button.c b/examples/textures/textures_sprite_button.c index 3d1a18342..3f654b724 100644 --- a/examples/textures/textures_sprite_button.c +++ b/examples/textures/textures_sprite_button.c @@ -13,6 +13,9 @@ #define NUM_FRAMES 3 // Number of frames (rectangles) for the button sprite texture +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_sprite_explosion.c b/examples/textures/textures_sprite_explosion.c index 10268aa83..2e60f11f9 100644 --- a/examples/textures/textures_sprite_explosion.c +++ b/examples/textures/textures_sprite_explosion.c @@ -14,6 +14,9 @@ #define NUM_FRAMES_PER_LINE 5 #define NUM_LINES 5 +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_srcrec_dstrec.c b/examples/textures/textures_srcrec_dstrec.c index d24ce0cc0..cee38e2fe 100644 --- a/examples/textures/textures_srcrec_dstrec.c +++ b/examples/textures/textures_srcrec_dstrec.c @@ -11,6 +11,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/examples/textures/textures_to_image.c b/examples/textures/textures_to_image.c index fc595b999..dfb7915bd 100644 --- a/examples/textures/textures_to_image.c +++ b/examples/textures/textures_to_image.c @@ -13,6 +13,9 @@ #include "raylib.h" +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ int main(void) { // Initialization diff --git a/parser/Makefile b/parser/Makefile index 9446e2826..e222f4e79 100644 --- a/parser/Makefile +++ b/parser/Makefile @@ -18,11 +18,11 @@ all: parse: ./raylib_parser -i ../src/raylib.h -o raylib_api.$(EXTENSION) -f $(FORMAT) -d RLAPI ./raylib_parser -i ../src/raymath.h -o raymath_api.$(EXTENSION) -f $(FORMAT) -d RMAPI - ./raylib_parser -i ../src/extras/easings.h -o easings_api.$(EXTENSION) -f $(FORMAT) -d EASEDEF - ./raylib_parser -i ../src/extras/physac.h -o physac_api.$(EXTENSION) -f $(FORMAT) -d PHYSACDEF - ./raylib_parser -i ../src/extras/raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIAPI - ./raylib_parser -i ../src/extras/rmem.h -o rmem_api.$(EXTENSION) -f $(FORMAT) -d RMEMAPI - ./raylib_parser -i ../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI + ./raylib_parser -i ../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI -t "RLGL IMPLEMENTATION" + ./raylib_parser -i ../src/easings.h -o easings_api.$(EXTENSION) -f $(FORMAT) -d EASEDEF + ./raylib_parser -i ../src/rmem.h -o rmem_api.$(EXTENSION) -f $(FORMAT) -d RMEMAPI -t "RMEM IMPLEMENTATION" + ./raylib_parser -i ../physac.h -o physac_api.$(EXTENSION) -f $(FORMAT) -d PHYSACDEF -t "PHYSAC IMPLEMENTATION" + ./raylib_parser -i ../raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIAPI -t "RAYGUI IMPLEMENTATION" clean: rm -f raylib_parser *.json *.txt *.xml *.lua diff --git a/parser/raylib_api.json b/parser/raylib_api.json index 5af28c50c..5a6cffe57 100644 --- a/parser/raylib_api.json +++ b/parser/raylib_api.json @@ -1,4 +1,318 @@ { + "defines": [ + { + "name": "RAYLIB_H", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RAYLIB_VERSION", + "type": "STRING", + "value": "4.1-dev", + "description": "" + }, + { + "name": "RLAPI", + "type": "UNKNOWN", + "value": "__declspec(dllexport)", + "description": "We are building the library as a Win32 shared library (.dll)" + }, + { + "name": "PI", + "type": "FLOAT", + "value": 3.14159265358979323846, + "description": "" + }, + { + "name": "DEG2RAD", + "type": "FLOAT_MATH", + "value": "(PI/180.0f)", + "description": "" + }, + { + "name": "RAD2DEG", + "type": "FLOAT_MATH", + "value": "(180.0f/PI)", + "description": "" + }, + { + "name": "RL_MALLOC(sz)", + "type": "MACRO", + "value": "malloc(sz)", + "description": "" + }, + { + "name": "RL_CALLOC(n,sz)", + "type": "MACRO", + "value": "calloc(n,sz)", + "description": "" + }, + { + "name": "RL_REALLOC(ptr,sz)", + "type": "MACRO", + "value": "realloc(ptr,sz)", + "description": "" + }, + { + "name": "RL_FREE(ptr)", + "type": "MACRO", + "value": "free(ptr)", + "description": "" + }, + { + "name": "CLITERAL(type)", + "type": "MACRO", + "value": "type", + "description": "" + }, + { + "name": "RL_COLOR_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_RECTANGLE_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_VECTOR2_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_VECTOR3_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_VECTOR4_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_QUATERNION_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "RL_MATRIX_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "LIGHTGRAY", + "type": "COLOR", + "value": "CLITERAL(Color){ 200, 200, 200, 255 }", + "description": "Light Gray" + }, + { + "name": "GRAY", + "type": "COLOR", + "value": "CLITERAL(Color){ 130, 130, 130, 255 }", + "description": "Gray" + }, + { + "name": "DARKGRAY", + "type": "COLOR", + "value": "CLITERAL(Color){ 80, 80, 80, 255 }", + "description": "Dark Gray" + }, + { + "name": "YELLOW", + "type": "COLOR", + "value": "CLITERAL(Color){ 253, 249, 0, 255 }", + "description": "Yellow" + }, + { + "name": "GOLD", + "type": "COLOR", + "value": "CLITERAL(Color){ 255, 203, 0, 255 }", + "description": "Gold" + }, + { + "name": "ORANGE", + "type": "COLOR", + "value": "CLITERAL(Color){ 255, 161, 0, 255 }", + "description": "Orange" + }, + { + "name": "PINK", + "type": "COLOR", + "value": "CLITERAL(Color){ 255, 109, 194, 255 }", + "description": "Pink" + }, + { + "name": "RED", + "type": "COLOR", + "value": "CLITERAL(Color){ 230, 41, 55, 255 }", + "description": "Red" + }, + { + "name": "MAROON", + "type": "COLOR", + "value": "CLITERAL(Color){ 190, 33, 55, 255 }", + "description": "Maroon" + }, + { + "name": "GREEN", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 228, 48, 255 }", + "description": "Green" + }, + { + "name": "LIME", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 158, 47, 255 }", + "description": "Lime" + }, + { + "name": "DARKGREEN", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 117, 44, 255 }", + "description": "Dark Green" + }, + { + "name": "SKYBLUE", + "type": "COLOR", + "value": "CLITERAL(Color){ 102, 191, 255, 255 }", + "description": "Sky Blue" + }, + { + "name": "BLUE", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 121, 241, 255 }", + "description": "Blue" + }, + { + "name": "DARKBLUE", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 82, 172, 255 }", + "description": "Dark Blue" + }, + { + "name": "PURPLE", + "type": "COLOR", + "value": "CLITERAL(Color){ 200, 122, 255, 255 }", + "description": "Purple" + }, + { + "name": "VIOLET", + "type": "COLOR", + "value": "CLITERAL(Color){ 135, 60, 190, 255 }", + "description": "Violet" + }, + { + "name": "DARKPURPLE", + "type": "COLOR", + "value": "CLITERAL(Color){ 112, 31, 126, 255 }", + "description": "Dark Purple" + }, + { + "name": "BEIGE", + "type": "COLOR", + "value": "CLITERAL(Color){ 211, 176, 131, 255 }", + "description": "Beige" + }, + { + "name": "BROWN", + "type": "COLOR", + "value": "CLITERAL(Color){ 127, 106, 79, 255 }", + "description": "Brown" + }, + { + "name": "DARKBROWN", + "type": "COLOR", + "value": "CLITERAL(Color){ 76, 63, 47, 255 }", + "description": "Dark Brown" + }, + { + "name": "WHITE", + "type": "COLOR", + "value": "CLITERAL(Color){ 255, 255, 255, 255 }", + "description": "White" + }, + { + "name": "BLACK", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 0, 0, 255 }", + "description": "Black" + }, + { + "name": "BLANK", + "type": "COLOR", + "value": "CLITERAL(Color){ 0, 0, 0, 0 }", + "description": "Blank (Transparent)" + }, + { + "name": "MAGENTA", + "type": "COLOR", + "value": "CLITERAL(Color){ 255, 0, 255, 255 }", + "description": "Magenta" + }, + { + "name": "RAYWHITE", + "type": "COLOR", + "value": "CLITERAL(Color){ 245, 245, 245, 255 }", + "description": "My own White (raylib logo)" + }, + { + "name": "RL_BOOL_TYPE", + "type": "GUARD", + "value": "", + "description": "" + }, + { + "name": "MOUSE_LEFT_BUTTON", + "type": "UNKNOWN", + "value": "MOUSE_BUTTON_LEFT", + "description": "" + }, + { + "name": "MOUSE_RIGHT_BUTTON", + "type": "UNKNOWN", + "value": "MOUSE_BUTTON_RIGHT", + "description": "" + }, + { + "name": "MOUSE_MIDDLE_BUTTON", + "type": "UNKNOWN", + "value": "MOUSE_BUTTON_MIDDLE", + "description": "" + }, + { + "name": "MATERIAL_MAP_DIFFUSE", + "type": "UNKNOWN", + "value": "MATERIAL_MAP_ALBEDO", + "description": "" + }, + { + "name": "MATERIAL_MAP_SPECULAR", + "type": "UNKNOWN", + "value": "MATERIAL_MAP_METALNESS", + "description": "" + }, + { + "name": "SHADER_LOC_MAP_DIFFUSE", + "type": "UNKNOWN", + "value": "SHADER_LOC_MAP_ALBEDO", + "description": "" + }, + { + "name": "SHADER_LOC_MAP_SPECULAR", + "type": "UNKNOWN", + "value": "SHADER_LOC_MAP_METALNESS", + "description": "" + } + ], "structs": [ { "name": "Vector2", @@ -69,22 +383,82 @@ "fields": [ { "type": "float", - "name": "m0, m4, m8, m12", + "name": "m0", "description": "Matrix first row (4 components)" }, { "type": "float", - "name": "m1, m5, m9, m13", + "name": "m4", + "description": "Matrix first row (4 components)" + }, + { + "type": "float", + "name": "m8", + "description": "Matrix first row (4 components)" + }, + { + "type": "float", + "name": "m12", + "description": "Matrix first row (4 components)" + }, + { + "type": "float", + "name": "m1", "description": "Matrix second row (4 components)" }, { "type": "float", - "name": "m2, m6, m10, m14", + "name": "m5", + "description": "Matrix second row (4 components)" + }, + { + "type": "float", + "name": "m9", + "description": "Matrix second row (4 components)" + }, + { + "type": "float", + "name": "m13", + "description": "Matrix second row (4 components)" + }, + { + "type": "float", + "name": "m2", "description": "Matrix third row (4 components)" }, { "type": "float", - "name": "m3, m7, m11, m15", + "name": "m6", + "description": "Matrix third row (4 components)" + }, + { + "type": "float", + "name": "m10", + "description": "Matrix third row (4 components)" + }, + { + "type": "float", + "name": "m14", + "description": "Matrix third row (4 components)" + }, + { + "type": "float", + "name": "m3", + "description": "Matrix fourth row (4 components)" + }, + { + "type": "float", + "name": "m7", + "description": "Matrix fourth row (4 components)" + }, + { + "type": "float", + "name": "m11", + "description": "Matrix fourth row (4 components)" + }, + { + "type": "float", + "name": "m15", "description": "Matrix fourth row (4 components)" } ] @@ -411,7 +785,7 @@ { "type": "float *", "name": "texcoords2", - "description": "Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)" + "description": "Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5)" }, { "type": "float *", @@ -517,8 +891,8 @@ "description": "Material maps array (MAX_MATERIAL_MAPS)" }, { - "type": "float", - "name": "params[4]", + "type": "float[4]", + "name": "params", "description": "Material generic parameters (if required)" } ] @@ -549,8 +923,8 @@ "description": "Bone, skeletal animation bone", "fields": [ { - "type": "char", - "name": "name[32]", + "type": "char[32]", + "name": "name", "description": "Bone name" }, { @@ -849,13 +1223,13 @@ "description": "IPD (distance between pupils) in meters" }, { - "type": "float", - "name": "lensDistortionValues[4]", + "type": "float[4]", + "name": "lensDistortionValues", "description": "Lens distortion constant parameters" }, { - "type": "float", - "name": "chromaAbCorrection[4]", + "type": "float[4]", + "name": "chromaAbCorrection", "description": "Chromatic aberration correction parameters" } ] @@ -865,48 +1239,75 @@ "description": "VrStereoConfig, VR stereo rendering configuration for simulator", "fields": [ { - "type": "Matrix", - "name": "projection[2]", + "type": "Matrix[2]", + "name": "projection", "description": "VR projection matrices (per eye)" }, { - "type": "Matrix", - "name": "viewOffset[2]", + "type": "Matrix[2]", + "name": "viewOffset", "description": "VR view offset matrices (per eye)" }, { - "type": "float", - "name": "leftLensCenter[2]", + "type": "float[2]", + "name": "leftLensCenter", "description": "VR left lens center" }, { - "type": "float", - "name": "rightLensCenter[2]", + "type": "float[2]", + "name": "rightLensCenter", "description": "VR right lens center" }, { - "type": "float", - "name": "leftScreenCenter[2]", + "type": "float[2]", + "name": "leftScreenCenter", "description": "VR left screen center" }, { - "type": "float", - "name": "rightScreenCenter[2]", + "type": "float[2]", + "name": "rightScreenCenter", "description": "VR right screen center" }, { - "type": "float", - "name": "scale[2]", + "type": "float[2]", + "name": "scale", "description": "VR distortion scale" }, { - "type": "float", - "name": "scaleIn[2]", + "type": "float[2]", + "name": "scaleIn", "description": "VR distortion scale in" } ] } ], + "aliases": [ + { + "type": "Vector4", + "name": "Quaternion", + "description": "Quaternion, 4 components (Vector4 alias)" + }, + { + "type": "Texture", + "name": "Texture2D", + "description": "Texture2D, same as Texture" + }, + { + "type": "Texture", + "name": "TextureCubemap", + "description": "TextureCubemap, same as Texture" + }, + { + "type": "RenderTexture", + "name": "RenderTexture2D", + "description": "RenderTexture2D, same as RenderTexture" + }, + { + "type": "Camera3D", + "name": "Camera", + "description": "Camera type fallback, defaults to Camera3D" + } + ], "enums": [ { "name": "ConfigFlags", @@ -2495,318 +2896,100 @@ ] } ], - "defines": [ + "callbacks": [ { - "name": "RAYLIB_H", - "type": "GUARD", - "value": "", - "description": "" + "name": "TraceLogCallback", + "description": "Logging: Redirect trace log messages", + "returnType": "void", + "params": [ + { + "type": "int", + "name": "logLevel" + }, + { + "type": "const char *", + "name": "text" + }, + { + "type": "va_list", + "name": "args" + } + ] }, { - "name": "RAYLIB_VERSION", - "type": "STRING", - "value": "4.1-dev", - "description": "" + "name": "LoadFileDataCallback", + "description": "FileIO: Load binary data", + "returnType": "unsigned char *", + "params": [ + { + "type": "const char *", + "name": "fileName" + }, + { + "type": "unsigned int *", + "name": "bytesRead" + } + ] }, { - "name": "RLAPI", - "type": "UNKNOWN", - "value": "__declspec(dllexport)", - "description": "We are building the library as a Win32 shared library (.dll)" + "name": "SaveFileDataCallback", + "description": "FileIO: Save binary data", + "returnType": "bool", + "params": [ + { + "type": "const char *", + "name": "fileName" + }, + { + "type": "void *", + "name": "data" + }, + { + "type": "unsigned int", + "name": "bytesToWrite" + } + ] }, { - "name": "PI", - "type": "FLOAT", - "value": 3.14159265358979323846, - "description": "" + "name": "LoadFileTextCallback", + "description": "FileIO: Load text data", + "returnType": "char *", + "params": [ + { + "type": "const char *", + "name": "fileName" + } + ] }, { - "name": "DEG2RAD", - "type": "UNKNOWN", - "value": "(PI/180.0f)", - "description": "" + "name": "SaveFileTextCallback", + "description": "FileIO: Save text data", + "returnType": "bool", + "params": [ + { + "type": "const char *", + "name": "fileName" + }, + { + "type": "char *", + "name": "text" + } + ] }, { - "name": "RAD2DEG", - "type": "UNKNOWN", - "value": "(180.0f/PI)", - "description": "" - }, - { - "name": "RL_MALLOC(sz)", - "type": "MACRO", - "value": "malloc(sz)", - "description": "" - }, - { - "name": "RL_CALLOC(n,sz)", - "type": "MACRO", - "value": "calloc(n,sz)", - "description": "" - }, - { - "name": "RL_REALLOC(ptr,sz)", - "type": "MACRO", - "value": "realloc(ptr,sz)", - "description": "" - }, - { - "name": "RL_FREE(ptr)", - "type": "MACRO", - "value": "free(ptr)", - "description": "" - }, - { - "name": "CLITERAL(type)", - "type": "MACRO", - "value": "type", - "description": "" - }, - { - "name": "RL_COLOR_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_RECTANGLE_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_VECTOR2_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_VECTOR3_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_VECTOR4_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_QUATERNION_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "RL_MATRIX_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "LIGHTGRAY", - "type": "COLOR", - "value": "CLITERAL(Color){ 200, 200, 200, 255 }", - "description": "Light Gray" - }, - { - "name": "GRAY", - "type": "COLOR", - "value": "CLITERAL(Color){ 130, 130, 130, 255 }", - "description": "Gray" - }, - { - "name": "DARKGRAY", - "type": "COLOR", - "value": "CLITERAL(Color){ 80, 80, 80, 255 }", - "description": "Dark Gray" - }, - { - "name": "YELLOW", - "type": "COLOR", - "value": "CLITERAL(Color){ 253, 249, 0, 255 }", - "description": "Yellow" - }, - { - "name": "GOLD", - "type": "COLOR", - "value": "CLITERAL(Color){ 255, 203, 0, 255 }", - "description": "Gold" - }, - { - "name": "ORANGE", - "type": "COLOR", - "value": "CLITERAL(Color){ 255, 161, 0, 255 }", - "description": "Orange" - }, - { - "name": "PINK", - "type": "COLOR", - "value": "CLITERAL(Color){ 255, 109, 194, 255 }", - "description": "Pink" - }, - { - "name": "RED", - "type": "COLOR", - "value": "CLITERAL(Color){ 230, 41, 55, 255 }", - "description": "Red" - }, - { - "name": "MAROON", - "type": "COLOR", - "value": "CLITERAL(Color){ 190, 33, 55, 255 }", - "description": "Maroon" - }, - { - "name": "GREEN", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 228, 48, 255 }", - "description": "Green" - }, - { - "name": "LIME", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 158, 47, 255 }", - "description": "Lime" - }, - { - "name": "DARKGREEN", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 117, 44, 255 }", - "description": "Dark Green" - }, - { - "name": "SKYBLUE", - "type": "COLOR", - "value": "CLITERAL(Color){ 102, 191, 255, 255 }", - "description": "Sky Blue" - }, - { - "name": "BLUE", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 121, 241, 255 }", - "description": "Blue" - }, - { - "name": "DARKBLUE", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 82, 172, 255 }", - "description": "Dark Blue" - }, - { - "name": "PURPLE", - "type": "COLOR", - "value": "CLITERAL(Color){ 200, 122, 255, 255 }", - "description": "Purple" - }, - { - "name": "VIOLET", - "type": "COLOR", - "value": "CLITERAL(Color){ 135, 60, 190, 255 }", - "description": "Violet" - }, - { - "name": "DARKPURPLE", - "type": "COLOR", - "value": "CLITERAL(Color){ 112, 31, 126, 255 }", - "description": "Dark Purple" - }, - { - "name": "BEIGE", - "type": "COLOR", - "value": "CLITERAL(Color){ 211, 176, 131, 255 }", - "description": "Beige" - }, - { - "name": "BROWN", - "type": "COLOR", - "value": "CLITERAL(Color){ 127, 106, 79, 255 }", - "description": "Brown" - }, - { - "name": "DARKBROWN", - "type": "COLOR", - "value": "CLITERAL(Color){ 76, 63, 47, 255 }", - "description": "Dark Brown" - }, - { - "name": "WHITE", - "type": "COLOR", - "value": "CLITERAL(Color){ 255, 255, 255, 255 }", - "description": "White" - }, - { - "name": "BLACK", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 0, 0, 255 }", - "description": "Black" - }, - { - "name": "BLANK", - "type": "COLOR", - "value": "CLITERAL(Color){ 0, 0, 0, 0 }", - "description": "Blank (Transparent)" - }, - { - "name": "MAGENTA", - "type": "COLOR", - "value": "CLITERAL(Color){ 255, 0, 255, 255 }", - "description": "Magenta" - }, - { - "name": "RAYWHITE", - "type": "COLOR", - "value": "CLITERAL(Color){ 245, 245, 245, 255 }", - "description": "My own White (raylib logo)" - }, - { - "name": "RL_BOOL_TYPE", - "type": "GUARD", - "value": "", - "description": "" - }, - { - "name": "MOUSE_LEFT_BUTTON", - "type": "UNKNOWN", - "value": "MOUSE_BUTTON_LEFT", - "description": "" - }, - { - "name": "MOUSE_RIGHT_BUTTON", - "type": "UNKNOWN", - "value": "MOUSE_BUTTON_RIGHT", - "description": "" - }, - { - "name": "MOUSE_MIDDLE_BUTTON", - "type": "UNKNOWN", - "value": "MOUSE_BUTTON_MIDDLE", - "description": "" - }, - { - "name": "MATERIAL_MAP_DIFFUSE", - "type": "UNKNOWN", - "value": "MATERIAL_MAP_ALBEDO", - "description": "" - }, - { - "name": "MATERIAL_MAP_SPECULAR", - "type": "UNKNOWN", - "value": "MATERIAL_MAP_METALNESS", - "description": "" - }, - { - "name": "SHADER_LOC_MAP_DIFFUSE", - "type": "UNKNOWN", - "value": "SHADER_LOC_MAP_ALBEDO", - "description": "" - }, - { - "name": "SHADER_LOC_MAP_SPECULAR", - "type": "UNKNOWN", - "value": "SHADER_LOC_MAP_METALNESS", - "description": "" + "name": "AudioCallback", + "description": "", + "returnType": "void", + "params": [ + { + "type": "void *", + "name": "bufferData" + }, + { + "type": "unsigned int", + "name": "frames" + } + ] } ], "functions": [ @@ -4029,7 +4212,7 @@ }, { "name": "GetDirectoryFiles", - "description": "Get filenames in a directory path (memory should be freed)", + "description": "Get filenames in a directory path (memory must be freed)", "returnType": "char **", "params": [ { @@ -4065,7 +4248,7 @@ }, { "name": "GetDroppedFiles", - "description": "Get dropped files names (memory should be freed)", + "description": "Get dropped files names (memory must be freed)", "returnType": "char **", "params": [ { @@ -4092,7 +4275,7 @@ }, { "name": "CompressData", - "description": "Compress data (DEFLATE algorithm)", + "description": "Compress data (DEFLATE algorithm), memory must be MemFree()", "returnType": "unsigned char *", "params": [ { @@ -4101,17 +4284,17 @@ }, { "type": "int", - "name": "dataLength" + "name": "dataSize" }, { "type": "int *", - "name": "compDataLength" + "name": "compDataSize" } ] }, { "name": "DecompressData", - "description": "Decompress data (DEFLATE algorithm)", + "description": "Decompress data (DEFLATE algorithm), memory must be MemFree()", "returnType": "unsigned char *", "params": [ { @@ -4120,17 +4303,17 @@ }, { "type": "int", - "name": "compDataLength" + "name": "compDataSize" }, { "type": "int *", - "name": "dataLength" + "name": "dataSize" } ] }, { "name": "EncodeDataBase64", - "description": "Encode data to Base64 string", + "description": "Encode data to Base64 string, memory must be MemFree()", "returnType": "char *", "params": [ { @@ -4139,17 +4322,17 @@ }, { "type": "int", - "name": "dataLength" + "name": "dataSize" }, { "type": "int *", - "name": "outputLength" + "name": "outputSize" } ] }, { "name": "DecodeDataBase64", - "description": "Decode Base64 string data", + "description": "Decode Base64 string data, memory must be MemFree()", "returnType": "unsigned char *", "params": [ { @@ -4158,7 +4341,7 @@ }, { "type": "int *", - "name": "outputLength" + "name": "outputSize" } ] }, diff --git a/parser/raylib_api.lua b/parser/raylib_api.lua index 00c129a38..d4fb9a4d2 100644 --- a/parser/raylib_api.lua +++ b/parser/raylib_api.lua @@ -1,4 +1,318 @@ return { + defines = { + { + name = "RAYLIB_H", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RAYLIB_VERSION", + type = "STRING", + value = "4.1-dev", + description = "" + }, + { + name = "RLAPI", + type = "UNKNOWN", + value = "__declspec(dllexport)", + description = "We are building the library as a Win32 shared library (.dll)" + }, + { + name = "PI", + type = "FLOAT", + value = 3.14159265358979323846, + description = "" + }, + { + name = "DEG2RAD", + type = "FLOAT_MATH", + value = "(PI/180.0f)", + description = "" + }, + { + name = "RAD2DEG", + type = "FLOAT_MATH", + value = "(180.0f/PI)", + description = "" + }, + { + name = "RL_MALLOC(sz)", + type = "MACRO", + value = "malloc(sz)", + description = "" + }, + { + name = "RL_CALLOC(n,sz)", + type = "MACRO", + value = "calloc(n,sz)", + description = "" + }, + { + name = "RL_REALLOC(ptr,sz)", + type = "MACRO", + value = "realloc(ptr,sz)", + description = "" + }, + { + name = "RL_FREE(ptr)", + type = "MACRO", + value = "free(ptr)", + description = "" + }, + { + name = "CLITERAL(type)", + type = "MACRO", + value = "type", + description = "" + }, + { + name = "RL_COLOR_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_RECTANGLE_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_VECTOR2_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_VECTOR3_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_VECTOR4_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_QUATERNION_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "RL_MATRIX_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "LIGHTGRAY", + type = "COLOR", + value = "CLITERAL(Color){ 200, 200, 200, 255 }", + description = "Light Gray" + }, + { + name = "GRAY", + type = "COLOR", + value = "CLITERAL(Color){ 130, 130, 130, 255 }", + description = "Gray" + }, + { + name = "DARKGRAY", + type = "COLOR", + value = "CLITERAL(Color){ 80, 80, 80, 255 }", + description = "Dark Gray" + }, + { + name = "YELLOW", + type = "COLOR", + value = "CLITERAL(Color){ 253, 249, 0, 255 }", + description = "Yellow" + }, + { + name = "GOLD", + type = "COLOR", + value = "CLITERAL(Color){ 255, 203, 0, 255 }", + description = "Gold" + }, + { + name = "ORANGE", + type = "COLOR", + value = "CLITERAL(Color){ 255, 161, 0, 255 }", + description = "Orange" + }, + { + name = "PINK", + type = "COLOR", + value = "CLITERAL(Color){ 255, 109, 194, 255 }", + description = "Pink" + }, + { + name = "RED", + type = "COLOR", + value = "CLITERAL(Color){ 230, 41, 55, 255 }", + description = "Red" + }, + { + name = "MAROON", + type = "COLOR", + value = "CLITERAL(Color){ 190, 33, 55, 255 }", + description = "Maroon" + }, + { + name = "GREEN", + type = "COLOR", + value = "CLITERAL(Color){ 0, 228, 48, 255 }", + description = "Green" + }, + { + name = "LIME", + type = "COLOR", + value = "CLITERAL(Color){ 0, 158, 47, 255 }", + description = "Lime" + }, + { + name = "DARKGREEN", + type = "COLOR", + value = "CLITERAL(Color){ 0, 117, 44, 255 }", + description = "Dark Green" + }, + { + name = "SKYBLUE", + type = "COLOR", + value = "CLITERAL(Color){ 102, 191, 255, 255 }", + description = "Sky Blue" + }, + { + name = "BLUE", + type = "COLOR", + value = "CLITERAL(Color){ 0, 121, 241, 255 }", + description = "Blue" + }, + { + name = "DARKBLUE", + type = "COLOR", + value = "CLITERAL(Color){ 0, 82, 172, 255 }", + description = "Dark Blue" + }, + { + name = "PURPLE", + type = "COLOR", + value = "CLITERAL(Color){ 200, 122, 255, 255 }", + description = "Purple" + }, + { + name = "VIOLET", + type = "COLOR", + value = "CLITERAL(Color){ 135, 60, 190, 255 }", + description = "Violet" + }, + { + name = "DARKPURPLE", + type = "COLOR", + value = "CLITERAL(Color){ 112, 31, 126, 255 }", + description = "Dark Purple" + }, + { + name = "BEIGE", + type = "COLOR", + value = "CLITERAL(Color){ 211, 176, 131, 255 }", + description = "Beige" + }, + { + name = "BROWN", + type = "COLOR", + value = "CLITERAL(Color){ 127, 106, 79, 255 }", + description = "Brown" + }, + { + name = "DARKBROWN", + type = "COLOR", + value = "CLITERAL(Color){ 76, 63, 47, 255 }", + description = "Dark Brown" + }, + { + name = "WHITE", + type = "COLOR", + value = "CLITERAL(Color){ 255, 255, 255, 255 }", + description = "White" + }, + { + name = "BLACK", + type = "COLOR", + value = "CLITERAL(Color){ 0, 0, 0, 255 }", + description = "Black" + }, + { + name = "BLANK", + type = "COLOR", + value = "CLITERAL(Color){ 0, 0, 0, 0 }", + description = "Blank (Transparent)" + }, + { + name = "MAGENTA", + type = "COLOR", + value = "CLITERAL(Color){ 255, 0, 255, 255 }", + description = "Magenta" + }, + { + name = "RAYWHITE", + type = "COLOR", + value = "CLITERAL(Color){ 245, 245, 245, 255 }", + description = "My own White (raylib logo)" + }, + { + name = "RL_BOOL_TYPE", + type = "GUARD", + value = "", + description = "" + }, + { + name = "MOUSE_LEFT_BUTTON", + type = "UNKNOWN", + value = "MOUSE_BUTTON_LEFT", + description = "" + }, + { + name = "MOUSE_RIGHT_BUTTON", + type = "UNKNOWN", + value = "MOUSE_BUTTON_RIGHT", + description = "" + }, + { + name = "MOUSE_MIDDLE_BUTTON", + type = "UNKNOWN", + value = "MOUSE_BUTTON_MIDDLE", + description = "" + }, + { + name = "MATERIAL_MAP_DIFFUSE", + type = "UNKNOWN", + value = "MATERIAL_MAP_ALBEDO", + description = "" + }, + { + name = "MATERIAL_MAP_SPECULAR", + type = "UNKNOWN", + value = "MATERIAL_MAP_METALNESS", + description = "" + }, + { + name = "SHADER_LOC_MAP_DIFFUSE", + type = "UNKNOWN", + value = "SHADER_LOC_MAP_ALBEDO", + description = "" + }, + { + name = "SHADER_LOC_MAP_SPECULAR", + type = "UNKNOWN", + value = "SHADER_LOC_MAP_METALNESS", + description = "" + } + }, structs = { { name = "Vector2", @@ -69,22 +383,82 @@ return { fields = { { type = "float", - name = "m0, m4, m8, m12", + name = "m0", description = "Matrix first row (4 components)" }, { type = "float", - name = "m1, m5, m9, m13", + name = "m4", + description = "Matrix first row (4 components)" + }, + { + type = "float", + name = "m8", + description = "Matrix first row (4 components)" + }, + { + type = "float", + name = "m12", + description = "Matrix first row (4 components)" + }, + { + type = "float", + name = "m1", description = "Matrix second row (4 components)" }, { type = "float", - name = "m2, m6, m10, m14", + name = "m5", + description = "Matrix second row (4 components)" + }, + { + type = "float", + name = "m9", + description = "Matrix second row (4 components)" + }, + { + type = "float", + name = "m13", + description = "Matrix second row (4 components)" + }, + { + type = "float", + name = "m2", description = "Matrix third row (4 components)" }, { type = "float", - name = "m3, m7, m11, m15", + name = "m6", + description = "Matrix third row (4 components)" + }, + { + type = "float", + name = "m10", + description = "Matrix third row (4 components)" + }, + { + type = "float", + name = "m14", + description = "Matrix third row (4 components)" + }, + { + type = "float", + name = "m3", + description = "Matrix fourth row (4 components)" + }, + { + type = "float", + name = "m7", + description = "Matrix fourth row (4 components)" + }, + { + type = "float", + name = "m11", + description = "Matrix fourth row (4 components)" + }, + { + type = "float", + name = "m15", description = "Matrix fourth row (4 components)" } } @@ -411,7 +785,7 @@ return { { type = "float *", name = "texcoords2", - description = "Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)" + description = "Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5)" }, { type = "float *", @@ -517,8 +891,8 @@ return { description = "Material maps array (MAX_MATERIAL_MAPS)" }, { - type = "float", - name = "params[4]", + type = "float[4]", + name = "params", description = "Material generic parameters (if required)" } } @@ -549,8 +923,8 @@ return { description = "Bone, skeletal animation bone", fields = { { - type = "char", - name = "name[32]", + type = "char[32]", + name = "name", description = "Bone name" }, { @@ -849,13 +1223,13 @@ return { description = "IPD (distance between pupils) in meters" }, { - type = "float", - name = "lensDistortionValues[4]", + type = "float[4]", + name = "lensDistortionValues", description = "Lens distortion constant parameters" }, { - type = "float", - name = "chromaAbCorrection[4]", + type = "float[4]", + name = "chromaAbCorrection", description = "Chromatic aberration correction parameters" } } @@ -865,48 +1239,75 @@ return { description = "VrStereoConfig, VR stereo rendering configuration for simulator", fields = { { - type = "Matrix", - name = "projection[2]", + type = "Matrix[2]", + name = "projection", description = "VR projection matrices (per eye)" }, { - type = "Matrix", - name = "viewOffset[2]", + type = "Matrix[2]", + name = "viewOffset", description = "VR view offset matrices (per eye)" }, { - type = "float", - name = "leftLensCenter[2]", + type = "float[2]", + name = "leftLensCenter", description = "VR left lens center" }, { - type = "float", - name = "rightLensCenter[2]", + type = "float[2]", + name = "rightLensCenter", description = "VR right lens center" }, { - type = "float", - name = "leftScreenCenter[2]", + type = "float[2]", + name = "leftScreenCenter", description = "VR left screen center" }, { - type = "float", - name = "rightScreenCenter[2]", + type = "float[2]", + name = "rightScreenCenter", description = "VR right screen center" }, { - type = "float", - name = "scale[2]", + type = "float[2]", + name = "scale", description = "VR distortion scale" }, { - type = "float", - name = "scaleIn[2]", + type = "float[2]", + name = "scaleIn", description = "VR distortion scale in" } } } }, + aliases = { + { + type = "Vector4", + name = "Quaternion", + description = "Quaternion, 4 components (Vector4 alias)" + }, + { + type = "Texture", + name = "Texture2D", + description = "Texture2D, same as Texture" + }, + { + type = "Texture", + name = "TextureCubemap", + description = "TextureCubemap, same as Texture" + }, + { + type = "RenderTexture", + name = "RenderTexture2D", + description = "RenderTexture2D, same as RenderTexture" + }, + { + type = "Camera3D", + name = "Camera", + description = "Camera type fallback, defaults to Camera3D" + } + }, enums = { { name = "ConfigFlags", @@ -2495,318 +2896,61 @@ return { } } }, - defines = { + callbacks = { { - name = "RAYLIB_H", - type = "GUARD", - value = "", - description = "" + name = "TraceLogCallback", + description = "Logging: Redirect trace log messages", + returnType = "void", + params = { + {type = "int", name = "logLevel"}, + {type = "const char *", name = "text"}, + {type = "va_list", name = "args"} + } }, { - name = "RAYLIB_VERSION", - type = "STRING", - value = "4.1-dev", - description = "" + name = "LoadFileDataCallback", + description = "FileIO: Load binary data", + returnType = "unsigned char *", + params = { + {type = "const char *", name = "fileName"}, + {type = "unsigned int *", name = "bytesRead"} + } }, { - name = "RLAPI", - type = "UNKNOWN", - value = "__declspec(dllexport)", - description = "We are building the library as a Win32 shared library (.dll)" + name = "SaveFileDataCallback", + description = "FileIO: Save binary data", + returnType = "bool", + params = { + {type = "const char *", name = "fileName"}, + {type = "void *", name = "data"}, + {type = "unsigned int", name = "bytesToWrite"} + } }, { - name = "PI", - type = "FLOAT", - value = 3.14159265358979323846, - description = "" + name = "LoadFileTextCallback", + description = "FileIO: Load text data", + returnType = "char *", + params = { + {type = "const char *", name = "fileName"} + } }, { - name = "DEG2RAD", - type = "UNKNOWN", - value = "(PI/180.0f)", - description = "" + name = "SaveFileTextCallback", + description = "FileIO: Save text data", + returnType = "bool", + params = { + {type = "const char *", name = "fileName"}, + {type = "char *", name = "text"} + } }, { - name = "RAD2DEG", - type = "UNKNOWN", - value = "(180.0f/PI)", - description = "" - }, - { - name = "RL_MALLOC(sz)", - type = "MACRO", - value = "malloc(sz)", - description = "" - }, - { - name = "RL_CALLOC(n,sz)", - type = "MACRO", - value = "calloc(n,sz)", - description = "" - }, - { - name = "RL_REALLOC(ptr,sz)", - type = "MACRO", - value = "realloc(ptr,sz)", - description = "" - }, - { - name = "RL_FREE(ptr)", - type = "MACRO", - value = "free(ptr)", - description = "" - }, - { - name = "CLITERAL(type)", - type = "MACRO", - value = "type", - description = "" - }, - { - name = "RL_COLOR_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_RECTANGLE_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_VECTOR2_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_VECTOR3_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_VECTOR4_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_QUATERNION_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "RL_MATRIX_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "LIGHTGRAY", - type = "COLOR", - value = "CLITERAL(Color){ 200, 200, 200, 255 }", - description = "Light Gray" - }, - { - name = "GRAY", - type = "COLOR", - value = "CLITERAL(Color){ 130, 130, 130, 255 }", - description = "Gray" - }, - { - name = "DARKGRAY", - type = "COLOR", - value = "CLITERAL(Color){ 80, 80, 80, 255 }", - description = "Dark Gray" - }, - { - name = "YELLOW", - type = "COLOR", - value = "CLITERAL(Color){ 253, 249, 0, 255 }", - description = "Yellow" - }, - { - name = "GOLD", - type = "COLOR", - value = "CLITERAL(Color){ 255, 203, 0, 255 }", - description = "Gold" - }, - { - name = "ORANGE", - type = "COLOR", - value = "CLITERAL(Color){ 255, 161, 0, 255 }", - description = "Orange" - }, - { - name = "PINK", - type = "COLOR", - value = "CLITERAL(Color){ 255, 109, 194, 255 }", - description = "Pink" - }, - { - name = "RED", - type = "COLOR", - value = "CLITERAL(Color){ 230, 41, 55, 255 }", - description = "Red" - }, - { - name = "MAROON", - type = "COLOR", - value = "CLITERAL(Color){ 190, 33, 55, 255 }", - description = "Maroon" - }, - { - name = "GREEN", - type = "COLOR", - value = "CLITERAL(Color){ 0, 228, 48, 255 }", - description = "Green" - }, - { - name = "LIME", - type = "COLOR", - value = "CLITERAL(Color){ 0, 158, 47, 255 }", - description = "Lime" - }, - { - name = "DARKGREEN", - type = "COLOR", - value = "CLITERAL(Color){ 0, 117, 44, 255 }", - description = "Dark Green" - }, - { - name = "SKYBLUE", - type = "COLOR", - value = "CLITERAL(Color){ 102, 191, 255, 255 }", - description = "Sky Blue" - }, - { - name = "BLUE", - type = "COLOR", - value = "CLITERAL(Color){ 0, 121, 241, 255 }", - description = "Blue" - }, - { - name = "DARKBLUE", - type = "COLOR", - value = "CLITERAL(Color){ 0, 82, 172, 255 }", - description = "Dark Blue" - }, - { - name = "PURPLE", - type = "COLOR", - value = "CLITERAL(Color){ 200, 122, 255, 255 }", - description = "Purple" - }, - { - name = "VIOLET", - type = "COLOR", - value = "CLITERAL(Color){ 135, 60, 190, 255 }", - description = "Violet" - }, - { - name = "DARKPURPLE", - type = "COLOR", - value = "CLITERAL(Color){ 112, 31, 126, 255 }", - description = "Dark Purple" - }, - { - name = "BEIGE", - type = "COLOR", - value = "CLITERAL(Color){ 211, 176, 131, 255 }", - description = "Beige" - }, - { - name = "BROWN", - type = "COLOR", - value = "CLITERAL(Color){ 127, 106, 79, 255 }", - description = "Brown" - }, - { - name = "DARKBROWN", - type = "COLOR", - value = "CLITERAL(Color){ 76, 63, 47, 255 }", - description = "Dark Brown" - }, - { - name = "WHITE", - type = "COLOR", - value = "CLITERAL(Color){ 255, 255, 255, 255 }", - description = "White" - }, - { - name = "BLACK", - type = "COLOR", - value = "CLITERAL(Color){ 0, 0, 0, 255 }", - description = "Black" - }, - { - name = "BLANK", - type = "COLOR", - value = "CLITERAL(Color){ 0, 0, 0, 0 }", - description = "Blank (Transparent)" - }, - { - name = "MAGENTA", - type = "COLOR", - value = "CLITERAL(Color){ 255, 0, 255, 255 }", - description = "Magenta" - }, - { - name = "RAYWHITE", - type = "COLOR", - value = "CLITERAL(Color){ 245, 245, 245, 255 }", - description = "My own White (raylib logo)" - }, - { - name = "RL_BOOL_TYPE", - type = "GUARD", - value = "", - description = "" - }, - { - name = "MOUSE_LEFT_BUTTON", - type = "UNKNOWN", - value = "MOUSE_BUTTON_LEFT", - description = "" - }, - { - name = "MOUSE_RIGHT_BUTTON", - type = "UNKNOWN", - value = "MOUSE_BUTTON_RIGHT", - description = "" - }, - { - name = "MOUSE_MIDDLE_BUTTON", - type = "UNKNOWN", - value = "MOUSE_BUTTON_MIDDLE", - description = "" - }, - { - name = "MATERIAL_MAP_DIFFUSE", - type = "UNKNOWN", - value = "MATERIAL_MAP_ALBEDO", - description = "" - }, - { - name = "MATERIAL_MAP_SPECULAR", - type = "UNKNOWN", - value = "MATERIAL_MAP_METALNESS", - description = "" - }, - { - name = "SHADER_LOC_MAP_DIFFUSE", - type = "UNKNOWN", - value = "SHADER_LOC_MAP_ALBEDO", - description = "" - }, - { - name = "SHADER_LOC_MAP_SPECULAR", - type = "UNKNOWN", - value = "SHADER_LOC_MAP_METALNESS", - description = "" + name = "AudioCallback", + description = "", + returnType = "void", + params = { + {type = "void *", name = "bufferData"}, + {type = "unsigned int", name = "frames"} + } } }, functions = { @@ -3684,7 +3828,7 @@ return { }, { name = "GetDirectoryFiles", - description = "Get filenames in a directory path (memory should be freed)", + description = "Get filenames in a directory path (memory must be freed)", returnType = "char **", params = { {type = "const char *", name = "dirPath"}, @@ -3711,7 +3855,7 @@ return { }, { name = "GetDroppedFiles", - description = "Get dropped files names (memory should be freed)", + description = "Get dropped files names (memory must be freed)", returnType = "char **", params = { {type = "int *", name = "count"} @@ -3732,41 +3876,41 @@ return { }, { name = "CompressData", - description = "Compress data (DEFLATE algorithm)", + description = "Compress data (DEFLATE algorithm), memory must be MemFree()", returnType = "unsigned char *", params = { {type = "const unsigned char *", name = "data"}, - {type = "int", name = "dataLength"}, - {type = "int *", name = "compDataLength"} + {type = "int", name = "dataSize"}, + {type = "int *", name = "compDataSize"} } }, { name = "DecompressData", - description = "Decompress data (DEFLATE algorithm)", + description = "Decompress data (DEFLATE algorithm), memory must be MemFree()", returnType = "unsigned char *", params = { {type = "const unsigned char *", name = "compData"}, - {type = "int", name = "compDataLength"}, - {type = "int *", name = "dataLength"} + {type = "int", name = "compDataSize"}, + {type = "int *", name = "dataSize"} } }, { name = "EncodeDataBase64", - description = "Encode data to Base64 string", + description = "Encode data to Base64 string, memory must be MemFree()", returnType = "char *", params = { {type = "const unsigned char *", name = "data"}, - {type = "int", name = "dataLength"}, - {type = "int *", name = "outputLength"} + {type = "int", name = "dataSize"}, + {type = "int *", name = "outputSize"} } }, { name = "DecodeDataBase64", - description = "Decode Base64 string data", + description = "Decode Base64 string data, memory must be MemFree()", returnType = "unsigned char *", params = { {type = "const unsigned char *", name = "data"}, - {type = "int *", name = "outputLength"} + {type = "int *", name = "outputSize"} } }, { diff --git a/parser/raylib_api.txt b/parser/raylib_api.txt index 78ec6bb93..18ef8aff2 100644 --- a/parser/raylib_api.txt +++ b/parser/raylib_api.txt @@ -1,4 +1,267 @@ +Defines found: 52 + +Define 001: RAYLIB_H + Name: RAYLIB_H + Type: GUARD + Value: + Description: +Define 002: RAYLIB_VERSION + Name: RAYLIB_VERSION + Type: STRING + Value: "4.1-dev" + Description: +Define 003: RLAPI + Name: RLAPI + Type: UNKNOWN + Value: __declspec(dllexport) + Description: We are building the library as a Win32 shared library (.dll) +Define 004: PI + Name: PI + Type: FLOAT + Value: 3.14159265358979323846 + Description: +Define 005: DEG2RAD + Name: DEG2RAD + Type: FLOAT_MATH + Value: (PI/180.0f) + Description: +Define 006: RAD2DEG + Name: RAD2DEG + Type: FLOAT_MATH + Value: (180.0f/PI) + Description: +Define 007: RL_MALLOC(sz) + Name: RL_MALLOC(sz) + Type: MACRO + Value: malloc(sz) + Description: +Define 008: RL_CALLOC(n,sz) + Name: RL_CALLOC(n,sz) + Type: MACRO + Value: calloc(n,sz) + Description: +Define 009: RL_REALLOC(ptr,sz) + Name: RL_REALLOC(ptr,sz) + Type: MACRO + Value: realloc(ptr,sz) + Description: +Define 010: RL_FREE(ptr) + Name: RL_FREE(ptr) + Type: MACRO + Value: free(ptr) + Description: +Define 011: CLITERAL(type) + Name: CLITERAL(type) + Type: MACRO + Value: type + Description: +Define 012: RL_COLOR_TYPE + Name: RL_COLOR_TYPE + Type: GUARD + Value: + Description: +Define 013: RL_RECTANGLE_TYPE + Name: RL_RECTANGLE_TYPE + Type: GUARD + Value: + Description: +Define 014: RL_VECTOR2_TYPE + Name: RL_VECTOR2_TYPE + Type: GUARD + Value: + Description: +Define 015: RL_VECTOR3_TYPE + Name: RL_VECTOR3_TYPE + Type: GUARD + Value: + Description: +Define 016: RL_VECTOR4_TYPE + Name: RL_VECTOR4_TYPE + Type: GUARD + Value: + Description: +Define 017: RL_QUATERNION_TYPE + Name: RL_QUATERNION_TYPE + Type: GUARD + Value: + Description: +Define 018: RL_MATRIX_TYPE + Name: RL_MATRIX_TYPE + Type: GUARD + Value: + Description: +Define 019: LIGHTGRAY + Name: LIGHTGRAY + Type: COLOR + Value: CLITERAL(Color){ 200, 200, 200, 255 } + Description: Light Gray +Define 020: GRAY + Name: GRAY + Type: COLOR + Value: CLITERAL(Color){ 130, 130, 130, 255 } + Description: Gray +Define 021: DARKGRAY + Name: DARKGRAY + Type: COLOR + Value: CLITERAL(Color){ 80, 80, 80, 255 } + Description: Dark Gray +Define 022: YELLOW + Name: YELLOW + Type: COLOR + Value: CLITERAL(Color){ 253, 249, 0, 255 } + Description: Yellow +Define 023: GOLD + Name: GOLD + Type: COLOR + Value: CLITERAL(Color){ 255, 203, 0, 255 } + Description: Gold +Define 024: ORANGE + Name: ORANGE + Type: COLOR + Value: CLITERAL(Color){ 255, 161, 0, 255 } + Description: Orange +Define 025: PINK + Name: PINK + Type: COLOR + Value: CLITERAL(Color){ 255, 109, 194, 255 } + Description: Pink +Define 026: RED + Name: RED + Type: COLOR + Value: CLITERAL(Color){ 230, 41, 55, 255 } + Description: Red +Define 027: MAROON + Name: MAROON + Type: COLOR + Value: CLITERAL(Color){ 190, 33, 55, 255 } + Description: Maroon +Define 028: GREEN + Name: GREEN + Type: COLOR + Value: CLITERAL(Color){ 0, 228, 48, 255 } + Description: Green +Define 029: LIME + Name: LIME + Type: COLOR + Value: CLITERAL(Color){ 0, 158, 47, 255 } + Description: Lime +Define 030: DARKGREEN + Name: DARKGREEN + Type: COLOR + Value: CLITERAL(Color){ 0, 117, 44, 255 } + Description: Dark Green +Define 031: SKYBLUE + Name: SKYBLUE + Type: COLOR + Value: CLITERAL(Color){ 102, 191, 255, 255 } + Description: Sky Blue +Define 032: BLUE + Name: BLUE + Type: COLOR + Value: CLITERAL(Color){ 0, 121, 241, 255 } + Description: Blue +Define 033: DARKBLUE + Name: DARKBLUE + Type: COLOR + Value: CLITERAL(Color){ 0, 82, 172, 255 } + Description: Dark Blue +Define 034: PURPLE + Name: PURPLE + Type: COLOR + Value: CLITERAL(Color){ 200, 122, 255, 255 } + Description: Purple +Define 035: VIOLET + Name: VIOLET + Type: COLOR + Value: CLITERAL(Color){ 135, 60, 190, 255 } + Description: Violet +Define 036: DARKPURPLE + Name: DARKPURPLE + Type: COLOR + Value: CLITERAL(Color){ 112, 31, 126, 255 } + Description: Dark Purple +Define 037: BEIGE + Name: BEIGE + Type: COLOR + Value: CLITERAL(Color){ 211, 176, 131, 255 } + Description: Beige +Define 038: BROWN + Name: BROWN + Type: COLOR + Value: CLITERAL(Color){ 127, 106, 79, 255 } + Description: Brown +Define 039: DARKBROWN + Name: DARKBROWN + Type: COLOR + Value: CLITERAL(Color){ 76, 63, 47, 255 } + Description: Dark Brown +Define 040: WHITE + Name: WHITE + Type: COLOR + Value: CLITERAL(Color){ 255, 255, 255, 255 } + Description: White +Define 041: BLACK + Name: BLACK + Type: COLOR + Value: CLITERAL(Color){ 0, 0, 0, 255 } + Description: Black +Define 042: BLANK + Name: BLANK + Type: COLOR + Value: CLITERAL(Color){ 0, 0, 0, 0 } + Description: Blank (Transparent) +Define 043: MAGENTA + Name: MAGENTA + Type: COLOR + Value: CLITERAL(Color){ 255, 0, 255, 255 } + Description: Magenta +Define 044: RAYWHITE + Name: RAYWHITE + Type: COLOR + Value: CLITERAL(Color){ 245, 245, 245, 255 } + Description: My own White (raylib logo) +Define 045: RL_BOOL_TYPE + Name: RL_BOOL_TYPE + Type: GUARD + Value: + Description: +Define 046: MOUSE_LEFT_BUTTON + Name: MOUSE_LEFT_BUTTON + Type: UNKNOWN + Value: MOUSE_BUTTON_LEFT + Description: +Define 047: MOUSE_RIGHT_BUTTON + Name: MOUSE_RIGHT_BUTTON + Type: UNKNOWN + Value: MOUSE_BUTTON_RIGHT + Description: +Define 048: MOUSE_MIDDLE_BUTTON + Name: MOUSE_MIDDLE_BUTTON + Type: UNKNOWN + Value: MOUSE_BUTTON_MIDDLE + Description: +Define 049: MATERIAL_MAP_DIFFUSE + Name: MATERIAL_MAP_DIFFUSE + Type: UNKNOWN + Value: MATERIAL_MAP_ALBEDO + Description: +Define 050: MATERIAL_MAP_SPECULAR + Name: MATERIAL_MAP_SPECULAR + Type: UNKNOWN + Value: MATERIAL_MAP_METALNESS + Description: +Define 051: SHADER_LOC_MAP_DIFFUSE + Name: SHADER_LOC_MAP_DIFFUSE + Type: UNKNOWN + Value: SHADER_LOC_MAP_ALBEDO + Description: +Define 052: SHADER_LOC_MAP_SPECULAR + Name: SHADER_LOC_MAP_SPECULAR + Type: UNKNOWN + Value: SHADER_LOC_MAP_METALNESS + Description: + Structures found: 31 Struct 01: Vector2 (2 fields) @@ -19,13 +282,25 @@ Struct 03: Vector4 (4 fields) Field[2]: float y // Vector y component Field[3]: float z // Vector z component Field[4]: float w // Vector w component -Struct 04: Matrix (4 fields) +Struct 04: Matrix (16 fields) Name: Matrix Description: Matrix, 4x4 components, column major, OpenGL style, right handed - Field[1]: float m0, m4, m8, m12 // Matrix first row (4 components) - Field[2]: float m1, m5, m9, m13 // Matrix second row (4 components) - Field[3]: float m2, m6, m10, m14 // Matrix third row (4 components) - Field[4]: float m3, m7, m11, m15 // Matrix fourth row (4 components) + Field[1]: float m0 // Matrix first row (4 components) + Field[2]: float m4 // Matrix first row (4 components) + Field[3]: float m8 // Matrix first row (4 components) + Field[4]: float m12 // Matrix first row (4 components) + Field[5]: float m1 // Matrix second row (4 components) + Field[6]: float m5 // Matrix second row (4 components) + Field[7]: float m9 // Matrix second row (4 components) + Field[8]: float m13 // Matrix second row (4 components) + Field[9]: float m2 // Matrix third row (4 components) + Field[10]: float m6 // Matrix third row (4 components) + Field[11]: float m10 // Matrix third row (4 components) + Field[12]: float m14 // Matrix third row (4 components) + Field[13]: float m3 // Matrix fourth row (4 components) + Field[14]: float m7 // Matrix fourth row (4 components) + Field[15]: float m11 // Matrix fourth row (4 components) + Field[16]: float m15 // Matrix fourth row (4 components) Struct 05: Color (4 fields) Name: Color Description: Color, 4 components, R8G8B8A8 (32bit) @@ -110,7 +385,7 @@ Struct 15: Mesh (15 fields) Field[2]: int triangleCount // Number of triangles stored (indexed or not) Field[3]: float * vertices // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) Field[4]: float * texcoords // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) - Field[5]: float * texcoords2 // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5) + Field[5]: float * texcoords2 // Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5) Field[6]: float * normals // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) Field[7]: float * tangents // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) Field[8]: unsigned char * colors // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) @@ -137,7 +412,7 @@ Struct 18: Material (3 fields) Description: Material, includes shader and maps Field[1]: Shader shader // Material shader Field[2]: MaterialMap * maps // Material maps array (MAX_MATERIAL_MAPS) - Field[3]: float params[4] // Material generic parameters (if required) + Field[3]: float[4] params // Material generic parameters (if required) Struct 19: Transform (3 fields) Name: Transform Description: Transform, vectex transformation data @@ -147,7 +422,7 @@ Struct 19: Transform (3 fields) Struct 20: BoneInfo (2 fields) Name: BoneInfo Description: Bone, skeletal animation bone - Field[1]: char name[32] // Bone name + Field[1]: char[32] name // Bone name Field[2]: int parent // Bone parent Struct 21: Model (9 fields) Name: Model @@ -225,19 +500,42 @@ Struct 30: VrDeviceInfo (10 fields) Field[6]: float eyeToScreenDistance // Distance between eye and display in meters Field[7]: float lensSeparationDistance // Lens separation distance in meters Field[8]: float interpupillaryDistance // IPD (distance between pupils) in meters - Field[9]: float lensDistortionValues[4] // Lens distortion constant parameters - Field[10]: float chromaAbCorrection[4] // Chromatic aberration correction parameters + Field[9]: float[4] lensDistortionValues // Lens distortion constant parameters + Field[10]: float[4] chromaAbCorrection // Chromatic aberration correction parameters Struct 31: VrStereoConfig (8 fields) Name: VrStereoConfig Description: VrStereoConfig, VR stereo rendering configuration for simulator - Field[1]: Matrix projection[2] // VR projection matrices (per eye) - Field[2]: Matrix viewOffset[2] // VR view offset matrices (per eye) - Field[3]: float leftLensCenter[2] // VR left lens center - Field[4]: float rightLensCenter[2] // VR right lens center - Field[5]: float leftScreenCenter[2] // VR left screen center - Field[6]: float rightScreenCenter[2] // VR right screen center - Field[7]: float scale[2] // VR distortion scale - Field[8]: float scaleIn[2] // VR distortion scale in + Field[1]: Matrix[2] projection // VR projection matrices (per eye) + Field[2]: Matrix[2] viewOffset // VR view offset matrices (per eye) + Field[3]: float[2] leftLensCenter // VR left lens center + Field[4]: float[2] rightLensCenter // VR right lens center + Field[5]: float[2] leftScreenCenter // VR left screen center + Field[6]: float[2] rightScreenCenter // VR right screen center + Field[7]: float[2] scale // VR distortion scale + Field[8]: float[2] scaleIn // VR distortion scale in + +Aliases found: 5 + +Alias 001: Quaternion + Type: Vector4 + Name: Quaternion + Description: Quaternion, 4 components (Vector4 alias) +Alias 002: Texture2D + Type: Texture + Name: Texture2D + Description: Texture2D, same as Texture +Alias 003: TextureCubemap + Type: Texture + Name: TextureCubemap + Description: TextureCubemap, same as Texture +Alias 004: RenderTexture2D + Type: RenderTexture + Name: RenderTexture2D + Description: RenderTexture2D, same as RenderTexture +Alias 005: Camera + Type: Camera3D + Name: Camera + Description: Camera type fallback, defaults to Camera3D Enums found: 21 @@ -597,6 +895,46 @@ Enum 21: NPatchLayout (3 values) Value[NPATCH_THREE_PATCH_VERTICAL]: 1 Value[NPATCH_THREE_PATCH_HORIZONTAL]: 2 +Callbacks found: 6 + +Callback 001: TraceLogCallback() (3 input parameters) + Name: TraceLogCallback + Return type: void + Description: Logging: Redirect trace log messages + Param[1]: logLevel (type: int) + Param[2]: text (type: const char *) + Param[3]: args (type: va_list) +Callback 002: LoadFileDataCallback() (2 input parameters) + Name: LoadFileDataCallback + Return type: unsigned char * + Description: FileIO: Load binary data + Param[1]: fileName (type: const char *) + Param[2]: bytesRead (type: unsigned int *) +Callback 003: SaveFileDataCallback() (3 input parameters) + Name: SaveFileDataCallback + Return type: bool + Description: FileIO: Save binary data + Param[1]: fileName (type: const char *) + Param[2]: data (type: void *) + Param[3]: bytesToWrite (type: unsigned int) +Callback 004: LoadFileTextCallback() (1 input parameters) + Name: LoadFileTextCallback + Return type: char * + Description: FileIO: Load text data + Param[1]: fileName (type: const char *) +Callback 005: SaveFileTextCallback() (2 input parameters) + Name: SaveFileTextCallback + Return type: bool + Description: FileIO: Save text data + Param[1]: fileName (type: const char *) + Param[2]: text (type: char *) +Callback 006: AudioCallback() (2 input parameters) + Name: AudioCallback + Return type: void + Description: + Param[1]: bufferData (type: void *) + Param[2]: frames (type: unsigned int) + Functions found: 499 Function 001: InitWindow() (3 input parameters) @@ -1246,7 +1584,7 @@ Function 121: GetApplicationDirectory() (0 input parameters) Function 122: GetDirectoryFiles() (2 input parameters) Name: GetDirectoryFiles Return type: char ** - Description: Get filenames in a directory path (memory should be freed) + Description: Get filenames in a directory path (memory must be freed) Param[1]: dirPath (type: const char *) Param[2]: count (type: int *) Function 123: ClearDirectoryFiles() (0 input parameters) @@ -1267,7 +1605,7 @@ Function 125: IsFileDropped() (0 input parameters) Function 126: GetDroppedFiles() (1 input parameters) Name: GetDroppedFiles Return type: char ** - Description: Get dropped files names (memory should be freed) + Description: Get dropped files names (memory must be freed) Param[1]: count (type: int *) Function 127: ClearDroppedFiles() (0 input parameters) Name: ClearDroppedFiles @@ -1282,30 +1620,30 @@ Function 128: GetFileModTime() (1 input parameters) Function 129: CompressData() (3 input parameters) Name: CompressData Return type: unsigned char * - Description: Compress data (DEFLATE algorithm) + Description: Compress data (DEFLATE algorithm), memory must be MemFree() Param[1]: data (type: const unsigned char *) - Param[2]: dataLength (type: int) - Param[3]: compDataLength (type: int *) + Param[2]: dataSize (type: int) + Param[3]: compDataSize (type: int *) Function 130: DecompressData() (3 input parameters) Name: DecompressData Return type: unsigned char * - Description: Decompress data (DEFLATE algorithm) + Description: Decompress data (DEFLATE algorithm), memory must be MemFree() Param[1]: compData (type: const unsigned char *) - Param[2]: compDataLength (type: int) - Param[3]: dataLength (type: int *) + Param[2]: compDataSize (type: int) + Param[3]: dataSize (type: int *) Function 131: EncodeDataBase64() (3 input parameters) Name: EncodeDataBase64 Return type: char * - Description: Encode data to Base64 string + Description: Encode data to Base64 string, memory must be MemFree() Param[1]: data (type: const unsigned char *) - Param[2]: dataLength (type: int) - Param[3]: outputLength (type: int *) + Param[2]: dataSize (type: int) + Param[3]: outputSize (type: int *) Function 132: DecodeDataBase64() (2 input parameters) Name: DecodeDataBase64 Return type: unsigned char * - Description: Decode Base64 string data + Description: Decode Base64 string data, memory must be MemFree() Param[1]: data (type: const unsigned char *) - Param[2]: outputLength (type: int *) + Param[2]: outputSize (type: int *) Function 133: SaveStorageValue() (2 input parameters) Name: SaveStorageValue Return type: bool @@ -3746,266 +4084,3 @@ Function 499: DetachAudioStreamProcessor() (2 input parameters) Description: Param[1]: stream (type: AudioStream) Param[2]: processor (type: AudioCallback) - -Defines found: 52 - -Define 001: RAYLIB_H - Name: RAYLIB_H - Type: GUARD - Value: - Description: -Define 002: RAYLIB_VERSION - Name: RAYLIB_VERSION - Type: STRING - Value: "4.1-dev" - Description: -Define 003: RLAPI - Name: RLAPI - Type: UNKNOWN - Value: __declspec(dllexport) - Description: We are building the library as a Win32 shared library (.dll) -Define 004: PI - Name: PI - Type: FLOAT - Value: 3.14159265358979323846 - Description: -Define 005: DEG2RAD - Name: DEG2RAD - Type: UNKNOWN - Value: (PI/180.0f) - Description: -Define 006: RAD2DEG - Name: RAD2DEG - Type: UNKNOWN - Value: (180.0f/PI) - Description: -Define 007: RL_MALLOC(sz) - Name: RL_MALLOC(sz) - Type: MACRO - Value: malloc(sz) - Description: -Define 008: RL_CALLOC(n,sz) - Name: RL_CALLOC(n,sz) - Type: MACRO - Value: calloc(n,sz) - Description: -Define 009: RL_REALLOC(ptr,sz) - Name: RL_REALLOC(ptr,sz) - Type: MACRO - Value: realloc(ptr,sz) - Description: -Define 010: RL_FREE(ptr) - Name: RL_FREE(ptr) - Type: MACRO - Value: free(ptr) - Description: -Define 011: CLITERAL(type) - Name: CLITERAL(type) - Type: MACRO - Value: type - Description: -Define 012: RL_COLOR_TYPE - Name: RL_COLOR_TYPE - Type: GUARD - Value: - Description: -Define 013: RL_RECTANGLE_TYPE - Name: RL_RECTANGLE_TYPE - Type: GUARD - Value: - Description: -Define 014: RL_VECTOR2_TYPE - Name: RL_VECTOR2_TYPE - Type: GUARD - Value: - Description: -Define 015: RL_VECTOR3_TYPE - Name: RL_VECTOR3_TYPE - Type: GUARD - Value: - Description: -Define 016: RL_VECTOR4_TYPE - Name: RL_VECTOR4_TYPE - Type: GUARD - Value: - Description: -Define 017: RL_QUATERNION_TYPE - Name: RL_QUATERNION_TYPE - Type: GUARD - Value: - Description: -Define 018: RL_MATRIX_TYPE - Name: RL_MATRIX_TYPE - Type: GUARD - Value: - Description: -Define 019: LIGHTGRAY - Name: LIGHTGRAY - Type: COLOR - Value: CLITERAL(Color){ 200, 200, 200, 255 } - Description: Light Gray -Define 020: GRAY - Name: GRAY - Type: COLOR - Value: CLITERAL(Color){ 130, 130, 130, 255 } - Description: Gray -Define 021: DARKGRAY - Name: DARKGRAY - Type: COLOR - Value: CLITERAL(Color){ 80, 80, 80, 255 } - Description: Dark Gray -Define 022: YELLOW - Name: YELLOW - Type: COLOR - Value: CLITERAL(Color){ 253, 249, 0, 255 } - Description: Yellow -Define 023: GOLD - Name: GOLD - Type: COLOR - Value: CLITERAL(Color){ 255, 203, 0, 255 } - Description: Gold -Define 024: ORANGE - Name: ORANGE - Type: COLOR - Value: CLITERAL(Color){ 255, 161, 0, 255 } - Description: Orange -Define 025: PINK - Name: PINK - Type: COLOR - Value: CLITERAL(Color){ 255, 109, 194, 255 } - Description: Pink -Define 026: RED - Name: RED - Type: COLOR - Value: CLITERAL(Color){ 230, 41, 55, 255 } - Description: Red -Define 027: MAROON - Name: MAROON - Type: COLOR - Value: CLITERAL(Color){ 190, 33, 55, 255 } - Description: Maroon -Define 028: GREEN - Name: GREEN - Type: COLOR - Value: CLITERAL(Color){ 0, 228, 48, 255 } - Description: Green -Define 029: LIME - Name: LIME - Type: COLOR - Value: CLITERAL(Color){ 0, 158, 47, 255 } - Description: Lime -Define 030: DARKGREEN - Name: DARKGREEN - Type: COLOR - Value: CLITERAL(Color){ 0, 117, 44, 255 } - Description: Dark Green -Define 031: SKYBLUE - Name: SKYBLUE - Type: COLOR - Value: CLITERAL(Color){ 102, 191, 255, 255 } - Description: Sky Blue -Define 032: BLUE - Name: BLUE - Type: COLOR - Value: CLITERAL(Color){ 0, 121, 241, 255 } - Description: Blue -Define 033: DARKBLUE - Name: DARKBLUE - Type: COLOR - Value: CLITERAL(Color){ 0, 82, 172, 255 } - Description: Dark Blue -Define 034: PURPLE - Name: PURPLE - Type: COLOR - Value: CLITERAL(Color){ 200, 122, 255, 255 } - Description: Purple -Define 035: VIOLET - Name: VIOLET - Type: COLOR - Value: CLITERAL(Color){ 135, 60, 190, 255 } - Description: Violet -Define 036: DARKPURPLE - Name: DARKPURPLE - Type: COLOR - Value: CLITERAL(Color){ 112, 31, 126, 255 } - Description: Dark Purple -Define 037: BEIGE - Name: BEIGE - Type: COLOR - Value: CLITERAL(Color){ 211, 176, 131, 255 } - Description: Beige -Define 038: BROWN - Name: BROWN - Type: COLOR - Value: CLITERAL(Color){ 127, 106, 79, 255 } - Description: Brown -Define 039: DARKBROWN - Name: DARKBROWN - Type: COLOR - Value: CLITERAL(Color){ 76, 63, 47, 255 } - Description: Dark Brown -Define 040: WHITE - Name: WHITE - Type: COLOR - Value: CLITERAL(Color){ 255, 255, 255, 255 } - Description: White -Define 041: BLACK - Name: BLACK - Type: COLOR - Value: CLITERAL(Color){ 0, 0, 0, 255 } - Description: Black -Define 042: BLANK - Name: BLANK - Type: COLOR - Value: CLITERAL(Color){ 0, 0, 0, 0 } - Description: Blank (Transparent) -Define 043: MAGENTA - Name: MAGENTA - Type: COLOR - Value: CLITERAL(Color){ 255, 0, 255, 255 } - Description: Magenta -Define 044: RAYWHITE - Name: RAYWHITE - Type: COLOR - Value: CLITERAL(Color){ 245, 245, 245, 255 } - Description: My own White (raylib logo) -Define 045: RL_BOOL_TYPE - Name: RL_BOOL_TYPE - Type: GUARD - Value: - Description: -Define 046: MOUSE_LEFT_BUTTON - Name: MOUSE_LEFT_BUTTON - Type: UNKNOWN - Value: MOUSE_BUTTON_LEFT - Description: -Define 047: MOUSE_RIGHT_BUTTON - Name: MOUSE_RIGHT_BUTTON - Type: UNKNOWN - Value: MOUSE_BUTTON_RIGHT - Description: -Define 048: MOUSE_MIDDLE_BUTTON - Name: MOUSE_MIDDLE_BUTTON - Type: UNKNOWN - Value: MOUSE_BUTTON_MIDDLE - Description: -Define 049: MATERIAL_MAP_DIFFUSE - Name: MATERIAL_MAP_DIFFUSE - Type: UNKNOWN - Value: MATERIAL_MAP_ALBEDO - Description: -Define 050: MATERIAL_MAP_SPECULAR - Name: MATERIAL_MAP_SPECULAR - Type: UNKNOWN - Value: MATERIAL_MAP_METALNESS - Description: -Define 051: SHADER_LOC_MAP_DIFFUSE - Name: SHADER_LOC_MAP_DIFFUSE - Type: UNKNOWN - Value: SHADER_LOC_MAP_ALBEDO - Description: -Define 052: SHADER_LOC_MAP_SPECULAR - Name: SHADER_LOC_MAP_SPECULAR - Type: UNKNOWN - Value: SHADER_LOC_MAP_METALNESS - Description: diff --git a/parser/raylib_api.xml b/parser/raylib_api.xml index 80e20939d..c2bb720ac 100644 --- a/parser/raylib_api.xml +++ b/parser/raylib_api.xml @@ -1,5 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -16,11 +70,23 @@ - - - - - + + + + + + + + + + + + + + + + + @@ -94,7 +160,7 @@ - + @@ -118,7 +184,7 @@ - + @@ -126,7 +192,7 @@ - + @@ -194,20 +260,27 @@ - - + + - - - - - - - - + + + + + + + + + + + + + + + @@ -544,60 +617,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -956,7 +1002,7 @@ - + @@ -967,7 +1013,7 @@ - + @@ -975,24 +1021,24 @@ - + - - + + - + - - + + - + - - + + - + - + diff --git a/parser/raylib_parser.c b/parser/raylib_parser.c index e775aa154..00751747b 100644 --- a/parser/raylib_parser.c +++ b/parser/raylib_parser.c @@ -2,13 +2,14 @@ raylib API parser - This parser scans raylib.h to get API information about structs, enums, functions and defines. + This parser scans raylib.h to get API information about defines, structs, aliases, enums, callbacks and functions. All data is divided into pieces, usually as strings. The following types are used for data: - - struct FunctionInfo + - struct DefineInfo - struct StructInfo + - struct AliasInfo - struct EnumInfo - - struct DefInfo + - struct FunctionInfo CONSTRAINTS: @@ -65,31 +66,49 @@ #include // Required for: bool #include // Required for: isdigit() -#define MAX_FUNCS_TO_PARSE 512 // Maximum number of functions to parse -#define MAX_STRUCTS_TO_PARSE 64 // Maximum number of structures to parse -#define MAX_ENUMS_TO_PARSE 64 // Maximum number of enums to parse #define MAX_DEFINES_TO_PARSE 2048 // Maximum number of defines to parse +#define MAX_STRUCTS_TO_PARSE 64 // Maximum number of structures to parse +#define MAX_ALIASES_TO_PARSE 64 // Maximum number of aliases to parse +#define MAX_ENUMS_TO_PARSE 64 // Maximum number of enums to parse +#define MAX_CALLBACKS_TO_PARSE 64 // Maximum number of callbacks to parse +#define MAX_FUNCS_TO_PARSE 512 // Maximum number of functions to parse #define MAX_LINE_LENGTH 512 // Maximum length of one line (including comments) -#define MAX_STRUCT_LINE_LENGTH 2048 // Maximum length of one struct (multiple lines) -#define MAX_FUNCTION_PARAMETERS 12 // Maximum number of function parameters -#define MAX_STRUCT_FIELDS 32 // Maximum number of struct fields +#define MAX_STRUCT_FIELDS 64 // Maximum number of struct fields #define MAX_ENUM_VALUES 512 // Maximum number of enum values +#define MAX_FUNCTION_PARAMETERS 12 // Maximum number of function parameters //---------------------------------------------------------------------------------- // Types and Structures Definition //---------------------------------------------------------------------------------- -// Function info data -typedef struct FunctionInfo { - char name[64]; // Function name - char desc[128]; // Function description (comment at the end) - char retType[32]; // Return value type - int paramCount; // Number of function parameters - char paramType[MAX_FUNCTION_PARAMETERS][32]; // Parameters type - char paramName[MAX_FUNCTION_PARAMETERS][32]; // Parameters name - char paramDesc[MAX_FUNCTION_PARAMETERS][128]; // Parameters description -} FunctionInfo; + +// Type of parsed define +typedef enum { + UNKNOWN = 0, + MACRO, + GUARD, + INT, + INT_MATH, + LONG, + LONG_MATH, + FLOAT, + FLOAT_MATH, + DOUBLE, + DOUBLE_MATH, + CHAR, + STRING, + COLOR +} DefineType; + +// Define info data +typedef struct DefineInfo { + char name[64]; // Define name + DefineType type; // Define type + char value[256]; // Define value + char desc[128]; // Define description + bool isHex; // Define is hex number (for types INT, LONG) +} DefineInfo; // Struct info data typedef struct StructInfo { @@ -101,6 +120,13 @@ typedef struct StructInfo { char fieldDesc[MAX_STRUCT_FIELDS][128]; // Field description } StructInfo; +// Alias info data +typedef struct AliasInfo { + char type[64]; // Alias type + char name[64]; // Alias name + char desc[128]; // Alias description +} AliasInfo; + // Enum info data typedef struct EnumInfo { char name[64]; // Enum name @@ -111,17 +137,16 @@ typedef struct EnumInfo { char valueDesc[MAX_ENUM_VALUES][128]; // Value description } EnumInfo; -// Type of parsed define -typedef enum { UNKNOWN = 0, MACRO, GUARD, INT, LONG, FLOAT, DOUBLE, CHAR, STRING, COLOR } DefineType; - -// Define info data -typedef struct DefineInfo { - char name[64]; // Define name - DefineType type; // Define type - char value[256]; // Define value - char desc[128]; // Define description - bool isHex; // Define is hex number (for types INT, LONG) -} DefineInfo; +// Function info data +typedef struct FunctionInfo { + char name[64]; // Function name + char desc[128]; // Function description (comment at the end) + char retType[32]; // Return value type + int paramCount; // Number of function parameters + char paramType[MAX_FUNCTION_PARAMETERS][32]; // Parameters type + char paramName[MAX_FUNCTION_PARAMETERS][32]; // Parameters name + char paramDesc[MAX_FUNCTION_PARAMETERS][128]; // Parameters description +} FunctionInfo; // Output format for parsed data typedef enum { DEFAULT = 0, JSON, XML, LUA } OutputFormat; @@ -129,17 +154,22 @@ typedef enum { DEFAULT = 0, JSON, XML, LUA } OutputFormat; //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- -static int funcCount = 0; -static int structCount = 0; -static int enumCount = 0; static int defineCount = 0; -static FunctionInfo *funcs = NULL; -static StructInfo *structs = NULL; -static EnumInfo *enums = NULL; +static int structCount = 0; +static int aliasCount = 0; +static int enumCount = 0; +static int callbackCount = 0; +static int funcCount = 0; static DefineInfo *defines = NULL; -static char apiDefine[32] = "RLAPI\0"; +static StructInfo *structs = NULL; +static AliasInfo *aliases = NULL; +static EnumInfo *enums = NULL; +static FunctionInfo *callbacks = NULL; +static FunctionInfo *funcs = NULL; // Command line variables +static char apiDefine[32] = { 0 }; // Functions define (i.e. RLAPI for raylib.h, RMDEF for raymath.h, etc.) +static char truncAfter[32] = { 0 }; // Truncate marker (i.e. "RLGL IMPLEMENTATION" for rlgl.h) static char inFileName[512] = { 0 }; // Input file name (required in case of provided through CLI) static char outFileName[512] = { 0 }; // Output file name (required for file save/export) static int outputFormat = DEFAULT; @@ -153,23 +183,27 @@ static void ProcessCommandLine(int argc, char *argv[]); // Process command l static char *LoadFileText(const char *fileName, int *length); static char **GetTextLines(const char *buffer, int length, int *linesCount); static void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char *name); +static void GetDescription(const char *source, char *description); +static void MoveArraySize(char *name, char *type); // Move array size from name to type static unsigned int TextLength(const char *text); // Get text length in bytes, check for \0 character static bool IsTextEqual(const char *text1, const char *text2, unsigned int count); +static int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string static void MemoryCopy(void *dest, const void *src, unsigned int count); static char *EscapeBackslashes(char *text); // Replace '\' by "\\" when exporting to JSON and XML +static const char *StrDefineType(DefineType type); // Get string of define type static void ExportParsedData(const char *fileName, int format); // Export parsed data in desired format -static const char *StrDefineType(DefineType type); // Get string of define type - -//------------------------------------------------------------------------------------ +//---------------------------------------------------------------------------------- // Program main entry point -//------------------------------------------------------------------------------------ +//---------------------------------------------------------------------------------- int main(int argc, char* argv[]) { if (argc > 1) ProcessCommandLine(argc, argv); if (inFileName[0] == '\0') MemoryCopy(inFileName, "../src/raylib.h\0", 16); + if (outFileName[0] == '\0') MemoryCopy(outFileName, "raylib_api.txt\0", 15); + if (apiDefine[0] == '\0') MemoryCopy(apiDefine, "RLAPI\0", 6); int length = 0; char *buffer = LoadFileText(inFileName, &length); @@ -179,82 +213,45 @@ int main(int argc, char* argv[]) int linesCount = 0; char **lines = GetTextLines(buffer, length, &linesCount); - // Function lines pointers, selected from buffer "lines" - char **funcLines = (char **)malloc(MAX_FUNCS_TO_PARSE*sizeof(char *)); + // Truncate lines + if (truncAfter[0] != '\0') + { + int newCount = -1; + for (int i = 0; i < linesCount; i++) + { + if (newCount > -1) free(lines[i]); + else if (TextFindIndex(lines[i], truncAfter) > -1) newCount = i; + } + if (newCount > -1) linesCount = newCount; + printf("Number of truncated text lines: %i\n", linesCount); + } - // Structs data (multiple lines), selected from "buffer" - int *structLines = (int *)malloc(MAX_STRUCTS_TO_PARSE*sizeof(int)); - - // Enums lines pointers, selected from buffer "lines" - int *enumLines = (int *)malloc(MAX_ENUMS_TO_PARSE*sizeof(int)); - - // Defines lines pointers, selected from buffer "lines" + // Defines line indices int *defineLines = (int *)malloc(MAX_DEFINES_TO_PARSE*sizeof(int)); + // Structs line indices + int *structLines = (int *)malloc(MAX_STRUCTS_TO_PARSE*sizeof(int)); + + // Aliases line indices + int *aliasLines = (int *)malloc(MAX_ALIASES_TO_PARSE*sizeof(int)); + + // Enums line indices + int *enumLines = (int *)malloc(MAX_ENUMS_TO_PARSE*sizeof(int)); + + // Callbacks line indices + int *callbackLines = (int *)malloc(MAX_CALLBACKS_TO_PARSE*sizeof(int)); + + // Function line indices + int *funcLines = (int *)malloc(MAX_FUNCS_TO_PARSE*sizeof(int)); + // Prepare required lines for parsing - //-------------------------------------------------------------------------------------------------- + //---------------------------------------------------------------------------------- - // Read function lines - for (int i = 0; i < linesCount; i++) - { - // Read function line (starting with `define`, i.e. for raylib.h "RLAPI") - if (IsTextEqual(lines[i], apiDefine, TextLength(apiDefine))) - { - // Keep a pointer to the function line - funcLines[funcCount] = lines[i]; - funcCount++; - } - } - - // Read struct lines - for (int i = 0; i < linesCount; i++) - { - // Find structs (starting with "typedef struct ... {", ending with '} ... ;') - if (IsTextEqual(lines[i], "typedef struct", 14)) - { - int j = 0; - bool validStruct = false; - - // WARNING: Typedefs between types: typedef Vector4 Quaternion; - // (maybe we could export these too?) - - for (int c = 0; c < MAX_LINE_LENGTH; c++) - { - char v = lines[i][c]; - if (v == '{') validStruct = true; - if (v == '{' || v == ';' || v == '\0') - { - // Not valid struct if it ends without '{': - // i.e typedef struct rAudioBuffer rAudioBuffer; -> Typedef and forward declaration - break; - } - } - if (!validStruct) continue; - structLines[structCount] = i; - while (lines[i][0] != '}') i++; - while (lines[i][0] != '\0') i++; - structCount++; - } - } - - // Read enum lines - for (int i = 0; i < linesCount; i++) - { - // Read enum line - if (IsTextEqual(lines[i], "typedef enum {", 14) && lines[i][TextLength(lines[i])-1] != ';') // ignore inline enums - { - // Keep the line position in the array of lines, - // so, we can scan that position and following lines - enumLines[enumCount] = i; - enumCount++; - } - } - - // Read const lines + // Read define lines for (int i = 0; i < linesCount; i++) { int j = 0; - while (lines[i][j] == ' ' || lines[i][j] == '\t') j++; // skip spaces and tabs in the begining + while ((lines[i][j] == ' ') || (lines[i][j] == '\t')) j++; // skip spaces and tabs in the begining // Read define line if (IsTextEqual(lines[i]+j, "#define ", 8)) { @@ -265,12 +262,340 @@ int main(int argc, char* argv[]) } } - // At this point we have all raylib structs, enums, functions, defines lines data to start parsing + // Read struct lines + for (int i = 0; i < linesCount; i++) + { + // Find structs + // starting with "typedef struct ... {" or "typedef struct ... ; \n struct ... {" + // ending with "} ... ;" + // i.e. excluding "typedef struct rAudioBuffer rAudioBuffer;" -> Typedef and forward declaration only + if (IsTextEqual(lines[i], "typedef struct", 14)) + { + bool validStruct = IsTextEqual(lines[i + 1], "struct", 6); + if (!validStruct) + { + for (int c = 0; c < MAX_LINE_LENGTH; c++) + { + char v = lines[i][c]; + if (v == '{') validStruct = true; + if ((v == '{') || (v == ';') || (v == '\0')) break; + } + } + if (!validStruct) continue; + structLines[structCount] = i; + while (lines[i][0] != '}') i++; + while (lines[i][0] != '\0') i++; + structCount++; + } + } + + // Read alias lines + for (int i = 0; i < linesCount; i++) + { + // Find aliases (lines with "typedef ... ...;") + if (IsTextEqual(lines[i], "typedef", 7)) + { + int spaceCount = 0; + bool validAlias = false; + + for (int c = 0; c < MAX_LINE_LENGTH; c++) + { + char v = lines[i][c]; + if (v == ' ') spaceCount++; + if ((v == ';') && (spaceCount == 2)) validAlias = true; + if ((v == ';') || (v == '(') || (v == '\0')) break; + } + if (!validAlias) continue; + aliasLines[aliasCount] = i; + aliasCount++; + } + } + + // Read enum lines + for (int i = 0; i < linesCount; i++) + { + // Read enum line + if (IsTextEqual(lines[i], "typedef enum {", 14) && (lines[i][TextLength(lines[i])-1] != ';')) // ignore inline enums + { + // Keep the line position in the array of lines, + // so, we can scan that position and following lines + enumLines[enumCount] = i; + enumCount++; + } + } + + // Read callback lines + for (int i = 0; i < linesCount; i++) + { + // Find callbacks (lines with "typedef ... (* ... )( ... );") + if (IsTextEqual(lines[i], "typedef", 7)) + { + bool hasBeginning = false; + bool hasMiddle = false; + bool hasEnd = false; + + for (int c = 0; c < MAX_LINE_LENGTH; c++) + { + if ((lines[i][c] == '(') && (lines[i][c + 1] == '*')) hasBeginning = true; + if ((lines[i][c] == ')') && (lines[i][c + 1] == '(')) hasMiddle = true; + if ((lines[i][c] == ')') && (lines[i][c + 1] == ';')) hasEnd = true; + if (hasEnd) break; + } + + if (hasBeginning && hasMiddle && hasEnd) + { + callbackLines[callbackCount] = i; + callbackCount++; + } + } + } + + // Read function lines + for (int i = 0; i < linesCount; i++) + { + // Read function line (starting with `define`, i.e. for raylib.h "RLAPI") + if (IsTextEqual(lines[i], apiDefine, TextLength(apiDefine))) + { + funcLines[funcCount] = i; + funcCount++; + } + } + + // At this point we have all raylib defines, structs, aliases, enums, callbacks, functions lines data to start parsing free(buffer); // Unload text buffer // Parsing raylib data - //-------------------------------------------------------------------------------------------------- + //---------------------------------------------------------------------------------- + + // Define info data + defines = (DefineInfo *)calloc(MAX_DEFINES_TO_PARSE, sizeof(DefineInfo)); + int defineIndex = 0; + + for (int i = 0; i < defineCount; i++) + { + char *linePtr = lines[defineLines[i]]; + int j = 0; + + while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs in the begining + j += 8; // Skip "#define " + while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs after "#define " + + // Extract name + int defineNameStart = j; + int openBraces = 0; + while (linePtr[j] != '\0') + { + if (((linePtr[j] == ' ') || (linePtr[j] == '\t')) && (openBraces == 0)) break; + if (linePtr[j] == '(') openBraces++; + if (linePtr[j] == ')') openBraces--; + j++; + } + int defineNameEnd = j-1; + + // Skip duplicates + int nameLen = defineNameEnd - defineNameStart + 1; + bool isDuplicate = false; + for (int k = 0; k < defineIndex; k++) + { + if ((nameLen == TextLength(defines[k].name)) && IsTextEqual(defines[k].name, &linePtr[defineNameStart], nameLen)) + { + isDuplicate = true; + break; + } + } + if (isDuplicate) continue; + + MemoryCopy(defines[defineIndex].name, &linePtr[defineNameStart], nameLen); + + // Determine type + if (linePtr[defineNameEnd] == ')') defines[defineIndex].type = MACRO; + + while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs after name + + int defineValueStart = j; + if ((linePtr[j] == '\0') || (linePtr == "/")) defines[defineIndex].type = GUARD; + if (linePtr[j] == '"') defines[defineIndex].type = STRING; + else if (linePtr[j] == '\'') defines[defineIndex].type = CHAR; + else if (IsTextEqual(linePtr+j, "CLITERAL(Color)", 15)) defines[defineIndex].type = COLOR; + else if (isdigit(linePtr[j])) // Parsing numbers + { + bool isFloat = false, isNumber = true, isHex = false; + while ((linePtr[j] != ' ') && (linePtr[j] != '\t') && (linePtr[j] != '\0')) + { + char ch = linePtr[j]; + if (ch == '.') isFloat = true; + if (ch == 'x') isHex = true; + if (!(isdigit(ch) || + ((ch >= 'a') && (ch <= 'f')) || + ((ch >= 'A') && (ch <= 'F')) || + (ch == 'x') || + (ch == 'L') || + (ch == '.') || + (ch == '+') || + (ch == '-'))) isNumber = false; + j++; + } + if (isNumber) + { + if (isFloat) + { + defines[defineIndex].type = linePtr[j-1] == 'f' ? FLOAT : DOUBLE; + } + else + { + defines[defineIndex].type = linePtr[j-1] == 'L' ? LONG : INT; + defines[defineIndex].isHex = isHex; + } + } + } + + // Extracting value + while ((linePtr[j] != '\\') && (linePtr[j] != '\0') && !((linePtr[j] == '/') && (linePtr[j+1] == '/'))) j++; + int defineValueEnd = j-1; + while ((linePtr[defineValueEnd] == ' ') || (linePtr[defineValueEnd] == '\t')) defineValueEnd--; // Remove trailing spaces and tabs + if ((defines[defineIndex].type == LONG) || (defines[defineIndex].type == FLOAT)) defineValueEnd--; // Remove number postfix + int valueLen = defineValueEnd - defineValueStart + 1; + if (valueLen > 255) valueLen = 255; + + if (valueLen > 0) MemoryCopy(defines[defineIndex].value, &linePtr[defineValueStart], valueLen); + + // Extracting description + if ((linePtr[j] == '/') && linePtr[j + 1] == '/') + { + j += 2; + while (linePtr[j] == ' ') j++; + int commentStart = j; + while ((linePtr[j] != '\\') && (linePtr[j] != '\0')) j++; + int commentEnd = j-1; + int commentLen = commentEnd - commentStart + 1; + if (commentLen > 127) commentLen = 127; + + MemoryCopy(defines[defineIndex].desc, &linePtr[commentStart], commentLen); + } + + // Parse defines of type UNKNOWN to find calculated numbers + if (defines[defineIndex].type == UNKNOWN) + { + DefineType largestType = UNKNOWN; + bool isMath = true; + char *valuePtr = defines[defineIndex].value; + + for (int c = 0; c < TextLength(valuePtr); c++) + { + char ch = valuePtr[c]; + + // Skip operators and whitespace + if ((ch == '(') || + (ch == ')') || + (ch == '+') || + (ch == '-') || + (ch == '*') || + (ch == '/') || + (ch == ' ') || + (ch == '\t')) continue; + + // Read number operand + else if (isdigit(ch)) + { + bool isNumber = true, isFloat = false; + while (!((ch == '(') || + (ch == ')') || + (ch == '*') || + (ch == '/') || + (ch == ' ') || + (ch == '\t') || + (ch == '\0'))) + { + if (ch == '.') isFloat = true; + if (!(isdigit(ch) || + ((ch >= 'a') && (ch <= 'f')) || + ((ch >= 'A') && (ch <= 'F')) || + (ch == 'x') || + (ch == 'L') || + (ch == '.') || + (ch == '+') || + (ch == '-'))) + { + isNumber = false; + break; + } + c++; + ch = valuePtr[c]; + } + if (isNumber) + { + // Found a valid number -> update largestType + DefineType numberType; + if (isFloat) numberType = valuePtr[c - 1] == 'f' ? FLOAT_MATH : DOUBLE_MATH; + else numberType = valuePtr[c - 1] == 'L' ? LONG_MATH : INT_MATH; + + if (numberType > largestType) largestType = numberType; + } + else + { + isMath = false; + break; + } + } + + // Read string operand + else + { + int operandStart = c; + while (!((ch == '\0') || + (ch == ' ') || + (ch == '(') || + (ch == ')') || + (ch == '+') || + (ch == '-') || + (ch == '*') || + (ch == '/'))) + { + c++; + ch = valuePtr[c]; + } + int operandEnd = c; + int operandLength = operandEnd - operandStart; + + // Search previous defines for operand + bool foundOperand = false; + for (int previousDefineIndex = 0; previousDefineIndex < defineIndex; previousDefineIndex++) + { + if (IsTextEqual(defines[previousDefineIndex].name, &valuePtr[operandStart], operandLength)) + { + if ((defines[previousDefineIndex].type >= INT) && (defines[previousDefineIndex].type <= DOUBLE_MATH)) + { + // Found operand and it's a number -> update largestType + if (defines[previousDefineIndex].type > largestType) largestType = defines[previousDefineIndex].type; + foundOperand = true; + } + break; + } + } + if (!foundOperand) + { + isMath = false; + break; + } + } + } + + if (isMath) + { + // Define is a calculated number -> update type + if (largestType == INT) largestType = INT_MATH; + else if (largestType == LONG) largestType = LONG_MATH; + else if (largestType == FLOAT) largestType = FLOAT_MATH; + else if (largestType == DOUBLE) largestType = DOUBLE_MATH; + defines[defineIndex].type = largestType; + } + } + + defineIndex++; + } + defineCount = defineIndex; + free(defineLines); // Structs info data structs = (StructInfo *)calloc(MAX_STRUCTS_TO_PARSE, sizeof(StructInfo)); @@ -280,18 +605,17 @@ int main(int argc, char* argv[]) char **linesPtr = &lines[structLines[i]]; // Parse struct description - if (linesPtr[-1][0] == '/') - { - MemoryCopy(structs[i].desc, linesPtr[-1], TextLength(linesPtr[-1])); - } + GetDescription(linesPtr[-1], structs[i].desc); // Get struct name: typedef struct name { const int TDS_LEN = 15; // length of "typedef struct " for (int c = TDS_LEN; c < 64 + TDS_LEN; c++) { - if (linesPtr[0][c] == '{') + if ((linesPtr[0][c] == '{') || (linesPtr[0][c] == ' ')) { - MemoryCopy(structs[i].name, &linesPtr[0][TDS_LEN], c - TDS_LEN - 1); + int nameLen = c - TDS_LEN; + while (linesPtr[0][TDS_LEN + nameLen - 1] == ' ') nameLen--; + MemoryCopy(structs[i].name, &linesPtr[0][TDS_LEN], nameLen); break; } } @@ -308,7 +632,7 @@ int main(int argc, char* argv[]) int fieldEndPos = 0; while (fieldLine[fieldEndPos] != ';') fieldEndPos++; - if (fieldLine[0] != '/') // Field line is not a comment + if ((fieldLine[0] != '/') && !IsTextEqual(fieldLine, "struct", 6)) // Field line is not a comment and not a struct declaration { //printf("Struct field: %s_\n", fieldLine); // OK! @@ -316,28 +640,150 @@ int main(int argc, char* argv[]) GetDataTypeAndName(fieldLine, fieldEndPos, structs[i].fieldType[structs[i].fieldCount], structs[i].fieldName[structs[i].fieldCount]); // Get the field description - // We start skipping spaces in front of description comment - int descStart = fieldEndPos; - while ((fieldLine[descStart] != '/') && (fieldLine[descStart] != '\0')) descStart++; - - int k = 0; - while ((fieldLine[descStart + k] != '\0') && (fieldLine[descStart + k] != '\n')) - { - structs[i].fieldDesc[structs[i].fieldCount][k] = fieldLine[descStart + k]; - k++; - } + GetDescription(&fieldLine[fieldEndPos], structs[i].fieldDesc[structs[i].fieldCount]); structs[i].fieldCount++; + + // Split field names containing multiple fields (like Matrix) + int additionalFields = 0; + int originalIndex = structs[i].fieldCount - 1; + for (int c = 0; c < TextLength(structs[i].fieldName[originalIndex]); c++) + { + if (structs[i].fieldName[originalIndex][c] == ',') additionalFields++; + } + if (additionalFields > 0) + { + int originalLength = -1; + int lastStart; + for (int c = 0; c < TextLength(structs[i].fieldName[originalIndex]) + 1; c++) + { + char v = structs[i].fieldName[originalIndex][c]; + bool isEndOfString = (v == '\0'); + if ((v == ',') || isEndOfString) + { + if (originalLength == -1) + { + // Save length of original field name + // Don't truncate yet, still needed for copying + originalLength = c; + } + else + { + // Copy field data from original field + int nameLength = c - lastStart; + MemoryCopy(structs[i].fieldName[structs[i].fieldCount], &structs[i].fieldName[originalIndex][lastStart], nameLength); + MemoryCopy(structs[i].fieldType[structs[i].fieldCount], &structs[i].fieldType[originalIndex][0], TextLength(structs[i].fieldType[originalIndex])); + MemoryCopy(structs[i].fieldDesc[structs[i].fieldCount], &structs[i].fieldDesc[originalIndex][0], TextLength(structs[i].fieldDesc[originalIndex])); + structs[i].fieldCount++; + } + if (!isEndOfString) + { + // Skip comma and spaces + c++; + while (structs[i].fieldName[originalIndex][c] == ' ') c++; + + // Save position for next field + lastStart = c; + } + } + } + // Set length of original field to truncate the first field name + structs[i].fieldName[originalIndex][originalLength] = '\0'; + } + + // Split field types containing multiple fields (like MemNode) + additionalFields = 0; + originalIndex = structs[i].fieldCount - 1; + for (int c = 0; c < TextLength(structs[i].fieldType[originalIndex]); c++) + { + if (structs[i].fieldType[originalIndex][c] == ',') additionalFields++; + } + if (additionalFields > 0) { + // Copy original name to last additional field + structs[i].fieldCount += additionalFields; + MemoryCopy(structs[i].fieldName[originalIndex + additionalFields], &structs[i].fieldName[originalIndex][0], TextLength(structs[i].fieldName[originalIndex])); + + // Copy names from type to additional fields + int fieldsRemaining = additionalFields; + int nameStart = -1; + int nameEnd = -1; + for (int k = TextLength(structs[i].fieldType[originalIndex]); k > 0; k--) + { + char v = structs[i].fieldType[originalIndex][k]; + if ((v == '*') || (v == ' ') || (v == ',')) + { + if (nameEnd != -1) { + // Don't copy to last additional field + if (fieldsRemaining != additionalFields) + { + nameStart = k + 1; + MemoryCopy(structs[i].fieldName[originalIndex + fieldsRemaining], &structs[i].fieldType[originalIndex][nameStart], nameEnd - nameStart + 1); + } + nameEnd = -1; + fieldsRemaining--; + } + } + else if (nameEnd == -1) nameEnd = k; + } + + // Truncate original field type + int fieldTypeLength = nameStart; + structs[i].fieldType[originalIndex][fieldTypeLength] = '\0'; + + // Set field type and description of additional fields + for (int j = 1; j <= additionalFields; j++) + { + MemoryCopy(structs[i].fieldType[originalIndex + j], &structs[i].fieldType[originalIndex][0], fieldTypeLength); + MemoryCopy(structs[i].fieldDesc[originalIndex + j], &structs[i].fieldDesc[originalIndex][0], TextLength(structs[i].fieldDesc[originalIndex])); + } + } } } l++; } + // Move array sizes from name to type + for (int j = 0; j < structs[i].fieldCount; j++) + { + MoveArraySize(structs[i].fieldName[j], structs[i].fieldType[j]); + } } - free(structLines); + // Alias info data + aliases = (AliasInfo *)calloc(MAX_ALIASES_TO_PARSE, sizeof(AliasInfo)); + + for (int i = 0; i < aliasCount; i++) + { + // Description from previous line + GetDescription(lines[aliasLines[i] - 1], aliases[i].desc); + + char *linePtr = lines[aliasLines[i]]; + + // Skip "typedef " + int c = 8; + + // Type + int typeStart = c; + while(linePtr[c] != ' ') c++; + int typeLen = c - typeStart; + MemoryCopy(aliases[i].type, &linePtr[typeStart], typeLen); + + // Skip space + c++; + + // Name + int nameStart = c; + while(linePtr[c] != ';') c++; + int nameLen = c - nameStart; + MemoryCopy(aliases[i].name, &linePtr[nameStart], nameLen); + + // Description + GetDescription(&linePtr[c], aliases[i].desc); + } + free(aliasLines); + // Enum info data enums = (EnumInfo *)calloc(MAX_ENUMS_TO_PARSE, sizeof(EnumInfo)); @@ -353,7 +799,7 @@ int main(int argc, char* argv[]) char *linePtr = lines[j]; if ((linePtr[0] != '/') || (linePtr[2] != ' ')) { - MemoryCopy(enums[i].desc, &lines[j + 1][0], sizeof(enums[i].desc) - 1); + GetDescription(&lines[j + 1][0], enums[i].desc); break; } } @@ -376,7 +822,11 @@ int main(int argc, char* argv[]) while ((linePtr[c] != ',') && (linePtr[c] != ' ') && (linePtr[c] != '=') && - (linePtr[c] != '\0')) { enums[i].valueName[enums[i].valueCount][c] = linePtr[c]; c++; } + (linePtr[c] != '\0')) + { + enums[i].valueName[enums[i].valueCount][c] = linePtr[c]; + c++; + } // After the name we can have: // '=' -> value is provided @@ -393,7 +843,11 @@ int main(int argc, char* argv[]) bool foundValue = false; while ((linePtr[c] != '\0') && (linePtr[c] != '/')) { - if (linePtr[c] == '=') { foundValue = true; break; } + if (linePtr[c] == '=') + { + foundValue = true; + break; + } c++; } @@ -419,13 +873,8 @@ int main(int argc, char* argv[]) } else enums[i].valueInteger[enums[i].valueCount] = (enums[i].valueInteger[enums[i].valueCount - 1] + 1); - // Look for description or end of line - while ((linePtr[c] != '/') && (linePtr[c] != '\0')) { c++; } - if (linePtr[c] == '/') - { - // Parse value description - MemoryCopy(enums[i].valueDesc[enums[i].valueCount], &linePtr[c], sizeof(enums[0].valueDesc[0]) - c - 1); - } + // Parse value description + GetDescription(&linePtr[c], enums[i].valueDesc[enums[i].valueCount]); enums[i].valueCount++; } @@ -433,7 +882,11 @@ int main(int argc, char* argv[]) { // Get enum name from typedef int c = 0; - while (linePtr[2 + c] != ';') { enums[i].name[c] = linePtr[2 + c]; c++; } + while (linePtr[2 + c] != ';') + { + enums[i].name[c] = linePtr[2 + c]; + c++; + } break; // Enum ended, break for() loop } @@ -441,104 +894,76 @@ int main(int argc, char* argv[]) } free(enumLines); - // Define info data - defines = (DefineInfo *)calloc(MAX_DEFINES_TO_PARSE, sizeof(DefineInfo)); - int defineIndex = 0; + // Callback info data + callbacks = (FunctionInfo *)calloc(MAX_CALLBACKS_TO_PARSE, sizeof(FunctionInfo)); - for (int i = 0; i < defineCount; i++) + for (int i = 0; i < callbackCount; i++) { - char *linePtr = lines[defineLines[i]]; - int j = 0; + char *linePtr = lines[callbackLines[i]]; - while (linePtr[j] == ' ' || linePtr[j] == '\t') j++; // Skip spaces and tabs in the begining - j += 8; // Skip "#define " - while (linePtr[j] == ' ' || linePtr[j] == '\t') j++; // Skip spaces and tabs after "#define " + // Skip "typedef " + int c = 8; - // Extract name - int defineNameStart = j; - while (linePtr[j] != ' ' && linePtr[j] != '\t' && linePtr[j] != '\0') j++; - int defineNameEnd = j-1; + // Return type + int retTypeStart = c; + while(linePtr[c] != '(') c++; + int retTypeLen = c - retTypeStart; + while(linePtr[retTypeStart + retTypeLen - 1] == ' ') retTypeLen--; + MemoryCopy(callbacks[i].retType, &linePtr[retTypeStart], retTypeLen); - // Skip duplicates - int nameLen = defineNameEnd - defineNameStart + 1; - bool isDuplicate = false; - for (int k = 0; k < defineIndex; k++) { - if (nameLen == TextLength(defines[k].name) && IsTextEqual(defines[k].name, linePtr + defineNameStart, nameLen)) { - isDuplicate = true; - break; - } - } - if (isDuplicate) continue; - - MemoryCopy(defines[defineIndex].name, linePtr + defineNameStart, nameLen); - - // Determine type - if (linePtr[defineNameEnd] == ')') defines[defineIndex].type = MACRO; - - while (linePtr[j] == ' ' || linePtr[j] == '\t') j++; // Skip spaces and tabs after name - - int defineValueStart = j; - if (linePtr[j] == '\0' || linePtr == "/") defines[defineIndex].type = GUARD; - if (linePtr[j] == '"') defines[defineIndex].type = STRING; - else if (linePtr[j] == '\'') defines[defineIndex].type = CHAR; - else if (IsTextEqual(linePtr+j, "CLITERAL(Color)", 15)) defines[defineIndex].type = COLOR; - else if (isdigit(linePtr[j])) { // Parsing numbers - bool isFloat = false, isNumber = true, isHex = false; - while (linePtr[j] != ' ' && linePtr[j] != '\t' && linePtr[j] != '\0') { - char ch = linePtr[j]; - if (ch == '.') isFloat = true; - if (ch == 'x') isHex = true; - if (!(isdigit(ch)||(ch >= 'a' && ch <= 'f')||(ch >= 'A' && ch <= 'F')||ch=='x'||ch=='L'||ch=='.'||ch=='+'||ch=='-')) isNumber = false; - j++; - } - if (isNumber) { - if (isFloat) { - defines[defineIndex].type = linePtr[j-1] == 'f' ? FLOAT : DOUBLE; - } else { - defines[defineIndex].type = linePtr[j-1] == 'L' ? LONG : INT; - defines[defineIndex].isHex = isHex; - } + // Skip "(*" + c += 2; + + // Name + int nameStart = c; + while(linePtr[c] != ')') c++; + int nameLen = c - nameStart; + MemoryCopy(callbacks[i].name, &linePtr[nameStart], nameLen); + + // Skip ")(" + c += 2; + + // Params + int paramStart = c; + for (c; c < MAX_LINE_LENGTH; c++) + { + if ((linePtr[c] == ',') || (linePtr[c] == ')')) + { + // Get parameter type + name, extract info + int paramLen = c - paramStart; + GetDataTypeAndName(&linePtr[paramStart], paramLen, callbacks[i].paramType[callbacks[i].paramCount], callbacks[i].paramName[callbacks[i].paramCount]); + callbacks[i].paramCount++; + paramStart = c + 1; + while(linePtr[paramStart] == ' ') paramStart++; } + if (linePtr[c] == ')') break; } - // Extracting value - while (linePtr[j] != '\\' && linePtr[j] != '\0' && !(linePtr[j] == '/' && linePtr[j+1] == '/')) j++; - int defineValueEnd = j-1; - while (linePtr[defineValueEnd] == ' ' || linePtr[defineValueEnd] == '\t') defineValueEnd--; // Remove trailing spaces and tabs - if (defines[defineIndex].type == LONG || defines[defineIndex].type == FLOAT) defineValueEnd--; // Remove number postfix - int valueLen = defineValueEnd - defineValueStart + 1; - if (valueLen > 255) valueLen = 255; + // Description + GetDescription(&linePtr[c], callbacks[i].desc); - if (valueLen > 0) MemoryCopy(defines[defineIndex].value, linePtr + defineValueStart, valueLen); - - // Extracting description - if (linePtr[j] == '/') { - int commentStart = j; - while (linePtr[j] != '\\' && linePtr[j] != '\0') j++; - int commentEnd = j-1; - int commentLen = commentEnd - commentStart + 1; - if (commentLen > 127) commentLen = 127; - - MemoryCopy(defines[defineIndex].desc, linePtr + commentStart, commentLen); + // Move array sizes from name to type + for (int j = 0; j < callbacks[i].paramCount; j++) + { + MoveArraySize(callbacks[i].paramName[j], callbacks[i].paramType[j]); } - - defineIndex++; } - defineCount = defineIndex; - free(defineLines); + free(callbackLines); // Functions info data funcs = (FunctionInfo *)calloc(MAX_FUNCS_TO_PARSE, sizeof(FunctionInfo)); for (int i = 0; i < funcCount; i++) { + char *linePtr = lines[funcLines[i]]; + int funcParamsStart = 0; int funcEnd = 0; // Get return type and function name from func line - for (int c = 0; (c < MAX_LINE_LENGTH) && (funcLines[i][c] != '\n'); c++) + for (int c = 0; (c < MAX_LINE_LENGTH) && (linePtr[c] != '\n'); c++) { - if (funcLines[i][c] == '(') // Starts function parameters + if (linePtr[c] == '(') // Starts function parameters { funcParamsStart = c + 1; @@ -546,7 +971,7 @@ int main(int argc, char* argv[]) char funcRetTypeName[128] = { 0 }; int dc = TextLength(apiDefine) + 1; int funcRetTypeNameLen = c - dc; // Substract `define` ("RLAPI " for raylib.h) - MemoryCopy(funcRetTypeName, &funcLines[i][dc], funcRetTypeNameLen); + MemoryCopy(funcRetTypeName, &linePtr[dc], funcRetTypeNameLen); GetDataTypeAndName(funcRetTypeName, funcRetTypeNameLen, funcs[i].retType, funcs[i].name); break; @@ -556,30 +981,30 @@ int main(int argc, char* argv[]) // Get parameters from func line for (int c = funcParamsStart; c < MAX_LINE_LENGTH; c++) { - if (funcLines[i][c] == ',') // Starts function parameters + if (linePtr[c] == ',') // Starts function parameters { // Get parameter type + name, extract info char funcParamTypeName[128] = { 0 }; int funcParamTypeNameLen = c - funcParamsStart; - MemoryCopy(funcParamTypeName, &funcLines[i][funcParamsStart], funcParamTypeNameLen); + MemoryCopy(funcParamTypeName, &linePtr[funcParamsStart], funcParamTypeNameLen); GetDataTypeAndName(funcParamTypeName, funcParamTypeNameLen, funcs[i].paramType[funcs[i].paramCount], funcs[i].paramName[funcs[i].paramCount]); funcParamsStart = c + 1; - if (funcLines[i][c + 1] == ' ') funcParamsStart += 1; + if (linePtr[c + 1] == ' ') funcParamsStart += 1; funcs[i].paramCount++; // Move to next parameter } - else if (funcLines[i][c] == ')') + else if (linePtr[c] == ')') { funcEnd = c + 2; // Check if previous word is void - if ((funcLines[i][c - 4] == 'v') && (funcLines[i][c - 3] == 'o') && (funcLines[i][c - 2] == 'i') && (funcLines[i][c - 1] == 'd')) break; + if ((linePtr[c - 4] == 'v') && (linePtr[c - 3] == 'o') && (linePtr[c - 2] == 'i') && (linePtr[c - 1] == 'd')) break; // Get parameter type + name, extract info char funcParamTypeName[128] = { 0 }; int funcParamTypeNameLen = c - funcParamsStart; - MemoryCopy(funcParamTypeName, &funcLines[i][funcParamsStart], funcParamTypeNameLen); + MemoryCopy(funcParamTypeName, &linePtr[funcParamsStart], funcParamTypeNameLen); GetDataTypeAndName(funcParamTypeName, funcParamTypeNameLen, funcs[i].paramType[funcs[i].paramCount], funcs[i].paramName[funcs[i].paramCount]); @@ -589,29 +1014,27 @@ int main(int argc, char* argv[]) } // Get function description - for (int c = funcEnd; c < MAX_LINE_LENGTH; c++) + GetDescription(&linePtr[funcEnd], funcs[i].desc); + + // Move array sizes from name to type + for (int j = 0; j < funcs[i].paramCount; j++) { - if (funcLines[i][c] == '/') - { - MemoryCopy(funcs[i].desc, &funcLines[i][c], 127); // WARNING: Size could be too long for funcLines[i][c]? - break; - } + MoveArraySize(funcs[i].paramName[j], funcs[i].paramType[j]); } } + free(funcLines); for (int i = 0; i < linesCount; i++) free(lines[i]); free(lines); - free(funcLines); // At this point, all raylib data has been parsed! - //----------------------------------------------------------------------------------------- - // structs[] -> We have all the structs decomposed into pieces for further analysis - // enums[] -> We have all the enums decomposed into pieces for further analysis - // funcs[] -> We have all the functions decomposed into pieces for further analysis - // defines[] -> We have all the defines decomposed into pieces for further analysis - - // Process input file to output - if (outFileName[0] == '\0') MemoryCopy(outFileName, "raylib_api.txt\0", 15); + //---------------------------------------------------------------------------------- + // defines[] -> We have all the defines decomposed into pieces for further analysis + // structs[] -> We have all the structs decomposed into pieces for further analysis + // aliases[] -> We have all the aliases decomposed into pieces for further analysis + // enums[] -> We have all the enums decomposed into pieces for further analysis + // callbacks[] -> We have all the callbacks decomposed into pieces for further analysis + // funcs[] -> We have all the functions decomposed into pieces for further analysis printf("\nInput file: %s", inFileName); printf("\nOutput file: %s", outFileName); @@ -622,14 +1045,18 @@ int main(int argc, char* argv[]) ExportParsedData(outFileName, outputFormat); - free(funcs); + free(defines); free(structs); + free(aliases); free(enums); + free(callbacks); + free(funcs); } //---------------------------------------------------------------------------------- // Module Functions Definition //---------------------------------------------------------------------------------- + // Show command line usage info static void ShowCommandLineInfo(void) { @@ -655,8 +1082,10 @@ static void ShowCommandLineInfo(void) printf(" NOTE: If not specified, defaults to: raylib_api.txt\n\n"); printf(" -f, --format : Define output format for parser data.\n"); printf(" Supported types: DEFAULT, JSON, XML, LUA\n\n"); - printf(" -d, --define : Define functions define (i.e. RLAPI for raylib.h, RMDEF for raymath.h, etc\n"); + printf(" -d, --define : Define functions define (i.e. RLAPI for raylib.h, RMDEF for raymath.h, etc.)\n"); printf(" NOTE: If not specified, defaults to: RLAPI\n\n"); + printf(" -t, --truncate : Define string to truncate input after (i.e. \"RLGL IMPLEMENTATION\" for rlgl.h)\n"); + printf(" NOTE: If not specified input is not truncated.\n\n"); printf("\nEXAMPLES:\n\n"); printf(" > raylib_parser --input raylib.h --output api.json\n"); @@ -676,6 +1105,7 @@ static void ProcessCommandLine(int argc, char *argv[]) { // Show info ShowCommandLineInfo(); + exit(0); } else if (IsTextEqual(argv[i], "-i", 2) || IsTextEqual(argv[i], "--input", 7)) { @@ -717,6 +1147,15 @@ static void ProcessCommandLine(int argc, char *argv[]) } else printf("WARNING: No define key provided\n"); } + else if (IsTextEqual(argv[i], "-t", 2) || IsTextEqual(argv[i], "--truncate", 10)) + { + if (((i + 1) < argc) && (argv[i + 1][0] != '-')) + { + MemoryCopy(truncAfter, argv[i + 1], TextLength(argv[i + 1])); // Read truncate marker + truncAfter[TextLength(argv[i + 1])] = '\0'; + i++; + } + } } } @@ -807,7 +1246,7 @@ static void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type { for (int k = typeNameLen; k > 0; k--) { - if (typeName[k] == ' ' && typeName[k - 1] != ',') + if ((typeName[k] == ' ') && (typeName[k - 1] != ',')) { // Function name starts at this point (and ret type finishes at this point) MemoryCopy(type, typeName, k); @@ -820,11 +1259,49 @@ static void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type MemoryCopy(name, typeName + k + 1, typeNameLen - k - 1); break; } - else if (typeName[k] == '.' && typeNameLen == 3) // Handle varargs ...); + else if ((typeName[k] == '.') && (typeNameLen == 3)) // Handle varargs ...); { MemoryCopy(type, "...", 3); MemoryCopy(name, "args", 4); - break; + break; + } + } +} + +// Get comment from a line, do nothing if no comment in line +static void GetDescription(const char *line, char *description) +{ + int c = 0; + int descStart = -1; + int lastSlash = -2; + bool isValid = false; + while (line[c] != '\0') + { + if (isValid && (descStart == -1) && (line[c] != ' ')) descStart = c; + else if (line[c] == '/') + { + if (lastSlash == c - 1) isValid = true; + lastSlash = c; + } + c++; + } + if (descStart != -1) MemoryCopy(description, &line[descStart], c - descStart); +} + +// Move array size from name to type +static void MoveArraySize(char *name, char *type) +{ + int nameLength = TextLength(name); + if (name[nameLength - 1] == ']') + { + for (int k = nameLength; k > 0; k--) + { + if (name[k] == '[') + { + int sizeLength = nameLength - k; + MemoryCopy(&type[TextLength(type)], &name[k], sizeLength); + name[k] = '\0'; + } } } } @@ -839,15 +1316,6 @@ static unsigned int TextLength(const char *text) return length; } -// Custom memcpy() to avoid -static void MemoryCopy(void *dest, const void *src, unsigned int count) -{ - char *srcPtr = (char *)src; - char *destPtr = (char *)dest; - - for (unsigned int i = 0; i < count; i++) destPtr[i] = srcPtr[i]; -} - // Compare two text strings, requires number of characters to compare static bool IsTextEqual(const char *text1, const char *text2, unsigned int count) { @@ -865,6 +1333,29 @@ static bool IsTextEqual(const char *text1, const char *text2, unsigned int count return result; } +// Find first text occurrence within a string +int TextFindIndex(const char *text, const char *find) +{ + int textLen = TextLength(text); + int findLen = TextLength(find); + + for (int i = 0; i <= textLen - findLen; i++) + { + if (IsTextEqual(&text[i], find, findLen)) return i; + } + + return -1; +} + +// Custom memcpy() to avoid +static void MemoryCopy(void *dest, const void *src, unsigned int count) +{ + char *srcPtr = (char *)src; + char *destPtr = (char *)dest; + + for (unsigned int i = 0; i < count; i++) destPtr[i] = srcPtr[i]; +} + // Escape backslashes in a string, writing the escaped string into a static buffer static char *EscapeBackslashes(char *text) { @@ -893,16 +1384,20 @@ static const char *StrDefineType(DefineType type) { switch (type) { - case UNKNOWN: return "UNKNOWN"; - case GUARD: return "GUARD"; - case MACRO: return "MACRO"; - case INT: return "INT"; - case LONG: return "LONG"; - case FLOAT: return "FLOAT"; - case DOUBLE: return "DOUBLE"; - case CHAR: return "CHAR"; - case STRING: return "STRING"; - case COLOR: return "COLOR"; + case UNKNOWN: return "UNKNOWN"; + case GUARD: return "GUARD"; + case MACRO: return "MACRO"; + case INT: return "INT"; + case INT_MATH: return "INT_MATH"; + case LONG: return "LONG"; + case LONG_MATH: return "LONG_MATH"; + case FLOAT: return "FLOAT"; + case FLOAT_MATH: return "FLOAT_MATH"; + case DOUBLE: return "DOUBLE"; + case DOUBLE_MATH: return "DOUBLE_MATH"; + case CHAR: return "CHAR"; + case STRING: return "STRING"; + case COLOR: return "COLOR"; } return ""; } @@ -968,14 +1463,40 @@ static void ExportParsedData(const char *fileName, int format) { case DEFAULT: { + // Print defines info + fprintf(outFile, "\nDefines found: %i\n\n", defineCount); + for (int i = 0; i < defineCount; i++) + { + fprintf(outFile, "Define %03i: %s\n", i + 1, defines[i].name); + fprintf(outFile, " Name: %s\n", defines[i].name); + fprintf(outFile, " Type: %s\n", StrDefineType(defines[i].type)); + fprintf(outFile, " Value: %s\n", defines[i].value); + fprintf(outFile, " Description: %s\n", defines[i].desc); + } + // Print structs info fprintf(outFile, "\nStructures found: %i\n\n", structCount); for (int i = 0; i < structCount; i++) { fprintf(outFile, "Struct %02i: %s (%i fields)\n", i + 1, structs[i].name, structs[i].fieldCount); fprintf(outFile, " Name: %s\n", structs[i].name); - fprintf(outFile, " Description: %s\n", structs[i].desc + 3); - for (int f = 0; f < structs[i].fieldCount; f++) fprintf(outFile, " Field[%i]: %s %s %s\n", f + 1, structs[i].fieldType[f], structs[i].fieldName[f], structs[i].fieldDesc[f]); + fprintf(outFile, " Description: %s\n", structs[i].desc); + for (int f = 0; f < structs[i].fieldCount; f++) + { + fprintf(outFile, " Field[%i]: %s %s ", f + 1, structs[i].fieldType[f], structs[i].fieldName[f]); + if (structs[i].fieldDesc[f][0]) fprintf(outFile, "// %s\n", structs[i].fieldDesc[f]); + else fprintf(outFile, "\n"); + } + } + + // Print aliases info + fprintf(outFile, "\nAliases found: %i\n\n", aliasCount); + for (int i = 0; i < aliasCount; i++) + { + fprintf(outFile, "Alias %03i: %s\n", i + 1, aliases[i].name); + fprintf(outFile, " Type: %s\n", aliases[i].type); + fprintf(outFile, " Name: %s\n", aliases[i].name); + fprintf(outFile, " Description: %s\n", aliases[i].desc); } // Print enums info @@ -984,10 +1505,22 @@ static void ExportParsedData(const char *fileName, int format) { fprintf(outFile, "Enum %02i: %s (%i values)\n", i + 1, enums[i].name, enums[i].valueCount); fprintf(outFile, " Name: %s\n", enums[i].name); - fprintf(outFile, " Description: %s\n", enums[i].desc + 3); + fprintf(outFile, " Description: %s\n", enums[i].desc); for (int e = 0; e < enums[i].valueCount; e++) fprintf(outFile, " Value[%s]: %i\n", enums[i].valueName[e], enums[i].valueInteger[e]); } + // Print callbacks info + fprintf(outFile, "\nCallbacks found: %i\n\n", callbackCount); + for (int i = 0; i < callbackCount; i++) + { + fprintf(outFile, "Callback %03i: %s() (%i input parameters)\n", i + 1, callbacks[i].name, callbacks[i].paramCount); + fprintf(outFile, " Name: %s\n", callbacks[i].name); + fprintf(outFile, " Return type: %s\n", callbacks[i].retType); + fprintf(outFile, " Description: %s\n", callbacks[i].desc); + for (int p = 0; p < callbacks[i].paramCount; p++) fprintf(outFile, " Param[%i]: %s (type: %s)\n", p + 1, callbacks[i].paramName[p], callbacks[i].paramType[p]); + if (callbacks[i].paramCount == 0) fprintf(outFile, " No input parameters\n"); + } + // Print functions info fprintf(outFile, "\nFunctions found: %i\n\n", funcCount); for (int i = 0; i < funcCount; i++) @@ -995,127 +1528,45 @@ static void ExportParsedData(const char *fileName, int format) fprintf(outFile, "Function %03i: %s() (%i input parameters)\n", i + 1, funcs[i].name, funcs[i].paramCount); fprintf(outFile, " Name: %s\n", funcs[i].name); fprintf(outFile, " Return type: %s\n", funcs[i].retType); - fprintf(outFile, " Description: %s\n", funcs[i].desc + 3); + fprintf(outFile, " Description: %s\n", funcs[i].desc); for (int p = 0; p < funcs[i].paramCount; p++) fprintf(outFile, " Param[%i]: %s (type: %s)\n", p + 1, funcs[i].paramName[p], funcs[i].paramType[p]); if (funcs[i].paramCount == 0) fprintf(outFile, " No input parameters\n"); } - - fprintf(outFile, "\nDefines found: %i\n\n", defineCount); - for (int i = 0; i < defineCount; i++) - { - fprintf(outFile, "Define %03i: %s\n", i + 1, defines[i].name); - fprintf(outFile, " Name: %s\n", defines[i].name); - fprintf(outFile, " Type: %s\n", StrDefineType(defines[i].type)); - fprintf(outFile, " Value: %s\n", defines[i].value); - fprintf(outFile, " Description: %s\n", defines[i].desc + 3); - } } break; - case LUA: + case JSON: { - fprintf(outFile, "return {\n"); - - // Print structs info - fprintf(outFile, " structs = {\n"); - for (int i = 0; i < structCount; i++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " name = \"%s\",\n", structs[i].name); - fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(structs[i].desc + 3)); - fprintf(outFile, " fields = {\n"); - for (int f = 0; f < structs[i].fieldCount; f++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " type = \"%s\",\n", structs[i].fieldType[f]); - fprintf(outFile, " name = \"%s\",\n", structs[i].fieldName[f]); - fprintf(outFile, " description = \"%s\"\n", EscapeBackslashes(structs[i].fieldDesc[f] + 3)); - fprintf(outFile, " }"); - if (f < structs[i].fieldCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " }\n"); - fprintf(outFile, " }"); - if (i < structCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " },\n"); - - // Print enums info - fprintf(outFile, " enums = {\n"); - for (int i = 0; i < enumCount; i++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " name = \"%s\",\n", enums[i].name); - fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(enums[i].desc + 3)); - fprintf(outFile, " values = {\n"); - for (int e = 0; e < enums[i].valueCount; e++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " name = \"%s\",\n", enums[i].valueName[e]); - fprintf(outFile, " value = %i,\n", enums[i].valueInteger[e]); - fprintf(outFile, " description = \"%s\"\n", EscapeBackslashes(enums[i].valueDesc[e] + 3)); - fprintf(outFile, " }"); - if (e < enums[i].valueCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " }\n"); - fprintf(outFile, " }"); - if (i < enumCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " },\n"); + fprintf(outFile, "{\n"); // Print defines info - fprintf(outFile, " defines = {\n"); + fprintf(outFile, " \"defines\": [\n"); for (int i = 0; i < defineCount; i++) { fprintf(outFile, " {\n"); - fprintf(outFile, " name = \"%s\",\n", defines[i].name); - fprintf(outFile, " type = \"%s\",\n", StrDefineType(defines[i].type)); - if (defines[i].type == INT || defines[i].type == LONG || defines[i].type == FLOAT || defines[i].type == DOUBLE || defines[i].type == STRING) { - fprintf(outFile, " value = %s,\n", defines[i].value); - } else { - fprintf(outFile, " value = \"%s\",\n", defines[i].value); + fprintf(outFile, " \"name\": \"%s\",\n", defines[i].name); + fprintf(outFile, " \"type\": \"%s\",\n", StrDefineType(defines[i].type)); + if (defines[i].isHex) // INT or LONG + { + fprintf(outFile, " \"value\": %ld,\n", strtol(defines[i].value, NULL, 16)); } - fprintf(outFile, " description = \"%s\"\n", defines[i].desc + 3); + else if ((defines[i].type == INT) || + (defines[i].type == LONG) || + (defines[i].type == FLOAT) || + (defines[i].type == DOUBLE) || + (defines[i].type == STRING)) + { + fprintf(outFile, " \"value\": %s,\n", defines[i].value); + } + else + { + fprintf(outFile, " \"value\": \"%s\",\n", defines[i].value); + } + fprintf(outFile, " \"description\": \"%s\"\n", defines[i].desc); fprintf(outFile, " }"); if (i < defineCount - 1) fprintf(outFile, ",\n"); else fprintf(outFile, "\n"); } - fprintf(outFile, " },\n"); - - // Print functions info - fprintf(outFile, " functions = {\n"); - for (int i = 0; i < funcCount; i++) - { - fprintf(outFile, " {\n"); - fprintf(outFile, " name = \"%s\",\n", funcs[i].name); - fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(funcs[i].desc + 3)); - fprintf(outFile, " returnType = \"%s\"", funcs[i].retType); - - if (funcs[i].paramCount == 0) fprintf(outFile, "\n"); - else - { - fprintf(outFile, ",\n params = {\n"); - for (int p = 0; p < funcs[i].paramCount; p++) - { - fprintf(outFile, " {type = \"%s\", name = \"%s\"}", funcs[i].paramType[p], funcs[i].paramName[p]); - if (p < funcs[i].paramCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " }\n"); - } - fprintf(outFile, " }"); - - if (i < funcCount - 1) fprintf(outFile, ",\n"); - else fprintf(outFile, "\n"); - } - fprintf(outFile, " }\n"); - fprintf(outFile, "}\n"); - } break; - case JSON: - { - fprintf(outFile, "{\n"); + fprintf(outFile, " ],\n"); // Print structs info fprintf(outFile, " \"structs\": [\n"); @@ -1123,14 +1574,14 @@ static void ExportParsedData(const char *fileName, int format) { fprintf(outFile, " {\n"); fprintf(outFile, " \"name\": \"%s\",\n", structs[i].name); - fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(structs[i].desc + 3)); + fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(structs[i].desc)); fprintf(outFile, " \"fields\": [\n"); for (int f = 0; f < structs[i].fieldCount; f++) { fprintf(outFile, " {\n"); fprintf(outFile, " \"type\": \"%s\",\n", structs[i].fieldType[f]); fprintf(outFile, " \"name\": \"%s\",\n", structs[i].fieldName[f]); - fprintf(outFile, " \"description\": \"%s\"\n", EscapeBackslashes(structs[i].fieldDesc[f] + 3)); + fprintf(outFile, " \"description\": \"%s\"\n", EscapeBackslashes(structs[i].fieldDesc[f])); fprintf(outFile, " }"); if (f < structs[i].fieldCount - 1) fprintf(outFile, ",\n"); else fprintf(outFile, "\n"); @@ -1142,20 +1593,35 @@ static void ExportParsedData(const char *fileName, int format) } fprintf(outFile, " ],\n"); + // Print aliases info + fprintf(outFile, " \"aliases\": [\n"); + for (int i = 0; i < aliasCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " \"type\": \"%s\",\n", aliases[i].type); + fprintf(outFile, " \"name\": \"%s\",\n", aliases[i].name); + fprintf(outFile, " \"description\": \"%s\"\n", aliases[i].desc); + fprintf(outFile, " }"); + + if (i < aliasCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " ],\n"); + // Print enums info fprintf(outFile, " \"enums\": [\n"); for (int i = 0; i < enumCount; i++) { fprintf(outFile, " {\n"); fprintf(outFile, " \"name\": \"%s\",\n", enums[i].name); - fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(enums[i].desc + 3)); + fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(enums[i].desc)); fprintf(outFile, " \"values\": [\n"); for (int e = 0; e < enums[i].valueCount; e++) { fprintf(outFile, " {\n"); fprintf(outFile, " \"name\": \"%s\",\n", enums[i].valueName[e]); fprintf(outFile, " \"value\": %i,\n", enums[i].valueInteger[e]); - fprintf(outFile, " \"description\": \"%s\"\n", EscapeBackslashes(enums[i].valueDesc[e] + 3)); + fprintf(outFile, " \"description\": \"%s\"\n", EscapeBackslashes(enums[i].valueDesc[e])); fprintf(outFile, " }"); if (e < enums[i].valueCount - 1) fprintf(outFile, ",\n"); else fprintf(outFile, "\n"); @@ -1167,24 +1633,33 @@ static void ExportParsedData(const char *fileName, int format) } fprintf(outFile, " ],\n"); - // Print defines info - fprintf(outFile, " \"defines\": [\n"); - for (int i = 0; i < defineCount; i++) + // Print callbacks info + fprintf(outFile, " \"callbacks\": [\n"); + for (int i = 0; i < callbackCount; i++) { fprintf(outFile, " {\n"); - fprintf(outFile, " \"name\": \"%s\",\n", defines[i].name); - fprintf(outFile, " \"type\": \"%s\",\n", StrDefineType(defines[i].type)); - if (defines[i].isHex) { // INT or LONG - fprintf(outFile, " \"value\": %ld,\n", strtol(defines[i].value, NULL, 16)); - } else if (defines[i].type == INT || defines[i].type == LONG || defines[i].type == FLOAT || defines[i].type == DOUBLE || defines[i].type == STRING) { - fprintf(outFile, " \"value\": %s,\n", defines[i].value); - } else { - fprintf(outFile, " \"value\": \"%s\",\n", defines[i].value); + fprintf(outFile, " \"name\": \"%s\",\n", callbacks[i].name); + fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(callbacks[i].desc)); + fprintf(outFile, " \"returnType\": \"%s\"", callbacks[i].retType); + + if (callbacks[i].paramCount == 0) fprintf(outFile, "\n"); + else + { + fprintf(outFile, ",\n \"params\": [\n"); + for (int p = 0; p < callbacks[i].paramCount; p++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " \"type\": \"%s\",\n", callbacks[i].paramType[p]); + fprintf(outFile, " \"name\": \"%s\"\n", callbacks[i].paramName[p]); + fprintf(outFile, " }"); + if (p < callbacks[i].paramCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " ]\n"); } - fprintf(outFile, " \"description\": \"%s\"\n", defines[i].desc + 3); fprintf(outFile, " }"); - if (i < defineCount - 1) fprintf(outFile, ",\n"); + if (i < callbackCount - 1) fprintf(outFile, ",\n"); else fprintf(outFile, "\n"); } fprintf(outFile, " ],\n"); @@ -1195,7 +1670,7 @@ static void ExportParsedData(const char *fileName, int format) { fprintf(outFile, " {\n"); fprintf(outFile, " \"name\": \"%s\",\n", funcs[i].name); - fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(funcs[i].desc + 3)); + fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(funcs[i].desc)); fprintf(outFile, " \"returnType\": \"%s\"", funcs[i].retType); if (funcs[i].paramCount == 0) fprintf(outFile, "\n"); @@ -1227,18 +1702,30 @@ static void ExportParsedData(const char *fileName, int format) /* + + + - - + + + + + - - + + + + + + + + @@ -1251,32 +1738,6 @@ static void ExportParsedData(const char *fileName, int format) fprintf(outFile, "\n"); fprintf(outFile, "\n"); - // Print structs info - fprintf(outFile, " \n", structCount); - for (int i = 0; i < structCount; i++) - { - fprintf(outFile, " \n", structs[i].name, structs[i].fieldCount, structs[i].desc + 3); - for (int f = 0; f < structs[i].fieldCount; f++) - { - fprintf(outFile, " \n", structs[i].fieldType[f], structs[i].fieldName[f], structs[i].fieldDesc[f] + 3); - } - fprintf(outFile, " \n"); - } - fprintf(outFile, " \n"); - - // Print enums info - fprintf(outFile, " \n", enumCount); - for (int i = 0; i < enumCount; i++) - { - fprintf(outFile, " \n", enums[i].name, enums[i].valueCount, enums[i].desc + 3); - for (int v = 0; v < enums[i].valueCount; v++) - { - fprintf(outFile, " \n", enums[i].valueName[v], enums[i].valueInteger[v], enums[i].valueDesc[v] + 3); - } - fprintf(outFile, " \n"); - } - fprintf(outFile, " \n"); - // Print defines info fprintf(outFile, " \n", defineCount); for (int i = 0; i < defineCount; i++) @@ -1290,18 +1751,65 @@ static void ExportParsedData(const char *fileName, int format) { fprintf(outFile, "value=\"%s\"", defines[i].value); } - fprintf(outFile, " desc=\"%s\" />\n", defines[i].desc + 3); + fprintf(outFile, " desc=\"%s\" />\n", defines[i].desc); } fprintf(outFile, " \n"); + // Print structs info + fprintf(outFile, " \n", structCount); + for (int i = 0; i < structCount; i++) + { + fprintf(outFile, " \n", structs[i].name, structs[i].fieldCount, structs[i].desc); + for (int f = 0; f < structs[i].fieldCount; f++) + { + fprintf(outFile, " \n", structs[i].fieldType[f], structs[i].fieldName[f], structs[i].fieldDesc[f]); + } + fprintf(outFile, " \n"); + } + fprintf(outFile, " \n"); + + // Print aliases info + fprintf(outFile, " \n", aliasCount); + for (int i = 0; i < aliasCount; i++) + { + fprintf(outFile, " \n", aliases[i].name, aliases[i].type, aliases[i].desc); + } + fprintf(outFile, " \n"); + + // Print enums info + fprintf(outFile, " \n", enumCount); + for (int i = 0; i < enumCount; i++) + { + fprintf(outFile, " \n", enums[i].name, enums[i].valueCount, enums[i].desc); + for (int v = 0; v < enums[i].valueCount; v++) + { + fprintf(outFile, " \n", enums[i].valueName[v], enums[i].valueInteger[v], enums[i].valueDesc[v]); + } + fprintf(outFile, " \n"); + } + fprintf(outFile, " \n"); + + // Print callbacks info + fprintf(outFile, " \n", callbackCount); + for (int i = 0; i < callbackCount; i++) + { + fprintf(outFile, " \n", callbacks[i].name, callbacks[i].retType, callbacks[i].paramCount, callbacks[i].desc); + for (int p = 0; p < callbacks[i].paramCount; p++) + { + fprintf(outFile, " \n", callbacks[i].paramType[p], callbacks[i].paramName[p], callbacks[i].paramDesc[p]); + } + fprintf(outFile, " \n"); + } + fprintf(outFile, " \n"); + // Print functions info fprintf(outFile, " \n", funcCount); for (int i = 0; i < funcCount; i++) { - fprintf(outFile, " \n", funcs[i].name, funcs[i].retType, funcs[i].paramCount, funcs[i].desc + 3); + fprintf(outFile, " \n", funcs[i].name, funcs[i].retType, funcs[i].paramCount, funcs[i].desc); for (int p = 0; p < funcs[i].paramCount; p++) { - fprintf(outFile, " \n", funcs[i].paramType[p], funcs[i].paramName[p], funcs[i].paramDesc[p] + 3); + fprintf(outFile, " \n", funcs[i].paramType[p], funcs[i].paramName[p], funcs[i].paramDesc[p]); } fprintf(outFile, " \n"); } @@ -1310,6 +1818,159 @@ static void ExportParsedData(const char *fileName, int format) fprintf(outFile, "\n"); } break; + case LUA: + { + fprintf(outFile, "return {\n"); + + // Print defines info + fprintf(outFile, " defines = {\n"); + for (int i = 0; i < defineCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", defines[i].name); + fprintf(outFile, " type = \"%s\",\n", StrDefineType(defines[i].type)); + if ((defines[i].type == INT) || + (defines[i].type == LONG) || + (defines[i].type == FLOAT) || + (defines[i].type == DOUBLE) || + (defines[i].type == STRING)) + { + fprintf(outFile, " value = %s,\n", defines[i].value); + } + else + { + fprintf(outFile, " value = \"%s\",\n", defines[i].value); + } + fprintf(outFile, " description = \"%s\"\n", defines[i].desc); + fprintf(outFile, " }"); + + if (i < defineCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " },\n"); + + // Print structs info + fprintf(outFile, " structs = {\n"); + for (int i = 0; i < structCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", structs[i].name); + fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(structs[i].desc)); + fprintf(outFile, " fields = {\n"); + for (int f = 0; f < structs[i].fieldCount; f++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " type = \"%s\",\n", structs[i].fieldType[f]); + fprintf(outFile, " name = \"%s\",\n", structs[i].fieldName[f]); + fprintf(outFile, " description = \"%s\"\n", EscapeBackslashes(structs[i].fieldDesc[f])); + fprintf(outFile, " }"); + if (f < structs[i].fieldCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " }\n"); + fprintf(outFile, " }"); + if (i < structCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " },\n"); + + // Print aliases info + fprintf(outFile, " aliases = {\n"); + for (int i = 0; i < aliasCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " type = \"%s\",\n", aliases[i].type); + fprintf(outFile, " name = \"%s\",\n", aliases[i].name); + fprintf(outFile, " description = \"%s\"\n", aliases[i].desc); + fprintf(outFile, " }"); + + if (i < aliasCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " },\n"); + + // Print enums info + fprintf(outFile, " enums = {\n"); + for (int i = 0; i < enumCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", enums[i].name); + fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(enums[i].desc)); + fprintf(outFile, " values = {\n"); + for (int e = 0; e < enums[i].valueCount; e++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", enums[i].valueName[e]); + fprintf(outFile, " value = %i,\n", enums[i].valueInteger[e]); + fprintf(outFile, " description = \"%s\"\n", EscapeBackslashes(enums[i].valueDesc[e])); + fprintf(outFile, " }"); + if (e < enums[i].valueCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " }\n"); + fprintf(outFile, " }"); + if (i < enumCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " },\n"); + + // Print callbacks info + fprintf(outFile, " callbacks = {\n"); + for (int i = 0; i < callbackCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", callbacks[i].name); + fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(callbacks[i].desc)); + fprintf(outFile, " returnType = \"%s\"", callbacks[i].retType); + + if (callbacks[i].paramCount == 0) fprintf(outFile, "\n"); + else + { + fprintf(outFile, ",\n params = {\n"); + for (int p = 0; p < callbacks[i].paramCount; p++) + { + fprintf(outFile, " {type = \"%s\", name = \"%s\"}", callbacks[i].paramType[p], callbacks[i].paramName[p]); + if (p < callbacks[i].paramCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " }\n"); + } + fprintf(outFile, " }"); + + if (i < callbackCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " },\n"); + + // Print functions info + fprintf(outFile, " functions = {\n"); + for (int i = 0; i < funcCount; i++) + { + fprintf(outFile, " {\n"); + fprintf(outFile, " name = \"%s\",\n", funcs[i].name); + fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(funcs[i].desc)); + fprintf(outFile, " returnType = \"%s\"", funcs[i].retType); + + if (funcs[i].paramCount == 0) fprintf(outFile, "\n"); + else + { + fprintf(outFile, ",\n params = {\n"); + for (int p = 0; p < funcs[i].paramCount; p++) + { + fprintf(outFile, " {type = \"%s\", name = \"%s\"}", funcs[i].paramType[p], funcs[i].paramName[p]); + if (p < funcs[i].paramCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " }\n"); + } + fprintf(outFile, " }"); + + if (i < funcCount - 1) fprintf(outFile, ",\n"); + else fprintf(outFile, "\n"); + } + fprintf(outFile, " }\n"); + fprintf(outFile, "}\n"); + } break; default: break; } diff --git a/projects/4coder/Makefile b/projects/4coder/Makefile index eca7db273..8923e732d 100644 --- a/projects/4coder/Makefile +++ b/projects/4coder/Makefile @@ -290,8 +290,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # Libraries for Windows desktop compilation # NOTE: WinMM library required to set high-res timer resolution LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - #LDLIBS += -static -lpthread endif ifeq ($(PLATFORM_OS),LINUX) # Libraries for Debian GNU/Linux desktop compiling diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index 580ecfed2..12af1c543 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+ project(example) +# Generate compile_commands.json +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + # Dependencies find_package(raylib 4.0.0 QUIET) # QUIET or REQUIRED if (NOT raylib_FOUND) # If there's none, fetch and build raylib diff --git a/projects/CMake/README.md b/projects/CMake/README.md index 402d3170c..f7873c30f 100644 --- a/projects/CMake/README.md +++ b/projects/CMake/README.md @@ -11,10 +11,8 @@ To compile the example, use one of the following dependending on your build targ Use the following to build for desktop: ``` bash -mkdir build -cd build -cmake .. -make +cmake -B build +cmake --build build ``` ### Web diff --git a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h index 85b35a405..6e7f903e7 100644 --- a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +++ b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h @@ -149,8 +149,8 @@ RLAPI char **GetDirectoryFiles(const char *dirPath, int *count); // Get filenam RLAPI void ClearDirectoryFiles(void); // Clear directory files paths buffers (free memory) RLAPI bool ChangeDirectory(const char *dir); // Change working directory, return true on success RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window -RLAPI char **GetDroppedFiles(int *count); // Get dropped files names (memory should be freed) -RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer (free memory) +RLAPI char **LoadDroppedFiles(int *count); // Get dropped files names (memory should be freed) +RLAPI void UnloadDroppedFiles(void); // Clear dropped files paths buffer (free memory) RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time) // Compression/Encoding functionality diff --git a/projects/VS2019/examples/physics_demo.vcxproj b/projects/VS2019/examples/physics_demo.vcxproj deleted file mode 100644 index e5d1a443b..000000000 --- a/projects/VS2019/examples/physics_demo.vcxproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097} - Win32Proj - physics_demo - 10.0 - physics_demo - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - - \ No newline at end of file diff --git a/projects/VS2019/examples/physics_friction.vcxproj b/projects/VS2019/examples/physics_friction.vcxproj deleted file mode 100644 index f12c3907b..000000000 --- a/projects/VS2019/examples/physics_friction.vcxproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - {A6260ED4-5361-4B61-B6B9-8D8119457BA4} - Win32Proj - physics_friction - 10.0 - physics_friction - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - - \ No newline at end of file diff --git a/projects/VS2019/examples/physics_movement.vcxproj b/projects/VS2019/examples/physics_movement.vcxproj deleted file mode 100644 index 4b6ad08a6..000000000 --- a/projects/VS2019/examples/physics_movement.vcxproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - {29817904-E3D3-4C28-BD8D-A3A09DD199D2} - Win32Proj - physics_movement - 10.0 - physics_movement - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - - \ No newline at end of file diff --git a/projects/VS2019/examples/physics_restitution.vcxproj b/projects/VS2019/examples/physics_restitution.vcxproj deleted file mode 100644 index 0561524f3..000000000 --- a/projects/VS2019/examples/physics_restitution.vcxproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1} - Win32Proj - physics_restitution - 10.0 - physics_restitution - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - - \ No newline at end of file diff --git a/projects/VS2019/examples/physics_shatter.vcxproj b/projects/VS2019/examples/physics_shatter.vcxproj deleted file mode 100644 index e4f501f03..000000000 --- a/projects/VS2019/examples/physics_shatter.vcxproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - {F272EF74-990E-4637-AF9E-77DC7139D95D} - Win32Proj - physics_shatter - 10.0 - physics_shatter - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - - \ No newline at end of file diff --git a/projects/VS2019/raylib.sln b/projects/VS2019/raylib.sln index 82f5fff21..4b37ca3d8 100644 --- a/projects/VS2019/raylib.sln +++ b/projects/VS2019/raylib.sln @@ -145,8 +145,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "textures_background_scrolli EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "text", "text", "{8D3C83B7-F1E0-4C2E-9E34-EE5F6AB2502A}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "physics", "physics", "{D6B669E2-68D0-4E62-83D1-E14DDD6A356F}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "other", "other", "{E9D708A5-9C1F-4B84-A795-C5F191801762}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "text_writing_anim", "examples\text_writing_anim.vcxproj", "{F6FD9C75-AAA7-48C9-B19D-FD37C8FB9B7E}" @@ -201,16 +199,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shapes_easings_rectangle_ar EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "top_down_lights", "examples\shapes_top_down_lights.vcxproj", "{67A9CF3B-A5E8-442E-A437-ED74A08CA312}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_demo", "examples\physics_demo.vcxproj", "{581F89BD-FBB9-4699-B8DB-EB38E6DEE097}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_friction", "examples\physics_friction.vcxproj", "{A6260ED4-5361-4B61-B6B9-8D8119457BA4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_movement", "examples\physics_movement.vcxproj", "{29817904-E3D3-4C28-BD8D-A3A09DD199D2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_restitution", "examples\physics_restitution.vcxproj", "{C7A235DF-460E-4816-9F3B-E0DEFA376EF1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_shatter", "examples\physics_shatter.vcxproj", "{F272EF74-990E-4637-AF9E-77DC7139D95D}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_basic_lighting", "examples\shaders_basic_lighting.vcxproj", "{A6B2A11B-0669-4AF5-A025-8DD02DBBE5EA}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_custom_uniform", "examples\shaders_custom_uniform.vcxproj", "{B176BB4A-CA31-4E2A-B790-3EA0ED2EE870}" diff --git a/projects/VS2022/examples/physics_demo.vcxproj b/projects/VS2022/examples/physics_demo.vcxproj deleted file mode 100644 index e5d1a443b..000000000 --- a/projects/VS2022/examples/physics_demo.vcxproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097} - Win32Proj - physics_demo - 10.0 - physics_demo - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - - \ No newline at end of file diff --git a/projects/VS2022/examples/physics_friction.vcxproj b/projects/VS2022/examples/physics_friction.vcxproj deleted file mode 100644 index f12c3907b..000000000 --- a/projects/VS2022/examples/physics_friction.vcxproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - {A6260ED4-5361-4B61-B6B9-8D8119457BA4} - Win32Proj - physics_friction - 10.0 - physics_friction - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - - \ No newline at end of file diff --git a/projects/VS2022/examples/physics_movement.vcxproj b/projects/VS2022/examples/physics_movement.vcxproj deleted file mode 100644 index 4b6ad08a6..000000000 --- a/projects/VS2022/examples/physics_movement.vcxproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - {29817904-E3D3-4C28-BD8D-A3A09DD199D2} - Win32Proj - physics_movement - 10.0 - physics_movement - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - - \ No newline at end of file diff --git a/projects/VS2022/examples/physics_restitution.vcxproj b/projects/VS2022/examples/physics_restitution.vcxproj deleted file mode 100644 index 0561524f3..000000000 --- a/projects/VS2022/examples/physics_restitution.vcxproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1} - Win32Proj - physics_restitution - 10.0 - physics_restitution - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - - \ No newline at end of file diff --git a/projects/VS2022/examples/physics_shatter.vcxproj b/projects/VS2022/examples/physics_shatter.vcxproj deleted file mode 100644 index e4f501f03..000000000 --- a/projects/VS2022/examples/physics_shatter.vcxproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - Win32 - - - Release - x64 - - - - {F272EF74-990E-4637-AF9E-77DC7139D95D} - Win32Proj - physics_shatter - 10.0 - physics_shatter - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\physics - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - - \ No newline at end of file diff --git a/projects/VS2022/raylib.sln b/projects/VS2022/raylib.sln index 9d404e39b..b77e27b08 100644 --- a/projects/VS2022/raylib.sln +++ b/projects/VS2022/raylib.sln @@ -145,8 +145,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "textures_background_scrolli EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "text", "text", "{8D3C83B7-F1E0-4C2E-9E34-EE5F6AB2502A}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "physics", "physics", "{D6B669E2-68D0-4E62-83D1-E14DDD6A356F}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "other", "other", "{E9D708A5-9C1F-4B84-A795-C5F191801762}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "text_writing_anim", "examples\text_writing_anim.vcxproj", "{F6FD9C75-AAA7-48C9-B19D-FD37C8FB9B7E}" @@ -199,16 +197,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shapes_easings_box_anim", " EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shapes_easings_rectangle_array", "examples\shapes_easings_rectangle_array.vcxproj", "{1EDD4BCF-345C-4065-8CBD-7285224293C3}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_demo", "examples\physics_demo.vcxproj", "{581F89BD-FBB9-4699-B8DB-EB38E6DEE097}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_friction", "examples\physics_friction.vcxproj", "{A6260ED4-5361-4B61-B6B9-8D8119457BA4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_movement", "examples\physics_movement.vcxproj", "{29817904-E3D3-4C28-BD8D-A3A09DD199D2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_restitution", "examples\physics_restitution.vcxproj", "{C7A235DF-460E-4816-9F3B-E0DEFA376EF1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_shatter", "examples\physics_shatter.vcxproj", "{F272EF74-990E-4637-AF9E-77DC7139D95D}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_basic_lighting", "examples\shaders_basic_lighting.vcxproj", "{A6B2A11B-0669-4AF5-A025-8DD02DBBE5EA}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_custom_uniform", "examples\shaders_custom_uniform.vcxproj", "{B176BB4A-CA31-4E2A-B790-3EA0ED2EE870}" @@ -1675,86 +1663,6 @@ Global {1EDD4BCF-345C-4065-8CBD-7285224293C3}.Release|x64.Build.0 = Release|x64 {1EDD4BCF-345C-4065-8CBD-7285224293C3}.Release|x86.ActiveCfg = Release|Win32 {1EDD4BCF-345C-4065-8CBD-7285224293C3}.Release|x86.Build.0 = Release|Win32 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Debug|x64.ActiveCfg = Debug|x64 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Debug|x64.Build.0 = Debug|x64 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Debug|x86.ActiveCfg = Debug|Win32 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Debug|x86.Build.0 = Debug|Win32 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Release.DLL|x64.ActiveCfg = Release.DLL|x64 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Release.DLL|x64.Build.0 = Release.DLL|x64 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Release.DLL|x86.Build.0 = Release.DLL|Win32 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Release|x64.ActiveCfg = Release|x64 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Release|x64.Build.0 = Release|x64 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Release|x86.ActiveCfg = Release|Win32 - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097}.Release|x86.Build.0 = Release|Win32 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Debug|x64.ActiveCfg = Debug|x64 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Debug|x64.Build.0 = Debug|x64 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Debug|x86.ActiveCfg = Debug|Win32 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Debug|x86.Build.0 = Debug|Win32 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Release.DLL|x64.ActiveCfg = Release.DLL|x64 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Release.DLL|x64.Build.0 = Release.DLL|x64 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Release.DLL|x86.Build.0 = Release.DLL|Win32 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Release|x64.ActiveCfg = Release|x64 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Release|x64.Build.0 = Release|x64 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Release|x86.ActiveCfg = Release|Win32 - {A6260ED4-5361-4B61-B6B9-8D8119457BA4}.Release|x86.Build.0 = Release|Win32 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Debug|x64.ActiveCfg = Debug|x64 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Debug|x64.Build.0 = Debug|x64 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Debug|x86.ActiveCfg = Debug|Win32 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Debug|x86.Build.0 = Debug|Win32 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Release.DLL|x64.ActiveCfg = Release.DLL|x64 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Release.DLL|x64.Build.0 = Release.DLL|x64 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Release.DLL|x86.Build.0 = Release.DLL|Win32 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Release|x64.ActiveCfg = Release|x64 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Release|x64.Build.0 = Release|x64 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Release|x86.ActiveCfg = Release|Win32 - {29817904-E3D3-4C28-BD8D-A3A09DD199D2}.Release|x86.Build.0 = Release|Win32 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Debug|x64.ActiveCfg = Debug|x64 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Debug|x64.Build.0 = Debug|x64 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Debug|x86.ActiveCfg = Debug|Win32 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Debug|x86.Build.0 = Debug|Win32 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Release.DLL|x64.ActiveCfg = Release.DLL|x64 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Release.DLL|x64.Build.0 = Release.DLL|x64 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Release.DLL|x86.Build.0 = Release.DLL|Win32 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Release|x64.ActiveCfg = Release|x64 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Release|x64.Build.0 = Release|x64 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Release|x86.ActiveCfg = Release|Win32 - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1}.Release|x86.Build.0 = Release|Win32 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Debug|x64.ActiveCfg = Debug|x64 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Debug|x64.Build.0 = Debug|x64 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Debug|x86.ActiveCfg = Debug|Win32 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Debug|x86.Build.0 = Debug|Win32 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Release.DLL|x64.ActiveCfg = Release.DLL|x64 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Release.DLL|x64.Build.0 = Release.DLL|x64 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Release.DLL|x86.Build.0 = Release.DLL|Win32 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Release|x64.ActiveCfg = Release|x64 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Release|x64.Build.0 = Release|x64 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Release|x86.ActiveCfg = Release|Win32 - {F272EF74-990E-4637-AF9E-77DC7139D95D}.Release|x86.Build.0 = Release|Win32 {A6B2A11B-0669-4AF5-A025-8DD02DBBE5EA}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 {A6B2A11B-0669-4AF5-A025-8DD02DBBE5EA}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 {A6B2A11B-0669-4AF5-A025-8DD02DBBE5EA}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 @@ -2211,7 +2119,6 @@ Global {6D75CD88-1A03-4955-B8C7-ACFC3742154F} = {DA049009-21FF-4AC0-84E4-830DD1BCD0CE} {8DD0EB7E-668E-452D-91D7-906C64A9C8AC} = {DA049009-21FF-4AC0-84E4-830DD1BCD0CE} {8D3C83B7-F1E0-4C2E-9E34-EE5F6AB2502A} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1} - {D6B669E2-68D0-4E62-83D1-E14DDD6A356F} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1} {E9D708A5-9C1F-4B84-A795-C5F191801762} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1} {F6FD9C75-AAA7-48C9-B19D-FD37C8FB9B7E} = {8D3C83B7-F1E0-4C2E-9E34-EE5F6AB2502A} {1FE8758D-7E8A-41F3-9B6D-FD50E9A2A03D} = {8D3C83B7-F1E0-4C2E-9E34-EE5F6AB2502A} @@ -2238,11 +2145,6 @@ Global {1C49E35A-2838-49D9-9D5F-4B8134960EF6} = {278D8859-20B1-428F-8448-064F46E1F021} {F91142E2-A999-47F0-9E74-38C1E2930EBE} = {278D8859-20B1-428F-8448-064F46E1F021} {1EDD4BCF-345C-4065-8CBD-7285224293C3} = {278D8859-20B1-428F-8448-064F46E1F021} - {581F89BD-FBB9-4699-B8DB-EB38E6DEE097} = {D6B669E2-68D0-4E62-83D1-E14DDD6A356F} - {A6260ED4-5361-4B61-B6B9-8D8119457BA4} = {D6B669E2-68D0-4E62-83D1-E14DDD6A356F} - {29817904-E3D3-4C28-BD8D-A3A09DD199D2} = {D6B669E2-68D0-4E62-83D1-E14DDD6A356F} - {C7A235DF-460E-4816-9F3B-E0DEFA376EF1} = {D6B669E2-68D0-4E62-83D1-E14DDD6A356F} - {F272EF74-990E-4637-AF9E-77DC7139D95D} = {D6B669E2-68D0-4E62-83D1-E14DDD6A356F} {A6B2A11B-0669-4AF5-A025-8DD02DBBE5EA} = {5317807F-61D4-4E0F-B6DC-2D9F12621ED9} {B176BB4A-CA31-4E2A-B790-3EA0ED2EE870} = {5317807F-61D4-4E0F-B6DC-2D9F12621ED9} {D08AA2A0-2F94-4BF5-B42D-E92450F03FD1} = {5317807F-61D4-4E0F-B6DC-2D9F12621ED9} diff --git a/projects/VSCode/Makefile b/projects/VSCode/Makefile index 9907c036d..4ae525c11 100644 --- a/projects/VSCode/Makefile +++ b/projects/VSCode/Makefile @@ -296,8 +296,6 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # Libraries for Windows desktop compilation # NOTE: WinMM library required to set high-res timer resolution LDLIBS = -lraylib -lopengl32 -lgdi32 -lwinmm - # Required for physac examples - #LDLIBS += -static -lpthread endif ifeq ($(PLATFORM_OS),LINUX) # Libraries for Debian GNU/Linux desktop compiling diff --git a/src/Makefile b/src/Makefile index b094099f7..d8a3b8aba 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,8 +8,8 @@ # PLATFORM_DESKTOP: OSX/macOS (arm64, x86_64) # PLATFORM_DESKTOP: FreeBSD, OpenBSD, NetBSD, DragonFly # PLATFORM_ANDROID: Android (arm, i686, arm64, x86_64) -# PLATFORM_RPI: Raspberry Pi (Raspbian) -# PLATFORM_DRM: Linux native mode, including Raspberry Pi 4 with V3D fkms driver +# PLATFORM_RPI: Raspberry Pi (deprecated - RPI OS Buster only) +# PLATFORM_DRM: Linux native mode, including Raspberry Pi (RPI OS Bullseye) # PLATFORM_WEB: HTML5 (Chrome, Firefox) # # Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline. @@ -81,8 +81,11 @@ RAYLIB_MODULE_MODELS ?= TRUE RAYLIB_MODULE_RAYGUI ?= FALSE RAYLIB_MODULE_PHYSAC ?= FALSE -RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/extras -RAYLIB_MODULE_PHYSAC_PATH ?= $(RAYLIB_SRC_PATH)/extras +# NOTE: Additional libraries have been moved to their own repos: +# raygui: https://github.com/raysan5/raygui +# physac: https://github.com/raysan5/physac +RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/../../raygui/src +RAYLIB_MODULE_PHYSAC_PATH ?= $(RAYLIB_SRC_PATH)/../../physac/src # Use external GLFW library instead of rglfw module USE_EXTERNAL_GLFW ?= FALSE @@ -509,9 +512,15 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) endif ifeq ($(PLATFORM),PLATFORM_RPI) LDLIBS = -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -ldl + ifeq ($(RAYLIB_MODULE_AUDIO),TRUE) + LDLIBS += -latomic + endif endif ifeq ($(PLATFORM),PLATFORM_DRM) LDLIBS = -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl + ifeq ($(RAYLIB_MODULE_AUDIO),TRUE) + LDLIBS += -latomic + endif endif ifeq ($(PLATFORM),PLATFORM_ANDROID) LDLIBS = -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lc -lm @@ -729,7 +738,6 @@ ifeq ($(ROOT),root) cp --update raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h cp --update raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h cp --update rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h - cp --update extras/physac.h $(RAYLIB_H_INSTALL_PATH)/physac.h @echo "raylib development files installed/updated!" else @echo "This function currently works on GNU/Linux systems. Add yours today (^;" @@ -757,7 +765,6 @@ ifeq ($(ROOT),root) rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raylib.h rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/raymath.h rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/rlgl.h - rm --force --interactive --verbose $(RAYLIB_H_INSTALL_PATH)/physac.h @echo "raylib development files removed!" else @echo "This function currently works on GNU/Linux systems. Add yours today (^;" diff --git a/src/config.h b/src/config.h index 41d8cdddc..d77d5d997 100644 --- a/src/config.h +++ b/src/config.h @@ -74,11 +74,8 @@ // rcore: Configuration values //------------------------------------------------------------------------------------ -#if defined(__linux__) - #define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value) -#else - #define MAX_FILEPATH_LENGTH 512 // Maximum length supported for filepaths -#endif +#define MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity +#define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value) #define MAX_KEYBOARD_KEYS 512 // Maximum number of keyboard keys supported #define MAX_MOUSE_BUTTONS 8 // Maximum number of mouse buttons supported diff --git a/src/extras/easings.h b/src/easings.h similarity index 80% rename from src/extras/easings.h rename to src/easings.h index 3441305f3..fb723d83a 100644 --- a/src/extras/easings.h +++ b/src/easings.h @@ -101,47 +101,47 @@ extern "C" { // Prevents name mangling of functions #endif // Linear Easing functions -EASEDEF float EaseLinearNone(float t, float b, float c, float d) { return (c*t/d + b); } -EASEDEF float EaseLinearIn(float t, float b, float c, float d) { return (c*t/d + b); } -EASEDEF float EaseLinearOut(float t, float b, float c, float d) { return (c*t/d + b); } -EASEDEF float EaseLinearInOut(float t,float b, float c, float d) { return (c*t/d + b); } +EASEDEF float EaseLinearNone(float t, float b, float c, float d) { return (c*t/d + b); } // Ease: Linear +EASEDEF float EaseLinearIn(float t, float b, float c, float d) { return (c*t/d + b); } // Ease: Linear In +EASEDEF float EaseLinearOut(float t, float b, float c, float d) { return (c*t/d + b); } // Ease: Linear Out +EASEDEF float EaseLinearInOut(float t, float b, float c, float d) { return (c*t/d + b); } // Ease: Linear In Out // Sine Easing functions -EASEDEF float EaseSineIn(float t, float b, float c, float d) { return (-c*cosf(t/d*(PI/2.0f)) + c + b); } -EASEDEF float EaseSineOut(float t, float b, float c, float d) { return (c*sinf(t/d*(PI/2.0f)) + b); } -EASEDEF float EaseSineInOut(float t, float b, float c, float d) { return (-c/2.0f*(cosf(PI*t/d) - 1.0f) + b); } +EASEDEF float EaseSineIn(float t, float b, float c, float d) { return (-c*cosf(t/d*(PI/2.0f)) + c + b); } // Ease: Sine In +EASEDEF float EaseSineOut(float t, float b, float c, float d) { return (c*sinf(t/d*(PI/2.0f)) + b); } // Ease: Sine Out +EASEDEF float EaseSineInOut(float t, float b, float c, float d) { return (-c/2.0f*(cosf(PI*t/d) - 1.0f) + b); } // Ease: Sine Out // Circular Easing functions -EASEDEF float EaseCircIn(float t, float b, float c, float d) { t /= d; return (-c*(sqrtf(1.0f - t*t) - 1.0f) + b); } -EASEDEF float EaseCircOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*sqrtf(1.0f - t*t) + b); } -EASEDEF float EaseCircInOut(float t, float b, float c, float d) +EASEDEF float EaseCircIn(float t, float b, float c, float d) { t /= d; return (-c*(sqrtf(1.0f - t*t) - 1.0f) + b); } // Ease: Circular In +EASEDEF float EaseCircOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*sqrtf(1.0f - t*t) + b); } // Ease: Circular Out +EASEDEF float EaseCircInOut(float t, float b, float c, float d) // Ease: Circular In Out { if ((t/=d/2.0f) < 1.0f) return (-c/2.0f*(sqrtf(1.0f - t*t) - 1.0f) + b); t -= 2.0f; return (c/2.0f*(sqrtf(1.0f - t*t) + 1.0f) + b); } // Cubic Easing functions -EASEDEF float EaseCubicIn(float t, float b, float c, float d) { t /= d; return (c*t*t*t + b); } -EASEDEF float EaseCubicOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*(t*t*t + 1.0f) + b); } -EASEDEF float EaseCubicInOut(float t, float b, float c, float d) +EASEDEF float EaseCubicIn(float t, float b, float c, float d) { t /= d; return (c*t*t*t + b); } // Ease: Cubic In +EASEDEF float EaseCubicOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*(t*t*t + 1.0f) + b); } // Ease: Cubic Out +EASEDEF float EaseCubicInOut(float t, float b, float c, float d) // Ease: Cubic In Out { if ((t/=d/2.0f) < 1.0f) return (c/2.0f*t*t*t + b); t -= 2.0f; return (c/2.0f*(t*t*t + 2.0f) + b); } // Quadratic Easing functions -EASEDEF float EaseQuadIn(float t, float b, float c, float d) { t /= d; return (c*t*t + b); } -EASEDEF float EaseQuadOut(float t, float b, float c, float d) { t /= d; return (-c*t*(t - 2.0f) + b); } -EASEDEF float EaseQuadInOut(float t, float b, float c, float d) +EASEDEF float EaseQuadIn(float t, float b, float c, float d) { t /= d; return (c*t*t + b); } // Ease: Quadratic In +EASEDEF float EaseQuadOut(float t, float b, float c, float d) { t /= d; return (-c*t*(t - 2.0f) + b); } // Ease: Quadratic Out +EASEDEF float EaseQuadInOut(float t, float b, float c, float d) // Ease: Quadratic In Out { if ((t/=d/2) < 1) return (((c/2)*(t*t)) + b); return (-c/2.0f*(((t - 1.0f)*(t - 3.0f)) - 1.0f) + b); } // Exponential Easing functions -EASEDEF float EaseExpoIn(float t, float b, float c, float d) { return (t == 0.0f) ? b : (c*powf(2.0f, 10.0f*(t/d - 1.0f)) + b); } -EASEDEF float EaseExpoOut(float t, float b, float c, float d) { return (t == d) ? (b + c) : (c*(-powf(2.0f, -10.0f*t/d) + 1.0f) + b); } -EASEDEF float EaseExpoInOut(float t, float b, float c, float d) +EASEDEF float EaseExpoIn(float t, float b, float c, float d) { return (t == 0.0f) ? b : (c*powf(2.0f, 10.0f*(t/d - 1.0f)) + b); } // Ease: Exponential In +EASEDEF float EaseExpoOut(float t, float b, float c, float d) { return (t == d) ? (b + c) : (c*(-powf(2.0f, -10.0f*t/d) + 1.0f) + b); } // Ease: Exponential Out +EASEDEF float EaseExpoInOut(float t, float b, float c, float d) // Ease: Exponential In Out { if (t == 0.0f) return b; if (t == d) return (b + c); @@ -151,21 +151,21 @@ EASEDEF float EaseExpoInOut(float t, float b, float c, float d) } // Back Easing functions -EASEDEF float EaseBackIn(float t, float b, float c, float d) +EASEDEF float EaseBackIn(float t, float b, float c, float d) // Ease: Back In { float s = 1.70158f; float postFix = t/=d; return (c*(postFix)*t*((s + 1.0f)*t - s) + b); } -EASEDEF float EaseBackOut(float t, float b, float c, float d) +EASEDEF float EaseBackOut(float t, float b, float c, float d) // Ease: Back Out { float s = 1.70158f; t = t/d - 1.0f; return (c*(t*t*((s + 1.0f)*t + s) + 1.0f) + b); } -EASEDEF float EaseBackInOut(float t, float b, float c, float d) +EASEDEF float EaseBackInOut(float t, float b, float c, float d) // Ease: Back In Out { float s = 1.70158f; if ((t/=d/2.0f) < 1.0f) @@ -180,7 +180,7 @@ EASEDEF float EaseBackInOut(float t, float b, float c, float d) } // Bounce Easing functions -EASEDEF float EaseBounceOut(float t, float b, float c, float d) +EASEDEF float EaseBounceOut(float t, float b, float c, float d) // Ease: Bounce Out { if ((t/=d) < (1.0f/2.75f)) { @@ -203,15 +203,15 @@ EASEDEF float EaseBounceOut(float t, float b, float c, float d) } } -EASEDEF float EaseBounceIn(float t, float b, float c, float d) { return (c - EaseBounceOut(d - t, 0.0f, c, d) + b); } -EASEDEF float EaseBounceInOut(float t, float b, float c, float d) +EASEDEF float EaseBounceIn(float t, float b, float c, float d) { return (c - EaseBounceOut(d - t, 0.0f, c, d) + b); } // Ease: Bounce In +EASEDEF float EaseBounceInOut(float t, float b, float c, float d) // Ease: Bounce In Out { if (t < d/2.0f) return (EaseBounceIn(t*2.0f, 0.0f, c, d)*0.5f + b); else return (EaseBounceOut(t*2.0f - d, 0.0f, c, d)*0.5f + c*0.5f + b); } // Elastic Easing functions -EASEDEF float EaseElasticIn(float t, float b, float c, float d) +EASEDEF float EaseElasticIn(float t, float b, float c, float d) // Ease: Elastic In { if (t == 0.0f) return b; if ((t/=d) == 1.0f) return (b + c); @@ -224,7 +224,7 @@ EASEDEF float EaseElasticIn(float t, float b, float c, float d) return (-(postFix*sinf((t*d-s)*(2.0f*PI)/p )) + b); } -EASEDEF float EaseElasticOut(float t, float b, float c, float d) +EASEDEF float EaseElasticOut(float t, float b, float c, float d) // Ease: Elastic Out { if (t == 0.0f) return b; if ((t/=d) == 1.0f) return (b + c); @@ -236,7 +236,7 @@ EASEDEF float EaseElasticOut(float t, float b, float c, float d) return (a*powf(2.0f,-10.0f*t)*sinf((t*d-s)*(2.0f*PI)/p) + c + b); } -EASEDEF float EaseElasticInOut(float t, float b, float c, float d) +EASEDEF float EaseElasticInOut(float t, float b, float c, float d) // Ease: Elastic In Out { if (t == 0.0f) return b; if ((t/=d/2.0f) == 2.0f) return (b + c); diff --git a/src/extras/physac.h b/src/extras/physac.h deleted file mode 100644 index 3ab427acd..000000000 --- a/src/extras/physac.h +++ /dev/null @@ -1,1987 +0,0 @@ -/********************************************************************************************** -* -* Physac v1.1 - 2D Physics library for videogames -* -* DESCRIPTION: -* -* Physac is a small 2D physics engine written in pure C. The engine uses a fixed time-step thread loop -* to simulate physics. A physics step contains the following phases: get collision information, -* apply dynamics, collision solving and position correction. It uses a very simple struct for physic -* bodies with a position vector to be used in any 3D rendering API. -* -* CONFIGURATION: -* -* #define PHYSAC_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. -* -* #define PHYSAC_DEBUG -* Show debug traces log messages about physic bodies creation/destruction, physic system errors, -* some calculations results and NULL reference exceptions. -* -* #define PHYSAC_AVOID_TIMMING_SYSTEM -* Disables internal timming system, used by UpdatePhysics() to launch timmed physic steps, -* it allows just running UpdatePhysics() automatically on a separate thread at a desired time step. -* In case physics steps update needs to be controlled by user with a custom timming mechanism, -* just define this flag and the internal timming mechanism will be avoided, in that case, -* timming libraries are neither required by the module. -* -* #define PHYSAC_MALLOC() -* #define PHYSAC_CALLOC() -* #define PHYSAC_FREE() -* You can define your own malloc/free implementation replacing stdlib.h malloc()/free() functions. -* Otherwise it will include stdlib.h and use the C standard library malloc()/free() function. -* -* COMPILATION: -* -* Use the following code to compile with GCC: -* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static -lraylib -lopengl32 -lgdi32 -lwinmm -std=c99 -* -* VERSIONS HISTORY: -* 1.1 (20-Jan-2021) @raysan5: Library general revision -* Removed threading system (up to the user) -* Support MSVC C++ compilation using CLITERAL() -* Review DEBUG mechanism for TRACELOG() and all TRACELOG() messages -* Review internal variables/functions naming for consistency -* Allow option to avoid internal timming system, to allow app manage the steps -* 1.0 (12-Jun-2017) First release of the library -* -* -* LICENSE: zlib/libpng -* -* Copyright (c) 2016-2022 Victor Fisac (@victorfisac) and Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ - -#if !defined(PHYSAC_H) -#define PHYSAC_H - -// Function specifiers in case library is build/used as a shared library (Windows) -// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll -#if defined(_WIN32) - #if defined(BUILD_LIBTYPE_SHARED) - #define PHYSACDEF __declspec(dllexport) // We are building the library as a Win32 shared library (.dll) - #elif defined(USE_LIBTYPE_SHARED) - #define PHYSACDEF __declspec(dllimport) // We are using the library as a Win32 shared library (.dll) - #endif -#endif - -#ifndef PHYSACDEF - #define PHYSACDEF // We are building or using physac as a static library -#endif - -// Allow custom memory allocators -#ifndef PHYSAC_MALLOC - #define PHYSAC_MALLOC(size) malloc(size) -#endif -#ifndef PHYSAC_CALLOC - #define PHYSAC_CALLOC(size, n) calloc(size, n) -#endif -#ifndef PHYSAC_FREE - #define PHYSAC_FREE(ptr) free(ptr) -#endif - -//---------------------------------------------------------------------------------- -// Defines and Macros -//---------------------------------------------------------------------------------- -#define PHYSAC_MAX_BODIES 64 // Maximum number of physic bodies supported -#define PHYSAC_MAX_MANIFOLDS 4096 // Maximum number of physic bodies interactions (64x64) -#define PHYSAC_MAX_VERTICES 24 // Maximum number of vertex for polygons shapes -#define PHYSAC_DEFAULT_CIRCLE_VERTICES 24 // Default number of vertices for circle shapes - -#define PHYSAC_COLLISION_ITERATIONS 100 -#define PHYSAC_PENETRATION_ALLOWANCE 0.05f -#define PHYSAC_PENETRATION_CORRECTION 0.4f - -#define PHYSAC_PI 3.14159265358979323846f -#define PHYSAC_DEG2RAD (PHYSAC_PI/180.0f) - -//---------------------------------------------------------------------------------- -// Data Types Structure Definition -//---------------------------------------------------------------------------------- -#if defined(__STDC__) && __STDC_VERSION__ >= 199901L - #include -#endif - -typedef enum PhysicsShapeType { PHYSICS_CIRCLE = 0, PHYSICS_POLYGON } PhysicsShapeType; - -// Previously defined to be used in PhysicsShape struct as circular dependencies -typedef struct PhysicsBodyData *PhysicsBody; - -#if !defined(RL_VECTOR2_TYPE) -// Vector2 type -typedef struct Vector2 { - float x; - float y; -} Vector2; -#endif - -// Matrix2x2 type (used for polygon shape rotation matrix) -typedef struct Matrix2x2 { - float m00; - float m01; - float m10; - float m11; -} Matrix2x2; - -typedef struct PhysicsVertexData { - unsigned int vertexCount; // Vertex count (positions and normals) - Vector2 positions[PHYSAC_MAX_VERTICES]; // Vertex positions vectors - Vector2 normals[PHYSAC_MAX_VERTICES]; // Vertex normals vectors -} PhysicsVertexData; - -typedef struct PhysicsShape { - PhysicsShapeType type; // Shape type (circle or polygon) - PhysicsBody body; // Shape physics body data pointer - PhysicsVertexData vertexData; // Shape vertices data (used for polygon shapes) - float radius; // Shape radius (used for circle shapes) - Matrix2x2 transform; // Vertices transform matrix 2x2 -} PhysicsShape; - -typedef struct PhysicsBodyData { - unsigned int id; // Unique identifier - bool enabled; // Enabled dynamics state (collisions are calculated anyway) - Vector2 position; // Physics body shape pivot - Vector2 velocity; // Current linear velocity applied to position - Vector2 force; // Current linear force (reset to 0 every step) - float angularVelocity; // Current angular velocity applied to orient - float torque; // Current angular force (reset to 0 every step) - float orient; // Rotation in radians - float inertia; // Moment of inertia - float inverseInertia; // Inverse value of inertia - float mass; // Physics body mass - float inverseMass; // Inverse value of mass - float staticFriction; // Friction when the body has not movement (0 to 1) - float dynamicFriction; // Friction when the body has movement (0 to 1) - float restitution; // Restitution coefficient of the body (0 to 1) - bool useGravity; // Apply gravity force to dynamics - bool isGrounded; // Physics grounded on other body state - bool freezeOrient; // Physics rotation constraint - PhysicsShape shape; // Physics body shape information (type, radius, vertices, transform) -} PhysicsBodyData; - -typedef struct PhysicsManifoldData { - unsigned int id; // Unique identifier - PhysicsBody bodyA; // Manifold first physics body reference - PhysicsBody bodyB; // Manifold second physics body reference - float penetration; // Depth of penetration from collision - Vector2 normal; // Normal direction vector from 'a' to 'b' - Vector2 contacts[2]; // Points of contact during collision - unsigned int contactsCount; // Current collision number of contacts - float restitution; // Mixed restitution during collision - float dynamicFriction; // Mixed dynamic friction during collision - float staticFriction; // Mixed static friction during collision -} PhysicsManifoldData, *PhysicsManifold; - -//---------------------------------------------------------------------------------- -// Module Functions Declaration -//---------------------------------------------------------------------------------- - -#if defined(__cplusplus) -extern "C" { // Prevents name mangling of functions -#endif -// Physics system management -PHYSACDEF void InitPhysics(void); // Initializes physics system -PHYSACDEF void UpdatePhysics(void); // Update physics system -PHYSACDEF void ResetPhysics(void); // Reset physics system (global variables) -PHYSACDEF void ClosePhysics(void); // Close physics system and unload used memory -PHYSACDEF void SetPhysicsTimeStep(double delta); // Sets physics fixed time step in milliseconds. 1.666666 by default -PHYSACDEF void SetPhysicsGravity(float x, float y); // Sets physics global gravity force - -// Physic body creation/destroy -PHYSACDEF PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density); // Creates a new circle physics body with generic parameters -PHYSACDEF PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density); // Creates a new rectangle physics body with generic parameters -PHYSACDEF PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density); // Creates a new polygon physics body with generic parameters -PHYSACDEF void DestroyPhysicsBody(PhysicsBody body); // Destroy a physics body - -// Physic body forces -PHYSACDEF void PhysicsAddForce(PhysicsBody body, Vector2 force); // Adds a force to a physics body -PHYSACDEF void PhysicsAddTorque(PhysicsBody body, float amount); // Adds an angular force to a physics body -PHYSACDEF void PhysicsShatter(PhysicsBody body, Vector2 position, float force); // Shatters a polygon shape physics body to little physics bodies with explosion force -PHYSACDEF void SetPhysicsBodyRotation(PhysicsBody body, float radians); // Sets physics body shape transform based on radians parameter - -// Query physics info -PHYSACDEF PhysicsBody GetPhysicsBody(int index); // Returns a physics body of the bodies pool at a specific index -PHYSACDEF int GetPhysicsBodiesCount(void); // Returns the current amount of created physics bodies -PHYSACDEF int GetPhysicsShapeType(int index); // Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON) -PHYSACDEF int GetPhysicsShapeVerticesCount(int index); // Returns the amount of vertices of a physics body shape -PHYSACDEF Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex); // Returns transformed position of a body shape (body position + vertex transformed position) -#if defined(__cplusplus) -} -#endif - -#endif // PHYSAC_H - -/*********************************************************************************** -* -* PHYSAC IMPLEMENTATION -* -************************************************************************************/ - -#if defined(PHYSAC_IMPLEMENTATION) - -// Support TRACELOG macros -#if defined(PHYSAC_DEBUG) - #include // Required for: printf() - #define TRACELOG(...) printf(__VA_ARGS__) -#else - #define TRACELOG(...) (void)0; -#endif - -#include // Required for: malloc(), calloc(), free() -#include // Required for: cosf(), sinf(), fabs(), sqrtf() - -#if !defined(PHYSAC_AVOID_TIMMING_SYSTEM) - // Time management functionality - #include // Required for: time(), clock_gettime() - #if defined(_WIN32) - #if defined(__cplusplus) - extern "C" { // Prevents name mangling of functions - #endif - // Functions required to query time on Windows - int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount); - int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency); - #if defined(__cplusplus) - } - #endif - #endif - #if defined(__linux__) || defined(__FreeBSD__) - #if _POSIX_C_SOURCE < 199309L - #undef _POSIX_C_SOURCE - #define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext. - #endif - #include // Required for: timespec - #endif - #if defined(__APPLE__) // macOS also defines __MACH__ - #include // Required for: mach_absolute_time() - #endif -#endif - -// NOTE: MSVC C++ compiler does not support compound literals (C99 feature) -// Plain structures in C++ (without constructors) can be initialized from { } initializers. -#if defined(__cplusplus) - #define CLITERAL(type) type -#else - #define CLITERAL(type) (type) -#endif - -//---------------------------------------------------------------------------------- -// Defines and Macros -//---------------------------------------------------------------------------------- -#define PHYSAC_MIN(a,b) (((a)<(b))?(a):(b)) -#define PHYSAC_MAX(a,b) (((a)>(b))?(a):(b)) -#define PHYSAC_FLT_MAX 3.402823466e+38f -#define PHYSAC_EPSILON 0.000001f -#define PHYSAC_K 1.0f/3.0f -#define PHYSAC_VECTOR_ZERO CLITERAL(Vector2){ 0.0f, 0.0f } - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -static double deltaTime = 1.0/60.0/10.0 * 1000; // Delta time in milliseconds used for physics steps - -#if !defined(PHYSAC_AVOID_TIMMING_SYSTEM) -// Time measure variables -static double baseClockTicks = 0.0; // Offset clock ticks for MONOTONIC clock -static unsigned long long int frequency = 0; // Hi-res clock frequency -static double startTime = 0.0; // Start time in milliseconds -static double currentTime = 0.0; // Current time in milliseconds -#endif - -// Physics system configuration -static PhysicsBody bodies[PHYSAC_MAX_BODIES]; // Physics bodies pointers array -static unsigned int physicsBodiesCount = 0; // Physics world current bodies counter -static PhysicsManifold contacts[PHYSAC_MAX_MANIFOLDS]; // Physics bodies pointers array -static unsigned int physicsManifoldsCount = 0; // Physics world current manifolds counter - -static Vector2 gravityForce = { 0.0f, 9.81f }; // Physics world gravity force - -// Utilities variables -static unsigned int usedMemory = 0; // Total allocated dynamic memory - -//---------------------------------------------------------------------------------- -// Module Internal Functions Declaration -//---------------------------------------------------------------------------------- -#if !defined(PHYSAC_AVOID_TIMMING_SYSTEM) -// Timming measure functions -static void InitTimerHiRes(void); // Initializes hi-resolution MONOTONIC timer -static unsigned long long int GetClockTicks(void); // Get hi-res MONOTONIC time measure in mseconds -static double GetCurrentTime(void); // Get current time measure in milliseconds -#endif - -static void UpdatePhysicsStep(void); // Update physics step (dynamics, collisions and position corrections) - -static int FindAvailableBodyIndex(); // Finds a valid index for a new physics body initialization -static int FindAvailableManifoldIndex(); // Finds a valid index for a new manifold initialization -static PhysicsVertexData CreateDefaultPolygon(float radius, int sides); // Creates a random polygon shape with max vertex distance from polygon pivot -static PhysicsVertexData CreateRectanglePolygon(Vector2 pos, Vector2 size); // Creates a rectangle polygon shape based on a min and max positions - -static void InitializePhysicsManifolds(PhysicsManifold manifold); // Initializes physics manifolds to solve collisions -static PhysicsManifold CreatePhysicsManifold(PhysicsBody a, PhysicsBody b); // Creates a new physics manifold to solve collision -static void DestroyPhysicsManifold(PhysicsManifold manifold); // Unitializes and destroys a physics manifold - -static void SolvePhysicsManifold(PhysicsManifold manifold); // Solves a created physics manifold between two physics bodies -static void SolveCircleToCircle(PhysicsManifold manifold); // Solves collision between two circle shape physics bodies -static void SolveCircleToPolygon(PhysicsManifold manifold); // Solves collision between a circle to a polygon shape physics bodies -static void SolvePolygonToCircle(PhysicsManifold manifold); // Solves collision between a polygon to a circle shape physics bodies -static void SolvePolygonToPolygon(PhysicsManifold manifold); // Solves collision between two polygons shape physics bodies -static void IntegratePhysicsForces(PhysicsBody body); // Integrates physics forces into velocity -static void IntegratePhysicsVelocity(PhysicsBody body); // Integrates physics velocity into position and forces -static void IntegratePhysicsImpulses(PhysicsManifold manifold); // Integrates physics collisions impulses to solve collisions -static void CorrectPhysicsPositions(PhysicsManifold manifold); // Corrects physics bodies positions based on manifolds collision information -static void FindIncidentFace(Vector2 *v0, Vector2 *v1, PhysicsShape ref, PhysicsShape inc, int index); // Finds two polygon shapes incident face -static float FindAxisLeastPenetration(int *faceIndex, PhysicsShape shapeA, PhysicsShape shapeB); // Finds polygon shapes axis least penetration - -// Math required functions -static Vector2 MathVector2Product(Vector2 vector, float value); // Returns the product of a vector and a value -static float MathVector2CrossProduct(Vector2 v1, Vector2 v2); // Returns the cross product of two vectors -static float MathVector2SqrLen(Vector2 vector); // Returns the len square root of a vector -static float MathVector2DotProduct(Vector2 v1, Vector2 v2); // Returns the dot product of two vectors -static inline float MathVector2SqrDistance(Vector2 v1, Vector2 v2); // Returns the square root of distance between two vectors -static void MathVector2Normalize(Vector2 *vector); // Returns the normalized values of a vector -static Vector2 MathVector2Add(Vector2 v1, Vector2 v2); // Returns the sum of two given vectors -static Vector2 MathVector2Subtract(Vector2 v1, Vector2 v2); // Returns the subtract of two given vectors -static Matrix2x2 MathMatFromRadians(float radians); // Returns a matrix 2x2 from a given radians value -static inline Matrix2x2 MathMatTranspose(Matrix2x2 matrix); // Returns the transpose of a given matrix 2x2 -static inline Vector2 MathMatVector2Product(Matrix2x2 matrix, Vector2 vector); // Returns product between matrix 2x2 and vector -static int MathVector2Clip(Vector2 normal, Vector2 *faceA, Vector2 *faceB, float clip); // Returns clipping value based on a normal and two faces -static Vector2 MathTriangleBarycenter(Vector2 v1, Vector2 v2, Vector2 v3); // Returns the barycenter of a triangle given by 3 points - -//---------------------------------------------------------------------------------- -// Module Functions Definition -//---------------------------------------------------------------------------------- - -// Initializes physics values, pointers and creates physics loop thread -void InitPhysics(void) -{ -#if !defined(PHYSAC_AVOID_TIMMING_SYSTEM) - // Initialize high resolution timer - InitTimerHiRes(); -#endif - - TRACELOG("[PHYSAC] Physics module initialized successfully\n"); -} - -// Sets physics global gravity force -void SetPhysicsGravity(float x, float y) -{ - gravityForce.x = x; - gravityForce.y = y; -} - -// Creates a new circle physics body with generic parameters -PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density) -{ - PhysicsBody body = CreatePhysicsBodyPolygon(pos, radius, PHYSAC_DEFAULT_CIRCLE_VERTICES, density); - return body; -} - -// Creates a new rectangle physics body with generic parameters -PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density) -{ - // NOTE: Make sure body data is initialized to 0 - PhysicsBody body = (PhysicsBody)PHYSAC_CALLOC(sizeof(PhysicsBodyData), 1); - usedMemory += sizeof(PhysicsBodyData); - - int id = FindAvailableBodyIndex(); - if (id != -1) - { - // Initialize new body with generic values - body->id = id; - body->enabled = true; - body->position = pos; - body->shape.type = PHYSICS_POLYGON; - body->shape.body = body; - body->shape.transform = MathMatFromRadians(0.0f); - body->shape.vertexData = CreateRectanglePolygon(pos, CLITERAL(Vector2){ width, height }); - - // Calculate centroid and moment of inertia - Vector2 center = { 0.0f, 0.0f }; - float area = 0.0f; - float inertia = 0.0f; - - for (unsigned int i = 0; i < body->shape.vertexData.vertexCount; i++) - { - // Triangle vertices, third vertex implied as (0, 0) - Vector2 p1 = body->shape.vertexData.positions[i]; - unsigned int nextIndex = (((i + 1) < body->shape.vertexData.vertexCount) ? (i + 1) : 0); - Vector2 p2 = body->shape.vertexData.positions[nextIndex]; - - float D = MathVector2CrossProduct(p1, p2); - float triangleArea = D/2; - - area += triangleArea; - - // Use area to weight the centroid average, not just vertex position - center.x += triangleArea*PHYSAC_K*(p1.x + p2.x); - center.y += triangleArea*PHYSAC_K*(p1.y + p2.y); - - float intx2 = p1.x*p1.x + p2.x*p1.x + p2.x*p2.x; - float inty2 = p1.y*p1.y + p2.y*p1.y + p2.y*p2.y; - inertia += (0.25f*PHYSAC_K*D)*(intx2 + inty2); - } - - center.x *= 1.0f/area; - center.y *= 1.0f/area; - - // Translate vertices to centroid (make the centroid (0, 0) for the polygon in model space) - // Note: this is not really necessary - for (unsigned int i = 0; i < body->shape.vertexData.vertexCount; i++) - { - body->shape.vertexData.positions[i].x -= center.x; - body->shape.vertexData.positions[i].y -= center.y; - } - - body->mass = density*area; - body->inverseMass = ((body->mass != 0.0f) ? 1.0f/body->mass : 0.0f); - body->inertia = density*inertia; - body->inverseInertia = ((body->inertia != 0.0f) ? 1.0f/body->inertia : 0.0f); - body->staticFriction = 0.4f; - body->dynamicFriction = 0.2f; - body->restitution = 0.0f; - body->useGravity = true; - body->isGrounded = false; - body->freezeOrient = false; - - // Add new body to bodies pointers array and update bodies count - bodies[physicsBodiesCount] = body; - physicsBodiesCount++; - - TRACELOG("[PHYSAC] Physic body created successfully (id: %i)\n", body->id); - } - else TRACELOG("[PHYSAC] Physic body could not be created, PHYSAC_MAX_BODIES reached\n"); - - return body; -} - -// Creates a new polygon physics body with generic parameters -PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density) -{ - PhysicsBody body = (PhysicsBody)PHYSAC_MALLOC(sizeof(PhysicsBodyData)); - usedMemory += sizeof(PhysicsBodyData); - - int id = FindAvailableBodyIndex(); - if (id != -1) - { - // Initialize new body with generic values - body->id = id; - body->enabled = true; - body->position = pos; - body->velocity = PHYSAC_VECTOR_ZERO; - body->force = PHYSAC_VECTOR_ZERO; - body->angularVelocity = 0.0f; - body->torque = 0.0f; - body->orient = 0.0f; - body->shape.type = PHYSICS_POLYGON; - body->shape.body = body; - body->shape.transform = MathMatFromRadians(0.0f); - body->shape.vertexData = CreateDefaultPolygon(radius, sides); - - // Calculate centroid and moment of inertia - Vector2 center = { 0.0f, 0.0f }; - float area = 0.0f; - float inertia = 0.0f; - - for (unsigned int i = 0; i < body->shape.vertexData.vertexCount; i++) - { - // Triangle vertices, third vertex implied as (0, 0) - Vector2 position1 = body->shape.vertexData.positions[i]; - unsigned int nextIndex = (((i + 1) < body->shape.vertexData.vertexCount) ? (i + 1) : 0); - Vector2 position2 = body->shape.vertexData.positions[nextIndex]; - - float cross = MathVector2CrossProduct(position1, position2); - float triangleArea = cross/2; - - area += triangleArea; - - // Use area to weight the centroid average, not just vertex position - center.x += triangleArea*PHYSAC_K*(position1.x + position2.x); - center.y += triangleArea*PHYSAC_K*(position1.y + position2.y); - - float intx2 = position1.x*position1.x + position2.x*position1.x + position2.x*position2.x; - float inty2 = position1.y*position1.y + position2.y*position1.y + position2.y*position2.y; - inertia += (0.25f*PHYSAC_K*cross)*(intx2 + inty2); - } - - center.x *= 1.0f/area; - center.y *= 1.0f/area; - - // Translate vertices to centroid (make the centroid (0, 0) for the polygon in model space) - // Note: this is not really necessary - for (unsigned int i = 0; i < body->shape.vertexData.vertexCount; i++) - { - body->shape.vertexData.positions[i].x -= center.x; - body->shape.vertexData.positions[i].y -= center.y; - } - - body->mass = density*area; - body->inverseMass = ((body->mass != 0.0f) ? 1.0f/body->mass : 0.0f); - body->inertia = density*inertia; - body->inverseInertia = ((body->inertia != 0.0f) ? 1.0f/body->inertia : 0.0f); - body->staticFriction = 0.4f; - body->dynamicFriction = 0.2f; - body->restitution = 0.0f; - body->useGravity = true; - body->isGrounded = false; - body->freezeOrient = false; - - // Add new body to bodies pointers array and update bodies count - bodies[physicsBodiesCount] = body; - physicsBodiesCount++; - - TRACELOG("[PHYSAC] Physic body created successfully (id: %i)\n", body->id); - } - else TRACELOG("[PHYSAC] Physics body could not be created, PHYSAC_MAX_BODIES reached\n"); - - return body; -} - -// Adds a force to a physics body -void PhysicsAddForce(PhysicsBody body, Vector2 force) -{ - if (body != NULL) body->force = MathVector2Add(body->force, force); -} - -// Adds an angular force to a physics body -void PhysicsAddTorque(PhysicsBody body, float amount) -{ - if (body != NULL) body->torque += amount; -} - -// Shatters a polygon shape physics body to little physics bodies with explosion force -void PhysicsShatter(PhysicsBody body, Vector2 position, float force) -{ - if (body != NULL) - { - if (body->shape.type == PHYSICS_POLYGON) - { - PhysicsVertexData vertexData = body->shape.vertexData; - bool collision = false; - - for (unsigned int i = 0; i < vertexData.vertexCount; i++) - { - Vector2 positionA = body->position; - Vector2 positionB = MathMatVector2Product(body->shape.transform, MathVector2Add(body->position, vertexData.positions[i])); - unsigned int nextIndex = (((i + 1) < vertexData.vertexCount) ? (i + 1) : 0); - Vector2 positionC = MathMatVector2Product(body->shape.transform, MathVector2Add(body->position, vertexData.positions[nextIndex])); - - // Check collision between each triangle - float alpha = ((positionB.y - positionC.y)*(position.x - positionC.x) + (positionC.x - positionB.x)*(position.y - positionC.y))/ - ((positionB.y - positionC.y)*(positionA.x - positionC.x) + (positionC.x - positionB.x)*(positionA.y - positionC.y)); - - float beta = ((positionC.y - positionA.y)*(position.x - positionC.x) + (positionA.x - positionC.x)*(position.y - positionC.y))/ - ((positionB.y - positionC.y)*(positionA.x - positionC.x) + (positionC.x - positionB.x)*(positionA.y - positionC.y)); - - float gamma = 1.0f - alpha - beta; - - if ((alpha > 0.0f) && (beta > 0.0f) & (gamma > 0.0f)) - { - collision = true; - break; - } - } - - if (collision) - { - int count = vertexData.vertexCount; - Vector2 bodyPos = body->position; - Vector2 *vertices = (Vector2 *)PHYSAC_MALLOC(sizeof(Vector2)*count); - Matrix2x2 trans = body->shape.transform; - for (int i = 0; i < count; i++) vertices[i] = vertexData.positions[i]; - - // Destroy shattered physics body - DestroyPhysicsBody(body); - - for (int i = 0; i < count; i++) - { - int nextIndex = (((i + 1) < count) ? (i + 1) : 0); - Vector2 center = MathTriangleBarycenter(vertices[i], vertices[nextIndex], PHYSAC_VECTOR_ZERO); - center = MathVector2Add(bodyPos, center); - Vector2 offset = MathVector2Subtract(center, bodyPos); - - PhysicsBody body = CreatePhysicsBodyPolygon(center, 10, 3, 10); // Create polygon physics body with relevant values - - PhysicsVertexData vertexData = { 0 }; - vertexData.vertexCount = 3; - - vertexData.positions[0] = MathVector2Subtract(vertices[i], offset); - vertexData.positions[1] = MathVector2Subtract(vertices[nextIndex], offset); - vertexData.positions[2] = MathVector2Subtract(position, center); - - // Separate vertices to avoid unnecessary physics collisions - vertexData.positions[0].x *= 0.95f; - vertexData.positions[0].y *= 0.95f; - vertexData.positions[1].x *= 0.95f; - vertexData.positions[1].y *= 0.95f; - vertexData.positions[2].x *= 0.95f; - vertexData.positions[2].y *= 0.95f; - - // Calculate polygon faces normals - for (unsigned int j = 0; j < vertexData.vertexCount; j++) - { - unsigned int nextVertex = (((j + 1) < vertexData.vertexCount) ? (j + 1) : 0); - Vector2 face = MathVector2Subtract(vertexData.positions[nextVertex], vertexData.positions[j]); - - vertexData.normals[j] = CLITERAL(Vector2){ face.y, -face.x }; - MathVector2Normalize(&vertexData.normals[j]); - } - - // Apply computed vertex data to new physics body shape - body->shape.vertexData = vertexData; - body->shape.transform = trans; - - // Calculate centroid and moment of inertia - center = PHYSAC_VECTOR_ZERO; - float area = 0.0f; - float inertia = 0.0f; - - for (unsigned int j = 0; j < body->shape.vertexData.vertexCount; j++) - { - // Triangle vertices, third vertex implied as (0, 0) - Vector2 p1 = body->shape.vertexData.positions[j]; - unsigned int nextVertex = (((j + 1) < body->shape.vertexData.vertexCount) ? (j + 1) : 0); - Vector2 p2 = body->shape.vertexData.positions[nextVertex]; - - float D = MathVector2CrossProduct(p1, p2); - float triangleArea = D/2; - - area += triangleArea; - - // Use area to weight the centroid average, not just vertex position - center.x += triangleArea*PHYSAC_K*(p1.x + p2.x); - center.y += triangleArea*PHYSAC_K*(p1.y + p2.y); - - float intx2 = p1.x*p1.x + p2.x*p1.x + p2.x*p2.x; - float inty2 = p1.y*p1.y + p2.y*p1.y + p2.y*p2.y; - inertia += (0.25f*PHYSAC_K*D)*(intx2 + inty2); - } - - center.x *= 1.0f/area; - center.y *= 1.0f/area; - - body->mass = area; - body->inverseMass = ((body->mass != 0.0f) ? 1.0f/body->mass : 0.0f); - body->inertia = inertia; - body->inverseInertia = ((body->inertia != 0.0f) ? 1.0f/body->inertia : 0.0f); - - // Calculate explosion force direction - Vector2 pointA = body->position; - Vector2 pointB = MathVector2Subtract(vertexData.positions[1], vertexData.positions[0]); - pointB.x /= 2.0f; - pointB.y /= 2.0f; - Vector2 forceDirection = MathVector2Subtract(MathVector2Add(pointA, MathVector2Add(vertexData.positions[0], pointB)), body->position); - MathVector2Normalize(&forceDirection); - forceDirection.x *= force; - forceDirection.y *= force; - - // Apply force to new physics body - PhysicsAddForce(body, forceDirection); - } - - PHYSAC_FREE(vertices); - } - } - } - else TRACELOG("[PHYSAC] WARNING: PhysicsShatter: NULL physic body\n"); -} - -// Returns the current amount of created physics bodies -int GetPhysicsBodiesCount(void) -{ - return physicsBodiesCount; -} - -// Returns a physics body of the bodies pool at a specific index -PhysicsBody GetPhysicsBody(int index) -{ - PhysicsBody body = NULL; - - if (index < (int)physicsBodiesCount) - { - body = bodies[index]; - - if (body == NULL) TRACELOG("[PHYSAC] WARNING: GetPhysicsBody: NULL physic body\n"); - } - else TRACELOG("[PHYSAC] WARNING: Physic body index is out of bounds\n"); - - return body; -} - -// Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON) -int GetPhysicsShapeType(int index) -{ - int result = -1; - - if (index < (int)physicsBodiesCount) - { - PhysicsBody body = bodies[index]; - - if (body != NULL) result = body->shape.type; - else TRACELOG("[PHYSAC] WARNING: GetPhysicsShapeType: NULL physic body\n"); - } - else TRACELOG("[PHYSAC] WARNING: Physic body index is out of bounds\n"); - - return result; -} - -// Returns the amount of vertices of a physics body shape -int GetPhysicsShapeVerticesCount(int index) -{ - int result = 0; - - if (index < (int)physicsBodiesCount) - { - PhysicsBody body = bodies[index]; - - if (body != NULL) - { - switch (body->shape.type) - { - case PHYSICS_CIRCLE: result = PHYSAC_DEFAULT_CIRCLE_VERTICES; break; - case PHYSICS_POLYGON: result = body->shape.vertexData.vertexCount; break; - default: break; - } - } - else TRACELOG("[PHYSAC] WARNING: GetPhysicsShapeVerticesCount: NULL physic body\n"); - } - else TRACELOG("[PHYSAC] WARNING: Physic body index is out of bounds\n"); - - return result; -} - -// Returns transformed position of a body shape (body position + vertex transformed position) -Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex) -{ - Vector2 position = { 0.0f, 0.0f }; - - if (body != NULL) - { - switch (body->shape.type) - { - case PHYSICS_CIRCLE: - { - position.x = body->position.x + cosf(360.0f/PHYSAC_DEFAULT_CIRCLE_VERTICES*vertex*PHYSAC_DEG2RAD)*body->shape.radius; - position.y = body->position.y + sinf(360.0f/PHYSAC_DEFAULT_CIRCLE_VERTICES*vertex*PHYSAC_DEG2RAD)*body->shape.radius; - } break; - case PHYSICS_POLYGON: - { - PhysicsVertexData vertexData = body->shape.vertexData; - position = MathVector2Add(body->position, MathMatVector2Product(body->shape.transform, vertexData.positions[vertex])); - } break; - default: break; - } - } - else TRACELOG("[PHYSAC] WARNING: GetPhysicsShapeVertex: NULL physic body\n"); - - return position; -} - -// Sets physics body shape transform based on radians parameter -void SetPhysicsBodyRotation(PhysicsBody body, float radians) -{ - if (body != NULL) - { - body->orient = radians; - - if (body->shape.type == PHYSICS_POLYGON) body->shape.transform = MathMatFromRadians(radians); - } -} - -// Unitializes and destroys a physics body -void DestroyPhysicsBody(PhysicsBody body) -{ - if (body != NULL) - { - int id = body->id; - int index = -1; - - for (unsigned int i = 0; i < physicsBodiesCount; i++) - { - if (bodies[i]->id == id) - { - index = i; - break; - } - } - - if (index == -1) - { - TRACELOG("[PHYSAC] WARNING: Requested body (id: %i) can not be found\n", id); - return; // Prevent access to index -1 - } - - // Free body allocated memory - PHYSAC_FREE(body); - usedMemory -= sizeof(PhysicsBodyData); - bodies[index] = NULL; - - // Reorder physics bodies pointers array and its catched index - for (unsigned int i = index; i < physicsBodiesCount; i++) - { - if ((i + 1) < physicsBodiesCount) bodies[i] = bodies[i + 1]; - } - - // Update physics bodies count - physicsBodiesCount--; - - TRACELOG("[PHYSAC] Physic body destroyed successfully (id: %i)\n", id); - } - else TRACELOG("[PHYSAC] WARNING: DestroyPhysicsBody: NULL physic body\n"); -} - -// Destroys created physics bodies and manifolds and resets global values -void ResetPhysics(void) -{ - if (physicsBodiesCount > 0) - { - // Unitialize physics bodies dynamic memory allocations - for (int i = physicsBodiesCount - 1; i >= 0; i--) - { - PhysicsBody body = bodies[i]; - - if (body != NULL) - { - PHYSAC_FREE(body); - bodies[i] = NULL; - usedMemory -= sizeof(PhysicsBodyData); - } - } - - physicsBodiesCount = 0; - } - - if (physicsManifoldsCount > 0) - { - // Unitialize physics manifolds dynamic memory allocations - for (int i = physicsManifoldsCount - 1; i >= 0; i--) - { - PhysicsManifold manifold = contacts[i]; - - if (manifold != NULL) - { - PHYSAC_FREE(manifold); - contacts[i] = NULL; - usedMemory -= sizeof(PhysicsManifoldData); - } - } - - physicsManifoldsCount = 0; - } - - TRACELOG("[PHYSAC] Physics module reseted successfully\n"); -} - -// Unitializes physics pointers and exits physics loop thread -void ClosePhysics(void) -{ - // Unitialize physics manifolds dynamic memory allocations - if (physicsManifoldsCount > 0) - { - for (int i = physicsManifoldsCount - 1; i >= 0; i--) DestroyPhysicsManifold(contacts[i]); - } - - // Unitialize physics bodies dynamic memory allocations - if (physicsBodiesCount > 0) - { - for (int i = physicsBodiesCount - 1; i >= 0; i--) DestroyPhysicsBody(bodies[i]); - } - - // Trace log info - if ((physicsBodiesCount > 0) || (usedMemory != 0)) - { - TRACELOG("[PHYSAC] WARNING: Physics module closed with unallocated bodies (BODIES: %i, MEMORY: %i bytes)\n", physicsBodiesCount, usedMemory); - } - else if ((physicsManifoldsCount > 0) || (usedMemory != 0)) - { - TRACELOG("[PHYSAC] WARNING: Pysics module closed with unallocated manifolds (MANIFOLDS: %i, MEMORY: %i bytes)\n", physicsManifoldsCount, usedMemory); - } - else TRACELOG("[PHYSAC] Physics module closed successfully\n"); -} - -// Update physics system -// Physics steps are launched at a fixed time step if enabled -void UpdatePhysics(void) -{ -#if !defined(PHYSAC_AVOID_TIMMING_SYSTEM) - static double deltaTimeAccumulator = 0.0; - - // Calculate current time (ms) - currentTime = GetCurrentTime(); - - // Calculate current delta time (ms) - const double delta = currentTime - startTime; - - // Store the time elapsed since the last frame began - deltaTimeAccumulator += delta; - - // Fixed time stepping loop - while (deltaTimeAccumulator >= deltaTime) - { - UpdatePhysicsStep(); - deltaTimeAccumulator -= deltaTime; - } - - // Record the starting of this frame - startTime = currentTime; -#else - UpdatePhysicsStep(); -#endif -} - -void SetPhysicsTimeStep(double delta) -{ - deltaTime = delta; -} - -//---------------------------------------------------------------------------------- -// Module Internal Functions Definition -//---------------------------------------------------------------------------------- -#if !defined(PHYSAC_AVOID_TIMMING_SYSTEM) -// Initializes hi-resolution MONOTONIC timer -static void InitTimerHiRes(void) -{ -#if defined(_WIN32) - QueryPerformanceFrequency((unsigned long long int *) &frequency); -#endif - -#if defined(__EMSCRIPTEN__) || defined(__linux__) - struct timespec now; - if (clock_gettime(CLOCK_MONOTONIC, &now) == 0) frequency = 1000000000; -#endif - -#if defined(__APPLE__) - mach_timebase_info_data_t timebase; - mach_timebase_info(&timebase); - frequency = (timebase.denom*1e9)/timebase.numer; -#endif - - baseClockTicks = (double)GetClockTicks(); // Get MONOTONIC clock time offset - startTime = GetCurrentTime(); // Get current time in milliseconds -} - -// Get hi-res MONOTONIC time measure in clock ticks -static unsigned long long int GetClockTicks(void) -{ - unsigned long long int value = 0; - -#if defined(_WIN32) - QueryPerformanceCounter((unsigned long long int *) &value); -#endif - -#if defined(__linux__) - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - value = (unsigned long long int)now.tv_sec*(unsigned long long int)1000000000 + (unsigned long long int)now.tv_nsec; -#endif - -#if defined(__APPLE__) - value = mach_absolute_time(); -#endif - - return value; -} - -// Get current time in milliseconds -static double GetCurrentTime(void) -{ - return (double)(GetClockTicks() - baseClockTicks)/frequency*1000; -} -#endif // !PHYSAC_AVOID_TIMMING_SYSTEM - -// Update physics step (dynamics, collisions and position corrections) -static void UpdatePhysicsStep(void) -{ - // Clear previous generated collisions information - for (int i = (int)physicsManifoldsCount - 1; i >= 0; i--) - { - PhysicsManifold manifold = contacts[i]; - if (manifold != NULL) DestroyPhysicsManifold(manifold); - } - - // Reset physics bodies grounded state - for (unsigned int i = 0; i < physicsBodiesCount; i++) - { - PhysicsBody body = bodies[i]; - body->isGrounded = false; - } - - // Generate new collision information - for (unsigned int i = 0; i < physicsBodiesCount; i++) - { - PhysicsBody bodyA = bodies[i]; - - if (bodyA != NULL) - { - for (unsigned int j = i + 1; j < physicsBodiesCount; j++) - { - PhysicsBody bodyB = bodies[j]; - - if (bodyB != NULL) - { - if ((bodyA->inverseMass == 0) && (bodyB->inverseMass == 0)) continue; - - PhysicsManifold manifold = CreatePhysicsManifold(bodyA, bodyB); - SolvePhysicsManifold(manifold); - - if (manifold->contactsCount > 0) - { - // Create a new manifold with same information as previously solved manifold and add it to the manifolds pool last slot - PhysicsManifold manifold = CreatePhysicsManifold(bodyA, bodyB); - manifold->penetration = manifold->penetration; - manifold->normal = manifold->normal; - manifold->contacts[0] = manifold->contacts[0]; - manifold->contacts[1] = manifold->contacts[1]; - manifold->contactsCount = manifold->contactsCount; - manifold->restitution = manifold->restitution; - manifold->dynamicFriction = manifold->dynamicFriction; - manifold->staticFriction = manifold->staticFriction; - } - } - } - } - } - - // Integrate forces to physics bodies - for (unsigned int i = 0; i < physicsBodiesCount; i++) - { - PhysicsBody body = bodies[i]; - if (body != NULL) IntegratePhysicsForces(body); - } - - // Initialize physics manifolds to solve collisions - for (unsigned int i = 0; i < physicsManifoldsCount; i++) - { - PhysicsManifold manifold = contacts[i]; - if (manifold != NULL) InitializePhysicsManifolds(manifold); - } - - // Integrate physics collisions impulses to solve collisions - for (unsigned int i = 0; i < PHYSAC_COLLISION_ITERATIONS; i++) - { - for (unsigned int j = 0; j < physicsManifoldsCount; j++) - { - PhysicsManifold manifold = contacts[i]; - if (manifold != NULL) IntegratePhysicsImpulses(manifold); - } - } - - // Integrate velocity to physics bodies - for (unsigned int i = 0; i < physicsBodiesCount; i++) - { - PhysicsBody body = bodies[i]; - if (body != NULL) IntegratePhysicsVelocity(body); - } - - // Correct physics bodies positions based on manifolds collision information - for (unsigned int i = 0; i < physicsManifoldsCount; i++) - { - PhysicsManifold manifold = contacts[i]; - if (manifold != NULL) CorrectPhysicsPositions(manifold); - } - - // Clear physics bodies forces - for (unsigned int i = 0; i < physicsBodiesCount; i++) - { - PhysicsBody body = bodies[i]; - if (body != NULL) - { - body->force = PHYSAC_VECTOR_ZERO; - body->torque = 0.0f; - } - } -} - -// Finds a valid index for a new physics body initialization -static int FindAvailableBodyIndex() -{ - int index = -1; - for (int i = 0; i < PHYSAC_MAX_BODIES; i++) - { - int currentId = i; - - // Check if current id already exist in other physics body - for (unsigned int k = 0; k < physicsBodiesCount; k++) - { - if (bodies[k]->id == currentId) - { - currentId++; - break; - } - } - - // If it is not used, use it as new physics body id - if (currentId == (int)i) - { - index = (int)i; - break; - } - } - - return index; -} - -// Creates a default polygon shape with max vertex distance from polygon pivot -static PhysicsVertexData CreateDefaultPolygon(float radius, int sides) -{ - PhysicsVertexData data = { 0 }; - data.vertexCount = sides; - - // Calculate polygon vertices positions - for (unsigned int i = 0; i < data.vertexCount; i++) - { - data.positions[i].x = (float)cosf(360.0f/sides*i*PHYSAC_DEG2RAD)*radius; - data.positions[i].y = (float)sinf(360.0f/sides*i*PHYSAC_DEG2RAD)*radius; - } - - // Calculate polygon faces normals - for (int i = 0; i < (int)data.vertexCount; i++) - { - int nextIndex = (((i + 1) < sides) ? (i + 1) : 0); - Vector2 face = MathVector2Subtract(data.positions[nextIndex], data.positions[i]); - - data.normals[i] = CLITERAL(Vector2){ face.y, -face.x }; - MathVector2Normalize(&data.normals[i]); - } - - return data; -} - -// Creates a rectangle polygon shape based on a min and max positions -static PhysicsVertexData CreateRectanglePolygon(Vector2 pos, Vector2 size) -{ - PhysicsVertexData data = { 0 }; - data.vertexCount = 4; - - // Calculate polygon vertices positions - data.positions[0] = CLITERAL(Vector2){ pos.x + size.x/2, pos.y - size.y/2 }; - data.positions[1] = CLITERAL(Vector2){ pos.x + size.x/2, pos.y + size.y/2 }; - data.positions[2] = CLITERAL(Vector2){ pos.x - size.x/2, pos.y + size.y/2 }; - data.positions[3] = CLITERAL(Vector2){ pos.x - size.x/2, pos.y - size.y/2 }; - - // Calculate polygon faces normals - for (unsigned int i = 0; i < data.vertexCount; i++) - { - int nextIndex = (((i + 1) < data.vertexCount) ? (i + 1) : 0); - Vector2 face = MathVector2Subtract(data.positions[nextIndex], data.positions[i]); - - data.normals[i] = CLITERAL(Vector2){ face.y, -face.x }; - MathVector2Normalize(&data.normals[i]); - } - - return data; -} - -// Finds a valid index for a new manifold initialization -static int FindAvailableManifoldIndex() -{ - int index = -1; - for (int i = 0; i < PHYSAC_MAX_MANIFOLDS; i++) - { - int currentId = i; - - // Check if current id already exist in other physics body - for (unsigned int k = 0; k < physicsManifoldsCount; k++) - { - if (contacts[k]->id == currentId) - { - currentId++; - break; - } - } - - // If it is not used, use it as new physics body id - if (currentId == i) - { - index = i; - break; - } - } - - return index; -} - -// Creates a new physics manifold to solve collision -static PhysicsManifold CreatePhysicsManifold(PhysicsBody a, PhysicsBody b) -{ - PhysicsManifold manifold = (PhysicsManifold)PHYSAC_MALLOC(sizeof(PhysicsManifoldData)); - usedMemory += sizeof(PhysicsManifoldData); - - int id = FindAvailableManifoldIndex(); - if (id != -1) - { - // Initialize new manifold with generic values - manifold->id = id; - manifold->bodyA = a; - manifold->bodyB = b; - manifold->penetration = 0; - manifold->normal = PHYSAC_VECTOR_ZERO; - manifold->contacts[0] = PHYSAC_VECTOR_ZERO; - manifold->contacts[1] = PHYSAC_VECTOR_ZERO; - manifold->contactsCount = 0; - manifold->restitution = 0.0f; - manifold->dynamicFriction = 0.0f; - manifold->staticFriction = 0.0f; - - // Add new body to bodies pointers array and update bodies count - contacts[physicsManifoldsCount] = manifold; - physicsManifoldsCount++; - } - else TRACELOG("[PHYSAC] Physic manifold could not be created, PHYSAC_MAX_MANIFOLDS reached\n"); - - return manifold; -} - -// Unitializes and destroys a physics manifold -static void DestroyPhysicsManifold(PhysicsManifold manifold) -{ - if (manifold != NULL) - { - int id = manifold->id; - int index = -1; - - for (unsigned int i = 0; i < physicsManifoldsCount; i++) - { - if (contacts[i]->id == id) - { - index = i; - break; - } - } - - if (index == -1) return; // Prevent access to index -1 - - // Free manifold allocated memory - PHYSAC_FREE(manifold); - usedMemory -= sizeof(PhysicsManifoldData); - contacts[index] = NULL; - - // Reorder physics manifolds pointers array and its catched index - for (unsigned int i = index; i < physicsManifoldsCount; i++) - { - if ((i + 1) < physicsManifoldsCount) contacts[i] = contacts[i + 1]; - } - - // Update physics manifolds count - physicsManifoldsCount--; - } - else TRACELOG("[PHYSAC] WARNING: DestroyPhysicsManifold: NULL physic manifold\n"); -} - -// Solves a created physics manifold between two physics bodies -static void SolvePhysicsManifold(PhysicsManifold manifold) -{ - switch (manifold->bodyA->shape.type) - { - case PHYSICS_CIRCLE: - { - switch (manifold->bodyB->shape.type) - { - case PHYSICS_CIRCLE: SolveCircleToCircle(manifold); break; - case PHYSICS_POLYGON: SolveCircleToPolygon(manifold); break; - default: break; - } - } break; - case PHYSICS_POLYGON: - { - switch (manifold->bodyB->shape.type) - { - case PHYSICS_CIRCLE: SolvePolygonToCircle(manifold); break; - case PHYSICS_POLYGON: SolvePolygonToPolygon(manifold); break; - default: break; - } - } break; - default: break; - } - - // Update physics body grounded state if normal direction is down and grounded state is not set yet in previous manifolds - if (!manifold->bodyB->isGrounded) manifold->bodyB->isGrounded = (manifold->normal.y < 0); -} - -// Solves collision between two circle shape physics bodies -static void SolveCircleToCircle(PhysicsManifold manifold) -{ - PhysicsBody bodyA = manifold->bodyA; - PhysicsBody bodyB = manifold->bodyB; - - if ((bodyA == NULL) || (bodyB == NULL)) return; - - // Calculate translational vector, which is normal - Vector2 normal = MathVector2Subtract(bodyB->position, bodyA->position); - - float distSqr = MathVector2SqrLen(normal); - float radius = bodyA->shape.radius + bodyB->shape.radius; - - // Check if circles are not in contact - if (distSqr >= radius*radius) - { - manifold->contactsCount = 0; - return; - } - - float distance = sqrtf(distSqr); - manifold->contactsCount = 1; - - if (distance == 0.0f) - { - manifold->penetration = bodyA->shape.radius; - manifold->normal = CLITERAL(Vector2){ 1.0f, 0.0f }; - manifold->contacts[0] = bodyA->position; - } - else - { - manifold->penetration = radius - distance; - manifold->normal = CLITERAL(Vector2){ normal.x/distance, normal.y/distance }; // Faster than using MathVector2Normalize() due to sqrt is already performed - manifold->contacts[0] = CLITERAL(Vector2){ manifold->normal.x*bodyA->shape.radius + bodyA->position.x, manifold->normal.y*bodyA->shape.radius + bodyA->position.y }; - } - - // Update physics body grounded state if normal direction is down - if (!bodyA->isGrounded) bodyA->isGrounded = (manifold->normal.y < 0); -} - -// Solves collision between a circle to a polygon shape physics bodies -static void SolveCircleToPolygon(PhysicsManifold manifold) -{ - PhysicsBody bodyA = manifold->bodyA; - PhysicsBody bodyB = manifold->bodyB; - - if ((bodyA == NULL) || (bodyB == NULL)) return; - - manifold->contactsCount = 0; - - // Transform circle center to polygon transform space - Vector2 center = bodyA->position; - center = MathMatVector2Product(MathMatTranspose(bodyB->shape.transform), MathVector2Subtract(center, bodyB->position)); - - // Find edge with minimum penetration - // It is the same concept as using support points in SolvePolygonToPolygon - float separation = -PHYSAC_FLT_MAX; - int faceNormal = 0; - PhysicsVertexData vertexData = bodyB->shape.vertexData; - - for (unsigned int i = 0; i < vertexData.vertexCount; i++) - { - float currentSeparation = MathVector2DotProduct(vertexData.normals[i], MathVector2Subtract(center, vertexData.positions[i])); - - if (currentSeparation > bodyA->shape.radius) return; - - if (currentSeparation > separation) - { - separation = currentSeparation; - faceNormal = i; - } - } - - // Grab face's vertices - Vector2 v1 = vertexData.positions[faceNormal]; - int nextIndex = (((faceNormal + 1) < (int)vertexData.vertexCount) ? (faceNormal + 1) : 0); - Vector2 v2 = vertexData.positions[nextIndex]; - - // Check to see if center is within polygon - if (separation < PHYSAC_EPSILON) - { - manifold->contactsCount = 1; - Vector2 normal = MathMatVector2Product(bodyB->shape.transform, vertexData.normals[faceNormal]); - manifold->normal = CLITERAL(Vector2){ -normal.x, -normal.y }; - manifold->contacts[0] = CLITERAL(Vector2){ manifold->normal.x*bodyA->shape.radius + bodyA->position.x, manifold->normal.y*bodyA->shape.radius + bodyA->position.y }; - manifold->penetration = bodyA->shape.radius; - return; - } - - // Determine which voronoi region of the edge center of circle lies within - float dot1 = MathVector2DotProduct(MathVector2Subtract(center, v1), MathVector2Subtract(v2, v1)); - float dot2 = MathVector2DotProduct(MathVector2Subtract(center, v2), MathVector2Subtract(v1, v2)); - manifold->penetration = bodyA->shape.radius - separation; - - if (dot1 <= 0.0f) // Closest to v1 - { - if (MathVector2SqrDistance(center, v1) > bodyA->shape.radius*bodyA->shape.radius) return; - - manifold->contactsCount = 1; - Vector2 normal = MathVector2Subtract(v1, center); - normal = MathMatVector2Product(bodyB->shape.transform, normal); - MathVector2Normalize(&normal); - manifold->normal = normal; - v1 = MathMatVector2Product(bodyB->shape.transform, v1); - v1 = MathVector2Add(v1, bodyB->position); - manifold->contacts[0] = v1; - } - else if (dot2 <= 0.0f) // Closest to v2 - { - if (MathVector2SqrDistance(center, v2) > bodyA->shape.radius*bodyA->shape.radius) return; - - manifold->contactsCount = 1; - Vector2 normal = MathVector2Subtract(v2, center); - v2 = MathMatVector2Product(bodyB->shape.transform, v2); - v2 = MathVector2Add(v2, bodyB->position); - manifold->contacts[0] = v2; - normal = MathMatVector2Product(bodyB->shape.transform, normal); - MathVector2Normalize(&normal); - manifold->normal = normal; - } - else // Closest to face - { - Vector2 normal = vertexData.normals[faceNormal]; - - if (MathVector2DotProduct(MathVector2Subtract(center, v1), normal) > bodyA->shape.radius) return; - - normal = MathMatVector2Product(bodyB->shape.transform, normal); - manifold->normal = CLITERAL(Vector2){ -normal.x, -normal.y }; - manifold->contacts[0] = CLITERAL(Vector2){ manifold->normal.x*bodyA->shape.radius + bodyA->position.x, manifold->normal.y*bodyA->shape.radius + bodyA->position.y }; - manifold->contactsCount = 1; - } -} - -// Solves collision between a polygon to a circle shape physics bodies -static void SolvePolygonToCircle(PhysicsManifold manifold) -{ - PhysicsBody bodyA = manifold->bodyA; - PhysicsBody bodyB = manifold->bodyB; - - if ((bodyA == NULL) || (bodyB == NULL)) return; - - manifold->bodyA = bodyB; - manifold->bodyB = bodyA; - SolveCircleToPolygon(manifold); - - manifold->normal.x *= -1.0f; - manifold->normal.y *= -1.0f; -} - -// Solves collision between two polygons shape physics bodies -static void SolvePolygonToPolygon(PhysicsManifold manifold) -{ - if ((manifold->bodyA == NULL) || (manifold->bodyB == NULL)) return; - - PhysicsShape bodyA = manifold->bodyA->shape; - PhysicsShape bodyB = manifold->bodyB->shape; - manifold->contactsCount = 0; - - // Check for separating axis with A shape's face planes - int faceA = 0; - float penetrationA = FindAxisLeastPenetration(&faceA, bodyA, bodyB); - if (penetrationA >= 0.0f) return; - - // Check for separating axis with B shape's face planes - int faceB = 0; - float penetrationB = FindAxisLeastPenetration(&faceB, bodyB, bodyA); - if (penetrationB >= 0.0f) return; - - int referenceIndex = 0; - bool flip = false; // Always point from A shape to B shape - - PhysicsShape refPoly; // Reference - PhysicsShape incPoly; // Incident - - // Determine which shape contains reference face - // Checking bias range for penetration - if (penetrationA >= (penetrationB*0.95f + penetrationA*0.01f)) - { - refPoly = bodyA; - incPoly = bodyB; - referenceIndex = faceA; - } - else - { - refPoly = bodyB; - incPoly = bodyA; - referenceIndex = faceB; - flip = true; - } - - // World space incident face - Vector2 incidentFace[2]; - FindIncidentFace(&incidentFace[0], &incidentFace[1], refPoly, incPoly, referenceIndex); - - // Setup reference face vertices - PhysicsVertexData refData = refPoly.vertexData; - Vector2 v1 = refData.positions[referenceIndex]; - referenceIndex = (((referenceIndex + 1) < (int)refData.vertexCount) ? (referenceIndex + 1) : 0); - Vector2 v2 = refData.positions[referenceIndex]; - - // Transform vertices to world space - v1 = MathMatVector2Product(refPoly.transform, v1); - v1 = MathVector2Add(v1, refPoly.body->position); - v2 = MathMatVector2Product(refPoly.transform, v2); - v2 = MathVector2Add(v2, refPoly.body->position); - - // Calculate reference face side normal in world space - Vector2 sidePlaneNormal = MathVector2Subtract(v2, v1); - MathVector2Normalize(&sidePlaneNormal); - - // Orthogonalize - Vector2 refFaceNormal = { sidePlaneNormal.y, -sidePlaneNormal.x }; - float refC = MathVector2DotProduct(refFaceNormal, v1); - float negSide = MathVector2DotProduct(sidePlaneNormal, v1)*-1; - float posSide = MathVector2DotProduct(sidePlaneNormal, v2); - - // MathVector2Clip incident face to reference face side planes (due to floating point error, possible to not have required points - if (MathVector2Clip(CLITERAL(Vector2){ -sidePlaneNormal.x, -sidePlaneNormal.y }, &incidentFace[0], &incidentFace[1], negSide) < 2) return; - if (MathVector2Clip(sidePlaneNormal, &incidentFace[0], &incidentFace[1], posSide) < 2) return; - - // Flip normal if required - manifold->normal = (flip ? CLITERAL(Vector2){ -refFaceNormal.x, -refFaceNormal.y } : refFaceNormal); - - // Keep points behind reference face - int currentPoint = 0; // MathVector2Clipped points behind reference face - float separation = MathVector2DotProduct(refFaceNormal, incidentFace[0]) - refC; - if (separation <= 0.0f) - { - manifold->contacts[currentPoint] = incidentFace[0]; - manifold->penetration = -separation; - currentPoint++; - } - else manifold->penetration = 0.0f; - - separation = MathVector2DotProduct(refFaceNormal, incidentFace[1]) - refC; - - if (separation <= 0.0f) - { - manifold->contacts[currentPoint] = incidentFace[1]; - manifold->penetration += -separation; - currentPoint++; - - // Calculate total penetration average - manifold->penetration /= currentPoint; - } - - manifold->contactsCount = currentPoint; -} - -// Integrates physics forces into velocity -static void IntegratePhysicsForces(PhysicsBody body) -{ - if ((body == NULL) || (body->inverseMass == 0.0f) || !body->enabled) return; - - body->velocity.x += (float)((body->force.x*body->inverseMass)*(deltaTime/2.0)); - body->velocity.y += (float)((body->force.y*body->inverseMass)*(deltaTime/2.0)); - - if (body->useGravity) - { - body->velocity.x += (float)(gravityForce.x*(deltaTime/1000/2.0)); - body->velocity.y += (float)(gravityForce.y*(deltaTime/1000/2.0)); - } - - if (!body->freezeOrient) body->angularVelocity += (float)(body->torque*body->inverseInertia*(deltaTime/2.0)); -} - -// Initializes physics manifolds to solve collisions -static void InitializePhysicsManifolds(PhysicsManifold manifold) -{ - PhysicsBody bodyA = manifold->bodyA; - PhysicsBody bodyB = manifold->bodyB; - - if ((bodyA == NULL) || (bodyB == NULL)) return; - - // Calculate average restitution, static and dynamic friction - manifold->restitution = sqrtf(bodyA->restitution*bodyB->restitution); - manifold->staticFriction = sqrtf(bodyA->staticFriction*bodyB->staticFriction); - manifold->dynamicFriction = sqrtf(bodyA->dynamicFriction*bodyB->dynamicFriction); - - for (unsigned int i = 0; i < manifold->contactsCount; i++) - { - // Caculate radius from center of mass to contact - Vector2 radiusA = MathVector2Subtract(manifold->contacts[i], bodyA->position); - Vector2 radiusB = MathVector2Subtract(manifold->contacts[i], bodyB->position); - - Vector2 crossA = MathVector2Product(radiusA, bodyA->angularVelocity); - Vector2 crossB = MathVector2Product(radiusB, bodyB->angularVelocity); - - Vector2 radiusV = { 0.0f, 0.0f }; - radiusV.x = bodyB->velocity.x + crossB.x - bodyA->velocity.x - crossA.x; - radiusV.y = bodyB->velocity.y + crossB.y - bodyA->velocity.y - crossA.y; - - // Determine if we should perform a resting collision or not; - // The idea is if the only thing moving this object is gravity, then the collision should be performed without any restitution - if (MathVector2SqrLen(radiusV) < (MathVector2SqrLen(CLITERAL(Vector2){ (float)(gravityForce.x*deltaTime/1000), (float)(gravityForce.y*deltaTime/1000) }) + PHYSAC_EPSILON)) manifold->restitution = 0; - } -} - -// Integrates physics collisions impulses to solve collisions -static void IntegratePhysicsImpulses(PhysicsManifold manifold) -{ - PhysicsBody bodyA = manifold->bodyA; - PhysicsBody bodyB = manifold->bodyB; - - if ((bodyA == NULL) || (bodyB == NULL)) return; - - // Early out and positional correct if both objects have infinite mass - if (fabs(bodyA->inverseMass + bodyB->inverseMass) <= PHYSAC_EPSILON) - { - bodyA->velocity = PHYSAC_VECTOR_ZERO; - bodyB->velocity = PHYSAC_VECTOR_ZERO; - return; - } - - for (unsigned int i = 0; i < manifold->contactsCount; i++) - { - // Calculate radius from center of mass to contact - Vector2 radiusA = MathVector2Subtract(manifold->contacts[i], bodyA->position); - Vector2 radiusB = MathVector2Subtract(manifold->contacts[i], bodyB->position); - - // Calculate relative velocity - Vector2 radiusV = { 0.0f, 0.0f }; - radiusV.x = bodyB->velocity.x + MathVector2Product(radiusB, bodyB->angularVelocity).x - bodyA->velocity.x - MathVector2Product(radiusA, bodyA->angularVelocity).x; - radiusV.y = bodyB->velocity.y + MathVector2Product(radiusB, bodyB->angularVelocity).y - bodyA->velocity.y - MathVector2Product(radiusA, bodyA->angularVelocity).y; - - // Relative velocity along the normal - float contactVelocity = MathVector2DotProduct(radiusV, manifold->normal); - - // Do not resolve if velocities are separating - if (contactVelocity > 0.0f) return; - - float raCrossN = MathVector2CrossProduct(radiusA, manifold->normal); - float rbCrossN = MathVector2CrossProduct(radiusB, manifold->normal); - - float inverseMassSum = bodyA->inverseMass + bodyB->inverseMass + (raCrossN*raCrossN)*bodyA->inverseInertia + (rbCrossN*rbCrossN)*bodyB->inverseInertia; - - // Calculate impulse scalar value - float impulse = -(1.0f + manifold->restitution)*contactVelocity; - impulse /= inverseMassSum; - impulse /= (float)manifold->contactsCount; - - // Apply impulse to each physics body - Vector2 impulseV = { manifold->normal.x*impulse, manifold->normal.y*impulse }; - - if (bodyA->enabled) - { - bodyA->velocity.x += bodyA->inverseMass*(-impulseV.x); - bodyA->velocity.y += bodyA->inverseMass*(-impulseV.y); - if (!bodyA->freezeOrient) bodyA->angularVelocity += bodyA->inverseInertia*MathVector2CrossProduct(radiusA, CLITERAL(Vector2){ -impulseV.x, -impulseV.y }); - } - - if (bodyB->enabled) - { - bodyB->velocity.x += bodyB->inverseMass*(impulseV.x); - bodyB->velocity.y += bodyB->inverseMass*(impulseV.y); - if (!bodyB->freezeOrient) bodyB->angularVelocity += bodyB->inverseInertia*MathVector2CrossProduct(radiusB, impulseV); - } - - // Apply friction impulse to each physics body - radiusV.x = bodyB->velocity.x + MathVector2Product(radiusB, bodyB->angularVelocity).x - bodyA->velocity.x - MathVector2Product(radiusA, bodyA->angularVelocity).x; - radiusV.y = bodyB->velocity.y + MathVector2Product(radiusB, bodyB->angularVelocity).y - bodyA->velocity.y - MathVector2Product(radiusA, bodyA->angularVelocity).y; - - Vector2 tangent = { radiusV.x - (manifold->normal.x*MathVector2DotProduct(radiusV, manifold->normal)), radiusV.y - (manifold->normal.y*MathVector2DotProduct(radiusV, manifold->normal)) }; - MathVector2Normalize(&tangent); - - // Calculate impulse tangent magnitude - float impulseTangent = -MathVector2DotProduct(radiusV, tangent); - impulseTangent /= inverseMassSum; - impulseTangent /= (float)manifold->contactsCount; - - float absImpulseTangent = (float)fabs(impulseTangent); - - // Don't apply tiny friction impulses - if (absImpulseTangent <= PHYSAC_EPSILON) return; - - // Apply coulumb's law - Vector2 tangentImpulse = { 0.0f, 0.0f }; - if (absImpulseTangent < impulse*manifold->staticFriction) tangentImpulse = CLITERAL(Vector2){ tangent.x*impulseTangent, tangent.y*impulseTangent }; - else tangentImpulse = CLITERAL(Vector2){ tangent.x*-impulse*manifold->dynamicFriction, tangent.y*-impulse*manifold->dynamicFriction }; - - // Apply friction impulse - if (bodyA->enabled) - { - bodyA->velocity.x += bodyA->inverseMass*(-tangentImpulse.x); - bodyA->velocity.y += bodyA->inverseMass*(-tangentImpulse.y); - - if (!bodyA->freezeOrient) bodyA->angularVelocity += bodyA->inverseInertia*MathVector2CrossProduct(radiusA, CLITERAL(Vector2){ -tangentImpulse.x, -tangentImpulse.y }); - } - - if (bodyB->enabled) - { - bodyB->velocity.x += bodyB->inverseMass*(tangentImpulse.x); - bodyB->velocity.y += bodyB->inverseMass*(tangentImpulse.y); - - if (!bodyB->freezeOrient) bodyB->angularVelocity += bodyB->inverseInertia*MathVector2CrossProduct(radiusB, tangentImpulse); - } - } -} - -// Integrates physics velocity into position and forces -static void IntegratePhysicsVelocity(PhysicsBody body) -{ - if ((body == NULL) ||!body->enabled) return; - - body->position.x += (float)(body->velocity.x*deltaTime); - body->position.y += (float)(body->velocity.y*deltaTime); - - if (!body->freezeOrient) body->orient += (float)(body->angularVelocity*deltaTime); - body->shape.transform = MathMatFromRadians(body->orient); - - IntegratePhysicsForces(body); -} - -// Corrects physics bodies positions based on manifolds collision information -static void CorrectPhysicsPositions(PhysicsManifold manifold) -{ - PhysicsBody bodyA = manifold->bodyA; - PhysicsBody bodyB = manifold->bodyB; - - if ((bodyA == NULL) || (bodyB == NULL)) return; - - Vector2 correction = { 0.0f, 0.0f }; - correction.x = (PHYSAC_MAX(manifold->penetration - PHYSAC_PENETRATION_ALLOWANCE, 0.0f)/(bodyA->inverseMass + bodyB->inverseMass))*manifold->normal.x*PHYSAC_PENETRATION_CORRECTION; - correction.y = (PHYSAC_MAX(manifold->penetration - PHYSAC_PENETRATION_ALLOWANCE, 0.0f)/(bodyA->inverseMass + bodyB->inverseMass))*manifold->normal.y*PHYSAC_PENETRATION_CORRECTION; - - if (bodyA->enabled) - { - bodyA->position.x -= correction.x*bodyA->inverseMass; - bodyA->position.y -= correction.y*bodyA->inverseMass; - } - - if (bodyB->enabled) - { - bodyB->position.x += correction.x*bodyB->inverseMass; - bodyB->position.y += correction.y*bodyB->inverseMass; - } -} - -// Returns the extreme point along a direction within a polygon -static Vector2 GetSupport(PhysicsShape shape, Vector2 dir) -{ - float bestProjection = -PHYSAC_FLT_MAX; - Vector2 bestVertex = { 0.0f, 0.0f }; - PhysicsVertexData data = shape.vertexData; - - for (unsigned int i = 0; i < data.vertexCount; i++) - { - Vector2 vertex = data.positions[i]; - float projection = MathVector2DotProduct(vertex, dir); - - if (projection > bestProjection) - { - bestVertex = vertex; - bestProjection = projection; - } - } - - return bestVertex; -} - -// Finds polygon shapes axis least penetration -static float FindAxisLeastPenetration(int *faceIndex, PhysicsShape shapeA, PhysicsShape shapeB) -{ - float bestDistance = -PHYSAC_FLT_MAX; - int bestIndex = 0; - - PhysicsVertexData dataA = shapeA.vertexData; - //PhysicsVertexData dataB = shapeB.vertexData; - - for (unsigned int i = 0; i < dataA.vertexCount; i++) - { - // Retrieve a face normal from A shape - Vector2 normal = dataA.normals[i]; - Vector2 transNormal = MathMatVector2Product(shapeA.transform, normal); - - // Transform face normal into B shape's model space - Matrix2x2 buT = MathMatTranspose(shapeB.transform); - normal = MathMatVector2Product(buT, transNormal); - - // Retrieve support point from B shape along -n - Vector2 support = GetSupport(shapeB, CLITERAL(Vector2){ -normal.x, -normal.y }); - - // Retrieve vertex on face from A shape, transform into B shape's model space - Vector2 vertex = dataA.positions[i]; - vertex = MathMatVector2Product(shapeA.transform, vertex); - vertex = MathVector2Add(vertex, shapeA.body->position); - vertex = MathVector2Subtract(vertex, shapeB.body->position); - vertex = MathMatVector2Product(buT, vertex); - - // Compute penetration distance in B shape's model space - float distance = MathVector2DotProduct(normal, MathVector2Subtract(support, vertex)); - - // Store greatest distance - if (distance > bestDistance) - { - bestDistance = distance; - bestIndex = i; - } - } - - *faceIndex = bestIndex; - return bestDistance; -} - -// Finds two polygon shapes incident face -static void FindIncidentFace(Vector2 *v0, Vector2 *v1, PhysicsShape ref, PhysicsShape inc, int index) -{ - PhysicsVertexData refData = ref.vertexData; - PhysicsVertexData incData = inc.vertexData; - - Vector2 referenceNormal = refData.normals[index]; - - // Calculate normal in incident's frame of reference - referenceNormal = MathMatVector2Product(ref.transform, referenceNormal); // To world space - referenceNormal = MathMatVector2Product(MathMatTranspose(inc.transform), referenceNormal); // To incident's model space - - // Find most anti-normal face on polygon - int incidentFace = 0; - float minDot = PHYSAC_FLT_MAX; - - for (unsigned int i = 0; i < incData.vertexCount; i++) - { - float dot = MathVector2DotProduct(referenceNormal, incData.normals[i]); - - if (dot < minDot) - { - minDot = dot; - incidentFace = i; - } - } - - // Assign face vertices for incident face - *v0 = MathMatVector2Product(inc.transform, incData.positions[incidentFace]); - *v0 = MathVector2Add(*v0, inc.body->position); - incidentFace = (((incidentFace + 1) < (int)incData.vertexCount) ? (incidentFace + 1) : 0); - *v1 = MathMatVector2Product(inc.transform, incData.positions[incidentFace]); - *v1 = MathVector2Add(*v1, inc.body->position); -} - -// Returns clipping value based on a normal and two faces -static int MathVector2Clip(Vector2 normal, Vector2 *faceA, Vector2 *faceB, float clip) -{ - int sp = 0; - Vector2 out[2] = { *faceA, *faceB }; - - // Retrieve distances from each endpoint to the line - float distanceA = MathVector2DotProduct(normal, *faceA) - clip; - float distanceB = MathVector2DotProduct(normal, *faceB) - clip; - - // If negative (behind plane) - if (distanceA <= 0.0f) out[sp++] = *faceA; - if (distanceB <= 0.0f) out[sp++] = *faceB; - - // If the points are on different sides of the plane - if ((distanceA*distanceB) < 0.0f) - { - // Push intersection point - float alpha = distanceA/(distanceA - distanceB); - out[sp] = *faceA; - Vector2 delta = MathVector2Subtract(*faceB, *faceA); - delta.x *= alpha; - delta.y *= alpha; - out[sp] = MathVector2Add(out[sp], delta); - sp++; - } - - // Assign the new converted values - *faceA = out[0]; - *faceB = out[1]; - - return sp; -} - -// Returns the barycenter of a triangle given by 3 points -static Vector2 MathTriangleBarycenter(Vector2 v1, Vector2 v2, Vector2 v3) -{ - Vector2 result = { 0.0f, 0.0f }; - - result.x = (v1.x + v2.x + v3.x)/3; - result.y = (v1.y + v2.y + v3.y)/3; - - return result; -} - -// Returns the cross product of a vector and a value -static inline Vector2 MathVector2Product(Vector2 vector, float value) -{ - Vector2 result = { -value*vector.y, value*vector.x }; - return result; -} - -// Returns the cross product of two vectors -static inline float MathVector2CrossProduct(Vector2 v1, Vector2 v2) -{ - return (v1.x*v2.y - v1.y*v2.x); -} - -// Returns the len square root of a vector -static inline float MathVector2SqrLen(Vector2 vector) -{ - return (vector.x*vector.x + vector.y*vector.y); -} - -// Returns the dot product of two vectors -static inline float MathVector2DotProduct(Vector2 v1, Vector2 v2) -{ - return (v1.x*v2.x + v1.y*v2.y); -} - -// Returns the square root of distance between two vectors -static inline float MathVector2SqrDistance(Vector2 v1, Vector2 v2) -{ - Vector2 dir = MathVector2Subtract(v1, v2); - return MathVector2DotProduct(dir, dir); -} - -// Returns the normalized values of a vector -static void MathVector2Normalize(Vector2 *vector) -{ - float length, ilength; - - Vector2 aux = *vector; - length = sqrtf(aux.x*aux.x + aux.y*aux.y); - - if (length == 0) length = 1.0f; - - ilength = 1.0f/length; - - vector->x *= ilength; - vector->y *= ilength; -} - -// Returns the sum of two given vectors -static inline Vector2 MathVector2Add(Vector2 v1, Vector2 v2) -{ - Vector2 result = { v1.x + v2.x, v1.y + v2.y }; - return result; -} - -// Returns the subtract of two given vectors -static inline Vector2 MathVector2Subtract(Vector2 v1, Vector2 v2) -{ - Vector2 result = { v1.x - v2.x, v1.y - v2.y }; - return result; -} - -// Creates a matrix 2x2 from a given radians value -static Matrix2x2 MathMatFromRadians(float radians) -{ - float cos = cosf(radians); - float sin = sinf(radians); - - Matrix2x2 result = { cos, -sin, sin, cos }; - return result; -} - -// Returns the transpose of a given matrix 2x2 -static inline Matrix2x2 MathMatTranspose(Matrix2x2 matrix) -{ - Matrix2x2 result = { matrix.m00, matrix.m10, matrix.m01, matrix.m11 }; - return result; -} - -// Multiplies a vector by a matrix 2x2 -static inline Vector2 MathMatVector2Product(Matrix2x2 matrix, Vector2 vector) -{ - Vector2 result = { matrix.m00*vector.x + matrix.m01*vector.y, matrix.m10*vector.x + matrix.m11*vector.y }; - return result; -} - -#endif // PHYSAC_IMPLEMENTATION diff --git a/src/raudio.c b/src/raudio.c index 9b83afd7f..19ecc1626 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -247,10 +247,6 @@ typedef struct tagBITMAPINFOHEADER { #include "external/dr_flac.h" // FLAC loading functions #endif -#if defined(_MSC_VER) - #undef bool -#endif - //---------------------------------------------------------------------------------- // Defines and Macros //---------------------------------------------------------------------------------- @@ -314,7 +310,7 @@ typedef enum { // Audio buffer struct struct rAudioBuffer { ma_data_converter converter; // Audio data converter - + AudioCallback callback; // Audio buffer callback for buffer filling on audio threads rAudioProcessor *processor; // Audio processor @@ -338,7 +334,7 @@ struct rAudioBuffer { rAudioBuffer *prev; // Previous audio buffer on the list }; -// Audio processor struct +// Audio processor struct // NOTE: Useful to apply effects to an AudioBuffer struct rAudioProcessor { AudioCallback process; // Processor callback function @@ -355,6 +351,8 @@ typedef struct AudioData { ma_device device; // miniaudio device ma_mutex lock; // miniaudio mutex lock bool isReady; // Check if audio device is ready + size_t pcmCapacity; + void *pcm; } System; struct { AudioBuffer *first; // Pointer to first AudioBuffer in the list @@ -514,6 +512,7 @@ void CloseAudioDevice(void) ma_context_uninit(&AUDIO.System.context); AUDIO.System.isReady = false; + RL_FREE(AUDIO.System.pcm); TRACELOG(LOG_INFO, "AUDIO: Device closed successfully"); } @@ -566,14 +565,14 @@ AudioBuffer *LoadAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sam audioBuffer->volume = 1.0f; audioBuffer->pitch = 1.0f; audioBuffer->pan = 0.5f; - + audioBuffer->callback = NULL; audioBuffer->processor = NULL; audioBuffer->playing = false; audioBuffer->paused = false; audioBuffer->looping = false; - + audioBuffer->usage = usage; audioBuffer->frameCursorPos = 0; audioBuffer->sizeInFrames = sizeInFrames; @@ -1156,8 +1155,8 @@ void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels) ma_format formatOut = ((sampleSize == 8)? ma_format_u8 : ((sampleSize == 16)? ma_format_s16 : ma_format_f32)); ma_uint32 frameCountIn = wave->frameCount; - ma_uint32 frameCount = (ma_uint32)ma_convert_frames(NULL, 0, formatOut, channels, sampleRate, NULL, frameCountIn, formatIn, wave->channels, wave->sampleRate); + if (frameCount == 0) { TRACELOG(LOG_WARNING, "WAVE: Failed to get frame count for format conversion"); @@ -1177,6 +1176,7 @@ void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels) wave->sampleSize = sampleSize; wave->sampleRate = sampleRate; wave->channels = channels; + RL_FREE(wave->data); wave->data = data; } @@ -1206,8 +1206,7 @@ Wave WaveCopy(Wave wave) // NOTE: Security check in case of out-of-range void WaveCrop(Wave *wave, int initSample, int finalSample) { - if ((initSample >= 0) && (initSample < finalSample) && - (finalSample > 0) && ((unsigned int)finalSample < (wave->frameCount*wave->channels))) + if ((initSample >= 0) && (initSample < finalSample) && ((unsigned int)finalSample < (wave->frameCount*wave->channels))) { int sampleCount = finalSample - initSample; @@ -1518,16 +1517,14 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, jar_xm_set_max_loop_count(ctxXm, 0); // Set infinite number of loops unsigned int bits = 32; - if (AUDIO_DEVICE_FORMAT == ma_format_s16) - bits = 16; - else if (AUDIO_DEVICE_FORMAT == ma_format_u8) - bits = 8; + if (AUDIO_DEVICE_FORMAT == ma_format_s16) bits = 16; + else if (AUDIO_DEVICE_FORMAT == ma_format_u8) bits = 8; // NOTE: Only stereo is supported for XM music.stream = LoadAudioStream(AUDIO.System.device.sampleRate, bits, 2); music.frameCount = (unsigned int)jar_xm_get_remaining_samples(ctxXm); // NOTE: Always 2 channels (stereo) music.looping = true; // Looping enabled by default - jar_xm_reset(ctxXm); // make sure we start at the beginning of the song + jar_xm_reset(ctxXm); // make sure we start at the beginning of the song music.ctxData = ctxXm; musicLoaded = true; @@ -1548,7 +1545,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, for (int i = 0; i < it; i++) newData[i] = data[i]; // Memory loaded version for jar_mod_load_file() - if (dataSize && dataSize < 32*1024*1024) + if (dataSize && (dataSize < 32*1024*1024)) { ctxMod->modfilesize = dataSize; ctxMod->modfile = newData; @@ -1628,7 +1625,7 @@ void UnloadMusicStream(Music music) else if (music.ctxType == MUSIC_AUDIO_FLAC) drflac_free((drflac *)music.ctxData, NULL); #endif #if defined(SUPPORT_FILEFORMAT_MP3) - else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); } + else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); } #endif #if defined(SUPPORT_FILEFORMAT_XM) else if (music.ctxType == MUSIC_MODULE_XM) jar_xm_free_context((jar_xm_context_t *)music.ctxData); @@ -1732,7 +1729,12 @@ void UpdateMusicStream(Music music) unsigned int subBufferSizeInFrames = music.stream.buffer->sizeInFrames/2; // NOTE: Using dynamic allocation because it could require more than 16KB - void *pcm = RL_CALLOC(subBufferSizeInFrames*music.stream.channels*music.stream.sampleSize/8, 1); + size_t pcmSize = subBufferSizeInFrames * music.stream.channels * music.stream.sampleSize / 8; + if (AUDIO.System.pcmCapacity < pcmSize) { + RL_FREE(AUDIO.System.pcm); + AUDIO.System.pcm = RL_CALLOC(1, pcmSize); + AUDIO.System.pcmCapacity = pcmSize; + } int frameCountToStream = 0; // Total size of data in frames to be streamed @@ -1751,8 +1753,8 @@ void UpdateMusicStream(Music music) case MUSIC_AUDIO_WAV: { // NOTE: Returns the number of samples to process (not required) - if (music.stream.sampleSize == 16) drwav_read_pcm_frames_s16((drwav *)music.ctxData, frameCountToStream, (short *)pcm); - else if (music.stream.sampleSize == 32) drwav_read_pcm_frames_f32((drwav *)music.ctxData, frameCountToStream, (float *)pcm); + if (music.stream.sampleSize == 16) drwav_read_pcm_frames_s16((drwav *)music.ctxData, frameCountToStream, (short *)AUDIO.System.pcm); + else if (music.stream.sampleSize == 32) drwav_read_pcm_frames_f32((drwav *)music.ctxData, frameCountToStream, (float *)AUDIO.System.pcm); } break; #endif @@ -1760,7 +1762,7 @@ void UpdateMusicStream(Music music) case MUSIC_AUDIO_OGG: { // NOTE: Returns the number of samples to process (be careful! we ask for number of shorts!) - stb_vorbis_get_samples_short_interleaved((stb_vorbis *)music.ctxData, music.stream.channels, (short *)pcm, frameCountToStream*music.stream.channels); + stb_vorbis_get_samples_short_interleaved((stb_vorbis *)music.ctxData, music.stream.channels, (short *)AUDIO.System.pcm, frameCountToStream*music.stream.channels); } break; #endif @@ -1768,14 +1770,14 @@ void UpdateMusicStream(Music music) case MUSIC_AUDIO_FLAC: { // NOTE: Returns the number of samples to process (not required) - drflac_read_pcm_frames_s16((drflac *)music.ctxData, frameCountToStream*music.stream.channels, (short *)pcm); + drflac_read_pcm_frames_s16((drflac *)music.ctxData, frameCountToStream*music.stream.channels, (short *)AUDIO.System.pcm); } break; #endif #if defined(SUPPORT_FILEFORMAT_MP3) case MUSIC_AUDIO_MP3: { - drmp3_read_pcm_frames_f32((drmp3 *)music.ctxData, frameCountToStream, (float *)pcm); + drmp3_read_pcm_frames_f32((drmp3 *)music.ctxData, frameCountToStream, (float *)AUDIO.System.pcm); } break; #endif @@ -1783,9 +1785,9 @@ void UpdateMusicStream(Music music) case MUSIC_MODULE_XM: { // NOTE: Internally we consider 2 channels generation, so sampleCount/2 - if (AUDIO_DEVICE_FORMAT == ma_format_f32) jar_xm_generate_samples((jar_xm_context_t *)music.ctxData, (float *)pcm, frameCountToStream); - else if (AUDIO_DEVICE_FORMAT == ma_format_s16) jar_xm_generate_samples_16bit((jar_xm_context_t *)music.ctxData, (short *)pcm, frameCountToStream); - else if (AUDIO_DEVICE_FORMAT == ma_format_u8) jar_xm_generate_samples_8bit((jar_xm_context_t *)music.ctxData, (char *)pcm, frameCountToStream); + if (AUDIO_DEVICE_FORMAT == ma_format_f32) jar_xm_generate_samples((jar_xm_context_t *)music.ctxData, (float *)AUDIO.System.pcm, frameCountToStream); + else if (AUDIO_DEVICE_FORMAT == ma_format_s16) jar_xm_generate_samples_16bit((jar_xm_context_t *)music.ctxData, (short *)AUDIO.System.pcm, frameCountToStream); + else if (AUDIO_DEVICE_FORMAT == ma_format_u8) jar_xm_generate_samples_8bit((jar_xm_context_t *)music.ctxData, (char *)AUDIO.System.pcm, frameCountToStream); } break; #endif @@ -1793,13 +1795,13 @@ void UpdateMusicStream(Music music) case MUSIC_MODULE_MOD: { // NOTE: 3rd parameter (nbsample) specify the number of stereo 16bits samples you want, so sampleCount/2 - jar_mod_fillbuffer((jar_mod_context_t *)music.ctxData, (short *)pcm, frameCountToStream, 0); + jar_mod_fillbuffer((jar_mod_context_t *)music.ctxData, (short *)AUDIO.System.pcm, frameCountToStream, 0); } break; #endif default: break; } - UpdateAudioStream(music.stream, pcm, frameCountToStream); + UpdateAudioStream(music.stream, AUDIO.System.pcm, frameCountToStream); framesLeft -= frameCountToStream; @@ -1810,9 +1812,6 @@ void UpdateMusicStream(Music music) } } - // Free allocated pcm data - RL_FREE(pcm); - // Reset audio stream for looping if (streamEnding) { @@ -2119,10 +2118,10 @@ static ma_uint32 ReadAudioBufferFramesInInternalFormat(AudioBuffer *audioBuffer, { audioBuffer->callback(framesOut, frameCount); audioBuffer->framesProcessed += frameCount; - + return frameCount; } - + ma_uint32 subBufferSizeInFrames = (audioBuffer->sizeInFrames > 1)? audioBuffer->sizeInFrames/2 : audioBuffer->sizeInFrames; ma_uint32 currentSubBufferIndex = audioBuffer->frameCursorPos/subBufferSizeInFrames; @@ -2222,7 +2221,7 @@ static ma_uint32 ReadAudioBufferFramesInMixingFormat(AudioBuffer *audioBuffer, f ma_uint64 outputFramesToProcessThisIteration = frameCount - totalOutputFramesProcessed; ma_uint64 inputFramesToProcessThisIteration = 0; - ma_result result = ma_data_converter_get_required_input_frame_count(&audioBuffer->converter, outputFramesToProcessThisIteration, &inputFramesToProcessThisIteration); + (void)ma_data_converter_get_required_input_frame_count(&audioBuffer->converter, outputFramesToProcessThisIteration, &inputFramesToProcessThisIteration); if (inputFramesToProcessThisIteration > inputBufferFrameCap) { inputFramesToProcessThisIteration = inputBufferFrameCap; diff --git a/src/raylib.h b/src/raylib.h index 9817cd885..9232e21a5 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1,6 +1,6 @@ /********************************************************************************************** * -* raylib v4.1-dev - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) +* raylib v4.2-dev - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) * * FEATURES: * - NO external dependencies, all required libraries included with raylib @@ -80,7 +80,7 @@ #include // Required for: va_list - Only used by TraceLogCallback -#define RAYLIB_VERSION "4.1-dev" +#define RAYLIB_VERSION "4.2-dev" // Function specifiers in case library is build/used as a shared library (Windows) // NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll @@ -177,10 +177,10 @@ // Structures Definition //---------------------------------------------------------------------------------- // Boolean type -#if defined(__STDC__) && __STDC_VERSION__ >= 199901L +#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) #include #elif !defined(__cplusplus) && !defined(bool) - typedef enum bool { false, true } bool; + typedef enum bool { false = 0, true = !false } bool; #define RL_BOOL_TYPE #endif @@ -322,7 +322,7 @@ typedef struct Mesh { // Vertex attributes data float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) - float *texcoords2; // Vertex second texture coordinates (useful for lightmaps) (shader-location = 5) + float *texcoords2; // Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5) float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) float *tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) @@ -482,6 +482,13 @@ typedef struct VrStereoConfig { float scaleIn[2]; // VR distortion scale in } VrStereoConfig; +// File path list +typedef struct FilePathList { + unsigned int capacity; // Filepaths max entries + unsigned int count; // Filepaths entries count + char **paths; // Filepaths entries +} FilePathList; + //---------------------------------------------------------------------------------- // Enumerators Definition //---------------------------------------------------------------------------------- @@ -501,6 +508,7 @@ typedef enum { FLAG_WINDOW_ALWAYS_RUN = 0x00000100, // Set to allow windows running while minimized FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI + FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D) } ConfigFlags; @@ -845,7 +853,7 @@ typedef enum { BLEND_MULTIPLIED, // Blend textures multiplying colors BLEND_ADD_COLORS, // Blend textures adding colors (alternative) BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative) - BLEND_ALPHA_PREMUL, // Blend premultiplied textures considering alpha + BLEND_ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha BLEND_CUSTOM // Blend textures using custom src/dst factors (use rlSetBlendMode()) } BlendMode; @@ -892,8 +900,8 @@ typedef enum { typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages typedef unsigned char *(*LoadFileDataCallback)(const char *fileName, unsigned int *bytesRead); // FileIO: Load binary data typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data -typedef char *(*LoadFileTextCallback)(const char *fileName); // FileIO: Load text data -typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileIO: Save text data +typedef char *(*LoadFileTextCallback)(const char *fileName); // FileIO: Load text data +typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileIO: Save text data //------------------------------------------------------------------------------------ // Global Variables Definition @@ -941,8 +949,8 @@ RLAPI int GetRenderHeight(void); // Get current RLAPI int GetMonitorCount(void); // Get number of connected monitors RLAPI int GetCurrentMonitor(void); // Get current connected monitor RLAPI Vector2 GetMonitorPosition(int monitor); // Get specified monitor position -RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width (max available by monitor) -RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height (max available by monitor) +RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width (current video mode used by monitor) +RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height (current video mode used by monitor) RLAPI int GetMonitorPhysicalWidth(int monitor); // Get specified monitor physical width in millimetres RLAPI int GetMonitorPhysicalHeight(int monitor); // Get specified monitor physical height in millimetres RLAPI int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate @@ -951,6 +959,9 @@ RLAPI Vector2 GetWindowScaleDPI(void); // Get window RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor RLAPI void SetClipboardText(const char *text); // Set clipboard text content RLAPI const char *GetClipboardText(void); // Get clipboard text content +RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling +RLAPI void DisableEventWaiting(void); // Disable waiting for events on EndDrawing(), automatic events polling + RLAPI void SetupViewport(int width, int height); RLAPI void SetWindowResizeDrawCallback(windowReSizeDrawCallB func); @@ -960,7 +971,7 @@ RLAPI void SetWindowResizeDrawCallback(windowReSizeDrawCallB func); // To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL RLAPI void SwapScreenBuffer(void); // Swap back buffer with front buffer (screen drawing) RLAPI void PollInputEvents(void); // Register all input events -RLAPI void WaitTime(float ms); // Wait for some milliseconds (halt program execution) +RLAPI void WaitTime(double seconds); // Wait for some time (halt program execution) // Cursor-related functions RLAPI void ShowCursor(void); // Shows cursor @@ -1010,9 +1021,9 @@ RLAPI Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Get a ray t RLAPI Matrix GetCameraMatrix(Camera camera); // Get camera transform matrix (view matrix) RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Get camera 2d transform matrix RLAPI Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Get the screen space position for a 3d world space position +RLAPI Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Get the world space position for a 2d camera screen space position RLAPI Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int height); // Get size position for a 3d world space position RLAPI Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); // Get the screen space position for a 2d camera world space position -RLAPI Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); // Get the world space position for a 2d camera screen space position // Timing-related functions RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum) @@ -1041,9 +1052,10 @@ RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver // Files management functions -RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read) +RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead); // Load file data as byte array (read) RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData() -RLAPI bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success +RLAPI bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success +RLAPI bool ExportDataAsCode(const char *data, unsigned int size, const char *fileName); // Export data to code (.h), returns true on success RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText() RLAPI bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success @@ -1058,19 +1070,21 @@ RLAPI const char *GetDirectoryPath(const char *filePath); // Get full pa RLAPI const char *GetPrevDirectoryPath(const char *dirPath); // Get previous directory path for a given path (uses static string) RLAPI const char *GetWorkingDirectory(void); // Get current working directory (uses static string) RLAPI const char *GetApplicationDirectory(void); // Get the directory if the running application (uses static string) -RLAPI char **GetDirectoryFiles(const char *dirPath, int *count); // Get filenames in a directory path (memory should be freed) -RLAPI void ClearDirectoryFiles(void); // Clear directory files paths buffers (free memory) RLAPI bool ChangeDirectory(const char *dir); // Change working directory, return true on success +RLAPI bool IsPathFile(const char *path); // Check if a given path is a file or a directory +RLAPI FilePathList LoadDirectoryFiles(const char *dirPath); // Load directory filepaths +RLAPI FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); // Load directory filepaths with extension filtering and recursive directory scan +RLAPI void UnloadDirectoryFiles(FilePathList files); // Unload filepaths RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window -RLAPI char **GetDroppedFiles(int *count); // Get dropped files names (memory should be freed) -RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer (free memory) +RLAPI FilePathList LoadDroppedFiles(void); // Load dropped filepaths +RLAPI void UnloadDroppedFiles(FilePathList files); // Unload dropped filepaths RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time) // Compression/Encoding functionality -RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); // Compress data (DEFLATE algorithm) -RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // Decompress data (DEFLATE algorithm) -RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string -RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data +RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); // Compress data (DEFLATE algorithm), memory must be MemFree() +RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // Decompress data (DEFLATE algorithm), memory must be MemFree() +RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string, memory must be MemFree() +RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data, memory must be MemFree() // Persistent storage management RLAPI bool SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position), returns true on success @@ -1115,7 +1129,8 @@ RLAPI Vector2 GetMouseDelta(void); // Get mouse delta RLAPI void SetMousePosition(int x, int y); // Set mouse position XY RLAPI void SetMouseOffset(int offsetX, int offsetY); // Set mouse offset RLAPI void SetMouseScale(float scaleX, float scaleY); // Set mouse scaling -RLAPI float GetMouseWheelMove(void); // Get mouse wheel movement Y +RLAPI float GetMouseWheelMove(void); // Get mouse wheel movement for X or Y, whichever is larger +RLAPI Vector2 GetMouseWheelMoveV(void); // Get mouse wheel movement for both X and Y RLAPI void SetMouseCursor(int cursor); // Set mouse cursor // Input-related functions: touch diff --git a/src/raymath.h b/src/raymath.h index 156e66384..503a157b2 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -77,6 +77,10 @@ #define PI 3.14159265358979323846f #endif +#ifndef EPSILON + #define EPSILON 0.000001f +#endif + #ifndef DEG2RAD #define DEG2RAD (PI/180.0f) #endif @@ -154,7 +158,7 @@ typedef struct float16 { float v[16]; } float16; -#include // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), fminf(), fmaxf(), fabs() +#include // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), floor(), fminf(), fmaxf(), fabs() //---------------------------------------------------------------------------------- // Module Functions Definition - Utils math @@ -194,6 +198,22 @@ RMAPI float Remap(float value, float inputStart, float inputEnd, float outputSta return result; } +// Wrap input value from min to max +RMAPI float Wrap(float value, float min, float max) +{ + float result = value - (max - min)*floor((value - min)/(max - min)); + + return result; +} + +// Check whether two given floats are almost equal +RMAPI int FloatEquals(float x, float y) +{ + int result = (fabsf(x - y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(x), fabsf(y)))); + + return result; +} + //---------------------------------------------------------------------------------- // Module Functions Definition - Vector2 math //---------------------------------------------------------------------------------- @@ -345,16 +365,16 @@ RMAPI Vector2 Vector2Normalize(Vector2 v) // Transforms a Vector2 by a given Matrix RMAPI Vector2 Vector2Transform(Vector2 v, Matrix mat) { - Vector2 result = { 0 }; + Vector2 result = { 0 }; - float x = v.x; - float y = v.y; - float z = 0; + float x = v.x; + float y = v.y; + float z = 0; - result.x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12; - result.y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13; + result.x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12; + result.y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13; - return result; + return result; } // Calculate linear interpolation between two vectors @@ -414,6 +434,62 @@ RMAPI Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance) return result; } +// Invert the given vector +RMAPI Vector2 Vector2Invert(Vector2 v) +{ + Vector2 result = { 1.0f/v.x, 1.0f/v.y }; + + return result; +} + +// Clamp the components of the vector between +// min and max values specified by the given vectors +RMAPI Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max) +{ + Vector2 result = { 0 }; + + result.x = fminf(max.x, fmaxf(min.x, v.x)); + result.y = fminf(max.y, fmaxf(min.y, v.y)); + + return result; +} + +// Clamp the magnitude of the vector between two min and max values +RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max) +{ + Vector2 result = { 0 }; + + float length = (v.x*v.x) + (v.y*v.y); + if (length > 0.0f) + { + length = sqrtf(length); + + if (length < min) + { + float scale = min/length; + result.x = v.x*scale; + result.y = v.y*scale; + } + else if (length > max) + { + float scale = max/length; + result.x = v.x*scale; + result.y = v.y*scale; + } + } + + return result; +} + +// Check whether two given vectors are almost equal +RMAPI int Vector2Equals(Vector2 p, Vector2 q) +{ + int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) && + ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))); + + return result; +} + //---------------------------------------------------------------------------------- // Module Functions Definition - Vector3 math //---------------------------------------------------------------------------------- @@ -851,6 +927,92 @@ RMAPI float3 Vector3ToFloatV(Vector3 v) return buffer; } +// Invert the given vector +RMAPI Vector3 Vector3Invert(Vector3 v) +{ + Vector3 result = { 1.0f/v.x, 1.0f/v.y, 1.0f/v.z }; + + return result; +} + +// Clamp the components of the vector between +// min and max values specified by the given vectors +RMAPI Vector3 Vector3Clamp(Vector3 v, Vector3 min, Vector3 max) +{ + Vector3 result = { 0 }; + + result.x = fminf(max.x, fmaxf(min.x, v.x)); + result.y = fminf(max.y, fmaxf(min.y, v.y)); + result.z = fminf(max.z, fmaxf(min.z, v.z)); + + return result; +} + +// Clamp the magnitude of the vector between two values +RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max) +{ + Vector3 result = { 0 }; + + float length = (v.x*v.x) + (v.y*v.y) + (v.z*v.z); + if (length > 0.0f) + { + length = sqrtf(length); + + if (length < min) + { + float scale = min/length; + result.x = v.x*scale; + result.y = v.y*scale; + result.z = v.z*scale; + } + else if (length > max) + { + float scale = max/length; + result.x = v.x*scale; + result.y = v.y*scale; + result.z = v.z*scale; + } + } + + return result; +} + +// Check whether two given vectors are almost equal +RMAPI int Vector3Equals(Vector3 p, Vector3 q) +{ + int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) && + ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) && + ((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))); + + return result; +} + +// Compute the direction of a refracted ray where v specifies the +// normalized direction of the incoming ray, n specifies the +// normalized normal vector of the interface of two optical media, +// and r specifies the ratio of the refractive index of the medium +// from where the ray comes to the refractive index of the medium +// on the other side of the surface +RMAPI Vector3 Vector3Refract(Vector3 v, Vector3 n, float r) +{ + Vector3 result = { 0 }; + + float dot = v.x*n.x + v.y*n.y + v.z*n.z; + float d = 1.0f - r*r*(1.0f - dot*dot); + + if (d >= 0.0f) + { + d = sqrtf(d); + v.x = r*v.x - (r*dot + d)*n.x; + v.y = r*v.y - (r*dot + d)*n.y; + v.z = r*v.z - (r*dot + d)*n.z; + + result = v; + } + + return result; +} + //---------------------------------------------------------------------------------- // Module Functions Definition - Matrix math //---------------------------------------------------------------------------------- @@ -1844,4 +2006,15 @@ RMAPI Quaternion QuaternionTransform(Quaternion q, Matrix mat) return result; } +// Check whether two given quaternions are almost equal +RMAPI int QuaternionEquals(Quaternion p, Quaternion q) +{ + int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) && + ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) && + ((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) && + ((fabsf(p.w - q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w))))); + + return result; +} + #endif // RAYMATH_H diff --git a/src/rcore.c b/src/rcore.c index 94520a60e..e317e3635 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -22,9 +22,11 @@ * Windowing and input system configured for Android device, app activity managed internally in this module. * NOTE: OpenGL ES 2.0 is required and graphic device is managed by EGL * -* #define PLATFORM_RPI +* #define PLATFORM_RPI (deprecated - RPI OS Buster only) * Windowing and input system configured for Raspberry Pi in native mode (no XWindow required), * graphic device is managed by EGL and inputs are processed is raw mode, reading from /dev/input/ +* WARNING: This platform is deprecated, since RPI OS Bullseye, the old Dispmanx libraries are not +* supported and you must be using PLATFORM_DRM * * #define PLATFORM_DRM * Windowing and input system configured for DRM native mode (RPI4 and other devices) @@ -179,19 +181,24 @@ #include // Required for: srand(), rand(), atexit() #include // Required for: sprintf() [Used in OpenURL()] -#include // Required for: strrchr(), strcmp(), strlen() +#include // Required for: strrchr(), strcmp(), strlen(), memset() #include // Required for: time() [Used in InitTimer()] #include // Required for: tan() [Used in BeginMode3D()], atan2f() [Used in LoadVrStereoConfig()] -#include // Required for: stat() [Used in GetFileModTime()] +#define _CRT_INTERNAL_NONSTDC_NAMES 1 +#include // Required for: stat(), S_ISREG [Used in GetFileModTime(), IsFilePath()] + +#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG) + #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif #if defined(PLATFORM_DESKTOP) && defined(_WIN32) && (defined(_MSC_VER) || defined(__TINYC__)) #define DIRENT_MALLOC RL_MALLOC #define DIRENT_FREE RL_FREE - #include "external/dirent.h" // Required for: DIR, opendir(), closedir() [Used in GetDirectoryFiles()] + #include "external/dirent.h" // Required for: DIR, opendir(), closedir() [Used in LoadDirectoryFiles()] #else - #include // Required for: DIR, opendir(), closedir() [Used in GetDirectoryFiles()] + #include // Required for: DIR, opendir(), closedir() [Used in LoadDirectoryFiles()] #endif #if defined(_WIN32) @@ -222,7 +229,7 @@ unsigned int __stdcall timeEndPeriod(unsigned int uPeriod); #endif #endif - #if defined(__linux__) || defined(__FreeBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) #include // Required for: timespec, nanosleep(), select() - POSIX //#define GLFW_EXPOSE_NATIVE_X11 // WARNING: Exposing Xlib.h > X.h results in dup symbols for Font type @@ -293,12 +300,11 @@ #define DEFAULT_EVDEV_PATH "/dev/input/" // Path to the linux input events #endif +#ifndef MAX_FILEPATH_CAPACITY + #define MAX_FILEPATH_CAPACITY 8192 // Maximum capacity for filepath +#endif #ifndef MAX_FILEPATH_LENGTH - #if defined(__linux__) - #define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value) - #else - #define MAX_FILEPATH_LENGTH 512 // Maximum length supported for filepaths - #endif + #define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value) #endif #ifndef MAX_KEYBOARD_KEYS @@ -394,6 +400,7 @@ typedef struct CoreData { bool fullscreen; // Check if fullscreen mode is enabled bool shouldClose; // Check if window set for closing bool resizedLastFrame; // Check if window has been resized last frame + bool eventWaiting; // Wait for events before ending frame Point position; // Window position on screen (required on fullscreen toggle) Size display; // Display width and height (monitor, device-screen, LCD, ...) @@ -403,8 +410,8 @@ typedef struct CoreData { Point renderOffset; // Offset from render area (must be divided by 2) Matrix screenScale; // Matrix to scale screen (framebuffer rendering) - char **dropFilesPath; // Store dropped files paths as strings - int dropFileCount; // Count dropped files strings + char **dropFilepaths; // Store dropped files paths pointers (provided by GLFW) + unsigned int dropFileCount; // Count dropped files strings windowReSizeDrawCallB resizeDrawCallB; } Window; @@ -456,8 +463,8 @@ typedef struct CoreData { char currentButtonState[MAX_MOUSE_BUTTONS]; // Registers current mouse button state char previousButtonState[MAX_MOUSE_BUTTONS]; // Registers previous mouse button state - float currentWheelMove; // Registers current mouse wheel variation - float previousWheelMove; // Registers previous mouse wheel variation + Vector2 currentWheelMove; // Registers current mouse wheel variation + Vector2 previousWheelMove; // Registers previous mouse wheel variation #if defined(PLATFORM_RPI) || defined(PLATFORM_DRM) // NOTE: currentButtonState[] can't be written directly due to multithreading, app could miss the update char currentButtonStateEvdev[MAX_MOUSE_BUTTONS]; // Holds the new mouse state for the next polling event to grab @@ -501,13 +508,10 @@ typedef struct CoreData { //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- -static CoreData CORE = { 0 }; // Global CORE state context - -static char **dirFilesPath = NULL; // Store directory files paths as strings -static int dirFileCount = 0; // Count directory files strings - const char *raylibVersion = RAYLIB_VERSION; // raylib version symbol, it could be required for some bindings +static CoreData CORE = { 0 }; // Global CORE state context + #if defined(SUPPORT_SCREEN_CAPTURE) static int screenshotCounter = 0; // Screenshots counter #endif @@ -531,7 +535,7 @@ typedef enum AutomationEventType { INPUT_MOUSE_BUTTON_UP, // param[0]: button INPUT_MOUSE_BUTTON_DOWN, // param[0]: button INPUT_MOUSE_POSITION, // param[0]: x, param[1]: y - INPUT_MOUSE_WHEEL_MOTION, // param[0]: delta + INPUT_MOUSE_WHEEL_MOTION, // param[0]: x delta, param[1]: y delta INPUT_GAMEPAD_CONNECT, // param[0]: gamepad INPUT_GAMEPAD_DISCONNECT, // param[0]: gamepad INPUT_GAMEPAD_BUTTON_UP, // param[0]: button @@ -622,6 +626,9 @@ static bool InitGraphicsDevice(int width, int height); // Initialize graphics d static void SetupFramebuffer(int width, int height); // Setup main framebuffer void SetupViewport(int width, int height); // Set viewport for a provided width and height +static void ScanDirectoryFiles(const char *basePath, FilePathList *list, const char *filter); // Scan all files and directories in a base path +static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *list, const char *filter); // Scan all files and directories recursively from a base path + #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error // Window callbacks events @@ -756,11 +763,15 @@ void InitWindow(int width, int height, const char *title) if ((title != NULL) && (title[0] != 0)) CORE.Window.title = title; - // Initialize required global values different than 0 + // Initialize global input state + memset(&CORE.Input, 0, sizeof(CORE.Input)); CORE.Input.Keyboard.exitKey = KEY_ESCAPE; CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f }; CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW; CORE.Input.Gamepad.lastButtonPressed = -1; +#if defined(SUPPORT_EVENTS_WAITING) + CORE.Window.eventWaiting = true; +#endif CORE.Window.resizeDrawCallB = NULL; @@ -1178,39 +1189,38 @@ bool IsWindowState(unsigned int flag) void ToggleFullscreen(void) { #if defined(PLATFORM_DESKTOP) - // NOTE: glfwSetWindowMonitor() doesn't work properly (bugs) if (!CORE.Window.fullscreen) { // Store previous window position (in case we exit fullscreen) glfwGetWindowPos(CORE.Window.handle, &CORE.Window.position.x, &CORE.Window.position.y); int monitorCount = 0; - GLFWmonitor** monitors = glfwGetMonitors(&monitorCount); - int monitorIndex = GetCurrentMonitor(); + GLFWmonitor **monitors = glfwGetMonitors(&monitorCount); // Use current monitor, so we correctly get the display the window is on - GLFWmonitor* monitor = monitorIndex < monitorCount ? monitors[monitorIndex] : NULL; + GLFWmonitor *monitor = (monitorIndex < monitorCount)? monitors[monitorIndex] : NULL; - if (!monitor) + if (monitor == NULL) { TRACELOG(LOG_WARNING, "GLFW: Failed to get monitor"); - CORE.Window.fullscreen = false; // Toggle fullscreen flag + CORE.Window.fullscreen = false; CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE; glfwSetWindowMonitor(CORE.Window.handle, NULL, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); - return; } + else + { + CORE.Window.fullscreen = true; + CORE.Window.flags |= FLAG_FULLSCREEN_MODE; - CORE.Window.fullscreen = true; // Toggle fullscreen flag - CORE.Window.flags |= FLAG_FULLSCREEN_MODE; - - glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); + glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); + } } else { - CORE.Window.fullscreen = false; // Toggle fullscreen flag + CORE.Window.fullscreen = false; CORE.Window.flags &= ~FLAG_FULLSCREEN_MODE; glfwSetWindowMonitor(CORE.Window.handle, NULL, CORE.Window.position.x, CORE.Window.position.y, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); @@ -1416,6 +1426,13 @@ void SetWindowState(unsigned int flags) { TRACELOG(LOG_WARNING, "WINDOW: High DPI can only by configured before window initialization"); } + + // State change: FLAG_WINDOW_MOUSE_PASSTHROUGH + if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) != (flags & FLAG_WINDOW_MOUSE_PASSTHROUGH)) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0)) + { + glfwSetWindowAttrib(CORE.Window.handle, GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE); + CORE.Window.flags |= FLAG_WINDOW_MOUSE_PASSTHROUGH; + } // State change: FLAG_MSAA_4X_HINT if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) != (flags & FLAG_MSAA_4X_HINT)) && ((flags & FLAG_MSAA_4X_HINT) > 0)) @@ -1517,6 +1534,13 @@ void ClearWindowState(unsigned int flags) { TRACELOG(LOG_WARNING, "WINDOW: High DPI can only by configured before window initialization"); } + + // State change: FLAG_WINDOW_MOUSE_PASSTHROUGH + if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0)) + { + glfwSetWindowAttrib(CORE.Window.handle, GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE); + CORE.Window.flags &= ~FLAG_WINDOW_MOUSE_PASSTHROUGH; + } // State change: FLAG_MSAA_4X_HINT if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) > 0) && ((flags & FLAG_MSAA_4X_HINT) > 0)) @@ -1721,7 +1745,7 @@ int GetCurrentMonitor(void) #endif } -// Get selected monitor width +// Get selected monitor position Vector2 GetMonitorPosition(int monitor) { #if defined(PLATFORM_DESKTOP) @@ -1740,7 +1764,7 @@ Vector2 GetMonitorPosition(int monitor) return (Vector2){ 0, 0 }; } -// Get selected monitor width (max available by monitor) +// Get selected monitor width (currently used by monitor) int GetMonitorWidth(int monitor) { #if defined(PLATFORM_DESKTOP) @@ -1749,11 +1773,9 @@ int GetMonitorWidth(int monitor) if ((monitor >= 0) && (monitor < monitorCount)) { - int count = 0; - const GLFWvidmode *modes = glfwGetVideoModes(monitors[monitor], &count); - - // We return the maximum resolution available, the last one in the modes array - if (count > 0) return modes[count - 1].width; + const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]); + + if (mode) return mode->width; else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor"); } else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor"); @@ -1761,7 +1783,7 @@ int GetMonitorWidth(int monitor) return 0; } -// Get selected monitor width (max available by monitor) +// Get selected monitor height (currently used by monitor) int GetMonitorHeight(int monitor) { #if defined(PLATFORM_DESKTOP) @@ -1770,11 +1792,9 @@ int GetMonitorHeight(int monitor) if ((monitor >= 0) && (monitor < monitorCount)) { - int count = 0; - const GLFWvidmode *modes = glfwGetVideoModes(monitors[monitor], &count); - - // We return the maximum resolution available, the last one in the modes array - if (count > 0) return modes[count - 1].height; + const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]); + + if (mode) return mode->height; else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor"); } else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor"); @@ -1901,6 +1921,29 @@ const char *GetMonitorName(int monitor) return ""; } +// Set clipboard text content +void SetClipboardText(const char *text) +{ +#if defined(PLATFORM_DESKTOP) + glfwSetClipboardString(CORE.Window.handle, text); +#endif +#if defined(PLATFORM_WEB) + emscripten_run_script(TextFormat("navigator.clipboard.writeText('%s')", text)); +#endif +} + +// Enable waiting for events on EndDrawing(), no automatic event polling +void EnableEventWaiting(void) +{ + CORE.Window.eventWaiting = true; +} + +// Disable waiting for events on EndDrawing(), automatic events polling +RLAPI void DisableEventWaiting(void) +{ + CORE.Window.eventWaiting = false; +} + // Get clipboard text content // NOTE: returned string is allocated and freed by GLFW const char *GetClipboardText(void) @@ -1914,16 +1957,7 @@ const char *GetClipboardText(void) return NULL; } -// Set clipboard text content -void SetClipboardText(const char *text) -{ -#if defined(PLATFORM_DESKTOP) - glfwSetClipboardString(CORE.Window.handle, text); -#endif -#if defined(PLATFORM_WEB) - emscripten_run_script(TextFormat("navigator.clipboard.writeText('%s')", text)); -#endif -} + // Show mouse cursor void ShowCursor(void) @@ -2033,8 +2067,9 @@ void EndDrawing(void) { // Get image data for the current frame (from backbuffer) // NOTE: This process is quite slow... :( - unsigned char *screenData = rlReadScreenPixels(CORE.Window.screen.width, CORE.Window.screen.height); - msf_gif_frame(&gifState, screenData, 10, 16, CORE.Window.screen.width*4); + Vector2 scale = GetWindowScaleDPI(); + unsigned char *screenData = rlReadScreenPixels((int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y)); + msf_gif_frame(&gifState, screenData, 10, 16, (int)((float)CORE.Window.render.width*scale.x)*4); RL_FREE(screenData); // Free image data } @@ -2092,7 +2127,7 @@ void EndDrawing(void) // Wait for some milliseconds... if (CORE.Time.frame < CORE.Time.target) { - WaitTime((float)(CORE.Time.target - CORE.Time.frame)*1000.0f); + WaitTime(CORE.Time.target - CORE.Time.frame); CORE.Time.current = GetTime(); double waitTime = CORE.Time.current - CORE.Time.previous; @@ -2203,8 +2238,10 @@ void BeginTextureMode(RenderTexture2D target) rlEnableFramebuffer(target.id); // Enable render target - // Set viewport to framebuffer size + // Set viewport and RLGL internal framebuffer size rlViewport(0, 0, target.texture.width, target.texture.height); + rlSetFramebufferWidth(target.texture.width); + rlSetFramebufferHeight(target.texture.height); rlMatrixMode(RL_PROJECTION); // Switch to projection matrix rlLoadIdentity(); // Reset current matrix (projection) @@ -2350,8 +2387,8 @@ VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device) // Fovy is normally computed with: 2*atan2f(device.vScreenSize, 2*device.eyeToScreenDistance) // ...but with lens distortion it is increased (see Oculus SDK Documentation) - //float fovy = 2.0f*atan2f(device.vScreenSize*0.5f*distortionScale, device.eyeToScreenDistance); // Really need distortionScale? - float fovy = 2.0f*(float)atan2f(device.vScreenSize*0.5f, device.eyeToScreenDistance); + float fovy = 2.0f*atan2f(device.vScreenSize*0.5f*distortionScale, device.eyeToScreenDistance); // Really need distortionScale? + // float fovy = 2.0f*(float)atan2f(device.vScreenSize*0.5f, device.eyeToScreenDistance); // Compute camera projection matrices float projOffset = 4.0f*lensShift; // Scaled to projection space coordinates [-1..1] @@ -2754,8 +2791,9 @@ void SetConfigFlags(unsigned int flags) void TakeScreenshot(const char *fileName) { #if defined(SUPPORT_MODULE_RTEXTURES) - unsigned char *imgData = rlReadScreenPixels(CORE.Window.render.width, CORE.Window.render.height); - Image image = { imgData, CORE.Window.render.width, CORE.Window.render.height, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; + Vector2 scale = GetWindowScaleDPI(); + unsigned char *imgData = rlReadScreenPixels((int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y)); + Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; char path[2048] = { 0 }; strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, fileName)); @@ -2817,6 +2855,8 @@ bool FileExists(const char *fileName) // NOTE: Extensions checking is not case-sensitive bool IsFileExtension(const char *fileName, const char *ext) { + #define MAX_FILE_EXTENSION_SIZE 16 + bool result = false; const char *fileExt = GetFileExtension(fileName); @@ -2824,10 +2864,10 @@ bool IsFileExtension(const char *fileName, const char *ext) { #if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_TEXT_MANIPULATION) int extCount = 0; - const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext + const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext - char fileExtLower[16] = { 0 }; - strcpy(fileExtLower, TextToLower(fileExt)); // WARNING: Module required: rtext + char fileExtLower[MAX_FILE_EXTENSION_SIZE] = { 0 }; + strncpy(fileExtLower, TextToLower(fileExt),MAX_FILE_EXTENSION_SIZE); // WARNING: Module required: rtext for (int i = 0; i < extCount; i++) { @@ -2910,7 +2950,7 @@ const char *GetFileName(const char *filePath) // Get filename string without extension (uses static string) const char *GetFileNameWithoutExt(const char *filePath) { - #define MAX_FILENAMEWITHOUTEXT_LENGTH 128 + #define MAX_FILENAMEWITHOUTEXT_LENGTH 256 static char fileName[MAX_FILENAMEWITHOUTEXT_LENGTH] = { 0 }; memset(fileName, 0, MAX_FILENAMEWITHOUTEXT_LENGTH); @@ -3089,52 +3129,72 @@ const char *GetApplicationDirectory(void) return appDir; } -// Get filenames in a directory path -// NOTE: Files count is returned by parameters pointer -char **GetDirectoryFiles(const char *dirPath, int *fileCount) +// Load directory filepaths +// NOTE: Base path is prepended to the scanned filepaths +// WARNING: Directory is scanned twice, first time to get files count +// No recursive scanning is done! +FilePathList LoadDirectoryFiles(const char *dirPath) { - ClearDirectoryFiles(); - - int counter = 0; + FilePathList files = { 0 }; + unsigned int fileCounter = 0; + struct dirent *entity; DIR *dir = opendir(dirPath); if (dir != NULL) // It's a directory { - // Count files - while ((entity = readdir(dir)) != NULL) counter++; - - dirFileCount = counter; - *fileCount = dirFileCount; + // SCAN 1: Count files + while ((entity = readdir(dir)) != NULL) + { + // NOTE: We skip '.' (current dir) and '..' (parent dir) filepaths + if ((strcmp(entity->d_name, ".") != 0) && (strcmp(entity->d_name, "..") != 0)) fileCounter++; + } // Memory allocation for dirFileCount - dirFilesPath = (char **)RL_MALLOC(dirFileCount*sizeof(char *)); - for (int i = 0; i < dirFileCount; i++) dirFilesPath[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char)); - - // Reset our position in the directory to the beginning - rewinddir(dir); - - // Read file names - for (int i = 0; (entity = readdir(dir)) != NULL; i++) strcpy(dirFilesPath[i], entity->d_name); + files.capacity = fileCounter; + files.paths = (char **)RL_MALLOC(files.capacity*sizeof(char *)); + for (int i = 0; i < files.capacity; i++) files.paths[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char)); closedir(dir); + + // SCAN 2: Read filepaths + // NOTE: Directory paths are also registered + ScanDirectoryFiles(dirPath, &files, NULL); + + // Security check: read files.count should match fileCounter + if (files.count != files.capacity) TRACELOG(LOG_WARNING, "FILEIO: Read files count do not match capacity allocated"); } else TRACELOG(LOG_WARNING, "FILEIO: Failed to open requested directory"); // Maybe it's a file... - - return dirFilesPath; + + return files; } -// Clear directory files paths buffers -void ClearDirectoryFiles(void) +// Load directory filepaths with extension filtering and recursive directory scan +// NOTE: On recursive loading we do not pre-scan for file count, we use MAX_FILEPATH_CAPACITY +FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs) { - if (dirFileCount > 0) + FilePathList files = { 0 }; + + files.capacity = MAX_FILEPATH_CAPACITY; + files.paths = (char **)RL_CALLOC(files.capacity, sizeof(char *)); + for (int i = 0; i < files.capacity; i++) files.paths[i] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char)); + + // WARNING: basePath is always prepended to scanned paths + if (scanSubdirs) ScanDirectoryFilesRecursively(basePath, &files, filter); + else ScanDirectoryFiles(basePath, &files, filter); + + return files; +} + +// Unload directory filepaths +void UnloadDirectoryFiles(FilePathList files) +{ + if (files.capacity > 0) { - for (int i = 0; i < dirFileCount; i++) RL_FREE(dirFilesPath[i]); + for (int i = 0; i < files.capacity; i++) RL_FREE(files.paths[i]); - RL_FREE(dirFilesPath); + RL_FREE(files.paths); } - - dirFileCount = 0; } // Change working directory, returns true on success @@ -3147,6 +3207,15 @@ bool ChangeDirectory(const char *dir) return (result == 0); } +// Check if a given path point to a file +bool IsPathFile(const char *path) +{ + struct stat pathStat = { 0 }; + stat(path, &pathStat); + + return S_ISREG(pathStat.st_mode); +} + // Check if a file has been dropped into window bool IsFileDropped(void) { @@ -3154,23 +3223,30 @@ bool IsFileDropped(void) else return false; } -// Get dropped files names -char **GetDroppedFiles(int *count) +// Load dropped filepaths +FilePathList LoadDroppedFiles(void) { - *count = CORE.Window.dropFileCount; - return CORE.Window.dropFilesPath; + FilePathList files = { 0 }; + + files.count = CORE.Window.dropFileCount; + files.paths = CORE.Window.dropFilepaths; + + return files; } -// Clear dropped files paths buffer -void ClearDroppedFiles(void) +// Unload dropped filepaths +void UnloadDroppedFiles(FilePathList files) { - if (CORE.Window.dropFileCount > 0) + // WARNING: files pointers are the same as internal ones + + if (files.count > 0) { - for (int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilesPath[i]); - - RL_FREE(CORE.Window.dropFilesPath); + for (int i = 0; i < files.count; i++) RL_FREE(files.paths[i]); + RL_FREE(files.paths); + CORE.Window.dropFileCount = 0; + CORE.Window.dropFilepaths = NULL; } } @@ -3189,7 +3265,7 @@ long GetFileModTime(const char *fileName) return 0; } -// Compress data (DEFLATE algorythm) +// Compress data (DEFLATE algorithm) unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize) { #define COMPRESSION_QUALITY_DEFLATE 8 @@ -3209,7 +3285,7 @@ unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDa return compData; } -// Decompress data (DEFLATE algorythm) +// Decompress data (DEFLATE algorithm) unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize) { unsigned char *data = NULL; @@ -3217,7 +3293,7 @@ unsigned char *DecompressData(const unsigned char *compData, int compDataSize, i #if defined(SUPPORT_COMPRESSION_API) // Decompress data from a valid DEFLATE stream data = RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1); - int length = sinflate(data, MAX_DECOMPRESSION_SIZE, compData, compDataSize); + int length = sinflate(data, MAX_DECOMPRESSION_SIZE*1024*1024, compData, compDataSize); unsigned char *temp = RL_REALLOC(data, length); if (temp != NULL) data = temp; @@ -3449,7 +3525,7 @@ void OpenURL(const char *url) #if defined(_WIN32) sprintf(cmd, "explorer \"%s\"", url); #endif - #if defined(__linux__) || defined(__FreeBSD__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser #endif #if defined(__APPLE__) @@ -3809,12 +3885,31 @@ void SetMouseScale(float scaleX, float scaleY) // Get mouse wheel movement Y float GetMouseWheelMove(void) +{ + float result = 0.0f; + +#if !defined(PLATFORM_ANDROID) + if (fabsf(CORE.Input.Mouse.currentWheelMove.x) > fabsf(CORE.Input.Mouse.currentWheelMove.y)) result = (float)CORE.Input.Mouse.currentWheelMove.x; + else result = (float)CORE.Input.Mouse.currentWheelMove.y; +#endif + +#if defined(PLATFORM_WEB) + result /= 100.0f; +#endif + + return result; +} + +// Get mouse wheel movement X/Y as a vector +Vector2 GetMouseWheelMoveV(void) { #if defined(PLATFORM_ANDROID) - return 0.0f; + return (Vector2){ 0.0f, 0.0f }; #endif #if defined(PLATFORM_WEB) - return CORE.Input.Mouse.currentWheelMove/100.0f; + Vector2 result = CORE.Input.Mouse.currentWheelMove; + result.x /= 100.0f; + result.y /= 100.0f; #endif return CORE.Input.Mouse.currentWheelMove; @@ -4020,6 +4115,10 @@ static bool InitGraphicsDevice(int width, int height) #endif } else glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE); + + // Mouse passthrough + if ((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE); + else glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE); #endif if (CORE.Window.flags & FLAG_MSAA_4X_HINT) @@ -4799,49 +4898,46 @@ static void InitTimer(void) CORE.Time.previous = GetTime(); // Get time as double } -// Wait for some milliseconds (stop program execution) +// Wait for some time (stop program execution) // NOTE: Sleep() granularity could be around 10 ms, it means, Sleep() could // take longer than expected... for that reason we use the busy wait loop // Ref: http://stackoverflow.com/questions/43057578/c-programming-win32-games-sleep-taking-longer-than-expected // Ref: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timming on Win32! -void WaitTime(float ms) +void WaitTime(double seconds) { -#if defined(SUPPORT_BUSY_WAIT_LOOP) - double previousTime = GetTime(); - double currentTime = 0.0; +#if defined(SUPPORT_BUSY_WAIT_LOOP) || defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) + double destinationTime = GetTime() + seconds; +#endif - // Busy wait loop - while ((currentTime - previousTime) < ms/1000.0f) currentTime = GetTime(); +#if defined(SUPPORT_BUSY_WAIT_LOOP) + while (GetTime() < destinationTime) { } #else #if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) - double busyWait = ms*0.05; // NOTE: We are using a busy wait of 5% of the time - ms -= (float)busyWait; + double sleepSeconds = seconds - seconds*0.05; // NOTE: We reserve a percentage of the time for busy waiting + #else + double sleepSeconds = seconds; #endif // System halt functions #if defined(_WIN32) - Sleep((unsigned int)ms); + Sleep((unsigned long)(sleepSeconds*1000.0)); #endif - #if defined(__linux__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__) struct timespec req = { 0 }; - time_t sec = (int)(ms/1000.0f); - ms -= (sec*1000); + time_t sec = sleepSeconds; + long nsec = (sleepSeconds - sec)*1000000000L; req.tv_sec = sec; - req.tv_nsec = ms*1000000L; + req.tv_nsec = nsec; // NOTE: Use nanosleep() on Unix platforms... usleep() it's deprecated. while (nanosleep(&req, &req) == -1) continue; #endif #if defined(__APPLE__) - usleep(ms*1000.0f); + usleep(sleepSeconds*1000000.0); #endif #if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) - double previousTime = GetTime(); - double currentTime = 0.0; - - // Partial busy wait loop (only a fraction of the total wait time) - while ((currentTime - previousTime) < busyWait/1000.0f) currentTime = GetTime(); + while (GetTime() < destinationTime) { } #endif #endif } @@ -4857,53 +4953,31 @@ void SwapScreenBuffer(void) eglSwapBuffers(CORE.Window.device, CORE.Window.surface); #if defined(PLATFORM_DRM) - if (!CORE.Window.gbmSurface || (-1 == CORE.Window.fd) || !CORE.Window.connector || !CORE.Window.crtc) - { - TRACELOG(LOG_ERROR, "DISPLAY: DRM initialization failed to swap"); - abort(); - } + + if (!CORE.Window.gbmSurface || (-1 == CORE.Window.fd) || !CORE.Window.connector || !CORE.Window.crtc) TRACELOG(LOG_ERROR, "DISPLAY: DRM initialization failed to swap"); struct gbm_bo *bo = gbm_surface_lock_front_buffer(CORE.Window.gbmSurface); - if (!bo) - { - TRACELOG(LOG_ERROR, "DISPLAY: Failed GBM to lock front buffer"); - abort(); - } + if (!bo) TRACELOG(LOG_ERROR, "DISPLAY: Failed GBM to lock front buffer"); uint32_t fb = 0; - int result = drmModeAddFB(CORE.Window.fd, CORE.Window.connector->modes[CORE.Window.modeIndex].hdisplay, - CORE.Window.connector->modes[CORE.Window.modeIndex].vdisplay, 24, 32, gbm_bo_get_stride(bo), gbm_bo_get_handle(bo).u32, &fb); - if (0 != result) - { - TRACELOG(LOG_ERROR, "DISPLAY: drmModeAddFB() failed with result: %d", result); - abort(); - } + int result = drmModeAddFB(CORE.Window.fd, CORE.Window.connector->modes[CORE.Window.modeIndex].hdisplay, CORE.Window.connector->modes[CORE.Window.modeIndex].vdisplay, 24, 32, gbm_bo_get_stride(bo), gbm_bo_get_handle(bo).u32, &fb); + if (result != 0) TRACELOG(LOG_ERROR, "DISPLAY: drmModeAddFB() failed with result: %d", result); - result = drmModeSetCrtc(CORE.Window.fd, CORE.Window.crtc->crtc_id, fb, 0, 0, - &CORE.Window.connector->connector_id, 1, &CORE.Window.connector->modes[CORE.Window.modeIndex]); - if (0 != result) - { - TRACELOG(LOG_ERROR, "DISPLAY: drmModeSetCrtc() failed with result: %d", result); - abort(); - } + result = drmModeSetCrtc(CORE.Window.fd, CORE.Window.crtc->crtc_id, fb, 0, 0, &CORE.Window.connector->connector_id, 1, &CORE.Window.connector->modes[CORE.Window.modeIndex]); + if (result != 0) TRACELOG(LOG_ERROR, "DISPLAY: drmModeSetCrtc() failed with result: %d", result); if (CORE.Window.prevFB) { result = drmModeRmFB(CORE.Window.fd, CORE.Window.prevFB); - if (0 != result) - { - TRACELOG(LOG_ERROR, "DISPLAY: drmModeRmFB() failed with result: %d", result); - abort(); - } + if (result != 0) TRACELOG(LOG_ERROR, "DISPLAY: drmModeRmFB() failed with result: %d", result); } + CORE.Window.prevFB = fb; - if (CORE.Window.prevBO) - { - gbm_surface_release_buffer(CORE.Window.gbmSurface, CORE.Window.prevBO); - } + if (CORE.Window.prevBO) gbm_surface_release_buffer(CORE.Window.gbmSurface, CORE.Window.prevBO); CORE.Window.prevBO = bo; + #endif // PLATFORM_DRM #endif // PLATFORM_ANDROID || PLATFORM_RPI || PLATFORM_DRM } @@ -4935,7 +5009,7 @@ void PollInputEvents(void) // Register previous mouse states CORE.Input.Mouse.previousWheelMove = CORE.Input.Mouse.currentWheelMove; - CORE.Input.Mouse.currentWheelMove = 0.0f; + CORE.Input.Mouse.currentWheelMove = (Vector2){ 0.0f, 0.0f }; for (int i = 0; i < MAX_MOUSE_BUTTONS; i++) { CORE.Input.Mouse.previousButtonState[i] = CORE.Input.Mouse.currentButtonState[i]; @@ -4964,7 +5038,7 @@ void PollInputEvents(void) // Register previous mouse wheel state CORE.Input.Mouse.previousWheelMove = CORE.Input.Mouse.currentWheelMove; - CORE.Input.Mouse.currentWheelMove = 0.0f; + CORE.Input.Mouse.currentWheelMove = (Vector2){ 0.0f, 0.0f }; // Register previous mouse position CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; @@ -5060,11 +5134,8 @@ void PollInputEvents(void) CORE.Window.resizedLastFrame = false; -#if defined(SUPPORT_EVENTS_WAITING) - glfwWaitEvents(); -#else - glfwPollEvents(); // Register keyboard/mouse events (callbacks)... and window events! -#endif + if (CORE.Window.eventWaiting) glfwWaitEvents(); // Wait for in input events before continue (drawing is paused) + else glfwPollEvents(); // Poll input events: keyboard/mouse/window events (callbacks) #endif // PLATFORM_DESKTOP #if defined(PLATFORM_WEB) @@ -5176,6 +5247,96 @@ void PollInputEvents(void) #endif } +// Scan all files and directories in a base path +// WARNING: files.paths[] must be previously allocated and +// contain enough space to store all required paths +static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const char *filter) +{ + static char path[MAX_FILEPATH_LENGTH] = { 0 }; + memset(path, 0, MAX_FILEPATH_LENGTH); + + struct dirent *dp = NULL; + DIR *dir = opendir(basePath); + + if (dir != NULL) + { + while ((dp = readdir(dir)) != NULL) + { + if ((strcmp(dp->d_name, ".") != 0) && + (strcmp(dp->d_name, "..") != 0)) + { + sprintf(path, "%s/%s", basePath, dp->d_name); + + if (filter != NULL) + { + if (IsFileExtension(path, filter)) + { + strcpy(files->paths[files->count], path); + files->count++; + } + } + else + { + strcpy(files->paths[files->count], path); + files->count++; + } + } + } + + closedir(dir); + } + else TRACELOG(LOG_WARNING, "FILEIO: Directory cannot be opened (%s)", basePath); +} + +// Scan all files and directories recursively from a base path +static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *files, const char *filter) +{ + static char path[MAX_FILEPATH_LENGTH] = { 0 }; + memset(path, 0, MAX_FILEPATH_LENGTH); + + struct dirent *dp = NULL; + DIR *dir = opendir(basePath); + + if (dir != NULL) + { + while (((dp = readdir(dir)) != NULL) && (files->count < files->capacity)) + { + if ((strcmp(dp->d_name, ".") != 0) && (strcmp(dp->d_name, "..") != 0)) + { + // Construct new path from our base path + sprintf(path, "%s/%s", basePath, dp->d_name); + + if (IsPathFile(path)) + { + if (filter != NULL) + { + if (IsFileExtension(path, filter)) + { + strcpy(files->paths[files->count], path); + files->count++; + } + } + else + { + strcpy(files->paths[files->count], path); + files->count++; + } + + if (files->count >= files->capacity) + { + TRACELOG(LOG_WARNING, "FILEIO: Maximum filepath scan capacity reached (%i files)", files->capacity); + break; + } + } + else ScanDirectoryFilesRecursively(path, files, filter); + } + } + + closedir(dir); + } + else TRACELOG(LOG_WARNING, "FILEIO: Directory cannot be opened (%s)", basePath); +} + #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) // GLFW3 Error Callback, runs on GLFW3 error static void ErrorCallback(int error, const char *description) @@ -5297,7 +5458,8 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i gifRecording = true; gifFrameCounter = 0; - msf_gif_begin(&gifState, CORE.Window.screen.width, CORE.Window.screen.height); + Vector2 scale = GetWindowScaleDPI(); + msf_gif_begin(&gifState, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y)); screenshotCounter++; TRACELOG(LOG_INFO, "SYSTEM: Start animated GIF recording: %s", TextFormat("screenrec%03i.gif", screenshotCounter)); @@ -5415,11 +5577,10 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y) #endif } -// GLFW3 Srolling Callback, runs on mouse wheel +// GLFW3 Scrolling Callback, runs on mouse wheel static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffset) { - if (xoffset != 0.0) CORE.Input.Mouse.currentWheelMove = (float)xoffset; - else CORE.Input.Mouse.currentWheelMove = (float)yoffset; + CORE.Input.Mouse.currentWheelMove = (Vector2){ (float)xoffset, (float)yoffset }; } // GLFW3 CursorEnter Callback, when cursor enters the window @@ -5430,21 +5591,28 @@ static void CursorEnterCallback(GLFWwindow *window, int enter) } // GLFW3 Window Drop Callback, runs when drop files into window -// NOTE: Paths are stored in dynamic memory for further retrieval -// Everytime new files are dropped, old ones are discarded static void WindowDropCallback(GLFWwindow *window, int count, const char **paths) { - ClearDroppedFiles(); - - CORE.Window.dropFilesPath = (char **)RL_MALLOC(count*sizeof(char *)); - - for (int i = 0; i < count; i++) + // In case previous dropped filepaths have not been freed, we free them + if (CORE.Window.dropFileCount > 0) { - CORE.Window.dropFilesPath[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char)); - strcpy(CORE.Window.dropFilesPath[i], paths[i]); - } + for (int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilepaths[i]); + RL_FREE(CORE.Window.dropFilepaths); + + CORE.Window.dropFileCount = 0; + CORE.Window.dropFilepaths = NULL; + } + + // WARNING: Paths are freed by GLFW when the callback returns, we must keep an internal copy CORE.Window.dropFileCount = count; + CORE.Window.dropFilepaths = (char **)RL_CALLOC(CORE.Window.dropFileCount, sizeof(char *)); + + for (int i = 0; i < CORE.Window.dropFileCount; i++) + { + CORE.Window.dropFilepaths[i] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char)); + strcpy(CORE.Window.dropFilepaths[i], paths[i]); + } } #endif @@ -5684,7 +5852,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) // Register fullscreen change events static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const EmscriptenFullscreenChangeEvent *event, void *userData) { - // TODO. + // TODO: Implement EmscriptenFullscreenChangeCallback()? return 1; // The event was consumed by the callback handler } @@ -5692,7 +5860,7 @@ static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const Emscripte // Register window resize event static EM_BOOL EmscriptenWindowResizedCallback(int eventType, const EmscriptenUiEvent *event, void *userData) { - // TODO. + // TODO: Implement EmscriptenWindowResizedCallback()? return 1; // The event was consumed by the callback handler } @@ -6010,7 +6178,8 @@ static void InitEvdevInput(void) { while ((entity = readdir(directory)) != NULL) { - if (strncmp("event", entity->d_name, strlen("event")) == 0) // Search for devices named "event*" + if ((strncmp("event", entity->d_name, strlen("event")) == 0) || // Search for devices named "event*" + (strncmp("mouse", entity->d_name, strlen("mouse")) == 0)) // Search for devices named "mouse*" { sprintf(path, "%s%s", DEFAULT_EVDEV_PATH, entity->d_name); ConfigureEvdevDevice(path); // Configure the device if appropriate @@ -6073,7 +6242,7 @@ static void ConfigureEvdevDevice(char *device) fd = open(device, O_RDONLY | O_NONBLOCK); if (fd < 0) { - TRACELOG(LOG_WARNING, "RPI: Failed to open input device %s", device); + TRACELOG(LOG_WARNING, "RPI: Failed to open input device: %s", device); return; } worker->fd = fd; @@ -6087,6 +6256,7 @@ static void ConfigureEvdevDevice(char *device) { if (sscanf(ptrDevName, "t%d", &devNum) == 1) worker->eventNum = devNum; } + else worker->eventNum = 0; // TODO: HACK: Grab number for mouse0 device! // At this point we have a connection to the device, but we don't yet know what the device is. // It could be many things, even as simple as a power button... @@ -6170,7 +6340,7 @@ static void ConfigureEvdevDevice(char *device) // Decide what to do with the device //------------------------------------------------------------------------------------------------------- - if (worker->isKeyboard && CORE.Input.Keyboard.fd == -1) + if (worker->isKeyboard && (CORE.Input.Keyboard.fd == -1)) { // Use the first keyboard encountered. This assumes that a device that says it's a keyboard is just a // keyboard. The keyboard is polled synchronously, whereas other input devices are polled in separate @@ -6334,7 +6504,7 @@ static void *EventThread(void *arg) gestureUpdate = true; } - if (event.code == REL_WHEEL) CORE.Input.Mouse.currentWheelMove += event.value; + if (event.code == REL_WHEEL) CORE.Input.Mouse.currentWheelMove.y += event.value; } // Absolute movement parsing @@ -6465,7 +6635,7 @@ static void *EventThread(void *arg) #endif } - WaitTime(5); // Sleep for 5ms to avoid hogging CPU time + WaitTime(0.005); // Sleep for 5ms to avoid hogging CPU time } close(worker->fd); @@ -6482,7 +6652,7 @@ static void InitGamepad(void) { sprintf(gamepadDev, "%s%i", DEFAULT_GAMEPAD_DEV, i); - if ((CORE.Input.Gamepad.streamId[i] = open(gamepadDev, O_RDONLY|O_NONBLOCK)) < 0) + if ((CORE.Input.Gamepad.streamId[i] = open(gamepadDev, O_RDONLY | O_NONBLOCK)) < 0) { // NOTE: Only show message for first gamepad if (i == 0) TRACELOG(LOG_WARNING, "RPI: Failed to open Gamepad device, no gamepad available"); @@ -6553,7 +6723,7 @@ static void *GamepadThread(void *arg) } } } - else WaitTime(1); // Sleep for 1 ms to avoid hogging CPU time + else WaitTime(0.001); // Sleep for 1 ms to avoid hogging CPU time } } @@ -6621,7 +6791,7 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt TRACELOG(LOG_TRACE, "DISPLAY: DRM mode: %d %ux%u@%u %s", i, mode->hdisplay, mode->vdisplay, mode->vrefresh, (mode->flags & DRM_MODE_FLAG_INTERLACE) ? "interlaced" : "progressive"); - if ((mode->hdisplay < width) || (mode->vdisplay < height) || (mode->vrefresh < fps)) + if ((mode->hdisplay < width) || (mode->vdisplay < height)) { TRACELOG(LOG_TRACE, "DISPLAY: DRM mode is too small"); continue; @@ -6633,23 +6803,22 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt continue; } - if ((mode->hdisplay >= width) && (mode->vdisplay >= height) && (mode->vrefresh >= fps)) + if (nearestIndex < 0) { - const int widthDiff = mode->hdisplay - width; - const int heightDiff = mode->vdisplay - height; - const int fpsDiff = mode->vrefresh - fps; + nearestIndex = i; + continue; + } - if (nearestIndex < 0) - { - nearestIndex = i; - continue; - } + const int widthDiff = abs(mode->hdisplay - width); + const int heightDiff = abs(mode->vdisplay - height); + const int fpsDiff = abs(mode->vrefresh - fps); - const int nearestWidthDiff = CORE.Window.connector->modes[nearestIndex].hdisplay - width; - const int nearestHeightDiff = CORE.Window.connector->modes[nearestIndex].vdisplay - height; - const int nearestFpsDiff = CORE.Window.connector->modes[nearestIndex].vrefresh - fps; + const int nearestWidthDiff = abs(CORE.Window.connector->modes[nearestIndex].hdisplay - width); + const int nearestHeightDiff = abs(CORE.Window.connector->modes[nearestIndex].vdisplay - height); + const int nearestFpsDiff = abs(CORE.Window.connector->modes[nearestIndex].vrefresh - fps); - if ((widthDiff < nearestWidthDiff) || (heightDiff < nearestHeightDiff) || (fpsDiff < nearestFpsDiff)) nearestIndex = i; + if ((widthDiff < nearestWidthDiff) || (heightDiff < nearestHeightDiff) || (fpsDiff < nearestFpsDiff)) { + nearestIndex = i; } } @@ -6822,12 +6991,13 @@ static void RecordAutomationEvent(unsigned int frame) } // INPUT_MOUSE_WHEEL_MOTION - if ((int)CORE.Input.Mouse.currentWheelMove != (int)CORE.Input.Mouse.previousWheelMove) + if (((int)CORE.Input.Mouse.currentWheelMove.x != (int)CORE.Input.Mouse.previousWheelMove.x) || + ((int)CORE.Input.Mouse.currentWheelMove.y != (int)CORE.Input.Mouse.previousWheelMove.y)) { events[eventCount].frame = frame; events[eventCount].type = INPUT_MOUSE_WHEEL_MOTION; - events[eventCount].params[0] = (int)CORE.Input.Mouse.currentWheelMove; - events[eventCount].params[1] = 0; + events[eventCount].params[0] = (int)CORE.Input.Mouse.currentWheelMove.x; + events[eventCount].params[1] = (int)CORE.Input.Mouse.currentWheelMove.y;; events[eventCount].params[2] = 0; TRACELOG(LOG_INFO, "[%i] INPUT_MOUSE_WHEEL_MOTION: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); @@ -6979,7 +7149,11 @@ static void PlayAutomationEvent(unsigned int frame) CORE.Input.Mouse.currentPosition.x = (float)events[i].params[0]; CORE.Input.Mouse.currentPosition.y = (float)events[i].params[1]; } break; - case INPUT_MOUSE_WHEEL_MOTION: CORE.Input.Mouse.currentWheelMove = (float)events[i].params[0]; break; // param[0]: delta + case INPUT_MOUSE_WHEEL_MOTION: // param[0]: x delta, param[1]: y delta + { + CORE.Input.Mouse.currentWheelMove.x = (float)events[i].params[0]; break; + CORE.Input.Mouse.currentWheelMove.y = (float)events[i].params[1]; break; + } break; case INPUT_TOUCH_UP: CORE.Input.Touch.currentTouchState[events[i].params[0]] = false; break; // param[0]: id case INPUT_TOUCH_DOWN: CORE.Input.Touch.currentTouchState[events[i].params[0]] = true; break; // param[0]: id case INPUT_TOUCH_POSITION: // param[0]: id, param[1]: x, param[2]: y diff --git a/src/rgestures.h b/src/rgestures.h index a40c41bc9..d32ea25fc 100644 --- a/src/rgestures.h +++ b/src/rgestures.h @@ -62,10 +62,10 @@ // NOTE: Below types are required for GESTURES_STANDALONE usage //---------------------------------------------------------------------------------- // Boolean type -#if defined(__STDC__) && __STDC_VERSION__ >= 199901L +#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) #include #elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE) - typedef enum bool { false, true } bool; + typedef enum bool { false = 0, true = !false } bool; #endif #if !defined(RL_VECTOR2_TYPE) diff --git a/src/rlgl.h b/src/rlgl.h index 8513998cb..ae6e04967 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -358,11 +358,11 @@ typedef struct rlRenderBatch { float currentDepth; // Current depth value for next draw } rlRenderBatch; -#if defined(__STDC__) && __STDC_VERSION__ >= 199901L +#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) #include #elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE) // Boolean type - typedef enum bool { false, true } bool; +typedef enum bool { false = 0, true = !false } bool; #endif #if !defined(RL_MATRIX_TYPE) @@ -433,7 +433,7 @@ typedef enum { RL_BLEND_MULTIPLIED, // Blend textures multiplying colors RL_BLEND_ADD_COLORS, // Blend textures adding colors (alternative) RL_BLEND_SUBTRACT_COLORS, // Blend textures subtracting colors (alternative) - RL_BLEND_ALPHA_PREMUL, // Blend premultiplied textures considering alpha + RL_BLEND_ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha RL_BLEND_CUSTOM // Blend textures using custom src/dst factors (use rlSetBlendFactors()) } rlBlendMode; @@ -598,7 +598,9 @@ RLAPI void rlglInit(int width, int height); // Initialize rlgl (buffer RLAPI void rlglClose(void); // De-inititialize rlgl (buffers, shaders, textures) RLAPI void rlLoadExtensions(void *loader); // Load OpenGL extensions (loader function required) RLAPI int rlGetVersion(void); // Get current OpenGL version +RLAPI void rlSetFramebufferWidth(int width); // Set current framebuffer width RLAPI int rlGetFramebufferWidth(void); // Get default framebuffer width +RLAPI void rlSetFramebufferHeight(int height); // Set current framebuffer height RLAPI int rlGetFramebufferHeight(void); // Get default framebuffer height RLAPI unsigned int rlGetTextureIdDefault(void); // Get default texture id @@ -639,7 +641,7 @@ RLAPI unsigned int rlLoadTexture(const void *data, int width, int height, int fo RLAPI unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer); // Load depth texture/renderbuffer (to be attached to fbo) RLAPI unsigned int rlLoadTextureCubemap(const void *data, int size, int format); // Load texture cubemap RLAPI void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int height, int format, const void *data); // Update GPU texture with new data -RLAPI void rlGetGlTextureFormats(int format, int *glInternalFormat, int *glFormat, int *glType); // Get OpenGL internal formats +RLAPI void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned int *glFormat, unsigned int *glType); // Get OpenGL internal formats RLAPI const char *rlGetPixelFormatName(unsigned int format); // Get name string for pixel format RLAPI void rlUnloadTexture(unsigned int id); // Unload texture from GPU memory RLAPI void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int *mipmaps); // Generate mipmap data for selected texture @@ -927,8 +929,8 @@ typedef struct rlglData { int glBlendDstFactor; // Blending destination factor int glBlendEquation; // Blending equation - int framebufferWidth; // Default framebuffer width - int framebufferHeight; // Default framebuffer height + int framebufferWidth; // Current framebuffer width + int framebufferHeight; // Current framebuffer height } State; // Renderer state struct { @@ -1230,6 +1232,7 @@ void rlOrtho(double left, double right, double bottom, double top, double znear, #endif // Set the viewport area (transformation from normalized device coordinates to window coordinates) +// NOTE: We store current viewport dimensions void rlViewport(int x, int y, int width, int height) { glViewport(x, y, width, height); @@ -1513,6 +1516,11 @@ void rlDisableTextureCubemap(void) void rlTextureParameters(unsigned int id, int param, int value) { glBindTexture(GL_TEXTURE_2D, id); + +#if !defined(GRAPHICS_API_OPENGL_11) + // Reset anisotropy filter, in case it was set + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f); +#endif switch (param) { @@ -1537,7 +1545,7 @@ void rlTextureParameters(unsigned int id, int param, int value) if (value <= RLGL.ExtSupported.maxAnisotropyLevel) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); else if (RLGL.ExtSupported.maxAnisotropyLevel > 0.0f) { - TRACELOG(RL_LOG_WARNING, "GL: Maximum anisotropic filter level supported is %iX", id, RLGL.ExtSupported.maxAnisotropyLevel); + TRACELOG(RL_LOG_WARNING, "GL: Maximum anisotropic filter level supported is %iX", id, (int)RLGL.ExtSupported.maxAnisotropyLevel); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); } else TRACELOG(RL_LOG_WARNING, "GL: Anisotropic filtering not supported"); @@ -1780,7 +1788,7 @@ void rlSetBlendMode(int mode) case RL_BLEND_MULTIPLIED: glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); break; case RL_BLEND_ADD_COLORS: glBlendFunc(GL_ONE, GL_ONE); glBlendEquation(GL_FUNC_ADD); break; case RL_BLEND_SUBTRACT_COLORS: glBlendFunc(GL_ONE, GL_ONE); glBlendEquation(GL_FUNC_SUBTRACT); break; - case RL_BLEND_ALPHA_PREMUL: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); break; + case RL_BLEND_ALPHA_PREMULTIPLY: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); break; case RL_BLEND_CUSTOM: { // NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactors() @@ -2219,6 +2227,22 @@ int rlGetVersion(void) return glVersion; } +// Set current framebuffer width +void rlSetFramebufferWidth(int width) +{ +#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) + RLGL.State.framebufferWidth = width; +#endif +} + +// Set current framebuffer height +void rlSetFramebufferHeight(int height) +{ +#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) + RLGL.State.framebufferHeight = height; +#endif +} + // Get default framebuffer width int rlGetFramebufferWidth(void) { @@ -2601,6 +2625,9 @@ void rlDrawRenderBatch(rlRenderBatch *batch) glUseProgram(0); // Unbind shader program } + + // Restore viewport to default measures + if (eyeCount == 2) rlViewport(0, 0, RLGL.State.framebufferWidth, RLGL.State.framebufferHeight); //------------------------------------------------------------------------------------------------------------ // Reset batch buffers @@ -2745,7 +2772,7 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format, { unsigned int mipSize = rlGetPixelDataSize(mipWidth, mipHeight, format); - int glInternalFormat, glFormat, glType; + unsigned int glInternalFormat, glFormat, glType; rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); TRACELOGD("TEXTURE: Load mipmap level %i (%i x %i), size: %i, offset: %i", i, mipWidth, mipHeight, mipSize, mipOffset); @@ -2895,7 +2922,7 @@ unsigned int rlLoadTextureCubemap(const void *data, int size, int format) glGenTextures(1, &id); glBindTexture(GL_TEXTURE_CUBE_MAP, id); - int glInternalFormat, glFormat, glType; + unsigned int glInternalFormat, glFormat, glType; rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); if (glInternalFormat != -1) @@ -2967,7 +2994,7 @@ void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int h { glBindTexture(GL_TEXTURE_2D, id); - int glInternalFormat, glFormat, glType; + unsigned int glInternalFormat, glFormat, glType; rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); if ((glInternalFormat != -1) && (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB)) @@ -2978,11 +3005,11 @@ void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int h } // Get OpenGL internal formats and data type from raylib PixelFormat -void rlGetGlTextureFormats(int format, int *glInternalFormat, int *glFormat, int *glType) +void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned int *glFormat, unsigned int *glType) { - *glInternalFormat = -1; - *glFormat = -1; - *glType = -1; + *glInternalFormat = 0; + *glFormat = 0; + *glType = 0; switch (format) { @@ -3088,14 +3115,11 @@ void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) if ((texIsPOT) || (RLGL.ExtSupported.texNPOT)) { - //glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE + //glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorithm: GL_FASTEST, GL_NICEST, GL_DONT_CARE glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Activate Trilinear filtering for mipmaps - - #define MIN(a,b) (((a)<(b))?(a):(b)) - #define MAX(a,b) (((a)>(b))?(a):(b)) + #define MIN(a,b) (((a)<(b))? (a):(b)) + #define MAX(a,b) (((a)>(b))? (a):(b)) *mipmaps = 1 + (int)floor(log(MAX(width, height))/log(2)); TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Mipmaps generated automatically, total: %i", id, *mipmaps); @@ -3128,7 +3152,7 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format) // GL_UNPACK_ALIGNMENT affects operations that write to OpenGL memory (glTexImage, etc.) glPixelStorei(GL_PACK_ALIGNMENT, 1); - int glInternalFormat, glFormat, glType; + unsigned int glInternalFormat, glFormat, glType; rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); unsigned int size = rlGetPixelDataSize(width, height, format); @@ -3171,7 +3195,6 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format) return pixels; } - // Read screen pixel data (color buffer) unsigned char *rlReadScreenPixels(int width, int height) { @@ -3649,7 +3672,7 @@ unsigned int rlCompileShader(const char *shaderCode, int type) if (maxLength > 0) { int length = 0; - char *log = RL_CALLOC(maxLength, sizeof(char)); + char *log = (char *)RL_CALLOC(maxLength, sizeof(char)); glGetShaderInfoLog(shader, maxLength, &length, log); TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Compile error: %s", shader, log); RL_FREE(log); @@ -3711,7 +3734,7 @@ unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId) if (maxLength > 0) { int length = 0; - char *log = RL_CALLOC(maxLength, sizeof(char)); + char *log = (char *)RL_CALLOC(maxLength, sizeof(char)); glGetProgramInfoLog(program, maxLength, &length, log); TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Link error: %s", program, log); RL_FREE(log); @@ -3878,7 +3901,7 @@ unsigned int rlLoadComputeShaderProgram(unsigned int shaderId) if (maxLength > 0) { int length = 0; - char *log = RL_CALLOC(maxLength, sizeof(char)); + char *log = (char *)RL_CALLOC(maxLength, sizeof(char)); glGetProgramInfoLog(program, maxLength, &length, log); TRACELOG(RL_LOG_WARNING, "SHADER: [ID %i] Link error: %s", program, log); RL_FREE(log); @@ -3987,7 +4010,7 @@ void rlCopyBuffersElements(unsigned int destId, unsigned int srcId, unsigned lon void rlBindImageTexture(unsigned int id, unsigned int index, unsigned int format, int readonly) { #if defined(GRAPHICS_API_OPENGL_43) - int glInternalFormat = 0, glFormat = 0, glType = 0; + unsigned int glInternalFormat = 0, glFormat = 0, glType = 0; rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); glBindImageTexture(index, id, 0, 0, 0, readonly ? GL_READ_ONLY : GL_READ_WRITE, glInternalFormat); diff --git a/src/extras/rmem.h b/src/rmem.h similarity index 85% rename from src/extras/rmem.h rename to src/rmem.h index 43005cfec..772a37b31 100644 --- a/src/extras/rmem.h +++ b/src/rmem.h @@ -1,12 +1,12 @@ /********************************************************************************************** * -* rmem - raylib memory pool and objects pool +* rmem v1.3 - raylib memory pool and objects pool * * A quick, efficient, and minimal free list and arena-based allocator * * PURPOSE: -* - A quicker, efficient memory allocator alternative to 'malloc' and friends. -* - Reduce the possibilities of memory leaks for beginner developers using Raylib. +* - A quicker, efficient memory allocator alternative to 'malloc()' and friends. +* - Reduce the possibilities of memory leaks for beginner developers using raylib. * - Being able to flexibly range check memory if necessary. * * CONFIGURATION: @@ -16,6 +16,22 @@ * 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. * +* DOCUMENTATION: +* +* raylib Wiki: https://github.com/raysan5/raylib/wiki/raylib-memory-pool +* Usage example with raylib: https://github.com/raysan5/raylib/issues/1329 +* +* CHANGELOG: +* +* v1.0: First version +* v1.1: Bug patches for the mempool and addition of object pool +* v1.2: Addition of bidirectional arena +* v1.3: Several changes: +* Pptimizations of allocators +* Renamed 'Stack' to 'Arena' +* Replaced certain define constants with an anonymous enum +* Refactored MemPool to no longer require active or deferred defragging +* * * LICENSE: zlib/libpng * @@ -61,7 +77,13 @@ // Types and Structures Definition //---------------------------------------------------------------------------------- -// Memory Pool +enum { + MEMPOOL_BUCKET_SIZE = 8, + MEMPOOL_BUCKET_BITS = (sizeof(uintptr_t) >> 1) + 1, + MEM_SPLIT_THRESHOLD = sizeof(uintptr_t) * 4 +}; + +// Memory pool node typedef struct MemNode MemNode; struct MemNode { size_t size; @@ -74,33 +96,25 @@ typedef struct AllocList { size_t len; } AllocList; -// Arena allocator. +// Arena allocator typedef struct Arena { uintptr_t mem, offs; size_t size; } Arena; - -enum { - MEMPOOL_BUCKET_SIZE = 8, - MEMPOOL_BUCKET_BITS = (sizeof(uintptr_t) >> 1) + 1, - MEM_SPLIT_THRESHOLD = sizeof(uintptr_t) * 4 -}; - +// Memory pool typedef struct MemPool { AllocList large, buckets[MEMPOOL_BUCKET_SIZE]; Arena arena; } MemPool; - -// Object Pool +// Object pool typedef struct ObjPool { uintptr_t mem, offs; size_t objSize, freeBlocks, memSize; } ObjPool; - -// Double-Ended Stack aka Deque +// Double-ended stack (aka Deque) typedef struct BiStack { uintptr_t mem, front, back; size_t size; @@ -166,9 +180,8 @@ RMEMAPI intptr_t BiStackMargins(BiStack destack); #if defined(RMEM_IMPLEMENTATION) -#include // Required for: -#include // Required for: -#include // Required for: +#include // Required for: malloc(), calloc(), free() +#include // Required for: memset(), memcpy(), memmove() //---------------------------------------------------------------------------------- // Defines and Macros @@ -201,18 +214,21 @@ static MemNode *__SplitMemNode(MemNode *const node, const size_t bytes) MemNode *const r = ( MemNode* )(n + (node->size - bytes)); node->size -= bytes; r->size = bytes; + return r; } static void __InsertMemNodeBefore(AllocList *const list, MemNode *const insert, MemNode *const curr) { insert->next = curr; + if (curr->prev==NULL) list->head = insert; else { insert->prev = curr->prev; curr->prev->next = insert; } + curr->prev = insert; } @@ -220,10 +236,9 @@ static void __ReplaceMemNode(MemNode *const old, MemNode *const replace) { replace->prev = old->prev; replace->next = old->next; - if( old->prev != NULL ) - old->prev->next = replace; - if( old->next != NULL ) - old->next->prev = replace; + + if (old->prev != NULL) old->prev->next = replace; + if (old->next != NULL) old->next->prev = replace; } @@ -244,7 +259,9 @@ static MemNode *__RemoveMemNode(AllocList *const list, MemNode *const node) if (list->tail != NULL) list->tail->next = NULL; else list->head = NULL; } + list->len--; + return node; } @@ -253,10 +270,12 @@ static MemNode *__FindMemNode(AllocList *const list, const size_t bytes) for (MemNode *node = list->head; node != NULL; node = node->next) { if (node->size < bytes) continue; - // close in size - reduce fragmentation by not splitting. + + // Close in size - reduce fragmentation by not splitting else if (node->size <= bytes + MEM_SPLIT_THRESHOLD) return __RemoveMemNode(list, node); else return __SplitMemNode(node, bytes); } + return NULL; } @@ -271,29 +290,34 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo { for (MemNode *iter = list->head; iter != NULL; iter = iter->next) { - if (( uintptr_t )iter == mempool->arena.offs) + if ((uintptr_t)iter == mempool->arena.offs) { mempool->arena.offs += iter->size; __RemoveMemNode(list, iter); iter = list->head; - if (iter == NULL) { + + if (iter == NULL) + { list->head = node; return; } } - const uintptr_t inode = ( uintptr_t )node; - const uintptr_t iiter = ( uintptr_t )iter; + + const uintptr_t inode = (uintptr_t)node; + const uintptr_t iiter = (uintptr_t)iter; const uintptr_t iter_end = iiter + iter->size; const uintptr_t node_end = inode + node->size; - if (iter==node) return; + + if (iter == node) return; else if (iter < node) { // node was coalesced prior. if (iter_end > inode) return; - else if (iter_end==inode && !is_bucket) + else if ((iter_end == inode) && !is_bucket) { // if we can coalesce, do so. iter->size += node->size; + return; } else if (iter->next == NULL) @@ -302,6 +326,7 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo iter->next = node; node->prev = iter; list->len++; + return; } } @@ -309,10 +334,10 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo { // Address sort, lowest to highest aka ascending order. if (iiter < node_end) return; - else if (iter==list->head && !is_bucket) + else if ((iter == list->head) && !is_bucket) { - if (iter_end==inode) iter->size += node->size; - else if (node_end==iiter) + if (iter_end == inode) iter->size += node->size; + else if (node_end == iiter) { node->size += list->head->size; node->next = list->head->next; @@ -327,9 +352,10 @@ static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNo list->head = node; list->len++; } + return; } - else if (iter_end==inode && !is_bucket) + else if ((iter_end == inode) && !is_bucket) { // if we can coalesce, do so. iter->size += node->size; @@ -359,12 +385,14 @@ MemPool CreateMemPool(const size_t size) { // Align the mempool size to at least the size of an alloc node. uint8_t *const restrict buf = malloc(size*sizeof *buf); + if (buf==NULL) return mempool; else { mempool.arena.size = size; - mempool.arena.mem = ( uintptr_t )buf; + mempool.arena.mem = (uintptr_t)buf; mempool.arena.offs = mempool.arena.mem + mempool.arena.size; + return mempool; } } @@ -373,12 +401,14 @@ MemPool CreateMemPool(const size_t size) MemPool CreateMemPoolFromBuffer(void *const restrict buf, const size_t size) { MemPool mempool = { 0 }; + if ((size == 0) || (buf == NULL) || (size <= sizeof(MemNode))) return mempool; else { mempool.arena.size = size; - mempool.arena.mem = ( uintptr_t )buf; + mempool.arena.mem = (uintptr_t)buf; mempool.arena.offs = mempool.arena.mem + mempool.arena.size; + return mempool; } } @@ -388,7 +418,7 @@ void DestroyMemPool(MemPool *const restrict mempool) if (mempool->arena.mem == 0) return; else { - void *const restrict ptr = ( void* )mempool->arena.mem; + void *const restrict ptr = (void *)mempool->arena.mem; free(ptr); *mempool = (MemPool){ 0 }; } @@ -440,7 +470,8 @@ void *MemPoolAlloc(MemPool *const mempool, const size_t size) // | space | highest addr of block // -------------- new_mem->next = new_mem->prev = NULL; - uint8_t *const restrict final_mem = ( uint8_t* )new_mem + sizeof *new_mem; + uint8_t *const restrict final_mem = (uint8_t *)new_mem + sizeof *new_mem; + return memset(final_mem, 0, new_mem->size - sizeof *new_mem); } } @@ -448,20 +479,22 @@ void *MemPoolAlloc(MemPool *const mempool, const size_t size) void *MemPoolRealloc(MemPool *const restrict mempool, void *const ptr, const size_t size) { if (size > mempool->arena.size) return NULL; - // NULL ptr should make this work like regular Allocation. + // NULL ptr should make this work like regular Allocation else if (ptr == NULL) return MemPoolAlloc(mempool, size); else if ((uintptr_t)ptr - sizeof(MemNode) < mempool->arena.mem) return NULL; else { - MemNode *const node = ( MemNode* )(( uint8_t* )ptr - sizeof *node); + MemNode *const node = (MemNode *)((uint8_t *)ptr - sizeof *node); const size_t NODE_SIZE = sizeof *node; uint8_t *const resized_block = MemPoolAlloc(mempool, size); + if (resized_block == NULL) return NULL; else { - MemNode *const resized = ( MemNode* )(resized_block - sizeof *resized); + MemNode *const resized = (MemNode *)(resized_block - sizeof *resized); memmove(resized_block, ptr, (node->size > resized->size)? (resized->size - NODE_SIZE) : (node->size - NODE_SIZE)); MemPoolFree(mempool, ptr); + return resized_block; } } @@ -469,7 +502,8 @@ void *MemPoolRealloc(MemPool *const restrict mempool, void *const ptr, const siz void MemPoolFree(MemPool *const restrict mempool, void *const ptr) { - const uintptr_t p = ( uintptr_t )ptr; + const uintptr_t p = (uintptr_t)ptr; + if ((ptr == NULL) || (p - sizeof(MemNode) < mempool->arena.mem)) return; else { @@ -511,9 +545,9 @@ size_t GetMemPoolFreeMemory(const MemPool mempool) { size_t total_remaining = mempool.arena.offs - mempool.arena.mem; - for (MemNode *n=mempool.large.head; n != NULL; n = n->next) total_remaining += n->size; + for (MemNode *n = mempool.large.head; n != NULL; n = n->next) total_remaining += n->size; - for (size_t i=0; inext) total_remaining += n->size; + for (size_t i = 0; i < MEMPOOL_BUCKET_SIZE; i++) for (MemNode *n = mempool.buckets[i].head; n != NULL; n = n->next) total_remaining += n->size; return total_remaining; } @@ -522,11 +556,13 @@ void MemPoolReset(MemPool *const mempool) { mempool->large.head = mempool->large.tail = NULL; mempool->large.len = 0; + for (size_t i = 0; i < MEMPOOL_BUCKET_SIZE; i++) { mempool->buckets[i].head = mempool->buckets[i].tail = NULL; mempool->buckets[i].len = 0; } + mempool->arena.offs = mempool->arena.mem + mempool->arena.size; } @@ -537,19 +573,21 @@ void MemPoolReset(MemPool *const mempool) ObjPool CreateObjPool(const size_t objsize, const size_t len) { ObjPool objpool = { 0 }; + if ((len == 0) || (objsize == 0)) return objpool; else { const size_t aligned_size = __AlignSize(objsize, sizeof(size_t)); uint8_t *const restrict buf = calloc(len, aligned_size); + if (buf == NULL) return objpool; objpool.objSize = aligned_size; objpool.memSize = objpool.freeBlocks = len; - objpool.mem = ( uintptr_t )buf; + objpool.mem = (uintptr_t)buf; for (size_t i=0; imem == 0) return; else { - void *const restrict ptr = ( void* )objpool->mem; + void *const restrict ptr = (void *)objpool->mem; free(ptr); - *objpool = (ObjPool){0}; + + *objpool = (ObjPool){ 0 }; } } @@ -600,12 +640,13 @@ void *ObjPoolAlloc(ObjPool *const objpool) // For first allocation, head points to the very first index. // Head = &pool[0]; // ret = Head == ret = &pool[0]; - size_t *const restrict block = ( size_t* )objpool->offs; + size_t *const restrict block = (size_t *)objpool->offs; objpool->freeBlocks--; - // after allocating, we set head to the address of the index that *Head holds. + // After allocating, we set head to the address of the index that *Head holds. // Head = &pool[*Head * pool.objsize]; objpool->offs = (objpool->freeBlocks != 0)? objpool->mem + (*block*objpool->objSize) : 0; + return memset(block, 0, objpool->objSize); } else return NULL; @@ -614,13 +655,14 @@ void *ObjPoolAlloc(ObjPool *const objpool) void ObjPoolFree(ObjPool *const restrict objpool, void *const ptr) { uintptr_t block = (uintptr_t)ptr; + if ((ptr == NULL) || (block < objpool->mem) || (block > objpool->mem + objpool->memSize*objpool->objSize)) return; else { // When we free our pointer, we recycle the pointer space to store the previous index and then we push it as our new head. // *p = index of Head in relation to the buffer; // Head = p; - size_t *const restrict index = ( size_t* )block; + size_t *const restrict index = (size_t *)block; *index = (objpool->offs != 0)? (objpool->offs - objpool->mem)/objpool->objSize : objpool->memSize; objpool->offs = block; objpool->freeBlocks++; @@ -641,29 +683,34 @@ void ObjPoolCleanUp(ObjPool *const restrict objpool, void **const restrict ptrre //---------------------------------------------------------------------------------- // Module Functions Definition - Double-Ended Stack //---------------------------------------------------------------------------------- + BiStack CreateBiStack(const size_t len) { BiStack destack = { 0 }; + if (len == 0) return destack; uint8_t *const buf = malloc(len*sizeof *buf); - if (buf==NULL) return destack; + if (buf == NULL) return destack; destack.size = len; - destack.mem = ( uintptr_t )buf; + destack.mem = (uintptr_t)buf; destack.front = destack.mem; destack.back = destack.mem + len; + return destack; } BiStack CreateBiStackFromBuffer(void *const buf, const size_t len) { BiStack destack = { 0 }; - if (len == 0 || buf == NULL) return destack; + + if ((len == 0) || (buf == NULL)) return destack; else { destack.size = len; - destack.mem = destack.front = ( uintptr_t )buf; + destack.mem = destack.front = (uintptr_t)buf; destack.back = destack.mem + len; + return destack; } } @@ -673,9 +720,9 @@ void DestroyBiStack(BiStack *const restrict destack) if (destack->mem == 0) return; else { - uint8_t *const restrict buf = ( uint8_t* )destack->mem; + uint8_t *const restrict buf = (uint8_t *)destack->mem; free(buf); - *destack = (BiStack){0}; + *destack = (BiStack){ 0 }; } } @@ -689,8 +736,9 @@ void *BiStackAllocFront(BiStack *const restrict destack, const size_t len) if (destack->front + ALIGNED_LEN >= destack->back) return NULL; else { - uint8_t *const restrict ptr = ( uint8_t* )destack->front; + uint8_t *const restrict ptr = (uint8_t *)destack->front; destack->front += ALIGNED_LEN; + return ptr; } } @@ -707,7 +755,8 @@ void *BiStackAllocBack(BiStack *const restrict destack, const size_t len) else { destack->back -= ALIGNED_LEN; - uint8_t *const restrict ptr = ( uint8_t* )destack->back; + uint8_t *const restrict ptr = (uint8_t *)destack->back; + return ptr; } } @@ -737,15 +786,3 @@ inline intptr_t BiStackMargins(const BiStack destack) } #endif // RMEM_IMPLEMENTATION - -/******* - * Changelog - * v1.0: First Creation. - * v1.1: bug patches for the mempool and addition of object pool. - * v1.2: addition of bidirectional arena. - * v1.3: - * optimizations of allocators. - * renamed 'Stack' to 'Arena'. - * replaced certain define constants with an anonymous enum. - * refactored MemPool to no longer require active or deferred defragging. - ********/ diff --git a/src/rmodels.c b/src/rmodels.c index 9f5cfd397..a088d4443 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -200,7 +200,7 @@ void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rota // Draw a color-filled triangle (vertex in counter-clockwise order!) void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color) { - rlCheckRenderBatchLimit(3); + rlCheckRenderBatchLimit(8); rlBegin(RL_TRIANGLES); rlColor4ub(color.r, color.g, color.b, color.a); @@ -2630,7 +2630,7 @@ Mesh GenMeshKnot(float radius, float size, int radSeg, int sides) // NOTE: Vertex data is uploaded to GPU Mesh GenMeshHeightmap(Image heightmap, Vector3 size) { - #define GRAY_VALUE(c) ((c.r+c.g+c.b)/3) + #define GRAY_VALUE(c) ((c.r+c.g+c.b)/3.0f) Mesh mesh = { 0 }; @@ -2653,8 +2653,6 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) int tcCounter = 0; // Used to count texcoords float by float int nCounter = 0; // Used to count normals float by float - int trisCounter = 0; - Vector3 scaleFactor = { size.x/mapX, size.y/255.0f, size.z/mapZ }; Vector3 vA = { 0 }; @@ -2671,15 +2669,15 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) // one triangle - 3 vertex mesh.vertices[vCounter] = (float)x*scaleFactor.x; - mesh.vertices[vCounter + 1] = (float)GRAY_VALUE(pixels[x + z*mapX])*scaleFactor.y; + mesh.vertices[vCounter + 1] = GRAY_VALUE(pixels[x + z*mapX])*scaleFactor.y; mesh.vertices[vCounter + 2] = (float)z*scaleFactor.z; mesh.vertices[vCounter + 3] = (float)x*scaleFactor.x; - mesh.vertices[vCounter + 4] = (float)GRAY_VALUE(pixels[x + (z + 1)*mapX])*scaleFactor.y; + mesh.vertices[vCounter + 4] = GRAY_VALUE(pixels[x + (z + 1)*mapX])*scaleFactor.y; mesh.vertices[vCounter + 5] = (float)(z + 1)*scaleFactor.z; mesh.vertices[vCounter + 6] = (float)(x + 1)*scaleFactor.x; - mesh.vertices[vCounter + 7] = (float)GRAY_VALUE(pixels[(x + 1) + z*mapX])*scaleFactor.y; + mesh.vertices[vCounter + 7] = GRAY_VALUE(pixels[(x + 1) + z*mapX])*scaleFactor.y; mesh.vertices[vCounter + 8] = (float)z*scaleFactor.z; // another triangle - 3 vertex @@ -2692,7 +2690,7 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) mesh.vertices[vCounter + 14] = mesh.vertices[vCounter + 5]; mesh.vertices[vCounter + 15] = (float)(x + 1)*scaleFactor.x; - mesh.vertices[vCounter + 16] = (float)GRAY_VALUE(pixels[(x + 1) + (z + 1)*mapX])*scaleFactor.y; + mesh.vertices[vCounter + 16] = GRAY_VALUE(pixels[(x + 1) + (z + 1)*mapX])*scaleFactor.y; mesh.vertices[vCounter + 17] = (float)(z + 1)*scaleFactor.z; vCounter += 18; // 6 vertex, 18 floats @@ -2749,7 +2747,6 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size) } nCounter += 18; // 6 vertex, 18 floats - trisCounter += 2; } } @@ -3335,7 +3332,7 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint) { // NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width - Vector2 sizeRatio = { size.y, size.x*(float)source.height/source.width }; + Vector2 sizeRatio = { size.x*(float)source.width/source.height, size.y }; Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up); @@ -3396,7 +3393,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector bottomRight = Vector3Add(bottomRight, position); bottomLeft = Vector3Add(bottomLeft, position); - rlCheckRenderBatchLimit(4); + rlCheckRenderBatchLimit(8); rlSetTexture(texture.id); @@ -4643,7 +4640,6 @@ static Model LoadGLTF(const char *fileName) // Load our model data: meshes and materials model.meshCount = primitivesCount; model.meshes = RL_CALLOC(model.meshCount, sizeof(Mesh)); - for (int i = 0; i < model.meshCount; i++) model.meshes[i].vboId = (unsigned int*)RL_CALLOC(MAX_MESH_VERTEX_BUFFERS, sizeof(unsigned int)); // NOTE: We keep an extra slot for default material, in case some mesh requires it model.materialCount = (int)data->materials_count + 1; @@ -4845,7 +4841,7 @@ static Model LoadGLTF(const char *fileName) LOAD_ATTRIBUTE(attribute, 4, unsigned short, temp); // Convert data to raylib color data type (4 bytes) - for (int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(((float)temp[c]/65535.0f)*255.0f); + for (unsigned int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(((float)temp[c]/65535.0f)*255.0f); RL_FREE(temp); } @@ -4859,7 +4855,7 @@ static Model LoadGLTF(const char *fileName) LOAD_ATTRIBUTE(attribute, 4, float, temp); // Convert data to raylib color data type (4 bytes), we expect the color data normalized - for (int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(temp[c]*255.0f); + for (unsigned int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(temp[c]*255.0f); RL_FREE(temp); } @@ -4894,7 +4890,7 @@ static Model LoadGLTF(const char *fileName) LOAD_ATTRIBUTE(attribute, 1, unsigned int, temp); // Convert data to raylib indices data type (unsigned short) - for (int d = 0; d < attribute->count; d++) model.meshes[meshIndex].indices[d] = (unsigned short)temp[d]; + for (unsigned int d = 0; d < attribute->count; d++) model.meshes[meshIndex].indices[d] = (unsigned short)temp[d]; TRACELOG(LOG_WARNING, "MODEL: [%s] Indices data converted from u32 to u16, possible loss of data", fileName); @@ -4906,7 +4902,7 @@ static Model LoadGLTF(const char *fileName) // Assign to the primitive mesh the corresponding material index // NOTE: If no material defined, mesh uses the already assigned default material (index: 0) - for (int m = 0; m < data->materials_count; m++) + for (unsigned int m = 0; m < data->materials_count; m++) { // The primitive actually keeps the pointer to the corresponding material, // raylib instead assigns to the mesh the by its index, as loaded in model.materials array diff --git a/src/rshapes.c b/src/rshapes.c index 79631d622..955f056d4 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -785,28 +785,26 @@ void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, rlSetTexture(texShapes.id); - rlPushMatrix(); - rlBegin(RL_QUADS); - rlNormal3f(0.0f, 0.0f, 1.0f); + rlBegin(RL_QUADS); + rlNormal3f(0.0f, 0.0f, 1.0f); - // NOTE: Default raylib font character 95 is a white square - rlColor4ub(col1.r, col1.g, col1.b, col1.a); - rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height); - rlVertex2f(rec.x, rec.y); + // NOTE: Default raylib font character 95 is a white square + rlColor4ub(col1.r, col1.g, col1.b, col1.a); + rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height); + rlVertex2f(rec.x, rec.y); - rlColor4ub(col2.r, col2.g, col2.b, col2.a); - rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height); - rlVertex2f(rec.x, rec.y + rec.height); + rlColor4ub(col2.r, col2.g, col2.b, col2.a); + rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height); + rlVertex2f(rec.x, rec.y + rec.height); - rlColor4ub(col3.r, col3.g, col3.b, col3.a); - rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height); - rlVertex2f(rec.x + rec.width, rec.y + rec.height); + rlColor4ub(col3.r, col3.g, col3.b, col3.a); + rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height); + rlVertex2f(rec.x + rec.width, rec.y + rec.height); - rlColor4ub(col4.r, col4.g, col4.b, col4.a); - rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height); - rlVertex2f(rec.x + rec.width, rec.y); - rlEnd(); - rlPopMatrix(); + rlColor4ub(col4.r, col4.g, col4.b, col4.a); + rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height); + rlVertex2f(rec.x + rec.width, rec.y); + rlEnd(); rlSetTexture(0); } diff --git a/src/rtext.c b/src/rtext.c index f266a6a68..722dbb1d7 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -25,7 +25,7 @@ * * DEPENDENCIES: * stb_truetype - Load TTF file and rasterize characters data -* stb_rect_pack - Rectangles packing algorythms, required for font atlas generation +* stb_rect_pack - Rectangles packing algorithms, required for font atlas generation * * * LICENSE: zlib/libpng @@ -229,7 +229,7 @@ extern void LoadFontDefault(void) //------------------------------------------------------------------------------ // Allocate space for our characters info data - // NOTE: This memory should be freed at end! --> CloseWindow() + // NOTE: This memory must be freed at end! --> Done by CloseWindow() defaultFont.glyphs = (GlyphInfo *)RL_MALLOC(defaultFont.glyphCount*sizeof(GlyphInfo)); defaultFont.recs = (Rectangle *)RL_MALLOC(defaultFont.glyphCount*sizeof(Rectangle)); @@ -334,7 +334,11 @@ Font LoadFont(const char *fileName) TRACELOG(LOG_WARNING, "FONT: [%s] Failed to load font texture -> Using default font", fileName); font = GetFontDefault(); } - else SetTextureFilter(font.texture, TEXTURE_FILTER_POINT); // By default we set point filter (best performance) + else + { + SetTextureFilter(font.texture, TEXTURE_FILTER_POINT); // By default we set point filter (best performance) + TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", FONT_TTF_DEFAULT_SIZE, FONT_TTF_DEFAULT_NUMCHARS); + } return font; } @@ -520,7 +524,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int UnloadImage(atlas); - // TRACELOG(LOG_INFO, "FONT: Font loaded successfully (%i glyphs)", font.glyphCount); + TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", font.baseSize, font.glyphCount); } else font = GetFontDefault(); } @@ -695,7 +699,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC // DEBUG: We can see padding in the generated image setting a gray background... //for (int i = 0; i < atlas.width*atlas.height; i++) ((unsigned char *)atlas.data)[i] = 100; - if (packMethod == 0) // Use basic packing algorythm + if (packMethod == 0) // Use basic packing algorithm { int offsetX = padding; int offsetY = padding; @@ -746,7 +750,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC } } } - else if (packMethod == 1) // Use Skyline rect packing algorythm (stb_pack_rect) + else if (packMethod == 1) // Use Skyline rect packing algorithm (stb_pack_rect) { stbrp_context *context = (stbrp_context *)RL_MALLOC(sizeof(*context)); stbrp_node *nodes = (stbrp_node *)RL_MALLOC(glyphCount*sizeof(*nodes)); @@ -935,7 +939,7 @@ bool ExportFontAsCode(Font font, const char *fileName) byteCount += sprintf(txtData + byteCount, " Font font = { 0 };\n\n"); byteCount += sprintf(txtData + byteCount, " font.baseSize = %i;\n", font.baseSize); byteCount += sprintf(txtData + byteCount, " font.glyphCount = %i;\n", font.glyphCount); - byteCount += sprintf(txtData + byteCount, " font.glyphPadding = %i;\n\n", FONT_TTF_DEFAULT_CHARS_PADDING); + byteCount += sprintf(txtData + byteCount, " font.glyphPadding = %i;\n\n", font.glyphPadding); byteCount += sprintf(txtData + byteCount, " // Custom font loading\n"); #if defined(SUPPORT_COMPRESSED_FONT_ATLAS) byteCount += sprintf(txtData + byteCount, " // NOTE: Compressed font image data (DEFLATE), it requires DecompressData() function\n"); @@ -1047,7 +1051,7 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f { // NOTE: Fixed line spacing of 1.5 line-height // TODO: Support custom line spacing defined by user - textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor); + textOffsetY += (int)((font.baseSize + font.baseSize/2.0f)*scaleFactor); textOffsetX = 0.0f; } else @@ -1119,7 +1123,7 @@ void DrawTextCodepoints(Font font, const int *codepoints, int count, Vector2 pos { // NOTE: Fixed line spacing of 1.5 line-height // TODO: Support custom line spacing defined by user - textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor); + textOffsetY += (int)((font.baseSize + font.baseSize/2.0f)*scaleFactor); textOffsetX = 0.0f; } else @@ -1383,7 +1387,7 @@ const char *TextSubtext(const char *text, int position, int length) // Replace text string // REQUIRES: strlen(), strstr(), strncpy(), strcpy() -// WARNING: Allocated memory should be manually freed +// WARNING: Allocated memory must be manually freed char *TextReplace(char *text, const char *replace, const char *by) { // Sanity checks and initialization @@ -1432,7 +1436,7 @@ char *TextReplace(char *text, const char *replace, const char *by) } // Insert text in a specific position, moves all text forward -// WARNING: Allocated memory should be manually freed +// WARNING: Allocated memory must be manually freed char *TextInsert(const char *text, const char *insert, int position) { int textLen = TextLength(text); @@ -1616,7 +1620,7 @@ const char *TextToPascal(const char *text) // Encode text codepoint into UTF-8 text // REQUIRES: memcpy() -// WARNING: Allocated memory should be manually freed +// WARNING: Allocated memory must be manually freed char *TextCodepointsToUTF8(const int *codepoints, int length) { // We allocate enough memory fo fit all possible codepoints diff --git a/src/rtextures.c b/src/rtextures.c index 9c93aedf1..3328553c9 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -37,7 +37,7 @@ * DEPENDENCIES: * stb_image - Multiple image formats loading (JPEG, PNG, BMP, TGA, PSD, GIF, PIC) * NOTE: stb_image has been slightly modified to support Android platform. -* stb_image_resize - Multiple image resize algorythms +* stb_image_resize - Multiple image resize algorithms * * * LICENSE: zlib/libpng @@ -1889,10 +1889,10 @@ void ImageColorTint(Image *image, Color color) unsigned char b = (unsigned char)(((float)pixels[index].b/255*cB)*255.0f); unsigned char a = (unsigned char)(((float)pixels[index].a/255*cA)*255.0f); - pixels[y*image->width + x].r = r; - pixels[y*image->width + x].g = g; - pixels[y*image->width + x].b = b; - pixels[y*image->width + x].a = a; + pixels[index].r = r; + pixels[index].g = g; + pixels[index].b = b; + pixels[index].a = a; } } @@ -2411,7 +2411,20 @@ Color GetImageColor(Image image, int x, int y) // Clear image background with given color void ImageClearBackground(Image *dst, Color color) { - for (int i = 0; i < dst->width*dst->height; ++i) ImageDrawPixel(dst, i%dst->width, i/dst->width, color); + // Security check to avoid program crash + if ((dst->data == NULL) || (dst->width == 0) || (dst->height == 0)) return; + + // Fill in first pixel based on image format + ImageDrawPixel(dst, 0, 0, color); + + unsigned char *pSrcPixel = (unsigned char *)dst->data; + int bytesPerPixel = GetPixelDataSize(1, 1, dst->format); + + // Repeat the first pixel data throughout the image + for (int i = 1; i < dst->width * dst->height; i++) + { + memcpy(pSrcPixel + i * bytesPerPixel, pSrcPixel, bytesPerPixel); + } } // Draw pixel within an image @@ -2685,13 +2698,21 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color) int ey = sy + (int)rec.height; int sx = (int)rec.x; - int ex = sx + (int)rec.width; + + int bytesPerPixel = GetPixelDataSize(1, 1, dst->format); for (int y = sy; y < ey; y++) { - for (int x = sx; x < ex; x++) + // Fill in the first pixel of the row based on image format + ImageDrawPixel(dst, sx, y, color); + + int bytesOffset = ((y * dst->width) + sx) * bytesPerPixel; + unsigned char *pSrcPixel = (unsigned char *)dst->data + bytesOffset; + + // Repeat the first pixel data throughout the row + for (int x = 1; x < (int)rec.width; x++) { - ImageDrawPixel(dst, x, y, color); + memcpy(pSrcPixel + x * bytesPerPixel, pSrcPixel, bytesPerPixel); } } } @@ -3788,10 +3809,10 @@ Color ColorAlphaBlend(Color dst, Color src, Color tint) Color out = WHITE; // Apply color tint to source color - src.r = (unsigned char)(((unsigned int)src.r*(unsigned int)tint.r) >> 8); - src.g = (unsigned char)(((unsigned int)src.g*(unsigned int)tint.g) >> 8); - src.b = (unsigned char)(((unsigned int)src.b*(unsigned int)tint.b) >> 8); - src.a = (unsigned char)(((unsigned int)src.a*(unsigned int)tint.a) >> 8); + src.r = (unsigned char)(((unsigned int)src.r*((unsigned int)tint.r+1)) >> 8); + src.g = (unsigned char)(((unsigned int)src.g*((unsigned int)tint.g+1)) >> 8); + src.b = (unsigned char)(((unsigned int)src.b*((unsigned int)tint.b+1)) >> 8); + src.a = (unsigned char)(((unsigned int)src.a*((unsigned int)tint.a+1)) >> 8); //#define COLORALPHABLEND_FLOAT #define COLORALPHABLEND_INTEGERS diff --git a/src/utils.c b/src/utils.c index 37b89a9ac..b922c8907 100644 --- a/src/utils.c +++ b/src/utils.c @@ -148,6 +148,7 @@ void TraceLog(int logType, const char *text, ...) strcat(buffer, text); strcat(buffer, "\n"); vprintf(buffer, args); + fflush(stdout); #endif va_end(args); @@ -268,6 +269,51 @@ bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite) return success; } +// Export data to code (.h), returns true on success +bool ExportDataAsCode(const char *data, unsigned int size, const char *fileName) +{ + bool success = false; + +#ifndef TEXT_BYTES_PER_LINE + #define TEXT_BYTES_PER_LINE 20 +#endif + + // NOTE: Text data buffer size is estimated considering raw data size in bytes + // and requiring 6 char bytes for every byte: "0x00, " + char *txtData = (char *)RL_CALLOC(size*6 + 2000, sizeof(char)); + + int byteCount = 0; + byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// DataAsCode exporter v1.0 - Raw data exported as an array of bytes //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); + byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2022 Ramon Santamaria (@raysan5) //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n"); + + // Get file name from path and convert variable name to uppercase + char varFileName[256] = { 0 }; + strcpy(varFileName, GetFileNameWithoutExt(fileName)); + for (int i = 0; varFileName[i] != '\0'; i++) if ((varFileName[i] >= 'a') && (varFileName[i] <= 'z')) { varFileName[i] = varFileName[i] - 32; } + + byteCount += sprintf(txtData + byteCount, "static unsigned char %s_DATA[%i] = { ", varFileName, size); + for (unsigned int i = 0; i < size - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), data[i]); + byteCount += sprintf(txtData + byteCount, "0x%x };\n", data[size - 1]); + + // NOTE: Text data size exported is determined by '\0' (NULL) character + success = SaveFileText(fileName, txtData); + + RL_FREE(txtData); + + if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Data as code exported successfully", fileName); + else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export data as code", fileName); + + return success; +} + // Load text data from file, returns a '\0' terminated string // NOTE: text chars array should be freed manually char *LoadFileText(const char *fileName)