Merge branch 'raysan5:master' into master
This commit is contained in:
commit
b701ad2a94
2
.github/workflows/android.yml
vendored
2
.github/workflows/android.yml
vendored
|
|
@ -67,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
|
||||
|
|
|
|||
2
.github/workflows/linux.yml
vendored
2
.github/workflows/linux.yml
vendored
|
|
@ -87,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
|
||||
|
|
|
|||
2
.github/workflows/macos.yml
vendored
2
.github/workflows/macos.yml
vendored
|
|
@ -72,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
|
||||
|
|
|
|||
2
.github/workflows/webassembly.yml
vendored
2
.github/workflows/webassembly.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
2
.github/workflows/windows.yml
vendored
2
.github/workflows/windows.yml
vendored
|
|
@ -109,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
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ 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 |
|
||||
|
|
@ -53,6 +53,7 @@ Some people ported raylib to other languages in form of bindings or wrappers to
|
|||
| 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.
|
||||
|
|
@ -103,7 +104,6 @@ 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 |
|
||||
|
|
|
|||
171
CHANGELOG
171
CHANGELOG
|
|
@ -3,11 +3,180 @@ changelog
|
|||
|
||||
Current Release: raylib 4.0.0 (05 November 2021)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
Release: raylib 4.2 (June 2022)
|
||||
-------------------------------------------------------------------------
|
||||
KEY CHANGES:
|
||||
- ...
|
||||
- rres 1.0
|
||||
- raygui 3.2
|
||||
- raylib_parser...
|
||||
|
||||
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] `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: 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: OpenURL()
|
||||
[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
|
||||
[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
|
||||
[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)
|
||||
[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()
|
||||
[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
|
||||
[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
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ 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
|
||||
|
||||
|
|
@ -337,8 +337,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
|
||||
|
|
@ -528,20 +526,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)
|
||||
|
|
@ -550,7 +540,6 @@ text: $(TEXT)
|
|||
models: $(MODELS)
|
||||
shaders: $(SHADERS)
|
||||
audio: $(AUDIO)
|
||||
physics: $(PHYSICS)
|
||||
|
||||
# Generic compilation pattern
|
||||
# NOTE: Examples must be ready for Android compilation!
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ ifeq ($(PLATFORM),PLATFORM_DRM)
|
|||
endif
|
||||
|
||||
# Define include paths for required headers
|
||||
# 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
|
||||
|
||||
# Define additional directories containing required header files
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -138,7 +138,6 @@ Examples using raylib models functionality, including models loading/generation
|
|||
| 82 | [models_yaw_pitch_roll](models/models_yaw_pitch_roll.c) | <img src="models/models_yaw_pitch_roll.png" alt="models_yaw_pitch_roll" width="200"> | [Berni](https://github.com/Berni8k) | ⭐️ |
|
||||
| 83 | [models_heightmap](models/models_heightmap.c) | <img src="models/models_heightmap.png" alt="models_heightmap" width="200"> | ray | |
|
||||
| 84 | [models_waving_cubes](models/models_waving_cubes.c) | <img src="models/models_waving_cubes.png" alt="models_waving_cubes" width="200"> | [codecat](https://github.com/codecat) | |
|
||||
| -- | [models_gltf_model](models/models_gltf_model.c) | <img src="models/models_gltf_model.png" alt="models_gltf_model" width="200"> | [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) | <img src="audio/audio_sound_loading.png" alt="audio_sound_loading" width="200"> | ray | |
|
||||
| 106 | [audio_multichannel_sound](audio/audio_multichannel_sound.c) | <img src="audio/audio_multichannel_sound.png" alt="audio_multichannel_sound" width="200"> | [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) | <img src="physics/physics_demo.png" alt="physics_demo" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
||||
| 108 | [physics_friction](physics/physics_friction.c) | <img src="physics/physics_friction.png" alt="physics_friction" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
||||
| 109 | [physics_movement](physics/physics_movement.c) | <img src="physics/physics_movement.png" alt="physics_movement" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
||||
| 110 | [physics_restitution](physics/physics_restitution.c) | <img src="physics/physics_restitution.png" alt="physics_restitution" width="200"> | [Victor Fisac](https://github.com/victorfisac) | |
|
||||
| 111 | [physics_shatter](physics/physics_shatter.c) | <img src="physics/physics_shatter.png" alt="physics_shatter" width="200"> | [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.
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ int main(void)
|
|||
//----------------------------------------------------------------------------------
|
||||
if (IsFileDropped())
|
||||
{
|
||||
droppedFiles = GetDroppedFiles(&count);
|
||||
droppedFiles = LoadDroppedFiles(&count);
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ int main(void)
|
|||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
ClearDroppedFiles(); // Clear internal buffers
|
||||
UnloadDroppedFiles(); // Clear internal buffers
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ int main(void)
|
|||
if (IsFileDropped())
|
||||
{
|
||||
int count = 0;
|
||||
char **droppedFiles = GetDroppedFiles(&count);
|
||||
char **droppedFiles = LoadDroppedFiles(&count);
|
||||
|
||||
if (count == 1) // Only support one file dropped
|
||||
{
|
||||
|
|
@ -95,7 +95,7 @@ int main(void)
|
|||
}
|
||||
}
|
||||
|
||||
ClearDroppedFiles(); // Clear internal buffers
|
||||
UnloadDroppedFiles(); // Clear internal buffers
|
||||
}
|
||||
|
||||
// Select model on mouse click
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ int main(void)
|
|||
if (IsFileDropped())
|
||||
{
|
||||
int count = 0;
|
||||
char **droppedFiles = GetDroppedFiles(&count);
|
||||
char **droppedFiles = LoadDroppedFiles(&count);
|
||||
|
||||
if (count == 1) // Only support one file dropped
|
||||
{
|
||||
|
|
@ -125,7 +125,7 @@ int main(void)
|
|||
}
|
||||
}
|
||||
|
||||
ClearDroppedFiles(); // Clear internal buffers
|
||||
UnloadDroppedFiles(); // Clear internal buffers
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
|
|
@ -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;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB |
|
|
@ -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;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
|
|
@ -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;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
|
|
@ -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;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
File diff suppressed because it is too large
Load Diff
|
|
@ -14,7 +14,7 @@
|
|||
#include <raylib.h>
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#include "extras/raygui.h" // Required for GUI controls
|
||||
#include "raygui.h" // Required for GUI controls
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#include <raylib.h>
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#include "extras/raygui.h" // Required for GUI controls
|
||||
#include "raygui.h" // Required for GUI controls
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#include <raylib.h>
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#include "extras/raygui.h" // Required for GUI controls
|
||||
#include "raygui.h" // Required for GUI controls
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -142,7 +142,7 @@ int main(void)
|
|||
if (IsFileDropped())
|
||||
{
|
||||
int count = 0;
|
||||
char **droppedFiles = GetDroppedFiles(&count);
|
||||
char **droppedFiles = LoadDroppedFiles(&count);
|
||||
|
||||
// NOTE: We only support first ttf file dropped
|
||||
if (IsFileExtension(droppedFiles[0], ".ttf"))
|
||||
|
|
@ -156,7 +156,7 @@ int main(void)
|
|||
font = LoadFont(droppedFiles[0]);
|
||||
fontSize = font.baseSize;
|
||||
}
|
||||
ClearDroppedFiles();
|
||||
UnloadDroppedFiles();
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
|
|
|||
|
|
@ -80,14 +80,14 @@ int main(void)
|
|||
if (IsFileDropped())
|
||||
{
|
||||
int count = 0;
|
||||
char **droppedFiles = GetDroppedFiles(&count);
|
||||
char **droppedFiles = LoadDroppedFiles(&count);
|
||||
|
||||
// NOTE: We only support first ttf file dropped
|
||||
if (IsFileExtension(droppedFiles[0], ".ttf"))
|
||||
{
|
||||
UnloadFont(font);
|
||||
font = LoadFontEx(droppedFiles[0], (int)fontSize, 0, 0);
|
||||
ClearDroppedFiles();
|
||||
UnloadDroppedFiles();
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
@ -123,7 +123,7 @@ int main(void)
|
|||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
ClearDroppedFiles(); // Clear internal buffers
|
||||
UnloadDroppedFiles(); // Clear internal buffers
|
||||
|
||||
UnloadFont(font); // Font unloading
|
||||
|
||||
|
|
|
|||
|
|
@ -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 -t "PHYSAC IMPLEMENTATION"
|
||||
./raylib_parser -i ../src/extras/raygui.h -o raygui_api.$(EXTENSION) -f $(FORMAT) -d RAYGUIAPI -t "RAYGUI IMPLEMENTATION"
|
||||
./raylib_parser -i ../src/extras/rmem.h -o rmem_api.$(EXTENSION) -f $(FORMAT) -d RMEMAPI -t "RMEM IMPLEMENTATION"
|
||||
./raylib_parser -i ../src/rlgl.h -o rlgl_api.$(EXTENSION) -f $(FORMAT) -d RLAPI -t "RLGL IMPLEMENTATION"
|
||||
./raylib_parser -i ../src/extras/easings.h -o easings_api.$(EXTENSION) -f $(FORMAT) -d EASEDEF
|
||||
./raylib_parser -i ../src/extras/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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -82,8 +82,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
|
||||
|
|
|
|||
1987
src/extras/physac.h
1987
src/extras/physac.h
File diff suppressed because it is too large
Load Diff
18
src/raylib.h
18
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 <stdarg.h> // 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
|
||||
|
|
@ -843,7 +843,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;
|
||||
|
||||
|
|
@ -958,7 +958,7 @@ RLAPI void DisableEventWaiting(void); // Disable wai
|
|||
// 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
|
||||
|
|
@ -1008,9 +1008,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)
|
||||
|
|
@ -1057,12 +1057,12 @@ 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 must 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 char **LoadDirectoryFiles(const char *dirPath, int *count); // Load directory filepaths
|
||||
RLAPI void UnloadDirectoryFiles(void); // Unload directory filepaths
|
||||
RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window
|
||||
RLAPI char **GetDroppedFiles(int *count); // Get dropped files names (memory must be freed)
|
||||
RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer (free memory)
|
||||
RLAPI char **LoadDroppedFiles(int *count); // Load dropped filepaths
|
||||
RLAPI void UnloadDroppedFiles(void); // Unload dropped filepaths
|
||||
RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time)
|
||||
|
||||
// Compression/Encoding functionality
|
||||
|
|
|
|||
93
src/rcore.c
93
src/rcore.c
|
|
@ -194,9 +194,9 @@
|
|||
#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 <dirent.h> // Required for: DIR, opendir(), closedir() [Used in GetDirectoryFiles()]
|
||||
#include <dirent.h> // Required for: DIR, opendir(), closedir() [Used in LoadDirectoryFiles()]
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
|
@ -422,7 +422,7 @@ 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
|
||||
char **dropFilepaths; // Store dropped files paths as strings
|
||||
int dropFileCount; // Count dropped files strings
|
||||
|
||||
} Window;
|
||||
|
|
@ -2087,8 +2087,8 @@ void EndDrawing(void)
|
|||
// Get image data for the current frame (from backbuffer)
|
||||
// NOTE: This process is quite slow... :(
|
||||
Vector2 scale = GetWindowScaleDPI();
|
||||
unsigned char *screenData = rlReadScreenPixels(CORE.Window.render.width*scale.x, CORE.Window.render.height*scale.y);
|
||||
msf_gif_frame(&gifState, screenData, 10, 16, CORE.Window.render.width*scale.x*4);
|
||||
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
|
||||
}
|
||||
|
|
@ -2146,7 +2146,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;
|
||||
|
|
@ -2811,8 +2811,8 @@ void TakeScreenshot(const char *fileName)
|
|||
{
|
||||
#if defined(SUPPORT_MODULE_RTEXTURES)
|
||||
Vector2 scale = GetWindowScaleDPI();
|
||||
unsigned char *imgData = rlReadScreenPixels(CORE.Window.render.width*scale.x, CORE.Window.render.height*scale.y);
|
||||
Image image = { imgData, CORE.Window.render.width*scale.x, CORE.Window.render.height*scale.y, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
|
||||
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));
|
||||
|
|
@ -3146,11 +3146,11 @@ const char *GetApplicationDirectory(void)
|
|||
return appDir;
|
||||
}
|
||||
|
||||
// Get filenames in a directory path
|
||||
// Load directory filepaths
|
||||
// NOTE: Files count is returned by parameters pointer
|
||||
char **GetDirectoryFiles(const char *dirPath, int *fileCount)
|
||||
char **LoadDirectoryFiles(const char *dirPath, int *fileCount)
|
||||
{
|
||||
ClearDirectoryFiles();
|
||||
UnloadDirectoryFiles();
|
||||
|
||||
int counter = 0;
|
||||
struct dirent *entity;
|
||||
|
|
@ -3181,8 +3181,8 @@ char **GetDirectoryFiles(const char *dirPath, int *fileCount)
|
|||
return dirFilesPath;
|
||||
}
|
||||
|
||||
// Clear directory files paths buffers
|
||||
void ClearDirectoryFiles(void)
|
||||
// Unload directory filepaths
|
||||
void UnloadDirectoryFiles(void)
|
||||
{
|
||||
if (dirFileCount > 0)
|
||||
{
|
||||
|
|
@ -3211,21 +3211,21 @@ bool IsFileDropped(void)
|
|||
else return false;
|
||||
}
|
||||
|
||||
// Get dropped files names
|
||||
char **GetDroppedFiles(int *count)
|
||||
// Load dropped filepaths
|
||||
char **LoadDroppedFiles(int *count)
|
||||
{
|
||||
*count = CORE.Window.dropFileCount;
|
||||
return CORE.Window.dropFilesPath;
|
||||
return CORE.Window.dropFilepaths;
|
||||
}
|
||||
|
||||
// Clear dropped files paths buffer
|
||||
void ClearDroppedFiles(void)
|
||||
// Unload dropped filepaths
|
||||
void UnloadDroppedFiles(void)
|
||||
{
|
||||
if (CORE.Window.dropFileCount > 0)
|
||||
{
|
||||
for (int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilesPath[i]);
|
||||
for (int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilepaths[i]);
|
||||
|
||||
RL_FREE(CORE.Window.dropFilesPath);
|
||||
RL_FREE(CORE.Window.dropFilepaths);
|
||||
|
||||
CORE.Window.dropFileCount = 0;
|
||||
}
|
||||
|
|
@ -4872,49 +4872,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(__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
|
||||
}
|
||||
|
|
@ -5537,7 +5534,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
|||
gifFrameCounter = 0;
|
||||
|
||||
Vector2 scale = GetWindowScaleDPI();
|
||||
msf_gif_begin(&gifState, CORE.Window.render.width*scale.x, CORE.Window.render.height*scale.y);
|
||||
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));
|
||||
|
|
@ -5674,14 +5671,14 @@ static void CursorEnterCallback(GLFWwindow *window, int enter)
|
|||
// Everytime new files are dropped, old ones are discarded
|
||||
static void WindowDropCallback(GLFWwindow *window, int count, const char **paths)
|
||||
{
|
||||
ClearDroppedFiles();
|
||||
UnloadDroppedFiles();
|
||||
|
||||
CORE.Window.dropFilesPath = (char **)RL_MALLOC(count*sizeof(char *));
|
||||
CORE.Window.dropFilepaths = (char **)RL_MALLOC(count*sizeof(char *));
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
CORE.Window.dropFilesPath[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char));
|
||||
strcpy(CORE.Window.dropFilesPath[i], paths[i]);
|
||||
CORE.Window.dropFilepaths[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char));
|
||||
strcpy(CORE.Window.dropFilepaths[i], paths[i]);
|
||||
}
|
||||
|
||||
CORE.Window.dropFileCount = count;
|
||||
|
|
@ -6314,12 +6311,13 @@ 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;
|
||||
|
||||
// Grab number on the end of the devices name "event<N>"
|
||||
// TODO: Grab number on the end of the device name "mouse<N>"
|
||||
int devNum = 0;
|
||||
char *ptrDevName = strrchr(device, 't');
|
||||
worker->eventNum = -1;
|
||||
|
|
@ -6328,6 +6326,7 @@ static void ConfigureEvdevDevice(char *device)
|
|||
{
|
||||
if (sscanf(ptrDevName, "t%d", &devNum) == 1) worker->eventNum = devNum;
|
||||
}
|
||||
else worker->eventNum = 0; // HACK 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...
|
||||
|
|
@ -6706,7 +6705,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);
|
||||
|
|
@ -6794,7 +6793,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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -1783,7 +1783,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()
|
||||
|
|
|
|||
|
|
@ -4844,7 +4844,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);
|
||||
}
|
||||
|
|
@ -4858,7 +4858,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);
|
||||
}
|
||||
|
|
@ -4893,7 +4893,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);
|
||||
|
||||
|
|
@ -4905,7 +4905,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
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ bool ExportDataAsCode(const char *data, unsigned int size, const char *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 (int i = 0; i < size - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), data[i]);
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user