1018 Commits

Author SHA1 Message Date
101502103a Fixed FLAG_IS_SET to check if all bits in the flag are set in the value (#5441) 2025-12-24 20:58:40 +01:00
Ray
20dd4641c8 REVIEWED: Potential security concerns while copying unbounded text data between strings
Note that issue has been reported by CodeQL static analysis system
2025-12-24 19:35:06 +01:00
Ray
fc843dc557 Create SECURITY.md 2025-12-24 19:21:43 +01:00
Ray
9103f6e055 ADDED: New platform backend for Web: Emscripten, not dependant on GLFW.js -WIP- 2025-12-24 18:58:20 +01:00
Ray
ced84333a9 Update rl_gputex.h 2025-12-24 18:02:24 +01:00
Ray
05f42aa119 Update core_highdpi_testbed.c 2025-12-24 18:02:04 +01:00
a1e84caa8c RGFW also requires RGBA8 images as window icons, as raylib already reports in raylib.h (#5431) 2025-12-24 09:04:41 +01:00
ddb827fb6f Fixed LoadCodepoints declaring a new local variable shadowing codpoints (#5430) 2025-12-24 08:59:51 +01:00
0a4583ca54 [rl_gputex.h] Possibly fixed the swizzling in rl_load_dds_from_memory() function (#5422)
* Possibly fixed the swizzling bug

* Removed examples, and generation.
2025-12-23 17:10:55 +01:00
6a701b2679 fix android SetWindowState (#5424) 2025-12-23 15:37:08 +01:00
Ray
aa2884bd78 Update rcore_desktop_glfw.c 2025-12-22 22:50:38 +01:00
Ray
f27f2d097f REVIEWED: HighDPI support on macOS (when requested by app)
Tested on two monitors with different DPI configuration, for HigDPI enabled and not, including window resizing (with framebuffer resizing if required). Verified mouse coordinates follow the requested screen size.
2025-12-22 22:48:08 +01:00
Ray
e4baf682ab Update rtext.c 2025-12-22 20:30:11 +01:00
Ray
8516750975 Remove internal function 2025-12-22 20:29:57 +01:00
3212becc91 Update BINDINGS.md (#5421) 2025-12-21 20:15:38 +01:00
Ray
b9446863d7 REXM: RENAMED: core_high_dpi --> core_highdpi_demo 2025-12-20 22:36:44 +01:00
Ray
13f9112d8c Update rcore_desktop_sdl.c 2025-12-19 01:16:34 +01:00
Ray
f16fb065ea Update rcore_template.c 2025-12-19 01:15:34 +01:00
Ray
66392fe0ae REVIEWED: rlGetPixelDataSize(), correct compressed data size calculation per blocks #5416 2025-12-19 00:06:44 +01:00
Ray
720dd22491 REVIEWED: rlLoadTexture(), un complete texture do to issue on mipmap loading #5416 2025-12-18 17:04:58 +01:00
Ray
ca578b8b08 Update raylib.sln 2025-12-18 17:03:53 +01:00
Ray
4b760091da REVIEWED: Window scaling with HighDPI on macOS #5059 2025-12-17 21:23:25 +01:00
Ray
6d562e5e87 REVIEWED: HiggDPI content scaling on changing monitors with different DPI #5335 #5356
Note that high-dpi awareness must be enabled by users and `CORE.Window.render` reports the scaled framebuffer size, while `CORE.Window.screen` reports the logical size.

`ToggleBorderlessWindow()` has also been reviewed to be consistent with scaling, if monitor physical display size is reported as 1920x1080 but there is a content scale of 1.5, then the borderless fullscreen window will be 1280x720, with the 1920x1080 framebuffer
2025-12-17 19:20:18 +01:00
Ray
7553e9d586 REVIEWED: Gamepads on latest SDL2 2.32.8 and SDL3 3.3.6 #5403 2025-12-16 19:36:01 +01:00
Ray
80ad96acc2 Fix #5413 2025-12-16 18:33:07 +01:00
Ray
7a5e8aa3a5 Update rcore_android.c 2025-12-16 18:30:33 +01:00
1c94e94873 [rcore] Implement FLAG_WINDOW_ALWAYS_RUN on Android (#5414) 2025-12-16 18:26:20 +01:00
33adda1983 fixed build errors with zig. now compatible with zig master 0.16.0-dev.1593+c13857e50. still backwards compatible with 0.15.1 (#5415) 2025-12-16 18:24:53 +01:00
Ray
f031b2f4f4 Alignment with other platform backends, avoid unneeded includes 2025-12-16 18:20:02 +01:00
Ray
1c7240a01d Revert "REVIEWED: Alignment with other platforms"
This reverts commit cf0d6fc664.
2025-12-16 18:18:42 +01:00
Ray
cf0d6fc664 REVIEWED: Alignment with other platforms 2025-12-15 20:44:28 +01:00
Ray
615fc36eeb Fix #5406 2025-12-15 18:56:14 +01:00
Ray
cbe31759ab Fix #5405 2025-12-15 18:52:27 +01:00
d74556d35c Modify text_words_alignment.c (#5411) 2025-12-15 18:49:40 +01:00
8d246fdaff Fix EXTERNAL_CONFIG_FLAGS being defined even when no custom config is used when building with zig (#5410) 2025-12-15 00:03:31 +01:00
Ray
a0fd5ab1d9 Update rmodels.c 2025-12-14 19:59:12 +01:00
Ray
9a337f3b3b ADDED: Support software renderer on Web, blitting framebuffer data directly to a 2d canvas
This improvement is just a prove of concept, at this moment `PLATFORM_WEB` is limited in terms of software rendering by `GLFW` that only allows creating a WebGL canvas context with `glfwCreateWindow()`.

We can skip that call but then some GLFW functionality is not available (windowing, inputs). The best solution is replacing GLFW completely by a pure Emscripten implementation for `PLATFORM_WEB`.
2025-12-14 19:52:18 +01:00
Ray
5025009860 REVIEWED: Make sure all variables are initialized on definition, prioritize one line per variable definitions 2025-12-14 19:45:28 +01:00
6f5cabf60c Fix misleading example text. (#5409) 2025-12-14 17:43:54 +01:00
Ray
c96669e123 REVIEWED: Webpage reference comments starting with REF:, more consistent with TODO: and NOTE: comments 2025-12-13 13:03:41 +01:00
Ray
9c04b1de82 REVIEWED: Store canvas name id at platform initialization
Useful to support multiple canvases running different wasm instances in same webpage
2025-12-13 11:58:04 +01:00
Ray
b465b4e2ea RENAMED: Variable names for consistency, textLength (length in bytes) vs textSize (measure in pixels) 2025-12-11 21:41:25 +01:00
Ray
2853b28d6d REVIEWED: Avoid program crash if GPU data is tried to be loaded before InitWindow() #4751
Following raylib design, a warning log message is shown and program can continue execution.
Some early return checks have been added on most  critical functions.
[rtext] Previous implementation checking `isGpuReady` cross-module variable is not needed any more, resulting in a more decoupled code, load failure is managed at rlgl level
2025-12-11 18:21:57 +01:00
8fa5f1fe2c [examples] Fixed shaders_game_of_life for web (#5399)
* [examples] Fixed `shaders_game_of_life` for web

* Fixed image loadig for rexm
2025-12-11 13:38:08 +01:00
6f7cd3a9ab [core] Camera2d comment updates (#5401)
* Make the comments on the camera 2d fields more clear about what space each one is in.

* rlparser: update raylib_api.* by CI

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-12-11 13:37:17 +01:00
ae438e804e rlparser: update raylib_api.* by CI 2025-12-11 12:00:15 +00:00
Ray
2a566544d4 ADDED: Multiply security checks to avoid crashes on wrongly provided string data #4751
- REVIEWED: Checking `NULL` input on functions getting `const char *text`, to avoid crashes
- REVIEWED: `strcpy()` usage, prioritize `strncpy()` with limited copy to buffer size
- REPLACED: `strlen()` by `TextLength()` on [rtext] module
- REVIEWED: Replaced some early returns (but keeping others, for easier code following)
2025-12-11 12:59:55 +01:00
Ray
71a35f661e Update rexm.c 2025-12-11 12:33:05 +01:00
Ray
2d8e346945 Update update_examples.yml 2025-12-10 19:14:28 +01:00
Ray
f3f02b3e17 REXM: examples validation and update 2025-12-10 19:06:41 +01:00
Ray
dad93abcf8 REXM: Ignore some warnings on GCC/Clang 2025-12-10 18:49:52 +01:00
Ray
5e8118daf2 Update shaders_game_of_life.c 2025-12-10 09:46:06 +01:00
Ray
bc2057345b REVIEWED: GetRandomValue(), explained the new approach to get more uniform random values range 2025-12-10 09:30:18 +01:00
f2a900a60d [rcore] Fix modulo bias in GetRandomValue() (#5392)
* Fix modulo bias in GetRandomValue(); implement rejection sampling for uniformity

* Replace do-while with for-loop in GetRandomValue rejection sampling
2025-12-10 09:23:40 +01:00
Ray
3adfde42f7 REVIEWED: rlLoadTeexture(), max mipmap levels to use #5400 2025-12-10 09:21:33 +01:00
Ray
91ac3cc707 FIX: LoadRandomSequence(), using GetRandomValue() #5393 2025-12-09 20:02:38 +01:00
Ray
19a1683641 REXM: Updated examples 2025-12-09 19:25:08 +01:00
be6007be93 fix: sha1 computation on messages longer than 31 bytes (#5397) 2025-12-09 19:18:43 +01:00
efeccfef61 [examples] Add textures_cellular_automata (#5395)
* [examples] Add `textures_cellular_automata`

* Comparison always true. Fixed

* Tabs to spaces
2025-12-09 19:14:16 +01:00
366300aafe [examples] Add shaders_game_of_life (#5394)
* [examples] Add `shaders_game_of_life`

* Declaration hides another variable same name
2025-12-09 19:13:05 +01:00
215ad78d5b Fix build.zig typos (#5390)
* fix small typo

* other small typos
2025-12-09 19:10:22 +01:00
Ray
8115b7e922 Update rmodels.c 2025-12-06 20:40:23 +01:00
fd8830948e fix newer NDK version compiling errors (#5389)
target already gets assigned by the clang macro it points to, overwriting it causes it to target linux instead of android, making it check for usr directories instead of the NDK's directories
2025-12-06 20:01:47 +01:00
Ray
f9899a7182 Reviewed code formating 2025-12-06 20:00:19 +01:00
561cc27403 [rModels] Support 16 bit vec3 values in gltf reader (#5388)
* Support 16 bit vec3 values coming from gltf

* Add support for 8 bit normals
2025-12-06 19:50:59 +01:00
983efae3e4 Expose RGFW to cmake (#5386)
i was wondering why that was missing
2025-12-03 22:55:54 +01:00
95c4efd7a3 Update comment on shapes_penrose_tile.c (#5384) 2025-12-03 16:56:41 +01:00
Ray
68befcc64f Update shapes_penrose_tile.c 2025-12-03 10:00:09 +01:00
b1f8cde329 [examples] Added: text_strings_management (#5379)
* new shapes example - penrose tile

* stack cleanup

* proper use of strnlen, strncat and strncpy

* typo correction

* update screenshot of shapes_penrose_tile example

* new example for strings management

* Improved structure for text_strings_management
2025-12-03 09:44:18 +01:00
Aly
78a81bf407 Fix ToggleBorderlessFullscreen() Not Hiding Taskbar (#5383)
* Use glfwSetWindowMonitor instead of Pos and Size GLFW functions

* Fix window not resetting properly when toggling out of fullscreen, formatting
2025-12-02 22:55:22 +01:00
944567651c replace sprintf with snprintf (#5382) 2025-12-02 22:49:55 +01:00
1bbc8682f4 Fixed some typos and mispellings (#5381)
Specifically "occured" -> "occurred"
2025-12-02 22:48:06 +01:00
Ray
ed5da45203 Update LICENSE.md #5380 2025-12-02 22:46:12 +01:00
Ray
d3addad9a7 REVIEWED: example: shapes_penrose_tile formating 2025-12-02 22:34:48 +01:00
Ray
d13314fe1c Update core_window_flags.c 2025-12-02 22:21:41 +01:00
3ba186f2c1 [examples] Added: shapes_penrose_tile (#5376)
* new shapes example - penrose tile

* stack cleanup

* proper use of strnlen, strncat and strncpy

* typo correction

* update screenshot of shapes_penrose_tile example
2025-12-01 12:57:45 +01:00
4d9df337a7 rlparser: update raylib_api.* by CI 2025-11-30 18:02:52 +00:00
Ray
4724f7cf1b REVIEWED: Comments for UpdateSound() specifying expected data format #5350 2025-11-30 19:02:38 +01:00
Ray
a568506265 REVIEWED: External libraries sdefl and sinfl to address #5367 2025-11-30 18:32:11 +01:00
6a048b7afe corrected visualstudio project (#5375) 2025-11-29 23:22:38 +01:00
Ray
ebce9fa97a Update rcore_memory.c 2025-11-29 20:01:44 +01:00
Ray
78661a4ee0 REXM: ADDED: shapes_ball_physics 2025-11-29 18:23:17 +01:00
Ray
18e1ec504f Updated example 2025-11-29 18:20:06 +01:00
9f567e6ee4 Example for creating balls with simple physics simulation (#5372)
* Example for creating balls with simple physics simulation

The goal of this example is to create several colored balls whose movement is simulated and which respond to the action of being grabbed and dragged using the mouse.

* renaming example

renaming example from physics_bouncing_balls to shapes_ball_physics
2025-11-29 18:11:15 +01:00
e273aaea1e [examples] text_inline_styling: make inline text and background colors respect base alpha (#5373)
* Added source alpha multiplier for text inline styling examples

* Added header description about base alpha multiplier
2025-11-29 18:10:15 +01:00
1ac1309b24 feat: add elle bindings (#5370) 2025-11-27 15:19:22 +01:00
Ray
c991f9e89f Merge branch 'master' of https://github.com/raysan5/raylib 2025-11-25 19:13:12 +01:00
Ray
8f3cabcf76 Update rcore.c 2025-11-25 19:13:08 +01:00
2b051afb29 [examples] shapes_kaleidoscope rewind, forward & reset buttons (#5369)
* [examples] rewind and forward lines drawing

* [examples] reset button

* [examples] update screenshot

* [examples] applied raylib convention
2025-11-25 19:10:56 +01:00
Ray
3d9129e3b4 Update rexm.rc 2025-11-25 12:15:23 +01:00
Ray
80ed6eadb8 REXM: RENAME: audio_fft_spectrum_visualizer -> audio_spectrum_visualizer 2025-11-25 12:15:14 +01:00
Ray
a7ce14ee95 Merge branch 'master' of https://github.com/raysan5/raylib 2025-11-24 15:39:08 +01:00
Ray
47a8b554bc **NEW**: PLATFORM_MEMORY backend
New platform backend for software rendering directly on RAM memory buffer
2025-11-24 15:38:58 +01:00
fc8049a039 rlparser: update raylib_api.* by CI 2025-11-24 14:37:49 +00:00
Ray
bd36610f91 Some formatting 2025-11-24 15:37:28 +01:00
Ray
7e3d6cbfa8 Update rcore.c 2025-11-23 23:16:32 +01:00
Ray
17dc2bb474 Update rcore.c 2025-11-23 22:58:15 +01:00
Ray
aaa893f668 Update rcore.c 2025-11-23 22:58:10 +01:00
Ray
e1b9857b14 Some TODOs and format reviews 2025-11-23 21:40:39 +01:00
Ray
cf5e84c3c4 Update models_skybox_rendering.c 2025-11-23 21:37:35 +01:00
Ray
f1719480e0 Minor format tweaks 2025-11-23 13:21:31 +01:00
Ray
84737a9fc1 Update CONVENTIONS.md 2025-11-22 20:25:42 +01:00
Ray
727a90c5d1 REVIEWED: Formatting to follow raylib conventions 2025-11-22 20:16:33 +01:00
Ray
6c3ef8d9b4 Remove trailing spaces 2025-11-22 20:15:50 +01:00
Ray
97707d7a6b Merge branch 'master' of https://github.com/raysan5/raylib 2025-11-22 20:15:03 +01:00
Ray
12cce1766f Update textures_screen_buffer.c 2025-11-22 20:14:41 +01:00
Ray
dddc94dc7a Update examples_testing_web.md 2025-11-22 20:14:29 +01:00
Ray
c22b1d84d5 Merge branch 'master' of https://github.com/raysan5/raylib 2025-11-20 21:33:51 +01:00
Ray
6820ff61f1 REVIEWED: example: shaders_hybrid_rendering, shaders issues 2025-11-20 21:33:43 +01:00
4ad9e09bb2 Ran rexm testing for macos (#5366) 2025-11-20 21:10:47 +01:00
90af210712 include malloc.h so the win32 platform can build in MSVC (#5365) 2025-11-20 08:00:23 +01:00
Ray
0747e9b5c1 Create examples_testing_drm.md 2025-11-20 01:00:02 +01:00
Ray
c6f4c8e3e0 FIX: Issue on PLATFORM_DRM 2025-11-20 00:59:43 +01:00
Ray
c0179288ba REXM: TEST: Support testing running on PLATFORM_DRM 2025-11-20 00:59:28 +01:00
8161475c28 rlparser: update raylib_api.* by CI 2025-11-19 23:03:27 +00:00
Ray
30cd36a8a9 Update audio_music_stream.c 2025-11-20 00:03:08 +01:00
Ray
ba65bd7f99 WARNING: BREAKING: Redesigned SetSoundPan() and SetMusicPan() #5350
Now it goes from -1.0 (full left) to 1.0 (full right) being 0.0 center
2025-11-20 00:03:03 +01:00
Ray
67f24b3b41 Update audio_sound_positioning.c 2025-11-20 00:01:06 +01:00
Ray
29173a4978 Update .gitignore 2025-11-20 00:00:51 +01:00
Ray
49868b356f Update examples_testing_linux.md 2025-11-19 19:41:43 +01:00
Ray
8fcd99c8dd Update textures_sprite_stacking.c 2025-11-19 19:41:39 +01:00
Ray
646e814baf Update Makefile 2025-11-19 19:41:35 +01:00
Ray
5aee9f9d50 Create examples_testing_linux.md 2025-11-19 19:31:17 +01:00
Ray
282c4b0eab Minor teaks to run on Linux 2025-11-19 19:30:25 +01:00
Ray
1f7f9ab22b Ignore examples binaries on Linux (and automated logs) 2025-11-19 19:30:07 +01:00
Ray
ee3d65cbc9 Update examples_testing_web.md 2025-11-19 13:25:54 +01:00
Ray
82ad486e6b Update rexm.c 2025-11-19 13:18:47 +01:00
Ray
d26435703f Update rcore_desktop_win32.c 2025-11-19 13:18:13 +01:00
Ray
0b9f463e64 REVIEWED: examples: Replace TABS and Remove trailing spaces 2025-11-19 13:18:10 +01:00
Ray
bd21d74914 Update examples_testing_web.md 2025-11-19 13:08:11 +01:00
Ray
4cef89cf04 Update rexm.c 2025-11-19 13:08:02 +01:00
Ray
63fb407dc5 Update raygui to avoid warnings 2025-11-19 13:07:57 +01:00
Ray
80e164fa04 Update core_monitor_detector.c 2025-11-19 13:07:45 +01:00
Ray
e1d5adb326 Update rexm.c 2025-11-19 12:43:44 +01:00
Ray
43bd2b1e18 REXM: Report issues if logs can not be loaded 2025-11-19 12:41:36 +01:00
Ray
313659d37d Update examples_testing_web.md 2025-11-19 12:40:59 +01:00
Ray
a6976b1930 Create examples_testing_web.md 2025-11-19 12:33:49 +01:00
Ray
39e39216f6 REXM: ADDED: TestLog option for logs processing (without rebuilding) 2025-11-19 12:31:15 +01:00
Ray
5fdf178969 REVIEWED: audio_fft_spectrum_visualizer, not working on web 2025-11-19 12:30:38 +01:00
Ray
e3738c1b17 REXM: UPDATE: Reviewed all examples requirements 2025-11-19 11:53:55 +01:00
Ray
d56371ce85 Update Makefile.Web 2025-11-19 11:41:50 +01:00
Ray
265fa7833c Update rtext.c 2025-11-19 10:21:16 +01:00
Ray
f21c1cc6ae Update rtext.c 2025-11-19 10:08:42 +01:00
Ray
ec828071ef Update rtext.c 2025-11-19 10:04:01 +01:00
Ray
33cee1146c REXM: REVIEWED: Automated testing for Web 2025-11-19 09:54:54 +01:00
Ray
8081d2bd07 REDESIGNED: example: shapes_kaleidoscope, store lines #5361
This redesign stores lines in Update and draws stored lines in Draw, instead of previous approach of drawing directly to framebuffer with no cleaning. This approach allows some interesting features like line draw replay or reversing.
2025-11-19 09:34:13 +01:00
Ray
2453977d59 Merge branch 'master' of https://github.com/raysan5/raylib 2025-11-19 09:13:02 +01:00
e2233acdb0 feat: Optimize ImageClearBackground and ImageDrawRectangleRec with doubling strategy (#5363) 2025-11-19 08:58:43 +01:00
3f92c396a0 Fixed typo (#5364) 2025-11-19 08:56:32 +01:00
Ray
d5e8ee77b1 Update core_input_gamepad.c 2025-11-18 21:32:20 +01:00
f51204821a Add vibration test button to core_input_gamepad (#5362) 2025-11-18 21:27:50 +01:00
Ray
a24e65d8e1 Update examples_testing_windows.md 2025-11-18 21:26:54 +01:00
Ray
f75682f5c9 Merge branch 'master' of https://github.com/raysan5/raylib 2025-11-18 21:26:33 +01:00
Ray
57e22d5fa0 Update rtext.c 2025-11-18 21:26:26 +01:00
Ray
1b6303b900 Update examples_testing_windows.md 2025-11-18 21:20:05 +01:00
Ray
83a167ca3f Update text_inline_styling.c 2025-11-18 21:19:55 +01:00
Ray
48496e2307 Update core_input_actions.c 2025-11-18 21:18:32 +01:00
Ray
e6ef99275a Update shapes_digital_clock.c 2025-11-18 21:14:48 +01:00
Ray
c7c6aaf156 Update examples_testing_windows.md 2025-11-18 21:12:25 +01:00
Ray
06958c91d0 Merge branch 'master' of https://github.com/raysan5/raylib 2025-11-18 20:59:55 +01:00
Ray
46ca641ec5 Update raygui to avoid warnings 2025-11-18 20:59:48 +01:00
Ray
f3393b8fd8 Update core_clipboard_text.c 2025-11-18 20:59:38 +01:00
Ray
8455f9d088 Update rexm.c 2025-11-18 20:59:33 +01:00
Ray
95d58ed988 Update examples_testing_windows.md 2025-11-18 20:52:05 +01:00
Ray
5da90172ac Update examples_testing_windows.md 2025-11-18 20:49:21 +01:00
Ray
6f4f4cc508 Update rexm.c 2025-11-18 20:44:23 +01:00
Ray
e062e3835e REVIEWED: examples: Several minor issues 2025-11-18 20:43:58 +01:00
Ray
dcc9e96148 Update rexm.c 2025-11-18 20:18:17 +01:00
Ray
6993bc7337 Update examples_testing_windows.md 2025-11-18 19:51:34 +01:00
Ray
a4a6812d68 REXM: REVIEWED: Testing report generation 2025-11-18 19:50:45 +01:00
Ray
9efe127f5d Update shapes_lines_drawing.c 2025-11-18 19:50:07 +01:00
4caba49658 [examples] Added: shapes_rlgl_color_wheel example (#5355)
* [examples] Added: `shapes_rlgl_triangle` example

* correct name

* formatting

* Revert "formatting"

This reverts commit f1d246a648.

* Revert "correct name"

This reverts commit 974985ed49.

* Revert "[examples] Added: `shapes_rlgl_triangle` example"

This reverts commit d053b9afa0.

* [examples] Added: `shapes_rlgl_color_wheel` example

* clarify color variable

* formatting

* formatting

* formatting

* formatting

* reduce redundancy

* moved color updating code to update
2025-11-18 16:31:43 +01:00
Ray
86e00bde65 Update rcore_desktop_sdl.c 2025-11-18 16:30:48 +01:00
Ray
95a8977e33 REXM: FIX: Web log redirect and download 2025-11-18 16:28:10 +01:00
Ray
f531ee2d8f Update rexm.c 2025-11-18 16:19:43 +01:00
b18f547d8f Update rcore_desktop_sdl.c, fix crash when strncpy tries to copy using NULL pointer (#5359)
When SDL_GameControllerNameForIndex returns null, the app crashes. This was addressed earlier in PR#4859 though the fix submitted on PR #4859 was only fixing the crashing and not addressing the root cause.
2025-11-18 16:19:07 +01:00
be9a24e68c Fix controller not available right after win init (#5358)
- Fix IsGamepadAvailable() returns false for an available controller immediately after window initialization
2025-11-18 16:17:58 +01:00
Ray
bbba3d0802 REXM: ADDED: Web platform logs automated reports -WIP- 2025-11-17 19:40:55 +01:00
Ray
cde917c63c REXM: ADDED: Build check warnings logs 2025-11-17 19:40:23 +01:00
Ray
a590126351 Updated some examples 2025-11-17 19:20:45 +01:00
Ray
063986fdae Updated solution 2025-11-17 19:20:23 +01:00
Ray
a235cd6a18 Update raygui.h 2025-11-17 19:20:12 +01:00
Ray
ab463ac89b Create raylib.vcxproj.filters 2025-11-17 09:39:59 +01:00
Ray
9fe3f7ca14 REXM: ADDED: Automated-testing system
Elements tested:
```
TESTING_FAIL_INIT      = 1 << 0,   // Initialization (InitWindow())    -> "INFO: DISPLAY: Device initialized successfully"
            TESTING_FAIL_CLOSE     = 1 << 1,   // Closing (CloseWindow())          -> "INFO: Window closed successfully"
            TESTING_FAIL_ASSETS    = 1 << 2,   // Assets loading (WARNING: FILE:)  -> "WARNING: FILEIO:"
            TESTING_FAIL_RLGL      = 1 << 3,   // OpenGL-wrapped initialization    -> "INFO: RLGL: Default OpenGL state initialized successfully"
            TESTING_FAIL_PLATFORM  = 1 << 4,   // Platform initialization          -> "INFO: PLATFORM: DESKTOP (GLFW - Win32): Initialized successfully"
            TESTING_FAIL_FONT      = 1 << 5,   // Font default initialization      -> "INFO: FONT: Default font loaded successfully (224 glyphs)"
            TESTING_FAIL_TIMER     = 1 << 6,   // Timer initialization             -> "INFO: TIMER: Target time per frame: 16.667 milliseconds"
```
2025-11-17 00:29:54 +01:00
Ray
d26b17f320 Some comment tweaks 2025-11-17 00:27:33 +01:00
Ray
6756e9d3d7 Update core_input_gestures_testbed.c 2025-11-17 00:16:47 +01:00
Ray
06589d3350 Update core_2d_camera_mouse_zoom.c 2025-11-17 00:14:08 +01:00
596d3bcb7e [examples] Added: textures_screen_buffer (#5357)
* Example textures_screen_buffer

* remove resource preload for web makefile

* update description

* code formatting
2025-11-16 19:40:49 +01:00
Ray
5c2747e3a8 Update shapes_rlgl_triangle.c 2025-11-16 19:13:01 +01:00
Ray
470a326588 Update shapes_rlgl_triangle.c 2025-11-15 16:47:11 +01:00
74f7112614 [examples] Added: shapes_rlgl_triangle example (#5353)
* [examples] Added: `shapes_rlgl_triangle` example

* correct name

* formatting
2025-11-14 17:09:30 +01:00
Ray
d29112fb1f Create examples_testing_windows.md 2025-11-14 16:36:00 +01:00
Ray
75ae4d347a REXM: RENAMED: Reports moved to reports directory 2025-11-14 16:34:56 +01:00
Ray
d06c820a44 Merge branch 'master' of https://github.com/raysan5/raylib 2025-11-13 23:19:39 +01:00
Ray
3e3453d54e REVIEWED: Bunnymark example new raybunny! #5344
As the license for previous bunny was not clear, it was replaced by a new custom bunny specifically created for this example with a CC0 license
2025-11-13 23:19:37 +01:00
4dca02daa5 first draft of audio fft spectrum visualizer (#5348) 2025-11-13 23:12:11 +01:00
c059ece2a4 [examples] Added: directional billboard (#5351)
* Added models directional billboard example

* add killbot texture

* various fixes and formatting tweaks

* corrected stdlib
2025-11-13 23:10:13 +01:00
Ray
b5caef1ffb REXM: ADDED: Example automated-testing -WIP- 2025-11-13 22:48:24 +01:00
Ray
6dcd4cd564 Update rexm.c 2025-11-13 20:37:59 +01:00
Ray
80b6b7fc2a Update core_input_gamepad.c 2025-11-13 20:37:35 +01:00
Ray
d172a24bb0 REVIEWED: main(void) 2025-11-13 20:37:21 +01:00
Ray
9c73b0eb37 Update Makefile 2025-11-13 20:36:57 +01:00
Ray
4dbe04b250 Update config.h 2025-11-13 11:26:54 +01:00
Ray
8ae2c9cf5f FIX: LoadFontDataBDF() #5346 2025-11-12 10:22:56 +01:00
Ray
7f82da0031 Update rlsw.h 2025-11-11 17:40:21 +01:00
Ray
fcaea5b1a1 Remove trailing spaces 2025-11-11 17:39:53 +01:00
Ray
4e8b087ffe REVIEWED: ComputeSHA256() 2025-11-11 17:15:40 +01:00
Ray
78faf6a120 Update README.md 2025-11-10 11:47:50 +01:00
d8601121da [examples] Added: textures_sprite_stacking example (#5345)
* Added sprite stacking example

* added link

* formatting
2025-11-09 23:08:26 +01:00
Ray
ee2999b3e0 Update rexm.c 2025-11-09 19:22:12 +01:00
Ray
f76e371436 REDESIGNED: core_clipboard_text, based on #5248 2025-11-09 19:14:46 +01:00
Ray
0b4815b8fe WARNING: REMOVED: GIT recording option, added example 2025-11-09 13:43:08 +01:00
d7a7eda959 [examples] core_directory_files fixes (#5343)
* [examples] reset on folder click

`continue` after clicking a new folder

* [examples] don't make non-directories clickable

`IsPathFile` is not enough to check if it's a directory
since it also takes in char devices.

* rlparser: update raylib_api.* by CI

* Delete tools/rlparser/rlparser

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ray <raysan5@gmail.com>
2025-11-08 11:36:42 +01:00
Ray
2a324ace27 Update parse_api.yml 2025-11-08 11:35:34 +01:00
Ray
8b3ea995f9 Update parse_api.yml 2025-11-08 11:32:58 +01:00
d8da443604 Fixed core_text_file_loading example in raylib examples, to account for blank lines in text file and text wrapping properly for the case when the last word goes out the display (#5339) 2025-11-08 11:29:45 +01:00
4ff296bf0b fix clipping issue (#5342) 2025-11-08 11:28:15 +01:00
ad17af57e9 [ignore][parser] properly ignore built rlparser executable (#5337)
* [ignore][parser] properly ignore built rlparser executable

* remove actual executable
2025-11-07 10:13:27 +01:00
Ray
af57c8854f REXM: ADDED: core_compute_hash 2025-11-05 20:53:14 +01:00
Ray
eacbc8bd61 Update examples_report.md 2025-11-05 20:52:45 +01:00
Ray
a66b6c998a Update README.md 2025-11-05 20:52:23 +01:00
Ray
4883813bbb Update raygui.h 2025-11-05 20:52:18 +01:00
Ray
c24f5ac412 REXM: Reviewed rebuild to support full categories -WIP- 2025-11-05 20:52:14 +01:00
Ray
6adb1c2704 Update core_viewport_scaling.c 2025-11-05 20:51:40 +01:00
Ray
9ff87b38b8 Update raygui.h 2025-11-05 20:51:23 +01:00
Ray
3843f771fb Update core_clipboard_text.c 2025-11-05 20:51:18 +01:00
12ce106661 [rcore][glfw] fix IsWindowFocused() inverted logic (#5333) 2025-11-04 18:17:37 +01:00
48c1619d20 added consistent behavior for texture in opengl11 draw states and fixed loadobj texcoord behavior for opengl11 context (#5328) 2025-11-04 17:52:53 +01:00
e92832fc6d Update rcore_desktop_sdl.c (#5332) 2025-11-04 17:50:54 +01:00
Ray
cfb43fa999 Update rcore_desktop_sdl.c 2025-11-03 09:45:18 +01:00
ed68a4fcce Fixed bugs in SDL backend (#5325) 2025-11-03 09:43:20 +01:00
Ray
91addeb889 Update rexm.c 2025-11-02 20:04:43 +01:00
Ray
ee3be5799a Update raymath.h 2025-11-02 19:59:46 +01:00
Ray
87d49262f8 REVIEWED: raymath: MatrixCompose() 2025-11-02 19:53:45 +01:00
81004135a4 adding Matrix MatrixCompose( translate, rotation, scale ) to raymath.h (#5324) 2025-11-02 19:48:11 +01:00
cc83b2bd8e fix: cursor lock/unlock inconsistent behaviour on glfw, rgfw, sl (#5323) 2025-11-02 19:46:57 +01:00
46e8343a30 [examples] Added core_viewport_scaling (#5313)
* example - core_viewport_scaling

* Code convention update
2025-11-02 19:45:51 +01:00
Ray
3cf3b309c6 REVIEWED: Flags set/clear #5169 2025-11-02 19:40:45 +01:00
5fbf67a630 [rcore] Use FLAG_* macros where possible (#5169)
* use FLAG_* macros where possible

* rename `FLAG_CHECK()` to `FLAG_IS_SET()`

* remove unnecessary equality checks

* fix issues

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-11-02 19:24:47 +01:00
Ray
0246621210 REVIEWED: SIMD intrinsics checks and usage 2025-11-01 21:06:18 +01:00
dfc94f64d1 Revert "UpdateModelAnimation does matrixtranspose(matrixinvert) only once per…" (#5322)
This reverts commit e3a562ab57.
2025-10-31 20:43:27 +01:00
bca54047f9 [rlsw] Review depth formats and fix depth writing (#5317)
* review depth format/writing

* adding a note
2025-10-30 19:17:18 +01:00
b2d455400c Adding SwiftForth language binding (#5319) 2025-10-30 19:15:14 +01:00
Ray
127cc1c79e REVIEWED: Makefile to support software renderer 2025-10-29 22:45:37 +01:00
Ray
3389c80f49 Update rlsw.h 2025-10-29 11:33:08 +01:00
Ray
f16d5ce1dd REVIEWED: Make sure SSE is being used when compiling with MSVC
Added log info and some formatting for visibility
2025-10-29 11:12:04 +01:00
cbff0fa22c [rlsw] Fix axis aligned quad detection (#5314)
* fix `sw_quad_is_axis_aligned`

* align fix

* remove swGetColorBuffer and tweak DRM

* review alignment
2025-10-28 23:50:04 +01:00
Ray
bf5c00f7e0 RE-ADDED: swGetColorBuffer() for convenience #5312
`PLATFORM_DRM` depends on it but if there is a better approach to get the buffer, it can just be removed again and replaced by alternative.
2025-10-28 20:57:31 +01:00
Ray
a844a943b5 It seems alignas() is C11 and raylib is C99, so not fully supported #5312
Added a workaround but it has other probably undesired implications
2025-10-28 20:45:21 +01:00
Ray
f106301d46 ADDED: Some code sample for RISC-V RVV vector instructions -WIP- 2025-10-28 20:11:29 +01:00
Ray
78870335e6 Update rlgl.h 2025-10-28 19:55:35 +01:00
Ray
93a21c7e13 Support other graphic backends on some platforms 2025-10-28 19:55:28 +01:00
f4ed8fc50e [rlsw] Simplify framebuffer logic and add blit/copy fast path (#5312)
* consistency tweak

* unified color and depth buffer

* tweaks

* review the storage of clear values + complete get/set depth value

* copy/blit fast path

* better simd read/write

* framebuffer alignment

* fix 'typo'
my french slipped out
2025-10-28 17:59:59 +01:00
3b6a68ba69 Improve support for PLATFORM_DESKTOP_WIN32 in src/Makefile (#5311)
Co-authored-by: Uneven Prankster <unevenprankster@pm.me>
2025-10-27 12:12:42 +01:00
Ray
f163209cf2 Merge branch 'master' of https://github.com/raysan5/raylib 2025-10-27 00:22:33 +01:00
Ray
5db5c9b4a1 Update rexm.c 2025-10-27 00:20:48 +01:00
9aaf120bbe [examples] Fixed spaces shaders_mandelbrot_set (#5310) 2025-10-27 00:15:59 +01:00
Ray
aae2c4b355 Update rexm.c 2025-10-26 21:25:25 +01:00
Ray
5338e39124 Update rexm.c 2025-10-26 21:23:11 +01:00
Ray
a0f3f07bdc Update examples_report.md 2025-10-26 21:23:08 +01:00
Ray
fdc500756d REXM: ADDED: More detailed log info 2025-10-26 21:21:28 +01:00
Ray
cf9a0619ca REXM: Validate and update examples 2025-10-26 21:21:05 +01:00
Ray
a6dd08fb71 Update shaders_color_correction.c 2025-10-26 20:10:47 +01:00
Ray
0bbe302e72 Merge branch 'master' of https://github.com/raysan5/raylib 2025-10-26 18:40:56 +01:00
Ray
6a5b7fb3f8 Update models_decals.c 2025-10-26 18:40:46 +01:00
40594f3ec0 Fix typo in font loading documentation (#5308) 2025-10-26 18:24:56 +01:00
70f4911698 [examples] Added shaders_color_correction (#5307)
* [examples] Added `shaders_color_correction`

* Add _CRT_SECURE_NO_WARNINGS to VS Project

* Added to makefiles
2025-10-26 18:24:19 +01:00
Ray
0fbc4272d0 Remove trailing spaces 2025-10-26 18:22:23 +01:00
Ray
cb58ca63d4 Review formating #5306 2025-10-26 18:21:24 +01:00
e244cf297a examples_model_decals : Fixed unload crash, added buttons (#5306) 2025-10-26 18:15:45 +01:00
a818508158 [rlsw] Completeness of glDraw functions (#5304)
* adding `glDrawElements`

* tweaks

* fix `glDrawArrays` and `glDrawElements` behavior
2025-10-26 00:58:56 +02:00
Ray
1c20b5588d Updatee project id 2025-10-25 23:20:49 +02:00
e501dfad60 [rlsw] Subpixel correction (#5300)
* fix triangle cracking

* subpixel corretion for quads

* replace Bresenham for DDA + subpixel correction

* consistency

* adding note

* style tweaks
2025-10-25 23:13:24 +02:00
a25d11ad1a Add example: shapes_math_angle_rotation (angle rotation lines) (#5236)
Co-authored-by: Ray <raysan5@gmail.com>
2025-10-25 13:42:35 +02:00
6f101f4011 [examples] Added: shapes_math_sine_cosine (#5257)
* draft: [examples] Added shapes_math_sine_cosine

* draft: [examples] Added screenshot shapes_math_sine_cosine

* Explementary

* Varying radius

* adjustments

* added comments and reorganized UI labels

* Updated Makefile, README.md, and examples_list.txt

* tabs to spaces

* Fix MSVC compilation

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-10-25 13:38:06 +02:00
Ray
efe62f0e0d Formating review to follow raylib code conventions #5298 2025-10-25 11:15:30 +02:00
Ray
79fd6be008 Minor format tweaks 2025-10-25 11:14:53 +02:00
dbcc508196 [examples] Added models_decals (#5298)
* Added decal models example

* Code formatting to match Raylib conventions
2025-10-25 10:41:39 +02:00
4bb8c89084 Don't undefine the versions of LoadImage that don't conflict with raylib so that the Win32 platform can use them. (#5299) 2025-10-25 09:49:31 +02:00
39242dba23 [rlsw] Smarter texture management (#5296)
* simplified framebuffer management

* convert texture to rgba32

* remove float copy/blit

* adding SIMD framebuffer read/write
This adds SIMD framebuffer read/write, and also texel fetch.
This supports SSE2/SSE41 and SISD fallback (also includes ARM NEON support, conceptually identical but still needs testing).

* consistency

* tweaks

* review of `sw_texture_sample_linear`

* better quad sorting
unrelated to the PR, but at least it's done

* ignore some pipeline state in certains context

* convention tweaks

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-10-24 18:29:01 +02:00
12dc0d6675 Revert undesired change to rcore and restore correct win32 ifdef and max path (#5297)
Fixes #5293
also add comment for win32 platform.
2025-10-23 17:45:33 +02:00
93c5dc3b5f [rlsw] c++ support (#5291)
* rlsw c++ support

* rslw formatting fixes
2025-10-23 17:28:00 +02:00
04930c5132 Fix typo in RPI cross-compiler variable name (#5295) 2025-10-23 13:27:28 +02:00
780a7df760 Fix warnings in more examples. (#5292) 2025-10-23 13:25:23 +02:00
Ray
428421f21a Update examples_list.txt 2025-10-22 11:03:19 +02:00
1b5a14e516 [rcore_desktop_sdl] fix: handle monitor ID correctly on SDL3 (#5290)
SDL3 uses ID when dealing with monitors, unlike SDL2 which uses Index
for the same thing. This problem was already fixed in multiple places
by use of preprocessor branches, so I did the very same thing.

Please, notice that this is a pretty bad solution to this problem,
and I only did it to keep it consistent with the rest of the code.
The more about why it's not correct is mentioned here:
https://github.com/raysan5/raylib/issues/5256#issuecomment-3429156919
Hopefully, someone will refactor it someday :)

Fixes: https://github.com/raysan5/raylib/issues/5256
2025-10-21 22:07:04 +02:00
Ray
99ed814615 Update rcore_desktop_win32.c 2025-10-21 20:07:42 +02:00
Ray
77b9214575 Update rcore_desktop_sdl.c 2025-10-21 20:07:32 +02:00
Ray
ec06f9be37 Removed trailing spaces 2025-10-21 13:51:03 +02:00
3c5b3f1c17 [examples] Added shapes_lines_drawing (#5283)
* Added shapes_lines_drawing Example

* store result of clamp

* conventions

* fixed more brackets

* buffer comments
2025-10-21 10:11:19 +02:00
Ray
79b7cd6b9b Format tweaks 2025-10-21 10:08:36 +02:00
Ray
1664204291 REVIEWED: New Win32 platform backend to accomodate rlsw Software Renderer 2025-10-20 19:10:41 +02:00
Ray
ec3cb7045f Update rcore.c 2025-10-20 19:09:56 +02:00
Ray
74f2a899d9 Update rshapes.c 2025-10-20 19:09:37 +02:00
8604085b6e [examples] Fixed shaders_mandelbrot_set for WebGL (#5286) 2025-10-20 15:18:15 +02:00
Ray
5aeedb4899 REXM: Update examples collection 2025-10-20 11:13:45 +02:00
Ray
7ae3eb5d3a Create web_basic_window.png 2025-10-20 11:10:08 +02:00
Ray
de8575b16e Update raylib.sln 2025-10-18 19:54:35 +02:00
aeafce5db4 [examples] Added: shaders_mandelbrot_set (#5282)
* [examples] Added: `shaders_mandelbrot_set`

* Simplified shader code and added comments

* Comments starting with a capital letter, and some minor fixes to adhere to the convention
2025-10-18 19:50:52 +02:00
Ray
9ef3448193 Reviewed UUIDs 2025-10-18 19:47:05 +02:00
Ray
085f933b17 Review example formating 2025-10-17 17:17:54 +02:00
ab4831911a [examples] Added: core_text_file_loading (#5278)
Added and example demonstrating reading the contents of a file and rendering them,
utilizing rtext module. The demonstration also handles wrapping of long sentences,
and text scrolling.

Co-authored-by: Ray <raysan5@gmail.com>
2025-10-17 17:12:14 +02:00
Ray
cd0d693a56 Reviewed example 2025-10-17 17:09:55 +02:00
Ray
7995f8d1b3 Avoid auto push on rename 2025-10-17 17:01:58 +02:00
Ray
ed8c4c1b9b REXM: Update examples collection, some renames 2025-10-17 17:01:38 +02:00
Ray
4099218f1a Update new examples UUID 2025-10-17 12:55:13 +02:00
Ray
ffc405325f Update shapes_pie_chart.c 2025-10-17 12:54:46 +02:00
Ray
9c1216699d ADDED: example: core_highdpi_testbed -WIP-
ADDED: example: `core_screen_recording` -WIP-
2025-10-17 12:35:12 +02:00
Ray
0c97c95f6c Update rexm.c 2025-10-17 12:33:50 +02:00
Ray
bb910bb0b8 REXM: RENAME: example: models_geometry_textures_cube --> models_rotating_cube 2025-10-17 12:33:41 +02:00
Ray
153401810a Merge branch 'master' of https://github.com/raysan5/raylib 2025-10-17 10:04:29 +02:00
Ray
9ed785c2e1 Update rlgl.h 2025-10-17 10:04:21 +02:00
311f6243e3 Disable touch position simulation from mouse movement for DRM touchscreen devices (#5279) 2025-10-17 10:01:24 +02:00
Ray
601ff4f02e REVIEW: Naming tweaks and comments added #5271 2025-10-17 09:54:49 +02:00
4256be5608 Fix branch array size and remove extra function (#5281)
* Fix branch array size and remove extra function

* Fix branch array size and remove extra function
2025-10-17 08:53:48 +02:00
087aa1bc3f Fix triangle strip array size and simplify loop (#5280) 2025-10-17 08:53:02 +02:00
484cc0e255 Fix DrawBillboardPro so that flipped images that are sampling from part of a larger texture still draw from the same source rectangle (#5276)
Co-authored-by: Violently <violently@violently.violently>
2025-10-16 10:18:42 +02:00
c6f9f76afb [examples] Added donut pie charts to shapes_pie_chart (#5277)
* Added donut chart option to pie chart example

* Increased example description buffer size

* Testing mouse trail building

* Removed unused variable

---------

Co-authored-by: Gideon Serfontein <gse@newspacesystems.com>
2025-10-16 09:53:55 +02:00
Ray
af068ec020 Reviewed dynamic library building #5270 2025-10-15 20:18:44 +02:00
Ray
8e052b81b4 REVIEWED: New examples on VS project 2025-10-15 19:59:28 +02:00
Ray
4ba92f8962 REVIEWED: Solution when adding new examples 2025-10-15 19:48:36 +02:00
2a04317cff [examples] Added: shapes_particles (#5260)
* [Examples] Added shapes_particles

* Changes to follow the code conventions. Improved some things.

* Fixed name

* Fixed PNG name

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-10-15 19:39:47 +02:00
1c45776bb7 Added clock of clocks example (#5263) 2025-10-15 19:37:17 +02:00
b020bed2b3 rlparser: update raylib_api.* by CI 2025-10-15 17:36:24 +00:00
Ray
fd28db53ad Update parse_api.yml 2025-10-15 19:35:59 +02:00
1c39d47b5b Added simple starfield example (#5255) 2025-10-15 19:34:39 +02:00
047c9d2052 Added text alignment example (#5254)
Co-authored-by: Ray <raysan5@gmail.com>
2025-10-15 19:33:53 +02:00
7383de3dea feat(shapes): Add shapes_mouse_trail.c example and screenshot (#5246)
Co-authored-by: Balamurugan R <balamuruga.r050814@gmail.com>
2025-10-15 19:30:37 +02:00
21404d958e [examples] Added core_clipboard_text (#5231)
* added clipboard example

* added image check

* added note about windows

* added indent
2025-10-15 19:28:38 +02:00
d2acf06779 [examples] Added core_directory_files (#5230)
* ADDED: example: `core_directory_files`

* Follow raylib's conventions

* Rework `core_directory_files` example

* Removed alternating colors & text on directory

* Update screenshot

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-10-15 19:27:42 +02:00
af11859906 [examples] Added shapes_pie_chart (#5227)
* Added shapes_pie_chart example

* Made the example colorful

* Added some interactivity to the example

* Revert top comment to the standard

* Remove unused MAX_SLICES constant

---------

Co-authored-by: Gideon Serfontein <gse@newspacesystems.com>
Co-authored-by: Ray <raysan5@gmail.com>
2025-10-15 19:25:01 +02:00
1f65a17274 Set name as Const and remove not used variable (#5245) 2025-10-15 19:22:05 +02:00
Ray
18e4d1d44f Reviewed formating 2025-10-15 19:20:11 +02:00
adfe2c1704 C++ compiler support v2 (#5252)
* Get C++ compilers working

* Fix Formatting
2025-10-15 19:11:44 +02:00
17bc628fd9 [rcore] Add ComputeSHA256() function (#5264)
* [rcore] Add `ComputeSHA256()` function

* adjust function signatures

* review issues

* fix repeating 0

* fix mistake

* fixed macro

* remove undefs

* review styling mismatches

* rename `A0,1` to `SHA256_A0,1`

---------

Co-authored-by: CrackedPixel <5776225+CrackedPixel@users.noreply.github.com>
2025-10-15 19:07:41 +02:00
7191749d66 [examples] Fix examples to work in MSVC (#5267)
* Fix warnings in many examples
Add examples to MSVC solution correctly

* fix CI error

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-10-15 19:02:52 +02:00
e3a562ab57 UpdateModelAnimation does matrixtranspose(matrixinvert) only once per bone instead of per vertex (#5244) 2025-10-15 19:00:24 +02:00
aaf4c1d3ae always forward declare the windows stuff, prevents failure of rgfw in GCC. (#5269) 2025-10-15 00:18:48 +02:00
2d7b66dd37 change free to RL_FREE (#5265) 2025-10-13 22:15:20 +02:00
Ray
9f831428e6 Update core_render_texture.c 2025-10-09 17:16:54 +02:00
Ray
c80726511c Merge branch 'master' of https://github.com/raysan5/raylib 2025-10-09 01:09:58 +02:00
Ray
767df4cf52 Update core_render_texture.c 2025-10-09 01:09:55 +02:00
Ray
04a1a0293e Update examples_list.txt 2025-10-08 18:17:32 +02:00
Ray
f62565dc72 Update text_unicode_ranges.c 2025-10-08 18:16:46 +02:00
6f584464b6 remove duplicate entry from keyMappingRGFW (#5242) 2025-10-08 15:04:29 +02:00
9bf7699624 [examples] Added shapes_kaleidoscope (#5233)
* ADDED: example: `shapes_kaleidoscope`

* Add line reflection

* Updated with `rexm update`

* Follow raylib's conventions
2025-10-08 00:10:43 +02:00
4cfae99a74 [examples] Added shapes_triangle_strip (#5240)
* [examples] Add shapes_triangle_strip

* Remove functions
2025-10-07 20:25:22 +02:00
Ray
5dd97ecf2f REVIEWED: TextToPascal(), fix https://github.com/raylibtech/rtools/issues/57 2025-10-07 19:42:05 +02:00
ca664cb023 Fix zig compileRaylib target to emscripten (#5239) 2025-10-07 12:00:50 +02:00
b99a6cc6bd [examples] Added shapes_recursive_tree (#5229)
* ADDED: example: shapes_recursive_tree

* [examples] Added shapes_recursive_tree

* [examples] shapes_recursive_tree: adjustments

* Reduced tree depth from 12 to 10

* new shapes_recursive_tree.png

* follow the conventions

* follow the conventions 2
2025-10-06 22:35:18 +02:00
Ray
b067b0b878 Update analyze_codeql.yml 2025-10-06 18:27:56 +02:00
Ray
59c3fcc23a Update analyze_codeql.yml 2025-10-06 18:15:32 +02:00
Ray
a683dd9615 Update analyze_codeql.yml 2025-10-06 17:40:39 +02:00
de50402dd5 Check if video mode is valid and rename to match with other methods (#5235) 2025-10-05 22:26:25 +02:00
Ray
b9e7cb64c5 rlparser: Reviewed command-line info 2025-10-04 20:16:16 +02:00
Ray
d4ca9f9213 Merge branch 'master' of https://github.com/raysan5/raylib 2025-10-04 20:15:19 +02:00
Ray
1937fedf08 rlparser: Minor tweaks 2025-10-04 20:07:39 +02:00
07aafdd585 Updated miniaudio.h - v0.11.23 (#5234)
Co-authored-by: pyrokn8 <202429796+pyrokn8@users.noreply.github.com>
2025-10-04 19:40:53 +02:00
Ray
d7a83a1111 REVIEWED: RENAMED: Renamed tool raylib_parser to rlparser
The tool can work with other libraries following `raylib.h` structure, keeping the `raylib_parser` name could be missleading. Also added an icon an reviewed Makefile an CI.
2025-10-04 19:39:25 +02:00
Ray
f0ffdb33f4 REXM: Support building full example collection and categories
ADDED: Some log info
2025-10-02 20:04:41 +02:00
Ray
e7d27e5b80 REXM: Remove test code 2025-10-02 19:26:27 +02:00
Ray
7b5c597da5 Update rexm.c 2025-10-02 19:25:45 +02:00
02b3e44f88 swap TraceLog to TRACELOG (#5226) 2025-10-02 14:13:07 +02:00
Ray
718a841cfb REXM: Update examples 2025-10-02 13:54:11 +02:00
Ray
8670e6e1b9 REXM: FIX: Get others category 2025-10-02 13:45:25 +02:00
Ray
29a7996402 REXM: Remove dead code of functions already moved to raylib 2025-10-02 13:45:06 +02:00
Ray
301df440bd Merge branch 'master' of https://github.com/raysan5/raylib 2025-10-02 13:41:40 +02:00
Ray
7e6f38ad29 Merge branch 'master' of https://github.com/raysan5/raylib 2025-10-02 13:40:55 +02:00
Ray
78a79a8523 Update list 2025-10-02 13:40:36 +02:00
2ea18f7c88 Update raylib_api.* by CI 2025-10-02 11:38:31 +00:00
Ray
7e3b7cd349 REVIEWED: DrawLineDashed() 2025-10-02 13:38:13 +02:00
Ray
36d3c8acfb Update rexm.c 2025-10-02 13:16:29 +02:00
Ray
377853bb32 REXM: Updated new examples requried files 2025-10-02 13:16:00 +02:00
Ray
a0a0d4d5ad Update rcore_desktop_win32.c 2025-10-02 13:05:42 +02:00
Ray
8494d76c93 Update rexm.c 2025-10-02 13:04:43 +02:00
Ray
5d9c11e165 Updated examples 2025-10-02 13:04:34 +02:00
Ray
de20076d36 Update examples_list.txt 2025-10-02 13:02:58 +02:00
a5a5d3f347 removed unneeded include (#5225) 2025-10-01 18:33:51 +02:00
1cdf1dcbbe [examples] Add models_geometry_textures_cube (#5221)
* ADDED: example:  models_geometry_textures_cube

* FIXED: example: models_geometry_textures_cube - removed leftover TODO and aligned title with header
2025-10-01 18:31:53 +02:00
452cac33b8 [examples] Add core_monitor_change (#5215)
* Add core monitor change example

* Add monitor drawing and more information

* Update monitor information every frame

* Show info and window position inside the rectangle
2025-10-01 18:31:03 +02:00
14a0a4d0c4 FIXED: rexm's makefile and default paths (#5224)
* FIXED: rexm's makefile and default paths

Fixed a windows only backslash in
rexm's makefile causing build errors on macOS and linux

Added unix paths to rexm for better compatibility

* Update rexm.c

Readded the fall-through in OP_CREATE

Added some safety checks to UpdateRequiredFiles() so it plays nicely outside of the raylib.com context (would segfault previously)
2025-10-01 18:27:28 +02:00
6f1077737e Update raylib_api.* by CI 2025-10-01 09:43:50 +00:00
f680776941 feat:Added DrawLineDashed() and a new example explaining how to use this new function. (#5222) 2025-10-01 11:43:38 +02:00
e5f809f534 switch to enum (#5223) 2025-10-01 11:42:35 +02:00
6ed61e107b flipped binary check to fix bug (#5220) 2025-09-30 21:49:58 +02:00
Ray
8932ba0b0a Update core_delta_time.c 2025-09-30 18:48:42 +02:00
Ray
6966ad5717 Update shaders_ascii_rendering.c 2025-09-30 18:39:27 +02:00
3f30533f1c [examples] Add core_delta_time (#5216)
* delta example

* clarification

* made it more clear what delta time is

* more explanation

* vector2 positions, removed all warnings

* removed keys, moved global to local, conventions & comments, show target fps

* new png

* remove more periods

* another period

* remove note about conventions, remove period
2025-09-30 18:35:15 +02:00
a553fbd0c7 [examples] Fix shaders_ascii_rendering (#5219)
* Add ascii post processing

* Fix broken characters and add more comments

* Rename example

* Refactored as requested
2025-09-30 18:34:06 +02:00
0e2e8ce225 [examples] Update shapes_bouncing_ball with gravity (#5217)
* [examples] Add shapes_bouncing_ball with gravity

* gravity could be enabled/disabled
2025-09-30 18:32:25 +02:00
Ray
5d9352a0a1 Update shapes_bullet_hell.c 2025-09-30 18:27:59 +02:00
56e32f2c3e ADDED: example: shapes_bullet_hell (#5218)
* add shapes_bullet_hell example

* adjust example count
2025-09-30 11:59:44 +02:00
Ray
37149082e8 Avoid warnings 2025-09-29 18:05:16 +02:00
Ray
0e57a572b4 REVIEWED: rlsw module and related files 2025-09-29 18:05:07 +02:00
Ray
beabb1300d Revert "Update miniaudio to v0.11.23 (#5208)"
This reverts commit 4cd131cf29.
2025-09-29 18:03:42 +02:00
Ray
218a806ec2 REVIEWED: example: shaders_ascii_rendering 2025-09-29 18:01:42 +02:00
317c1eaeeb Add ascii post processing (#5213) 2025-09-29 17:44:48 +02:00
3da2fc1bf8 [rtextures] fix initialization align in Image to avoid issues with some platforms (#5214) 2025-09-29 17:16:51 +02:00
Ray
43c81d216c REVIEWED: VS2022: New example core_input_actions UUID 2025-09-29 11:00:35 +02:00
584bc14929 [rlgl] Add Software Rendering Support (#4832)
* add base of rlsw.h

* implement state support
Also replace the triangle rasterization functions with macros that generate specific functions for each state of the rendering system.
Also, add the OpenGL definitions in order to add a binding for rlgl.

* branchless float saturation

* apply perspective correction to colors

* impl line clipping and rasterization
+ tweak function names

* impl face culling

* impl color blending

* fixes and tweaks

* add clear buffer bitmasks

* small optimizations / tweaks

* review ndc to screen projection

* avoid to recalculate MVP when its not needed + tweaks

* review the loading and management of textures
to be closer to the OpenGL API

* texture sampling optimization

* review get pixel functions
+ review unorm/float conversion

* add several buffer format support
Several depth and color formats have been added for the framebuffer.

8-bit, 16-bit, and 24-bit formats are now available for depth.

RGB 8-bit (332), RGB 16-bit (565), and RGB 24-bit (888) formats are now available for color.

Alpha support is no longer present for the framebuffer at the moment, but it can easily be restored by adding the formats and reinterpolating the alpha in the areas that do not perform color blending.

Additionally, this commit brings performance improvements.

* tweaks

* impl line width

* impl points + point size

* fix and improve polygon clipping functions

* impl polygone modes

* add some not planned functions
- `glDepthMask`
- `glColorMask`

* framebuffer resizing + handle init failure

* add quick notes about line clipping algorithms used

* start to impl scissor test + review line clipping
The support for the scissor test has been implemented for clearing as well as for triangle clipping.
The implementation for lines and points is still missing.

I also removed the 2D clipping of lines that used the Cohen-Sutherland algorithm, opting instead to always use the Liang-Barsky algorithm in all cases.
This simplifies the implementation, and the 2D version would have caused issues when interpolating vertices in the future if we want to implement additional features.

* review scissor clear

* review `swScissor`

* impl line scissor clipping

* round screen coordinate (line rasterization)

* impl point scissor clipping

* remove unused defs

* add getter functions

* gl binding

* add `glHint` and `glShadeModel` macros (not implmented)

* binding tweaks

* impl copy framebuffer function + glReadPixels

* review `swCopyFramebuffer`

* update rlgl.h

* update rlgl.h

* texture copy support

* fix typo..

* add get error function

* def sw alloc macros

* reimpl get color buffer func
just in case

* remove normal interpolation

* review texture wrap

* fix ndc projection (viewport/scissor)

* impl framebuffer blit function

* reduce matrix compuations and memory usage

* swBegin tweaks

* preventing a possible division by zero

* remove useless scissor related data

* review color blending system

* greatly improve float saturation

* tweak lerp vertex function

* use opitmized fract function in sw_texture_map

* tweak framebuffer functions for better readability

* optimized copy/blit functions for each dst format

* review framebuffer filling functions

* impl specific quad rendering func

* use of a single global vertex buffer

* fix 'sw_poly_point_render'

* added `SW_RESTRICT` and redesigned `sw_lerp_vertex_PNCTH`

* tweak the pipeline flow regarding the face culling
avoids misprediction, improves vectorization if possible

* new rendering path for axis aligned quads

* oops, translating some comments

* use of `restrict` for blending function parameters

* update rlgl.h

* adding `GRAPHICS_API_OPENGL_11_SOFTWARE` in `DrawMesh`

* add `RL_OPENGL_11_SOFTWARE` enum

* temp tweak

* build fixes

* fix DrawMesh for GL 1.1

* update swClose

* review texture format + fix copy

* set minimum req vertices to 3 (quads)

* check swInit

* review pixelformat

* tweaks

* fix animNormals (DrawMesh)

* fallback color/texcoord (swDrawArrays)

* review swMultMatrixf

* fix texture pool alloc..

* review triangle scanlines
increment all data

* fix `sw_quad_sort_cw`

* impl sdl platform

* rm def

* increase max clipped polygon vertices

* improve triangle rasterization along Y axis
improved robustness against numerical errors
incremental interpolation along Y
simplified function, fewer jumps

* review current vertex data
+ increase max clipped polygon vertices (for extreme cases)

* fix and improve polygon clipping
Sets the vertex count to zero when the polygon is invalid
Stops clipping when the vertex count drops below 3

* fix gradient calculation

* cache texture size minus one + comments

* tweaks

* BGRA copy support

* adding software backend option (cmake)

* update Makefile

* fix face culling

* excluse some exemple with the software backend

* review SW_CLAMP case in sw_texture_map

* review sw_saturate

* review line raster

* fix sw_quad_is_aligned

* review sw_raster_quad_axis_aligned

* tweaks

* codepoint fix (?)

* fix var name...

* rcore_drm software renderering

* cleanup and tweaks

* adding support for `GL_POINT_SIZE` and `GL_LINE_WIDTH` get

* fix sampling issue

* fix swBlendFunc

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-09-29 10:28:20 +02:00
Ray
6d9e17594b Merge branch 'master' of https://github.com/raysan5/raylib 2025-09-28 23:48:24 +02:00
Ray
f76666af3f REXM: Avoid updating metadata from others examples 2025-09-28 23:48:10 +02:00
Ray
e5e684a5ca Update examples_report.md 2025-09-28 23:47:39 +02:00
c551fb7118 Add models_basic_voxel example (#5212) 2025-09-28 23:40:09 +02:00
Ray
7d780d18b5 REVIEWED: New example format and requirements: core_input_actions #5211 2025-09-28 23:31:07 +02:00
a2a22e5e48 ADDED: example: core_input_actions (#5211)
* adding core_input_actions

action based input API vs direct input, allows remapping of buttons or keys to an action.

* adjusted formatting.

* updates for struct name

and fixed a typo
2025-09-28 23:02:53 +02:00
Ray
4767841b71 Code format review 2025-09-28 19:45:52 +02:00
f36c8ddc56 [rlgl] Allow tint colors in GL_LINE (wires) and GL_POINT (points) draw modes on OpenGL 1.1 clean (#5207)
* gate with OPENGL_11 prototype and definition for rlSetPointSize and rlGetPointSize

* gate with OPENGL_11 prototype and definition for rlSetPointSize and rlGetPointSize

* more coverage for fixing expected texcoords, normals, and colors

* fix guard styling

* fix guard issue, and remove fallback unneccessary else clause (default shader ill work)

* opengl3.3 and es2 need the color array allocated in order to allow for updates later (unlike opengl11)
2025-09-28 19:34:38 +02:00
4cd131cf29 Update miniaudio to v0.11.23 (#5208) 2025-09-28 18:53:40 +02:00
Ray
070c7894c6 REVIEWED: Some flags for window/context creation attributes 2025-09-26 23:35:28 +02:00
Ray
e79603d501 REDESIGNED: rcore_desktop_win32 platform backend
Now it works! but there is still work to do to support all required features...

I really enjoyed reviewing and redesigning this platform backend!
2025-09-26 23:17:37 +02:00
Ray
06cfda6ff9 Update raymath.h 2025-09-26 23:03:10 +02:00
Ray
87f758f9b4 Review latest PRs formatting 2025-09-26 22:26:19 +02:00
Ray
f6c07099af Merge branch 'master' of https://github.com/raysan5/raylib 2025-09-26 22:22:57 +02:00
Ray
2724f07c9a Update rexm.c 2025-09-26 22:22:43 +02:00
fe8c83b57d Update palette_switch.fs (#5205)
Removed unnecessary `a` in palette_switch.fs `note` comment
2025-09-26 20:56:54 +02:00
15d234b79d GLTF anim correctly inherits world transform (#5206) 2025-09-26 20:56:37 +02:00
3f6d67c61c [rcore_android] implement GetCurrentMonitor() (#5204) 2025-09-24 20:45:55 +02:00
07033cff90 Fix polygon drawing example for opengl 1.1 (#5202) 2025-09-24 20:44:15 +02:00
2554dcba9b fix rlSetTexture not overriding default mode (#5200) 2025-09-24 10:22:03 +02:00
Ray
4f9b933b34 REXM: Update examples; text_unicode_emojis requires additional resources on Web 2025-09-24 10:17:34 +02:00
ca33d495b3 [build][cmake] set lib m as public so it can be linked by consumer (#5193)
* [build][cmake] set lib m as public so it can be linked by consumer

* [build][cmake] removed redundancy when BSD systems
2025-09-23 18:07:11 +02:00
085391e788 [build][cmake] fix issue introduced by #5181 (#5198)
* fix web build issue with CMake introduced by #5181

* remove ASYNCIFY
2025-09-23 18:04:30 +02:00
fbae395e85 Update raymath.h (#5201) 2025-09-23 17:58:42 +02:00
Ray
78a607b778 Update twitter links 2025-09-22 11:40:06 +02:00
Ray
bb28d7fd0e Update normalmap.fs 2025-09-21 20:37:01 +02:00
Ray
363855ec3e Update rexm.c 2025-09-21 20:21:42 +02:00
Ray
8ada37d967 Update depth_write.fs 2025-09-21 13:28:30 +02:00
Ray
e7cfd3d4a3 Update depth_render.fs 2025-09-21 13:28:27 +02:00
Ray
95cb0cbf67 Update README.md 2025-09-21 13:14:01 +02:00
Ray
47576e4e10 Merge branch 'master' of https://github.com/raysan5/raylib 2025-09-21 13:13:48 +02:00
Ray
1161286d51 Update rexm.c 2025-09-21 13:13:46 +02:00
Ray
f0674676b6 Update raylib_parser.c 2025-09-21 13:12:32 +02:00
ff8333435a use lowercase "message" to remove recommendation warning (#5196)
It is recommended to use lowercase CMake commands
2025-09-19 17:06:43 +02:00
Ray
1c3f9fa135 Update parse_api.yml 2025-09-18 16:06:24 +02:00
Ray
9268b0d029 REXM: Commented functions moved to main raylib API 2025-09-18 15:51:48 +02:00
Ray
e81fc8d21a Merge branch 'master' of https://github.com/raysan5/raylib 2025-09-18 15:51:27 +02:00
Ray
23e0898c65 Ouch! 2025-09-18 15:51:18 +02:00
97e214fc68 Update raylib_api.* by CI 2025-09-18 13:34:30 +00:00
Ray
c264c86ee0 ADDED: Some useful functions for Files and Text management
// File management functions
 - int FileRename(const char *fileName, const char *fileRename); // Rename file (if exists)
 - iint FileRemove(const char *fileName);                         // Remove file (if exists)
 - iint FileCopy(const char *srcPath, const char *dstPath);       // Copy file from one path to another, dstPath created if it doesn't exist
 - iint FileMove(const char *srcPath, const char *dstPath);       // Move file from one directory to another, dstPath created if it doesn't exist
 - int FileTextReplace(const char *fileName, const char *search, const char *replacement); // Replace text in an existing file
 - iint FileTextFindIndex(const char *fileName, const char *search); // Find text in existing file

// Text management functions
 - const char *TextRemoveSpaces(const char *text);                                       // Remove text spaces, concat words
 - char *GetTextBetween(const char *text, const char *begin, const char *end);           // Get text between two strings
 - char *TextReplace(const char *text, const char *search, const char *replacement);     // Replace text string (WARNING: memory must be freed!)
 - char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replacement); // Replace text between two specific strings (WARNING: memory must be freed!)
2025-09-18 15:34:09 +02:00
Ray
bd6065a4fd Update rlgl.h 2025-09-18 15:29:13 +02:00
Ray
dc1632c17a REVIEWED: Platform code formatting and organization 2025-09-18 15:28:03 +02:00
7729727752 Use the render size not the screen size for screenshots so we use the actual framebuffer size. (#5192) 2025-09-18 00:01:24 +02:00
a15651f4fe Restore projects/CMake/CMakeLists.txt (#5191)
For some reason, #5181 deleted it.
This project is intended to be a simple template to set up a project
consuming raylib with CMake.
2025-09-17 19:22:53 +02:00
fbdf5e4fd2 fix(rcore): correctly scale content on macOS (#5186)
Currently, scaling doesn't work correctly on macOS (see #5185).  This commit
works around this issue by disabling SCALE_FRAMEBUFFER on macOS when
`FLAG_WINDOW_HIGHDPI` is unset.
2025-09-16 19:37:05 +02:00
Ray
ed8f1a22d1 Remove trailing spaces 2025-09-14 18:07:58 +02:00
Ray
96fb4851ce Merge branch 'master' of https://github.com/raysan5/raylib 2025-09-14 10:27:08 +02:00
Ray
068978d5b3 REXM: RENAME: example: models_gpu_skinning --> models_animation_gpu_skinning 2025-09-14 10:26:04 +02:00
Ray
c1615aaac4 Update examples_template.c 2025-09-14 10:22:56 +02:00
b281101001 [build][cmake] Review web compilation system (#5181)
* [cmake] export automatically raylib definitions and compile/link options

* [cmake] pass emscripten options to consumer project

* [web] compile for web

* [web] canvas width 100%
2025-09-14 10:05:07 +02:00
Ray
c9b1f2ce54 REVIEWED: example: core_input_gestures_testbed, follow default structure 2025-09-14 10:04:24 +02:00
Ray
9931ddd27a Update core_undo_redo.c 2025-09-13 21:17:16 +02:00
Ray
36ad7127c2 REXM: Update 2025-09-13 21:09:59 +02:00
Ray
36824b6c0a REXM: ADDED: example: core_undo_redo 2025-09-13 20:58:27 +02:00
Ray
865b3310f8 Updated project GUIDs 2025-09-13 20:57:39 +02:00
Ray
161cab24da Update core_random_sequence.c 2025-09-13 20:57:20 +02:00
Ray
6f01f3c06d Update rexm.c 2025-09-13 20:57:00 +02:00
Ray
b8420d4821 REXM: Update examples 2025-09-13 10:46:14 +02:00
Ray
3148206758 Renamed shaders for consistency 2025-09-13 10:44:12 +02:00
Ray
f711c98bd6 Merge branch 'master' of https://github.com/raysan5/raylib 2025-09-13 10:43:38 +02:00
Ray
adac5f7770 REXM: RENAME: example: shaders_write_depth --> shaders_depth_writing 2025-09-13 10:41:25 +02:00
bb0c78476c [build][cmake] Fix definition to use SDL3 (#5175)
* fix definition to use SDL3

* [cmake] fix definition to use SDL3

* [build][cmake] prefer USING_VERSION_SDL3 over PLATFORM_DESKTOP_SDL3

* [build][cmake] when libs are added externally, consumer needs to import them too
2025-09-13 10:19:44 +02:00
6cf38b6292 fix SDL3 gamepad detection (#5176) 2025-09-13 10:17:17 +02:00
Ray
8d48a12306 Merge branch 'master' of https://github.com/raysan5/raylib 2025-09-12 21:44:56 +02:00
Ray
28ce99b539 Update core_3d_camera_fps.c 2025-09-12 21:44:56 +02:00
71321d179b [build][cmake] Added emscripten build options (#5180)
* [cmake] export automatically raylib definitions and compile/link options

* [cmake] pass emscripten options to consumer project
2025-09-12 21:42:50 +02:00
7db5f56e81 [cmake] export automatically raylib definitions and compile/link options (#5179) 2025-09-12 13:07:46 +02:00
Ray
8d3a4b8dd5 REVIEWED: Renamed PLATFORM_DESKTOP_SDL3 to USING_VERSION_SDL3 #5175
Avoid using a new platform flag to address one platform version
2025-09-12 13:03:28 +02:00
Ray
d0c39db6c2 Update rlgl.h 2025-09-12 13:02:13 +02:00
Ray
5a54fc12a2 REVIEWED: Prioritize calloc() calls than malloc() on some cases 2025-09-10 21:03:06 +02:00
Ray
8a1468c0c7 Update examples_report.md 2025-09-10 21:02:26 +02:00
Ray
2550a45821 Update core_render_texture.c 2025-09-10 18:31:52 +02:00
Ray
109b3b2d2e REXM: ADDED: example: text_inline_styling 2025-09-10 18:31:49 +02:00
Ray
9e14faffcc REXM: REVIEWED: example addition logic 2025-09-10 18:27:19 +02:00
Ray
ffe74658ab REXM: ADDED: example: core_render_texture 2025-09-10 18:26:43 +02:00
Ray
84e2cbccc4 Update complexity level for shapes_digital_clock 2025-09-09 17:33:19 +02:00
Ray
a42eb2f79b REDESIGNED: example: shapes_digital_clock 2025-09-09 17:32:13 +02:00
Ray
866e7238bf Remove projects from solution 2025-09-09 17:30:54 +02:00
Ray
698d37c57a Update shaders_normalmap_rendering.c 2025-09-09 17:30:25 +02:00
Ray
1b9aa0bcf3 Update rmodels.c 2025-09-09 17:30:18 +02:00
Ray
f4250da042 Update text_unicode_ranges.c 2025-09-09 09:37:06 +02:00
Ray
f6ae596a1d Update rexm.c 2025-09-09 00:47:12 +02:00
Ray
0da5bc1e17 REXM: REVIEWED: TextReplaceBetween() 2025-09-09 00:26:38 +02:00
Ray
4447868c60 REXM: Updated examples, resources checking 2025-09-09 00:16:47 +02:00
Ray
adb078128b Update rexm.c 2025-09-09 00:15:30 +02:00
Ray
28c5d16000 Update shaders_shadowmap_rendering.c 2025-09-09 00:15:26 +02:00
Ray
811ec4fb1e REVIEWED: shaders_shadowmap_rendering example 2025-09-08 21:02:58 +02:00
Ray
ef0dd5f774 REXM: Updated examples after some renames 2025-09-08 21:01:59 +02:00
Ray
c7f8843200 REXM: RENAME: example: shaders_eratosthenes --> shaders_eratosthenes_sieve 2025-09-08 20:37:27 +02:00
Ray
851bb3120d REXM: RENAME: example: shaders_view_depth --> shaders_depth_rendering 2025-09-08 20:37:11 +02:00
Ray
adda398e65 REXM: RENAME: example: shapes_easings_rectangle_array --> shapes_easings_rectangles 2025-09-08 20:36:48 +02:00
Ray
5ac0539481 REXM: RENAME: example: shapes_easings_box_anim --> shapes_easings_box 2025-09-08 20:36:41 +02:00
Ray
84baaa6ee7 REXM: RENAME: example: shapes_easings_ball_anim --> shapes_easings_ball 2025-09-08 20:36:29 +02:00
Ray
ede4547015 REXM: RENAME: example: models_draw_cube_texture --> models_textured_cube 2025-09-08 20:35:37 +02:00
Ray
d8f3b51a3f REXM: RENAME: example: models_animation --> models_animation_playing 2025-09-08 20:35:27 +02:00
Ray
4a23ed698f REXM: RENAME: example: shaders_raymarching --> shaders_raymarching_rendering 2025-09-08 20:34:48 +02:00
Ray
f4f3325e1e REXM: RENAME: example: shaders_spotlight --> shaders_spotlight_rendering 2025-09-08 20:34:33 +02:00
Ray
11ca32493a REXM: RENAME: example: shaders_lightmap --> shaders_lightmap_rendering 2025-09-08 20:34:16 +02:00
Ray
07070b81e8 REXM: RENAME: example: shaders_shadowmap --> shaders_shadowmap_rendering 2025-09-08 20:33:36 +02:00
Ray
6afc608477 REXM: RENAME: example: shaders_normal_map --> shaders_normalmap_rendering 2025-09-08 20:33:18 +02:00
Ray
4cf4c6645e REXM: RENAME: example: shaders_hybrid_render --> shaders_hybrid_rendering 2025-09-08 20:30:45 +02:00
Ray
14bef50464 REXM: RENAME: example: shaders_deferred_render --> shaders_deferred_rendering 2025-09-08 20:30:26 +02:00
Ray
ab3e99fd30 REXM: RENAME: example: models_cubicmap --> models_cubicmap_rendering 2025-09-08 20:30:07 +02:00
Ray
463d069eff REXM: RENAME: example: models_heightmap --> models_heightmap_rendering 2025-09-08 20:29:53 +02:00
Ray
b67e7ffc44 REXM: RENAME: example: shapes_draw_circle_sector --> shapes_circle_sector_drawing 2025-09-08 20:28:17 +02:00
Ray
16fbca2e8b REXM: RENAME: example: shapes_draw_rectangle_rounded --> shapes_rounded_rectangle_drawing 2025-09-08 20:27:00 +02:00
Ray
266b8efbd6 REXM: Reviewed examples inconsistencies 2025-09-07 12:05:11 +02:00
Ray
688cf680c0 Update examples_list.txt 2025-09-07 12:03:16 +02:00
Ray
25f4e544d1 REXM: UPDATED: Examples source code header info, aligned with name 2025-09-07 12:01:51 +02:00
Ray
4020885c35 REXM: Reviewed UpdateSourceMetadata() 2025-09-07 11:54:36 +02:00
Ray
8544020023 Update required files for example rename 2025-09-07 11:47:58 +02:00
Ray
5373ede25c REXM: Review examples source code header metadata for consistency 2025-09-07 11:44:33 +02:00
Ray
e1dfb4cd4e Update shaders_normal_map.c 2025-09-07 11:44:03 +02:00
Ray
1bbd4c3566 REXM: RENAME: example: shapes_draw_ring --> shapes_ring_drawing 2025-09-07 11:19:29 +02:00
Ray
c0234e5e3d REXM: RENAME: example: textures_sprite_anim --> textures_sprite_animation 2025-09-07 11:14:56 +02:00
Ray
02d004274c Update rexm.c 2025-09-07 11:14:35 +02:00
Ray
2d19abb2cf REXM: REVIEWED: Examples header info inconsistencies 2025-09-07 11:04:00 +02:00
Ray
e5cef3c0d8 REXM: Reviewed examples source code headers metadata 2025-09-07 10:46:51 +02:00
Ray
68a678a549 Update rexm.c 2025-09-07 10:18:41 +02:00
Ray
16a0b966c3 Update rexm.c 2025-09-06 00:09:22 +02:00
Ray
4af48fba74 REXM: REVIEWED: UpdateSourceMetadata() and TextReplaceBetween() 2025-09-06 00:04:07 +02:00
Ray
446f015ac5 Review formating 2025-09-05 23:10:13 +02:00
Ray
b2684a9c38 Merge branch 'master' of https://github.com/raysan5/raylib 2025-09-05 23:07:46 +02:00
Ray
86ec1c08c2 Update rexm.c 2025-09-05 23:07:29 +02:00
bd810368b0 Fixing base64 decoding error when input string is bad (#5170)
The following code would crash the previous version when calling MemFree:

	// 53 * A
        const char maliciousBase64Input[] = "AAAAAAAAAAAAAAAAAAAAAAAA"
		"AAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
        int decodedSize = 0;
        unsigned char *decodedData = DecodeDataBase64(
		maliciousBase64Input, &decodedSize);
        if (decodedData) {
		MemFree(decodedData);
        }

The reason is a lack of array bound checks in the decoding loop, which
corrupted here the heap (though this is platform dependent).

Adding the bound checks here prevents the memory corruption.

Tested with encoding random data of sizes 0-1023 and comparing it
with the decoded result.
2025-09-05 23:05:08 +02:00
Ray
eb816898e5 Revert "Added creation-review years to examples"
This reverts commit b5e25916fc.
2025-09-05 23:02:06 +02:00
Ray
84e606b8c7 Update rexm.c 2025-09-05 23:00:36 +02:00
Ray
1d4d8da3e9 Removed temp code to generate updated examples_list.txt 2025-09-05 22:59:42 +02:00
Ray
3e59797a68 REXM: ADDED: Read examples years created/reviewed info
ADDED: `UpdateSourceMetadata()`
2025-09-05 14:10:26 +02:00
Ray
424cdebda5 Updated examples_list.txt to include example year created/reviewed
Reviewed star used, aligned with empty star and examples header
2025-09-05 14:04:28 +02:00
Ray
b5e25916fc Added creation-review years to examples 2025-09-05 11:25:24 +02:00
Ray
47bdfb91a2 Update README.md 2025-09-05 10:57:25 +02:00
Ray
8e52aee853 Update rtext.c 2025-09-05 00:13:32 +02:00
Ray
389800fd34 REXM: REVIEWED: ScanExampleResources() 2025-09-04 23:55:23 +02:00
Ray
43305c4865 REXM: ADDED: RemoveVSProjectFromSolution() 2025-09-04 23:54:57 +02:00
Ray
d980642421 Merge branch 'master' of https://github.com/raysan5/raylib 2025-09-04 23:54:17 +02:00
Ray
51aa8776bb Update rtext.c 2025-09-04 23:53:26 +02:00
55a1c58b64 Update raylib_api.* by CI 2025-09-04 21:26:00 +00:00
Ray
0203a47bf9 REDESIGNED: LoadTextLines()/UnloadTextLines() 2025-09-04 23:25:42 +02:00
Ray
8116ebd9bb Update rexm.c 2025-09-04 19:15:47 +02:00
Ray
a51cb7fe30 REXM: Updated some examples inconsistencies 2025-09-04 19:15:37 +02:00
Ray
91bc8d9b10 REXM: Remove duplicate entries on examples list on Update process 2025-09-04 18:57:32 +02:00
Ray
7646d08751 Updated some examples with inconsistencies 2025-09-04 18:57:00 +02:00
Ray
fb42819eab Added project to folder in solution 2025-09-04 16:56:38 +02:00
Ray
d418704c0b REXM: Update examples collection 2025-09-04 16:17:23 +02:00
Ray
293477e2b5 Reorganized examples list 2025-09-04 16:05:54 +02:00
Ray
6d7dd43c13 Update core_input_gestures_testbed.c 2025-09-04 16:05:38 +02:00
Ray
e21093d434 REXM: RENAME: example: core_input_gestures_web --> core_input_gestures_testbed 2025-09-04 15:59:53 +02:00
Ray
c17f82a78c REMOVED: core_basic_window_web
The example is not following examples conventions and it will be moved to `others` with a new name
2025-09-04 15:43:54 +02:00
Ray
d97e0a8ac7 REXM: RENAME: example: shaders_texture_drawing --> shaders_texture_rendering 2025-09-04 11:27:32 +02:00
Ray
427b0d2653 Update rexm.c 2025-09-04 11:26:39 +02:00
Ray
5f9465d569 Update rexm.c 2025-09-04 11:21:52 +02:00
Ray
d79f294af0 Update rexm.c 2025-09-04 11:20:48 +02:00
Ray
41dee9e9f9 REXM: RENAME: example: shaders_fog --> shaders_fog_rendering 2025-09-04 11:12:01 +02:00
Ray
3cbe911613 REXM: RENAME: example: models_billboard --> models_billboard_rendering 2025-09-04 11:04:00 +02:00
Ray
b17936de22 REXM: RENAME: example: models_billboard --> models_billboard_rendering 2025-09-04 10:55:48 +02:00
Ray
3659eee994 Update rexm.c 2025-09-04 10:50:35 +02:00
Ray
ba046a5d60 REVIEWED: DecompressData(), fixed buffer copying 2025-09-04 10:44:20 +02:00
Ray
f9e6c85cce Update rexm.c 2025-09-04 10:40:17 +02:00
Ray
9b99c5b04e REXM: Adding some UpdateSourceMetadata() -WIP- 2025-09-04 10:34:39 +02:00
Ray
64641c6a01 Update raudio.c 2025-09-04 10:33:26 +02:00
Ray
dd0587e12a Update shaders_texture_drawing.c 2025-09-04 10:33:22 +02:00
Ray
2e376c6f5b Update shaders_spotlight.c 2025-09-04 10:33:14 +02:00
Ray
48eac60171 REVIEWED: Potential issue with animated normals on OpenGL 1.1 2025-09-03 23:14:58 +02:00
Ray
2a295210fb Update shaders_spotlight.c 2025-09-03 19:58:38 +02:00
Ray
1008066644 Removed core_loading_thread project 2025-09-03 19:58:26 +02:00
Ray
a7e62e73d8 REXM: REMOVE: example: core_loading_thread
This example was POSIX only and had some special requirements for web, it made it more difficult to be managed from collection standard examples format.

It will be re-added in the `others` category, that is not processed for web.
2025-09-03 19:00:33 +02:00
Ray
5cbe013273 REXM: RENAME: example: models_skybox --> models_skybox_rendering 2025-09-03 18:48:20 +02:00
Ray
d8ee8a45c4 REXM: RENAME: example: textures_draw_tiled --> textures_tiled_drawing 2025-09-03 18:45:50 +02:00
Ray
33327760f1 REXM: RENAME: example: text_draw_3d --> text_3d_drawing 2025-09-03 18:43:17 +02:00
Ray
785ad4015c REXM: RENAME: example: textures_polygon --> textures_polygon_drawing 2025-09-03 18:40:53 +02:00
Ray
cadd28e5a0 REXM: RENAME: example: text_raylib_fonts -> text_sprite_fonts 2025-09-03 18:33:33 +02:00
Ray
2cb387b50a REVIEWED: Font atlas image generation, added some comments #5141 2025-09-03 18:30:00 +02:00
Ray
f53cd449ce Update config.h 2025-09-03 18:25:27 +02:00
b7eda8159c [build.zig] Make X11 the default display backend instead of choosing at runtime (#5168) 2025-09-03 18:17:07 +02:00
Ray
64d6a90d48 REXM: RENAME: example: text_unicode --> text_unicode_emojis 2025-09-03 18:14:47 +02:00
Ray
3a0c8009af Update rexm.c 2025-09-03 18:14:18 +02:00
Ray
d1768d387c Update utils.c 2025-09-03 13:37:08 +02:00
Ray
c579eef4b7 REVIEWED: Examples section comments, for better organization and consistency 2025-09-03 10:40:31 +02:00
Ray
1fa3c15942 Revert "add const qualifier to the first arg of TextJoin (#5166)"
This reverts commit 4e8d08523f.
2025-09-02 19:00:22 +02:00
4e8d08523f add const qualifier to the first arg of TextJoin (#5166)
* add const qualifier to the first arg of TextJoin

* Update raylib_api.* by CI

* Update raylib.h

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ray <raysan5@gmail.com>
2025-09-02 18:58:39 +02:00
Ray
cb6a64843c Remove raylib logs 2025-09-02 18:52:10 +02:00
Ray
4fa8e23efc Update rexm.c 2025-09-02 18:52:00 +02:00
Ray
1dfff2252d rexm update 2025-09-02 18:44:27 +02:00
Ray
cf61a8b888 REXM: Update examples report 2025-09-02 18:38:20 +02:00
Ray
bcd46fb36b Update rexm.c 2025-09-02 18:38:04 +02:00
Ray
9fab2c8a13 REVIEWED: example: text_unicode_ranges 2025-09-02 18:34:58 +02:00
Ray
0fd5a1a3f5 REDESIGNED: example: text_unicode_ranges 2025-09-02 17:47:25 +02:00
Ray
d5ea6a87d9 Merge branch 'master' of https://github.com/raysan5/raylib 2025-09-02 17:47:13 +02:00
17d9927a4f Update raylib_api.* by CI 2025-09-02 15:46:09 +00:00
Ray
b16d14f5ed Update text_font_sdf.c 2025-09-02 17:45:52 +02:00
Ray
29ce5d8aa9 WARNING: BREAKING: LoadFontData() redesigned, added parameter
This redesign is a big improvement on font loading time and memory requirements. It only loads glyphs available on font from requested codepoints and only processes those glyphs for packaging. When processing +10K codepoints (CJK), the loading time improves considerably.
2025-09-02 17:45:39 +02:00
Ray
aa475b1046 REVIEWED: Code sections description for consistency 2025-09-02 12:34:04 +02:00
Ray
8b3c68f8b5 Update core_random_sequence.c 2025-09-02 12:18:19 +02:00
Ray
8f32c502a7 REVIEWED: Code sections definition 2025-09-02 12:10:40 +02:00
Ray
b6ae380260 REVIEWED: Examples comments, consistent code sections 2025-09-02 12:10:16 +02:00
Ray
864459cbd2 Update core_3d_camera_fps.c 2025-09-01 20:59:37 +02:00
Ray
e18d167c8f REVIEWED: New examples added renaming, avoid duplicated .sln GUIDs 2025-09-01 20:47:59 +02:00
Ray
1777da9056 REVIEWED: Avoid realloc() calls, small security improvement 2025-09-01 20:37:23 +02:00
Ray
6226abb0d3 Merge branch 'master' of https://github.com/raysan5/raylib 2025-09-01 11:39:20 +02:00
Ray
708c1539e4 Update rtextures.c 2025-09-01 11:38:57 +02:00
917533224f Update raylib_api.* by CI 2025-09-01 09:27:38 +00:00
Ray
0a92c863c4 Reverted const codepoints to avoid warnings 2025-09-01 11:27:11 +02:00
Ray
12ce72c32d REVIEWED: ExportImage() 2025-09-01 11:24:53 +02:00
998a18b641 removed macro that does nothing (#5163) 2025-09-01 11:17:51 +02:00
223feca13a Update raylib_api.* by CI 2025-09-01 05:56:44 +00:00
7d07d21ee5 Update Camera3D.fovy description in raylib.h (#5164)
Previously stated it was the near plane width in orthographic, in actuality it's the height. The wording has been fixed, with added clarity that it's in world units so no conversion is needed.
2025-09-01 07:56:31 +02:00
Ray
82d65e110a Update build status badges 2025-08-31 12:22:50 +02:00
f61c2c504d [rcore][win32] Adding native win32 backend (#4869)
* win32 backend

* [rcore][win32] use SwapBuffers instead of wglSwapLayerBuffers

I don't understand OpenGL well enough to know the difference between
SwapBuffers and wglSwapLayerBuffers but the former seems to double
my FPS (from 2000 to about 4000 in core_vr_simulator).

* [rcore][win32] stop lying to the OS about when our window is updated

Instead of calling BeginPaint/EndPaint in WM_PAINT which signals to the
OS that our window content is updated, now when we encounter the WM_PAINT
message instead we return back to the raylib application which will
trigger it to render a new frame. We've replaced the call to BeginPaint
and EndPaint with a call to ValidateRect in SwapBuffers, which, means
we're now correctly telling the OS when our window content is actually
up-to-date.

Note that this doesn't fix the window content not being updated during
a window resize/move beacuse thos have their own message loop which
doesn't return early when it's time to paint.

* [rcore][win32] fallback to finding functions from opengl32.dll

* [rcore][win32] fixes from review/for gcc

* [rcore][win32] incorporate style conventions

* [rcore][win32] workaround unused function error SetupFramebuffer

* [rcore][win32] re-enable sanitize flags check for MSAA_4X

* [rcore][win32] more style changes and remove old DPI cases

Added some more missing spaces after conditional statements.  Also
made unsupported MSAA_4X an assert instead of an abort and also
removed dpi-aware cases for older OS's.  More changes would be needed
to support those OS versions, namely, removing the dependency
on shcore.

* [rcore][win32] fixes for compling with w64devkit without -DUNICODE

* Update build.zig

* Update build.zig

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-08-31 12:13:21 +02:00
Ray
ecf032fe4f REVIEW: Avoid warning on fgets() return value 2025-08-31 12:11:48 +02:00
d7f82aa7ae Update raylib_api.* by CI 2025-08-31 10:11:18 +00:00
Ray
edce3d41b2 REVERT: Making codepoints const, variable is used to generate list in case it was NULL 2025-08-31 12:11:03 +02:00
f2adb0272d Update raylib_api.* by CI 2025-08-31 09:39:29 +00:00
Ray
ecedf40da6 REVIEW: const for codepoints arrays passed to function #5159 2025-08-31 11:39:14 +02:00
fce888c0c0 changed function params formatting (#5160) 2025-08-31 11:34:39 +02:00
d9cb078299 FindNearestConnectorMode: prefer mode with smallest number of unused pixels (#5158)
Co-authored-by: Philipp Maierhoefer <particle@maierhoefer.net>
2025-08-31 11:34:05 +02:00
0d29d8d4b1 [build.zig]: a concrete approach to build for web with zig-build (#5157) 2025-08-31 11:32:19 +02:00
Ray
bbf884d7b3 Merge branch 'master' of https://github.com/raysan5/raylib 2025-08-29 21:32:34 +02:00
Ray
f0e49787cd minor tweak 2025-08-29 21:32:21 +02:00
0e73e0ea64 reviewed ALL non-external files to follow raylib's convention of no spaces around / or * (#5153) 2025-08-29 14:53:16 +02:00
507c85900f fix: [digital_clock] minute hand doesn't appear (#5151) 2025-08-28 22:32:41 +02:00
03617e0bdd Add raylib-ada to BINDINGS.md (#5150) 2025-08-28 22:31:39 +02:00
481daf2423 remove extra backslash in fix_win32_compatibility.h (#5148) 2025-08-28 22:30:25 +02:00
4a4997c615 fix unnecessary warnings in some files (#5152) 2025-08-28 22:28:56 +02:00
7103703313 Update raylib_api.* by CI 2025-08-26 08:17:48 +00:00
Ray
d2f6c4924c ADDED: [rtext] LoadTextLines()/UnloadTextLines() 2025-08-26 10:17:33 +02:00
Ray
ed3b5b2649 Update rexm.c 2025-08-26 09:23:18 +02:00
Ray
42abcb9492 Updated examples init window title 2025-08-26 00:36:32 +02:00
Ray
a72b4b177b Updated examples short description 2025-08-26 00:32:24 +02:00
Ray
a67b49498f Update rexm.c 2025-08-26 00:24:01 +02:00
Ray
3b16a72302 REXM: Allow building web examples locally on Windows platform 2025-08-25 21:23:30 +02:00
Ray
6343251857 Update rexm.c 2025-08-25 21:13:44 +02:00
Ray
60ac8f2a86 Renamed example 2025-08-25 21:11:37 +02:00
Ray
47db1da9ea REXM: RENAMED: example: core_3d_fps_controller to core_3d_camera_fps 2025-08-25 20:58:09 +02:00
Ray
8b68d548c9 Reviewing some examples titles 2025-08-25 20:57:18 +02:00
Ray
b04a94d1e1 Merge branch 'master' of https://github.com/raysan5/raylib 2025-08-25 20:56:20 +02:00
Ray
f9af011965 Update core_window_letterbox.c 2025-08-25 20:56:05 +02:00
99c4d4b597 Add pub to compileRaylib (#5143)
This is necessary to allow for using the function in dependent `build.zig`s.
2025-08-25 00:55:13 +02:00
Ray
79497e1c88 REXM: Updated reports 2025-08-24 12:02:24 +02:00
Ray
2e95cdb2b5 Minor comment tweaks 2025-08-24 12:01:58 +02:00
Ray
c9564c0de8 Update update_examples.yml 2025-08-24 12:01:46 +02:00
e796b00eb0 [workflows] (almost) rewrite update_examples.yml workflow (#5130)
* debug print the working directory

* trigger it on any branch (temporarily)

* nope, wrong fix

* dummy commit to trigger the workflow

* lets see if this works

* trigger the workflow when updating it

* nice typo

* add missing dollar signs

* debug list the contents of the repository

* dir/s instead of ls

* remove this, no longer needed

* backslashes maybe? windows...

* this should be a forward slash

* remove no longer needed spam

* debug check if examples dir exists

* LOG is disabled apparently

* ...

* temporarily disable this step to save time

* ubuntu maybe

* bash

* install deps

* link libc

* link libm

* now to test the rest

* emsdk is back

* add missing shaders

* Update examples collection

* add indentation

* remove emsdk cache

* ignore emsdk cache

* Update examples collection

* fix errors with the find command

* remove emsdk cache now

* i forgot to actually add it to gitignore

* fix error with git not finding anything to commit

* global config instead of repo specific

* clone raylib.com repo under the same owner as the raylib repo owner

* add proper access token

* reorganize it all

* remove non-existent example

* clone raylib.com before running rexm

* no extra slash

* Update examples collection

* copy updated examples to the right place

* remove unnecessary debug line from rexm.c

* Update examples collection

* Update examples collection

* use hardcoded absolute path to make

* add debug line

* semicolon

* fix wrong handling of make path

* fix wrong cwd

* rebuild raylib for web after installing it

* cleanuo

* conditionally push to repos, never on PR

* build rexm with make for consistency

* remove workflow run results

* add back the examples report files

* pause automatic commits

* revert makefile changes

* readd removed vs2022 project file

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-08-24 11:56:49 +02:00
Ray
04a3ab0ca7 REVIEW: Added warning in case of no [rcore] backend defined 2025-08-24 11:23:15 +02:00
Ray
52980c947d REVIEWED: [rtext] Provide more detailed info on glyphs failing to pack #5141 2025-08-24 11:07:55 +02:00
Ray
4d0c3affaa REXM: Update examples and lists 2025-08-24 10:53:47 +02:00
Ray
0e5837fb86 REXM: Fixed some issues, improved make call defining base path 2025-08-24 10:53:19 +02:00
Ray
f60333d9b2 Update update_examples.yml 2025-08-23 22:19:51 +02:00
Ray
785965fcef Update update_examples.yml 2025-08-23 22:18:17 +02:00
Ray
d0e6f60ef3 Update update_examples.yml 2025-08-23 22:13:18 +02:00
Ray
6c4f220e89 Update update_examples.yml 2025-08-23 22:07:39 +02:00
Ray
c95630b7d0 Update update_examples.yml 2025-08-23 22:00:06 +02:00
Ray
e9f655d002 Update update_examples.yml 2025-08-23 21:54:09 +02:00
Ray
41211b0c8c Update update_examples.yml 2025-08-23 21:45:50 +02:00
Ray
d320a029c8 REXM: Reviewed building, using default examples Makefile/Makefile.Web 2025-08-23 21:44:28 +02:00
Ray
f83c5cb6e1 Merge pull request #5138 from maiconpintoabreu/fix-glsl100
[examples][shaders] set glsl100 back to 100
2025-08-23 14:59:32 +02:00
69021939e6 fix write_depth.fs glsl120 2025-08-23 13:06:56 +01:00
Ray
9cc9f3bbbe Merge pull request #5139 from Siltnamis/stbtt_rl_malloc
use RL_MALLOC in stb_truetype
2025-08-23 13:07:04 +02:00
3c9c66e72b use RL_MALLOC in stb_truetype 2025-08-23 13:10:27 +03:00
c6d7694286 set glsl100 back to 100 2025-08-23 10:17:11 +01:00
Ray
11bf3996cf REDM: Add web metadata validation and update 2025-08-23 02:00:21 +02:00
Ray
a7aeb2f2b5 REXM: Add example build option 2025-08-23 01:59:24 +02:00
Ray
500494f791 Update core_3d_fps_controller.c 2025-08-23 00:02:19 +02:00
Ray
1d17be6c1c Merge pull request #5137 from feive7/master
Clamp camera pitch
2025-08-22 23:41:34 +02:00
Ray
ce1cd0d7e6 Merge pull request #5128 from CashWasabi/zig-0.15
[build] Update `build.zig` (breaking)
2025-08-22 08:19:35 +02:00
566eb34ff8 Update build.zig 2025-08-21 23:15:05 +02:00
8b0cbb6f47 Clamp camera pitch 2025-08-21 11:10:13 -07:00
Ray
ce8bcb332b Using internal defined File*() functions 2025-08-21 19:37:59 +02:00
Ray
fc082edccc Merge branch 'master' of https://github.com/raysan5/raylib 2025-08-21 19:37:10 +02:00
Ray
4e71e91a4a REXM: Replace example name on project file 2025-08-21 19:30:44 +02:00
Ray
18c50bb01b Merge pull request #5136 from alexander-nichols/fix-shader_normal_map-solution
[build] Fixed VS2022 broken build
2025-08-21 19:29:15 +02:00
Ray
09bd2df17b Merge pull request #5133 from rossberg/patch-1
[raudio] Properly close FLAC in UnloadMusicStream
2025-08-21 19:24:05 +02:00
Ray
0aa5e8169d Merge pull request #5132 from maiconpintoabreu/fix-examples
[examples][core] refactoring core_input_mouse.c to use IsCursorHidden function for consistency
2025-08-21 19:23:15 +02:00
5d9c8c365e [build] Fixed VS2022 broken build
Fixed bad references to shaders_normalmap in the project raylib\projects\VS2022\examples\shaders_normal_map.vcxproj

Changed GUID for shaders_normal_map as it coincided with that for core_3d_fps_controller {6B1A933E-71B8-4C1F-9E79-02D98830E671}
2025-08-21 17:42:07 +01:00
2deae294c6 [raudio] Properly close FLAC in UnloadMusicStream
Fix  raysan5/raylib#5131.
2025-08-21 13:02:19 +02:00
238163c6ca swap local variable isCursorHidden to use new method IsCursorHidden() 2025-08-21 11:31:40 +01:00
Ray
99cb82a82c REVIEWED: [rmodels] LoadGLFT(), avoid loading attributes already loaded, issue a warning. FIX: #4996 2025-08-20 16:39:45 +02:00
Ray
c3c33e9654 Merge pull request #5125 from JohnnyCena123/missing-vox-shaders
add missing shaders for glsl100, glsl120
2025-08-20 12:34:05 +02:00
a99649b455 remove unneeded checks 2025-08-20 12:18:51 +02:00
df200b942c add versions to new shaders 2025-08-20 12:16:57 +02:00
cb05945e76 add missing shaders 2025-08-20 12:09:30 +02:00
Ray
5b88e4fe5f Merge pull request #5124 from JeffM2501/fix_win32_compatibility
[utility] Add helper header to fix compatibility with windows.h
2025-08-19 20:18:00 +02:00
15baf176b2 Add a utility header to external that undefines the parts of windows that conflict with raylib, allowing raylib functions to run unimpeded 2025-08-19 10:39:38 -07:00
Ray
d9392b94c4 Merge pull request #5123 from JeffM2501/clean_sound_alias
[raudio] Initialize sound alias properties as if it was a new sound
2025-08-19 17:26:51 +02:00
572230c8ad Initialize sound alias properties as if it was a new sound 2025-08-19 08:16:20 -07:00
Ray
fd44c26584 Merge pull request #5122 from JohnnyCena123/workflow-typo
fix typo in workflow name
2025-08-19 13:26:28 +02:00
Ray
0658abc64c Update text_raylib_fonts.c 2025-08-19 13:22:15 +02:00
Ray
8ba4ff2143 Renamed directory for sprite fonts 2025-08-19 13:22:04 +02:00
Ray
25d00130a8 REVIEWED: example: text_unicode_ranges 2025-08-19 13:17:50 +02:00
01c68d7e75 fix typo in workflow name 2025-08-19 12:30:07 +02:00
Ray
291042352b Merge pull request #4886 from GuvaCode/master
[examples] Possible improvements for `text_codepoints_loading`, adding ranges
2025-08-19 12:00:25 +02:00
Ray
44207b293e RENAMED: GitHub Actions files, clearer naming 2025-08-19 11:54:32 +02:00
Ray
8562841c63 Update linux_examples.yml 2025-08-19 11:51:57 +02:00
Ray
f1796ff143 Update examples_update.yml 2025-08-19 11:50:41 +02:00
Ray
4492707e0e Update webassembly.yml 2025-08-19 11:50:38 +02:00
Ray
e3d714ae41 Update GitHub Actions names 2025-08-19 11:45:19 +02:00
Ray
df886a8abb REXM: Added VS2022 project for GitHub Actions building 2025-08-19 11:38:29 +02:00
Ray
915c02adf3 Update examples_update.yml 2025-08-19 11:20:38 +02:00
Ray
f0471aaddb Update examples_update.yml 2025-08-19 11:20:19 +02:00
Ray
e38e7a8141 Update examples_update.yml 2025-08-19 11:18:38 +02:00
Ray
df1244688e Revert "Update examples collection"
This reverts commit 87d3066428.
2025-08-19 11:17:59 +02:00
87d3066428 Update examples collection 2025-08-19 09:15:28 +00:00
Ray
8bc9f30d87 Update examples_update.yml 2025-08-19 11:14:04 +02:00
Ray
e9b1bb25ab Create examples_update.yml 2025-08-19 11:02:01 +02:00
Ray
304045c63a REXM: Allow external path definition for VS solution file 2025-08-19 11:00:22 +02:00
Ray
a3da39cd81 REXM: Store example resource paths, could be useful... 2025-08-19 10:38:07 +02:00
Ray
87731e3db4 Create rexm.rc.data 2025-08-19 10:36:59 +02:00
Ray
cf1217f5c1 Update Makefile 2025-08-19 10:36:56 +02:00
Ray
a338b9694c Update build_example_web.bat 2025-08-19 10:36:31 +02:00
Ray
1098f41885 Update parse.yml 2025-08-19 10:36:22 +02:00
Ray
b1f6ab38b5 Merge pull request #5119 from jan-beukes/master
Fix SDL3 compilation error with gcc
2025-08-18 20:43:11 +02:00
Ray
595befec40 Update models_mesh_picking.c 2025-08-18 20:37:07 +02:00
Ray
0a513e6fbe Comment unused script instructions... 2025-08-18 15:04:50 +02:00
Ray
60b46062c6 REXM: Reviewed example rename on examples.js 2025-08-18 15:00:54 +02:00
Ray
6bf8249f75 Update examples_report.md 2025-08-18 15:00:24 +02:00
Ray
a8dfd9db76 REXM: RENAMED: shaders_normalmap --> shaders_normal_map 2025-08-18 14:35:04 +02:00
8772b0287c Fix SDL3 compilation error with gcc 2025-08-17 23:44:37 +02:00
Ray
284d9ddd89 Merge pull request #5118 from slendidev/sdl3fixes
Fix SDL3 build if using package
2025-08-17 21:35:35 +02:00
Ray
dcd012e00f REXM: Generate second report with examples with issues 2025-08-17 21:32:05 +02:00
Ray
24d1d64417 REXM: REVIEWED: ScanExampleResources() avoid resources to be saved by the program 2025-08-17 21:31:05 +02:00
Ray
6da0a180e6 REXM: Using Makefile.Web for specific web versions generation, only with required resources for every example 2025-08-17 21:30:16 +02:00
16bd18070f Fix SDL3 build if using package 2025-08-17 11:11:54 +03:00
Ray
0dc4ba53dc Minor format tweak 2025-08-16 21:06:13 +02:00
Ray
e4dfb6dbb5 Update rl_gputex.h 2025-08-16 20:24:54 +02:00
Ray
2e652bbef1 Merge pull request #5115 from maiconpintoabreu/web_resizable_window_mouse_issue
[rcore][web] Work around to fix mouse positioning on scaled window
2025-08-15 12:51:15 +02:00
Ray
5236b2420a Update rexm.c 2025-08-15 12:43:45 +02:00
73950befca Work around to fix mouse positioning on scaled window 2025-08-15 10:57:44 +01:00
Ray
d1b535c7b8 Merge branch 'master' of https://github.com/raysan5/raylib 2025-08-14 21:23:08 +02:00
Ray
ed06cdbbe4 Update examples_report.md 2025-08-14 21:22:57 +02:00
Ray
81615a91a6 Merge pull request #5111 from didas72/master
Adds more filters for conditional build of GetWindowHandle with GLFW
2025-08-14 21:13:27 +02:00
Ray
6252d92f79 Update rexm.c 2025-08-14 21:11:30 +02:00
Ray
a65bdd6cca REXM: Reviewed automatic validation and update -WIP- 2025-08-14 21:07:36 +02:00
Ray
afdc7972d6 REXM: Automatic validation and update of examples 2025-08-14 21:07:10 +02:00
3ef5ee878c Adjusted formatting to comply with contribution guidelines 2025-08-14 19:58:22 +01:00
Ray
28b804a6ba REXM: Validate examples list against existing examples in repo 2025-08-14 20:38:27 +02:00
Ray
7037f131dc REVIEWED: example: core_3d_fps_controller 2025-08-14 20:37:52 +02:00
Ray
a9970484f3 Remove trailing spaces 2025-08-14 20:37:18 +02:00
Ray
be974bb67e Update CONVENTIONS.md 2025-08-14 20:36:08 +02:00
eae1296b08 Fixed bad macro logic 2025-08-14 18:56:31 +01:00
59c979a59d Added suggestions by planetis-m 2025-08-14 18:46:45 +01:00
93f86fa074 fixes #5110
Adds more filters for conditional build of GetWindowHandle with glfw
2025-08-14 14:30:29 +01:00
Ray
3c9d3d9bef REXM: REVIEWED: Update examples status report when examples Updated 2025-08-13 23:54:44 +02:00
Ray
f0131f6ee6 Added missing project to solution 2025-08-13 23:53:35 +02:00
Ray
b17f00b6d9 REXM: Avoid external tool for UUIDv4 generation, implement custom function 2025-08-13 13:25:27 +02:00
Ray
ddebf5d7ac Update Makefile.Web 2025-08-13 12:34:55 +02:00
Ray
a7e66df56d Using define for buffers size 2025-08-13 12:33:38 +02:00
Ray
800be084b6 REXM: Implemented AddVSProjectToSolution() 2025-08-13 12:33:12 +02:00
Ray
ef81145776 Update examples_list.txt 2025-08-13 11:35:23 +02:00
Ray
74339d2008 REVIEWED: IsFileExtension() 2025-08-13 10:43:33 +02:00
Ray
8c7b3b7323 Update examples_report.md 2025-08-13 10:38:04 +02:00
Ray
601091b69e Update raylib.sln 2025-08-13 09:56:22 +02:00
Ray
388bc5075e Update raylib.sln 2025-08-13 08:56:50 +02:00
Ray
b7265c3df1 Update rexm.ico 2025-08-13 08:24:57 +02:00
Ray
cd1c206676 Update rl_gputex.h 2025-08-13 08:22:00 +02:00
Ray
76284f1a16 Corrected typo 2025-08-13 08:13:18 +02:00
Ray
dd19b8d2c2 REVIEWED: Requested window flags application after window initialization 2025-08-12 11:44:20 +02:00
Ray
195b968b86 Merge pull request #4837 from Andersama/support_all_window_flags_at_initialization
[rcore] Support window flags with initialization issues
2025-08-12 11:38:22 +02:00
Ray
95e4494cfe ADDED: cursorLocked variable and review required code #4940 #4955 2025-08-12 11:33:58 +02:00
Ray
c4414fa1ed Revert "Merge pull request #4945 from Moros1138/master"
This reverts commit bab234a160, reversing
changes made to 13e384ce71.
2025-08-12 10:58:56 +02:00
Ray
bab234a160 Merge pull request #4945 from Moros1138/master
[rcore][web] Review resizable canvas on `FLAG_WINDOW_RESIZABLE`
2025-08-12 10:31:12 +02:00
Ray
db2abfb9be Merge branch 'master' into master 2025-08-12 10:28:52 +02:00
Ray
13e384ce71 Merge pull request #5004 from nezvers/example_quake_controller
[examples] New example: `core_3d_fps_controller`
2025-08-12 09:54:23 +02:00
Ray
9aa1b86fdf Merge pull request #5109 from maiconpintoabreu/julia_set
[examples] Increasing julia_set maxInterations glsl100 to 255
2025-08-11 20:26:24 +02:00
Ray
503e6d8bb5 Merge branch 'master' into julia_set 2025-08-11 20:26:16 +02:00
Ray
9b598f6bcf REVIEWED: Shaders formating to follow raylib code conventions 2025-08-11 20:22:31 +02:00
Ray
8dae39fbda ADDED: Missing GLSL120 shaders 2025-08-11 20:22:02 +02:00
00f7121b1c Increasing maxInterations glsl100 to 255 to match with glsl330 and add glsl120 2025-08-11 18:16:00 +01:00
Ray
705ce45a33 FIX: Added callback broke keyboard input on web... #5107 2025-08-10 19:59:33 +02:00
Ray
9ff8862826 Merge pull request #5108 from lassade/fix-qoa-music-from-mem
fix: QOA when using with LoadMusicStreamFromMemory
2025-08-10 19:27:08 +02:00
71b7734ce4 fix: QOA when using with LoadMusicStreamFromMemory, reduced the number of allocs and memcpy 2025-08-10 10:05:03 -03:00
Ray
e17e0933af Merge pull request #5104 from matthijskooijman/fix-ssh-backspace
Fix backspace key in Rpi SSH keyboard
2025-08-10 13:22:06 +02:00
Ray
27d7e61f28 Update rexm.c 2025-08-10 09:54:45 +02:00
9582d25217 Fix backspace key in Rpi SSH keyboard
There was a typo in the generated keycode.
2025-08-09 21:04:09 +02:00
Ray
852c51343d Merge pull request #5103 from Not-Nik/raylib-zig-update
Update raylib-zig in BINDINGS.md
2025-08-09 19:08:17 +02:00
7bc22f71bd Update raylib-zig in BINDINGS.md 2025-08-09 19:04:00 +02:00
60826855c4 Update raylib_api.* by CI 2025-08-08 21:09:03 +00:00
Ray
5daeffd91b Update parse.yml 2025-08-08 23:08:42 +02:00
Ray
e11bf1c978 Update Makefile 2025-08-08 23:07:08 +02:00
Ray
c6241b91a2 REVIEWED: IsFileExtension() to avoid other modules dependency #5071 2025-08-08 23:01:04 +02:00
Ray
f73b04c42c REXM: Copy examples web-build files to raylib.com 2025-08-08 21:54:15 +02:00
Ray
d6f9988e82 Update Makefile 2025-08-08 13:52:56 +02:00
Ray
c2f2878575 Merge pull request #5099 from JohnnyCena123/raysan-typo
fix typo in 'Ramon Santamaria'
2025-08-08 07:16:07 +02:00
c25e9f641d fix typo in 'Ramon Santamaria' 2025-08-08 03:04:33 +03:00
Ray
17aec580f8 Merge pull request #5096 from wileyanderssen/master
removed unneeded comma
2025-08-07 19:01:53 +02:00
c6171d339c removed unneeded comma
hope this gets merged
2025-08-07 19:55:46 +03:00
Ray
df40357f19 Update linux.yml 2025-08-07 18:37:11 +02:00
Ray
570082deba WARNING: **NEW** raylib code CONVENTION: Comments do not end with '.' 2025-08-07 18:23:20 +02:00
Ray
6792e6e2dd Updated required files for new example: shaders_normalmap 2025-08-07 17:50:18 +02:00
Ray
2365ac8def REVIEWED: Example shaders_normalmap #5032 2025-08-07 17:31:11 +02:00
Ray
54473e2c2b REVIEWED: Example shaders_normalmap, it crashes #5032 2025-08-07 17:28:25 +02:00
Ray
47d1cc200d Merge branch 'master' of https://github.com/raysan5/raylib 2025-08-07 17:19:39 +02:00
Ray
8da4887c2d Update examples_list.txt 2025-08-07 17:19:27 +02:00
Ray
ea3932949c Merge pull request #5032 from Sir-Irk/normalmap_example
[examples] New example: `shaders_normalmap`
2025-08-07 17:17:29 +02:00
Ray
a06962ee38 Merge branch 'master' into normalmap_example 2025-08-07 17:17:12 +02:00
Ray
c19c6fc6e0 Merge pull request #5093 from maiconpintoabreu/check-newname-category
[remx] Add check for category on new name
2025-08-07 17:14:45 +02:00
Ray
948b48430d Merge pull request #5092 from maiconpintoabreu/fix-rename-missing-newname
[remx] Add warning for missing new name to avoid segmentation fault
2025-08-07 17:13:27 +02:00
Ray
881c68e323 Merge pull request #5091 from Auios/patch-2
fix: buffer overflow in jar_mod.h memcopy
2025-08-07 17:13:00 +02:00
Ray
ca61b8d555 Merge pull request #5090 from Auios/patch-1
Remove binding link for https://github.com/Rabios/raylib-v7
2025-08-07 17:09:20 +02:00
Ray
f0889a74fe EXAMPLES: Format tweaks 2025-08-07 17:08:22 +02:00
Ray
9f07cfe0b7 Update textures_image_kernel.c 2025-08-07 17:08:02 +02:00
Ray
f02c7fca8a Update shapes_double_pendulum.c 2025-08-07 17:07:45 +02:00
Ray
d45b00b191 Update shaders_rounded_rectangle.c 2025-08-07 17:07:26 +02:00
Ray
7e597dd574 Update rlgl_compute_shader.c 2025-08-07 17:07:10 +02:00
Ray
9003cd32ba Update models_rlgl_solar_system.c 2025-08-07 17:06:50 +02:00
Ray
366887b863 Update models_loading_vox.c 2025-08-07 17:06:39 +02:00
Ray
64fbf07e7b Update audio_sound_multi.c 2025-08-07 17:06:11 +02:00
Ray
5d4a233f52 Update examples_template.c 2025-08-07 17:05:57 +02:00
Ray
fd79b44920 Create distortion.fs 2025-08-07 17:05:50 +02:00
Ray
5eacc872c7 Update README.md 2025-08-07 17:05:45 +02:00
Ray
1fadc67fb3 ADDED: Missing resources on some examples 2025-08-07 17:05:25 +02:00
Ray
ff1087480c ADDED: New projects to VS2022 solution 2025-08-07 17:04:49 +02:00
Ray
c91c185221 Update examples_report.md 2025-08-07 17:04:22 +02:00
Ray
89e6ed2697 REXM: Reviewed VS project adding to solution, no tool to do it! -WIP- 2025-08-07 17:03:54 +02:00
fa5560881e Check for category on new name 2025-08-07 12:39:12 +01:00
36dc70443a Add warning for missing new name to avoid segmentation fault 2025-08-07 12:01:21 +01:00
1c2ecfd6ab fix: buffer overflow in jar_mod.h memcopy 2025-08-06 23:13:05 -04:00
5dc304b5a7 Remove binding link for https://github.com/Rabios/raylib-v7
This repo (and user) does not exist. Remove it.
2025-08-06 22:41:37 -04:00
Ray
a6f29e4f19 Update examples_report.md 2025-08-06 18:42:33 +02:00
Ray
b3513e4719 ADDED: Missing example VS2022 projects 2025-08-06 18:42:27 +02:00
Ray
c3a4217148 Update rexm.c 2025-08-06 18:25:58 +02:00
Ray
533f06109d Update README.md 2025-08-06 18:23:42 +02:00
Ray
c6f8f06f7e Update rexm.c 2025-08-06 18:20:34 +02:00
Ray
f64d405ef3 Update Makefile.Web 2025-08-06 18:18:39 +02:00
Ray
c477c68419 REXM: Automatically fix not found VS2022 project / solution 2025-08-06 18:14:52 +02:00
Ray
2878f7db22 Create examples_report.md 2025-08-06 15:43:15 +02:00
Ray
8bc1d62e88 REXM: Added legend info to report 2025-08-06 15:43:13 +02:00
Ray
59546eb54a REXM: Support examples data validation and **report generation** 2025-08-06 14:04:30 +02:00
Ray
c95fd5a803 REXM: Support paths customization with environment variables 2025-08-06 14:03:32 +02:00
Ray
c3cad65d30 Update examples_list.txt 2025-08-06 14:02:51 +02:00
Ray
095319602c REVIEWED: Compule for OpenGL 1.1 #5088 2025-08-06 13:09:56 +02:00
Ray
68a1190bf2 REXM: ADDED: Examples validation 2025-08-06 00:56:29 +02:00
Ray
64921e2d8a Merge pull request #5086 from maiconpintoabreu/ignore-compiled-rexm
[rexm] Add compiled rexm to gitignore
2025-08-05 13:18:20 +02:00
81eb48cad8 Add compiled rexm to gitignore 2025-08-05 11:44:41 +01:00
Ray
f306685469 Update rexm.c 2025-08-05 12:38:30 +02:00
Ray
99a43457e8 REXM: ADDED: Command; update to validate+update required files 2025-08-05 12:38:11 +02:00
Ray
90cf6a18da REXM: Renamed some variables 2025-08-05 12:37:11 +02:00
Ray
1f2b5d6282 Update examples_template.c 2025-08-05 10:04:54 +02:00
Ray
7b93591676 Added some notes to avoid platform-dependant .BAT scripts 2025-08-05 09:54:51 +02:00
Ray
02992ce63b UPDATE: Get example info from example header when added, to be added to collection 2025-08-05 09:54:17 +02:00
Ray
b683af298c Update examples_template.c 2025-08-05 09:40:01 +02:00
Ray
cdbe9d75ef Merge pull request #5085 from Not-Nik/culling_consistency
Make culling distances consistent across raylib
2025-08-05 00:45:47 +02:00
7267c1c8a1 Make culling distances consistent across raylib 2025-08-05 00:15:52 +02:00
Ray
e09c9ce281 Minor tweaks 2025-08-04 23:36:07 +02:00
Ray
945f1410d2 MOVED: rexm to tools directory 2025-08-04 23:24:43 +02:00
Ray
f5e95029b1 Update rexm.c 2025-08-04 20:44:22 +02:00
Ray
47c186dd87 WARNING: **BREAKING**: Moved raylib parser to tools/parser directory 2025-08-04 20:26:19 +02:00
Ray
cdfb9d7a0b Added some notes for example collection validation 2025-08-04 19:29:28 +02:00
Ray
a436d935f1 Update README.md 2025-08-04 19:28:07 +02:00
Ray
1293461f5e REXM: Some code reviews, README.md generation improvements 2025-08-04 19:27:48 +02:00
Ray
a457ab154e ADDED: Example resources for automatic removal
WARNING: Some of those resources could be shared by other examples in the category so for now we leave removed manual by users...
2025-08-04 18:11:57 +02:00
Ray
1f5fec851d UPDATE: Added Makefile.Web per-example target generation including used resources 2025-08-04 17:52:22 +02:00
Ray
bc0f93baea UPDATE: Added resources scanning from examples for automated copying 2025-08-04 17:51:48 +02:00
Ray
e130775e0d Updated for resources scanning system 2025-08-04 14:13:17 +02:00
Ray
80dd72ce12 REVIEWED: For automation simplification 2025-08-04 13:23:57 +02:00
Ray
d8952958db Update Makefile 2025-08-04 13:23:14 +02:00
Ray
72de562542 REVIEWED: Examples for automation processes 2025-08-04 13:23:04 +02:00
Ray
d43470a3d4 Minor comment reviews 2025-08-03 23:49:52 +02:00
Ray
d182ae7837 UPDATED: Support example removal 2025-08-03 23:32:54 +02:00
Ray
b11d089202 UPDATED: Implementing file rename requirements
Moved files update from collection to separate function
2025-08-03 22:56:15 +02:00
Ray
d194b8d503 ADDED: Some security checks to verify examples categories provided 2025-08-03 21:20:35 +02:00
Ray
8f8a5ada60 REVIEWED: Make sure environment is set in same process and not a child one 2025-08-03 21:19:55 +02:00
Ray
b4ecfb648d Merge pull request #5084 from kariem2k/fix_cmake_sdl3
Removed verbose logging on SDL3.
2025-08-03 19:53:53 +02:00
603219d6d6 Removed verbose logging on SDL3. Happens every time the property is read! 2025-08-03 18:48:24 +01:00
Ray
c146be16cb Update rexm.c 2025-08-03 09:43:38 +02:00
Ray
6ddc9251c2 UPDATE: README.md example addition working 2025-08-03 01:18:19 +02:00
Ray
73baaeeb2e REVIEWED: LoadTextLines() 2025-08-03 01:17:50 +02:00
Ray
361e730f83 Merge pull request #5083 from JeffM2501/obj_double_load
[rModels] Don't Double Upload Meshes in LoadObj,
2025-08-03 00:29:20 +02:00
ffe76a4b67 Don't Upload Meshes in LoadObj, LoadModel will upload them. None of the other interchange format readers upload 2025-08-02 14:58:05 -07:00
Ray
1948453394 Update README.md 2025-08-02 20:11:31 +02:00
Ray
b044b52955 UPDATED: examples.js example addition working 2025-08-02 19:43:27 +02:00
Ray
528ad4964d UPDATE: Makefile example addition working 2025-08-02 19:21:36 +02:00
Ray
e76c5f7d64 Update rexm.c 2025-08-02 18:11:30 +02:00
Ray
0533987f80 Merge branch 'master' of https://github.com/raysan5/raylib 2025-08-02 18:01:32 +02:00
Ray
e01f3f158e Remove some testing code 2025-08-02 18:01:23 +02:00
42619ea2df Update raylib_api.* by CI 2025-08-02 16:01:00 +00:00
Ray
c60763d19e UPDATED: LoadExamplesData() to support filtering and sorting 2025-08-02 18:00:41 +02:00
Ray
1c8eef9b0b Update raylib and generate ARM64 libraries for Windows, Linux, macOS 2025-08-02 17:59:34 +02:00
Ray
d3fe9e5036 Merge branch 'master' of https://github.com/raysan5/raylib 2025-08-02 17:58:47 +02:00
Ray
159a9eac4a Update build_example_web.bat 2025-08-02 17:58:44 +02:00
Ray
c4d733e864 Merge pull request #5082 from JeffM2501/render_target_size
[CORE} Make GetRenderWidth/Height return the FBO size if one is active
2025-08-02 17:40:37 +02:00
bf536d68e1 Make GetRenderWidth and GetREnderHeight return the FBO size if one is active. 2025-08-02 08:37:11 -07:00
Ray
b01c8a7a90 UPDATE: Implementing examples commands -WIP- 2025-08-02 00:36:17 +02:00
Ray
a36905607c Update linux.yml 2025-08-01 20:19:35 +02:00
Ray
3e65b23f89 Update windows.yml 2025-08-01 20:10:35 +02:00
Ray
8adccfd521 Update windows.yml 2025-08-01 20:09:49 +02:00
Ray
fde3166e6a Merge pull request #5075 from killerdevildog/add-linux-arm64-builds
[build] Add ARM64 support to Linux builds
2025-08-01 20:07:56 +02:00
Ray
9477838193 ADDED: Some useful functions for examples info loading, using examples_list 2025-08-01 19:40:44 +02:00
Ray
cb91c02bea Merge branch 'master' of https://github.com/raysan5/raylib 2025-08-01 19:40:25 +02:00
Ray
a872de82ed Create examples_list, to be used by rexm or other tools for reference
NOTE: This file should be the source of truth for raylib examples collection, everything will be generated using this file as primary reference.
2025-08-01 19:39:30 +02:00
9d07be6bde Update raylib_api.* by CI 2025-08-01 17:38:20 +00:00
Ray
234f4b2b10 Update raylib.h 2025-08-01 19:38:02 +02:00
Ray
10079e4e65 Reviewed minor formating issues 2025-08-01 18:58:24 +02:00
Ray
6b0174d034 REVIEWED: Examples Makefile to locate examples list: #EXAMPLES_LIST_* 2025-08-01 18:58:05 +02:00
Ray
9fa53aac6f Update examples_template.c 2025-08-01 18:56:54 +02:00
Ray
43bc00379c removed trailing spaces 2025-08-01 10:26:28 +02:00
Ray
ba798e9155 Merge pull request #5079 from zet23t/fixing-obj-loader-crash
[rmodels] Fixing OBJ loading crash when there are no normals present
2025-08-01 08:57:55 +02:00
121c996c6e fixing OBJ loading crash when there are no normals present 2025-08-01 08:49:48 +02:00
Ray
e7bd177826 Merge pull request #5077 from lpow100/master
Added certain variable assigment to the rename option and fixed some arugment based logs
2025-08-01 01:27:43 +02:00
65e3d67eb9 Merge branch 'master' of https://github.com/raysan5/raylib 2025-07-31 16:16:10 -07:00
58e3c8604a Added setup for the rename command (NOT TESTED) 2025-07-31 16:16:07 -07:00
Ray
e0b58b7eee Update rexm.c 2025-08-01 01:08:31 +02:00
Ray
d88f27f08d NEW: ADDED: rexm - A simple command-line tool to manage raylib examples -WIP- 2025-08-01 00:30:01 +02:00
Ray
4b2654f851 Create examples_template.png 2025-07-31 23:55:50 +02:00
Ray
968385b5f4 Update examples_template.c 2025-07-31 23:55:46 +02:00
Ray
38ff5d00a0 Create build_example_web.bat 2025-07-31 23:55:26 +02:00
11ccf11814 [build] Add ARM64 support to Linux builds
- Add ubuntu-24.04-arm runner for native ARM64 compilation
- Support building both static and shared libraries for ARM64
- Maintain backwards compatibility with existing x86/x64 builds
- Addresses issue #5051 for ARM64 pre-compiled binaries

Expected output: raylib-X.X-linux_arm64.tar.gz in releases
2025-07-30 22:40:54 -06:00
Ray
305c7a2ef9 Merge pull request #5073 from Luca-coder07/master
[examples] Add screenshot for core_basic_window_web
2025-07-31 00:26:26 +02:00
b273ba930b Add screenshot for core_basic_window_web
The veritable screenshot is this
2025-07-31 01:05:00 +03:00
756203581e Merge branch 'raysan5:master' into master 2025-07-31 01:00:02 +03:00
Ray
50acba3ce8 REVIEWED: rcore_web, cleaning and reorganizing 2025-07-30 17:31:49 +02:00
Ray
18ae6a377c Merge pull request #4956 from Moros1138/consume-keyboard-events
[rcore][web] Add `EmscriptenKeyboardCallback()` to consume key events
2025-07-30 17:03:10 +02:00
e662ac80d5 Merge branch 'raysan5:master' into master 2025-07-30 17:37:15 +03:00
Ray
12f0943bd9 Update rcore.c 2025-07-30 16:07:14 +02:00
Ray
b40e53f11c Remove double line spacing 2025-07-30 16:07:08 +02:00
Ray
414235dd17 Update shaders_multi_sample2d.c 2025-07-30 16:06:43 +02:00
37104195b4 add screenshot core_basic_window_web
There are no screenshot for this and the alt is seen
2025-07-30 16:54:06 +03:00
Ray
138010c1eb Merge branch 'master' of https://github.com/raysan5/raylib 2025-07-28 23:38:00 +02:00
Ray
5ca6bff8ca Update rl_gputex.h 2025-07-28 23:37:48 +02:00
Ray
70daf39eaf Merge pull request #5066 from lepasona/master
[glfw] Update `mappings.h`
2025-07-27 21:23:53 +02:00
Ray
47df461047 Merge pull request #5068 from lepasona/patch-1
[examples] typo: hardcoded gamepad ids in `core_input_gamepad.c`
2025-07-27 21:22:37 +02:00
b230720842 example core_input_gamepad.c: fix hardcoded gamepad 0 2025-07-27 14:35:38 +00:00
1da6b281de Update glfw mappings.h 2025-07-27 07:37:07 +00:00
Ray
1fc0b4955f REVIEWED: rl_gputex.h, added some info for future improvements 2025-07-26 13:36:03 +02:00
Ray
eb7f8912f8 Minor format tweaks 2025-07-26 12:50:29 +02:00
Ray
8343aed4f6 Avoid fatal errors on OBJ model loading 2025-07-26 12:50:12 +02:00
Ray
c9f9219fa6 REVIEWED: DRM cache buffers support #4988 2025-07-26 12:49:49 +02:00
Ray
5c680739bd Removed platform-specific flag from config.h #4988 2025-07-26 12:49:03 +02:00
Ray
86d9afc10c Merge pull request #4988 from rob-bits/master
[rcore][drm] Replace DRM swap buffer implementation with asynchronous page-flipping and triple framebuffer caching
2025-07-26 12:14:21 +02:00
Ray
715e174d13 Merge pull request #5062 from danilwhale/feat/get-proc-address
[rlgl] Add rlGetProcAddress
2025-07-26 12:07:43 +02:00
Ray
7262be85fd Minor format tweaks 2025-07-26 12:06:24 +02:00
Ray
4da399141a Merge pull request #5063 from kariem2k/fix_cmake_sdl3
Fixed: CMake support for SDL3
2025-07-26 11:49:05 +02:00
Ray
d7893141f3 REVIEWED: rl_gputex.h library to be usable standalone 2025-07-26 11:44:36 +02:00
Ray
94d8d7133b Merge pull request #5045 from sleeptightAnsiC/fix_gputex_logging
[rl_gputex] fix: decouple logging and memory allocation from Raylib
2025-07-26 11:25:58 +02:00
32960af1dc Fixed:
Added CMake support for SDL3.
Now supports including SDL2 or SDL3 as a subdirectory within the project. The system will first check for SDL3, then SDL2. If neither is found, it will attempt find_package(SDL3), followed by find_package(SDL2). If all these checks fail, the process will terminate with an error.
2025-07-24 09:48:52 +01:00
Ray
9a042bc9ad Merge pull request #5061 from myQwil/zig_manual_module
[build][zig] use `addLibrary()` and set root modules manually
2025-07-23 22:13:29 +02:00
d6a897e551 [rlgl]: Add rlGetProcAddress 2025-07-23 21:41:45 +03:00
dfa21c2d1f [build][zig] use addLibrary() and set root modules manually
These changes will be required by Zig version 0.15.0.
2025-07-23 11:56:58 -04:00
Ray
5434ae1100 Merge pull request #5057 from Joecheong2006/example-double-pendulum
[examples]: New example: `shapes_double_pendulum`
2025-07-22 21:01:31 +02:00
10fadd9185 Replaced scalar to float 2025-07-22 11:59:46 -07:00
b6ae5af4e3 Removed redefined RAD and DEG 2025-07-22 11:57:16 -07:00
8a0ab163d3 Changed to 4 spaces 2025-07-22 11:50:48 -07:00
f3854cb406 Fixed typo 2025-07-22 11:39:24 -07:00
f1714a6234 [examples]: New shapes example - double pendulum 2025-07-21 14:59:51 -07:00
Ray
7b017b60d9 Move global variable to right code section 2025-07-21 10:57:21 +02:00
Ray
dedf382f64 Merge pull request #5053 from didas72/master
[rcore][linux] Fixes GetWindowHandle returning a bad handle under Linux X11
2025-07-20 21:23:32 +02:00
36364192d5 Fixes GetWindowHandle returning a bad handle under Linux X11 2025-07-19 22:29:08 +01:00
Ray
9b6c09c32f Merge pull request #5049 from wwderw/master
[build] Update Makefile
2025-07-19 12:29:39 +02:00
0b125a5fd7 Update Makefile
Remove .bc file removal from clean shell for windows configuration.
2025-07-19 04:54:05 -05:00
Ray
0b7dda8ab1 Merge pull request #5050 from katanya04/master
Update font load message
2025-07-19 11:44:11 +02:00
3d93b30262 Update font load message 2025-07-18 15:20:38 +02:00
Ray
78a06990c7 Merge pull request #5041 from PanicTitan/master
[example][web] Fix core_custom_frame_control.c to properly register inputs on web platform
2025-07-17 19:01:27 +02:00
Ray
82b80a6998 Review formatting, avoid variable 2025-07-17 18:49:58 +02:00
Ray
71b302846a Review formatting, avoid variable 2025-07-17 18:49:54 +02:00
Ray
8823aba9df Update rprand.h 2025-07-17 18:49:34 +02:00
Ray
6b9a685bae Merge pull request #5048 from veins1/patch-4
[raudio] Fix: music stopping early. Fix: GetMusicTimePlayed for short music
2025-07-17 18:44:29 +02:00
Ray
14582a9f06 Merge pull request #5047 from RomainPlmg/#5009-fix-colorreplace-alpha
[rtextures] Fix ImageColorReplace() alpha issue replacement
2025-07-17 18:43:10 +02:00
093e5200d0 Update Makefile
Clean up library build for the web
2025-07-17 05:19:39 -05:00
0405de794a Fix for music stopping too early 2025-07-16 14:22:57 +00:00
d03ac97eff GetMusicTimePlayed fix for music shorter than buffer size 2025-07-16 14:18:38 +00:00
34af70866c [rtextures] Fix ImageColorReplace() alpha issue #5009 2025-07-15 23:19:39 +02:00
Ray
e00c5eb8b1 Merge pull request #5043 from vinnyhorgan/master
Fix warning log macro in rlgl
2025-07-15 20:20:27 +02:00
Ray
cbea2ff502 Merge pull request #5046 from maiconpintoabreu/updatestream-music
[raudio] Prevent UpdateMusicStream to run without music playing
2025-07-15 20:18:46 +02:00
3320a2c837 Fix to prevent UpdateMusicStream to run without music playing 2025-07-15 19:07:15 +01:00
8388160c32 - fixing SUPPORT_DRM_CACHE define check at the end of InitPlatform() 2025-07-15 13:58:23 +02:00
Ray
e7c043529c Merge pull request #5044 from backspaceoverload/fix-HalfToFloat
[rtextures] Fix HalfToFloat Mantissa hex value
2025-07-15 13:12:46 +02:00
85bf04c7bf [rl_gputex] fix: decouple logging and memory allocation from Raylib
- make sure that src/external/rl_gputex.h uses it's own macros
    for printing warnings and allocating memory
- add few additional macros in order to decouple rl_gputex from headers
    that are being included by Raylib (e.g. *_MEMSET, *_NULL and so on)
- make sure that rl_gputex uses RL_*ALLOC, TRACELOG and RLAPI macros
    when (and only when) being included by src/rtextures.c
- replace LOG() and RL_GPUTEX_SHOW_LOG_INFO macros with: RL_GPUTEX_WARN
    and RL_GPUTEX_SHOW_WARN_INFO (this is a breaking change, but it was
    broken and unusable anyway, see:
    https://github.com/raysan5/raylib/issues/5039#issuecomment-3065732596 )
- fixes issue all issues mentioned in:
    https://github.com/raysan5/raylib/issues/5039#issuecomment-3065732596
- remove logging upon successfully saving a file; Raylib does this
    anyway and we want rl_gputex to only print WARNings upon failures;
    see: https://discord.com/channels/426912293134270465/541710686468702250/1394406734306480352
- add additional condition when saving a file; now checks for both
    fwrite() and fclose() failures; before it would warn about both,
    but only return result based on fclose()
- add some notes about the current state of compiling rl_gputex
    without depending on Raylib (spoiler: it's still broken...)
- bump rl_gputex version to 1.1 since this is a potential breaking
    change (only for people attempting to use it without Raylib)

Fixes: https://github.com/raysan5/raylib/issues/5039
Reference: https://discord.com/channels/426912293134270465/541710686468702250/1394403611852931255
2025-07-15 07:53:50 +02:00
44ebf32389 Fix HalfToFloat Mantissa hex value 2025-07-15 00:52:47 -03:00
901afadbf1 fix warning log macro in rlgl 2025-07-14 15:36:02 +02:00
Ray
f34e240688 Merge pull request #5042 from Sir-Irk/ImageDrawLineEx_fix
[rtextures] Fix `ImageDrawLineEx()` line thickness
2025-07-14 10:30:34 +02:00
fce3102f1c Remove excess comments 2025-07-14 00:11:17 -05:00
9f03d7c426 fixing comments 2025-07-13 23:02:02 -05:00
0c69c43c3a fix ImageDrawLineEx to be able to draw even numbered thicknesses 2025-07-13 22:37:41 -05:00
9e908e4a76 Update core_custom_frame_control.c to work properly on web 2025-07-14 00:27:56 -03:00
Ray
20a07a65d7 Merge pull request #5037 from garrisonhh/fix-gaussian-blur
[rtextures] fix integer overflow in cast for `ImageBlurGaussian`
2025-07-10 19:06:34 +02:00
8dbacafbe6 fix overflow in cast for ImageBlurGaussian 2025-07-10 12:48:29 -04:00
Ray
55a5674714 Merge pull request #5036 from sleeptightAnsiC/update_glfw_mappings_h
[glfw] update mappings.h using GenerateMappings.cmake
2025-07-10 09:02:13 +02:00
930890555c [glfw] update mappings.h using GenerateMappings.cmake
I did this with the intention of fixing
https://github.com/raysan5/raylib/issues/5027
but it's hard to tell if it will help in that case or not.
Anyway, bumping the header with mappings should be done once in a while.

I haven't found any Raylib script for doing this, so here's how I did it
step-by-step with CMake rule provided by GLFW (I'm on Linux, but this
should be similar on any other POSIX system):
```sh
$ git clone https://github.com/raysan5/raylib.git
$ cd raylib/src/external/glfw/
$ cmake -B ./build -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF -G "Unix Makefiles"
$ make -C ./build update_mappings
$ rm -fr ./build
```
then I checked, if any mappings were deleted (without updating) with
following shell one-liner:
```sh
  # you must be at 'raylib/src/external/glfw/' when executing this
$ for i in $(git diff ./src/mappings.h | sed -n -e 's/^-"\([0-9a-z]*\),.*$/\1/p'); do grep <./src/mappings.h "$i" > /dev/null || echo "$i"; done;
```
which gave me the following IDs:
```txt
0300000066f700000500000000000000
030000000d0f00001600000000007803
03000000efbe0000edfe000000000000
03000000786901006e70000000000000
050000005e040000e002000030110000
03000000790000000600000010010000
030000000d0f00000d00000000010000
030000000d0f0000d800000072056800
03000000c0160000dc27000001010000
030000008916000000fd000024010000
```
I have checked all those IDs with `git log -p` against
https://github.com/mdqinc/SDL_GameControllerDB
and it seems that all of them were deleted by upstream (I was afraid that
maybe some mappings were added manually by a Raylib contributor and then
overwritten by my patch, but they weren't; All good!)
2025-07-10 01:37:25 +02:00
Ray
defbeee1a7 Merge pull request #5020 from Emil2010/master
update dr_libs
2025-07-08 21:45:17 +02:00
Ray
d972582bc7 Merge pull request #5025 from zedeckj/master
Fixed typo in example
2025-07-08 21:43:54 +02:00
Ray
5957564983 Merge pull request #5026 from jonathandw743/sdlfix
fixed compile error for PLATFORM sdl
2025-07-08 21:43:30 +02:00
Ray
eaea8e0b0a Merge pull request #5033 from wwderw/master
Update raudio.c
2025-07-08 21:42:47 +02:00
8ef51850bf Update raudio.c
Allow for the use of raudio stand alone
2025-07-08 08:51:33 -05:00
32026ca78b fix preview image file name 2025-07-08 06:34:25 -05:00
86d2db2aa9 fix typo on UI and preview image 2025-07-08 05:51:14 -05:00
9a578dbce0 fix formatting 2025-07-08 05:47:11 -05:00
a94feef6d0 update readme 2025-07-08 05:36:39 -05:00
897a8fbc9f adding preview image 2025-07-08 05:28:15 -05:00
510dc763e9 adding normal map example 2025-07-08 05:05:30 -05:00
Ray
a92f67bf34 Merge pull request #5031 from AmityWilder/safety-comments
Safety Comments for Sound/Texture Update Functions
2025-07-08 08:49:11 +02:00
205b6a0926 Merge branch 'raysan5:master' into safety-comments 2025-07-07 21:52:54 -04:00
9f6d37ecb4 Update raylib_api.* by CI 2025-07-08 01:51:52 +00:00
d4f09984ac Add safety notes to 'Update_' functions 2025-07-07 21:51:27 -04:00
5b182139ae - implementing Raylib coding convention 2025-07-07 17:55:32 +02:00
de62be0ec5 - created complier flag SUPPORT_DRM_CACHE, to enable triple buffered DRM caching 2025-07-07 17:28:23 +02:00
79c29cbe24 fixed compile error for PLATFORM sdl 2025-07-06 11:36:44 +01:00
e91a3697ff Fixed typo 2025-07-06 01:59:03 -04:00
910f4083e1 update dr_libs 2025-07-05 00:53:01 +03:00
Ray
7f8dfc6c69 Merge pull request #5018 from maiconpintoabreu/fix-zig-wasm-win-mac
[Zig] Fix issue on zig build Emscripten run if no emsdk installed
2025-07-04 14:34:07 +02:00
f1600a0c7e Fix issue on zig build emscripten run if the user has not installed emsdk 2025-07-04 10:24:32 +01:00
ed022e89e5 fix preview crop 2025-06-23 16:22:14 +03:00
f6b7168ed4 Add preview image 2025-06-23 16:06:46 +03:00
fa9653d179 Fix function call 2025-06-23 13:50:24 +03:00
fca2317640 remove //#define PLATFORM_WEB 2025-06-23 13:44:50 +03:00
a2cf878190 cleanup variable shadowing 2025-06-23 13:43:38 +03:00
4233544670 Update core_3d_fps_controller.c 2025-06-23 13:32:08 +03:00
4d5a56a5f8 change game's resolution 2025-06-23 13:15:14 +03:00
eee9dd8c94 Example: core_3d_fps_controller
Quake like camera animations and strafe jump movement
2025-06-23 13:03:35 +03:00
060bd787b1 Refactor: Replace DRM swap buffer implementation with asynchronous page-flipping and framebuffer caching
The original implementation created/destroyed framebuffers (FBs) per-frame, leading to kernel overhead and screen tearing. This commit replaces it with a different approach using:
- Asynchronous `drmModePageFlip()` with vblank sync
- Framebuffer caching to reduce repeated FB creation/removal operations
- Proper resource management through BO callbacks and buffer release synchronization
- Added error handling for busy displays, cache overflows, and flip failures
- Event-driven cleanup via page_flip_handler to prevent GPU/scanout conflicts

Co-authored-by: rob-bits
2025-06-05 15:50:07 +02:00
f7fe8b88cb add EmscriptenKeyboardCallback to consume key events 2025-05-28 17:47:18 -04:00
8ef6473d33 return to ray's expected resize behavior 2025-05-25 18:58:35 -04:00
cf2099f18a the holy grail 2025-05-24 20:33:27 -04:00
358917ffc3 trigger resize event when going into and out of fullscreen mode 2025-05-17 21:08:57 -04:00
d0d42e78ea inform glfw that a change of window size has taken place 2025-05-17 21:08:35 -04:00
b618d7b35b use parentElement's dimensions for width/height 2025-05-17 21:08:07 -04:00
53cbd3cb11 rename 2025-04-12 07:10:14 +05:00
0d86084709 Update text_unicode_font_example.c
The creation of the array has been rewritten, the size of the example has been reduced
2025-04-12 07:07:14 +05:00
4184a5b251 Update text_unicode_font_example.c 2025-04-11 18:43:12 +05:00
5d7e8010a5 example unicode font
A review of the code is required.  Since I'm not sure what's written correctly at all.
2025-04-11 14:39:06 +05:00
99a9ecfaac [rcore] Support window flags with initialization issues
This may not be the correct approach, however this appears to work. The idea is that before modifying `CORE.Window.flags` when first creating the window we keep a copy of the flags in order to call `SetWindowState` after initialization has completed, which should behave as if `MaximizeWindow` or `MinimizeWindow`, or conceptually any other flag modifying function were called after `InitWindow`.

This pull request only performs this for the windows platform, modify as needed in the switch statement at the end for others.
2025-03-12 14:56:02 -07:00
663 changed files with 114922 additions and 29425 deletions

View File

@ -3,7 +3,7 @@
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"
name: Analyze raylib with CodeQL
on:
workflow_dispatch:
@ -71,7 +71,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@ -90,7 +90,7 @@ jobs:
cmake --build . --config $BUILD_TYPE
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
upload: false

View File

@ -1,4 +1,4 @@
name: Android
name: Build raylib - Android
on:
workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: CMakeBuilds
name: Build raylib CMake - Windows+Linux
on:
workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: Linux Examples
name: Build raylib examples - Linux
on:
workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: Windows Examples
name: Build raylib examples - Windows
on:
workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: Linux
name: Build raylib - Linux
on:
workflow_dispatch:
@ -22,22 +22,28 @@ jobs:
build:
permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 1
matrix:
bits: [32, 64]
include:
- bits: 32
ARCH: "i386"
ARCH_NAME: "i386"
COMPILER_PATH: "/user/bin"
COMPILER_PATH: "/usr/bin"
runner: "ubuntu-latest"
- bits: 64
ARCH: "x86_64"
ARCH_NAME: "amd64"
COMPILER_PATH: "/user/bin"
COMPILER_PATH: "/usr/bin"
runner: "ubuntu-latest"
- bits: 64
ARCH: "aarch64"
ARCH_NAME: "arm64"
COMPILER_PATH: "/usr/bin"
runner: "ubuntu-24.04-arm"
runs-on: ${{ matrix.runner }}
env:
RELEASE_NAME: raylib-dev_linux_${{ matrix.ARCH_NAME }}
@ -54,7 +60,6 @@ jobs:
- name: Setup Environment
run: |
sudo apt-get update -qq
sudo apt-get install gcc-multilib
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev
mkdir build
cd build
@ -64,9 +69,14 @@ jobs:
mkdir lib
cd ../../../raylib
# ${{ matrix.ARCH }}-linux-gnu-gcc -v
- name: Setup Environment (x86)
run : |
sudo apt-get install gcc-multilib
if: matrix.bits == 32 && matrix.ARCH == 'i386'
# TODO: Support 32bit (i386) static/shared library building
- name: Build Library
- name: Build Library (32-bit)
run: |
cd src
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" CUSTOM_CFLAGS="-m32" -B
@ -74,13 +84,21 @@ jobs:
cd ..
if: matrix.bits == 32
- name: Build Library
- name: Build Library (64-bit x86)
run: |
cd src
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
cd ..
if: matrix.bits == 64
if: matrix.bits == 64 && matrix.ARCH == 'x86_64'
- name: Build Library (64-bit ARM)
run: |
cd src
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
make PLATFORM=PLATFORM_DESKTOP CC=gcc RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
cd ..
if: matrix.bits == 64 && matrix.ARCH == 'aarch64'
- name: Generate Artifacts
run: |

View File

@ -1,4 +1,4 @@
name: macOS
name: Build raylib - macOS
on:
workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: WebAssembly
name: Build raylib - WebAssembly
on:
workflow_dispatch:

View File

@ -1,4 +1,4 @@
name: Windows
name: Build raylib - Windows
on:
workflow_dispatch:
@ -40,10 +40,10 @@ jobs:
ziptarget: "win64"
- compiler: msvc16
ARCH: "x86"
VSARCHPATH: "Win32"
VSARCHPATH: "Win32"
ziptarget: "win32"
- compiler: msvc16
ARCH: "x64"
ARCH: "x64"
VSARCHPATH: "x64"
ziptarget: "win64"
- compiler: msvc16
@ -54,7 +54,6 @@ jobs:
- compiler: mingw-w64
ziptarget: winarm64 # We don't build arm64 with mingw-w64 yet
env:
RELEASE_NAME: raylib-dev_${{ matrix.ziptarget }}_${{ matrix.compiler }}
GNUTARGET: default
@ -62,7 +61,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
- name: Setup Release Version
run: |
echo "RELEASE_NAME=raylib-${{ github.event.release.tag_name }}_${{ matrix.ziptarget }}_${{ matrix.compiler }}" >> $GITHUB_ENV
@ -70,7 +69,7 @@ jobs:
if: github.event_name == 'release' && github.event.action == 'published'
- name: Setup Environment
run: |
run: |
dir
mkdir build
cd build
@ -99,7 +98,7 @@ jobs:
if: |
matrix.compiler == 'mingw-w64' &&
matrix.arch == 'i686'
- name: Build Library (MinGW-w64 64bit)
run: |
cd src
@ -145,7 +144,7 @@ jobs:
with:
name: ${{ env.RELEASE_NAME }}.zip
path: ./build/${{ env.RELEASE_NAME }}.zip
- name: Upload Artifact to Release
uses: softprops/action-gh-release@v1
with:

View File

@ -1,37 +1,37 @@
name: Parse raylib_api
on:
workflow_dispatch:
push:
paths:
- "src/raylib.h"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update parse files
working-directory: parser
run: |
make raylib_api
mv raylib_api.* output
- name: Diff parse files
id: diff
run: |
git add -N parser
git diff --name-only --exit-code
continue-on-error: true
- name: Commit parse files
if: steps.diff.outcome == 'failure'
run: |
set -x
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add parser
git commit -m "Update raylib_api.* by CI"
git push
name: Parse raylib API
on:
workflow_dispatch:
push:
paths:
- "src/raylib.h"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update parse files
working-directory: tools/rlparser
run: |
make raylib_api
mv raylib_api.* output
- name: Diff parse files
id: diff
run: |
git add -N tools/rlparser/output
git diff --name-only --exit-code
continue-on-error: true
- name: Commit parse files
if: steps.diff.outcome == 'failure'
run: |
set -x
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add tools/rlparser/output
git commit -m "rlparser: update raylib_api.* by CI"
git push

73
.github/workflows/update_examples.yml vendored Normal file
View File

@ -0,0 +1,73 @@
name: Update examples collection
on:
workflow_dispatch:
push:
paths:
- 'examples/**'
pull_request:
paths:
- 'examples/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
with:
version: 'latest'
actions-cache-folder: 'emsdk-cache'
- name: Clone raylib.com repo to update files
run: |
git clone https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/raysan5/raylib.com.git
shell: bash
- name: Build and run rexm tool (requires GNU Makefile)
# "rexm validate" validates examples collection, looking for inconsistencies, it does not rebuild examples
# "rexm update" validates and updates all examples with inconsistencies, pushing fixes to raylib and raylib.com repos
# note that rexm calls examples/Makefile.Web internally, so it requires [make] tool available
run: |
sudo apt-get update && sudo apt-get install -y libopengl0 libglu1-mesa libx11-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libgl1-mesa-dev libglu1-mesa-dev
cd "${{ github.workspace }}/src"
make PLATFORM=PLATFORM_DESKTOP
sudo make install
make clean
make PLATFORM=PLATFORM_WEB
cd ../tools/rexm/
make
export REXM_EXAMPLES_BASE_PATH="${{ github.workspace }}/examples"
export REXM_EXAMPLES_WEB_PATH="${{ github.workspace }}/raylib.com/examples"
export REXM_EXAMPLES_TEMPLATE_FILE_PATH="${{ github.workspace }}/examples/examples_template.c"
export REXM_EXAMPLES_TEMPLATE_SCREENSHOT_PATH="${{ github.workspace }}/examples/examples_template.png"
export REXM_EXAMPLES_COLLECTION_FILE_PATH="${{ github.workspace }}/examples/examples_list.txt"
export REXM_EXAMPLES_VS2022_SLN_FILE="${{ github.workspace }}/projects/VS2022/raylib.sln"
export EMSDK_PATH="${{ github.workspace }}/emsdk-cache/emsdk-main"
./rexm validate
shell: bash
- name: Commit changes to raylib repo (DISABLED)
if: github.event_name == 'push' && false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Update examples collection" || echo "git exited with code 1, nothing changed"
git push
shell: bash
- name: Push changes to raylib.com repo (DISABLED)
if: github.event_name == 'push' && false
run: |
cd raylib.com
git add -A
git commit -m "Update web examples" || echo "git exited with code 1, nothing changed"
git push origin
shell: bash

23
.gitignore vendored
View File

@ -55,15 +55,26 @@ packages/
*.so
*.so.*
*.dll
*.h.pch
./*.obj
# Ignore SDL libs for testing
src/external/SDL2
src/external/SDL3
# Emscripten
emsdk
# Ignore wasm data in examples/
examples/**/*
!examples/**/*.*
!examples/**/*/
examples/**/*.exe
examples/**/*.wasm
examples/**/*.data
examples/**/*.js
examples/**/*.html
examples/**/logs/*
# Ignore files build by xcode
*.mode*v*
@ -81,6 +92,7 @@ DerivedData/
# VSCode project
.vscode
.clangd
# Jetbrains project
.idea/
@ -111,5 +123,12 @@ build/
build-*/
docgen_tmp/
# Parser stuff
parser/raylib_parser
# Tools stuff
tools/parser/rlparser.exe
tools/parser/rlparser
tools/rexm/rexm.exe
tools/rexm/rexm
# CI
emsdk-cache/
raylib.com/

View File

@ -7,6 +7,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
| Name | raylib Version | Language | License |
| :--------------------------------------------------------------------------------------- | :--------------: | :------------------------------------------------------------------: | :------------------: |
| [raylib](https://github.com/raysan5/raylib) | **5.5** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib |
| [raylib-ada](https://github.com/Fabien-Chouteau/raylib-ada) | **5.5** | [Ada](https://en.wikipedia.org/wiki/Ada_(programming_language)) | MIT |
| [raylib-beef](https://github.com/Starpelly/raylib-beef) | **5.5** | [Beef](https://www.beeflang.org) | MIT |
| [raybit](https://github.com/Alex-Velez/raybit) | **5.0** | [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) | MIT |
| [raylib-c3](https://github.com/c3lang/vendor/tree/main/libraries/raylib55.c3l) | **5.5** | [C3](https://c3-lang.org) | MIT |
@ -28,8 +29,10 @@ Some people ported raylib to other languages in the form of bindings or wrappers
| [dray](https://github.com/redthing1/dray) | **5.0** | [D](https://dlang.org) | Apache-2.0 |
| [raylib-d](https://github.com/schveiguy/raylib-d) | **5.5** | [D](https://dlang.org) | Zlib |
| [rayex](https://github.com/shiryel/rayex) | 3.7 | [elixir](https://elixir-lang.org) | Apache-2.0 |
| [raylib-elle](https://github.com/acquitelol/elle/blob/rewrite/std/raylib.le) | **5.5** | [Elle](https://github.com/acquitelol/elle) | GPL-3.0 |
| [raylib-factor](https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor) | 4.5 | [Factor](https://factorcode.org) | BSD |
| [raylib-freebasic](https://github.com/WIITD/raylib-freebasic) | **5.0** | [FreeBASIC](https://www.freebasic.net) | MIT |
| [raylib.f](https://github.com/cthulhuology/raylib.f) | **5.5** | [Forth](https://forth.com) | Zlib |
| [fortran-raylib](https://github.com/interkosmos/fortran-raylib) | **5.5** | [Fortran](https://fortran-lang.org) | ISC |
| [raylib-go](https://github.com/gen2brain/raylib-go) | **5.5** | [Go](https://golang.org) | Zlib |
| [raylib-guile](https://github.com/petelliott/raylib-guile) | **auto** | [Guile](https://www.gnu.org/software/guile) | Zlib |
@ -73,6 +76,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
| [raylib-rs](https://github.com/raylib-rs/raylib-rs) | **5.5** | [Rust](https://www.rust-lang.org) | Zlib |
| [raylib-ruby](https://github.com/wilsonsilva/raylib-ruby) | 4.5 | [Ruby](https://www.ruby-lang.org) | Zlib |
| [Relib](https://github.com/RedCubeDev-ByteSpace/Relib) | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | **???** |
| [ringraylib5](https://github.com/ring-lang/ring/tree/master/extensions/ringraylib5) | **5.0** | [Ring](https://ring-lang.github.io/) | **???** |
| [racket-raylib](https://github.com/eutro/racket-raylib) | **5.5** | [Racket](https://racket-lang.org) | MIT/Apache-2.0 |
| [raylib-swift](https://github.com/STREGAsGate/Raylib) | 4.0 | [Swift](https://swift.org) | MIT |
| [raylib-scopes](https://github.com/salotz/raylib-scopes) | auto | [Scopes](http://scopes.rocks) | MIT |
@ -82,7 +86,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
| [raylib.v](https://github.com/irishgreencitrus/raylib.v) | 4.2 | [V](https://vlang.io) | Zlib |
| [raylib-vapi](https://github.com/lxmcf/raylib-vapi) | **5.0** | [Vala](https://vala.dev) | Zlib |
| [raylib-wren](https://github.com/TSnake41/raylib-wren) | 4.5 | [Wren](http://wren.io) | ISC |
| [raylib-zig](https://github.com/Not-Nik/raylib-zig) | **5.5** | [Zig](https://ziglang.org) | MIT |
| [raylib-zig](https://github.com/raylib-zig/raylib-zig) | **5.6-dev** | [Zig](https://ziglang.org) | MIT |
| [raylib.zig](https://github.com/ryupold/raylib.zig) | **5.1-dev** | [Zig](https://ziglang.org) | MIT |
| [raylib-zig-bindings](https://github.com/L-Briand/raylib-zig-bindings) | **5.0** | [Zig](https://ziglang.org) | Zlib |
| [hare-raylib](https://git.sr.ht/~evantj/hare-raylib) | **auto** | [Hare](https://harelang.org) | Zlib |
@ -145,7 +149,6 @@ These are older raylib bindings that are more than 2 versions old or have not be
| [clj-raylib](https://github.com/lsevero/clj-raylib) | 3.0 | [Clojure](https://clojure.org) |
| [QuickJS-raylib](https://github.com/sntg-p/QuickJS-raylib) | 3.0 | [QuickJS](https://bellard.org/quickjs) |
| [raylib-duktape](https://github.com/RobLoach/raylib-duktape) | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) |
| [raylib-v7](https://github.com/Rabios/raylib-v7) | 3.5 | [JavaScript (v7)](https://en.wikipedia.org/wiki/JavaScript) |
| [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) | 2.6 | [ChaiScript](http://chaiscript.com) |
| [raylib-squirrel](https://github.com/RobLoach/raylib-squirrel) | 2.5 | [Squirrel](http://www.squirrel-lang.org) |
| [racket-raylib-2d](https://github.com/arvyy/racket-raylib-2d) | 2.5 | [Racket](https://racket-lang.org) |

View File

@ -565,7 +565,7 @@ Detailed changes:
[rtext] ADDED: SetTextLineSpacing() to define line breaks text drawing spacing by @raysan5
[rtext] RENAMED: LoadFont*() parameter names for consistency and coherence by @raysan5
[rtext] REVIEWED: GetCodepointCount(), ignore unused return value of GetCodepointNext by @ashn-dot-dev
[rtext] REVIEWED: TextFormat() warn user if buffer overflow occured (#3399) by @Murlocohol
[rtext] REVIEWED: TextFormat() warn user if buffer overflow occurred (#3399) by @Murlocohol
[rtext] REVIEWED: TextFormat(), added "..." for truncation (#3366) by @raysan5
[rtext] REVIEWED: GetGlyphIndex() (#3000) by @raysan5
[rtext] REVIEWED: GetCodepointNext() to return default value by @chocolate42

View File

@ -29,9 +29,9 @@ include(CompilerFlags)
# Registers build options that are exposed to cmake
include(CMakeOptions.txt)
if (UNIX AND NOT APPLE AND NOT "${PLATFORM}" MATCHES "DRM")
if (UNIX AND NOT APPLE AND NOT "${PLATFORM}" MATCHES "DRM" AND NOT "${PLATFORM}" MATCHES "Web")
if (NOT GLFW_BUILD_WAYLAND AND NOT GLFW_BUILD_X11)
MESSAGE(FATAL_ERROR "Cannot disable both Wayland and X11")
message(FATAL_ERROR "Cannot disable both Wayland and X11")
endif()
endif()
@ -51,7 +51,7 @@ if(NOT TARGET uninstall AND PROJECT_IS_TOP_LEVEL)
endif()
if (${BUILD_EXAMPLES})
MESSAGE(STATUS "Building examples is enabled")
message(STATUS "Building examples is enabled")
add_subdirectory(examples)
endif()

View File

@ -6,9 +6,9 @@ if(EMSCRIPTEN)
# When configuring web builds with "emcmake cmake -B build -S .", set PLATFORM to Web by default
SET(PLATFORM Web CACHE STRING "Platform to build for.")
endif()
enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi;DRM;SDL" "Platform to build for.")
enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi;DRM;SDL;RGFW" "Platform to build for.")
enum_option(OPENGL_VERSION "OFF;4.3;3.3;2.1;1.1;ES 2.0;ES 3.0" "Force a specific OpenGL Version?")
enum_option(OPENGL_VERSION "OFF;4.3;3.3;2.1;1.1;ES 2.0;ES 3.0;Software" "Force a specific OpenGL Version?")
# Configuration options
option(BUILD_EXAMPLES "Build the examples." ${PROJECT_IS_TOP_LEVEL})

View File

@ -69,8 +69,8 @@ If you have any doubt, don't hesitate to [contact me](mailto:ray@raylib.com)!.
You can write me a direct mail but you can also contact me on the following networks:
- [raylib Discord](https://discord.gg/raylib) - A direct communication channel for project discussions.
- [raylib twitter](https://twitter.com/raysan5) - My personal twitter account, I usually post about raylib, you can send me PMs.
- [raylib reddit](https://www.reddit.com/r/raylib/) - A good place for discussions or to ask for help.
- [raylib web](http://www.raylib.com/) - On top-right corner there is a bunch of networks where you can find me.
- [raylib X](https://x.com/raysan5) - My personal X account, I usually post about raylib, you can send me PMs.
Thank you very much for your time! :)

View File

@ -11,7 +11,7 @@ Local variables | lowerCase | `Vector2 playerPosition = { 0 };`
Global variables | lowerCase | `bool windowReady = false;`
Constants | lowerCase | `const int maxValue = 8;`
Pointers | MyType *pointer | `Texture2D *array = NULL;`
float values | always x.xf | `float gravity = 10.0f`
float values | always x.xf | `float gravity = 10.0f` (avoid `10.f`)
Operators | value1*value2 | `int product = value*6;`
Operators | value1/value2 | `int division = value/4;`
Operators | value1 + value2 | `int sum = value + 10;`
@ -28,6 +28,10 @@ Some other conventions to follow:
- **ALWAYS** initialize all defined variables.
- **Do not use TABS**, use 4 spaces instead.
- Avoid trailing spaces, please, avoid them
- Comments always start with space + capital letter and never end with a '.', place them **before** the line(s) they refer to
```c
// This is a comment in raylib or raylib examples
```
- Control flow statements always are followed **by a space**:
```c
if (condition) value = 0;
@ -37,6 +41,7 @@ while (!WindowShouldClose())
}
// Always use accumulators as `x++` instead of `++x`
for (int i = 0; i < NUM_VALUES; i++) printf("%i", i);
// Be careful with the switch formatting!
@ -68,19 +73,19 @@ void SomeFunction()
**If proposing new functions, please try to use a clear naming for function-name and functions-parameters, in case of doubt, open an issue for discussion.**
## Files and Directories Naming Conventions
- Directories will be named using `snake_case`: `resources/models`, `resources/fonts`
- Files will be named using `snake_case`: `main_title.png`, `cubicmap.png`, `sound.wav`
_NOTE: Avoid any space or special character in the files/dir naming!_
## Games/Examples Directories Organization Conventions
- Data files should be organized by context and usage in the game, think about the loading requirements for data and put all the resources that need to be loaded at the same time together.
- Use descriptive names for the files, it would be perfect if just reading the name of the file, it was possible to know what is that file and where fits in the game.
- Here is an example, note that some resources require to be loaded all at once while other require to be loaded only at initialization (gui, font).
```
resources/audio/fx/long_jump.wav
resources/audio/music/main_theme.ogg

View File

@ -24,14 +24,14 @@ Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
[![Youtube Subscribers](https://img.shields.io/youtube/channel/subscribers/UC8WIBkhYb5sBNqXO1mZ7WSQ?style=flat&label=Youtube&logo=youtube)](https://www.youtube.com/c/raylib)
[![Twitch Status](https://img.shields.io/twitch/status/raysan5?style=flat&label=Twitch&logo=twitch)](https://www.twitch.tv/raysan5)
[![Windows](https://github.com/raysan5/raylib/workflows/Windows/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AWindows)
[![Linux](https://github.com/raysan5/raylib/workflows/Linux/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3ALinux)
[![macOS](https://github.com/raysan5/raylib/workflows/macOS/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AmacOS)
[![WebAssembly](https://github.com/raysan5/raylib/workflows/WebAssembly/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AWebAssembly)
[![Build Windows](https://github.com/raysan5/raylib/actions/workflows/build_windows.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_windows.yml)
[![Build Linux](https://github.com/raysan5/raylib/actions/workflows/build_linux.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_linux.yml)
[![Build macOS](https://github.com/raysan5/raylib/actions/workflows/build_macos.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_macos.yml)
[![Build WebAssembly](https://github.com/raysan5/raylib/actions/workflows/build_webassembly.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_webassembly.yml)
[![CMakeBuilds](https://github.com/raysan5/raylib/workflows/CMakeBuilds/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3ACMakeBuilds)
[![Windows Examples](https://github.com/raysan5/raylib/actions/workflows/windows_examples.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/windows_examples.yml)
[![Linux Examples](https://github.com/raysan5/raylib/actions/workflows/linux_examples.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/linux_examples.yml)
[![Build CMake](https://github.com/raysan5/raylib/actions/workflows/build_cmake.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_cmake.yml)
[![Build examples Windows](https://github.com/raysan5/raylib/actions/workflows/build_examples_windows.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_examples_windows.yml)
[![Build examples Linux](https://github.com/raysan5/raylib/actions/workflows/build_examples_linux.yml/badge.svg)](https://github.com/raysan5/raylib/actions/workflows/build_examples_linux.yml)
features
--------
@ -129,7 +129,7 @@ raylib is present in several networks and raylib community is growing everyday.
- Webpage: [https://www.raylib.com](https://www.raylib.com)
- Discord: [https://discord.gg/raylib](https://discord.gg/raylib)
- Twitter: [https://www.twitter.com/raysan5](https://www.twitter.com/raysan5)
- X: [https://x.com/raysan5](https://x.com/raysan5)
- BlueSky: [https://bsky.app/profile/raysan5](https://bsky.app/profile/raysan5.bsky.social)
- Twitch: [https://www.twitch.tv/raysan5](https://www.twitch.tv/raysan5)
- Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)

18
SECURITY.md Normal file
View File

@ -0,0 +1,18 @@
# Security Policy
## Supported Versions
Most considerations of errors and defects can be handled using the project Issues and/or Discussions.
| Version | Supported |
| ------- | ------------------ |
| 6.0.x | :white_check_mark: |
| < 5.5 | :x: |
## Reporting a Vulnerability
Discovered vulnerability can be directly reported using the project Issues and/or Discussions.
_TODO: Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc._

659
build.zig
View File

@ -2,7 +2,7 @@ const std = @import("std");
const builtin = @import("builtin");
/// Minimum supported version of Zig
const min_ver = "0.13.0";
const min_ver = "0.15.1";
const emccOutputDir = "zig-out" ++ std.fs.path.sep_str ++ "htmlout" ++ std.fs.path.sep_str;
const emccOutputFile = "index.html";
@ -14,6 +14,72 @@ comptime {
@compileError("Raylib requires zig version " ++ min_ver);
}
pub const emsdk = struct {
const zemscripten = @import("zemscripten");
pub fn shell(b: *std.Build) std.Build.LazyPath {
return b.dependency("raylib", .{}).path("src/shell.html");
}
pub const FlagsOptions = struct {
optimize: std.builtin.OptimizeMode,
asyncify: bool = true,
};
pub fn emccDefaultFlags(allocator: std.mem.Allocator, options: FlagsOptions) zemscripten.EmccFlags {
var emcc_flags = zemscripten.emccDefaultFlags(allocator, .{
.optimize = options.optimize,
.fsanitize = true,
});
if (options.asyncify)
emcc_flags.put("-sASYNCIFY", {}) catch unreachable;
return emcc_flags;
}
pub const SettingsOptions = struct {
optimize: std.builtin.OptimizeMode,
es3: bool = true,
emsdk_allocator: zemscripten.EmsdkAllocator = .emmalloc,
};
pub fn emccDefaultSettings(allocator: std.mem.Allocator, options: SettingsOptions) zemscripten.EmccSettings {
var emcc_settings = zemscripten.emccDefaultSettings(allocator, .{
.optimize = options.optimize,
.emsdk_allocator = options.emsdk_allocator,
});
if (options.es3)
emcc_settings.put("FULL_ES3", "1") catch unreachable;
emcc_settings.put("USE_GLFW", "3") catch unreachable;
emcc_settings.put("EXPORTED_RUNTIME_METHODS", "['requestFullscreen']") catch unreachable;
return emcc_settings;
}
pub fn emccStep(b: *std.Build, raylib: *std.Build.Step.Compile, wasm: *std.Build.Step.Compile, options: zemscripten.StepOptions) *std.Build.Step {
const activate_emsdk_step = zemscripten.activateEmsdkStep(b);
const emsdk_dep = b.dependency("emsdk", .{});
raylib.root_module.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
wasm.root_module.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
const emcc_step = zemscripten.emccStep(b, wasm, options);
emcc_step.dependOn(activate_emsdk_step);
return emcc_step;
}
pub fn emrunStep(
b: *std.Build,
html_path: []const u8,
extra_args: []const []const u8,
) *std.Build.Step {
return zemscripten.emrunStep(b, html_path, extra_args);
}
};
fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend) void {
switch (platform) {
.glfw => raylib.root_module.addCMacro("PLATFORM_DESKTOP_GLFW", ""),
@ -24,50 +90,6 @@ fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend
}
}
fn createEmsdkStep(b: *std.Build, emsdk: *std.Build.Dependency) *std.Build.Step.Run {
if (builtin.os.tag == .windows) {
return b.addSystemCommand(&.{emsdk.path("emsdk.bat").getPath(b)});
} else {
return b.addSystemCommand(&.{emsdk.path("emsdk").getPath(b)});
}
}
fn emSdkSetupStep(b: *std.Build, emsdk: *std.Build.Dependency) !?*std.Build.Step.Run {
const dot_emsc_path = emsdk.path(".emscripten").getPath(b);
const dot_emsc_exists = !std.meta.isError(std.fs.accessAbsolute(dot_emsc_path, .{}));
if (!dot_emsc_exists) {
const emsdk_install = createEmsdkStep(b, emsdk);
emsdk_install.addArgs(&.{ "install", "latest" });
const emsdk_activate = createEmsdkStep(b, emsdk);
emsdk_activate.addArgs(&.{ "activate", "latest" });
emsdk_activate.step.dependOn(&emsdk_install.step);
return emsdk_activate;
} else {
return null;
}
}
// Adapted from Not-Nik/raylib-zig
fn emscriptenRunStep(b: *std.Build, emsdk: *std.Build.Dependency, examplePath: []const u8) !*std.Build.Step.Run {
const dot_emsc_path = emsdk.path("upstream/emscripten/cache/sysroot/include").getPath(b);
// If compiling on windows , use emrun.bat.
const emrunExe = switch (builtin.os.tag) {
.windows => "emrun.bat",
else => "emrun",
};
var emrun_run_arg = try b.allocator.alloc(u8, dot_emsc_path.len + emrunExe.len + 1);
defer b.allocator.free(emrun_run_arg);
if (b.sysroot == null) {
emrun_run_arg = try std.fmt.bufPrint(emrun_run_arg, "{s}", .{emrunExe});
} else {
emrun_run_arg = try std.fmt.bufPrint(emrun_run_arg, "{s}" ++ std.fs.path.sep_str ++ "{s}", .{ dot_emsc_path, emrunExe });
}
const run_cmd = b.addSystemCommand(&.{ emrun_run_arg, examplePath });
return run_cmd;
}
/// A list of all flags from `src/config.h` that one may override
const config_h_flags = outer: {
// Set this value higher if compile errors happen as `src/config.h` gets larger
@ -84,9 +106,9 @@ const config_h_flags = outer: {
if (std.mem.startsWith(u8, line, "//")) continue;
if (std.mem.startsWith(u8, line, "#if")) continue;
var flag = std.mem.trimLeft(u8, line, " \t"); // Trim whitespace
var flag = std.mem.trimStart(u8, line, " \t"); // Trim whitespace
flag = flag["#define ".len - 1 ..]; // Remove #define
flag = std.mem.trimLeft(u8, flag, " \t"); // Trim whitespace
flag = std.mem.trimStart(u8, flag, " \t"); // Trim whitespace
flag = flag[0 .. std.mem.indexOf(u8, flag, " ") orelse continue]; // Flag is only one word, so capture till space
flag = "-D" ++ flag; // Prepend with -D
@ -100,26 +122,42 @@ const config_h_flags = outer: {
};
fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) !*std.Build.Step.Compile {
var raylib_flags_arr = std.ArrayList([]const u8).init(b.allocator);
defer raylib_flags_arr.deinit();
var raylib_flags_arr: std.ArrayList([]const u8) = .empty;
defer raylib_flags_arr.deinit(b.allocator);
try raylib_flags_arr.appendSlice(&[_][]const u8{
"-std=gnu99",
"-D_GNU_SOURCE",
"-DGL_SILENCE_DEPRECATION=199309L",
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/3674
const raylib = b.addLibrary(.{
.name = "raylib",
.linkage = options.linkage,
.root_module = b.createModule(.{
.optimize = optimize,
.target = target,
.link_libc = true,
}),
});
if (options.shared) {
try raylib_flags_arr.appendSlice(&[_][]const u8{
"-fPIC",
"-DBUILD_LIBTYPE_SHARED",
});
try raylib_flags_arr.appendSlice(
b.allocator,
&[_][]const u8{
"-std=gnu99",
"-D_GNU_SOURCE",
"-DGL_SILENCE_DEPRECATION=199309L",
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/3674
},
);
if (options.linkage == .dynamic) {
try raylib_flags_arr.appendSlice(
b.allocator,
&[_][]const u8{
"-fPIC",
"-DBUILD_LIBTYPE_SHARED",
},
);
}
// Sets a flag indiciating the use of a custom `config.h`
try raylib_flags_arr.append("-DEXTERNAL_CONFIG_FLAGS");
if (options.config.len > 0) {
// Sets a flag indicating the use of a custom `config.h`
try raylib_flags_arr.append(b.allocator, "-DEXTERNAL_CONFIG_FLAGS");
// Splits a space-separated list of config flags into multiple flags
//
// Note: This means certain flags like `-x c++` won't be processed properly.
@ -128,7 +166,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
// Apply config flags supplied by the user
while (config_iter.next()) |config_flag|
try raylib_flags_arr.append(config_flag);
try raylib_flags_arr.append(b.allocator, config_flag);
// Apply all relevant configs from `src/config.h` *except* the user-specified ones
//
@ -146,84 +184,70 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
}
// Otherwise, append default value from config.h to compile flags
try raylib_flags_arr.append(flag);
try raylib_flags_arr.append(b.allocator, flag);
}
} else {
// Set default config if no custome config got set
try raylib_flags_arr.appendSlice(&config_h_flags);
// Set default config if no custom config got set
try raylib_flags_arr.appendSlice(b.allocator, &config_h_flags);
}
const raylib = if (options.shared)
b.addSharedLibrary(.{
.name = "raylib",
.target = target,
.optimize = optimize,
})
else
b.addStaticLibrary(.{
.name = "raylib",
.target = target,
.optimize = optimize,
});
raylib.linkLibC();
// No GLFW required on PLATFORM_DRM
if (options.platform != .drm) {
raylib.addIncludePath(b.path("src/external/glfw/include"));
raylib.root_module.addIncludePath(b.path("src/external/glfw/include"));
}
var c_source_files = try std.ArrayList([]const u8).initCapacity(b.allocator, 2);
var c_source_files: std.ArrayList([]const u8) = try .initCapacity(b.allocator, 2);
c_source_files.appendSliceAssumeCapacity(&.{ "src/rcore.c", "src/utils.c" });
if (options.rshapes) {
try c_source_files.append("src/rshapes.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RSHAPES");
try c_source_files.append(b.allocator, "src/rshapes.c");
try raylib_flags_arr.append(b.allocator, "-DSUPPORT_MODULE_RSHAPES");
}
if (options.rtextures) {
try c_source_files.append("src/rtextures.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RTEXTURES");
try c_source_files.append(b.allocator, "src/rtextures.c");
try raylib_flags_arr.append(b.allocator, "-DSUPPORT_MODULE_RTEXTURES");
}
if (options.rtext) {
try c_source_files.append("src/rtext.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RTEXT");
try c_source_files.append(b.allocator, "src/rtext.c");
try raylib_flags_arr.append(b.allocator, "-DSUPPORT_MODULE_RTEXT");
}
if (options.rmodels) {
try c_source_files.append("src/rmodels.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RMODELS");
try c_source_files.append(b.allocator, "src/rmodels.c");
try raylib_flags_arr.append(b.allocator, "-DSUPPORT_MODULE_RMODELS");
}
if (options.raudio) {
try c_source_files.append("src/raudio.c");
try raylib_flags_arr.append("-DSUPPORT_MODULE_RAUDIO");
try c_source_files.append(b.allocator, "src/raudio.c");
try raylib_flags_arr.append(b.allocator, "-DSUPPORT_MODULE_RAUDIO");
}
if (options.opengl_version != .auto) {
raylib.root_module.addCMacro(options.opengl_version.toCMacroStr(), "");
}
raylib.addIncludePath(b.path("src/platforms"));
raylib.root_module.addIncludePath(b.path("src/platforms"));
switch (target.result.os.tag) {
.windows => {
switch (options.platform) {
.glfw => try c_source_files.append("src/rglfw.c"),
.glfw => try c_source_files.append(b.allocator, "src/rglfw.c"),
.rgfw, .sdl, .drm, .android => {},
}
raylib.linkSystemLibrary("winmm");
raylib.linkSystemLibrary("gdi32");
raylib.linkSystemLibrary("opengl32");
raylib.root_module.linkSystemLibrary("winmm", .{});
raylib.root_module.linkSystemLibrary("gdi32", .{});
raylib.root_module.linkSystemLibrary("opengl32", .{});
setDesktopPlatform(raylib, options.platform);
},
.linux => {
if (options.platform == .drm) {
if (options.opengl_version == .auto) {
raylib.linkSystemLibrary("GLESv2");
raylib.root_module.linkSystemLibrary("GLESv2", .{});
raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", "");
}
raylib.linkSystemLibrary("EGL");
raylib.linkSystemLibrary("gbm");
raylib.linkSystemLibrary2("libdrm", .{ .use_pkg_config = .force });
raylib.root_module.linkSystemLibrary("EGL", .{});
raylib.root_module.linkSystemLibrary("gbm", .{});
raylib.root_module.linkSystemLibrary("libdrm", .{ .use_pkg_config = .force });
raylib.root_module.addCMacro("PLATFORM_DRM", "");
raylib.root_module.addCMacro("EGL_NO_X11", "");
@ -258,21 +282,21 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
const androidAsmPath = try std.fs.path.join(b.allocator, &.{ androidIncludePath, "/asm-generic" });
const androidGluePath = try std.fs.path.join(b.allocator, &.{ androidNdkPathString, "/sources/android/native_app_glue/" });
raylib.addLibraryPath(.{ .cwd_relative = androidLibPath });
raylib.root_module.addLibraryPath(.{ .cwd_relative = androidLibPath });
raylib.root_module.addLibraryPath(.{ .cwd_relative = androidApiSpecificPath });
raylib.addSystemIncludePath(.{ .cwd_relative = androidIncludePath });
raylib.addSystemIncludePath(.{ .cwd_relative = androidArchIncludePath });
raylib.addSystemIncludePath(.{ .cwd_relative = androidAsmPath });
raylib.addSystemIncludePath(.{ .cwd_relative = androidGluePath });
raylib.root_module.addSystemIncludePath(.{ .cwd_relative = androidIncludePath });
raylib.root_module.addSystemIncludePath(.{ .cwd_relative = androidArchIncludePath });
raylib.root_module.addSystemIncludePath(.{ .cwd_relative = androidAsmPath });
raylib.root_module.addSystemIncludePath(.{ .cwd_relative = androidGluePath });
var libcData = std.ArrayList(u8).init(b.allocator);
const writer = libcData.writer();
var libcData: std.ArrayList(u8) = .empty;
var aw: std.Io.Writer.Allocating = .fromArrayList(b.allocator, &libcData);
try (std.zig.LibCInstallation{
.include_dir = androidIncludePath,
.sys_include_dir = androidIncludePath,
.crt_dir = androidApiSpecificPath,
}).render(writer);
const libcFile = b.addWriteFiles().add("android-libc.txt", try libcData.toOwnedSlice());
}).render(&aw.writer);
const libcFile = b.addWriteFiles().add("android-libc.txt", try libcData.toOwnedSlice(b.allocator));
raylib.setLibCFile(libcFile);
if (options.opengl_version == .auto) {
@ -283,19 +307,19 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
setDesktopPlatform(raylib, .android);
} else {
try c_source_files.append("src/rglfw.c");
try c_source_files.append(b.allocator, "src/rglfw.c");
if (options.linux_display_backend == .X11 or options.linux_display_backend == .Both) {
raylib.root_module.addCMacro("_GLFW_X11", "");
raylib.linkSystemLibrary("GLX");
raylib.linkSystemLibrary("X11");
raylib.linkSystemLibrary("Xcursor");
raylib.linkSystemLibrary("Xext");
raylib.linkSystemLibrary("Xfixes");
raylib.linkSystemLibrary("Xi");
raylib.linkSystemLibrary("Xinerama");
raylib.linkSystemLibrary("Xrandr");
raylib.linkSystemLibrary("Xrender");
raylib.root_module.linkSystemLibrary("GLX", .{});
raylib.root_module.linkSystemLibrary("X11", .{});
raylib.root_module.linkSystemLibrary("Xcursor", .{});
raylib.root_module.linkSystemLibrary("Xext", .{});
raylib.root_module.linkSystemLibrary("Xfixes", .{});
raylib.root_module.linkSystemLibrary("Xi", .{});
raylib.root_module.linkSystemLibrary("Xinerama", .{});
raylib.root_module.linkSystemLibrary("Xrandr", .{});
raylib.root_module.linkSystemLibrary("Xrender", .{});
}
if (options.linux_display_backend == .Wayland or options.linux_display_backend == .Both) {
@ -307,9 +331,9 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
@panic("`wayland-scanner` not found");
};
raylib.root_module.addCMacro("_GLFW_WAYLAND", "");
raylib.linkSystemLibrary("EGL");
raylib.linkSystemLibrary("wayland-client");
raylib.linkSystemLibrary("xkbcommon");
raylib.root_module.linkSystemLibrary("EGL", .{});
raylib.root_module.linkSystemLibrary("wayland-client", .{});
raylib.root_module.linkSystemLibrary("xkbcommon", .{});
waylandGenerate(b, raylib, "wayland.xml", "wayland-client-protocol");
waylandGenerate(b, raylib, "xdg-shell.xml", "xdg-shell-client-protocol");
waylandGenerate(b, raylib, "xdg-decoration-unstable-v1.xml", "xdg-decoration-unstable-v1-client-protocol");
@ -324,55 +348,49 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
}
},
.freebsd, .openbsd, .netbsd, .dragonfly => {
try c_source_files.append("rglfw.c");
raylib.linkSystemLibrary("GL");
raylib.linkSystemLibrary("rt");
raylib.linkSystemLibrary("dl");
raylib.linkSystemLibrary("m");
raylib.linkSystemLibrary("X11");
raylib.linkSystemLibrary("Xrandr");
raylib.linkSystemLibrary("Xinerama");
raylib.linkSystemLibrary("Xi");
raylib.linkSystemLibrary("Xxf86vm");
raylib.linkSystemLibrary("Xcursor");
try c_source_files.append(b.allocator, "rglfw.c");
raylib.root_module.linkSystemLibrary("GL", .{});
raylib.root_module.linkSystemLibrary("rt", .{});
raylib.root_module.linkSystemLibrary("dl", .{});
raylib.root_module.linkSystemLibrary("m", .{});
raylib.root_module.linkSystemLibrary("X11", .{});
raylib.root_module.linkSystemLibrary("Xrandr", .{});
raylib.root_module.linkSystemLibrary("Xinerama", .{});
raylib.root_module.linkSystemLibrary("Xi", .{});
raylib.root_module.linkSystemLibrary("Xxf86vm", .{});
raylib.root_module.linkSystemLibrary("Xcursor", .{});
setDesktopPlatform(raylib, options.platform);
},
.macos => {
// Include xcode_frameworks for cross compilation
if (b.lazyDependency("xcode_frameworks", .{})) |dep| {
raylib.addSystemFrameworkPath(dep.path("Frameworks"));
raylib.addSystemIncludePath(dep.path("include"));
raylib.addLibraryPath(dep.path("lib"));
raylib.root_module.addSystemFrameworkPath(dep.path("Frameworks"));
raylib.root_module.addSystemIncludePath(dep.path("include"));
raylib.root_module.addLibraryPath(dep.path("lib"));
}
// On macos rglfw.c include Objective-C files.
try raylib_flags_arr.append("-ObjC");
try raylib_flags_arr.append(b.allocator, "-ObjC");
raylib.root_module.addCSourceFile(.{
.file = b.path("src/rglfw.c"),
.flags = raylib_flags_arr.items,
});
_ = raylib_flags_arr.pop();
raylib.linkFramework("Foundation");
raylib.linkFramework("CoreServices");
raylib.linkFramework("CoreGraphics");
raylib.linkFramework("AppKit");
raylib.linkFramework("IOKit");
raylib.root_module.linkFramework("Foundation", .{});
raylib.root_module.linkFramework("CoreServices", .{});
raylib.root_module.linkFramework("CoreGraphics", .{});
raylib.root_module.linkFramework("AppKit", .{});
raylib.root_module.linkFramework("IOKit", .{});
setDesktopPlatform(raylib, options.platform);
},
.emscripten => {
if (b.lazyDependency("emsdk", .{})) |dep| {
if (try emSdkSetupStep(b, dep)) |emSdkStep| {
raylib.step.dependOn(&emSdkStep.step);
}
raylib.addIncludePath(dep.path("upstream/emscripten/cache/sysroot/include"));
}
const activate_emsdk_step = emsdk.zemscripten.activateEmsdkStep(b);
raylib.step.dependOn(activate_emsdk_step);
raylib.root_module.addCMacro("PLATFORM_WEB", "");
if (options.opengl_version == .auto) {
raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", "");
raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES3", "");
}
},
else => {
@ -394,9 +412,9 @@ pub fn addRaygui(b: *std.Build, raylib: *std.Build.Step.Compile, raygui_dep: *st
raylib.step.dependOn(&gen_step.step);
const raygui_c_path = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n");
raylib.addCSourceFile(.{ .file = raygui_c_path });
raylib.addIncludePath(raygui_dep.path("src"));
raylib.addIncludePath(raylib_dep.path("src"));
raylib.root_module.addCSourceFile(.{ .file = raygui_c_path });
raylib.root_module.addIncludePath(raygui_dep.path("src"));
raylib.root_module.addIncludePath(raylib_dep.path("src"));
raylib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h");
}
@ -408,8 +426,8 @@ pub const Options = struct {
rtext: bool = true,
rtextures: bool = true,
platform: PlatformBackend = .glfw,
shared: bool = false,
linux_display_backend: LinuxDisplayBackend = .Both,
linkage: std.builtin.LinkMode = .static,
linux_display_backend: LinuxDisplayBackend = .X11,
opengl_version: OpenglVersion = .auto,
android_ndk: []const u8 = "",
android_api_version: []const u8 = "35",
@ -420,13 +438,13 @@ pub const Options = struct {
pub fn getOptions(b: *std.Build) Options {
return .{
.platform = b.option(PlatformBackend, "platform", "Choose the platform backedn for desktop target") orelse defaults.platform,
.platform = b.option(PlatformBackend, "platform", "Choose the platform backend for desktop target") orelse defaults.platform,
.raudio = b.option(bool, "raudio", "Compile with audio support") orelse defaults.raudio,
.rmodels = b.option(bool, "rmodels", "Compile with models support") orelse defaults.rmodels,
.rtext = b.option(bool, "rtext", "Compile with text support") orelse defaults.rtext,
.rtextures = b.option(bool, "rtextures", "Compile with textures support") orelse defaults.rtextures,
.rshapes = b.option(bool, "rshapes", "Compile with shapes support") orelse defaults.rshapes,
.shared = b.option(bool, "shared", "Compile as shared library") orelse defaults.shared,
.linkage = b.option(std.builtin.LinkMode, "linkage", "Compile as shared or static library") orelse defaults.linkage,
.linux_display_backend = b.option(LinuxDisplayBackend, "linux_display_backend", "Linux display backend to use") orelse defaults.linux_display_backend,
.opengl_version = b.option(OpenglVersion, "opengl_version", "OpenGL version to use") orelse defaults.opengl_version,
.config = b.option([]const u8, "config", "Compile with custom define macros overriding config.h") orelse &.{},
@ -473,14 +491,7 @@ pub const PlatformBackend = enum {
};
pub fn build(b: *std.Build) !void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
const lib = try compileRaylib(b, target, optimize, Options.getOptions(b));
@ -503,6 +514,145 @@ pub fn build(b: *std.Build) !void {
examples.dependOn(try addExamples("textures", b, target, optimize, lib));
}
fn addExamples(
comptime module: []const u8,
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
raylib: *std.Build.Step.Compile,
) !*std.Build.Step {
const all = b.step(module, "All " ++ module ++ " examples");
const module_subpath = b.pathJoin(&.{ "examples", module });
var dir = try std.fs.cwd().openDir(b.pathFromRoot(module_subpath), .{ .iterate = true });
defer dir.close();
var iter = dir.iterate();
while (try iter.next()) |entry| {
if (entry.kind != .file) continue;
const extension_idx = std.mem.lastIndexOf(u8, entry.name, ".c") orelse continue;
const name = entry.name[0..extension_idx];
const path = b.pathJoin(&.{ module_subpath, entry.name });
// zig's mingw headers do not include pthread.h
if (std.mem.eql(u8, "core_loading_thread", name) and target.result.os.tag == .windows) continue;
const exe_mod = b.createModule(.{
.target = target,
.optimize = optimize,
});
exe_mod.addCSourceFile(.{ .file = b.path(path), .flags = &.{} });
exe_mod.linkLibrary(raylib);
const run_step = b.step(name, name);
if (target.result.os.tag == .emscripten) {
const wasm = b.addLibrary(.{
.name = name,
.linkage = .static,
.root_module = exe_mod,
});
if (std.mem.eql(u8, name, "rlgl_standalone")) {
//TODO: Make rlgl_standalone example work
continue;
}
if (std.mem.eql(u8, name, "raylib_opengl_interop")) {
//TODO: Make raylib_opengl_interop example work
continue;
}
const emcc_flags = emsdk.emccDefaultFlags(b.allocator, .{ .optimize = optimize });
const emcc_settings = emsdk.emccDefaultSettings(b.allocator, .{ .optimize = optimize });
const install_dir: std.Build.InstallDir = .{ .custom = "htmlout" };
const emcc_step = emsdk.emccStep(b, raylib, wasm, .{
.optimize = optimize,
.flags = emcc_flags,
.settings = emcc_settings,
.shell_file_path = b.path("src/shell.html"),
.embed_paths = &.{
.{
.src_path = b.pathJoin(&.{ module_subpath, "resources" }),
.virtual_path = "resources",
},
},
.install_dir = install_dir,
});
const html_filename = try std.fmt.allocPrint(b.allocator, "{s}.html", .{wasm.name});
const emrun_step = emsdk.emrunStep(
b,
b.getInstallPath(install_dir, html_filename),
&.{"--no_browser"},
);
emrun_step.dependOn(emcc_step);
run_step.dependOn(emrun_step);
all.dependOn(emcc_step);
} else {
// special examples that test using these external dependencies directly
// alongside raylib
if (std.mem.eql(u8, name, "rlgl_standalone")) {
exe_mod.addIncludePath(b.path("src"));
exe_mod.addIncludePath(b.path("src/external/glfw/include"));
if (!hasCSource(raylib.root_module, "rglfw.c")) {
exe_mod.addCSourceFile(.{ .file = b.path("src/rglfw.c"), .flags = &.{} });
}
}
if (std.mem.eql(u8, name, "raylib_opengl_interop")) {
exe_mod.addIncludePath(b.path("src/external"));
}
switch (target.result.os.tag) {
.windows => {
exe_mod.linkSystemLibrary("winmm", .{});
exe_mod.linkSystemLibrary("gdi32", .{});
exe_mod.linkSystemLibrary("opengl32", .{});
exe_mod.addCMacro("PLATFORM_DESKTOP", "");
},
.linux => {
exe_mod.linkSystemLibrary("GL", .{});
exe_mod.linkSystemLibrary("rt", .{});
exe_mod.linkSystemLibrary("dl", .{});
exe_mod.linkSystemLibrary("m", .{});
exe_mod.linkSystemLibrary("X11", .{});
exe_mod.addCMacro("PLATFORM_DESKTOP", "");
},
.macos => {
exe_mod.linkFramework("Foundation", .{});
exe_mod.linkFramework("Cocoa", .{});
exe_mod.linkFramework("OpenGL", .{});
exe_mod.linkFramework("CoreAudio", .{});
exe_mod.linkFramework("CoreVideo", .{});
exe_mod.linkFramework("IOKit", .{});
exe_mod.addCMacro("PLATFORM_DESKTOP", "");
},
else => {
@panic("Unsupported OS");
},
}
const exe = b.addExecutable(.{
.name = name,
.root_module = exe_mod,
});
const install_cmd = b.addInstallArtifact(exe, .{});
const run_cmd = b.addRunArtifact(exe);
run_cmd.cwd = b.path(module_subpath);
run_cmd.step.dependOn(&install_cmd.step);
run_step.dependOn(&run_cmd.step);
all.dependOn(&install_cmd.step);
}
}
return all;
}
fn waylandGenerate(
b: *std.Build,
raylib: *std.Build.Step.Compile,
@ -516,191 +666,16 @@ fn waylandGenerate(
const client_step = b.addSystemCommand(&.{ "wayland-scanner", "client-header" });
client_step.addFileArg(b.path(protocolDir));
raylib.addIncludePath(client_step.addOutputFileArg(clientHeader).dirname());
raylib.root_module.addIncludePath(client_step.addOutputFileArg(clientHeader).dirname());
const private_step = b.addSystemCommand(&.{ "wayland-scanner", "private-code" });
private_step.addFileArg(b.path(protocolDir));
raylib.addIncludePath(private_step.addOutputFileArg(privateCode).dirname());
raylib.root_module.addIncludePath(private_step.addOutputFileArg(privateCode).dirname());
raylib.step.dependOn(&client_step.step);
raylib.step.dependOn(&private_step.step);
}
fn addExamples(
comptime module: []const u8,
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
raylib: *std.Build.Step.Compile,
) !*std.Build.Step {
const all = b.step(module, "All " ++ module ++ " examples");
const module_subpath = b.pathJoin(&.{ "examples", module });
const module_resources = b.pathJoin(&.{ module_subpath, "resources@resources" });
var dir = try std.fs.cwd().openDir(b.pathFromRoot(module_subpath), .{ .iterate = true });
defer if (comptime builtin.zig_version.minor >= 12) dir.close();
var iter = dir.iterate();
while (try iter.next()) |entry| {
if (entry.kind != .file) continue;
const extension_idx = std.mem.lastIndexOf(u8, entry.name, ".c") orelse continue;
const name = entry.name[0..extension_idx];
const path = b.pathJoin(&.{ module_subpath, entry.name });
// zig's mingw headers do not include pthread.h
if (std.mem.eql(u8, "core_loading_thread", name) and target.result.os.tag == .windows) continue;
if (target.result.os.tag == .emscripten) {
const exe_lib = b.addStaticLibrary(.{
.name = name,
.target = target,
.optimize = optimize,
});
exe_lib.addCSourceFile(.{
.file = b.path(path),
.flags = &.{},
});
exe_lib.linkLibC();
if (std.mem.eql(u8, name, "rlgl_standalone")) {
//TODO: Make rlgl_standalone example work
continue;
}
if (std.mem.eql(u8, name, "raylib_opengl_interop")) {
//TODO: Make raylib_opengl_interop example work
continue;
}
exe_lib.linkLibrary(raylib);
// Include emscripten for cross compilation
if (b.lazyDependency("emsdk", .{})) |emsdk_dep| {
if (try emSdkSetupStep(b, emsdk_dep)) |emSdkStep| {
exe_lib.step.dependOn(&emSdkStep.step);
}
exe_lib.addIncludePath(emsdk_dep.path("upstream/emscripten/cache/sysroot/include"));
// Create the output directory because emcc can't do it.
const emccOutputDirExample = b.pathJoin(&.{ emccOutputDir, name, std.fs.path.sep_str });
const mkdir_command = switch (builtin.os.tag) {
.windows => b.addSystemCommand(&.{ "cmd.exe", "/c", "if", "not", "exist", emccOutputDirExample, "mkdir", emccOutputDirExample }),
else => b.addSystemCommand(&.{ "mkdir", "-p", emccOutputDirExample }),
};
const emcc_exe = switch (builtin.os.tag) {
.windows => "emcc.bat",
else => "emcc",
};
const emcc_exe_path = b.pathJoin(&.{ emsdk_dep.path("upstream/emscripten").getPath(b), emcc_exe });
const emcc_command = b.addSystemCommand(&[_][]const u8{emcc_exe_path});
emcc_command.step.dependOn(&mkdir_command.step);
const emccOutputDirExampleWithFile = b.pathJoin(&.{ emccOutputDir, name, std.fs.path.sep_str, emccOutputFile });
emcc_command.addArgs(&[_][]const u8{
"-o",
emccOutputDirExampleWithFile,
"-sFULL-ES3=1",
"-sUSE_GLFW=3",
"-sSTACK_OVERFLOW_CHECK=1",
"-sEXPORTED_RUNTIME_METHODS=['requestFullscreen']",
"-sASYNCIFY",
"-O0",
"--emrun",
"--preload-file",
module_resources,
"--shell-file",
b.path("src/shell.html").getPath(b),
});
const link_items: []const *std.Build.Step.Compile = &.{
raylib,
exe_lib,
};
for (link_items) |item| {
emcc_command.addFileArg(item.getEmittedBin());
emcc_command.step.dependOn(&item.step);
}
const run_step = try emscriptenRunStep(b, emsdk_dep, emccOutputDirExampleWithFile);
run_step.step.dependOn(&emcc_command.step);
run_step.addArg("--no_browser");
const run_option = b.step(name, name);
run_option.dependOn(&run_step.step);
all.dependOn(&emcc_command.step);
}
} else {
const exe = b.addExecutable(.{
.name = name,
.target = target,
.optimize = optimize,
});
exe.addCSourceFile(.{ .file = b.path(path), .flags = &.{} });
exe.linkLibC();
// special examples that test using these external dependencies directly
// alongside raylib
if (std.mem.eql(u8, name, "rlgl_standalone")) {
exe.addIncludePath(b.path("src"));
exe.addIncludePath(b.path("src/external/glfw/include"));
if (!hasCSource(raylib.root_module, "rglfw.c")) {
exe.addCSourceFile(.{ .file = b.path("src/rglfw.c"), .flags = &.{} });
}
}
if (std.mem.eql(u8, name, "raylib_opengl_interop")) {
exe.addIncludePath(b.path("src/external"));
}
exe.linkLibrary(raylib);
switch (target.result.os.tag) {
.windows => {
exe.linkSystemLibrary("winmm");
exe.linkSystemLibrary("gdi32");
exe.linkSystemLibrary("opengl32");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
.linux => {
exe.linkSystemLibrary("GL");
exe.linkSystemLibrary("rt");
exe.linkSystemLibrary("dl");
exe.linkSystemLibrary("m");
exe.linkSystemLibrary("X11");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
.macos => {
exe.linkFramework("Foundation");
exe.linkFramework("Cocoa");
exe.linkFramework("OpenGL");
exe.linkFramework("CoreAudio");
exe.linkFramework("CoreVideo");
exe.linkFramework("IOKit");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
else => {
@panic("Unsupported OS");
},
}
const install_cmd = b.addInstallArtifact(exe, .{});
const run_cmd = b.addRunArtifact(exe);
run_cmd.cwd = b.path(module_subpath);
run_cmd.step.dependOn(&install_cmd.step);
const run_step = b.step(name, name);
run_step.dependOn(&run_cmd.step);
all.dependOn(&install_cmd.step);
}
}
return all;
}
fn hasCSource(module: *std.Build.Module, name: []const u8) bool {
for (module.link_objects.items) |o| switch (o) {
.c_source_file => |c| if (switch (c.file) {

View File

@ -1,7 +1,7 @@
.{
.name = .raylib,
.version = "5.5.0",
.minimum_zig_version = "0.14.0",
.version = "5.6.0-dev",
.minimum_zig_version = "0.15.1",
.fingerprint = 0x13035e5cb8bc1ac2, // Changing this has security and trust implications.
@ -14,7 +14,10 @@
.emsdk = .{
.url = "git+https://github.com/emscripten-core/emsdk#4.0.9",
.hash = "N-V-__8AAJl1DwBezhYo_VE6f53mPVm00R-Fk28NPW7P14EQ",
.lazy = true,
},
.zemscripten = .{
.url = "git+https://github.com/zig-gamedev/zemscripten#3fa4b778852226c7346bdcc3c1486e875a9a6d02",
.hash = "zemscripten-0.2.0-dev-sRlDqApRAACspTbAZnuNKWIzfWzSYgYkb2nWAXZ-tqqt",
},
},

View File

@ -19,9 +19,18 @@ join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
configure_file(../raylib.pc.in raylib.pc @ONLY)
configure_file(../cmake/raylib-config-version.cmake raylib-config-version.cmake @ONLY)
configure_file(../cmake/raylib-config.cmake raylib-config.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib")
install(FILES ${PROJECT_SOURCE_DIR}/../cmake/raylib-config.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib")
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/raylib-config.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/raylib
)
install(EXPORT raylib-targets
FILE raylib-targets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/raylib
)
# populates raylib_{FOUND, INCLUDE_DIRS, LIBRARIES, LDFLAGS, DEFINITIONS}
include(PopulateConfigVariablesLocally)

View File

@ -7,6 +7,8 @@ if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
endif()
set(RAYLIB_DEPENDENCIES "include(CMakeFindDependencyMacro)")
if (${PLATFORM} MATCHES "Desktop")
set(PLATFORM_CPP "PLATFORM_DESKTOP")
@ -36,7 +38,8 @@ if (${PLATFORM} MATCHES "Desktop")
find_library(OSS_LIBRARY ossaudio)
endif ()
set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
set(LIBS_PRIVATE pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
set(LIBS_PUBLIC m)
else ()
find_library(pthread NAMES pthread)
find_package(OpenGL QUIET)
@ -44,11 +47,13 @@ if (${PLATFORM} MATCHES "Desktop")
set(OPENGL_LIBRARIES "GL")
endif ()
set(LIBS_PRIVATE m atomic pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
set(LIBS_PRIVATE pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
set(LIBS_PUBLIC m)
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
find_library(OSS_LIBRARY ossaudio)
set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
else ()
set(LIBS_PRIVATE ${LIBS_PRIVATE} atomic)
endif ()
if (NOT "${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD" AND USE_AUDIO)
@ -80,7 +85,8 @@ elseif (${PLATFORM} MATCHES "Android")
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")
find_library(OPENGL_LIBRARY OpenGL)
set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c)
set(LIBS_PRIVATE log android EGL GLESv2 OpenSLES atomic c)
set(LIBS_PUBLIC m)
elseif ("${PLATFORM}" MATCHES "DRM")
set(PLATFORM_CPP "PLATFORM_DRM")
@ -98,13 +104,45 @@ elseif ("${PLATFORM}" MATCHES "DRM")
if (NOT CMAKE_CROSSCOMPILING OR NOT CMAKE_SYSROOT)
include_directories(/usr/include/libdrm)
endif ()
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} atomic pthread m dl)
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} atomic pthread dl)
set(LIBS_PUBLIC m)
elseif ("${PLATFORM}" MATCHES "SDL")
find_package(SDL2 REQUIRED)
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
set(LIBS_PRIVATE SDL2::SDL2)
# First, check if SDL is included as a subdirectory
if(TARGET SDL3::SDL3)
message(STATUS "Using SDL3 from subdirectory")
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
set(LIBS_PRIVATE SDL3::SDL3)
add_compile_definitions(USING_SDL3_PROJECT)
elseif(TARGET SDL2::SDL2)
message(STATUS "Using SDL2 from subdirectory")
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
set(LIBS_PRIVATE SDL2::SDL2)
add_compile_definitions(USING_SDL2_PROJECT)
else()
# No SDL added via add_subdirectory(), try find_package()
message(STATUS "No SDL target from subdirectory, searching via find_package()...")
# First try SDL3
find_package(SDL3 QUIET)
if(SDL3_FOUND)
message(STATUS "Found SDL3 via find_package()")
set(LIBS_PUBLIC SDL3::SDL3)
set(RAYLIB_DEPENDENCIES "${RAYLIB_DEPENDENCIES}\nfind_dependency(SDL3 REQUIRED)")
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
add_compile_definitions(USING_SDL3_PACKAGE)
else()
# Fallback to SDL2
find_package(SDL2 REQUIRED)
message(STATUS "Found SDL2 via find_package()")
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
set(LIBS_PUBLIC SDL2::SDL2)
set(RAYLIB_DEPENDENCIES "${RAYLIB_DEPENDENCIES}\nfind_dependency(SDL3 REQUIRED)")
add_compile_definitions(USING_SDL2_PACKAGE)
endif()
endif()
elseif ("${PLATFORM}" MATCHES "RGFW")
set(PLATFORM_CPP "PLATFORM_DESKTOP_RGFW")
endif ()
if (NOT ${OPENGL_VERSION} MATCHES "OFF")
@ -122,6 +160,8 @@ if (NOT ${OPENGL_VERSION} MATCHES "OFF")
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
elseif (${OPENGL_VERSION} MATCHES "ES 3.0")
set(GRAPHICS "GRAPHICS_API_OPENGL_ES3")
elseif (${OPENGL_VERSION} MATCHES "Software")
set(GRAPHICS "GRAPHICS_API_OPENGL_11_SOFTWARE")
endif ()
if (NOT "${SUGGESTED_GRAPHICS}" STREQUAL "" AND NOT "${SUGGESTED_GRAPHICS}" STREQUAL "${GRAPHICS}")
message(WARNING "You are overriding the suggested GRAPHICS=${SUGGESTED_GRAPHICS} with ${GRAPHICS}! This may fail.")

View File

@ -1,81 +1,4 @@
# - Try to find raylib
# Options:
# raylib_USE_STATIC_LIBS - ON by default
# raylib_VERBOSE - OFF by default
# Once done, this defines a raylib target that can be passed to
# target_link_libraries as well as following variables:
#
# raylib_FOUND - System has raylib installed
# raylib_INCLUDE_DIRS - The include directories for the raylib header(s)
# raylib_LIBRARIES - The libraries needed to use raylib
# raylib_LDFLAGS - The linker flags needed with raylib
# raylib_DEFINITIONS - Compiler switches required for using raylib
@PACKAGE_INIT@
@RAYLIB_DEPENDENCIES@
option(raylib_USE_STATIC_LIBS "Use static libs" ON)
option(raylib_VERBOSE "Show raylib verbose messages" OFF)
if (NOT TARGET raylib)
set(XPREFIX PC_RAYLIB)
find_package(PkgConfig QUIET)
pkg_check_modules(${XPREFIX} QUIET raylib)
if (raylib_USE_STATIC_LIBS)
set(XPREFIX ${XPREFIX}_STATIC)
endif()
set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
find_path(raylib_INCLUDE_DIR
NAMES raylib.h
HINTS ${${XPREFIX}_INCLUDE_DIRS} ${raylib_DIR}/../../../include/
)
if (raylib_USE_STATIC_LIBS)
set(RAYLIB_NAMES libraylib.a raylib.lib)
else ()
set(RAYLIB_NAMES raylib)
endif ()
find_library(raylib_LIBRARY
NAMES ${RAYLIB_NAMES}
HINTS ${${XPREFIX}_LIBRARY_DIRS} ${raylib_DIR}/../../
)
set(raylib_LIBRARIES ${raylib_LIBRARY})
set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR})
set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(raylib DEFAULT_MSG
raylib_LIBRARY
raylib_INCLUDE_DIR
)
mark_as_advanced(raylib_LIBRARY raylib_INCLUDE_DIR)
if (raylib_USE_STATIC_LIBS)
add_library(raylib STATIC IMPORTED GLOBAL)
else()
add_library(raylib SHARED IMPORTED GLOBAL)
endif()
string (REPLACE ";" " " raylib_LDFLAGS "${raylib_LDFLAGS}")
set_target_properties(raylib
PROPERTIES
IMPORTED_LOCATION "${raylib_LIBRARIES}"
IMPORTED_IMPLIB "${raylib_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}"
INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}"
)
if (raylib_VERBOSE)
message(STATUS "raylib_FOUND: ${raylib_FOUND}")
message(STATUS "raylib_INCLUDE_DIRS: ${raylib_INCLUDE_DIRS}")
message(STATUS "raylib_LIBRARIES: ${raylib_LIBRARIES}")
message(STATUS "raylib_LDFLAGS: ${raylib_LDFLAGS}")
message(STATUS "raylib_DEFINITIONS: ${raylib_DEFINITIONS}")
endif()
endif()
include("${CMAKE_CURRENT_LIST_DIR}/raylib-targets.cmake")

View File

@ -97,22 +97,18 @@ if (${PLATFORM} MATCHES "Android")
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_basic_lighting.c)
elseif (${PLATFORM} MATCHES "Web")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os")
# Since WASM is used, ALLOW_MEMORY_GROWTH has no extra overheads
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s WASM=1 -s ASYNCIFY -s ALLOW_MEMORY_GROWTH=1 --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c)
# Remove the -rdynamic flag because otherwise emscripten
# 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}")
set(example_sources) # clear example_sources
list(APPEND example_sources others/web_basic_window.c)
list(APPEND example_sources core/core_input_gestures_testbed.c)
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)
elseif ("${OPENGL_VERSION}" STREQUAL "Software")
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)
elseif (NOT SUPPORT_GESTURES_SYSTEM)
# Items requiring gestures system
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/textures/textures_mouse_painting.c)
@ -165,10 +161,34 @@ foreach (example_source ${example_sources})
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
string(APPEND resources_dir "resources")
if (${PLATFORM} MATCHES "Web" AND EXISTS ${resources_dir})
# The local resources path needs to be mapped to /resources virtual path
string(APPEND resources_dir "@resources")
set_target_properties(${example_name} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir}")
if (${PLATFORM} MATCHES "Web")
target_compile_options(${example_name} PRIVATE -Os)
target_link_options(${example_name} PRIVATE
-sALLOW_MEMORY_GROWTH=1
-sEXPORTED_RUNTIME_METHODS=[requestFullscreen]
-sUSE_GLFW=3
--shell-file "${CMAKE_SOURCE_DIR}/src/shell.html"
)
set_target_properties(${example_name} PROPERTIES SUFFIX ".html")
if (EXISTS ${resources_dir})
# The local resources path needs to be mapped to /resources virtual path
string(APPEND resources_dir "@resources")
set_target_properties(${example_name} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir}")
endif ()
if(${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_ES3")
target_link_options(${example_name} PUBLIC "-sMIN_WEBGL_VERSION=2")
target_link_options(${example_name} PUBLIC "-sMAX_WEBGL_VERSION=2")
endif()
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
if (APPLE)
target_link_libraries(${example_name} "-framework IOKit")
target_link_libraries(${example_name} "-framework Cocoa")
target_link_libraries(${example_name} "-framework OpenGL")
endif()
endif ()
endforeach ()

View File

@ -77,7 +77,7 @@ RAYLIB_SRC_PATH ?= ../src
# Locations of raylib.h and libraylib.a/libraylib.so
# NOTE: Those variables are only used for PLATFORM_OS: LINUX, BSD
DESTDIR ?= /usr/local
DESTDIR ?= /usr/local
RAYLIB_INCLUDE_PATH ?= $(DESTDIR)/include
RAYLIB_LIB_PATH ?= $(DESTDIR)/lib
@ -106,6 +106,9 @@ BUILD_WEB_SHELL ?= $(RAYLIB_PATH)/src/minshell.html
BUILD_WEB_HEAP_SIZE ?= 134217728
BUILD_WEB_RESOURCES ?= TRUE
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
# Use WebGL2 backend (OpenGL 3.0)
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
BUILD_WEB_WEBGL2 ?= FALSE
# Determine PLATFORM_OS when required
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_WEB_RGFW))
@ -186,7 +189,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
endif
endif
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# HTML5 emscripten compiler
# HTML5 emscripten compiler
# WARNING: To compile to HTML5, code must be redesigned
# to use emscripten.h and emscripten_set_main_loop()
CC = emcc
@ -228,7 +231,7 @@ endif
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -Wno-unused-value ignore unused return values of some functions (i.e. fread())
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result
CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wno-unused-result
ifeq ($(BUILD_MODE),DEBUG)
CFLAGS += -g -D_DEBUG
@ -269,8 +272,8 @@ endif
# NOTE: Some external/extras libraries could be required (stb, easings...)
#------------------------------------------------------------------------------------------------
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external $(EXTRA_INCLUDE_PATHS)
# Define additional directories containing required header files
# Define additional directories containing required header files
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(PLATFORM_OS),BSD)
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) -I/usr/pkg/include -I/usr/X11R7/include
@ -287,11 +290,6 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
INCLUDE_PATHS += -I/usr/include/libdrm
endif
# Include GLFW required for examples/others/rlgl_standalone.c
ifeq ($(USE_EXTERNAL_GLFW),FALSE)
all others: INCLUDE_PATHS += -I$(RAYLIB_PATH)/src/external/glfw/include
endif
# Define library paths containing required libs: LDFLAGS
#------------------------------------------------------------------------------------------------
LDFLAGS = -L. -L$(RAYLIB_RELEASE_PATH) -L$(RAYLIB_PATH)/src
@ -340,18 +338,24 @@ ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_R
# --preload-file resources # specify a resources folder for data compilation
# --source-map-base # allow debugging in browser with source map
# --shell-file shell.html # define a custom shell .html and output extension
LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1 -sMINIFY_HTML=0
LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1 -sEXPORTED_RUNTIME_METHODS=ccall -sMINIFY_HTML=0
# Using GLFW3 library (instead of RGFW)
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
LDFLAGS += -sUSE_GLFW=3
endif
# Build using asyncify
# Build using asyncify
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
LDFLAGS += -sASYNCIFY
endif
# NOTE: Flags required for WebGL 2.0 (OpenGL ES 3.0)
# WARNING: Requires raylib compiled with GRAPHICS_API_OPENGL_ES3
ifeq ($(BUILD_WEB_WEBGL2),TRUE)
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2
endif
# Add resources building if required
ifeq ($(BUILD_WEB_RESOURCES),TRUE)
LDFLAGS += --preload-file $(BUILD_WEB_RESOURCES_PATH)
@ -482,21 +486,37 @@ endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
# Libraries for DRM compiling
# NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic
LDLIBS = -lraylib -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl -latomic
# TODO: Examples compilation does not define GRAPHICS, is it required?
#ifeq ($(GRAPHICS),GRAPHICS_API_OPENGL_ES2)
# LDLIBS += -lGLESv2 -lEGL
#endif
endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_WIN32)
# Libraries for Windows desktop compilation
LDFLAGS += -L..\src
LDLIBS = -lraylib -lgdi32 -lwinmm -lshcore
ifneq ($(GRAPHICS),GRAPHICS_API_OPENGL_11_SOFTWARE)
LDLIBS += -lopengl32
endif
endif
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a
endif
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
# Define source code object files required
#------------------------------------------------------------------------------------------------
#EXAMPLES_LIST_START
CORE = \
core/core_2d_camera \
core/core_2d_camera_mouse_zoom \
core/core_2d_camera_platformer \
core/core_2d_camera_split_screen \
core/core_3d_camera_first_person \
core/core_3d_camera_fps \
core/core_3d_camera_free \
core/core_3d_camera_mode \
core/core_3d_camera_split_screen \
@ -504,25 +524,35 @@ CORE = \
core/core_automation_events \
core/core_basic_screen_manager \
core/core_basic_window \
core/core_basic_window_web \
core/core_clipboard_text \
core/core_compute_hash \
core/core_custom_frame_control \
core/core_custom_logging \
core/core_delta_time \
core/core_directory_files \
core/core_drop_files \
core/core_high_dpi \
core/core_highdpi_demo \
core/core_highdpi_testbed \
core/core_input_actions \
core/core_input_gamepad \
core/core_input_gestures \
core/core_input_gestures_web \
core/core_input_gestures_testbed \
core/core_input_keys \
core/core_input_mouse \
core/core_input_mouse_wheel \
core/core_input_multitouch \
core/core_input_virtual_controls \
core/core_loading_thread \
core/core_monitor_detector \
core/core_random_sequence \
core/core_random_values \
core/core_render_texture \
core/core_scissor_test \
core/core_screen_recording \
core/core_smooth_pixelperfect \
core/core_storage_values \
core/core_text_file_loading \
core/core_undo_redo \
core/core_viewport_scaling \
core/core_vr_simulator \
core/core_window_flags \
core/core_window_letterbox \
@ -530,31 +560,50 @@ CORE = \
core/core_world_screen
SHAPES = \
shapes/shapes_ball_physics \
shapes/shapes_basic_shapes \
shapes/shapes_bouncing_ball \
shapes/shapes_bullet_hell \
shapes/shapes_circle_sector_drawing \
shapes/shapes_clock_of_clocks \
shapes/shapes_collision_area \
shapes/shapes_colors_palette \
shapes/shapes_draw_circle_sector \
shapes/shapes_draw_rectangle_rounded \
shapes/shapes_draw_ring \
shapes/shapes_easings_ball_anim \
shapes/shapes_easings_box_anim \
shapes/shapes_easings_rectangle_array \
shapes/shapes_dashed_line \
shapes/shapes_digital_clock \
shapes/shapes_double_pendulum \
shapes/shapes_easings_ball \
shapes/shapes_easings_box \
shapes/shapes_easings_rectangles \
shapes/shapes_following_eyes \
shapes/shapes_kaleidoscope \
shapes/shapes_lines_bezier \
shapes/shapes_lines_drawing \
shapes/shapes_logo_raylib \
shapes/shapes_logo_raylib_anim \
shapes/shapes_math_angle_rotation \
shapes/shapes_math_sine_cosine \
shapes/shapes_mouse_trail \
shapes/shapes_penrose_tile \
shapes/shapes_pie_chart \
shapes/shapes_rectangle_advanced \
shapes/shapes_rectangle_scaling \
shapes/shapes_recursive_tree \
shapes/shapes_ring_drawing \
shapes/shapes_rlgl_color_wheel \
shapes/shapes_rlgl_triangle \
shapes/shapes_rounded_rectangle_drawing \
shapes/shapes_simple_particles \
shapes/shapes_splines_drawing \
shapes/shapes_starfield_effect \
shapes/shapes_top_down_lights \
shapes/shapes_digital_clock
shapes/shapes_triangle_strip \
shapes/shapes_vector_angle
TEXTURES = \
textures/textures_background_scrolling \
textures/textures_blend_modes \
textures/textures_bunnymark \
textures/textures_draw_tiled \
textures/textures_cellular_automata \
textures/textures_fog_of_war \
textures/textures_gif_player \
textures/textures_image_channel \
@ -569,40 +618,49 @@ TEXTURES = \
textures/textures_mouse_painting \
textures/textures_npatch_drawing \
textures/textures_particles_blending \
textures/textures_polygon \
textures/textures_polygon_drawing \
textures/textures_raw_data \
textures/textures_sprite_anim \
textures/textures_screen_buffer \
textures/textures_sprite_animation \
textures/textures_sprite_button \
textures/textures_sprite_explosion \
textures/textures_sprite_stacking \
textures/textures_srcrec_dstrec \
textures/textures_textured_curve \
textures/textures_tiled_drawing \
textures/textures_to_image
TEXT = \
text/text_3d_drawing \
text/text_codepoints_loading \
text/text_draw_3d \
text/text_font_filters \
text/text_font_loading \
text/text_font_sdf \
text/text_font_spritefont \
text/text_format_text \
text/text_inline_styling \
text/text_input_box \
text/text_raylib_fonts \
text/text_rectangle_bounds \
text/text_unicode \
text/text_sprite_fonts \
text/text_strings_management \
text/text_unicode_emojis \
text/text_unicode_ranges \
text/text_words_alignment \
text/text_writing_anim
MODELS = \
models/models_animation \
models/models_billboard \
models/models_animation_gpu_skinning \
models/models_animation_playing \
models/models_basic_voxel \
models/models_billboard_rendering \
models/models_bone_socket \
models/models_box_collisions \
models/models_cubicmap \
models/models_draw_cube_texture \
models/models_cubicmap_rendering \
models/models_decals \
models/models_directional_billboard \
models/models_first_person_maze \
models/models_geometric_shapes \
models/models_gpu_skinning \
models/models_heightmap \
models/models_heightmap_rendering \
models/models_loading \
models/models_loading_gltf \
models/models_loading_m3d \
@ -612,39 +670,46 @@ MODELS = \
models/models_orthographic_projection \
models/models_point_rendering \
models/models_rlgl_solar_system \
models/models_skybox \
models/models_rotating_cube \
models/models_skybox_rendering \
models/models_tesseract_view \
models/models_textured_cube \
models/models_waving_cubes \
models/models_yaw_pitch_roll
SHADERS = \
shaders/shaders_ascii_rendering \
shaders/shaders_basic_lighting \
shaders/shaders_basic_pbr \
shaders/shaders_color_correction \
shaders/shaders_custom_uniform \
shaders/shaders_deferred_render \
shaders/shaders_eratosthenes \
shaders/shaders_fog \
shaders/shaders_deferred_rendering \
shaders/shaders_depth_rendering \
shaders/shaders_depth_writing \
shaders/shaders_eratosthenes_sieve \
shaders/shaders_fog_rendering \
shaders/shaders_game_of_life \
shaders/shaders_hot_reloading \
shaders/shaders_hybrid_render \
shaders/shaders_hybrid_rendering \
shaders/shaders_julia_set \
shaders/shaders_lightmap \
shaders/shaders_lightmap_rendering \
shaders/shaders_mandelbrot_set \
shaders/shaders_mesh_instancing \
shaders/shaders_model_shader \
shaders/shaders_multi_sample2d \
shaders/shaders_normalmap_rendering \
shaders/shaders_palette_switch \
shaders/shaders_postprocessing \
shaders/shaders_raymarching \
shaders/shaders_raymarching_rendering \
shaders/shaders_rounded_rectangle \
shaders/shaders_shadowmap \
shaders/shaders_shadowmap_rendering \
shaders/shaders_shapes_textures \
shaders/shaders_simple_mask \
shaders/shaders_spotlight \
shaders/shaders_texture_drawing \
shaders/shaders_spotlight_rendering \
shaders/shaders_texture_outline \
shaders/shaders_texture_rendering \
shaders/shaders_texture_tiling \
shaders/shaders_texture_waves \
shaders/shaders_view_depth \
shaders/shaders_write_depth \
shaders/shaders_vertex_displacement
AUDIO = \
@ -655,25 +720,22 @@ AUDIO = \
audio/audio_sound_loading \
audio/audio_sound_multi \
audio/audio_sound_positioning \
audio/audio_spectrum_visualizer \
audio/audio_stream_effects
OTHERS = \
others/easings_testbed \
others/embedded_files_loading \
others/raylib_opengl_interop \
others/raymath_vector_angle \
others/rlgl_compute_shader
ifeq ($(TARGET_PLATFORM), PLATFORM_DESKTOP_GFLW)
OTHERS += others/rlgl_standalone
endif
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
others/rlgl_compute_shader \
others/rlgl_standalone \
others/web_basic_window
#EXAMPLES_LIST_END
# Define processes to execute
#------------------------------------------------------------------------------------------------
# Default target entry
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO) $(OTHERS)
all: $(CORE) $(SHAPES) $(TEXT) $(TEXTURES) $(MODELS) $(SHADERS) $(AUDIO)
core: $(CORE)
shapes: $(SHAPES)
@ -682,7 +744,6 @@ text: $(TEXT)
models: $(MODELS)
shaders: $(SHADERS)
audio: $(AUDIO)
others: $(OTHERS)
# Generic compilation pattern
# NOTE: Examples must be ready for Android compilation!

View File

@ -130,7 +130,7 @@ ifeq ($(ANDROID_ARCH),ARM)
CFLAGS = -std=c99 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
endif
ifeq ($(ANDROID_ARCH),ARM64)
CFLAGS = -std=c99 -target aarch64 -mfix-cortex-a53-835769
CFLAGS = -std=c99 -mfix-cortex-a53-835769
endif
# Compilation functions attributes options
CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@ The examples assume you have already built the `raylib` library in `../src`.
- `make` builds all examples
- `make [module]` builds all examples for a particular module (e.g `make core`)
- `make [module]/[name]` builds one examples for a particular module (e.g `make core/core_basic_window`)
### With Zig
@ -16,219 +17,268 @@ You may find it easier to use than other toolchains, especially when it comes to
- `zig build [module]` to compile all examples for a module (e.g. `zig build core`)
- `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)
## EXAMPLES LIST
## EXAMPLES COLLECTION [TOTAL: 205]
### category: core
### category: core [47]
Examples using raylib core platform functionality like window creation, inputs, drawing modes and system functionality.
Examples using raylib [core](../src/rcore.c) module platform functionality: window creation, inputs, drawing modes and system functionality.
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 01 | [core_basic_window](core/core_basic_window.c) | <img src="core/core_basic_window.png" alt="core_basic_window" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
| 02 | [core_input_keys](core/core_input_keys.c) | <img src="core/core_input_keys.png" alt="core_input_keys" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
| 03 | [core_input_mouse](core/core_input_mouse.c) | <img src="core/core_input_mouse.png" alt="core_input_mouse" width="80"> | ⭐☆☆☆ | 1.0 | 5.5 | [Ray](https://github.com/raysan5) |
| 04 | [core_input_mouse_wheel](core/core_input_mouse_wheel.c) | <img src="core/core_input_mouse_wheel.png" alt="core_input_mouse_wheel" width="80"> | ⭐☆☆☆ | 1.1 | 1.3 | [Ray](https://github.com/raysan5) |
| 05 | [core_input_gamepad](core/core_input_gamepad.c) | <img src="core/core_input_gamepad.png" alt="core_input_gamepad" width="80"> | ⭐☆☆☆ | 1.1 | 4.2 | [Ray](https://github.com/raysan5) |
| 06 | [core_input_multitouch](core/core_input_multitouch.c) | <img src="core/core_input_multitouch.png" alt="core_input_multitouch" width="80"> | ⭐☆☆☆ | 2.1 | 2.5 | [Berni](https://github.com/Berni8k) |
| 07 | [core_input_gestures](core/core_input_gestures.c) | <img src="core/core_input_gestures.png" alt="core_input_gestures" width="80"> | ⭐️⭐️☆☆ | 1.4 | 4.2 | [Ray](https://github.com/raysan5) |
| 08 | [core_input_virtual_controls](core/core_input_virtual_controls.c) | <img src="core/core_input_virtual_controls.png" alt="core_input_virtual_controls" width="80"> | ⭐️⭐️☆☆ | 5.0 | 5.0 | [oblerion](https://github.com/oblerion) |
| 09 | [core_2d_camera](core/core_2d_camera.c) | <img src="core/core_2d_camera.png" alt="core_2d_camera" width="80"> | ⭐️⭐️☆☆ | 1.5 | 3.0 | [Ray](https://github.com/raysan5) |
| 10 | [core_2d_camera_mouse_zoom](core/core_2d_camera_mouse_zoom.c) | <img src="core/core_2d_camera_mouse_zoom.png" alt="core_2d_camera_mouse_zoom" width="80"> | ⭐️⭐️☆☆ | 4.2 | 4.2 | [Jeffery Myers](https://github.com/JeffM2501) |
| 11 | [core_2d_camera_platformer](core/core_2d_camera_platformer.c) | <img src="core/core_2d_camera_platformer.png" alt="core_2d_camera_platformer" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.0 | [arvyy](https://github.com/arvyy) |
| 12 | [core_2d_camera_split_screen](core/core_2d_camera_split_screen.c) | <img src="core/core_2d_camera_split_screen.png" alt="core_2d_camera_split_screen" width="80"> | ⭐️⭐️⭐️⭐️ | 4.5 | 4.5 | [Gabriel dos Santos Sanches](https://github.com/gabrielssanches) |
| 13 | [core_3d_camera_mode](core/core_3d_camera_mode.c) | <img src="core/core_3d_camera_mode.png" alt="core_3d_camera_mode" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
| 14 | [core_3d_camera_free](core/core_3d_camera_free.c) | <img src="core/core_3d_camera_free.png" alt="core_3d_camera_free" width="80"> | ⭐️☆☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
| 15 | [core_3d_camera_first_person](core/core_3d_camera_first_person.c) | <img src="core/core_3d_camera_first_person.png" alt="core_3d_camera_first_person" width="80"> | ⭐️⭐️☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
| 16 | [core_3d_camera_split_screen](core/core_3d_camera_split_screen.c) | <img src="core/core_3d_camera_split_screen.png" alt="core_3d_camera_split_screen" width="80"> | ⭐️⭐️⭐️☆ | 3.7 | 4.0 | [Jeffery Myers](https://github.com/JeffM2501) |
| 17 | [core_3d_picking](core/core_3d_picking.c) | <img src="core/core_3d_picking.png" alt="core_3d_picking" width="80"> | ⭐️⭐️☆☆ | 1.3 | 4.0 | [Ray](https://github.com/raysan5) |
| 18 | [core_world_screen](core/core_world_screen.c) | <img src="core/core_world_screen.png" alt="core_world_screen" width="80"> | ⭐️⭐️☆☆ | 1.3 | 1.4 | [Ray](https://github.com/raysan5) |
| 19 | [core_custom_logging](core/core_custom_logging.c) | <img src="core/core_custom_logging.png" alt="core_custom_logging" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 2.5 | [Pablo Marcos Oltra](https://github.com/pamarcos) |
| 20 | [core_window_flags](core/core_window_flags.c) | <img src="core/core_window_flags.png" alt="core_window_flags" width="80"> | ⭐️⭐️⭐️☆ | 3.5 | 3.5 | [Ray](https://github.com/raysan5) |
| 21 | [core_window_letterbox](core/core_window_letterbox.c) | <img src="core/core_window_letterbox.png" alt="core_window_letterbox" width="80"> | ⭐️⭐️☆☆ | 2.5 | 4.0 | [Anata](https://github.com/anatagawa) |
| 22 | [core_window_should_close](core/core_window_should_close.c) | <img src="core/core_window_should_close.png" alt="core_window_should_close" width="80"> | ⭐️☆☆☆ | 4.2 | 4.2 | [Ray](https://github.com/raysan5) |
| 23 | [core_drop_files](core/core_drop_files.c) | <img src="core/core_drop_files.png" alt="core_drop_files" width="80"> | ⭐️⭐️☆☆ | 1.3 | 4.2 | [Ray](https://github.com/raysan5) |
| 24 | [core_random_values](core/core_random_values.c) | <img src="core/core_random_values.png" alt="core_random_values" width="80"> | ⭐☆☆☆ | 1.1 | 1.1 | [Ray](https://github.com/raysan5) |
| 25 | [core_storage_values](core/core_storage_values.c) | <img src="core/core_storage_values.png" alt="core_storage_values" width="80"> | ⭐️⭐️☆☆ | 1.4 | 4.2 | [Ray](https://github.com/raysan5) |
| 26 | [core_vr_simulator](core/core_vr_simulator.c) | <img src="core/core_vr_simulator.png" alt="core_vr_simulator" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 4.0 | [Ray](https://github.com/raysan5) |
| 27 | [core_loading_thread](core/core_loading_thread.c) | <img src="core/core_loading_thread.png" alt="core_loading_thread" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.0 | [Ray](https://github.com/raysan5) |
| 28 | [core_scissor_test](core/core_scissor_test.c) | <img src="core/core_scissor_test.png" alt="core_scissor_test" width="80"> | ⭐☆☆☆ | 2.5 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) |
| 29 | [core_basic_screen_manager](core/core_basic_screen_manager.c) | <img src="core/core_basic_screen_manager.png" alt="core_basic_screen_manager" width="80"> | ⭐️☆☆☆ | 4.0 | 4.0 | [Ray](https://github.com/raysan5) |
| 30 | [core_custom_frame_control](core/core_custom_frame_control.c) | <img src="core/core_custom_frame_control.png" alt="core_custom_frame_control" width="80"> | ⭐️⭐️⭐️⭐️ | 4.0 | 4.0 | [Ray](https://github.com/raysan5) |
| 31 | [core_smooth_pixelperfect](core/core_smooth_pixelperfect.c) | <img src="core/core_smooth_pixelperfect.png" alt="core_smooth_pixelperfect" width="80"> | ⭐️⭐️⭐️☆ | 3.7 | 4.0 | [Giancamillo Alessandroni](https://github.com/NotManyIdeasDev) |
| 32 | [core_random_sequence](core/core_random_sequence.c) | <img src="core/core_random_sequence.png" alt="core_random_sequence" width="80"> | ⭐☆☆☆ | 5.0 | 5.0 | [Dalton Overmyer](https://github.com/REDl3east) |
| 33 | [core_basic_window_web](core/core_basic_window_web.c) | <img src="core/core_basic_window_web.png" alt="core_basic_window_web" width="80"> | ⭐️☆☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
| 34 | [core_input_gestures_web](core/core_input_gestures_web.c) | <img src="core/core_input_gestures_web.png" alt="core_input_gestures_web" width="80"> | ⭐️⭐️☆☆ | 4.6-dev | 4.6-dev | [ubkp](https://github.com/ubkp) |
| 35 | [core_automation_events](core/core_automation_events.c) | <img src="core/core_automation_events.png" alt="core_automation_events" width="80"> | ⭐️⭐️⭐️☆ | 5.0 | 5.0 | [Ray](https://github.com/raysan5) |
| 36 | [core_high_dpi](core/core_high_dpi.c) | <img src="core/core_high_dpi.png" alt="core_high_dpi" width="80"> | ⭐️☆☆☆ | 5.0 | 5.0 | [Jonathan Marler](https://github.com/marler8997) |
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| [core_basic_window](core/core_basic_window.c) | <img src="core/core_basic_window.png" alt="core_basic_window" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_delta_time](core/core_delta_time.c) | <img src="core/core_delta_time.png" alt="core_delta_time" width="80"> | ⭐☆☆☆ | 5.5 | 5.6-dev | [Robin](https://github.com/RobinsAviary) |
| [core_input_keys](core/core_input_keys.c) | <img src="core/core_input_keys.png" alt="core_input_keys" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_input_mouse](core/core_input_mouse.c) | <img src="core/core_input_mouse.png" alt="core_input_mouse" width="80"> | ⭐☆☆☆ | 1.0 | 5.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_input_mouse_wheel](core/core_input_mouse_wheel.c) | <img src="core/core_input_mouse_wheel.png" alt="core_input_mouse_wheel" width="80"> | ⭐☆☆☆ | 1.1 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_input_gamepad](core/core_input_gamepad.c) | <img src="core/core_input_gamepad.png" alt="core_input_gamepad" width="80"> | ⭐☆☆☆ | 1.1 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_input_multitouch](core/core_input_multitouch.c) | <img src="core/core_input_multitouch.png" alt="core_input_multitouch" width="80"> | ⭐☆☆ | 2.1 | 2.5 | [Berni](https://github.com/Berni8k) |
| [core_input_gestures](core/core_input_gestures.c) | <img src="core/core_input_gestures.png" alt="core_input_gestures" width="80"> | ⭐☆☆ | 1.4 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_input_gestures_testbed](core/core_input_gestures_testbed.c) | <img src="core/core_input_gestures_testbed.png" alt="core_input_gestures_testbed" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.6-dev | [ubkp](https://github.com/ubkp) |
| [core_input_virtual_controls](core/core_input_virtual_controls.c) | <img src="core/core_input_virtual_controls.png" alt="core_input_virtual_controls" width="80"> | ⭐☆☆ | 5.0 | 5.0 | [GreenSnakeLinux](https://github.com/GreenSnakeLinux) |
| [core_2d_camera](core/core_2d_camera.c) | <img src="core/core_2d_camera.png" alt="core_2d_camera" width="80"> | ⭐⭐☆☆ | 1.5 | 3.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_2d_camera_mouse_zoom](core/core_2d_camera_mouse_zoom.c) | <img src="core/core_2d_camera_mouse_zoom.png" alt="core_2d_camera_mouse_zoom" width="80"> | ⭐⭐☆☆ | 4.2 | 4.2 | [Jeffery Myers](https://github.com/JeffM2501) |
| [core_2d_camera_platformer](core/core_2d_camera_platformer.c) | <img src="core/core_2d_camera_platformer.png" alt="core_2d_camera_platformer" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.0 | [arvyy](https://github.com/arvyy) |
| [core_2d_camera_split_screen](core/core_2d_camera_split_screen.c) | <img src="core/core_2d_camera_split_screen.png" alt="core_2d_camera_split_screen" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [Gabriel dos Santos Sanches](https://github.com/gabrielssanches) |
| [core_3d_camera_mode](core/core_3d_camera_mode.c) | <img src="core/core_3d_camera_mode.png" alt="core_3d_camera_mode" width="80"> | ⭐☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_3d_camera_free](core/core_3d_camera_free.c) | <img src="core/core_3d_camera_free.png" alt="core_3d_camera_free" width="80"> | ⭐☆☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_3d_camera_first_person](core/core_3d_camera_first_person.c) | <img src="core/core_3d_camera_first_person.png" alt="core_3d_camera_first_person" width="80"> | ⭐☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_3d_camera_split_screen](core/core_3d_camera_split_screen.c) | <img src="core/core_3d_camera_split_screen.png" alt="core_3d_camera_split_screen" width="80"> | ⭐⭐⭐☆ | 3.7 | 4.0 | [Jeffery Myers](https://github.com/JeffM2501) |
| [core_3d_camera_fps](core/core_3d_camera_fps.c) | <img src="core/core_3d_camera_fps.png" alt="core_3d_camera_fps" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.5 | [Agnis Aldiņš](https://github.com/nezvers) |
| [core_3d_picking](core/core_3d_picking.c) | <img src="core/core_3d_picking.png" alt="core_3d_picking" width="80"> | ⭐⭐☆☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_world_screen](core/core_world_screen.c) | <img src="core/core_world_screen.png" alt="core_world_screen" width="80"> | ⭐☆☆ | 1.3 | 1.4 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_window_flags](core/core_window_flags.c) | <img src="core/core_window_flags.png" alt="core_window_flags" width="80"> | ⭐⭐⭐☆ | 3.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_window_letterbox](core/core_window_letterbox.c) | <img src="core/core_window_letterbox.png" alt="core_window_letterbox" width="80"> | ⭐☆☆ | 2.5 | 4.0 | [Anata](https://github.com/anatagawa) |
| [core_window_should_close](core/core_window_should_close.c) | <img src="core/core_window_should_close.png" alt="core_window_should_close" width="80"> | ⭐☆☆☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_monitor_detector](core/core_monitor_detector.c) | <img src="core/core_monitor_detector.png" alt="core_monitor_detector" width="80"> | ⭐☆☆ | 5.5 | 5.6 | [Maicon Santana](https://github.com/maiconpintoabreu) |
| [core_custom_logging](core/core_custom_logging.c) | <img src="core/core_custom_logging.png" alt="core_custom_logging" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Pablo Marcos Oltra](https://github.com/pamarcos) |
| [core_drop_files](core/core_drop_files.c) | <img src="core/core_drop_files.png" alt="core_drop_files" width="80"> | ⭐⭐☆☆ | 1.3 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_random_values](core/core_random_values.c) | <img src="core/core_random_values.png" alt="core_random_values" width="80"> | ⭐☆☆☆ | 1.1 | 1.1 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_storage_values](core/core_storage_values.c) | <img src="core/core_storage_values.png" alt="core_storage_values" width="80"> | ⭐☆☆ | 1.4 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_vr_simulator](core/core_vr_simulator.c) | <img src="core/core_vr_simulator.png" alt="core_vr_simulator" width="80"> | ⭐⭐⭐☆ | 2.5 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_scissor_test](core/core_scissor_test.c) | <img src="core/core_scissor_test.png" alt="core_scissor_test" width="80"> | ⭐☆☆☆ | 2.5 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) |
| [core_basic_screen_manager](core/core_basic_screen_manager.c) | <img src="core/core_basic_screen_manager.png" alt="core_basic_screen_manager" width="80"> | ⭐☆☆☆ | 4.0 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_custom_frame_control](core/core_custom_frame_control.c) | <img src="core/core_custom_frame_control.png" alt="core_custom_frame_control" width="80"> | ⭐⭐⭐⭐️ | 4.0 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_smooth_pixelperfect](core/core_smooth_pixelperfect.c) | <img src="core/core_smooth_pixelperfect.png" alt="core_smooth_pixelperfect" width="80"> | ⭐⭐⭐☆ | 3.7 | 4.0 | [Giancamillo Alessandroni](https://github.com/NotManyIdeasDev) |
| [core_random_sequence](core/core_random_sequence.c) | <img src="core/core_random_sequence.png" alt="core_random_sequence" width="80"> | ⭐☆☆☆ | 5.0 | 5.0 | [Dalton Overmyer](https://github.com/REDl3east) |
| [core_automation_events](core/core_automation_events.c) | <img src="core/core_automation_events.png" alt="core_automation_events" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_highdpi_demo](core/core_highdpi_demo.c) | <img src="core/core_highdpi_demo.png" alt="core_highdpi_demo" width="80"> | ⭐⭐☆☆ | 5.0 | 5.5 | [Jonathan Marler](https://github.com/marler8997) |
| [core_render_texture](core/core_render_texture.c) | <img src="core/core_render_texture.png" alt="core_render_texture" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6-dev | [Ramon Santamaria](https://github.com/raysan5) |
| [core_undo_redo](core/core_undo_redo.c) | <img src="core/core_undo_redo.png" alt="core_undo_redo" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.6 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_viewport_scaling](core/core_viewport_scaling.c) | <img src="core/core_viewport_scaling.png" alt="core_viewport_scaling" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Agnis Aldiņš](https://github.com/nezvers) |
| [core_input_actions](core/core_input_actions.c) | <img src="core/core_input_actions.png" alt="core_input_actions" width="80"> | ⭐⭐☆☆ | 5.5 | 5.6 | [Jett](https://github.com/JettMonstersGoBoom) |
| [core_directory_files](core/core_directory_files.c) | <img src="core/core_directory_files.png" alt="core_directory_files" width="80"> | ⭐☆☆☆ | 5.5 | 5.6 | [Hugo ARNAL](https://github.com/hugoarnal) |
| [core_highdpi_testbed](core/core_highdpi_testbed.c) | <img src="core/core_highdpi_testbed.png" alt="core_highdpi_testbed" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6-dev | [Ramon Santamaria](https://github.com/raysan5) |
| [core_screen_recording](core/core_screen_recording.c) | <img src="core/core_screen_recording.png" alt="core_screen_recording" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6-dev | [Ramon Santamaria](https://github.com/raysan5) |
| [core_clipboard_text](core/core_clipboard_text.c) | <img src="core/core_clipboard_text.png" alt="core_clipboard_text" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6-dev | [Ananth S](https://github.com/Ananth1839) |
| [core_text_file_loading](core/core_text_file_loading.c) | <img src="core/core_text_file_loading.png" alt="core_text_file_loading" width="80"> | ⭐☆☆☆ | 5.5 | 5.6 | [Aanjishnu Bhattacharyya](https://github.com/NimComPoo-04) |
| [core_compute_hash](core/core_compute_hash.c) | <img src="core/core_compute_hash.png" alt="core_compute_hash" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6-dev | [Ramon Santamaria](https://github.com/raysan5) |
### category: shapes
### category: shapes [38]
Examples using raylib shapes drawing functionality, provided by raylib [shapes](../src/shapes.c) module.
Examples using raylib shapes drawing functionality, provided by raylib [shapes](../src/rshapes.c) module.
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 36 | [shapes_basic_shapes](shapes/shapes_basic_shapes.c) | <img src="shapes/shapes_basic_shapes.png" alt="shapes_basic_shapes" width="80"> | ⭐☆☆☆ | 1.0 | 4.2 | [Ray](https://github.com/raysan5) |
| 37 | [shapes_bouncing_ball](shapes/shapes_bouncing_ball.c) | <img src="shapes/shapes_bouncing_ball.png" alt="shapes_bouncing_ball" width="80"> | ⭐☆☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) |
| 38 | [shapes_colors_palette](shapes/shapes_colors_palette.c) | <img src="shapes/shapes_colors_palette.png" alt="shapes_colors_palette" width="80"> | ⭐️⭐️☆☆ | 1.0 | 2.5 | [Ray](https://github.com/raysan5) |
| 39 | [shapes_logo_raylib](shapes/shapes_logo_raylib.c) | <img src="shapes/shapes_logo_raylib.png" alt="shapes_logo_raylib" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
| 40 | [shapes_logo_raylib_anim](shapes/shapes_logo_raylib_anim.c) | <img src="shapes/shapes_logo_raylib_anim.png" alt="shapes_logo_raylib_anim" width="80"> | ⭐️⭐️☆☆ | 2.5 | 4.0 | [Ray](https://github.com/raysan5) |
| 41 | [shapes_rectangle_scaling](shapes/shapes_rectangle_scaling.c) | <img src="shapes/shapes_rectangle_scaling.png" alt="shapes_rectangle_scaling" width="80"> | ⭐️⭐️☆☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| 42 | [shapes_lines_bezier](shapes/shapes_lines_bezier.c) | <img src="shapes/shapes_lines_bezier.png" alt="shapes_lines_bezier" width="80"> | ⭐️☆☆☆ | 1.7 | 1.7 | [Ray](https://github.com/raysan5) |
| 43 | [shapes_collision_area](shapes/shapes_collision_area.c) | <img src="shapes/shapes_collision_area.png" alt="shapes_collision_area" width="80"> | ⭐️⭐️☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) |
| 44 | [shapes_following_eyes](shapes/shapes_following_eyes.c) | <img src="shapes/shapes_following_eyes.png" alt="shapes_following_eyes" width="80"> | ⭐️⭐️☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) |
| 45 | [shapes_easings_ball_anim](shapes/shapes_easings_ball_anim.c) | <img src="shapes/shapes_easings_ball_anim.png" alt="shapes_easings_ball_anim" width="80"> | ⭐️⭐️☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) |
| 46 | [shapes_easings_box_anim](shapes/shapes_easings_box_anim.c) | <img src="shapes/shapes_easings_box_anim.png" alt="shapes_easings_box_anim" width="80"> | ⭐️⭐️☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) |
| 47 | [shapes_easings_rectangle_array](shapes/shapes_easings_rectangle_array.c) | <img src="shapes/shapes_easings_rectangle_array.png" alt="shapes_easings_rectangle_array" width="80"> | ⭐️⭐️⭐️☆ | 2.0 | 2.5 | [Ray](https://github.com/raysan5) |
| 48 | [shapes_draw_ring](shapes/shapes_draw_ring.c) | <img src="shapes/shapes_draw_ring.png" alt="shapes_draw_ring" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| 49 | [shapes_draw_circle_sector](shapes/shapes_draw_circle_sector.c) | <img src="shapes/shapes_draw_circle_sector.png" alt="shapes_draw_circle_sector" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| 50 | [shapes_draw_rectangle_rounded](shapes/shapes_draw_rectangle_rounded.c) | <img src="shapes/shapes_draw_rectangle_rounded.png" alt="shapes_draw_rectangle_rounded" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| 51 | [shapes_top_down_lights](shapes/shapes_top_down_lights.c) | <img src="shapes/shapes_top_down_lights.png" alt="shapes_top_down_lights" width="80"> | ⭐️⭐️⭐️⭐️ | 4.2 | 4.2 | [Jeffery Myers](https://github.com/JeffM2501) |
| 52 | [shapes_rectangle_advanced](shapes/shapes_rectangle_advanced.c) | <img src="shapes/shapes_rectangle_advanced.png" alt="shapes_rectangle_advanced" width="80"> | ⭐️⭐️⭐️⭐️ | 5.5 | 5.5 | [Everton Jr.](https://github.com/evertonse) |
| 53 | [shapes_splines_drawing](shapes/shapes_splines_drawing.c) | <img src="shapes/shapes_splines_drawing.png" alt="shapes_splines_drawing" width="80"> | ⭐️⭐️⭐️ | 5.0 | 5.0 | [Ray](https://github.com/raysan5) |
| 54 | [shapes_digital_clock](shapes/shapes_digital_clock.c) | <img src="shapes/shapes_digital_clock.png" alt="shapes_digital_clock" width="80"> | ⭐️⭐️☆☆ | 5.5 | 5.5 | [Hamza RAHAL](https://github.com/rhmz-rhl) |
### category: textures
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| [shapes_basic_shapes](shapes/shapes_basic_shapes.c) | <img src="shapes/shapes_basic_shapes.png" alt="shapes_basic_shapes" width="80"> | ⭐☆☆☆ | 1.0 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_bouncing_ball](shapes/shapes_bouncing_ball.c) | <img src="shapes/shapes_bouncing_ball.png" alt="shapes_bouncing_ball" width="80"> | ⭐☆☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_bullet_hell](shapes/shapes_bullet_hell.c) | <img src="shapes/shapes_bullet_hell.png" alt="shapes_bullet_hell" width="80"> | ⭐☆☆ | 5.6 | 5.6 | [Zero](https://github.com/zerohorsepower) |
| [shapes_colors_palette](shapes/shapes_colors_palette.c) | <img src="shapes/shapes_colors_palette.png" alt="shapes_colors_palette" width="80"> | ⭐☆☆ | 1.0 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_logo_raylib](shapes/shapes_logo_raylib.c) | <img src="shapes/shapes_logo_raylib.png" alt="shapes_logo_raylib" width="80"> | ⭐☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_logo_raylib_anim](shapes/shapes_logo_raylib_anim.c) | <img src="shapes/shapes_logo_raylib_anim.png" alt="shapes_logo_raylib_anim" width="80"> | ⭐☆☆ | 2.5 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_rectangle_scaling](shapes/shapes_rectangle_scaling.c) | <img src="shapes/shapes_rectangle_scaling.png" alt="shapes_rectangle_scaling" width="80"> | ⭐☆☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| [shapes_lines_bezier](shapes/shapes_lines_bezier.c) | <img src="shapes/shapes_lines_bezier.png" alt="shapes_lines_bezier" width="80"> | ⭐☆☆ | 1.7 | 1.7 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_collision_area](shapes/shapes_collision_area.c) | <img src="shapes/shapes_collision_area.png" alt="shapes_collision_area" width="80"> | ⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_following_eyes](shapes/shapes_following_eyes.c) | <img src="shapes/shapes_following_eyes.png" alt="shapes_following_eyes" width="80"> | ⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_easings_ball](shapes/shapes_easings_ball.c) | <img src="shapes/shapes_easings_ball.png" alt="shapes_easings_ball" width="80"> | ⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_easings_box](shapes/shapes_easings_box.c) | <img src="shapes/shapes_easings_box.png" alt="shapes_easings_box" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_easings_rectangles](shapes/shapes_easings_rectangles.c) | <img src="shapes/shapes_easings_rectangles.png" alt="shapes_easings_rectangles" width="80"> | ⭐⭐⭐☆ | 2.0 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_recursive_tree](shapes/shapes_recursive_tree.c) | <img src="shapes/shapes_recursive_tree.png" alt="shapes_recursive_tree" width="80"> | ⭐⭐⭐☆ | 5.6-dev | 5.6-dev | [Jopestpe](https://github.com/jopestpe) |
| [shapes_ring_drawing](shapes/shapes_ring_drawing.c) | <img src="shapes/shapes_ring_drawing.png" alt="shapes_ring_drawing" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| [shapes_circle_sector_drawing](shapes/shapes_circle_sector_drawing.c) | <img src="shapes/shapes_circle_sector_drawing.png" alt="shapes_circle_sector_drawing" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| [shapes_rounded_rectangle_drawing](shapes/shapes_rounded_rectangle_drawing.c) | <img src="shapes/shapes_rounded_rectangle_drawing.png" alt="shapes_rounded_rectangle_drawing" width="80"> | ⭐⭐⭐☆ | 2.5 | 2.5 | [Vlad Adrian](https://github.com/demizdor) |
| [shapes_top_down_lights](shapes/shapes_top_down_lights.c) | <img src="shapes/shapes_top_down_lights.png" alt="shapes_top_down_lights" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [Jeffery Myers](https://github.com/JeffM2501) |
| [shapes_rectangle_advanced](shapes/shapes_rectangle_advanced.c) | <img src="shapes/shapes_rectangle_advanced.png" alt="shapes_rectangle_advanced" width="80"> | ⭐⭐⭐⭐ | 5.5 | 5.5 | [Everton Jr.](https://github.com/evertonse) |
| [shapes_splines_drawing](shapes/shapes_splines_drawing.c) | <img src="shapes/shapes_splines_drawing.png" alt="shapes_splines_drawing" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_digital_clock](shapes/shapes_digital_clock.c) | <img src="shapes/shapes_digital_clock.png" alt="shapes_digital_clock" width="80"> | ⭐⭐⭐⭐️ | 5.5 | 5.6 | [Hamza RAHAL](https://github.com/hmz-rhl) |
| [shapes_double_pendulum](shapes/shapes_double_pendulum.c) | <img src="shapes/shapes_double_pendulum.png" alt="shapes_double_pendulum" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [JoeCheong](https://github.com/Joecheong2006) |
| [shapes_dashed_line](shapes/shapes_dashed_line.c) | <img src="shapes/shapes_dashed_line.png" alt="shapes_dashed_line" width="80"> | ⭐☆☆☆ | 5.5 | 5.5 | [Luís Almeida](https://github.com/luis605) |
| [shapes_triangle_strip](shapes/shapes_triangle_strip.c) | <img src="shapes/shapes_triangle_strip.png" alt="shapes_triangle_strip" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6-dev | [Jopestpe](https://github.com/jopestpe) |
| [shapes_vector_angle](shapes/shapes_vector_angle.c) | <img src="shapes/shapes_vector_angle.png" alt="shapes_vector_angle" width="80"> | ⭐⭐☆☆ | 1.0 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_pie_chart](shapes/shapes_pie_chart.c) | <img src="shapes/shapes_pie_chart.png" alt="shapes_pie_chart" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.6 | [Gideon Serfontein](https://github.com/GideonSerf) |
| [shapes_kaleidoscope](shapes/shapes_kaleidoscope.c) | <img src="shapes/shapes_kaleidoscope.png" alt="shapes_kaleidoscope" width="80"> | ⭐⭐☆☆ | 5.5 | 5.6 | [Hugo ARNAL](https://github.com/hugoarnal) |
| [shapes_clock_of_clocks](shapes/shapes_clock_of_clocks.c) | <img src="shapes/shapes_clock_of_clocks.png" alt="shapes_clock_of_clocks" width="80"> | ⭐⭐☆☆ | 5.5 | 5.6-dev | [JP Mortiboys](https://github.com/themushroompirates) |
| [shapes_math_sine_cosine](shapes/shapes_math_sine_cosine.c) | <img src="shapes/shapes_math_sine_cosine.png" alt="shapes_math_sine_cosine" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6-dev | [Jopestpe](https://github.com/jopestpe) |
| [shapes_mouse_trail](shapes/shapes_mouse_trail.c) | <img src="shapes/shapes_mouse_trail.png" alt="shapes_mouse_trail" width="80"> | ⭐☆☆☆ | 5.6 | 5.6-dev | [Balamurugan R](https://github.com/Bala050814) |
| [shapes_simple_particles](shapes/shapes_simple_particles.c) | <img src="shapes/shapes_simple_particles.png" alt="shapes_simple_particles" width="80"> | ⭐⭐☆☆ | 5.6 | 5.6 | [Jordi Santonja](https://github.com/JordSant) |
| [shapes_starfield_effect](shapes/shapes_starfield_effect.c) | <img src="shapes/shapes_starfield_effect.png" alt="shapes_starfield_effect" width="80"> | ⭐⭐☆☆ | 5.5 | 5.6-dev | [JP Mortiboys](https://github.com/themushroompirates) |
| [shapes_lines_drawing](shapes/shapes_lines_drawing.c) | <img src="shapes/shapes_lines_drawing.png" alt="shapes_lines_drawing" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6 | [Robin](https://github.com/RobinsAviary) |
| [shapes_math_angle_rotation](shapes/shapes_math_angle_rotation.c) | <img src="shapes/shapes_math_angle_rotation.png" alt="shapes_math_angle_rotation" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6 | [Kris](https://github.com/krispy-snacc) |
| [shapes_rlgl_color_wheel](shapes/shapes_rlgl_color_wheel.c) | <img src="shapes/shapes_rlgl_color_wheel.png" alt="shapes_rlgl_color_wheel" width="80"> | ⭐⭐⭐☆ | 5.6-dev | 5.6-dev | [Robin](https://github.com/RobinsAviary) |
| [shapes_rlgl_triangle](shapes/shapes_rlgl_triangle.c) | <img src="shapes/shapes_rlgl_triangle.png" alt="shapes_rlgl_triangle" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6-dev | [Robin](https://github.com/RobinsAviary) |
| [shapes_ball_physics](shapes/shapes_ball_physics.c) | <img src="shapes/shapes_ball_physics.png" alt="shapes_ball_physics" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6-dev | [David Buzatto](https://github.com/davidbuzatto) |
| [shapes_penrose_tile](shapes/shapes_penrose_tile.c) | <img src="shapes/shapes_penrose_tile.png" alt="shapes_penrose_tile" width="80"> | ⭐⭐⭐⭐️ | 5.5 | 5.6-dev | [David Buzatto](https://github.com/davidbuzatto) |
Examples using raylib textures functionality, including image/textures loading/generation and drawing, provided by raylib [textures](../src/textures.c) modul
### category: textures [29]
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 55 | [textures_logo_raylib](textures/textures_logo_raylib.c) | <img src="textures/textures_logo_raylib.png" alt="textures_logo_raylib" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
| 56 | [textures_srcrec_dstrec](textures/textures_srcrec_dstrec.c) | <img src="textures/textures_srcrec_dstrec.png" alt="textures_srcrec_dstrec" width="80"> | ⭐️⭐️⭐️☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
| 57 | [textures_image_drawing](textures/textures_image_drawing.c) | <img src="textures/textures_image_drawing.png" alt="textures_image_drawing" width="80"> | ⭐️⭐️☆☆ | 1.4 | 1.4 | [Ray](https://github.com/raysan5) |
| 58 | [textures_image_generation](textures/textures_image_generation.c) | <img src="textures/textures_image_generation.png" alt="textures_image_generation" width="80"> | ⭐️⭐️☆☆ | 1.8 | 1.8 | [Wilhem Barbier](https://github.com/nounoursheureux) |
| 59 | [textures_image_loading](textures/textures_image_loading.c) | <img src="textures/textures_image_loading.png" alt="textures_image_loading" width="80"> | ⭐️☆☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
| 60 | [textures_image_processing](textures/textures_image_processing.c) | <img src="textures/textures_image_processing.png" alt="textures_image_processing" width="80"> | ⭐️⭐️⭐️☆ | 1.4 | 3.5 | [Ray](https://github.com/raysan5) |
| 61 | [textures_image_text](textures/textures_image_text.c) | <img src="textures/textures_image_text.png" alt="textures_image_text" width="80"> | ⭐️⭐️☆☆ | 1.8 | 4.0 | [Ray](https://github.com/raysan5) |
| 62 | [textures_to_image](textures/textures_to_image.c) | <img src="textures/textures_to_image.png" alt="textures_to_image" width="80"> | ⭐️☆☆☆ | 1.3 | 4.0 | [Ray](https://github.com/raysan5) |
| 63 | [textures_raw_data](textures/textures_raw_data.c) | <img src="textures/textures_raw_data.png" alt="textures_raw_data" width="80"> | ⭐️⭐️⭐️☆ | 1.3 | 3.5 | [Ray](https://github.com/raysan5) |
| 64 | [textures_particles_blending](textures/textures_particles_blending.c) | <img src="textures/textures_particles_blending.png" alt="textures_particles_blending" width="80"> | ⭐️☆☆☆ | 1.7 | 3.5 | [Ray](https://github.com/raysan5) |
| 65 | [textures_npatch_drawing](textures/textures_npatch_drawing.c) | <img src="textures/textures_npatch_drawing.png" alt="textures_npatch_drawing" width="80"> | ⭐️⭐️⭐️☆ | 2.0 | 2.5 | [Jorge A. Gomes](https://github.com/overdev) |
| 66 | [textures_background_scrolling](textures/textures_background_scrolling.c) | <img src="textures/textures_background_scrolling.png" alt="textures_background_scrolling" width="80"> | ⭐️☆☆☆ | 2.0 | 2.5 | [Ray](https://github.com/raysan5) |
| 67 | [textures_sprite_anim](textures/textures_sprite_anim.c) | <img src="textures/textures_sprite_anim.png" alt="textures_sprite_anim" width="80"> | ⭐️⭐️☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) |
| 68 | [textures_sprite_button](textures/textures_sprite_button.c) | <img src="textures/textures_sprite_button.png" alt="textures_sprite_button" width="80"> | ⭐️⭐️☆☆ | 2.5 | 2.5 | [Ray](https://github.com/raysan5) |
| 69 | [textures_sprite_explosion](textures/textures_sprite_explosion.c) | <img src="textures/textures_sprite_explosion.png" alt="textures_sprite_explosion" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.5 | [Ray](https://github.com/raysan5) |
| 70 | [textures_bunnymark](textures/textures_bunnymark.c) | <img src="textures/textures_bunnymark.png" alt="textures_bunnymark" width="80"> | ⭐️⭐️⭐️☆ | 1.6 | 2.5 | [Ray](https://github.com/raysan5) |
| 71 | [textures_mouse_painting](textures/textures_mouse_painting.c) | <img src="textures/textures_mouse_painting.png" alt="textures_mouse_painting" width="80"> | ⭐️⭐️⭐️☆ | 3.0 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) |
| 72 | [textures_blend_modes](textures/textures_blend_modes.c) | <img src="textures/textures_blend_modes.png" alt="textures_blend_modes" width="80"> | ⭐️☆☆☆ | 3.5 | 3.5 | [Karlo Licudine](https://github.com/accidentalrebel) |
| 73 | [textures_draw_tiled](textures/textures_draw_tiled.c) | <img src="textures/textures_draw_tiled.png" alt="textures_draw_tiled" width="80"> | ⭐️⭐️⭐️☆ | 3.0 | 4.2 | [Vlad Adrian](https://github.com/demizdor) |
| 74 | [textures_polygon](textures/textures_polygon.c) | <img src="textures/textures_polygon.png" alt="textures_polygon" width="80"> | ⭐️☆☆☆ | 3.7 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| 75 | [textures_fog_of_war](textures/textures_fog_of_war.c) | <img src="textures/textures_fog_of_war.png" alt="textures_fog_of_war" width="80"> | ⭐️⭐️⭐️☆ | 4.2 | 4.2 | [Ray](https://github.com/raysan5) |
| 76 | [textures_gif_player](textures/textures_gif_player.c) | <img src="textures/textures_gif_player.png" alt="textures_gif_player" width="80"> | ⭐️⭐️⭐️☆ | 4.2 | 4.2 | [Ray](https://github.com/raysan5) |
| 77 | [textures_image_kernel](textures/textures_image_kernel.c) | <img src="textures/textures_image_kernel.png" alt="textures_image_kernel" width="80"> | ⭐️⭐️⭐️⭐️ | 1.3 | 1.3 | [Karim Salem](https://github.com/kimo-s) |
| 78 | [textures_image_channel](textures/textures_image_channel.c) | <img src="textures/textures_image_channel.png" alt="textures_image_channel" width="80"> | ⭐️⭐️☆☆ | 5.1-dev | 5.1-dev | [Bruno Cabral](https://github.com/brccabral) |
| 79 | [textures_image_rotate](textures/textures_image_rotate.c) | <img src="textures/textures_image_rotate.png" alt="textures_image_rotate" width="80"> | ⭐️⭐️☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
| 80 | [textures_textured_curve](textures/textures_textured_curve.c) | <img src="textures/textures_textured_curve.png" alt="textures_textured_curve" width="80"> | ⭐️⭐️⭐️☆ | 4.5 | 4.5 | [Jeffery Myers](https://github.com/JeffM2501) |
Examples using raylib textures functionality, including image/textures loading/generation and drawing, provided by raylib [textures](../src/rtextures.c) module.
### category: text
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| [textures_logo_raylib](textures/textures_logo_raylib.c) | <img src="textures/textures_logo_raylib.png" alt="textures_logo_raylib" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_srcrec_dstrec](textures/textures_srcrec_dstrec.c) | <img src="textures/textures_srcrec_dstrec.png" alt="textures_srcrec_dstrec" width="80"> | ⭐⭐⭐☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_image_drawing](textures/textures_image_drawing.c) | <img src="textures/textures_image_drawing.png" alt="textures_image_drawing" width="80"> | ⭐⭐☆☆ | 1.4 | 1.4 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_image_generation](textures/textures_image_generation.c) | <img src="textures/textures_image_generation.png" alt="textures_image_generation" width="80"> | ⭐⭐☆☆ | 1.8 | 1.8 | [Wilhem Barbier](https://github.com/nounoursheureux) |
| [textures_image_loading](textures/textures_image_loading.c) | <img src="textures/textures_image_loading.png" alt="textures_image_loading" width="80"> | ⭐☆☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_image_processing](textures/textures_image_processing.c) | <img src="textures/textures_image_processing.png" alt="textures_image_processing" width="80"> | ⭐⭐⭐☆ | 1.4 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_image_text](textures/textures_image_text.c) | <img src="textures/textures_image_text.png" alt="textures_image_text" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_to_image](textures/textures_to_image.c) | <img src="textures/textures_to_image.png" alt="textures_to_image" width="80"> | ⭐☆☆☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_raw_data](textures/textures_raw_data.c) | <img src="textures/textures_raw_data.png" alt="textures_raw_data" width="80"> | ⭐⭐⭐☆ | 1.3 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_particles_blending](textures/textures_particles_blending.c) | <img src="textures/textures_particles_blending.png" alt="textures_particles_blending" width="80"> | ⭐☆☆☆ | 1.7 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_npatch_drawing](textures/textures_npatch_drawing.c) | <img src="textures/textures_npatch_drawing.png" alt="textures_npatch_drawing" width="80"> | ⭐⭐⭐☆ | 2.0 | 2.5 | [Jorge A. Gomes](https://github.com/overdev) |
| [textures_background_scrolling](textures/textures_background_scrolling.c) | <img src="textures/textures_background_scrolling.png" alt="textures_background_scrolling" width="80"> | ⭐☆☆☆ | 2.0 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_sprite_animation](textures/textures_sprite_animation.c) | <img src="textures/textures_sprite_animation.png" alt="textures_sprite_animation" width="80"> | ⭐⭐☆☆ | 1.3 | 1.3 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_sprite_button](textures/textures_sprite_button.c) | <img src="textures/textures_sprite_button.png" alt="textures_sprite_button" width="80"> | ⭐⭐☆☆ | 2.5 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_sprite_explosion](textures/textures_sprite_explosion.c) | <img src="textures/textures_sprite_explosion.png" alt="textures_sprite_explosion" width="80"> | ⭐⭐☆☆ | 2.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_bunnymark](textures/textures_bunnymark.c) | <img src="textures/textures_bunnymark.png" alt="textures_bunnymark" width="80"> | ⭐⭐⭐☆ | 1.6 | 2.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_mouse_painting](textures/textures_mouse_painting.c) | <img src="textures/textures_mouse_painting.png" alt="textures_mouse_painting" width="80"> | ⭐⭐⭐☆ | 3.0 | 3.0 | [Chris Dill](https://github.com/MysteriousSpace) |
| [textures_blend_modes](textures/textures_blend_modes.c) | <img src="textures/textures_blend_modes.png" alt="textures_blend_modes" width="80"> | ⭐☆☆☆ | 3.5 | 3.5 | [Karlo Licudine](https://github.com/accidentalrebel) |
| [textures_tiled_drawing](textures/textures_tiled_drawing.c) | <img src="textures/textures_tiled_drawing.png" alt="textures_tiled_drawing" width="80"> | ⭐⭐⭐☆ | 3.0 | 4.2 | [Vlad Adrian](https://github.com/demizdor) |
| [textures_polygon_drawing](textures/textures_polygon_drawing.c) | <img src="textures/textures_polygon_drawing.png" alt="textures_polygon_drawing" width="80"> | ⭐☆☆☆ | 3.7 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| [textures_fog_of_war](textures/textures_fog_of_war.c) | <img src="textures/textures_fog_of_war.png" alt="textures_fog_of_war" width="80"> | ⭐⭐⭐☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_gif_player](textures/textures_gif_player.c) | <img src="textures/textures_gif_player.png" alt="textures_gif_player" width="80"> | ⭐⭐⭐☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_image_kernel](textures/textures_image_kernel.c) | <img src="textures/textures_image_kernel.png" alt="textures_image_kernel" width="80"> | ⭐⭐⭐⭐️ | 1.3 | 1.3 | [Karim Salem](https://github.com/kimo-s) |
| [textures_image_channel](textures/textures_image_channel.c) | <img src="textures/textures_image_channel.png" alt="textures_image_channel" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Bruno Cabral](https://github.com/brccabral) |
| [textures_image_rotate](textures/textures_image_rotate.c) | <img src="textures/textures_image_rotate.png" alt="textures_image_rotate" width="80"> | ⭐⭐☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [textures_screen_buffer](textures/textures_screen_buffer.c) | <img src="textures/textures_screen_buffer.png" alt="textures_screen_buffer" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Agnis Aldiņš](https://github.com/nezvers) |
| [textures_textured_curve](textures/textures_textured_curve.c) | <img src="textures/textures_textured_curve.png" alt="textures_textured_curve" width="80"> | ⭐⭐⭐☆ | 4.5 | 4.5 | [Jeffery Myers](https://github.com/JeffM2501) |
| [textures_sprite_stacking](textures/textures_sprite_stacking.c) | <img src="textures/textures_sprite_stacking.png" alt="textures_sprite_stacking" width="80"> | ⭐⭐☆☆ | 5.6-dev | 6.0 | [Robin](https://github.com/RobinsAviary) |
| [textures_cellular_automata](textures/textures_cellular_automata.c) | <img src="textures/textures_cellular_automata.png" alt="textures_cellular_automata" width="80"> | ⭐⭐☆☆ | 5.6 | 5.6 | [Jordi Santonja](https://github.com/JordSant) |
Examples using raylib text functionality, including sprite fonts loading/generation and text drawing, provided by raylib [text](../src/text.c) module.
### category: text [16]
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 81 | [text_raylib_fonts](text/text_raylib_fonts.c) | <img src="text/text_raylib_fonts.png" alt="text_raylib_fonts" width="80"> | ⭐️☆☆☆ | 1.7 | 3.7 | [Ray](https://github.com/raysan5) |
| 82 | [text_font_spritefont](text/text_font_spritefont.c) | <img src="text/text_font_spritefont.png" alt="text_font_spritefont" width="80"> | ⭐️☆☆☆ | 1.0 | 1.0 | [Ray](https://github.com/raysan5) |
| 83 | [text_font_filters](text/text_font_filters.c) | <img src="text/text_font_filters.png" alt="text_font_filters" width="80"> | ⭐️⭐️☆☆ | 1.3 | 4.2 | [Ray](https://github.com/raysan5) |
| 84 | [text_font_loading](text/text_font_loading.c) | <img src="text/text_font_loading.png" alt="text_font_loading" width="80"> | ⭐️☆☆☆ | 1.4 | 3.0 | [Ray](https://github.com/raysan5) |
| 85 | [text_font_sdf](text/text_font_sdf.c) | <img src="text/text_font_sdf.png" alt="text_font_sdf" width="80"> | ⭐️⭐️⭐️☆ | 1.3 | 4.0 | [Ray](https://github.com/raysan5) |
| 86 | [text_format_text](text/text_format_text.c) | <img src="text/text_format_text.png" alt="text_format_text" width="80"> | ⭐️☆☆☆ | 1.1 | 3.0 | [Ray](https://github.com/raysan5) |
| 87 | [text_input_box](text/text_input_box.c) | <img src="text/text_input_box.png" alt="text_input_box" width="80"> | ⭐️⭐️☆☆ | 1.7 | 3.5 | [Ray](https://github.com/raysan5) |
| 88 | [text_writing_anim](text/text_writing_anim.c) | <img src="text/text_writing_anim.png" alt="text_writing_anim" width="80"> | ⭐️⭐️☆☆ | 1.4 | 1.4 | [Ray](https://github.com/raysan5) |
| 89 | [text_rectangle_bounds](text/text_rectangle_bounds.c) | <img src="text/text_rectangle_bounds.png" alt="text_rectangle_bounds" width="80"> | ⭐️⭐️⭐️⭐️ | 2.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| 90 | [text_unicode](text/text_unicode.c) | <img src="text/text_unicode.png" alt="text_unicode" width="80"> | ⭐️⭐️⭐️⭐️ | 2.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| 91 | [text_draw_3d](text/text_draw_3d.c) | <img src="text/text_draw_3d.png" alt="text_draw_3d" width="80"> | ⭐️⭐️⭐️⭐️ | 3.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| 92 | [text_codepoints_loading](text/text_codepoints_loading.c) | <img src="text/text_codepoints_loading.png" alt="text_codepoints_loading" width="80"> | ⭐️⭐️⭐️☆ | 4.2 | 4.2 | [Ray](https://github.com/raysan5) |
Examples using raylib text functionality, including sprite fonts loading/generation and text drawing, provided by raylib [text](../src/rtext.c) module.
### category: models
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| [text_sprite_fonts](text/text_sprite_fonts.c) | <img src="text/text_sprite_fonts.png" alt="text_sprite_fonts" width="80"> | ⭐☆☆☆ | 1.7 | 3.7 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_font_spritefont](text/text_font_spritefont.c) | <img src="text/text_font_spritefont.png" alt="text_font_spritefont" width="80"> | ⭐☆☆☆ | 1.0 | 1.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_font_filters](text/text_font_filters.c) | <img src="text/text_font_filters.png" alt="text_font_filters" width="80"> | ⭐⭐☆☆ | 1.3 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_font_loading](text/text_font_loading.c) | <img src="text/text_font_loading.png" alt="text_font_loading" width="80"> | ⭐☆☆☆ | 1.4 | 3.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_font_sdf](text/text_font_sdf.c) | <img src="text/text_font_sdf.png" alt="text_font_sdf" width="80"> | ⭐⭐⭐☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_format_text](text/text_format_text.c) | <img src="text/text_format_text.png" alt="text_format_text" width="80"> | ⭐☆☆☆ | 1.1 | 3.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_input_box](text/text_input_box.c) | <img src="text/text_input_box.png" alt="text_input_box" width="80"> | ⭐⭐☆☆ | 1.7 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_writing_anim](text/text_writing_anim.c) | <img src="text/text_writing_anim.png" alt="text_writing_anim" width="80"> | ⭐⭐☆☆ | 1.4 | 1.4 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_rectangle_bounds](text/text_rectangle_bounds.c) | <img src="text/text_rectangle_bounds.png" alt="text_rectangle_bounds" width="80"> | ⭐⭐⭐⭐️ | 2.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| [text_unicode_emojis](text/text_unicode_emojis.c) | <img src="text/text_unicode_emojis.png" alt="text_unicode_emojis" width="80"> | ⭐⭐⭐⭐️ | 2.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| [text_unicode_ranges](text/text_unicode_ranges.c) | <img src="text/text_unicode_ranges.png" alt="text_unicode_ranges" width="80"> | ⭐⭐⭐⭐️ | 5.5 | 5.6 | [Vadim Gunko](https://github.com/GuvaCode) |
| [text_3d_drawing](text/text_3d_drawing.c) | <img src="text/text_3d_drawing.png" alt="text_3d_drawing" width="80"> | ⭐⭐⭐⭐️ | 3.5 | 4.0 | [Vlad Adrian](https://github.com/demizdor) |
| [text_codepoints_loading](text/text_codepoints_loading.c) | <img src="text/text_codepoints_loading.png" alt="text_codepoints_loading" width="80"> | ⭐⭐⭐☆ | 4.2 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [text_inline_styling](text/text_inline_styling.c) | <img src="text/text_inline_styling.png" alt="text_inline_styling" width="80"> | ⭐⭐⭐☆ | 5.6-dev | 5.6-dev | [Wagner Barongello](https://github.com/SultansOfCode) |
| [text_words_alignment](text/text_words_alignment.c) | <img src="text/text_words_alignment.png" alt="text_words_alignment" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6-dev | [JP Mortiboys](https://github.com/themushroompirates) |
| [text_strings_management](text/text_strings_management.c) | <img src="text/text_strings_management.png" alt="text_strings_management" width="80"> | ⭐⭐⭐☆ | 5.6-dev | 5.6-dev | [David Buzatto](https://github.com/davidbuzatto) |
Examples using raylib models functionality, including models loading/generation and drawing, provided by raylib [models](../src/models.c) module.
### category: models [27]
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 93 | [models_animation](models/models_animation.c) | <img src="models/models_animation.png" alt="models_animation" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.5 | [Culacant](https://github.com/culacant) |
| 94 | [models_billboard](models/models_billboard.c) | <img src="models/models_billboard.png" alt="models_billboard" width="80"> | ⭐️⭐️⭐️☆ | 1.3 | 3.5 | [Ray](https://github.com/raysan5) |
| 95 | [models_box_collisions](models/models_box_collisions.c) | <img src="models/models_box_collisions.png" alt="models_box_collisions" width="80"> | ⭐️☆☆☆ | 1.3 | 3.5 | [Ray](https://github.com/raysan5) |
| 96 | [models_cubicmap](models/models_cubicmap.c) | <img src="models/models_cubicmap.png" alt="models_cubicmap" width="80"> | ⭐️⭐️☆☆ | 1.8 | 3.5 | [Ray](https://github.com/raysan5) |
| 97 | [models_first_person_maze](models/models_first_person_maze.c) | <img src="models/models_first_person_maze.png" alt="models_first_person_maze" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.5 | [Ray](https://github.com/raysan5) |
| 98 | [models_geometric_shapes](models/models_geometric_shapes.c) | <img src="models/models_geometric_shapes.png" alt="models_geometric_shapes" width="80"> | ⭐️☆☆☆ | 1.0 | 3.5 | [Ray](https://github.com/raysan5) |
| 99 | [models_mesh_generation](models/models_mesh_generation.c) | <img src="models/models_mesh_generation.png" alt="models_mesh_generation" width="80"> | ⭐️⭐️☆☆ | 1.8 | 4.0 | [Ray](https://github.com/raysan5) |
| 100 | [models_mesh_picking](models/models_mesh_picking.c) | <img src="models/models_mesh_picking.png" alt="models_mesh_picking" width="80"> | ⭐️⭐️⭐️☆ | 1.7 | 4.0 | [Joel Davis](https://github.com/joeld42) |
| 101 | [models_loading](models/models_loading.c) | <img src="models/models_loading.png" alt="models_loading" width="80"> | ⭐️☆☆☆ | 2.0 | 4.2 | [Ray](https://github.com/raysan5) |
| 102 | [models_loading_gltf](models/models_loading_gltf.c) | <img src="models/models_loading_gltf.png" alt="models_loading_gltf" width="80"> | ⭐️☆☆☆ | 3.7 | 4.2 | [Ray](https://github.com/raysan5) |
| 103 | [models_loading_vox](models/models_loading_vox.c) | <img src="models/models_loading_vox.png" alt="models_loading_vox" width="80"> | ⭐️☆☆☆ | 4.0 | 4.0 | [Johann Nadalutti](https://github.com/procfxgen) |
| 104 | [models_loading_m3d](models/models_loading_m3d.c) | <img src="models/models_loading_m3d.png" alt="models_loading_m3d" width="80"> | ⭐️⭐️☆☆ | 4.5 | 4.5 | [bzt](https://bztsrc.gitlab.io/model3d) |
| 105 | [models_orthographic_projection](models/models_orthographic_projection.c) | <img src="models/models_orthographic_projection.png" alt="models_orthographic_projection" width="80"> | ⭐️☆☆☆ | 2.0 | 3.7 | [Max Danielsson](https://github.com/autious) |
| 106 | [models_point_rendering](models/models_point_rendering.c) | <img src="models/models_point_rendering.png" alt="models_point_rendering" width="80"> | ⭐️⭐️⭐️☆ | 5.0 | 5.0 | [Reese Gallagher](https://github.com/satchelfrost) |
| 107 | [models_rlgl_solar_system](models/models_rlgl_solar_system.c) | <img src="models/models_rlgl_solar_system.png" alt="models_rlgl_solar_system" width="80"> | ⭐️⭐️⭐️⭐️ | 2.5 | 4.0 | [Ray](https://github.com/raysan5) |
| 108 | [models_yaw_pitch_roll](models/models_yaw_pitch_roll.c) | <img src="models/models_yaw_pitch_roll.png" alt="models_yaw_pitch_roll" width="80"> | ⭐️⭐️☆☆ | 1.8 | 4.0 | [Berni](https://github.com/Berni8k) |
| 109 | [models_waving_cubes](models/models_waving_cubes.c) | <img src="models/models_waving_cubes.png" alt="models_waving_cubes" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.7 | [Codecat](https://github.com/codecat) |
| 110 | [models_heightmap](models/models_heightmap.c) | <img src="models/models_heightmap.png" alt="models_heightmap" width="80"> | ⭐️☆☆☆ | 1.8 | 3.5 | [Ray](https://github.com/raysan5) |
| 111 | [models_skybox](models/models_skybox.c) | <img src="models/models_skybox.png" alt="models_skybox" width="80"> | ⭐️⭐️☆☆ | 1.8 | 4.0 | [Ray](https://github.com/raysan5) |
| 112 | [models_draw_cube_texture](models/models_draw_cube_texture.c) | <img src="models/models_draw_cube_texture.png" alt="models_draw_cube_texture" width="80"> | ⭐️⭐️☆☆ | 4.5 | 4.5 | [Ray](https://github.com/raysan5) |
| 113 | [models_gpu_skinning](models/models_gpu_skinning.c) | <img src="models/models_gpu_skinning.png" alt="models_gpu_skinning" width="80"> | ⭐️⭐️⭐️☆ | 4.5 | 4.5 | [Daniel Holden](https://github.com/orangeduck) |
| 114 | [models_bone_socket](models/models_bone_socket.c) | <img src="models/models_bone_socket.png" alt="models_bone_socket" width="80"> | ⭐️⭐️⭐️⭐️ | 4.5 | 4.5 | [iP](https://github.com/ipzaur) |
| 115 | [models_tesseract_view](models/models_tesseract_view.c) | <img src="models/models_tesseract_view.png" alt="models_tesseract_view" width="80"> | ⭐️⭐️☆☆ | 5.6-dev | 5.6-dev | [Timothy van der Valk](https://github.com/arceryz) |
Examples using raylib models functionality, including models loading/generation and drawing, provided by raylib [models](../src/rmodels.c) module.
### category: shaders
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| [models_animation_playing](models/models_animation_playing.c) | <img src="models/models_animation_playing.png" alt="models_animation_playing" width="80"> | ⭐⭐☆☆ | 2.5 | 3.5 | [Culacant](https://github.com/culacant) |
| [models_billboard_rendering](models/models_billboard_rendering.c) | <img src="models/models_billboard_rendering.png" alt="models_billboard_rendering" width="80"> | ⭐⭐⭐☆ | 1.3 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_box_collisions](models/models_box_collisions.c) | <img src="models/models_box_collisions.png" alt="models_box_collisions" width="80"> | ⭐☆☆☆ | 1.3 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_cubicmap_rendering](models/models_cubicmap_rendering.c) | <img src="models/models_cubicmap_rendering.png" alt="models_cubicmap_rendering" width="80"> | ⭐⭐☆☆ | 1.8 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_first_person_maze](models/models_first_person_maze.c) | <img src="models/models_first_person_maze.png" alt="models_first_person_maze" width="80"> | ⭐⭐☆☆ | 2.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_geometric_shapes](models/models_geometric_shapes.c) | <img src="models/models_geometric_shapes.png" alt="models_geometric_shapes" width="80"> | ⭐☆☆☆ | 1.0 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_mesh_generation](models/models_mesh_generation.c) | <img src="models/models_mesh_generation.png" alt="models_mesh_generation" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_mesh_picking](models/models_mesh_picking.c) | <img src="models/models_mesh_picking.png" alt="models_mesh_picking" width="80"> | ⭐⭐⭐☆ | 1.7 | 4.0 | [Joel Davis](https://github.com/joeld42) |
| [models_loading](models/models_loading.c) | <img src="models/models_loading.png" alt="models_loading" width="80"> | ⭐☆☆☆ | 2.0 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_loading_gltf](models/models_loading_gltf.c) | <img src="models/models_loading_gltf.png" alt="models_loading_gltf" width="80"> | ⭐☆☆☆ | 3.7 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_loading_vox](models/models_loading_vox.c) | <img src="models/models_loading_vox.png" alt="models_loading_vox" width="80"> | ⭐☆☆☆ | 4.0 | 4.0 | [Johann Nadalutti](https://github.com/procfxgen) |
| [models_loading_m3d](models/models_loading_m3d.c) | <img src="models/models_loading_m3d.png" alt="models_loading_m3d" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [bzt](https://github.com/bztsrc) |
| [models_orthographic_projection](models/models_orthographic_projection.c) | <img src="models/models_orthographic_projection.png" alt="models_orthographic_projection" width="80"> | ⭐☆☆☆ | 2.0 | 3.7 | [Max Danielsson](https://github.com/autious) |
| [models_point_rendering](models/models_point_rendering.c) | <img src="models/models_point_rendering.png" alt="models_point_rendering" width="80"> | ⭐⭐⭐☆ | 5.0 | 5.0 | [Reese Gallagher](https://github.com/satchelfrost) |
| [models_rlgl_solar_system](models/models_rlgl_solar_system.c) | <img src="models/models_rlgl_solar_system.png" alt="models_rlgl_solar_system" width="80"> | ⭐⭐⭐⭐️ | 2.5 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_yaw_pitch_roll](models/models_yaw_pitch_roll.c) | <img src="models/models_yaw_pitch_roll.png" alt="models_yaw_pitch_roll" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Berni](https://github.com/Berni8k) |
| [models_waving_cubes](models/models_waving_cubes.c) | <img src="models/models_waving_cubes.png" alt="models_waving_cubes" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.7 | [Codecat](https://github.com/codecat) |
| [models_heightmap_rendering](models/models_heightmap_rendering.c) | <img src="models/models_heightmap_rendering.png" alt="models_heightmap_rendering" width="80"> | ⭐☆☆☆ | 1.8 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_skybox_rendering](models/models_skybox_rendering.c) | <img src="models/models_skybox_rendering.png" alt="models_skybox_rendering" width="80"> | ⭐⭐☆☆ | 1.8 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_textured_cube](models/models_textured_cube.c) | <img src="models/models_textured_cube.png" alt="models_textured_cube" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [models_animation_gpu_skinning](models/models_animation_gpu_skinning.c) | <img src="models/models_animation_gpu_skinning.png" alt="models_animation_gpu_skinning" width="80"> | ⭐⭐⭐☆ | 4.5 | 4.5 | [Daniel Holden](https://github.com/orangeduck) |
| [models_bone_socket](models/models_bone_socket.c) | <img src="models/models_bone_socket.png" alt="models_bone_socket" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [iP](https://github.com/ipzaur) |
| [models_tesseract_view](models/models_tesseract_view.c) | <img src="models/models_tesseract_view.png" alt="models_tesseract_view" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6-dev | [Timothy van der Valk](https://github.com/arceryz) |
| [models_basic_voxel](models/models_basic_voxel.c) | <img src="models/models_basic_voxel.png" alt="models_basic_voxel" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [Tim Little](https://github.com/timlittle) |
| [models_rotating_cube](models/models_rotating_cube.c) | <img src="models/models_rotating_cube.png" alt="models_rotating_cube" width="80"> | ⭐☆☆☆ | 5.6-dev | 5.6-dev | [Jopestpe](https://github.com/jopestpe) |
| [models_decals](models/models_decals.c) | <img src="models/models_decals.png" alt="models_decals" width="80"> | ⭐⭐⭐⭐️ | 5.6-dev | 5.6-dev | [JP Mortiboys](https://github.com/themushroompirates) |
| [models_directional_billboard](models/models_directional_billboard.c) | <img src="models/models_directional_billboard.png" alt="models_directional_billboard" width="80"> | ⭐⭐☆☆ | 5.6-dev | 5.6 | [Robin](https://github.com/RobinsAviary) |
### category: shaders [33]
Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.c) module.
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 116 | [shaders_basic_lighting](shaders/shaders_basic_lighting.c) | <img src="shaders/shaders_basic_lighting.png" alt="shaders_basic_lighting" width="80"> | ⭐️⭐️⭐️⭐️ | 3.0 | 4.2 | [Chris Camacho](https://github.com/chriscamacho) |
| 117 | [shaders_model_shader](shaders/shaders_model_shader.c) | <img src="shaders/shaders_model_shader.png" alt="shaders_model_shader" width="80"> | ⭐️⭐️☆☆ | 1.3 | 3.7 | [Ray](https://github.com/raysan5) |
| 118 | [shaders_shapes_textures](shaders/shaders_shapes_textures.c) | <img src="shaders/shaders_shapes_textures.png" alt="shaders_shapes_textures" width="80"> | ⭐️⭐️☆☆ | 1.7 | 3.7 | [Ray](https://github.com/raysan5) |
| 119 | [shaders_custom_uniform](shaders/shaders_custom_uniform.c) | <img src="shaders/shaders_custom_uniform.png" alt="shaders_custom_uniform" width="80"> | ⭐️⭐️☆☆ | 1.3 | 4.0 | [Ray](https://github.com/raysan5) |
| 120 | [shaders_postprocessing](shaders/shaders_postprocessing.c) | <img src="shaders/shaders_postprocessing.png" alt="shaders_postprocessing" width="80"> | ⭐️⭐️⭐️☆ | 1.3 | 4.0 | [Ray](https://github.com/raysan5) |
| 121 | [shaders_palette_switch](shaders/shaders_palette_switch.c) | <img src="shaders/shaders_palette_switch.png" alt="shaders_palette_switch" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.7 | [Marco Lizza](https://github.com/MarcoLizza) |
| 122 | [shaders_raymarching](shaders/shaders_raymarching.c) | <img src="shaders/shaders_raymarching.png" alt="shaders_raymarching" width="80"> | ⭐️⭐️⭐️⭐️ | 2.0 | 4.2 | [Ray](https://github.com/raysan5) |
| 123 | [shaders_texture_drawing](shaders/shaders_texture_drawing.c) | <img src="shaders/shaders_texture_drawing.png" alt="shaders_texture_drawing" width="80"> | ⭐️⭐️☆☆ | 2.0 | 3.7 | [Michał Ciesielski](https://github.com/ciessielski) |
| 124 | [shaders_texture_outline](shaders/shaders_texture_outline.c) | <img src="shaders/shaders_texture_outline.png" alt="shaders_texture_outline" width="80"> | ⭐️⭐️⭐️☆ | 4.0 | 4.0 | [Samuel Skiff](https://github.com/GoldenThumbs) |
| 125 | [shaders_texture_waves](shaders/shaders_texture_waves.c) | <img src="shaders/shaders_texture_waves.png" alt="shaders_texture_waves" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.7 | [Anata](https://github.com/anatagawa) |
| 126 | [shaders_julia_set](shaders/shaders_julia_set.c) | <img src="shaders/shaders_julia_set.png" alt="shaders_julia_set" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 4.0 | [Josh Colclough](https://github.com/joshcol9232) |
| 127 | [shaders_eratosthenes](shaders/shaders_eratosthenes.c) | <img src="shaders/shaders_eratosthenes.png" alt="shaders_eratosthenes" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 4.0 | [ProfJski](https://github.com/ProfJski) |
| 128 | [shaders_fog](shaders/shaders_fog.c) | <img src="shaders/shaders_fog.png" alt="shaders_fog" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| 129 | [shaders_simple_mask](shaders/shaders_simple_mask.c) | <img src="shaders/shaders_simple_mask.png" alt="shaders_simple_mask" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| 130 | [shaders_hot_reloading](shaders/shaders_hot_reloading.c) | <img src="shaders/shaders_hot_reloading.png" alt="shaders_hot_reloading" width="80"> | ⭐️⭐️⭐️☆ | 3.0 | 3.5 | [Ray](https://github.com/raysan5) |
| 131 | [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐️⭐️⭐️⭐️ | 3.7 | 4.2 | [seanpringle](https://github.com/seanpringle) |
| 132 | [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐️⭐️☆☆ | 3.5 | 3.5 | [Ray](https://github.com/raysan5) |
| 133 | [shaders_spotlight](shaders/shaders_spotlight.c) | <img src="shaders/shaders_spotlight.png" alt="shaders_spotlight" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| 134 | [shaders_deferred_render](shaders/shaders_deferred_render.c) | <img src="shaders/shaders_deferred_render.png" alt="shaders_deferred_render" width="80"> | ⭐️⭐️⭐️⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) |
| 135 | [shaders_hybrid_render](shaders/shaders_hybrid_render.c) | <img src="shaders/shaders_hybrid_render.png" alt="shaders_hybrid_render" width="80"> | ⭐️⭐️⭐️⭐️ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) |
| 136 | [shaders_texture_tiling](shaders/shaders_texture_tiling.c) | <img src="shaders/shaders_texture_tiling.png" alt="shaders_texture_tiling" width="80"> | ⭐️⭐️☆☆ | 4.5 | 4.5 | [Luis Almeida](https://github.com/luis605) |
| 137 | [shaders_shadowmap](shaders/shaders_shadowmap.c) | <img src="shaders/shaders_shadowmap.png" alt="shaders_shadowmap" width="80"> | ⭐️⭐️⭐️⭐️ | 5.0 | 5.0 | [TheManTheMythTheGameDev](https://github.com/TheManTheMythTheGameDev) |
| 138 | [shaders_vertex_displacement](shaders/shaders_vertex_displacement.c) | <img src="shaders/shaders_vertex_displacement.png" alt="shaders_vertex_displacement" width="80"> | ⭐️⭐️⭐️ | 5.0 | 4.5 | [Alex ZH](https://github.com/ZzzhHe) |
| 139 | [shaders_write_depth](shaders/shaders_write_depth.c) | <img src="shaders/shaders_write_depth.png" alt="shaders_write_depth" width="80"> | ⭐️⭐️☆☆ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) |
| 140 | [shaders_basic_pbr](shaders/shaders_basic_pbr.c) | <img src="shaders/shaders_basic_pbr.png" alt="shaders_basic_pbr" width="80"> | ⭐️⭐️⭐️⭐️ | 5.0 | 5.1-dev | [Afan OLOVCIC](https://github.com/_DevDad) |
| 141 | [shaders_lightmap](shaders/shaders_lightmap.c) | <img src="shaders/shaders_lightmap.png" alt="shaders_lightmap" width="80"> | ⭐️⭐️⭐️ | 4.5 | 4.5 | [Jussi Viitala](https://github.com/nullstare) |
| 142 | [shaders_rounded_rectangle](shaders/shaders_rounded_rectangle.c) | <img src="shaders/shaders_rounded_rectangle.png" alt="shaders_rounded_rectangle" width=80> | ⭐️⭐️⭐️☆ | 5.5 | 5.5 | [Anstro Pleuton](https://github.com/anstropleuton) |
| 143 | [shaders_view_depth](shaders/shaders_view_depth.c) | <img src="shaders/shaders_view_depth.png" alt="shaders_view_depth" width="80"> | ⭐️⭐️⭐️☆ | 5.6-dev | 5.6-dev | [Luís Almeida](https://github.com/luis605) |
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| [shaders_ascii_rendering](shaders/shaders_ascii_rendering.c) | <img src="shaders/shaders_ascii_rendering.png" alt="shaders_ascii_rendering" width="80"> | ⭐⭐☆☆ | 5.5 | 5.6 | [Maicon Santana](https://github.com/maiconpintoabreu) |
| [shaders_basic_lighting](shaders/shaders_basic_lighting.c) | <img src="shaders/shaders_basic_lighting.png" alt="shaders_basic_lighting" width="80"> | ⭐⭐⭐⭐️ | 3.0 | 4.2 | [Chris Camacho](https://github.com/chriscamacho) |
| [shaders_model_shader](shaders/shaders_model_shader.c) | <img src="shaders/shaders_model_shader.png" alt="shaders_model_shader" width="80"> | ⭐☆☆ | 1.3 | 3.7 | [Ramon Santamaria](https://github.com/raysan5) |
| [shaders_shapes_textures](shaders/shaders_shapes_textures.c) | <img src="shaders/shaders_shapes_textures.png" alt="shaders_shapes_textures" width="80"> | ⭐☆☆ | 1.7 | 3.7 | [Ramon Santamaria](https://github.com/raysan5) |
| [shaders_custom_uniform](shaders/shaders_custom_uniform.c) | <img src="shaders/shaders_custom_uniform.png" alt="shaders_custom_uniform" width="80"> | ⭐⭐☆☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [shaders_postprocessing](shaders/shaders_postprocessing.c) | <img src="shaders/shaders_postprocessing.png" alt="shaders_postprocessing" width="80"> | ⭐⭐⭐☆ | 1.3 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [shaders_palette_switch](shaders/shaders_palette_switch.c) | <img src="shaders/shaders_palette_switch.png" alt="shaders_palette_switch" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.7 | [Marco Lizza](https://github.com/MarcoLizza) |
| [shaders_raymarching_rendering](shaders/shaders_raymarching_rendering.c) | <img src="shaders/shaders_raymarching_rendering.png" alt="shaders_raymarching_rendering" width="80"> | ⭐⭐⭐⭐ | 2.0 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [shaders_texture_rendering](shaders/shaders_texture_rendering.c) | <img src="shaders/shaders_texture_rendering.png" alt="shaders_texture_rendering" width="80"> | ⭐⭐☆☆ | 2.0 | 3.7 | [Michał Ciesielski](https://github.com/ciessielski) |
| [shaders_texture_outline](shaders/shaders_texture_outline.c) | <img src="shaders/shaders_texture_outline.png" alt="shaders_texture_outline" width="80"> | ⭐⭐⭐☆ | 4.0 | 4.0 | [Serenity Skiff](https://github.com/GoldenThumbs) |
| [shaders_texture_waves](shaders/shaders_texture_waves.c) | <img src="shaders/shaders_texture_waves.png" alt="shaders_texture_waves" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Anata](https://github.com/anatagawa) |
| [shaders_julia_set](shaders/shaders_julia_set.c) | <img src="shaders/shaders_julia_set.png" alt="shaders_julia_set" width="80"> | ⭐⭐⭐☆ | 2.5 | 4.0 | [Josh Colclough](https://github.com/joshcol9232) |
| [shaders_mandelbrot_set](shaders/shaders_mandelbrot_set.c) | <img src="shaders/shaders_mandelbrot_set.png" alt="shaders_mandelbrot_set" width="80"> | ⭐⭐⭐☆ | 5.6 | 5.6 | [Jordi Santonja](https://github.com/JordSant) |
| [shaders_color_correction](shaders/shaders_color_correction.c) | <img src="shaders/shaders_color_correction.png" alt="shaders_color_correction" width="80"> | ⭐☆☆ | 5.6 | 5.6 | [Jordi Santonja](https://github.com/JordSant) |
| [shaders_eratosthenes_sieve](shaders/shaders_eratosthenes_sieve.c) | <img src="shaders/shaders_eratosthenes_sieve.png" alt="shaders_eratosthenes_sieve" width="80"> | ⭐⭐⭐☆ | 2.5 | 4.0 | [ProfJski](https://github.com/ProfJski) |
| [shaders_fog_rendering](shaders/shaders_fog_rendering.c) | <img src="shaders/shaders_fog_rendering.png" alt="shaders_fog_rendering" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| [shaders_simple_mask](shaders/shaders_simple_mask.c) | <img src="shaders/shaders_simple_mask.png" alt="shaders_simple_mask" width="80"> | ⭐☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| [shaders_hot_reloading](shaders/shaders_hot_reloading.c) | <img src="shaders/shaders_hot_reloading.png" alt="shaders_hot_reloading" width="80"> | ⭐⭐⭐☆ | 3.0 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐⭐⭐⭐️ | 3.7 | 4.2 | [seanpringle](https://github.com/seanpringle) |
| [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐⭐☆☆ | 3.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [shaders_normalmap_rendering](shaders/shaders_normalmap_rendering.c) | <img src="shaders/shaders_normalmap_rendering.png" alt="shaders_normalmap_rendering" width="80"> | ⭐⭐⭐⭐️ | 5.6 | 5.6 | [Jeremy Montgomery](https://github.com/Sir_Irk) |
| [shaders_spotlight_rendering](shaders/shaders_spotlight_rendering.c) | <img src="shaders/shaders_spotlight_rendering.png" alt="shaders_spotlight_rendering" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
| [shaders_deferred_rendering](shaders/shaders_deferred_rendering.c) | <img src="shaders/shaders_deferred_rendering.png" alt="shaders_deferred_rendering" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) |
| [shaders_hybrid_rendering](shaders/shaders_hybrid_rendering.c) | <img src="shaders/shaders_hybrid_rendering.png" alt="shaders_hybrid_rendering" width="80"> | ⭐⭐⭐⭐ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) |
| [shaders_texture_tiling](shaders/shaders_texture_tiling.c) | <img src="shaders/shaders_texture_tiling.png" alt="shaders_texture_tiling" width="80"> | ⭐⭐☆☆ | 4.5 | 4.5 | [Luis Almeida](https://github.com/luis605) |
| [shaders_shadowmap_rendering](shaders/shaders_shadowmap_rendering.c) | <img src="shaders/shaders_shadowmap_rendering.png" alt="shaders_shadowmap_rendering" width="80"> | ⭐⭐⭐⭐️ | 5.0 | 5.0 | [TheManTheMythTheGameDev](https://github.com/TheManTheMythTheGameDev) |
| [shaders_vertex_displacement](shaders/shaders_vertex_displacement.c) | <img src="shaders/shaders_vertex_displacement.png" alt="shaders_vertex_displacement" width="80"> | ⭐⭐⭐☆ | 5.0 | 4.5 | [Alex ZH](https://github.com/ZzzhHe) |
| [shaders_depth_writing](shaders/shaders_depth_writing.c) | <img src="shaders/shaders_depth_writing.png" alt="shaders_depth_writing" width="80"> | ⭐⭐☆☆ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) |
| [shaders_basic_pbr](shaders/shaders_basic_pbr.c) | <img src="shaders/shaders_basic_pbr.png" alt="shaders_basic_pbr" width="80"> | ⭐⭐⭐⭐️ | 5.0 | 5.5 | [Afan OLOVCIC](https://github.com/_DevDad) |
| [shaders_lightmap_rendering](shaders/shaders_lightmap_rendering.c) | <img src="shaders/shaders_lightmap_rendering.png" alt="shaders_lightmap_rendering" width="80"> | ⭐⭐⭐☆ | 4.5 | 4.5 | [Jussi Viitala](https://github.com/nullstare) |
| [shaders_rounded_rectangle](shaders/shaders_rounded_rectangle.c) | <img src="shaders/shaders_rounded_rectangle.png" alt="shaders_rounded_rectangle" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.5 | [Anstro Pleuton](https://github.com/anstropleuton) |
| [shaders_depth_rendering](shaders/shaders_depth_rendering.c) | <img src="shaders/shaders_depth_rendering.png" alt="shaders_depth_rendering" width="80"> | ⭐⭐⭐☆ | 5.6-dev | 5.6-dev | [Luís Almeida](https://github.com/luis605) |
| [shaders_game_of_life](shaders/shaders_game_of_life.c) | <img src="shaders/shaders_game_of_life.png" alt="shaders_game_of_life" width="80"> | ⭐⭐⭐☆ | 5.6 | 5.6 | [Jordi Santonja](https://github.com/JordSant) |
### category: audio
### category: audio [9]
Examples using raylib audio functionality, including sound/music loading and playing. This functionality is provided by raylib [raudio](../src/raudio.c) module. Note this module can be used standalone independently of raylib, check [raudio_standalone](others/raudio_standalone.c) example.
Examples using raylib audio functionality, including sound/music loading and playing. This functionality is provided by raylib [raudio](../src/raudio.c) module. Note this module can be used standalone independently of raylib.
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 144 | [audio_module_playing](audio/audio_module_playing.c) | <img src="audio/audio_module_playing.png" alt="audio_module_playing" width="80"> | ⭐☆☆☆ | 1.5 | 3.5 | [Ray](https://github.com/raysan5) |
| 145 | [audio_music_stream](audio/audio_music_stream.c) | <img src="audio/audio_music_stream.png" alt="audio_music_stream" width="80"> | ⭐☆☆☆ | 1.3 | 4.2 | [Ray](https://github.com/raysan5) |
| 146 | [audio_raw_stream](audio/audio_raw_stream.c) | <img src="audio/audio_raw_stream.png" alt="audio_raw_stream" width="80"> | ⭐️⭐️⭐️☆ | 1.6 | 4.2 | [Ray](https://github.com/raysan5) |
| 147 | [audio_sound_loading](audio/audio_sound_loading.c) | <img src="audio/audio_sound_loading.png" alt="audio_sound_loading" width="80"> | ⭐☆☆☆ | 1.1 | 3.5 | [Ray](https://github.com/raysan5) |
| 148 | [audio_mixed_processor](audio/audio_mixed_processor.c) | <img src="audio/audio_mixed_processor.png" alt="audio_mixed_processor" width="80"> | ⭐️⭐️⭐️⭐️ | 4.2 | 4.2 | [hkc](https://github.com/hatkidchan) |
| 149 | [audio_stream_effects](audio/audio_stream_effects.c) | <img src="audio/audio_stream_effects.png" alt="audio_stream_effects" width="80"> | ⭐️⭐️⭐️⭐️ | 4.2 | 5.0 | [Ray](https://github.com/raysan5) |
| 150 [audio_sound_multi](audio/audio_sound_multi.c) | <img src="audio/audio_sound_multi.png" alt="audio_sound_multi" width="80"> | ⭐️⭐️☆☆ | 4.6 | 4.6 | [Jeffery Myers](https://github.com/JeffM2501) |
| 151 | [audio_sound_positioning](audio/audio_sound_positioning.c) | <img src="audio/audio_sound_positioning.png" alt="audio_sound_positioning" width="80"> | ⭐️⭐️☆☆ | 5.5 | 5.5 | [Le Juez Victor](https://github.com/Bigfoot71) |
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| [audio_module_playing](audio/audio_module_playing.c) | <img src="audio/audio_module_playing.png" alt="audio_module_playing" width="80"> | ⭐☆☆☆ | 1.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [audio_music_stream](audio/audio_music_stream.c) | <img src="audio/audio_music_stream.png" alt="audio_music_stream" width="80"> | ⭐☆☆☆ | 1.3 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [audio_raw_stream](audio/audio_raw_stream.c) | <img src="audio/audio_raw_stream.png" alt="audio_raw_stream" width="80"> | ⭐⭐⭐☆ | 1.6 | 4.2 | [Ramon Santamaria](https://github.com/raysan5) |
| [audio_sound_loading](audio/audio_sound_loading.c) | <img src="audio/audio_sound_loading.png" alt="audio_sound_loading" width="80"> | ⭐☆☆☆ | 1.1 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
| [audio_mixed_processor](audio/audio_mixed_processor.c) | <img src="audio/audio_mixed_processor.png" alt="audio_mixed_processor" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [hkc](https://github.com/hatkidchan) |
| [audio_stream_effects](audio/audio_stream_effects.c) | <img src="audio/audio_stream_effects.png" alt="audio_stream_effects" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [audio_sound_multi](audio/audio_sound_multi.c) | <img src="audio/audio_sound_multi.png" alt="audio_sound_multi" width="80"> | ⭐☆☆ | 5.0 | 5.0 | [Jeffery Myers](https://github.com/JeffM2501) |
| [audio_sound_positioning](audio/audio_sound_positioning.c) | <img src="audio/audio_sound_positioning.png" alt="audio_sound_positioning" width="80"> | ⭐☆☆ | 5.5 | 5.5 | [Le Juez Victor](https://github.com/Bigfoot71) |
| [audio_spectrum_visualizer](audio/audio_spectrum_visualizer.c) | <img src="audio/audio_spectrum_visualizer.png" alt="audio_spectrum_visualizer" width="80"> | ⭐⭐⭐☆ | 6.0 | 5.6-dev | [IANN](https://github.com/meisei4) |
### category: others
### category: others [6]
Ex150amples showing raylib misc functionality that does not fit in other categories, like standalone modules usage or examples integrating external libraries.
Examples showing raylib misc functionality that does not fit in other categories, like standalone modules usage or examples integrating external libraries.
| ## | example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|----|----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| 152 | [rlgl_standalone](others/rlgl_standalone.c) | <img src="others/rlgl_standalone.png" alt="rlgl_standalone" width="80"> | ⭐️⭐️⭐️⭐️ | 1.6 | 4.0 | [Ray](https://github.com/raysan5) |
| 153 | [rlgl_compute_shader](others/rlgl_compute_shader.c) | <img src="others/rlgl_compute_shader.png" alt="rlgl_compute_shader" width="80"> | ⭐️⭐️⭐️⭐️ | 4.0 | 4.0 | [Teddy Astie](https://github.com/tsnake41) |
| 154 | [easings_testbed](others/easings_testbed.c) | <img src="others/easings_testbed.png" alt="easings_testbed" width="80"> | ⭐️⭐️⭐️☆ | 2.5 | 3.0 | [Juan Miguel López](https://github.com/flashback-fx) |
| 155 | [raylib_opengl_interop](others/raylib_opengl_interop.c) | <img src="others/raylib_opengl_interop.png" alt="raylib_opengl_interop" width="80"> | ⭐️⭐️⭐️⭐️ | 3.8 | 4.0 | [Stephan Soller](https://github.com/arkanis) |
| 156 | [embedded_files_loading](others/embedded_files_loading.c) | <img src="others/embedded_files_loading.png" alt="embedded_files_loading" width="80"> | ⭐️⭐️☆☆ | 3.0 | 3.5 | [Kristian Holmgren](https://github.com/defutura) |
| 157 | [raymath_vector_angle](others/raymath_vector_angle.c) | <img src="others/raymath_vector_angle.png" alt="raymath_vector_angle" width="80"> | ⭐️⭐️☆☆ | 1.0 | 4.6 | [Ray](https://github.com/raysan5) |
| example | image | difficulty<br>level | version<br>created | last version<br>updated | original<br>developer |
|-----------|--------|:-------------------:|:------------------:|:-----------------------:|:----------------------|
| [rlgl_standalone](others/rlgl_standalone.c) | <img src="others/rlgl_standalone.png" alt="rlgl_standalone" width="80"> | ⭐⭐⭐⭐️ | 1.6 | 4.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [rlgl_compute_shader](others/rlgl_compute_shader.c) | <img src="others/rlgl_compute_shader.png" alt="rlgl_compute_shader" width="80"> | ⭐⭐⭐⭐️ | 4.0 | 4.0 | [Teddy Astie](https://github.com/tsnake41) |
| [easings_testbed](others/easings_testbed.c) | <img src="others/easings_testbed.png" alt="easings_testbed" width="80"> | ⭐⭐⭐☆ | 2.5 | 3.0 | [Juan Miguel López](https://github.com/flashback-fx) |
| [raylib_opengl_interop](others/raylib_opengl_interop.c) | <img src="others/raylib_opengl_interop.png" alt="raylib_opengl_interop" width="80"> | ⭐⭐⭐⭐️ | 3.8 | 4.0 | [Stephan Soller](https://github.com/arkanis) |
| [embedded_files_loading](others/embedded_files_loading.c) | <img src="others/embedded_files_loading.png" alt="embedded_files_loading" width="80"> | ⭐☆☆ | 3.0 | 3.5 | [Kristian Holmgren](https://github.com/defutura) |
| [web_basic_window](others/web_basic_window.c) | <img src="others/web_basic_window.png" alt="web_basic_window" width="80"> | ⭐☆☆ | 5.6-dev | 5.6-dev | [Ramon Santamaria](https://github.com/raysan5) |
As always contributions are welcome, feel free to send new examples! Here is an [examples template](examples_template.c) to start with!
Some example missing? As always, contributions are welcome, feel free to send new examples!
Here is an [examples template](examples_template.c) with instructions to start with!

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [audio] example - Mixed audio processing
* raylib [audio] example - mixed processor
*
* Example complexity rating: [★★★★] 4/4
*
@ -30,13 +30,13 @@ void ProcessAudio(void *buffer, unsigned int frames)
for (unsigned int frame = 0; frame < frames; frame++)
{
float *left = &samples[frame * 2 + 0], *right = &samples[frame * 2 + 1];
float *left = &samples[frame*2 + 0], *right = &samples[frame*2 + 1];
*left = powf(fabsf(*left), exponent) * ( (*left < 0.0f)? -1.0f : 1.0f );
*right = powf(fabsf(*right), exponent) * ( (*right < 0.0f)? -1.0f : 1.0f );
*left = powf(fabsf(*left), exponent)*( (*left < 0.0f)? -1.0f : 1.0f );
*right = powf(fabsf(*right), exponent)*( (*right < 0.0f)? -1.0f : 1.0f );
average += fabsf(*left) / frames; // accumulating average volume
average += fabsf(*right) / frames;
average += fabsf(*left)/frames; // accumulating average volume
average += fabsf(*right)/frames;
}
// Moving history to the left
@ -55,7 +55,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - processing mixed output");
InitWindow(screenWidth, screenHeight, "raylib [audio] example - mixed processor");
InitAudioDevice(); // Initialize audio device
@ -99,7 +99,7 @@ int main(void)
DrawRectangle(199, 199, 402, 34, LIGHTGRAY);
for (int i = 0; i < 400; i++)
{
DrawLine(201 + i, 232 - (int)(averageVolume[i] * 32), 201 + i, 232, MAROON);
DrawLine(201 + i, 232 - (int)(averageVolume[i]*32), 201 + i, 232, MAROON);
}
DrawRectangleLines(199, 199, 402, 34, GRAY);

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [audio] example - Module playing (streaming)
* raylib [audio] example - module playing
*
* Example complexity rating: [★☆☆☆] 1/4
*
@ -37,7 +37,7 @@ int main(void)
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)");
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing");
InitAudioDevice(); // Initialize audio device

View File

@ -1,10 +1,10 @@
/*******************************************************************************************
*
* raylib [audio] example - Music playing (streaming)
* raylib [audio] example - music stream
*
* Example complexity rating: [★☆☆☆] 1/4
*
* Example originally created with raylib 1.3, last time updated with raylib 4.0
* Example originally created with raylib 1.3, last time updated with raylib 4.2
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
@ -25,7 +25,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)");
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music stream");
InitAudioDevice(); // Initialize audio device
@ -36,6 +36,12 @@ int main(void)
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
bool pause = false; // Music playing paused
float pan = 0.0f; // Default audio pan center [-1.0f..1.0f]
SetMusicPan(music, pan);
float volume = 0.8f; // Default audio volume [0.0f..1.0f]
SetMusicVolume(music, volume);
SetTargetFPS(30); // Set our game to run at 30 frames-per-second
//--------------------------------------------------------------------------------------
@ -45,7 +51,7 @@ int main(void)
// Update
//----------------------------------------------------------------------------------
UpdateMusicStream(music); // Update music buffer with new stream data
// Restart music playing (stop and play)
if (IsKeyPressed(KEY_SPACE))
{
@ -62,6 +68,34 @@ int main(void)
else ResumeMusicStream(music);
}
// Set audio pan
if (IsKeyDown(KEY_LEFT))
{
pan -= 0.05f;
if (pan < -1.0f) pan = -1.0f;
SetMusicPan(music, pan);
}
else if (IsKeyDown(KEY_RIGHT))
{
pan += 0.05f;
if (pan > 1.0f) pan = 1.0f;
SetMusicPan(music, pan);
}
// Set audio volume
if (IsKeyDown(KEY_DOWN))
{
volume -= 0.05f;
if (volume < 0.0f) volume = 0.0f;
SetMusicVolume(music, volume);
}
else if (IsKeyDown(KEY_UP))
{
volume += 0.05f;
if (volume > 1.0f) volume = 1.0f;
SetMusicVolume(music, volume);
}
// Get normalized time played for current music stream
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music);
@ -76,6 +110,11 @@ int main(void)
DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY);
DrawText("LEFT-RIGHT for PAN CONTROL", 320, 74, 10, DARKBLUE);
DrawRectangle(300, 100, 200, 12, LIGHTGRAY);
DrawRectangleLines(300, 100, 200, 12, GRAY);
DrawRectangle(300 + (pan + 1.0)/2.0f*200 - 5, 92, 10, 28, DARKGRAY);
DrawRectangle(200, 200, 400, 12, LIGHTGRAY);
DrawRectangle(200, 200, (int)(timePlayed*400.0f), 12, MAROON);
DrawRectangleLines(200, 200, 400, 12, GRAY);
@ -83,6 +122,11 @@ int main(void)
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, LIGHTGRAY);
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, LIGHTGRAY);
DrawText("UP-DOWN for VOLUME CONTROL", 320, 334, 10, DARKGREEN);
DrawRectangle(300, 360, 200, 12, LIGHTGRAY);
DrawRectangleLines(300, 360, 200, 12, GRAY);
DrawRectangle(300 + volume*200 - 5, 352, 10, 28, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [audio] example - Raw audio streaming
* raylib [audio] example - raw stream
*
* Example complexity rating: [★★★☆] 3/4
*
@ -62,7 +62,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio streaming");
InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw stream");
InitAudioDevice(); // Initialize audio device
@ -108,8 +108,6 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
// Sample mouse input.
mousePosition = GetMousePosition();
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
@ -117,7 +115,7 @@ int main(void)
float fp = (float)(mousePosition.y);
frequency = 40.0f + (float)(fp);
float pan = (float)(mousePosition.x) / (float)screenWidth;
float pan = (float)(mousePosition.x)/(float)screenWidth;
SetAudioStreamPan(stream, pan);
}
@ -125,7 +123,7 @@ int main(void)
// Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc.
if (frequency != oldFrequency)
{
// Compute wavelength. Limit size in both directions.
// Compute wavelength. Limit size in both directions
//int oldWavelength = waveLength;
waveLength = (int)(22050/frequency);
if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2;
@ -143,7 +141,7 @@ int main(void)
}
// Scale read cursor's position to minimize transition artifacts
//readCursor = (int)(readCursor * ((float)waveLength / (float)oldWavelength));
//readCursor = (int)(readCursor*((float)waveLength/(float)oldWavelength));
oldFrequency = frequency;
}
@ -168,7 +166,7 @@ int main(void)
memcpy(writeBuf + writeCursor, data + readCursor, writeLength*sizeof(short));
// Update cursors and loop audio
readCursor = (readCursor + writeLength) % waveLength;
readCursor = (readCursor + writeLength)%waveLength;
writeCursor += writeLength;
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [audio] example - Sound loading and playing
* raylib [audio] example - sound loading
*
* Example complexity rating: [★☆☆☆] 1/4
*
@ -25,7 +25,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing");
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading");
InitAudioDevice(); // Initialize audio device

View File

@ -1,10 +1,10 @@
/*******************************************************************************************
*
* raylib [audio] example - Playing sound multiple times
* raylib [audio] example - sound multi
*
* Example complexity rating: [★★☆☆] 2/4
*
* Example originally created with raylib 4.6, last time updated with raylib 4.6
* Example originally created with raylib 5.0, last time updated with raylib 5.0
*
* Example contributed by Jeffery Myers (@JeffM2501) and reviewed by Ramon Santamaria (@raysan5)
*
@ -31,18 +31,18 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - playing sound multiple times");
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound multi");
InitAudioDevice(); // Initialize audio device
// load the sound list
soundArray[0] = LoadSound("resources/sound.wav"); // Load WAV audio file into the first slot as the 'source' sound
// this sound owns the sample data
for (int i = 1; i < MAX_SOUNDS; i++)
{
soundArray[i] = LoadSoundAlias(soundArray[0]); // Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
}
currentSound = 0; // set the sound list to the start
// Load audio file into the first slot as the 'source' sound,
// this sound owns the sample data
soundArray[0] = LoadSound("resources/sound.wav");
// Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
for (int i = 1; i < MAX_SOUNDS; i++) soundArray[i] = LoadSoundAlias(soundArray[0]);
currentSound = 0; // Set the sound list to the start
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -54,14 +54,15 @@ int main(void)
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE))
{
PlaySound(soundArray[currentSound]); // play the next open sound slot
currentSound++; // increment the sound slot
if (currentSound >= MAX_SOUNDS) // if the sound slot is out of bounds, go back to 0
currentSound = 0;
PlaySound(soundArray[currentSound]); // Play the next open sound slot
currentSound++; // Increment the sound slot
// Note: a better way would be to look at the list for the first sound that is not playing and use that slot
// If the sound slot is out of bounds, go back to 0
if (currentSound >= MAX_SOUNDS) currentSound = 0;
// NOTE: Another approach would be to look at the list for the first sound
// that is not playing and use that slot
}
//----------------------------------------------------------------------------------
// Draw
@ -78,9 +79,8 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
for (int i = 1; i < MAX_SOUNDS; i++)
UnloadSoundAlias(soundArray[i]); // Unload sound aliases
UnloadSound(soundArray[0]); // Unload source sound data
for (int i = 1; i < MAX_SOUNDS; i++) UnloadSoundAlias(soundArray[i]); // Unload sound aliases
UnloadSound(soundArray[0]); // Unload source sound data
CloseAudioDevice(); // Close audio device

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [audio] example - Playing spatialized 3D sound
* raylib [audio] example - sound positioning
*
* Example complexity rating: [★★☆☆] 2/4
*
@ -19,7 +19,9 @@
#include "raymath.h"
// Sound positioning function
//------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, float maxDist);
//------------------------------------------------------------------------------------
@ -31,9 +33,9 @@ int main(void)
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - Playing spatialized 3D sound");
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound positioning");
InitAudioDevice();
Sound sound = LoadSound("resources/coin.wav");
@ -45,9 +47,9 @@ int main(void)
.fovy = 60,
.projection = CAMERA_PERSPECTIVE
};
DisableCursor();
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -58,7 +60,7 @@ int main(void)
//----------------------------------------------------------------------------------
UpdateCamera(&camera, CAMERA_FREE);
float th = GetTime();
float th = (float)GetTime();
Vector3 spherePos = {
.x = 5.0f*cosf(th),
@ -67,6 +69,7 @@ int main(void)
};
SetSoundPosition(camera, sound, spherePos, 20.0f);
if (!IsSoundPlaying(sound)) PlaySound(sound);
//----------------------------------------------------------------------------------
@ -89,34 +92,39 @@ int main(void)
//--------------------------------------------------------------------------------------
UnloadSound(sound);
CloseAudioDevice(); // Close audio device
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
// Sound positioning function
//------------------------------------------------------------------------------------
// Module Functions Definition
//------------------------------------------------------------------------------------
// Set sound 3d position
static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, float maxDist)
{
// Calculate direction vector and distance between listener and sound source
Vector3 direction = Vector3Subtract(position, listener.position);
float distance = Vector3Length(direction);
// Apply logarithmic distance attenuation and clamp between 0-1
float attenuation = 1.0f/(1.0f + (distance/maxDist));
attenuation = Clamp(attenuation, 0.0f, 1.0f);
// Calculate normalized vectors for spatial positioning
Vector3 normalizedDirection = Vector3Normalize(direction);
Vector3 forward = Vector3Normalize(Vector3Subtract(listener.target, listener.position));
Vector3 right = Vector3Normalize(Vector3CrossProduct(listener.up, forward));
// Reduce volume for sounds behind the listener
float dotProduct = Vector3DotProduct(forward, normalizedDirection);
if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct*0.5f);
// Set stereo panning based on sound position relative to listener
float pan = 0.5f + 0.5f*Vector3DotProduct(normalizedDirection, right);
// Apply final sound properties
SetSoundVolume(sound, attenuation);
SetSoundPan(sound, pan);

View File

@ -0,0 +1,285 @@
/*******************************************************************************************
*
* raylib [audio] example - spectrum visualizer
*
* Example complexity rating: [★★★☆] 3/4
*
* Example originally created with raylib 6.0, last time updated with raylib 5.6-dev
*
* Inspired by Inigo Quilez's https://www.shadertoy.com/
* Resources/specification: https://gist.github.com/soulthreads/2efe50da4be1fb5f7ab60ff14ca434b8
*
* Example created by created by IANN (@meisei4) reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025 IANN (@meisei4)
*
********************************************************************************************/
#include "raylib.h"
#include "raymath.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#if defined(PLATFORM_DESKTOP)
#define GLSL_VERSION 330
#else // PLATFORM_ANDROID, PLATFORM_WEB
#define GLSL_VERSION 100
#endif
#define MONO 1
#define SAMPLE_RATE 44100
#define SAMPLE_RATE_F 44100.0f
#define FFT_WINDOW_SIZE 1024
#define BUFFER_SIZE 512
#define PER_SAMPLE_BIT_DEPTH 16
#define AUDIO_STREAM_RING_BUFFER_SIZE (FFT_WINDOW_SIZE*2)
#define EFFECTIVE_SAMPLE_RATE (SAMPLE_RATE_F*0.5f)
#define WINDOW_TIME ((double)FFT_WINDOW_SIZE/(double)EFFECTIVE_SAMPLE_RATE)
#define FFT_HISTORICAL_SMOOTHING_DUR 2.0f
#define MIN_DECIBELS (-100.0f) // https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/minDecibels
#define MAX_DECIBELS (-30.0f) // https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/maxDecibels
#define INVERSE_DECIBEL_RANGE (1.0f/(MAX_DECIBELS - MIN_DECIBELS))
#define DB_TO_LINEAR_SCALE (20.0f/2.302585092994046f)
#define SMOOTHING_TIME_CONSTANT 0.8f // https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/smoothingTimeConstant
#define TEXTURE_HEIGHT 1
#define FFT_ROW 0
#define UNUSED_CHANNEL 0.0f
typedef struct FFTComplex { float real, imaginary; } FFTComplex;
typedef struct FFTData {
FFTComplex *spectrum;
FFTComplex *workBuffer;
float *prevMagnitudes;
float (*fftHistory)[BUFFER_SIZE];
int fftHistoryLen;
int historyPos;
double lastFftTime;
float tapbackPos;
} FFTData;
static void CaptureFrame(FFTData *fftData, const float *audioSamples);
static void RenderFrame(const FFTData *fftData, Image *fftImage);
static void CooleyTukeyFFTSlow(FFTComplex *spectrum, int n);
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//----------------------------------------------------------------------------------- ---
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - spectrum visualizer");
Image fftImage = GenImageColor(BUFFER_SIZE, TEXTURE_HEIGHT, WHITE);
Texture2D fftTexture = LoadTextureFromImage(fftImage);
RenderTexture2D bufferA = LoadRenderTexture(screenWidth, screenHeight);
Vector2 iResolution = { (float)screenWidth, (float)screenHeight };
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/fft.fs", GLSL_VERSION));
int iResolutionLocation = GetShaderLocation(shader, "iResolution");
int iChannel0Location = GetShaderLocation(shader, "iChannel0");
SetShaderValue(shader, iResolutionLocation, &iResolution, SHADER_UNIFORM_VEC2);
SetShaderValueTexture(shader, iChannel0Location, fftTexture);
InitAudioDevice();
SetAudioStreamBufferSizeDefault(AUDIO_STREAM_RING_BUFFER_SIZE);
// WARNING: Memory out-of-bounds on PLATFORM_WEB
Wave wav = LoadWave("resources/country.mp3");
WaveFormat(&wav, SAMPLE_RATE, PER_SAMPLE_BIT_DEPTH, MONO);
AudioStream audioStream = LoadAudioStream(SAMPLE_RATE, PER_SAMPLE_BIT_DEPTH, MONO);
PlayAudioStream(audioStream);
int fftHistoryLen = (int)ceilf(FFT_HISTORICAL_SMOOTHING_DUR/WINDOW_TIME) + 1;
FFTData fft = {
.spectrum = RL_CALLOC(sizeof(FFTComplex), FFT_WINDOW_SIZE),
.workBuffer = RL_CALLOC(sizeof(FFTComplex), FFT_WINDOW_SIZE),
.prevMagnitudes = RL_CALLOC(BUFFER_SIZE, sizeof(float)),
.fftHistory = RL_CALLOC(fftHistoryLen, sizeof(float[BUFFER_SIZE])),
.fftHistoryLen = fftHistoryLen,
.historyPos = 0,
.lastFftTime = 0.0,
.tapbackPos = 0.01f
};
size_t wavCursor = 0;
const short *wavPCM16 = wav.data;
short chunkSamples[AUDIO_STREAM_RING_BUFFER_SIZE] = { 0 };
float audioSamples[FFT_WINDOW_SIZE] = { 0 };
SetTargetFPS(60);
//----------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
while (IsAudioStreamProcessed(audioStream))
{
for (int i = 0; i < AUDIO_STREAM_RING_BUFFER_SIZE; i++)
{
int left = (wav.channels == 2)? wavPCM16[wavCursor*2 + 0] : wavPCM16[wavCursor];
int right = (wav.channels == 2)? wavPCM16[wavCursor*2 + 1] : left;
chunkSamples[i] = (short)((left + right)/2);
if (++wavCursor >= wav.frameCount) wavCursor = 0;
}
UpdateAudioStream(audioStream, chunkSamples, AUDIO_STREAM_RING_BUFFER_SIZE);
for (int i = 0; i < FFT_WINDOW_SIZE; i++) audioSamples[i] = (chunkSamples[i*2] + chunkSamples[i*2 + 1])*0.5f/32767.0f;
}
CaptureFrame(&fft, audioSamples);
RenderFrame(&fft, &fftImage);
UpdateTexture(fftTexture, fftImage.data);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
BeginShaderMode(shader);
SetShaderValueTexture(shader, iChannel0Location, fftTexture);
DrawTextureRec(bufferA.texture,
(Rectangle){ 0, 0, (float)screenWidth, (float)-screenHeight },
(Vector2){ 0, 0 }, WHITE);
EndShaderMode();
EndDrawing();
//------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadShader(shader);
UnloadRenderTexture(bufferA);
UnloadTexture(fftTexture);
UnloadImage(fftImage);
UnloadAudioStream(audioStream);
UnloadWave(wav);
CloseAudioDevice();
RL_FREE(fft.spectrum);
RL_FREE(fft.workBuffer);
RL_FREE(fft.prevMagnitudes);
RL_FREE(fft.fftHistory);
CloseWindow(); // Close window and OpenGL context
//----------------------------------------------------------------------------------
return 0;
}
// CooleyTukey FFT https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm#Data_reordering,_bit_reversal,_and_in-place_algorithms
static void CooleyTukeyFFTSlow(FFTComplex *spectrum, int n)
{
int j = 0;
for (int i = 1; i < n - 1; i++)
{
int bit = n >> 1;
while (j >= bit)
{
j -= bit;
bit >>= 1;
}
j += bit;
if (i < j)
{
FFTComplex temp = spectrum[i];
spectrum[i] = spectrum[j];
spectrum[j] = temp;
}
}
for (int len = 2; len <= n; len <<= 1)
{
float angle = -2.0f*PI/len;
FFTComplex twiddleUnit = { cosf(angle), sinf(angle) };
for (int i = 0; i < n; i += len)
{
FFTComplex twiddleCurrent = { 1.0f, 0.0f };
for (int j = 0; j < len/2; j++)
{
FFTComplex even = spectrum[i + j];
FFTComplex odd = spectrum[i + j + len/2];
FFTComplex twiddledOdd = {
odd.real*twiddleCurrent.real - odd.imaginary*twiddleCurrent.imaginary,
odd.real*twiddleCurrent.imaginary + odd.imaginary*twiddleCurrent.real
};
spectrum[i + j].real = even.real + twiddledOdd.real;
spectrum[i + j].imaginary = even.imaginary + twiddledOdd.imaginary;
spectrum[i + j + len/2].real = even.real - twiddledOdd.real;
spectrum[i + j + len/2].imaginary = even.imaginary - twiddledOdd.imaginary;
float twiddleRealNext = twiddleCurrent.real*twiddleUnit.real - twiddleCurrent.imaginary*twiddleUnit.imaginary;
twiddleCurrent.imaginary = twiddleCurrent.real*twiddleUnit.imaginary + twiddleCurrent.imaginary*twiddleUnit.real;
twiddleCurrent.real = twiddleRealNext;
}
}
}
}
static void CaptureFrame(FFTData *fftData, const float *audioSamples)
{
for (int i = 0; i < FFT_WINDOW_SIZE; i++)
{
float x = (2.0f*PI*i)/(FFT_WINDOW_SIZE - 1.0f);
float blackmanWeight = 0.42f - 0.5f*cosf(x) + 0.08f*cosf(2.0f*x); // https://en.wikipedia.org/wiki/Window_function#Blackman_window
fftData->workBuffer[i].real = audioSamples[i]*blackmanWeight;
fftData->workBuffer[i].imaginary = 0.0f;
}
CooleyTukeyFFTSlow(fftData->workBuffer, FFT_WINDOW_SIZE);
memcpy(fftData->spectrum, fftData->workBuffer, sizeof(FFTComplex)*FFT_WINDOW_SIZE);
float smoothedSpectrum[BUFFER_SIZE];
for (int bin = 0; bin < BUFFER_SIZE; bin++)
{
float re = fftData->workBuffer[bin].real;
float im = fftData->workBuffer[bin].imaginary;
float linearMagnitude = sqrtf(re*re + im*im)/FFT_WINDOW_SIZE;
float smoothedMagnitude = SMOOTHING_TIME_CONSTANT*fftData->prevMagnitudes[bin] + (1.0f - SMOOTHING_TIME_CONSTANT)*linearMagnitude;
fftData->prevMagnitudes[bin] = smoothedMagnitude;
float db = logf(fmaxf(smoothedMagnitude, 1e-40f))*DB_TO_LINEAR_SCALE;
float normalized = (db - MIN_DECIBELS)*INVERSE_DECIBEL_RANGE;
smoothedSpectrum[bin] = Clamp(normalized, 0.0f, 1.0f);
}
fftData->lastFftTime = GetTime();
memcpy(fftData->fftHistory[fftData->historyPos], smoothedSpectrum, sizeof(smoothedSpectrum));
fftData->historyPos = (fftData->historyPos + 1)%fftData->fftHistoryLen;
}
static void RenderFrame(const FFTData *fftData, Image *fftImage)
{
double framesSinceTapback = floor(fftData->tapbackPos/WINDOW_TIME);
framesSinceTapback = Clamp(framesSinceTapback, 0.0, fftData->fftHistoryLen - 1);
int historyPosition = (fftData->historyPos - 1 - (int)framesSinceTapback)%fftData->fftHistoryLen;
if (historyPosition < 0) historyPosition += fftData->fftHistoryLen;
const float *amplitude = fftData->fftHistory[historyPosition];
for (int bin = 0; bin < BUFFER_SIZE; bin++) ImageDrawPixel(fftImage, bin, FFT_ROW, ColorFromNormalized((Vector4){ amplitude[bin], UNUSED_CHANNEL, UNUSED_CHANNEL, UNUSED_CHANNEL }));
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [audio] example - Music stream processing effects
* raylib [audio] example - stream effects
*
* Example complexity rating: [★★★★] 4/4
*
@ -17,7 +17,9 @@
#include <stdlib.h> // Required for: NULL
// Required delay effect variables
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
static float *delayBuffer = NULL;
static unsigned int delayBufferSize = 0;
static unsigned int delayReadIndex = 2;
@ -53,7 +55,7 @@ int main(void)
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
bool pause = false; // Music playing paused
bool enableEffectLPF = false; // Enable effect low-pass-filter
bool enableEffectDelay = false; // Enable effect delay (1 second)
@ -98,7 +100,7 @@ int main(void)
if (enableEffectDelay) AttachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
else DetachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
}
// Get normalized time played for current music stream
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music);
@ -119,7 +121,7 @@ int main(void)
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 230, 20, LIGHTGRAY);
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 260, 20, LIGHTGRAY);
DrawText(TextFormat("PRESS F TO TOGGLE LPF EFFECT: %s", enableEffectLPF? "ON" : "OFF"), 200, 320, 20, GRAY);
DrawText(TextFormat("PRESS D TO TOGGLE DELAY EFFECT: %s", enableEffectDelay? "ON" : "OFF"), 180, 350, 20, GRAY);
@ -148,8 +150,8 @@ int main(void)
static void AudioProcessEffectLPF(void *buffer, unsigned int frames)
{
static float low[2] = { 0.0f, 0.0f };
static const float cutoff = 70.0f / 44100.0f; // 70 Hz lowpass filter
const float k = cutoff / (cutoff + 0.1591549431f); // RC filter formula
static const float cutoff = 70.0f/44100.0f; // 70 Hz lowpass filter
const float k = cutoff/(cutoff + 0.1591549431f); // RC filter formula
// Converts the buffer data before using it
float *bufferData = (float *)buffer;
@ -158,8 +160,8 @@ static void AudioProcessEffectLPF(void *buffer, unsigned int frames)
const float l = bufferData[i];
const float r = bufferData[i + 1];
low[0] += k * (l - low[0]);
low[1] += k * (r - low[1]);
low[0] += k*(l - low[0]);
low[1] += k*(r - low[1]);
bufferData[i] = low[0];
bufferData[i + 1] = low[1];
}

View File

@ -0,0 +1,37 @@
#version 100
precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform vec2 iResolution;
uniform sampler2D iChannel0;
const vec4 BLACK = vec4(0.0, 0.0, 0.0, 1.0);
const vec4 WHITE = vec4(1.0, 1.0, 1.0, 1.0);
const float FFT_ROW = 0.0;
const float NUM_OF_BINS = 512.0;
void main()
{
vec2 fragCoord = fragTexCoord*iResolution;
float cellWidth = iResolution.x/NUM_OF_BINS;
float binIndex = floor(fragCoord.x/cellWidth);
float localX = mod(fragCoord.x, cellWidth);
float barWidth = cellWidth - 1.0;
vec4 color = WHITE;
if (localX <= barWidth)
{
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
float amplitude = texture2D(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
if (fragTexCoord.y < amplitude) color = BLACK;
}
gl_FragColor = color;
}

View File

@ -0,0 +1,35 @@
#version 120
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform vec2 iResolution;
uniform sampler2D iChannel0;
const vec4 BLACK = vec4(0.0, 0.0, 0.0, 1.0);
const vec4 WHITE = vec4(1.0, 1.0, 1.0, 1.0);
const float FFT_ROW = 0.0;
const float NUM_OF_BINS = 512.0;
void main()
{
vec2 fragCoord = fragTexCoord*iResolution;
float cellWidth = iResolution.x/NUM_OF_BINS;
float binIndex = floor(fragCoord.x/cellWidth);
float localX = mod(fragCoord.x, cellWidth);
float barWidth = cellWidth - 1.0;
vec4 color = WHITE;
if (localX <= barWidth)
{
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
float amplitude = texture2D(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
if (fragTexCoord.y < amplitude) color = BLACK;
}
gl_FragColor = color;
}

View File

@ -0,0 +1,35 @@
#version 330
in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 finalColor;
uniform vec2 iResolution;
uniform sampler2D iChannel0;
const vec4 BLACK = vec4(0.0, 0.0, 0.0, 1.0);
const vec4 WHITE = vec4(1.0, 1.0, 1.0, 1.0);
const float FFT_ROW = 0.0;
const float NUM_OF_BINS = 512.0;
void main()
{
vec2 fragCoord = fragTexCoord*iResolution;
float cellWidth = iResolution.x/NUM_OF_BINS;
float binIndex = floor(fragCoord.x/cellWidth);
float localX = mod(fragCoord.x, cellWidth);
float barWidth = cellWidth - 1.0;
vec4 color = WHITE;
if (localX <= barWidth)
{
float sampleX = (binIndex + 0.5)/NUM_OF_BINS;
vec2 sampleCoord = vec2(sampleX, FFT_ROW);
float amplitude = texture(iChannel0, sampleCoord).r; // Only filled the red channel, all channels left open for alternative use
if (fragTexCoord.y < amplitude) color = BLACK;
}
finalColor = color;
}

View File

@ -0,0 +1,44 @@
::@echo off
:: .
:: Compile your examples for web using: build_example_web.bat <example_category>/<example_name>
:: .
SET "INPUT_FILE=%1"
:: Change delimiter for the FOR loop
FOR /f "tokens=1-10 delims=/" %%a IN ("%INPUT_FILE%") DO (
SET CATEGORY=%%a
SET FILENAME=%%b
)
:: > SETup required Environment
:: -------------------------------------
SET RAYLIB_PATH=C:\GitHub\raylib
SET EMSDK_PATH=C:\raylib\emsdk
SET COMPILER_PATH=C:\raylib\w64devkit\bin
ENV_SET PATH=%COMPILER_PATH%
SET MAKE=mingw32-make
echo
:: Set required web compilation options
:: -------------------------------------
::SET CC=%EMSDK_PATH%\upstream\emscripten\emcc
::SET CFLAGS=-Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O3 -I. -Iexternal -I%RAYLIB_PATH%\src -I%RAYLIB_PATH%\external -DPLATFORM_WEB
::SET LDFLAGS=-L. -L$(RAYLIB_PATH)\src -sUSE_GLFW=3 -sEXPORTED_RUNTIME_METHODS=ccall -sASYNCIFY --shell-file %RAYLIB_PATH%\src\shell.html
::SET LDLIBS=%RAYLIB_PATH%\src\libraylib.web.a
echo
:: Clean latest build
:: ------------------------
cmd /c if exist %FILENAME%.html del /F %FILENAME%.html
cmd /c if exist %FILENAME%.wasm del /F %FILENAME%.wasm
cmd /c if exist %FILENAME%.js del /F %FILENAME%.js
cmd /c if exist %FILENAME%.data del /F %FILENAME%.data
echo
:: Setup emsdk environment
:: --------------------------
call %EMSDK_PATH%\emsdk_env.bat
echo on
:: Compile program
:: -----------------------
C:
cd %RAYLIB_PATH%\examples
%MAKE% -f Makefile.Web %CATEGORY%/%FILENAME% PLATFORM=PLATFORM_WEB -B
::%CC% -o %FILENAME%.html %FILENAME%.c %CFLAGS% %LDFLAGS% %LDLIBS% %RESOURCES%
cd ..
echo

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - 2D Camera system
* raylib [core] example - 2d camera
*
* Example complexity rating: [★★☆☆] 2/4
*
@ -125,8 +125,8 @@ int main(void)
DrawRectangle( 10, 10, 250, 113, Fade(SKYBLUE, 0.5f));
DrawRectangleLines( 10, 10, 250, 113, BLUE);
DrawText("Free 2d camera controls:", 20, 20, 10, BLACK);
DrawText("- Right/Left to move Offset", 40, 40, 10, DARKGRAY);
DrawText("Free 2D camera controls:", 20, 20, 10, BLACK);
DrawText("- Right/Left to move player", 40, 40, 10, DARKGRAY);
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY);
DrawText("- A / S to Rotate", 40, 80, 10, DARKGRAY);
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -23,7 +23,7 @@
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main ()
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
@ -35,9 +35,9 @@ int main ()
Camera2D camera = { 0 };
camera.zoom = 1.0f;
int zoomMode = 0; // 0-Mouse Wheel, 1-Mouse Move
int zoomMode = 0; // 0-Mouse Wheel, 1-Mouse Move
SetTargetFPS(60); // 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
@ -47,7 +47,7 @@ int main ()
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_ONE)) zoomMode = 0;
else if (IsKeyPressed(KEY_TWO)) zoomMode = 1;
// Translate based on mouse right click
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
{
@ -68,7 +68,7 @@ int main ()
// Set the offset to where the mouse is
camera.offset = GetMousePosition();
// Set the target to match, so that the camera maps the world space point
// Set the target to match, so that the camera maps the world space point
// under the cursor to the screen space point under the cursor at any zoom
camera.target = mouseWorldPos;
@ -89,10 +89,11 @@ int main ()
// Set the offset to where the mouse is
camera.offset = GetMousePosition();
// Set the target to match, so that the camera maps the world space point
// Set the target to match, so that the camera maps the world space point
// under the cursor to the screen space point under the cursor at any zoom
camera.target = mouseWorldPos;
}
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
{
// Zoom increment
@ -110,8 +111,7 @@ int main ()
ClearBackground(RAYWHITE);
BeginMode2D(camera);
// Draw the 3d grid, rotated 90 degrees and centered around 0,0
// Draw the 3d grid, rotated 90 degrees and centered around 0,0
// just so we have something in the XY plane
rlPushMatrix();
rlTranslatef(0, 25*50, 0);
@ -121,19 +121,18 @@ int main ()
// Draw a reference circle
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, 50, MAROON);
EndMode2D();
// Draw mouse reference
//Vector2 mousePos = GetWorldToScreen2D(GetMousePosition(), camera)
DrawCircleV(GetMousePosition(), 4, DARKGRAY);
DrawTextEx(GetFontDefault(), TextFormat("[%i, %i]", GetMouseX(), GetMouseY()),
DrawTextEx(GetFontDefault(), TextFormat("[%i, %i]", GetMouseX(), GetMouseY()),
Vector2Add(GetMousePosition(), (Vector2){ -44, -24 }), 20, 2, BLACK);
DrawText("[1][2] Select mouse zoom mode (Wheel or Move)", 20, 20, 20, DARKGRAY);
if (zoomMode == 0) DrawText("Mouse left button drag to move, mouse wheel to zoom", 20, 50, 20, DARKGRAY);
else DrawText("Mouse left button drag to move, mouse press and move to zoom", 20, 50, 20, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
@ -142,5 +141,6 @@ int main ()
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - 2D Camera platformer
* raylib [core] example - 2d camera platformer
*
* Example complexity rating: [★★★☆] 3/4
*
@ -22,6 +22,9 @@
#define PLAYER_JUMP_SPD 350.0f
#define PLAYER_HOR_SPD 200.0f
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef struct Player {
Vector2 position;
float speed;
@ -35,7 +38,7 @@ typedef struct EnvItem {
} EnvItem;
//----------------------------------------------------------------------------------
// Module functions declaration
// 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);
@ -54,7 +57,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera");
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera platformer");
Player player = { 0 };
player.position = (Vector2){ 400, 280 };
@ -137,7 +140,7 @@ int main(void)
Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40.0f, 40.0f };
DrawRectangleRec(playerRect, RED);
DrawCircleV(player.position, 5.0f, GOLD);
EndMode2D();
@ -294,7 +297,7 @@ void UpdateCameraPlayerBoundsPush(Camera2D *camera, Player *player, EnvItem *env
Vector2 bboxWorldMin = GetScreenToWorld2D((Vector2){ (1 - bbox.x)*0.5f*width, (1 - bbox.y)*0.5f*height }, *camera);
Vector2 bboxWorldMax = GetScreenToWorld2D((Vector2){ (1 + bbox.x)*0.5f*width, (1 + bbox.y)*0.5f*height }, *camera);
camera->offset = (Vector2){ (1 - bbox.x)*0.5f * width, (1 - bbox.y)*0.5f*height };
camera->offset = (Vector2){ (1 - bbox.x)*0.5f*width, (1 - bbox.y)*0.5f*height };
if (player->position.x < bboxWorldMin.x) camera->target.x = player->position.x;
if (player->position.y < bboxWorldMin.y) camera->target.y = player->position.y;

View File

@ -4,7 +4,7 @@
*
* Example complexity rating: [★★★★] 4/4
*
* Addapted from the core_3d_camera_split_screen example:
* Addapted from the core_3d_camera_split_screen example:
* https://github.com/raysan5/raylib/blob/master/examples/core/core_3d_camera_split_screen.c
*
* Example originally created with raylib 4.5, last time updated with raylib 4.5
@ -81,9 +81,9 @@ int main(void)
//----------------------------------------------------------------------------------
BeginTextureMode(screenCamera1);
ClearBackground(RAYWHITE);
BeginMode2D(camera1);
// Draw full scene with first camera
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
{
@ -106,17 +106,17 @@ int main(void)
DrawRectangleRec(player1, RED);
DrawRectangleRec(player2, BLUE);
EndMode2D();
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
DrawText("PLAYER1: W/S/A/D to move", 10, 10, 10, MAROON);
EndTextureMode();
BeginTextureMode(screenCamera2);
ClearBackground(RAYWHITE);
BeginMode2D(camera2);
// Draw full scene with second camera
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
{
@ -138,21 +138,21 @@ int main(void)
DrawRectangleRec(player1, RED);
DrawRectangleRec(player2, BLUE);
EndMode2D();
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
DrawText("PLAYER2: UP/DOWN/LEFT/RIGHT to move", 10, 10, 10, DARKBLUE);
EndTextureMode();
// Draw both views render textures to the screen side by side
BeginDrawing();
ClearBackground(BLACK);
DrawTextureRec(screenCamera1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
DrawTextureRec(screenCamera2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
EndDrawing();
}

View File

@ -100,8 +100,8 @@ int main(void)
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.projection = CAMERA_ORTHOGRAPHIC;
camera.fovy = 20.0f; // near plane width in CAMERA_ORTHOGRAPHIC
CameraYaw(&camera, -135 * DEG2RAD, true);
CameraPitch(&camera, -45 * DEG2RAD, true, true, false);
CameraYaw(&camera, -135*DEG2RAD, true);
CameraPitch(&camera, -45*DEG2RAD, true, true, false);
}
else if (camera.projection == CAMERA_ORTHOGRAPHIC)
{
@ -119,7 +119,6 @@ int main(void)
// Some default standard keyboard/mouse inputs are hardcoded to simplify use
// For advanced camera controls, it's recommended to compute camera movement manually
UpdateCamera(&camera, cameraMode); // Update camera
/*
// Camera PRO usage example (EXPERIMENTAL)
// This new camera function allows custom movement/rotation values to be directly provided
@ -127,7 +126,7 @@ int main(void)
UpdateCameraPro(&camera,
(Vector3){
(IsKeyDown(KEY_W) || IsKeyDown(KEY_UP))*0.1f - // Move forward-backward
(IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN))*0.1f,
(IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN))*0.1f,
(IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT))*0.1f - // Move right-left
(IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT))*0.1f,
0.0f // Move up-down

View File

@ -0,0 +1,329 @@
/*******************************************************************************************
*
* raylib [core] example - 3d camera fps
*
* Example complexity rating: [★★★☆] 3/4
*
* Example originally created with raylib 5.5, last time updated with raylib 5.5
*
* Example contributed by Agnis Aldiņš (@nezvers) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025 Agnis Aldiņš (@nezvers)
*
********************************************************************************************/
#include "raylib.h"
#include "raymath.h"
//----------------------------------------------------------------------------------
// Defines and Macros
//----------------------------------------------------------------------------------
// Movement constants
#define GRAVITY 32.0f
#define MAX_SPEED 20.0f
#define CROUCH_SPEED 5.0f
#define JUMP_FORCE 12.0f
#define MAX_ACCEL 150.0f
// Grounded drag
#define FRICTION 0.86f
// Increasing air drag, increases strafing speed
#define AIR_DRAG 0.98f
// Responsiveness for turning movement direction to looked direction
#define CONTROL 15.0f
#define CROUCH_HEIGHT 0.0f
#define STAND_HEIGHT 1.0f
#define BOTTOM_HEIGHT 0.5f
#define NORMALIZE_INPUT 0
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
// Body structure
typedef struct {
Vector3 position;
Vector3 velocity;
Vector3 dir;
bool isGrounded;
} Body;
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
static Vector2 sensitivity = { 0.001f, 0.001f };
static Body player = { 0 };
static Vector2 lookRotation = { 0 };
static float headTimer = 0.0f;
static float walkLerp = 0.0f;
static float headLerp = STAND_HEIGHT;
static Vector2 lean = { 0 };
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
static void DrawLevel(void);
static void UpdateCameraFPS(Camera *camera);
static void UpdateBody(Body *body, float rot, char side, char forward, bool jumpPressed, bool crouchHold);
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera fps");
// Initialize camera variables
// NOTE: UpdateCameraFPS() takes care of the rest
Camera camera = { 0 };
camera.fovy = 60.0f;
camera.projection = CAMERA_PERSPECTIVE;
camera.position = (Vector3){
player.position.x,
player.position.y + (BOTTOM_HEIGHT + headLerp),
player.position.z,
};
UpdateCameraFPS(&camera); // Update camera parameters
DisableCursor(); // Limit cursor to relative movement inside the window
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
//----------------------------------------------------------------------------------
Vector2 mouseDelta = GetMouseDelta();
lookRotation.x -= mouseDelta.x*sensitivity.x;
lookRotation.y += mouseDelta.y*sensitivity.y;
char sideway = (IsKeyDown(KEY_D) - IsKeyDown(KEY_A));
char forward = (IsKeyDown(KEY_W) - IsKeyDown(KEY_S));
bool crouching = IsKeyDown(KEY_LEFT_CONTROL);
UpdateBody(&player, lookRotation.x, sideway, forward, IsKeyPressed(KEY_SPACE), crouching);
float delta = GetFrameTime();
headLerp = Lerp(headLerp, (crouching ? CROUCH_HEIGHT : STAND_HEIGHT), 20.0f*delta);
camera.position = (Vector3){
player.position.x,
player.position.y + (BOTTOM_HEIGHT + headLerp),
player.position.z,
};
if (player.isGrounded && ((forward != 0) || (sideway != 0)))
{
headTimer += delta*3.0f;
walkLerp = Lerp(walkLerp, 1.0f, 10.0f*delta);
camera.fovy = Lerp(camera.fovy, 55.0f, 5.0f*delta);
}
else
{
walkLerp = Lerp(walkLerp, 0.0f, 10.0f*delta);
camera.fovy = Lerp(camera.fovy, 60.0f, 5.0f*delta);
}
lean.x = Lerp(lean.x, sideway*0.02f, 10.0f*delta);
lean.y = Lerp(lean.y, forward*0.015f, 10.0f*delta);
UpdateCameraFPS(&camera);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode3D(camera);
DrawLevel();
EndMode3D();
// Draw info box
DrawRectangle(5, 5, 330, 75, Fade(SKYBLUE, 0.5f));
DrawRectangleLines(5, 5, 330, 75, BLUE);
DrawText("Camera controls:", 15, 15, 10, BLACK);
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 10, BLACK);
DrawText("- Look around: arrow keys or mouse", 15, 45, 10, BLACK);
DrawText(TextFormat("- Velocity Len: (%06.3f)", Vector2Length((Vector2){ player.velocity.x, player.velocity.z })), 15, 60, 10, BLACK);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Update body considering current world state
void UpdateBody(Body *body, float rot, char side, char forward, bool jumpPressed, bool crouchHold)
{
Vector2 input = (Vector2){ (float)side, (float)-forward };
#if defined(NORMALIZE_INPUT)
// Slow down diagonal movement
if ((side != 0) && (forward != 0)) input = Vector2Normalize(input);
#endif
float delta = GetFrameTime();
if (!body->isGrounded) body->velocity.y -= GRAVITY*delta;
if (body->isGrounded && jumpPressed)
{
body->velocity.y = JUMP_FORCE;
body->isGrounded = false;
// Sound can be played at this moment
//SetSoundPitch(fxJump, 1.0f + (GetRandomValue(-100, 100)*0.001));
//PlaySound(fxJump);
}
Vector3 front = (Vector3){ sinf(rot), 0.f, cosf(rot) };
Vector3 right = (Vector3){ cosf(-rot), 0.f, sinf(-rot) };
Vector3 desiredDir = (Vector3){ input.x*right.x + input.y*front.x, 0.0f, input.x*right.z + input.y*front.z, };
body->dir = Vector3Lerp(body->dir, desiredDir, CONTROL*delta);
float decel = (body->isGrounded ? FRICTION : AIR_DRAG);
Vector3 hvel = (Vector3){ body->velocity.x*decel, 0.0f, body->velocity.z*decel };
float hvelLength = Vector3Length(hvel); // Magnitude
if (hvelLength < (MAX_SPEED*0.01f)) hvel = (Vector3){ 0 };
// This is what creates strafing
float speed = Vector3DotProduct(hvel, body->dir);
// Whenever the amount of acceleration to add is clamped by the maximum acceleration constant,
// a Player can make the speed faster by bringing the direction closer to horizontal velocity angle
// More info here: https://youtu.be/v3zT3Z5apaM?t=165
float maxSpeed = (crouchHold? CROUCH_SPEED : MAX_SPEED);
float accel = Clamp(maxSpeed - speed, 0.f, MAX_ACCEL*delta);
hvel.x += body->dir.x*accel;
hvel.z += body->dir.z*accel;
body->velocity.x = hvel.x;
body->velocity.z = hvel.z;
body->position.x += body->velocity.x*delta;
body->position.y += body->velocity.y*delta;
body->position.z += body->velocity.z*delta;
// Fancy collision system against the floor
if (body->position.y <= 0.0f)
{
body->position.y = 0.0f;
body->velocity.y = 0.0f;
body->isGrounded = true; // Enable jumping
}
}
// Update camera for FPS behaviour
static void UpdateCameraFPS(Camera *camera)
{
const Vector3 up = (Vector3){ 0.0f, 1.0f, 0.0f };
const Vector3 targetOffset = (Vector3){ 0.0f, 0.0f, -1.0f };
// Left and right
Vector3 yaw = Vector3RotateByAxisAngle(targetOffset, up, lookRotation.x);
// Clamp view up
float maxAngleUp = Vector3Angle(up, yaw);
maxAngleUp -= 0.001f; // Avoid numerical errors
if ( -(lookRotation.y) > maxAngleUp) { lookRotation.y = -maxAngleUp; }
// Clamp view down
float maxAngleDown = Vector3Angle(Vector3Negate(up), yaw);
maxAngleDown *= -1.0f; // Downwards angle is negative
maxAngleDown += 0.001f; // Avoid numerical errors
if ( -(lookRotation.y) < maxAngleDown) { lookRotation.y = -maxAngleDown; }
// Up and down
Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up));
// Rotate view vector around right axis
float pitchAngle = -lookRotation.y - lean.y;
pitchAngle = Clamp(pitchAngle, -PI/2 + 0.0001f, PI/2 - 0.0001f); // Clamp angle so it doesn't go past straight up or straight down
Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, pitchAngle);
// Head animation
// Rotate up direction around forward axis
float headSin = sinf(headTimer*PI);
float headCos = cosf(headTimer*PI);
const float stepRotation = 0.01f;
camera->up = Vector3RotateByAxisAngle(up, pitch, headSin*stepRotation + lean.x);
// Camera BOB
const float bobSide = 0.1f;
const float bobUp = 0.15f;
Vector3 bobbing = Vector3Scale(right, headSin*bobSide);
bobbing.y = fabsf(headCos*bobUp);
camera->position = Vector3Add(camera->position, Vector3Scale(bobbing, walkLerp));
camera->target = Vector3Add(camera->position, pitch);
}
// Draw game level
static void DrawLevel(void)
{
const int floorExtent = 25;
const float tileSize = 5.0f;
const Color tileColor1 = (Color){ 150, 200, 200, 255 };
// Floor tiles
for (int y = -floorExtent; y < floorExtent; y++)
{
for (int x = -floorExtent; x < floorExtent; x++)
{
if ((y & 1) && (x & 1))
{
DrawPlane((Vector3){ x*tileSize, 0.0f, y*tileSize}, (Vector2){ tileSize, tileSize }, tileColor1);
}
else if (!(y & 1) && !(x & 1))
{
DrawPlane((Vector3){ x*tileSize, 0.0f, y*tileSize}, (Vector2){ tileSize, tileSize }, LIGHTGRAY);
}
}
}
const Vector3 towerSize = (Vector3){ 16.0f, 32.0f, 16.0f };
const Color towerColor = (Color){ 150, 200, 200, 255 };
Vector3 towerPos = (Vector3){ 16.0f, 16.0f, 16.0f };
DrawCubeV(towerPos, towerSize, towerColor);
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
towerPos.x *= -1;
DrawCubeV(towerPos, towerSize, towerColor);
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
towerPos.z *= -1;
DrawCubeV(towerPos, towerSize, towerColor);
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
towerPos.x *= -1;
DrawCubeV(towerPos, towerSize, towerColor);
DrawCubeWiresV(towerPos, towerSize, DARKBLUE);
// Red sun
DrawSphere((Vector3){ 300.0f, 300.0f, 0.0f }, 100.0f, (Color){ 255, 0, 0, 255 });
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Initialize 3d camera free
* raylib [core] example - 3d camera free
*
* Example complexity rating: [★☆☆☆] 1/4
*
@ -49,7 +49,7 @@ int main(void)
//----------------------------------------------------------------------------------
UpdateCamera(&camera, CAMERA_FREE);
if (IsKeyPressed('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
if (IsKeyPressed(KEY_Z)) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
//----------------------------------------------------------------------------------
// Draw

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Initialize 3d camera mode
* raylib [core] example - 3d camera mode
*
* Example complexity rating: [★☆☆☆] 1/4
*

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - 3d cmaera split screen
* raylib [core] example - 3d camera split screen
*
* Example complexity rating: [★★★☆] 3/4
*
@ -47,11 +47,11 @@ int main(void)
cameraPlayer2.position.x = -3.0f;
cameraPlayer2.position.y = 3.0f;
RenderTexture screenPlayer2 = LoadRenderTexture(screenWidth / 2, screenHeight);
RenderTexture screenPlayer2 = LoadRenderTexture(screenWidth/2, screenHeight);
// Build a flipped rectangle the size of the split view to use for drawing later
Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenPlayer1.texture.width, (float)-screenPlayer1.texture.height };
// Grid data
int count = 5;
float spacing = 4;
@ -98,9 +98,9 @@ int main(void)
// Draw Player1 view to the render texture
BeginTextureMode(screenPlayer1);
ClearBackground(SKYBLUE);
BeginMode3D(cameraPlayer1);
// Draw scene: grid of cube trees on a plane to make a "world"
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane
@ -116,20 +116,20 @@ int main(void)
// Draw a cube at each player's position
DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
EndMode3D();
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
DrawText("PLAYER1: W/S to move", 10, 10, 20, MAROON);
EndTextureMode();
// Draw Player2 view to the render texture
BeginTextureMode(screenPlayer2);
ClearBackground(SKYBLUE);
BeginMode3D(cameraPlayer2);
// Draw scene: grid of cube trees on a plane to make a "world"
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane
@ -145,21 +145,21 @@ int main(void)
// Draw a cube at each player's position
DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
EndMode3D();
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
DrawText("PLAYER2: UP/DOWN to move", 10, 10, 20, DARKBLUE);
EndTextureMode();
// Draw both views render textures to the screen side by side
BeginDrawing();
ClearBackground(BLACK);
DrawTextureRec(screenPlayer1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
DrawTextureRec(screenPlayer2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
EndDrawing();
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Picking in 3d mode
* raylib [core] example - 3d picking
*
* Example complexity rating: [★★☆☆] 2/4
*
@ -101,7 +101,7 @@ int main(void)
DrawText("Try clicking on the box with your mouse!", 240, 10, 20, DARKGRAY);
if (collision.hit) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN);
if (collision.hit) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30))/2, (int)(screenHeight*0.1f), 30, GREEN);
DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY);

View File

@ -24,6 +24,9 @@
#define MAX_ENVIRONMENT_ELEMENTS 5
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef struct Player {
Vector2 position;
float speed;
@ -36,7 +39,6 @@ typedef struct EnvElement {
Color color;
} EnvElement;
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
@ -54,7 +56,7 @@ int main(void)
player.position = (Vector2){ 400, 280 };
player.speed = 0;
player.canJump = false;
// Define environment elements (platforms)
EnvElement envElements[MAX_ENVIRONMENT_ELEMENTS] = {
{{ 0, 0, 1000, 400 }, 0, LIGHTGRAY },
@ -70,13 +72,13 @@ int main(void)
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
camera.rotation = 0.0f;
camera.zoom = 1.0f;
// Automation events
AutomationEventList aelist = LoadAutomationEventList(0); // Initialize list of automation events to record new events
SetAutomationEventList(&aelist);
bool eventRecording = false;
bool eventPlaying = false;
unsigned int frameCounter = 0;
unsigned int playFrameCounter = 0;
unsigned int currentPlayFrame = 0;
@ -90,7 +92,7 @@ int main(void)
// Update
//----------------------------------------------------------------------------------
float deltaTime = 0.015f;//GetFrameTime();
// Dropped files logic
//----------------------------------------------------------------------------------
if (IsFileDropped())
@ -102,14 +104,14 @@ int main(void)
{
UnloadAutomationEventList(aelist);
aelist = LoadAutomationEventList(droppedFiles.paths[0]);
eventRecording = false;
// Reset scene state to play
eventPlaying = true;
playFrameCounter = 0;
currentPlayFrame = 0;
player.position = (Vector2){ 400, 280 };
player.speed = 0;
player.canJump = false;
@ -174,7 +176,7 @@ int main(void)
//----------------------------------------------------------------------------------
// Events playing
// NOTE: Logic must be before Camera update because it depends on mouse-wheel value,
// NOTE: Logic must be before Camera update because it depends on mouse-wheel value,
// that can be set by the played event... but some other inputs could be affected
//----------------------------------------------------------------------------------
if (eventPlaying)
@ -228,7 +230,7 @@ int main(void)
if (min.x > 0) camera.offset.x = screenWidth/2 - min.x;
if (min.y > 0) camera.offset.y = screenHeight/2 - min.y;
//----------------------------------------------------------------------------------
// Events management
if (IsKeyPressed(KEY_S)) // Toggle events recording
{
@ -238,12 +240,12 @@ int main(void)
{
StopAutomationEventRecording();
eventRecording = false;
ExportAutomationEventList(aelist, "automation.rae");
TraceLog(LOG_INFO, "RECORDED FRAMES: %i", aelist.count);
}
else
else
{
SetAutomationEventBaseFrame(180);
StartAutomationEventRecording();
@ -293,7 +295,7 @@ int main(void)
DrawRectangleRec((Rectangle){ player.position.x - 20, player.position.y - 40, 40, 40 }, RED);
EndMode2D();
// Draw game controls
DrawRectangle(10, 10, 290, 145, Fade(SKYBLUE, 0.5f));
DrawRectangleLines(10, 10, 290, 145, Fade(BLUE, 0.8f));
@ -323,7 +325,7 @@ int main(void)
if (((frameCounter/15)%2) == 1) DrawText(TextFormat("PLAYING RECORDED EVENTS... [%i]", currentPlayFrame), 50, 170, 10, DARKGREEN);
}
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] examples - basic screen manager
* raylib [core] example - basic screen manager
*
* Example complexity rating: [★☆☆☆] 1/4
*

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Basic window
* raylib [core] example - basic window
*
* Example complexity rating: [★☆☆☆] 1/4
*

View File

@ -0,0 +1,164 @@
/*******************************************************************************************
*
* raylib [core] example - clipboard text
*
* Example complexity rating: [★★☆☆] 2/4
*
* Example originally created with raylib 5.6-dev, last time updated with raylib 5.6-dev
*
* Example contributed by Ananth S (@Ananth1839) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025 Ananth S (@Ananth1839)
*
********************************************************************************************/
#include "raylib.h"
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
#define MAX_TEXT_SAMPLES 5
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - clipboard text");
// Define some sample texts
const char *sampleTexts[MAX_TEXT_SAMPLES] = {
"Hello from raylib!",
"The quick brown fox jumps over the lazy dog",
"Clipboard operations are useful!",
"raylib is a simple and easy-to-use library",
"Copy and paste me!"
};
const char *clipboardText = NULL;
char inputBuffer[256] = "Hello from raylib!"; // Random initial string
// UI required variables
bool textBoxEditMode = false;
bool btnCutPressed = false;
bool btnCopyPressed = false;
bool btnPastePressed = false;
bool btnClearPressed = false;
bool btnRandomPressed = false;
// Set UI style
GuiSetStyle(DEFAULT, TEXT_SIZE, 20);
GuiSetIconScale(2);
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
//----------------------------------------------------------------------------------
// Handle button interactions
if (btnCutPressed)
{
SetClipboardText(inputBuffer);
clipboardText = GetClipboardText();
inputBuffer[0] = '\0'; // Quick solution to clear text
//memset(inputBuffer, 0, 256); // Clear full buffer properly
}
if (btnCopyPressed)
{
SetClipboardText(inputBuffer); // Copy text to clipboard
clipboardText = GetClipboardText(); // Get text from clipboard
}
if (btnPastePressed)
{
// Paste text from clipboard
clipboardText = GetClipboardText();
if (clipboardText != NULL) TextCopy(inputBuffer, clipboardText);
}
if (btnClearPressed)
{
inputBuffer[0] = '\0'; // Quick solution to clear text
//memset(inputBuffer, 0, 256); // Clear full buffer properly
}
if (btnRandomPressed)
{
// Get random text from sample list
TextCopy(inputBuffer, sampleTexts[GetRandomValue(0, MAX_TEXT_SAMPLES - 1)]);
}
// Quick cut/copy/paste with keyboard shortcuts
if (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL))
{
if (IsKeyPressed(KEY_X))
{
SetClipboardText(inputBuffer);
inputBuffer[0] = '\0'; // Quick solution to clear text
}
if (IsKeyPressed(KEY_C)) SetClipboardText(inputBuffer);
if (IsKeyPressed(KEY_V))
{
clipboardText = GetClipboardText();
if (clipboardText != NULL) TextCopy(inputBuffer, clipboardText);
}
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw instructions
GuiLabel((Rectangle){ 50, 20, 700, 36 }, "Use the BUTTONS or KEY SHORTCUTS:");
DrawText("[CTRL+X] - CUT | [CTRL+C] COPY | [CTRL+V] | PASTE", 50, 60, 20, MAROON);
// Draw text box
if (GuiTextBox((Rectangle){ 50, 120, 652, 40 }, inputBuffer, 256, textBoxEditMode)) textBoxEditMode = !textBoxEditMode;
// Random text button
btnRandomPressed = GuiButton((Rectangle){ 50 + 652 + 8, 120, 40, 40 }, "#77#");
// Draw buttons
btnCutPressed = GuiButton((Rectangle){ 50, 180, 158, 40 }, "#17#CUT");
btnCopyPressed = GuiButton((Rectangle){ 50 + 165, 180, 158, 40 }, "#16#COPY");
btnPastePressed = GuiButton((Rectangle){ 50 + 165*2, 180, 158, 40 }, "#18#PASTE");
btnClearPressed = GuiButton((Rectangle){ 50 + 165*3, 180, 158, 40 }, "#143#CLEAR");
// Draw clipboard status
GuiSetState(STATE_DISABLED);
GuiLabel((Rectangle){ 50, 260, 700, 40 }, "Clipboard current text data:");
GuiSetStyle(TEXTBOX, TEXT_READONLY, 1);
GuiTextBox((Rectangle){ 50, 300, 700, 40 }, (char *)clipboardText, 256, false);
GuiSetStyle(TEXTBOX, TEXT_READONLY, 0);
GuiLabel((Rectangle){ 50, 360, 700, 40 }, "Try copying text from other applications and pasting here!");
GuiSetState(STATE_NORMAL);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,143 @@
/*******************************************************************************************
*
* raylib [core] example - compute hash
*
* Example complexity rating: [★★☆☆] 2/4
*
* Example originally created with raylib 5.6-dev, last time updated with raylib 5.6-dev
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
static char *GetDataAsHexText(const unsigned int *data, int dataSize);
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - compute hash");
// UI controls variables
char textInput[96] = "The quick brown fox jumps over the lazy dog.";
bool textBoxEditMode = false;
bool btnComputeHashes = false;
// Data hash values
unsigned int hashCRC32 = 0;
unsigned int *hashMD5 = NULL;
unsigned int *hashSHA1 = NULL;
unsigned int *hashSHA256 = NULL;
// Base64 encoded data
char *base64Text = NULL;
int base64TextSize = 0;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (btnComputeHashes)
{
int textInputLen = strlen(textInput);
// Encode data to Base64 string (includes NULL terminator), memory must be MemFree()
base64Text = EncodeDataBase64((unsigned char *)textInput, textInputLen, &base64TextSize);
hashCRC32 = ComputeCRC32((unsigned char *)textInput, textInputLen); // Compute CRC32 hash code (4 bytes)
hashMD5 = ComputeMD5((unsigned char *)textInput, textInputLen); // Compute MD5 hash code, returns static int[4] (16 bytes)
hashSHA1 = ComputeSHA1((unsigned char *)textInput, textInputLen); // Compute SHA1 hash code, returns static int[5] (20 bytes)
hashSHA256 = ComputeSHA256((unsigned char *)textInput, textInputLen); // Compute SHA256 hash code, returns static int[8] (32 bytes)
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
GuiSetStyle(DEFAULT, TEXT_SIZE, 20);
GuiSetStyle(DEFAULT, TEXT_SPACING, 2);
GuiLabel((Rectangle){ 40, 26, 720, 32 }, "INPUT DATA (TEXT):");
GuiSetStyle(DEFAULT, TEXT_SPACING, 1);
GuiSetStyle(DEFAULT, TEXT_SIZE, 10);
if (GuiTextBox((Rectangle){ 40, 64, 720, 32 }, textInput, 95, textBoxEditMode)) textBoxEditMode = !textBoxEditMode;
btnComputeHashes = GuiButton((Rectangle){ 40, 64 + 40, 720, 32 }, "COMPUTE INPUT DATA HASHES");
GuiSetStyle(DEFAULT, TEXT_SIZE, 20);
GuiSetStyle(DEFAULT, TEXT_SPACING, 2);
GuiLabel((Rectangle){ 40, 160, 720, 32 }, "INPUT DATA HASH VALUES:");
GuiSetStyle(DEFAULT, TEXT_SPACING, 1);
GuiSetStyle(DEFAULT, TEXT_SIZE, 10);
GuiSetStyle(TEXTBOX, TEXT_READONLY, 1);
GuiLabel((Rectangle){ 40, 200, 120, 32 }, "CRC32 [32 bit]:");
GuiTextBox((Rectangle){ 40 + 120, 200, 720 - 120, 32 }, GetDataAsHexText(&hashCRC32, 1), 120, false);
GuiLabel((Rectangle){ 40, 200 + 36, 120, 32 }, "MD5 [128 bit]:");
GuiTextBox((Rectangle){ 40 + 120, 200 + 36, 720 - 120, 32 }, GetDataAsHexText(hashMD5, 4), 120, false);
GuiLabel((Rectangle){ 40, 200 + 36*2, 120, 32 }, "SHA1 [160 bit]:");
GuiTextBox((Rectangle){ 40 + 120, 200 + 36*2, 720 - 120, 32 }, GetDataAsHexText(hashSHA1, 5), 120, false);
GuiLabel((Rectangle){ 40, 200 + 36*3, 120, 32 }, "SHA256 [256 bit]:");
GuiTextBox((Rectangle){ 40 + 120, 200 + 36*3, 720 - 120, 32 }, GetDataAsHexText(hashSHA256, 8), 120, false);
GuiSetState(STATE_FOCUSED);
GuiLabel((Rectangle){ 40, 200 + 36*5 - 30, 320, 32 }, "BONUS - BAS64 ENCODED STRING:");
GuiSetState(STATE_NORMAL);
GuiLabel((Rectangle){ 40, 200 + 36*5, 120, 32 }, "BASE64 ENCODING:");
GuiTextBox((Rectangle){ 40 + 120, 200 + 36*5, 720 - 120, 32 }, base64Text, 120, false);
GuiSetStyle(TEXTBOX, TEXT_READONLY, 0);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
MemFree(base64Text); // Free Base64 text data
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
static char *GetDataAsHexText(const unsigned int *data, int dataSize)
{
static char text[128] = { 0 };
memset(text, 0, 128);
if ((data != NULL) && (dataSize > 0) && (dataSize < ((128/8) - 1)))
{
for (int i = 0; i < dataSize; i++) TextCopy(text + i*8, TextFormat("%08X", data[i]));
}
else TextCopy(text, "00000000");
return text;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -12,7 +12,7 @@
* 4. PollInputEvents()
*
* To avoid steps 2, 3 and 4, flag SUPPORT_CUSTOM_FRAME_CONTROL can be enabled in
* config.h (it requires recompiling raylib). This way those steps are up to the user.
* config.h (it requires recompiling raylib). This way those steps are up to the user
*
* Note that enabling this flag invalidates some functions:
* - GetFrameTime()
@ -39,7 +39,7 @@ int main(void)
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom frame control");
// Custom timming variables
@ -48,11 +48,11 @@ int main(void)
double updateDrawTime = 0.0; // Update + Draw time
double waitTime = 0.0; // Wait time (if target fps required)
float deltaTime = 0.0f; // Frame time (Update + Draw + Wait time)
float timeCounter = 0.0f; // Accumulative time counter (seconds)
float position = 0.0f; // Circle position
bool pause = false; // Pause control flag
int targetFPS = 60; // Our initial target fps
//--------------------------------------------------------------------------------------
@ -61,13 +61,15 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL)
#ifndef PLATFORM_WEB // NOTE: On non web platforms the PollInputEvents just works before the inputs checks
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL)
#endif
if (IsKeyPressed(KEY_SPACE)) pause = !pause;
if (IsKeyPressed(KEY_UP)) targetFPS += 20;
else if (IsKeyPressed(KEY_DOWN)) targetFPS -= 20;
if (targetFPS < 0) targetFPS = 0;
if (!pause)
@ -76,6 +78,10 @@ int main(void)
if (position >= GetScreenWidth()) position = 0;
timeCounter += deltaTime; // We count time (seconds)
}
#ifdef PLATFORM_WEB // NOTE: On web platform for some reason the PollInputEvents only works after the inputs check, so just call it after check all your inputs (on web)
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL)
#endif
//----------------------------------------------------------------------------------
// Draw
@ -85,12 +91,12 @@ int main(void)
ClearBackground(RAYWHITE);
for (int i = 0; i < GetScreenWidth()/200; i++) DrawRectangle(200*i, 0, 1, GetScreenHeight(), SKYBLUE);
DrawCircle((int)position, GetScreenHeight()/2 - 25, 50, RED);
DrawText(TextFormat("%03.0f ms", timeCounter*1000.0f), (int)position - 40, GetScreenHeight()/2 - 100, 20, MAROON);
DrawText(TextFormat("PosX: %03.0f", position), (int)position - 50, GetScreenHeight()/2 + 40, 20, BLACK);
DrawText("Circle is moving at a constant 200 pixels/sec,\nindependently of the frame rate.", 10, 10, 20, DARKGRAY);
DrawText("PRESS SPACE to PAUSE MOVEMENT", 10, GetScreenHeight() - 60, 20, GRAY);
DrawText("PRESS UP | DOWN to CHANGE TARGET FPS", 10, GetScreenHeight() - 30, 20, GRAY);
@ -102,18 +108,18 @@ int main(void)
EndDrawing();
// NOTE: In case raylib is configured to SUPPORT_CUSTOM_FRAME_CONTROL,
// NOTE: In case raylib is configured to SUPPORT_CUSTOM_FRAME_CONTROL,
// Events polling, screen buffer swap and frame time control must be managed by the user
SwapScreenBuffer(); // Flip the back buffer to screen (front buffer)
currentTime = GetTime();
updateDrawTime = currentTime - previousTime;
if (targetFPS > 0) // We want a fixed frame rate
{
waitTime = (1.0f/(float)targetFPS) - updateDrawTime;
if (waitTime > 0.0)
if (waitTime > 0.0)
{
WaitTime((float)waitTime);
currentTime = GetTime();

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Custom logging
* raylib [core] example - custom logging
*
* Example complexity rating: [★★★☆] 3/4
*
@ -17,11 +17,11 @@
#include "raylib.h"
#include <stdio.h> // Required for: fopen(), fclose(), fputc(), fwrite(), printf(), fprintf(), funopen()
#include <time.h> // Required for: time_t, tm, time(), localtime(), strftime()
#include <stdio.h> // Required for: printf(), vprintf(), fprintf()
#include <time.h> // Required for: time_t, tm, time(), localtime(), strftime()
// Custom logging function
void CustomLog(int msgType, const char *text, va_list args)
void CustomTraceLog(int msgType, const char *text, va_list args)
{
char timeStr[64] = { 0 };
time_t now = time(NULL);
@ -54,7 +54,7 @@ int main(void)
const int screenHeight = 450;
// Set custom logger
SetTraceLogCallback(CustomLog);
SetTraceLogCallback(CustomTraceLog);
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging");

View File

@ -0,0 +1,112 @@
/*******************************************************************************************
*
* raylib [core] example - delta time
*
* Example complexity rating: [★☆☆☆] 1/4
*
* Example originally created with raylib 5.5, last time updated with raylib 5.6-dev
*
* Example contributed by Robin (@RobinsAviary) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025 Robin (@RobinsAviary)
*
********************************************************************************************/
#include "raylib.h"
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - delta time");
int currentFps = 60;
// Store the position for the both of the circles
Vector2 deltaCircle = { 0, (float)screenHeight/3.0f };
Vector2 frameCircle = { 0, (float)screenHeight*(2.0f/3.0f) };
// The speed applied to both circles
const float speed = 10.0f;
const float circleRadius = 32.0f;
SetTargetFPS(currentFps);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// Adjust the FPS target based on the mouse wheel
float mouseWheel = GetMouseWheelMove();
if (mouseWheel != 0)
{
currentFps += (int)mouseWheel;
if (currentFps < 0) currentFps = 0;
SetTargetFPS(currentFps);
}
// GetFrameTime() returns the time it took to draw the last frame, in seconds (usually called delta time)
// Uses the delta time to make the circle look like it's moving at a "consistent" speed regardless of FPS
// Multiply by 6.0 (an arbitrary value) in order to make the speed
// visually closer to the other circle (at 60 fps), for comparison
deltaCircle.x += GetFrameTime()*6.0f*speed;
// This circle can move faster or slower visually depending on the FPS
frameCircle.x += 0.1f*speed;
// If either circle is off the screen, reset it back to the start
if (deltaCircle.x > screenWidth) deltaCircle.x = 0;
if (frameCircle.x > screenWidth) frameCircle.x = 0;
// Reset both circles positions
if (IsKeyPressed(KEY_R))
{
deltaCircle.x = 0;
frameCircle.x = 0;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw both circles to the screen
DrawCircleV(deltaCircle, circleRadius, RED);
DrawCircleV(frameCircle, circleRadius, BLUE);
// Draw the help text
// Determine what help text to show depending on the current FPS target
const char *fpsText = 0;
if (currentFps <= 0) fpsText = TextFormat("FPS: unlimited (%i)", GetFPS());
else fpsText = TextFormat("FPS: %i (target: %i)", GetFPS(), currentFps);
DrawText(fpsText, 10, 10, 20, DARKGRAY);
DrawText(TextFormat("Frame time: %02.02f ms", GetFrameTime()), 10, 30, 20, DARKGRAY);
DrawText("Use the scroll wheel to change the fps limit, r to reset", 10, 50, 20, DARKGRAY);
// Draw the text above the circles
DrawText("FUNC: x += GetFrameTime()*speed", 10, 90, 20, RED);
DrawText("FUNC: x += speed", 10, 240, 20, BLUE);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,100 @@
/*******************************************************************************************
*
* raylib [core] example - directory files
*
* Example complexity rating: [★☆☆☆] 1/4
*
* Example originally created with raylib 5.5, last time updated with raylib 5.6
*
* Example contributed by Hugo ARNAL (@hugoarnal) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025 Hugo ARNAL (@hugoarnal)
*
********************************************************************************************/
#include "raylib.h"
#define RAYGUI_IMPLEMENTATION
#include "raygui.h" // Required for GUI controls
#define MAX_FILEPATH_SIZE 1024
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - directory files");
char directory[MAX_FILEPATH_SIZE] = { 0 };
strcpy(directory, GetWorkingDirectory());
FilePathList files = LoadDirectoryFiles(directory);
int btnBackPressed = false;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (btnBackPressed)
{
TextCopy(directory, GetPrevDirectoryPath(directory));
UnloadDirectoryFiles(files);
files = LoadDirectoryFiles(directory);
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText(directory, 100, 40, 20, DARKGRAY);
btnBackPressed = GuiButton((Rectangle){ 40.0f, 38.0f, 48, 24 }, "<");
for (int i = 0; i < (int)files.count; i++)
{
Color color = Fade(LIGHTGRAY, 0.3f);
if (!IsPathFile(files.paths[i]) && DirectoryExists(files.paths[i]))
{
if (GuiButton((Rectangle){0.0f, 85.0f + 40.0f*(float)i, screenWidth, 40}, ""))
{
TextCopy(directory, files.paths[i]);
UnloadDirectoryFiles(files);
files = LoadDirectoryFiles(directory);
continue;
}
}
DrawRectangle(0, 85 + 40*i, screenWidth, 40, color);
DrawText(GetFileName(files.paths[i]), 120, 100 + 40*i, 10, GRAY);
}
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadDirectoryFiles(files);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Windows drop files
* raylib [core] example - drop files
*
* Example complexity rating: [★★☆☆] 2/4
*

View File

@ -1,24 +1,26 @@
/*******************************************************************************************
*
* raylib [core] example - HighDPI
* raylib [core] example - highdpi demo
*
* Example complexity rating: [] e/4
* Example complexity rating: [] 2/4
*
* Example originally created with raylib 5.0, last time updated with raylib 5.5
*
* Example contributed by Jonathan Marler (@marler8997) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5)
* Copyright (c) 2025 Jonathan Marler (@marler8997)
*
********************************************************************************************/
#include "raylib.h"
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color)
{
Vector2 size = MeasureTextEx(GetFontDefault(), text, (float)fontSize, 3);
Vector2 pos = (Vector2){x - size.x/2, y - size.y/2 };
DrawTextEx(GetFontDefault(), text, pos, (float)fontSize, 3, color);
}
//------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color);
//------------------------------------------------------------------------------------
// Program main entry point
@ -31,10 +33,20 @@ int main(void)
const int screenHeight = 450;
SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE);
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi");
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi demo");
SetWindowMinSize(450, 450);
int logicalGridDescY = 120;
int logicalGridLabelY = logicalGridDescY + 30;
int logicalGridTop = logicalGridLabelY + 30;
int logicalGridBottom = logicalGridTop + 80;
int pixelGridTop = logicalGridBottom - 20;
int pixelGridBottom = pixelGridTop + 80;
int pixelGridLabelY = pixelGridBottom + 30;
int pixelGridDescY = pixelGridLabelY + 30;
int cellSize = 50;
float cellSizePx = (float)cellSize;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -44,67 +56,60 @@ int main(void)
// Update
//----------------------------------------------------------------------------------
int monitorCount = GetMonitorCount();
if (monitorCount > 1 && IsKeyPressed(KEY_N)) {
SetWindowMonitor((GetCurrentMonitor() + 1) % monitorCount);
if ((monitorCount > 1) && IsKeyPressed(KEY_N))
{
SetWindowMonitor((GetCurrentMonitor() + 1)%monitorCount);
}
int currentMonitor = GetCurrentMonitor();
Vector2 dpiScale = GetWindowScaleDPI();
cellSizePx = ((float)cellSize)/dpiScale.x;
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
Vector2 dpiScale = GetWindowScaleDPI();
ClearBackground(RAYWHITE);
int windowCenter = GetScreenWidth() / 2;
int windowCenter = GetScreenWidth()/2;
DrawTextCenter(TextFormat("Dpi Scale: %f", dpiScale.x), windowCenter, 30, 40, DARKGRAY);
DrawTextCenter(TextFormat("Monitor: %d/%d ([N] next monitor)", currentMonitor+1, monitorCount), windowCenter, 70, 16, LIGHTGRAY);
const int logicalGridDescY = 120;
const int logicalGridLabelY = logicalGridDescY + 30;
const int logicalGridTop = logicalGridLabelY + 30;
const int logicalGridBottom = logicalGridTop + 80;
const int pixelGridTop = logicalGridBottom - 20;
const int pixelGridBottom = pixelGridTop + 80;
const int pixelGridLabelY = pixelGridBottom + 30;
const int pixelGridDescY = pixelGridLabelY + 30;
const int cellSize = 50;
const float cellSizePx = ((float)cellSize) / dpiScale.x;
DrawTextCenter(TextFormat("Monitor: %d/%d ([N] next monitor)", currentMonitor+1, monitorCount), windowCenter, 70, 20, LIGHTGRAY);
DrawTextCenter(TextFormat("Window is %d \"logical points\" wide", GetScreenWidth()), windowCenter, logicalGridDescY, 20, ORANGE);
bool odd = true;
for (int i = cellSize; i < GetScreenWidth(); i += cellSize, odd = !odd) {
if (odd) {
DrawRectangle(i, logicalGridTop, cellSize, logicalGridBottom-logicalGridTop, ORANGE);
}
DrawTextCenter(TextFormat("%d", i), i, logicalGridLabelY, 12, LIGHTGRAY);
for (int i = cellSize; i < GetScreenWidth(); i += cellSize, odd = !odd)
{
if (odd) DrawRectangle(i, logicalGridTop, cellSize, logicalGridBottom-logicalGridTop, ORANGE);
DrawTextCenter(TextFormat("%d", i), i, logicalGridLabelY, 10, LIGHTGRAY);
DrawLine(i, logicalGridLabelY + 10, i, logicalGridBottom, GRAY);
}
odd = true;
const int minTextSpace = 30;
int last_text_x = -minTextSpace;
for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd) {
int x = (int)(((float)i) / dpiScale.x);
if (odd) {
DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom-pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
}
DrawLine(x, pixelGridTop, (int)(((float)i) / dpiScale.x), pixelGridLabelY - 10, GRAY);
if (x - last_text_x >= minTextSpace) {
DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 12, LIGHTGRAY);
last_text_x = x;
int lastTextX = -minTextSpace;
for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd)
{
int x = (int)(((float)i)/dpiScale.x);
if (odd) DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom - pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
DrawLine(x, pixelGridTop, (int)(((float)i)/dpiScale.x), pixelGridLabelY - 10, GRAY);
if ((x - lastTextX) >= minTextSpace)
{
DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 10, LIGHTGRAY);
lastTextX = x;
}
}
DrawTextCenter(TextFormat("Window is %d \"physical pixels\" wide", GetRenderWidth()), windowCenter, pixelGridDescY, 20, BLUE);
{
const char *text = "Can you see this?";
Vector2 size = MeasureTextEx(GetFontDefault(), text, 16, 3);
Vector2 pos = (Vector2){GetScreenWidth() - size.x - 5, GetScreenHeight() - size.y - 5};
DrawTextEx(GetFontDefault(), text, pos, 16, 3, LIGHTGRAY);
}
const char *text = "Can you see this?";
Vector2 size = MeasureTextEx(GetFontDefault(), text, 20, 3);
Vector2 pos = (Vector2){ GetScreenWidth() - size.x - 5, GetScreenHeight() - size.y - 5 };
DrawTextEx(GetFontDefault(), text, pos, 20, 3, LIGHTGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
@ -117,3 +122,13 @@ int main(void)
return 0;
}
//------------------------------------------------------------------------------------
// Module Functions Definition
//------------------------------------------------------------------------------------
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color)
{
Vector2 size = MeasureTextEx(GetFontDefault(), text, (float)fontSize, 3);
Vector2 pos = (Vector2){ x - size.x/2, y - size.y/2 };
DrawTextEx(GetFontDefault(), text, pos, (float)fontSize, 3, color);
}

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -0,0 +1,99 @@
/*******************************************************************************************
*
* raylib [core] example - highdpi testbed
*
* Example complexity rating: [★☆☆☆] 1/4
*
* Example originally created with raylib 5.6-dev, last time updated with raylib 5.6-dev
*
* Example contributed by Ramon Santamaria (@raysan5) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI);
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi testbed");
Vector2 scaleDpi = GetWindowScaleDPI();
Vector2 mousePos = GetMousePosition();
int currentMonitor = GetCurrentMonitor();
int gridSpacing = 40; // Grid spacing in pixels
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
mousePos = GetMousePosition();
currentMonitor = GetCurrentMonitor();
scaleDpi = GetWindowScaleDPI();
if (IsKeyPressed(KEY_SPACE)) ToggleBorderlessWindowed();
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw grid
for (int h = 0; h < 20; h++)
{
DrawText(TextFormat("%02i", h*gridSpacing), 4, h*gridSpacing - 4, 10, GRAY);
DrawLine(24, h*gridSpacing, GetScreenWidth(), h*gridSpacing, LIGHTGRAY);
}
for (int v = 0; v < 40; v++)
{
DrawText(TextFormat("%02i", v*gridSpacing), v*gridSpacing - 10, 4, 10, GRAY);
DrawLine(v*gridSpacing, 20, v*gridSpacing, GetScreenHeight(), LIGHTGRAY);
}
// Draw UI info
DrawText(TextFormat("CURRENT MONITOR: %i/%i (%ix%i)", currentMonitor + 1, GetMonitorCount(),
GetMonitorWidth(currentMonitor), GetMonitorHeight(currentMonitor)), 50, 50, 20, DARKGRAY);
DrawText(TextFormat("SCREEN SIZE: %ix%i", GetScreenWidth(), GetScreenHeight()), 50, 90, 20, DARKGRAY);
DrawText(TextFormat("RENDER SIZE: %ix%i", GetRenderWidth(), GetRenderHeight()), 50, 130, 20, DARKGRAY);
DrawText(TextFormat("SCALE FACTOR: %.1fx%.1f", scaleDpi.x, scaleDpi.y), 50, 170, 20, GRAY);
// Draw mouse position
DrawCircleV(GetMousePosition(), 20, MAROON);
DrawRectangle(mousePos.x - 25, mousePos.y, 50, 2, BLACK);
DrawRectangle(mousePos.x, mousePos.y - 25, 2, 50, BLACK);
DrawText(TextFormat("[%i,%i]", GetMouseX(), GetMouseY()), mousePos.x - 44,
(mousePos.y > GetScreenHeight() - 60)? mousePos.y - 46 : mousePos.y + 30, 20, BLACK);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
// TODO: Unload all loaded resources at this point
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,203 @@
/*******************************************************************************************
*
* raylib [core] example - input actions
*
* Example complexity rating: [★★☆☆] 2/4
*
* Example originally created with raylib 5.5, last time updated with raylib 5.6
*
* Example contributed by Jett (@JettMonstersGoBoom) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025 Jett (@JettMonstersGoBoom)
*
********************************************************************************************/
// Simple example for decoding input as actions, allowing remapping of input to different keys or gamepad buttons
// For example instead of using `IsKeyDown(KEY_LEFT)`, you can use `IsActionDown(ACTION_LEFT)`
// which can be reassigned to e.g. KEY_A and also assigned to a gamepad button. the action will trigger with either gamepad or keys
#include "raylib.h"
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef enum ActionType {
NO_ACTION = 0,
ACTION_UP,
ACTION_DOWN,
ACTION_LEFT,
ACTION_RIGHT,
ACTION_FIRE,
MAX_ACTION
} ActionType;
// Key and button inputs
typedef struct ActionInput {
int key;
int button;
} ActionInput;
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
static int gamepadIndex = 0; // Gamepad default index
static ActionInput actionInputs[MAX_ACTION] = { 0 };
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
static bool IsActionPressed(int action); // Check action key/button pressed
static bool IsActionReleased(int action); // Check action key/button released
static bool IsActionDown(int action); // Check action key/button down
static void SetActionsDefault(void); // Set the "default" keyset
static void SetActionsCursor(void); // Set the "alternate" keyset
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - input actions");
// Set default actions
char actionSet = 0;
SetActionsDefault();
bool releaseAction = false;
Vector2 position = (Vector2){ 400.0f, 200.0f };
Vector2 size = (Vector2){ 40.0f, 40.0f };
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
gamepadIndex = 0; // Set gamepad being checked
if (IsActionDown(ACTION_UP)) position.y -= 2;
if (IsActionDown(ACTION_DOWN)) position.y += 2;
if (IsActionDown(ACTION_LEFT)) position.x -= 2;
if (IsActionDown(ACTION_RIGHT)) position.x += 2;
if (IsActionPressed(ACTION_FIRE))
{
position.x = (screenWidth-size.x)/2;
position.y = (screenHeight-size.y)/2;
}
// Register release action for one frame
releaseAction = false;
if (IsActionReleased(ACTION_FIRE)) releaseAction = true;
// Switch control scheme by pressing TAB
if (IsKeyPressed(KEY_TAB))
{
actionSet = !actionSet;
if (actionSet == 0) SetActionsDefault();
else SetActionsCursor();
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(GRAY);
DrawRectangleV(position, size, releaseAction? BLUE : RED);
DrawText((actionSet == 0)? "Current input set: WASD (default)" : "Current input set: Cursor", 10, 10, 20, WHITE);
DrawText("Use TAB key to toggles Actions keyset", 10, 50, 20, GREEN);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Check action key/button pressed
// NOTE: Combines key pressed and gamepad button pressed in one action
static bool IsActionPressed(int action)
{
bool result = false;
if (action < MAX_ACTION) result = (IsKeyPressed(actionInputs[action].key) || IsGamepadButtonPressed(gamepadIndex, actionInputs[action].button));
return result;
}
// Check action key/button released
// NOTE: Combines key released and gamepad button released in one action
static bool IsActionReleased(int action)
{
bool result = false;
if (action < MAX_ACTION) result = (IsKeyReleased(actionInputs[action].key) || IsGamepadButtonReleased(gamepadIndex, actionInputs[action].button));
return result;
}
// Check action key/button down
// NOTE: Combines key down and gamepad button down in one action
static bool IsActionDown(int action)
{
bool result = false;
if (action < MAX_ACTION) result = (IsKeyDown(actionInputs[action].key) || IsGamepadButtonDown(gamepadIndex, actionInputs[action].button));
return result;
}
// Set the "default" keyset
// NOTE: Here WASD and gamepad buttons on the left side for movement
static void SetActionsDefault(void)
{
actionInputs[ACTION_UP].key = KEY_W;
actionInputs[ACTION_DOWN].key = KEY_S;
actionInputs[ACTION_LEFT].key = KEY_A;
actionInputs[ACTION_RIGHT].key = KEY_D;
actionInputs[ACTION_FIRE].key = KEY_SPACE;
actionInputs[ACTION_UP].button = GAMEPAD_BUTTON_LEFT_FACE_UP;
actionInputs[ACTION_DOWN].button = GAMEPAD_BUTTON_LEFT_FACE_DOWN;
actionInputs[ACTION_LEFT].button = GAMEPAD_BUTTON_LEFT_FACE_LEFT;
actionInputs[ACTION_RIGHT].button = GAMEPAD_BUTTON_LEFT_FACE_RIGHT;
actionInputs[ACTION_FIRE].button = GAMEPAD_BUTTON_RIGHT_FACE_DOWN;
}
// Set the "alternate" keyset
// NOTE: Here cursor keys and gamepad buttons on the right side for movement
static void SetActionsCursor(void)
{
actionInputs[ACTION_UP].key = KEY_UP;
actionInputs[ACTION_DOWN].key = KEY_DOWN;
actionInputs[ACTION_LEFT].key = KEY_LEFT;
actionInputs[ACTION_RIGHT].key = KEY_RIGHT;
actionInputs[ACTION_FIRE].key = KEY_SPACE;
actionInputs[ACTION_UP].button = GAMEPAD_BUTTON_RIGHT_FACE_UP;
actionInputs[ACTION_DOWN].button = GAMEPAD_BUTTON_RIGHT_FACE_DOWN;
actionInputs[ACTION_LEFT].button = GAMEPAD_BUTTON_RIGHT_FACE_LEFT;
actionInputs[ACTION_RIGHT].button = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT;
actionInputs[ACTION_FIRE].button = GAMEPAD_BUTTON_LEFT_FACE_DOWN;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Gamepad input
* raylib [core] example - input gamepad
*
* Example complexity rating: [★☆☆☆] 1/4
*
@ -38,7 +38,7 @@ int main(void)
SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
InitWindow(screenWidth, screenHeight, "raylib [core] example - input gamepad");
Texture2D texPs3Pad = LoadTexture("resources/ps3.png");
Texture2D texXboxPad = LoadTexture("resources/xbox.png");
@ -51,6 +51,8 @@ int main(void)
const float leftTriggerDeadzone = -0.9f;
const float rightTriggerDeadzone = -0.9f;
Rectangle vibrateButton = { 0 };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -61,7 +63,12 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
// ...
if (IsKeyPressed(KEY_LEFT) && gamepad > 0) gamepad--;
if (IsKeyPressed(KEY_RIGHT)) gamepad++;
Vector2 mousePosition = GetMousePosition();
vibrateButton = (Rectangle){ 10, 70 + 20*GetGamepadAxisCount(gamepad) + 20, 75, 24 };
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointRec(mousePosition, vibrateButton)) SetGamepadVibration(gamepad, 1.0, 1.0, 1.0);
//----------------------------------------------------------------------------------
// Draw
@ -70,9 +77,6 @@ int main(void)
ClearBackground(RAYWHITE);
if (IsKeyPressed(KEY_LEFT) && gamepad > 0) gamepad--;
if (IsKeyPressed(KEY_RIGHT)) gamepad++;
if (IsGamepadAvailable(gamepad))
{
DrawText(TextFormat("GP%d: %s", gamepad, GetGamepadName(gamepad)), 10, 10, 10, BLACK);
@ -93,7 +97,8 @@ int main(void)
if (leftTrigger < leftTriggerDeadzone) leftTrigger = -1.0f;
if (rightTrigger < rightTriggerDeadzone) rightTrigger = -1.0f;
if (TextFindIndex(TextToLower(GetGamepadName(gamepad)), XBOX_ALIAS_1) > -1 || TextFindIndex(TextToLower(GetGamepadName(gamepad)), XBOX_ALIAS_2) > -1)
if ((TextFindIndex(TextToLower(GetGamepadName(gamepad)), XBOX_ALIAS_1) > -1) ||
(TextFindIndex(TextToLower(GetGamepadName(gamepad)), XBOX_ALIAS_2) > -1))
{
DrawTexture(texXboxPad, 0, 0, DARKGRAY);
@ -125,16 +130,14 @@ int main(void)
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_THUMB)) leftGamepadColor = RED;
DrawCircle(259, 152, 39, BLACK);
DrawCircle(259, 152, 34, LIGHTGRAY);
DrawCircle(259 + (int)(leftStickX*20),
152 + (int)(leftStickY*20), 25, leftGamepadColor);
DrawCircle(259 + (int)(leftStickX*20), 152 + (int)(leftStickY*20), 25, leftGamepadColor);
// Draw axis: right joystick
Color rightGamepadColor = BLACK;
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_THUMB)) rightGamepadColor = RED;
DrawCircle(461, 237, 38, BLACK);
DrawCircle(461, 237, 33, LIGHTGRAY);
DrawCircle(461 + (int)(rightStickX*20),
237 + (int)(rightStickY*20), 25, rightGamepadColor);
DrawCircle(461 + (int)(rightStickX*20), 237 + (int)(rightStickY*20), 25, rightGamepadColor);
// Draw axis: left-right triggers
DrawRectangle(170, 30, 15, 70, GRAY);
@ -177,16 +180,14 @@ int main(void)
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_THUMB)) leftGamepadColor = RED;
DrawCircle(319, 255, 35, BLACK);
DrawCircle(319, 255, 31, LIGHTGRAY);
DrawCircle(319 + (int)(leftStickX*20),
255 + (int)(leftStickY*20), 25, leftGamepadColor);
DrawCircle(319 + (int)(leftStickX*20), 255 + (int)(leftStickY*20), 25, leftGamepadColor);
// Draw axis: right joystick
Color rightGamepadColor = BLACK;
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_THUMB)) rightGamepadColor = RED;
DrawCircle(475, 255, 35, BLACK);
DrawCircle(475, 255, 31, LIGHTGRAY);
DrawCircle(475 + (int)(rightStickX*20),
255 + (int)(rightStickY*20), 25, rightGamepadColor);
DrawCircle(475 + (int)(rightStickX*20), 255 + (int)(rightStickY*20), 25, rightGamepadColor);
// Draw axis: left-right triggers
DrawRectangle(169, 48, 15, 70, GRAY);
@ -196,7 +197,6 @@ int main(void)
}
else
{
// Draw background: generic
DrawRectangleRounded((Rectangle){ 175, 110, 460, 220}, 0.3f, 16, DARKGRAY);
@ -237,39 +237,39 @@ int main(void)
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_LEFT_THUMB)) leftGamepadColor = RED;
DrawCircle(345, 260, 40, BLACK);
DrawCircle(345, 260, 35, LIGHTGRAY);
DrawCircle(345 + (int)(leftStickX*20),
260 + (int)(leftStickY*20), 25, leftGamepadColor);
DrawCircle(345 + (int)(leftStickX*20), 260 + (int)(leftStickY*20), 25, leftGamepadColor);
// Draw axis: right joystick
Color rightGamepadColor = BLACK;
if (IsGamepadButtonDown(gamepad, GAMEPAD_BUTTON_RIGHT_THUMB)) rightGamepadColor = RED;
DrawCircle(465, 260, 40, BLACK);
DrawCircle(465, 260, 35, LIGHTGRAY);
DrawCircle(465 + (int)(rightStickX*20),
260 + (int)(rightStickY*20), 25, rightGamepadColor);
DrawCircle(465 + (int)(rightStickX*20), 260 + (int)(rightStickY*20), 25, rightGamepadColor);
// Draw axis: left-right triggers
DrawRectangle(151, 110, 15, 70, GRAY);
DrawRectangle(644, 110, 15, 70, GRAY);
DrawRectangle(151, 110, 15, (int)(((1 + leftTrigger)/2)*70), RED);
DrawRectangle(644, 110, 15, (int)(((1 + rightTrigger)/2)*70), RED);
}
DrawText(TextFormat("DETECTED AXIS [%i]:", GetGamepadAxisCount(0)), 10, 50, 10, MAROON);
DrawText(TextFormat("DETECTED AXIS [%i]:", GetGamepadAxisCount(gamepad)), 10, 50, 10, MAROON);
for (int i = 0; i < GetGamepadAxisCount(0); i++)
for (int i = 0; i < GetGamepadAxisCount(gamepad); i++)
{
DrawText(TextFormat("AXIS %i: %.02f", i, GetGamepadAxisMovement(0, i)), 20, 70 + 20*i, 10, DARKGRAY);
DrawText(TextFormat("AXIS %i: %.02f", i, GetGamepadAxisMovement(gamepad, i)), 20, 70 + 20*i, 10, DARKGRAY);
}
// Draw vibrate button
DrawRectangleRec(vibrateButton, SKYBLUE);
DrawText("VIBRATE", vibrateButton.x + 14, vibrateButton.y + 1, 10, DARKGRAY);
if (GetGamepadButtonPressed() != GAMEPAD_BUTTON_UNKNOWN) DrawText(TextFormat("DETECTED BUTTON: %i", GetGamepadButtonPressed()), 10, 430, 10, RED);
else DrawText("DETECTED BUTTON: NONE", 10, 430, 10, GRAY);
}
else
{
DrawText(TextFormat("GP%d: NOT DETECTED", gamepad), 10, 10, 10, GRAY);
DrawTexture(texXboxPad, 0, 0, LIGHTGRAY);
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Input Gestures Detection
* raylib [core] example - input gestures
*
* Example complexity rating: [★★☆☆] 2/4
*
@ -118,4 +118,6 @@ int main(void)
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@ -0,0 +1,315 @@
/*******************************************************************************************
*
* raylib [core] example - input gestures testbed
*
* Example complexity rating: [★★★☆] 3/4
*
* Example originally created with raylib 5.0, last time updated with raylib 5.6-dev
*
* Example contributed by ubkp (@ubkp) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2023-2025 ubkp (@ubkp)
*
********************************************************************************************/
#include "raylib.h"
#include <math.h> // Required for the protractor angle graphic drawing
#define GESTURE_LOG_SIZE 20
#define MAX_TOUCH_COUNT 32
//------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
static char const *GetGestureName(int gesture); // Get text string for gesture value
static Color GetGestureColor(int gesture); // Get color for gesture value
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures testbed");
Vector2 messagePosition = { 160, 7 };
// Last gesture variables definitions
int lastGesture = 0;
Vector2 lastGesturePosition = { 165, 130 };
// Gesture log variables definitions
// NOTE: The gesture log uses an array (as an inverted circular queue) to store the performed gestures
char gestureLog[GESTURE_LOG_SIZE][12] = { "" };
// NOTE: The index for the inverted circular queue (moving from last to first direction, then looping around)
int gestureLogIndex = GESTURE_LOG_SIZE;
int previousGesture = 0;
// Log mode values:
// - 0 shows repeated events
// - 1 hides repeated events
// - 2 shows repeated events but hide hold events
// - 3 hides repeated events and hide hold events
int logMode = 1;
Color gestureColor = { 0, 0, 0, 255 };
Rectangle logButton1 = { 53, 7, 48, 26 };
Rectangle logButton2 = { 108, 7, 36, 26 };
Vector2 gestureLogPosition = { 10, 10 };
// Protractor variables definitions
float angleLength = 90.0f;
float currentAngleDegrees = 0.0f;
Vector2 finalVector = { 0.0f, 0.0f };
Vector2 protractorPosition = { 266.0f, 315.0f };
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
//--------------------------------------------------------------------------------------
// Handle common gestures data
int i, ii; // Iterators that will be reused by all for loops
const int currentGesture = GetGestureDetected();
const float currentDragDegrees = GetGestureDragAngle();
const float currentPitchDegrees = GetGesturePinchAngle();
const int touchCount = GetTouchPointCount();
// Handle last gesture
if ((currentGesture != 0) && (currentGesture != 4) && (currentGesture != previousGesture))
lastGesture = currentGesture; // Filter the meaningful gestures (1, 2, 8 to 512) for the display
// Handle gesture log
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
{
if (CheckCollisionPointRec(GetMousePosition(), logButton1))
{
switch (logMode)
{
case 3: logMode = 2; break;
case 2: logMode = 3; break;
case 1: logMode = 0; break;
default: logMode = 1; break;
}
}
else if (CheckCollisionPointRec(GetMousePosition(), logButton2))
{
switch (logMode)
{
case 3: logMode = 1; break;
case 2: logMode = 0; break;
case 1: logMode = 3; break;
default: logMode = 2; break;
}
}
}
int fillLog = 0; // Gate variable to be used to allow or not the gesture log to be filled
if (currentGesture !=0)
{
if (logMode == 3) // 3 hides repeated events and hide hold events
{
if (((currentGesture != 4) && (currentGesture != previousGesture)) || (currentGesture < 3)) fillLog = 1;
}
else if (logMode == 2) // 2 shows repeated events but hide hold events
{
if (currentGesture != 4) fillLog = 1;
}
else if (logMode == 1) // 1 hides repeated events
{
if (currentGesture != previousGesture) fillLog = 1;
}
else // 0 shows repeated events
{
fillLog = 1;
}
}
if (fillLog) // If one of the conditions from logMode was met, fill the gesture log
{
previousGesture = currentGesture;
gestureColor = GetGestureColor(currentGesture);
if (gestureLogIndex <= 0) gestureLogIndex = GESTURE_LOG_SIZE;
gestureLogIndex--;
// Copy the gesture respective name to the gesture log array
TextCopy(gestureLog[gestureLogIndex], GetGestureName(currentGesture));
}
// Handle protractor
if (currentGesture > 255) currentAngleDegrees = currentPitchDegrees; // Pinch In and Pinch Out
else if (currentGesture > 15) currentAngleDegrees = currentDragDegrees; // Swipe Right, Swipe Left, Swipe Up and Swipe Down
else if (currentGesture > 0) currentAngleDegrees = 0.0f; // Tap, Doubletap, Hold and Grab
float currentAngleRadians = ((currentAngleDegrees + 90.0f)*PI/180); // Convert the current angle to Radians
// Calculate the final vector for display
finalVector = (Vector2){ (angleLength*sinf(currentAngleRadians)) + protractorPosition.x,
(angleLength*cosf(currentAngleRadians)) + protractorPosition.y };
// Handle touch and mouse pointer points
Vector2 touchPosition[MAX_TOUCH_COUNT] = { 0 };
Vector2 mousePosition = { 0 };
if (currentGesture != GESTURE_NONE)
{
if (touchCount != 0)
{
for (i = 0; i < touchCount; i++) touchPosition[i] = GetTouchPosition(i); // Fill the touch positions
}
else mousePosition = GetMousePosition();
}
//--------------------------------------------------------------------------------------
// Draw
//--------------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw common elements
DrawText("*", (int)messagePosition.x + 5, (int)messagePosition.y + 5, 10, BLACK);
DrawText("Example optimized for Web/HTML5\non Smartphones with Touch Screen.", (int)messagePosition.x + 15, (int)messagePosition.y + 5, 10, BLACK);
DrawText("*", (int)messagePosition.x + 5, (int)messagePosition.y + 35, 10, BLACK);
DrawText("While running on Desktop Web Browsers,\ninspect and turn on Touch Emulation.", (int)messagePosition.x + 15, (int)messagePosition.y + 35, 10, BLACK);
// Draw last gesture
DrawText("Last gesture", (int)lastGesturePosition.x + 33, (int)lastGesturePosition.y - 47, 20, BLACK);
DrawText("Swipe Tap Pinch Touch", (int)lastGesturePosition.x + 17, (int)lastGesturePosition.y - 18, 10, BLACK);
DrawRectangle((int)lastGesturePosition.x + 20, (int)lastGesturePosition.y, 20, 20, lastGesture == GESTURE_SWIPE_UP ? RED : LIGHTGRAY);
DrawRectangle((int)lastGesturePosition.x, (int)lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_LEFT ? RED : LIGHTGRAY);
DrawRectangle((int)lastGesturePosition.x + 40, (int)lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_RIGHT ? RED : LIGHTGRAY);
DrawRectangle((int)lastGesturePosition.x + 20, (int)lastGesturePosition.y + 40, 20, 20, lastGesture == GESTURE_SWIPE_DOWN ? RED : LIGHTGRAY);
DrawCircle((int)lastGesturePosition.x + 80, (int)lastGesturePosition.y + 16, 10, lastGesture == GESTURE_TAP ? BLUE : LIGHTGRAY);
DrawRing( (Vector2){lastGesturePosition.x + 103, lastGesturePosition.y + 16}, 6.0f, 11.0f, 0.0f, 360.0f, 0, lastGesture == GESTURE_DRAG ? LIME : LIGHTGRAY);
DrawCircle((int)lastGesturePosition.x + 80, (int)lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
DrawCircle((int)lastGesturePosition.x + 103, (int)lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
DrawTriangle((Vector2){ lastGesturePosition.x + 122, lastGesturePosition.y + 16 }, (Vector2){ lastGesturePosition.x + 137, lastGesturePosition.y + 26 }, (Vector2){lastGesturePosition.x + 137, lastGesturePosition.y + 6 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
DrawTriangle((Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 6 }, (Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 26 }, (Vector2){ lastGesturePosition.x + 162, lastGesturePosition.y + 16 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
DrawTriangle((Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 33 }, (Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 140, lastGesturePosition.y + 43 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
DrawTriangle((Vector2){ lastGesturePosition.x + 144, lastGesturePosition.y + 43 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 33 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
for (i = 0; i < 4; i++) DrawCircle((int)lastGesturePosition.x + 180, (int)lastGesturePosition.y + 7 + i*15, 5, touchCount <= i? LIGHTGRAY : gestureColor);
// Draw gesture log
DrawText("Log", (int)gestureLogPosition.x, (int)gestureLogPosition.y, 20, BLACK);
// Loop in both directions to print the gesture log array in the inverted order (and looping around if the index started somewhere in the middle)
for (i = 0, ii = gestureLogIndex; i < GESTURE_LOG_SIZE; i++, ii = (ii + 1)%GESTURE_LOG_SIZE) DrawText(gestureLog[ii], (int)gestureLogPosition.x, (int)gestureLogPosition.y + 410 - i*20, 20, (i == 0 ? gestureColor : LIGHTGRAY));
Color logButton1Color, logButton2Color;
switch (logMode)
{
case 3: logButton1Color=MAROON; logButton2Color=MAROON; break;
case 2: logButton1Color=GRAY; logButton2Color=MAROON; break;
case 1: logButton1Color=MAROON; logButton2Color=GRAY; break;
default: logButton1Color=GRAY; logButton2Color=GRAY; break;
}
DrawRectangleRec(logButton1, logButton1Color);
DrawText("Hide", (int)logButton1.x + 7, (int)logButton1.y + 3, 10, WHITE);
DrawText("Repeat", (int)logButton1.x + 7, (int)logButton1.y + 13, 10, WHITE);
DrawRectangleRec(logButton2, logButton2Color);
DrawText("Hide", (int)logButton1.x + 62, (int)logButton1.y + 3, 10, WHITE);
DrawText("Hold", (int)logButton1.x + 62, (int)logButton1.y + 13, 10, WHITE);
// Draw protractor
DrawText("Angle", (int)protractorPosition.x + 55, (int)protractorPosition.y + 76, 10, BLACK);
const char *angleString = TextFormat("%f", currentAngleDegrees);
const int angleStringDot = TextFindIndex(angleString, ".");
const char *angleStringTrim = TextSubtext(angleString, 0, angleStringDot + 3);
DrawText( angleStringTrim, (int)protractorPosition.x + 55, (int)protractorPosition.y + 92, 20, gestureColor);
DrawCircleV(protractorPosition, 80.0f, WHITE);
DrawLineEx((Vector2){ protractorPosition.x - 90, protractorPosition.y }, (Vector2){ protractorPosition.x + 90, protractorPosition.y }, 3.0f, LIGHTGRAY);
DrawLineEx((Vector2){ protractorPosition.x, protractorPosition.y - 90 }, (Vector2){ protractorPosition.x, protractorPosition.y + 90 }, 3.0f, LIGHTGRAY);
DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y - 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y + 45 }, 3.0f, GREEN);
DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y + 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y - 45 }, 3.0f, GREEN);
DrawText("0", (int)protractorPosition.x + 96, (int)protractorPosition.y - 9, 20, BLACK);
DrawText("30", (int)protractorPosition.x + 74, (int)protractorPosition.y - 68, 20, BLACK);
DrawText("90", (int)protractorPosition.x - 11, (int)protractorPosition.y - 110, 20, BLACK);
DrawText("150", (int)protractorPosition.x - 100, (int)protractorPosition.y - 68, 20, BLACK);
DrawText("180", (int)protractorPosition.x - 124, (int)protractorPosition.y - 9, 20, BLACK);
DrawText("210", (int)protractorPosition.x - 100, (int)protractorPosition.y + 50, 20, BLACK);
DrawText("270", (int)protractorPosition.x - 18, (int)protractorPosition.y + 92, 20, BLACK);
DrawText("330", (int)protractorPosition.x + 72, (int)protractorPosition.y + 50, 20, BLACK);
if (currentAngleDegrees != 0.0f) DrawLineEx(protractorPosition, finalVector, 3.0f, gestureColor);
// Draw touch and mouse pointer points
if (currentGesture != GESTURE_NONE)
{
if ( touchCount != 0 )
{
for (i = 0; i < touchCount; i++)
{
DrawCircleV(touchPosition[i], 50.0f, Fade(gestureColor, 0.5f));
DrawCircleV(touchPosition[i], 5.0f, gestureColor);
}
if (touchCount == 2) DrawLineEx(touchPosition[0], touchPosition[1], ((currentGesture == 512)? 8.0f : 12.0f), gestureColor);
}
else
{
DrawCircleV(mousePosition, 35.0f, Fade(gestureColor, 0.5f));
DrawCircleV(mousePosition, 5.0f, gestureColor);
}
}
EndDrawing();
//--------------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Get text string for gesture value
static char const *GetGestureName(int gesture)
{
switch (gesture)
{
case 0: return "None"; break;
case 1: return "Tap"; break;
case 2: return "Double Tap"; break;
case 4: return "Hold"; break;
case 8: return "Drag"; break;
case 16: return "Swipe Right"; break;
case 32: return "Swipe Left"; break;
case 64: return "Swipe Up"; break;
case 128: return "Swipe Down"; break;
case 256: return "Pinch In"; break;
case 512: return "Pinch Out"; break;
default: return "Unknown"; break;
}
}
// Get color for gesture value
static Color GetGestureColor(int gesture)
{
switch (gesture)
{
case 0: return BLACK; break;
case 1: return BLUE; break;
case 2: return SKYBLUE; break;
case 4: return BLACK; break;
case 8: return LIME; break;
case 16: return RED; break;
case 32: return RED; break;
case 64: return RED; break;
case 128: return RED; break;
case 256: return VIOLET; break;
case 512: return ORANGE; break;
default: return BLACK; break;
}
}

View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@ -1,332 +0,0 @@
/*******************************************************************************************
*
* raylib [core] example - Input Gestures for Web
*
* Example complexity rating: [★★☆☆] 2/4
*
* Example originally created with raylib 4.6-dev, last time updated with raylib 4.6-dev
*
* Example contributed by ubkp (@ubkp) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2023-2025 ubkp (@ubkp)
*
********************************************************************************************/
#include "raylib.h"
#include "math.h" // Required for the protractor angle graphic drawing
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> // Required for the Web/HTML5
#endif
//--------------------------------------------------------------------------------------
// Global definitions and declarations
//--------------------------------------------------------------------------------------
// Common variables definitions
//--------------------------------------------------------------------------------------
int screenWidth = 800; // Update depending on web canvas
const int screenHeight = 450;
Vector2 messagePosition = { 160, 7 };
// Last gesture variables definitions
//--------------------------------------------------------------------------------------
int lastGesture = 0;
Vector2 lastGesturePosition = { 165, 130 };
// Gesture log variables definitions and functions declarations
//--------------------------------------------------------------------------------------
#define GESTURE_LOG_SIZE 20
char gestureLog[GESTURE_LOG_SIZE][12] = { "" }; // The gesture log uses an array (as an inverted circular queue) to store the performed gestures
int gestureLogIndex = GESTURE_LOG_SIZE; // The index for the inverted circular queue (moving from last to first direction, then looping around)
int previousGesture = 0;
char const *GetGestureName(int i)
{
switch (i) {
case 0: return "None"; break;
case 1: return "Tap"; break;
case 2: return "Double Tap"; break;
case 4: return "Hold"; break;
case 8: return "Drag"; break;
case 16: return "Swipe Right"; break;
case 32: return "Swipe Left"; break;
case 64: return "Swipe Up"; break;
case 128: return "Swipe Down"; break;
case 256: return "Pinch In"; break;
case 512: return "Pinch Out"; break;
default: return "Unknown"; break;
}
}
Color GetGestureColor(int i)
{
switch (i) {
case 0: return BLACK; break;
case 1: return BLUE; break;
case 2: return SKYBLUE; break;
case 4: return BLACK; break;
case 8: return LIME; break;
case 16: return RED; break;
case 32: return RED; break;
case 64: return RED; break;
case 128: return RED; break;
case 256: return VIOLET; break;
case 512: return ORANGE; break;
default: return BLACK; break;
}
}
int logMode = 1; // Log mode values: 0 shows repeated events; 1 hides repeated events; 2 shows repeated events but hide hold events; 3 hides repeated events and hide hold events
Color gestureColor = { 0, 0, 0, 255 };
Rectangle logButton1 = { 53, 7, 48, 26 };
Rectangle logButton2 = { 108, 7, 36, 26 };
Vector2 gestureLogPosition = { 10, 10 };
// Protractor variables definitions
//--------------------------------------------------------------------------------------
float angleLength = 90.0f;
float currentAngleDegrees = 0.0f;
Vector2 finalVector = { 0.0f, 0.0f };
char currentAngleStr[7] = "";
Vector2 protractorPosition = { 266.0f, 315.0f };
// Update
//--------------------------------------------------------------------------------------
void Update(void)
{
// Handle common
//--------------------------------------------------------------------------------------
int i, ii; // Iterators that will be reused by all for loops
const int currentGesture = GetGestureDetected();
const float currentDragDegrees = GetGestureDragAngle();
const float currentPitchDegrees = GetGesturePinchAngle();
const int touchCount = GetTouchPointCount();
// Handle last gesture
//--------------------------------------------------------------------------------------
if ((currentGesture != 0) && (currentGesture != 4) && (currentGesture != previousGesture)) lastGesture = currentGesture; // Filter the meaningful gestures (1, 2, 8 to 512) for the display
// Handle gesture log
//--------------------------------------------------------------------------------------
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
{
if (CheckCollisionPointRec(GetMousePosition(), logButton1))
{
switch (logMode)
{
case 3: logMode=2; break;
case 2: logMode=3; break;
case 1: logMode=0; break;
default: logMode=1; break;
}
}
else if (CheckCollisionPointRec(GetMousePosition(), logButton2))
{
switch (logMode)
{
case 3: logMode=1; break;
case 2: logMode=0; break;
case 1: logMode=3; break;
default: logMode=2; break;
}
}
}
int fillLog = 0; // Gate variable to be used to allow or not the gesture log to be filled
if (currentGesture !=0)
{
if (logMode == 3) // 3 hides repeated events and hide hold events
{
if (((currentGesture != 4) && (currentGesture != previousGesture)) || (currentGesture < 3)) fillLog = 1;
}
else if (logMode == 2) // 2 shows repeated events but hide hold events
{
if (currentGesture != 4) fillLog = 1;
}
else if (logMode == 1) // 1 hides repeated events
{
if (currentGesture != previousGesture) fillLog = 1;
}
else // 0 shows repeated events
{
fillLog = 1;
}
}
if (fillLog) // If one of the conditions from logMode was met, fill the gesture log
{
previousGesture = currentGesture;
gestureColor = GetGestureColor(currentGesture);
if (gestureLogIndex <= 0) gestureLogIndex = GESTURE_LOG_SIZE;
gestureLogIndex--;
// Copy the gesture respective name to the gesture log array
TextCopy(gestureLog[gestureLogIndex], GetGestureName(currentGesture));
}
// Handle protractor
//--------------------------------------------------------------------------------------
if (currentGesture > 255) // aka Pinch In and Pinch Out
{
currentAngleDegrees = currentPitchDegrees;
}
else if (currentGesture > 15) // aka Swipe Right, Swipe Left, Swipe Up and Swipe Down
{
currentAngleDegrees = currentDragDegrees;
}
else if (currentGesture > 0) // aka Tap, Doubletap, Hold and Grab
{
currentAngleDegrees = 0.0f;
}
float currentAngleRadians = ((currentAngleDegrees +90.0f)*PI/180); // Convert the current angle to Radians
finalVector = (Vector2){ (angleLength*sinf(currentAngleRadians)) + protractorPosition.x, (angleLength*cosf(currentAngleRadians)) + protractorPosition.y }; // Calculate the final vector for display
// Handle touch and mouse pointer points
//--------------------------------------------------------------------------------------
#define MAX_TOUCH_COUNT 32
Vector2 touchPosition[MAX_TOUCH_COUNT] = { 0 };
Vector2 mousePosition = {0, 0};
if (currentGesture != GESTURE_NONE)
{
if (touchCount != 0)
{
for (i = 0; i < touchCount; i++) touchPosition[i] = GetTouchPosition(i); // Fill the touch positions
}
else mousePosition = GetMousePosition();
}
// Draw
//--------------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw common
//--------------------------------------------------------------------------------------
DrawText("*", messagePosition.x + 5, messagePosition.y + 5, 10, BLACK);
DrawText("Example optimized for Web/HTML5\non Smartphones with Touch Screen.", messagePosition.x + 15, messagePosition.y + 5, 10, BLACK);
DrawText("*", messagePosition.x + 5, messagePosition.y + 35, 10, BLACK);
DrawText("While running on Desktop Web Browsers,\ninspect and turn on Touch Emulation.", messagePosition.x + 15, messagePosition.y + 35, 10, BLACK);
// Draw last gesture
//--------------------------------------------------------------------------------------
DrawText("Last gesture", lastGesturePosition.x + 33, lastGesturePosition.y - 47, 20, BLACK);
DrawText("Swipe Tap Pinch Touch", lastGesturePosition.x + 17, lastGesturePosition.y - 18, 10, BLACK);
DrawRectangle(lastGesturePosition.x + 20, lastGesturePosition.y, 20, 20, lastGesture == GESTURE_SWIPE_UP ? RED : LIGHTGRAY);
DrawRectangle(lastGesturePosition.x, lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_LEFT ? RED : LIGHTGRAY);
DrawRectangle(lastGesturePosition.x + 40, lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_RIGHT ? RED : LIGHTGRAY);
DrawRectangle(lastGesturePosition.x + 20, lastGesturePosition.y + 40, 20, 20, lastGesture == GESTURE_SWIPE_DOWN ? RED : LIGHTGRAY);
DrawCircle(lastGesturePosition.x + 80, lastGesturePosition.y + 16, 10, lastGesture == GESTURE_TAP ? BLUE : LIGHTGRAY);
DrawRing( (Vector2){lastGesturePosition.x + 103, lastGesturePosition.y + 16}, 6.0f, 11.0f, 0.0f, 360.0f, 0, lastGesture == GESTURE_DRAG ? LIME : LIGHTGRAY);
DrawCircle(lastGesturePosition.x + 80, lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
DrawCircle(lastGesturePosition.x + 103, lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
DrawTriangle((Vector2){ lastGesturePosition.x + 122, lastGesturePosition.y + 16 }, (Vector2){ lastGesturePosition.x + 137, lastGesturePosition.y + 26 }, (Vector2){ lastGesturePosition.x + 137, lastGesturePosition.y + 6 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
DrawTriangle((Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 6 }, (Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 26 }, (Vector2){ lastGesturePosition.x + 162, lastGesturePosition.y + 16 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
DrawTriangle((Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 33 }, (Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 140, lastGesturePosition.y + 43 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
DrawTriangle((Vector2){ lastGesturePosition.x + 144, lastGesturePosition.y + 43 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 33 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
for (i = 0; i < 4; i++) DrawCircle(lastGesturePosition.x + 180, lastGesturePosition.y + 7 + i*15, 5, touchCount <= i? LIGHTGRAY : gestureColor);
// Draw gesture log
//--------------------------------------------------------------------------------------
DrawText("Log", gestureLogPosition.x, gestureLogPosition.y, 20, BLACK);
// Loop in both directions to print the gesture log array in the inverted order (and looping around if the index started somewhere in the middle)
for (i = 0, ii = gestureLogIndex; i < GESTURE_LOG_SIZE; i++, ii = (ii + 1) % GESTURE_LOG_SIZE) DrawText(gestureLog[ii], gestureLogPosition.x, gestureLogPosition.y + 410 - i*20, 20, (i == 0 ? gestureColor : LIGHTGRAY));
Color logButton1Color, logButton2Color;
switch (logMode)
{
case 3: logButton1Color=MAROON; logButton2Color=MAROON; break;
case 2: logButton1Color=GRAY; logButton2Color=MAROON; break;
case 1: logButton1Color=MAROON; logButton2Color=GRAY; break;
default: logButton1Color=GRAY; logButton2Color=GRAY; break;
}
DrawRectangleRec(logButton1, logButton1Color);
DrawText("Hide", logButton1.x + 7, logButton1.y + 3, 10, WHITE);
DrawText("Repeat", logButton1.x + 7, logButton1.y + 13, 10, WHITE);
DrawRectangleRec(logButton2, logButton2Color);
DrawText("Hide", logButton1.x + 62, logButton1.y + 3, 10, WHITE);
DrawText("Hold", logButton1.x + 62, logButton1.y + 13, 10, WHITE);
// Draw protractor
//--------------------------------------------------------------------------------------
DrawText("Angle", protractorPosition.x + 55, protractorPosition.y + 76, 10, BLACK);
const char *angleString = TextFormat("%f", currentAngleDegrees);
const int angleStringDot = TextFindIndex(angleString, ".");
const char *angleStringTrim = TextSubtext(angleString, 0, angleStringDot + 3);
DrawText( angleStringTrim, protractorPosition.x + 55, protractorPosition.y + 92, 20, gestureColor);
DrawCircle(protractorPosition.x, protractorPosition.y, 80.0f, WHITE);
DrawLineEx((Vector2){ protractorPosition.x - 90, protractorPosition.y }, (Vector2){ protractorPosition.x + 90, protractorPosition.y }, 3.0f, LIGHTGRAY);
DrawLineEx((Vector2){ protractorPosition.x, protractorPosition.y - 90 }, (Vector2){ protractorPosition.x, protractorPosition.y + 90 }, 3.0f, LIGHTGRAY);
DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y - 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y + 45 }, 3.0f, GREEN);
DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y + 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y - 45 }, 3.0f, GREEN);
DrawText("0", protractorPosition.x + 96, protractorPosition.y - 9, 20, BLACK);
DrawText("30", protractorPosition.x + 74, protractorPosition.y - 68, 20, BLACK);
DrawText("90", protractorPosition.x - 11, protractorPosition.y - 110, 20, BLACK);
DrawText("150", protractorPosition.x - 100, protractorPosition.y - 68, 20, BLACK);
DrawText("180", protractorPosition.x - 124, protractorPosition.y - 9, 20, BLACK);
DrawText("210", protractorPosition.x - 100, protractorPosition.y + 50, 20, BLACK);
DrawText("270", protractorPosition.x - 18, protractorPosition.y + 92, 20, BLACK);
DrawText("330", protractorPosition.x + 72, protractorPosition.y + 50, 20, BLACK);
if (currentAngleDegrees != 0.0f) DrawLineEx(protractorPosition, finalVector, 3.0f, gestureColor);
// Draw touch and mouse pointer points
//--------------------------------------------------------------------------------------
if (currentGesture != GESTURE_NONE)
{
if ( touchCount != 0 )
{
for (i = 0; i < touchCount; i++)
{
DrawCircleV(touchPosition[i], 50.0f, Fade(gestureColor, 0.5f));
DrawCircleV(touchPosition[i], 5.0f, gestureColor);
}
if (touchCount == 2) DrawLineEx(touchPosition[0], touchPosition[1], ((currentGesture == 512)? 8 : 12), gestureColor);
}
else
{
DrawCircleV(mousePosition, 35.0f, Fade(gestureColor, 0.5f));
DrawCircleV(mousePosition, 5.0f, gestureColor);
}
}
EndDrawing();
//--------------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures web");
//--------------------------------------------------------------------------------------
// Main game loop
//--------------------------------------------------------------------------------------
#if defined(PLATFORM_WEB)
emscripten_set_main_loop(Update, 0, 1);
#else
SetTargetFPS(60);
while (!WindowShouldClose()) Update(); // Detect window close button or ESC key
#endif
//--------------------------------------------------------------------------------------
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Keyboard input
* raylib [core] example - input keys
*
* Example complexity rating: [★☆☆☆] 1/4
*
@ -25,7 +25,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");
InitWindow(screenWidth, screenHeight, "raylib [core] example - input keys");
Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Mouse input
* raylib [core] example - input mouse
*
* Example complexity rating: [★☆☆☆] 1/4
*
@ -25,11 +25,10 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse");
Vector2 ballPosition = { -100.0f, -100.0f };
Color ballColor = DARKBLUE;
int isCursorHidden = 0;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//---------------------------------------------------------------------------------------
@ -41,18 +40,10 @@ int main(void)
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_H))
{
if (isCursorHidden == 0)
{
HideCursor();
isCursorHidden = 1;
}
else
{
ShowCursor();
isCursorHidden = 0;
}
if (IsCursorHidden()) ShowCursor();
else HideCursor();
}
ballPosition = GetMousePosition();
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) ballColor = MAROON;
@ -75,7 +66,7 @@ int main(void)
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
DrawText("Press 'H' to toggle cursor visibility", 10, 30, 20, DARKGRAY);
if (isCursorHidden == 1) DrawText("CURSOR HIDDEN", 20, 60, 20, RED);
if (IsCursorHidden()) DrawText("CURSOR HIDDEN", 20, 60, 20, RED);
else DrawText("CURSOR VISIBLE", 20, 60, 20, LIME);
EndDrawing();

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] examples - Mouse wheel input
* raylib [core] example - input mouse wheel
*
* Example complexity rating: [★☆☆☆] 1/4
*

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Input multitouch
* raylib [core] example - input multitouch
*
* Example complexity rating: [★☆☆☆] 1/4
*
@ -46,7 +46,7 @@ int main(void)
// Clamp touch points available ( set the maximum touch points allowed )
if (tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
// Get touch points positions
for (int i = 0; i < tCount; ++i) touchPositions[i] = GetTouchPosition(i);
for (int i = 0; i < tCount; i++) touchPositions[i] = GetTouchPosition(i);
//----------------------------------------------------------------------------------
// Draw
@ -54,8 +54,8 @@ int main(void)
BeginDrawing();
ClearBackground(RAYWHITE);
for (int i = 0; i < tCount; ++i)
for (int i = 0; i < tCount; i++)
{
// Make sure point is not (0, 0) as this means there is no touch for it
if ((touchPositions[i].x > 0) && (touchPositions[i].y > 0))

View File

@ -2,23 +2,22 @@
*
* raylib [core] example - input virtual controls
*
* Example complexity rating: [★★☆] 3/4
* Example complexity rating: [★★☆] 2/4
*
* Example originally created with raylib 5.0, last time updated with raylib 5.0
*
* Example create by GreenSnakeLinux (@GreenSnakeLinux),
* lighter by oblerion (@oblerion) and
* reviewed by Ramon Santamaria (@raysan5) and
* improved by danilwhale (@danilwhale)
* Example contributed by GreenSnakeLinux (@GreenSnakeLinux),
* reviewed by Ramon Santamaria (@raysan5), oblerion (@oblerion) and danilwhale (@danilwhale)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2024-2025 oblerion (@oblerion) and Ramon Santamaria (@raysan5)
* Copyright (c) 2024-2025 GreenSnakeLinux (@GreenSnakeLinux) and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#include <math.h>
typedef enum {
@ -45,24 +44,21 @@ int main(void)
Vector2 padPosition = { 100, 350 };
float buttonRadius = 30;
Vector2 buttonPositions[BUTTON_MAX] =
{
Vector2 buttonPositions[BUTTON_MAX] = {
{ padPosition.x,padPosition.y - buttonRadius*1.5f }, // Up
{ padPosition.x - buttonRadius*1.5f, padPosition.y }, // Left
{ padPosition.x + buttonRadius*1.5f, padPosition.y }, // Right
{ padPosition.x, padPosition.y + buttonRadius*1.5f } // Down
};
const char *buttonLabels[BUTTON_MAX] =
{
const char *buttonLabels[BUTTON_MAX] = {
"Y", // Up
"X", // Left
"B", // Right
"A" // Down
};
Color buttonLabelColors[BUTTON_MAX] =
{
Color buttonLabelColors[BUTTON_MAX] = {
YELLOW, // Up
BLUE, // Left
RED, // Right
@ -83,22 +79,15 @@ int main(void)
{
// Update
//--------------------------------------------------------------------------
if ((GetTouchPointCount() > 0))
{
// Use touch position
inputPosition = GetTouchPosition(0);
}
else
{
// Use mouse position
inputPosition = GetMousePosition();
}
if ((GetTouchPointCount() > 0)) inputPosition = GetTouchPosition(0); // Use touch position
else inputPosition = GetMousePosition(); // Use mouse position
// Reset pressed button to none
pressedButton = BUTTON_NONE;
// Make sure user is pressing left mouse button if they're from desktop
if ((GetTouchPointCount() > 0) || ((GetTouchPointCount() == 0) && IsMouseButtonDown(MOUSE_BUTTON_LEFT)))
if ((GetTouchPointCount() > 0) ||
((GetTouchPointCount() == 0) && IsMouseButtonDown(MOUSE_BUTTON_LEFT)))
{
// Find nearest D-Pad button to the input position
for (int i = 0; i < BUTTON_MAX; i++)
@ -123,8 +112,8 @@ int main(void)
case BUTTON_DOWN: playerPosition.y += playerSpeed*GetFrameTime(); break;
default: break;
};
//--------------------------------------------------------------------------
// Draw
//--------------------------------------------------------------------------
BeginDrawing();
@ -157,4 +146,3 @@ int main(void)
return 0;
}

View File

@ -1,158 +0,0 @@
/*******************************************************************************************
*
* raylib [core] example - loading thread
*
* Example complexity rating: [★★★☆] 3/4
*
* NOTE: This example requires linking with pthreads library on MinGW,
* it can be accomplished passing -static parameter to compiler
*
* Example originally created with raylib 2.5, last time updated with raylib 3.0
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
*
* Copyright (c) 2014-2025 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
// WARNING: This example does not build on Windows with MSVC compiler
#include "pthread.h" // POSIX style threads management
#include <stdatomic.h> // C11 atomic data types
#include <time.h> // Required for: clock()
// Using C11 atomics for synchronization
// NOTE: A plain bool (or any plain data type for that matter) can't be used for inter-thread synchronization
static atomic_bool dataLoaded = false; // Data Loaded completion indicator
static void *LoadDataThread(void *arg); // Loading data thread function declaration
static atomic_int dataProgress = 0; // Data progress accumulator
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread");
pthread_t threadId = { 0 }; // Loading data thread id
enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING;
int framesCounter = 0;
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
//----------------------------------------------------------------------------------
switch (state)
{
case STATE_WAITING:
{
if (IsKeyPressed(KEY_ENTER))
{
int error = pthread_create(&threadId, NULL, &LoadDataThread, NULL);
if (error != 0) TraceLog(LOG_ERROR, "Error creating loading thread");
else TraceLog(LOG_INFO, "Loading thread initialized successfully");
state = STATE_LOADING;
}
} break;
case STATE_LOADING:
{
framesCounter++;
if (atomic_load_explicit(&dataLoaded, memory_order_relaxed))
{
framesCounter = 0;
int error = pthread_join(threadId, NULL);
if (error != 0) TraceLog(LOG_ERROR, "Error joining loading thread");
else TraceLog(LOG_INFO, "Loading thread terminated successfully");
state = STATE_FINISHED;
}
} break;
case STATE_FINISHED:
{
if (IsKeyPressed(KEY_ENTER))
{
// Reset everything to launch again
atomic_store_explicit(&dataLoaded, false, memory_order_relaxed);
atomic_store_explicit(&dataProgress, 0, memory_order_relaxed);
state = STATE_WAITING;
}
} break;
default: break;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
switch (state)
{
case STATE_WAITING: DrawText("PRESS ENTER to START LOADING DATA", 150, 170, 20, DARKGRAY); break;
case STATE_LOADING:
{
DrawRectangle(150, 200, atomic_load_explicit(&dataProgress, memory_order_relaxed), 60, SKYBLUE);
if ((framesCounter/15)%2) DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE);
} break;
case STATE_FINISHED:
{
DrawRectangle(150, 200, 500, 60, LIME);
DrawText("DATA LOADED!", 250, 210, 40, GREEN);
} break;
default: break;
}
DrawRectangleLines(150, 200, 500, 60, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
// Loading data thread function definition
static void *LoadDataThread(void *arg)
{
int timeCounter = 0; // Time counted in ms
clock_t prevTime = clock(); // Previous time
// We simulate data loading with a time counter for 5 seconds
while (timeCounter < 5000)
{
clock_t currentTime = clock() - prevTime;
timeCounter = currentTime*1000/CLOCKS_PER_SEC;
// We accumulate time over a global variable to be used in
// main thread as a progress bar
atomic_store_explicit(&dataProgress, timeCounter/10, memory_order_relaxed);
}
// When data has finished loading, we set global variable
atomic_store_explicit(&dataLoaded, true, memory_order_relaxed);
return NULL;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,160 @@
/*******************************************************************************************
*
* raylib [core] example - monitor detector
*
* Example complexity rating: [★☆☆☆] 1/4
*
* Example originally created with raylib 5.5, last time updated with raylib 5.6
*
* Example contributed by Maicon Santana (@maiconpintoabreu) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025 Maicon Santana (@maiconpintoabreu)
*
********************************************************************************************/
#include "raylib.h"
#define MAX_MONITORS 10
// Monitor info
typedef struct MonitorInfo {
Vector2 position;
const char *name;
int width;
int height;
int physicalWidth;
int physicalHeight;
int refreshRate;
} MonitorInfo;
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - monitor detector");
MonitorInfo monitors[MAX_MONITORS] = { 0 };
int currentMonitorIndex = GetCurrentMonitor();
int monitorCount = 0;
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
//----------------------------------------------------------------------------------
// Variables to find the max x and Y to calculate the scale
int maxWidth = 1;
int maxHeight = 1;
// Monitor offset is to fix when monitor position x is negative
int monitorOffsetX = 0;
// Rebuild monitors array every frame
monitorCount = GetMonitorCount();
for (int i = 0; i < monitorCount; i++)
{
monitors[i] = (MonitorInfo){
GetMonitorPosition(i),
GetMonitorName(i),
GetMonitorWidth(i),
GetMonitorHeight(i),
GetMonitorPhysicalWidth(i),
GetMonitorPhysicalHeight(i),
GetMonitorRefreshRate(i)
};
if (monitors[i].position.x < monitorOffsetX) monitorOffsetX = -(int)monitors[i].position.x;
const int width = (int)monitors[i].position.x + monitors[i].width;
const int height = (int)monitors[i].position.y + monitors[i].height;
if (maxWidth < width) maxWidth = width;
if (maxHeight < height) maxHeight = height;
}
if (IsKeyPressed(KEY_ENTER) && (monitorCount > 1))
{
currentMonitorIndex += 1;
// Set index to 0 if the last one
if (currentMonitorIndex == monitorCount) currentMonitorIndex = 0;
SetWindowMonitor(currentMonitorIndex); // Move window to currentMonitorIndex
}
else currentMonitorIndex = GetCurrentMonitor(); // Get currentMonitorIndex if manually moved
float monitorScale = 0.6f;
if (maxHeight > (maxWidth + monitorOffsetX)) monitorScale *= ((float)screenHeight/(float)maxHeight);
else monitorScale *= ((float)screenWidth/(float)(maxWidth + monitorOffsetX));
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Press [Enter] to move window to next monitor available", 20, 20, 20, DARKGRAY);
DrawRectangleLines(20, 60, screenWidth - 40, screenHeight - 100, DARKGRAY);
// Draw Monitor Rectangles with information inside
for (int i = 0; i < monitorCount; i++)
{
// Calculate retangle position and size using monitorScale
const Rectangle rec = (Rectangle){
(monitors[i].position.x + monitorOffsetX)*monitorScale + 140,
monitors[i].position.y*monitorScale + 80,
monitors[i].width*monitorScale,
monitors[i].height*monitorScale
};
// Draw monitor name and information inside the rectangle
DrawText(TextFormat("[%i] %s", i, monitors[i].name), (int)rec.x + 10, (int)rec.y + (int)(100*monitorScale), (int)(120*monitorScale), BLUE);
DrawText(
TextFormat("Resolution: [%ipx x %ipx]\nRefreshRate: [%ihz]\nPhysical Size: [%imm x %imm]\nPosition: %3.0f x %3.0f",
monitors[i].width,
monitors[i].height,
monitors[i].refreshRate,
monitors[i].physicalWidth,
monitors[i].physicalHeight,
monitors[i].position.x,
monitors[i].position.y
), (int)rec.x + 10, (int)rec.y + (int)(200*monitorScale), (int)(120*monitorScale), DARKGRAY);
// Highlight current monitor
if (i == currentMonitorIndex)
{
DrawRectangleLinesEx(rec, 5, RED);
Vector2 windowPosition = (Vector2){ (GetWindowPosition().x + monitorOffsetX)*monitorScale + 140, GetWindowPosition().y*monitorScale + 80 };
// Draw window position based on monitors
DrawRectangleV(windowPosition, (Vector2){screenWidth*monitorScale, screenHeight*monitorScale}, Fade(GREEN, 0.5));
}
else DrawRectangleLinesEx(rec, 5, GRAY);
}
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Generates a random sequence
* raylib [core] example - random sequence
*
* Example complexity rating: [★☆☆☆] 1/4
*
@ -16,22 +16,25 @@
********************************************************************************************/
#include "raylib.h"
#include "raymath.h"
#include <stdlib.h> // Required for: malloc() and free()
#include <stdlib.h> // Required for: malloc(), free()
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef struct ColorRect {
Color c;
Rectangle r;
Color color;
Rectangle rect;
} ColorRect;
//------------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//------------------------------------------------------------------------------------
static Color GenerateRandomColor();
static Color GenerateRandomColor(void);
static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight);
static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount);
static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, int posY, int fontSize, Color color);
//------------------------------------------------------------------------------------
// Program main entry point
@ -43,7 +46,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - Generates a random sequence");
InitWindow(screenWidth, screenHeight, "raylib [core] example - random sequence");
int rectCount = 20;
float rectSize = (float)screenWidth/rectCount;
@ -63,7 +66,9 @@ int main(void)
{
rectCount++;
rectSize = (float)screenWidth/rectCount;
free(rectangles);
RL_FREE(rectangles);
// Re-generate random sequence with new count
rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f*screenHeight);
}
@ -73,7 +78,9 @@ int main(void)
{
rectCount--;
rectSize = (float)screenWidth/rectCount;
free(rectangles);
RL_FREE(rectangles);
// Re-generate random sequence with new count
rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f*screenHeight);
}
}
@ -85,20 +92,20 @@ int main(void)
ClearBackground(RAYWHITE);
int fontSize = 20;
for (int i = 0; i < rectCount; i++)
{
DrawRectangleRec(rectangles[i].r, rectangles[i].c);
DrawTextCenterKeyHelp("SPACE", "to shuffle the sequence.", 10, screenHeight - 96, fontSize, BLACK);
DrawTextCenterKeyHelp("UP", "to add a rectangle and generate a new sequence.", 10, screenHeight - 64, fontSize, BLACK);
DrawTextCenterKeyHelp("DOWN", "to remove a rectangle and generate a new sequence.", 10, screenHeight - 32, fontSize, BLACK);
DrawRectangleRec(rectangles[i].rect, rectangles[i].color);
DrawText("Press SPACE to shuffle the sequence", 10, screenHeight - 96, 20, BLACK);
DrawText("Press SPACE to shuffle the current sequence", 10, screenHeight - 96, 20, BLACK);
DrawText("Press UP to add a rectangle and generate a new sequence", 10, screenHeight - 64, 20, BLACK);
DrawText("Press DOWN to remove a rectangle and generate a new sequence", 10, screenHeight - 32, 20, BLACK);
}
const char *rectCountText = TextFormat("%d rectangles", rectCount);
int rectCountTextSize = MeasureText(rectCountText, fontSize);
DrawText(rectCountText, screenWidth - rectCountTextSize - 10, 10, fontSize, BLACK);
DrawText(TextFormat("Count: %d rectangles", rectCount), 10, 10, 20, MAROON);
DrawFPS(10, 10);
DrawFPS(screenWidth - 80, 10);
EndDrawing();
//----------------------------------------------------------------------------------
@ -114,12 +121,12 @@ int main(void)
}
//------------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//------------------------------------------------------------------------------------
static Color GenerateRandomColor()
static Color GenerateRandomColor(void)
{
Color color = {
GetRandomValue(0, 255),
Color color = {
GetRandomValue(0, 255),
GetRandomValue(0, 255),
GetRandomValue(0, 255),
255
@ -130,7 +137,8 @@ static Color GenerateRandomColor()
static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight)
{
ColorRect *rectangles = (ColorRect *)malloc((int)rectCount*sizeof(ColorRect));
ColorRect *rectangles = (ColorRect *)RL_CALLOC((int)rectCount, sizeof(ColorRect));
int *seq = LoadRandomSequence((unsigned int)rectCount, 0, (unsigned int)rectCount - 1);
float rectSeqWidth = rectCount*rectWidth;
float startX = (screenWidth - rectSeqWidth)*0.5f;
@ -138,20 +146,20 @@ static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWid
for (int i = 0; i < rectCount; i++)
{
int rectHeight = (int)Remap((float)seq[i], 0, rectCount - 1, 0, screenHeight);
rectangles[i].c = GenerateRandomColor();
rectangles[i].r = CLITERAL(Rectangle){ startX + i*rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight };
rectangles[i].color = GenerateRandomColor();
rectangles[i].rect = CLITERAL(Rectangle){ startX + i*rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight };
}
UnloadRandomSequence(seq);
return rectangles;
}
static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount)
{
int *seq = LoadRandomSequence(rectCount, 0, rectCount - 1);
for (int i1 = 0; i1 < rectCount; i1++)
{
ColorRect *r1 = &rectangles[i1];
@ -159,29 +167,13 @@ static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount)
// Swap only the color and height
ColorRect tmp = *r1;
r1->c = r2->c;
r1->r.height = r2->r.height;
r1->r.y = r2->r.y;
r2->c = tmp.c;
r2->r.height = tmp.r.height;
r2->r.y = tmp.r.y;
r1->color = r2->color;
r1->rect.height = r2->rect.height;
r1->rect.y = r2->rect.y;
r2->color = tmp.color;
r2->rect.height = tmp.rect.height;
r2->rect.y = tmp.rect.y;
}
UnloadRandomSequence(seq);
}
static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, int posY, int fontSize, Color color)
{
int spaceSize = MeasureText(" ", fontSize);
int pressSize = MeasureText("Press", fontSize);
int keySize = MeasureText(key, fontSize);
int textSize = MeasureText(text, fontSize);
int textSizeCurrent = 0;
DrawText("Press", posX, posY, fontSize, color);
textSizeCurrent += pressSize + 2*spaceSize;
DrawText(key, posX + textSizeCurrent, posY, fontSize, RED);
DrawRectangle(posX + textSizeCurrent, posY + fontSize, keySize, 3, RED);
textSizeCurrent += keySize + 2*spaceSize;
DrawText(text, posX + textSizeCurrent, posY, fontSize, color);
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Generate random values
* raylib [core] example - random values
*
* Example complexity rating: [★☆☆☆] 1/4
*
@ -25,14 +25,14 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values");
InitWindow(screenWidth, screenHeight, "raylib [core] example - random values");
// SetRandomSeed(0xaabbccff); // Set a custom random seed if desired, by default: "time(NULL)"
int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included)
unsigned int framesCounter = 0; // Variable used to count frames
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

View File

@ -0,0 +1,101 @@
/*******************************************************************************************
*
* raylib [core] example - render texture
*
* Example complexity rating: [★☆☆☆] 1/4
*
* Example originally created with raylib 5.6-dev, last time updated with raylib 5.6-dev
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//---------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - render texture");
// Define a render texture to render
int renderTextureWidth = 300;
int renderTextureHeight = 300;
RenderTexture2D target = LoadRenderTexture(renderTextureWidth, renderTextureHeight);
Vector2 ballPosition = { renderTextureWidth/2.0f, renderTextureHeight/2.0f };
Vector2 ballSpeed = { 5.0f, 4.0f };
int ballRadius = 20;
float rotation = 0.0f;
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
//-----------------------------------------------------
// Ball movement logic
ballPosition.x += ballSpeed.x;
ballPosition.y += ballSpeed.y;
// Check walls collision for bouncing
if ((ballPosition.x >= (renderTextureWidth - ballRadius)) || (ballPosition.x <= ballRadius)) ballSpeed.x *= -1.0f;
if ((ballPosition.y >= (renderTextureHeight - ballRadius)) || (ballPosition.y <= ballRadius)) ballSpeed.y *= -1.0f;
// Render texture rotation
rotation += 0.5f;
//-----------------------------------------------------
// Draw
//-----------------------------------------------------
// Draw our scene to the render texture
BeginTextureMode(target);
ClearBackground(SKYBLUE);
DrawRectangle(0, 0, 20, 20, RED);
DrawCircleV(ballPosition, (float)ballRadius, MAROON);
EndTextureMode();
// Draw render texture to main framebuffer
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw our render texture with rotation applied
// NOTE 1: We set the origin of the texture to the center of the render texture
// NOTE 2: We flip vertically the texture setting negative source rectangle height
DrawTexturePro(target.texture,
(Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height },
(Rectangle){ screenWidth/2.0f, screenHeight/2.0f, (float)target.texture.width, (float)target.texture.height },
(Vector2){ target.texture.width/2.0f, target.texture.height/2.0f }, rotation, WHITE);
DrawText("DRAWING BOUNCING BALL INSIDE RENDER TEXTURE!", 10, screenHeight - 40, 20, BLACK);
DrawFPS(10, 10);
EndDrawing();
//-----------------------------------------------------
}
// De-Initialization
//---------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//----------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Scissor test
* raylib [core] example - scissor test
*
* Example complexity rating: [★☆☆☆] 1/4
*

View File

@ -0,0 +1,166 @@
/*******************************************************************************************
*
* raylib [core] example - screen recording
*
* Example complexity rating: [★★☆☆] 2/4
*
* Example originally created with raylib 5.6-dev, last time updated with raylib 5.6-dev
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2025 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
// Using msf_gif library to record frames into GIF
#define MSF_GIF_IMPL
#include "msf_gif.h" // GIF recording functionality
#include <math.h> // Required for: sinf()
#define GIF_RECORD_FRAMERATE 5 // Record framerate, we get a frame every N frames
#define MAX_SINEWAVE_POINTS 256
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - screen recording");
bool gifRecording = false; // GIF recording state
unsigned int gifFrameCounter = 0; // GIF frames counter
MsfGifState gifState = { 0 }; // MSGIF context state
Vector2 circlePosition = { 0.0f, screenHeight/2.0f };
float timeCounter = 0.0f;
// Get sine wave points for line drawing
Vector2 sinePoints[MAX_SINEWAVE_POINTS] = { 0 };
for (int i = 0; i < MAX_SINEWAVE_POINTS; i++)
{
sinePoints[i].x = i*GetScreenWidth()/180.0f;
sinePoints[i].y = screenHeight/2.0f + 150*sinf((2*PI/1.5f)*(1.0f/60.0f)*(float)i); // Calculate for 60 fps
}
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// Update circle sinusoidal movement
timeCounter += GetFrameTime();
circlePosition.x += GetScreenWidth()/180.0f;
circlePosition.y = screenHeight/2.0f + 150*sinf((2*PI/1.5f)*timeCounter);
if (circlePosition.x > screenWidth)
{
circlePosition.x = 0.0f;
circlePosition.y = screenHeight/2.0f;
timeCounter = 0.0f;
}
// Start-Stop GIF recording on CTRL+R
if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_R))
{
if (gifRecording)
{
// Stop current recording and save file
gifRecording = false;
MsfGifResult result = msf_gif_end(&gifState);
SaveFileData(TextFormat("%s/screenrecording.gif", GetApplicationDirectory()), result.data, (unsigned int)result.dataSize);
msf_gif_free(result);
TraceLog(LOG_INFO, "Finish animated GIF recording");
}
else
{
// Start a new recording
gifRecording = true;
gifFrameCounter = 0;
msf_gif_begin(&gifState, GetRenderWidth(), GetRenderHeight());
TraceLog(LOG_INFO, "Start animated GIF recording");
}
}
if (gifRecording)
{
gifFrameCounter++;
// NOTE: We record one gif frame depending on the desired gif framerate
if (gifFrameCounter > GIF_RECORD_FRAMERATE)
{
// Get image data for the current frame (from backbuffer)
// WARNING: This process is quite slow, it can generate stuttering
Image imScreen = LoadImageFromScreen();
// Add the frame to the gif recording, providing and "estimated" time for display in centiseconds
msf_gif_frame(&gifState, imScreen.data, (int)((1.0f/60.0f)*GIF_RECORD_FRAMERATE)/10, 16, imScreen.width*4);
gifFrameCounter = 0;
UnloadImage(imScreen); // Free image data
}
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
for (int i = 0; i < (MAX_SINEWAVE_POINTS - 1); i++)
{
DrawLineV(sinePoints[i], sinePoints[i + 1], MAROON);
DrawCircleV(sinePoints[i], 3, MAROON);
}
DrawCircleV(circlePosition, 30, RED);
DrawFPS(10, 10);
/*
// Draw record indicator
// WARNING: If drawn here, it will appear in the recorded image,
// use a render texture instead for the recording and LoadImageFromTexture(rt.texture)
if (gifRecording)
{
// Display the recording indicator every half-second
if ((int)(GetTime()/0.5)%2 == 1)
{
DrawCircle(30, GetScreenHeight() - 20, 10, MAROON);
DrawText("GIF RECORDING", 50, GetScreenHeight() - 25, 10, RED);
}
}
*/
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
// If still recording a GIF on close window, just finish
if (gifRecording)
{
MsfGifResult result = msf_gif_end(&gifState);
msf_gif_free(result);
gifRecording = false;
}
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,11 +1,11 @@
/*******************************************************************************************
*
* raylib [core] example - Smooth Pixel-perfect camera
* raylib [core] example - smooth pixelperfect
*
* Example complexity rating: [★★★☆] 3/4
*
* Example originally created with raylib 3.7, last time updated with raylib 4.0
*
*
* Example contributed by Giancamillo Alessandroni (@NotManyIdeasDev) and
* reviewed by Ramon Santamaria (@raysan5)
*
@ -35,7 +35,7 @@ int main(void)
const float virtualRatio = (float)screenWidth/(float)virtualScreenWidth;
InitWindow(screenWidth, screenHeight, "raylib [core] example - smooth pixel-perfect camera");
InitWindow(screenWidth, screenHeight, "raylib [core] example - smooth pixelperfect");
Camera2D worldSpaceCamera = { 0 }; // Game world camera
worldSpaceCamera.zoom = 1.0f;
@ -43,7 +43,8 @@ int main(void)
Camera2D screenSpaceCamera = { 0 }; // Smoothing camera
screenSpaceCamera.zoom = 1.0f;
RenderTexture2D target = LoadRenderTexture(virtualScreenWidth, virtualScreenHeight); // This is where we'll draw all our objects.
// Load render texture to draw all our objects
RenderTexture2D target = LoadRenderTexture(virtualScreenWidth, virtualScreenHeight);
Rectangle rec01 = { 70.0f, 35.0f, 20.0f, 20.0f };
Rectangle rec02 = { 90.0f, 55.0f, 30.0f, 10.0f };

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [core] example - Storage save/load values
* raylib [core] example - storage values
*
* Example complexity rating: [★★☆☆] 2/4
*
@ -25,7 +25,9 @@ typedef enum {
STORAGE_POSITION_HISCORE = 1
} StorageData;
// Persistent storage functions
//------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
static bool SaveStorageValue(unsigned int position, int value);
static int LoadStorageValue(unsigned int position);
@ -39,7 +41,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - storage save/load values");
InitWindow(screenWidth, screenHeight, "raylib [core] example - storage values");
int score = 0;
int hiscore = 0;
@ -101,6 +103,9 @@ int main(void)
return 0;
}
//------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
// Save integer value to storage file (to defined position)
// NOTE: Storage positions is directly related to file memory layout (4 bytes each integer)
bool SaveStorageValue(unsigned int position, int value)

View File

@ -0,0 +1,173 @@
/*******************************************************************************************
*
* raylib [core] example - text file loading
*
* Example complexity rating: [★☆☆☆] 1/4
*
* Example originally created with raylib 5.5, last time updated with raylib 5.6
*
* Example contributed by Aanjishnu Bhattacharyya (@NimComPoo-04) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 0 Aanjishnu Bhattacharyya (@NimComPoo-04)
*
********************************************************************************************/
#include "raylib.h"
#include "raymath.h" // Required for: Lerp()
#include <string.h>
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - text file loading");
// Setting up the camera
Camera2D cam = {
.offset = {0, 0},
.target = {0, 0},
.rotation = 0,
.zoom = 1
};
// Loading text file from resources/text_file.txt
const char *fileName = "resources/text_file.txt";
char *text = LoadFileText(fileName);
// Loading all the text lines
int lineCount = 0;
char **lines = LoadTextLines(text, &lineCount);
// Stylistic choises
int fontSize = 20;
int textTop = 25 + fontSize; // Top of the screen from where the text is rendered
int wrapWidth = screenWidth - 20;
// Wrap the lines as needed
for (int i = 0; i < lineCount; i++)
{
int j = 0;
int lastSpace = 0; // Keeping track of last valid space to insert '\n'
int lastWrapStart = 0; // Keeping track of the start of this wrapped line.
while (j <= strlen(lines[i]))
{
if (lines[i][j] == ' ' || lines[i][j] == '\0')
{
char before = lines[i][j];
// Making a C Style string by adding a '\0' at the required location so that we can use the MeasureText function
lines[i][j] = '\0';
// Checking if the text has crossed the wrapWidth, then going back and inserting a newline
if (MeasureText(lines[i] + lastWrapStart, fontSize) > wrapWidth)
{
lines[i][lastSpace] = '\n';
// Since we added a newline the place of wrap changed so we update our lastWrapStart
lastWrapStart = lastSpace + 1;
}
if(before != '\0') lines[i][j] = ' '; // Resetting the space back
lastSpace = j; // Since we encountered a new space we update our last encountered space location
}
j++;
}
}
// Calculating the total height so that we can show a scrollbar
int textHeight = 0;
for (int i = 0; i < lineCount; i++)
{
Vector2 size = MeasureTextEx(GetFontDefault(), lines[i], (float)fontSize, 2);
textHeight += (int)size.y + 10;
}
// A simple scrollbar on the side to show how far we have read into the file
Rectangle scrollBar = {
.x = (float)screenWidth - 5,
.y = 0,
.width = 5,
.height = screenHeight*100.0f/(textHeight - screenHeight) // Scrollbar height is just a percentage
};
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
float scroll = GetMouseWheelMove();
cam.target.y -= scroll*fontSize*1.5f; // Choosing an arbitrary speed for scroll
if (cam.target.y < 0) cam.target.y = 0; // Snapping to 0 if we go too far back
// Ensuring that the camera does not scroll past all text
if (cam.target.y > textHeight - screenHeight + textTop)
cam.target.y = (float)textHeight - screenHeight + textTop;
// Computing the position of the scrollBar depending on the percentage of text covered
scrollBar.y = Lerp((float)textTop, (float)screenHeight - scrollBar.height, (float)(cam.target.y - textTop)/(textHeight - screenHeight));
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode2D(cam);
// Going through all the read lines
for (int i = 0, t = textTop; i < lineCount; i++)
{
// Each time we go through and calculate the height of the text to move the cursor appropriately
Vector2 size;
if(strcmp(lines[i], "")){
// Fix for empty line in the text file
size = MeasureTextEx( GetFontDefault(), lines[i], (float)fontSize, 2);
}else{
size = MeasureTextEx( GetFontDefault(), " ", (float)fontSize, 2);
}
DrawText(lines[i], 10, t, fontSize, RED);
// Inserting extra space for real newlines,
// wrapped lines are rendered closer together
t += (int)size.y + 10;
}
EndMode2D();
// Header displaying which file is being read currently
DrawRectangle(0, 0, screenWidth, textTop - 10, BEIGE);
DrawText(TextFormat("File: %s", fileName), 10, 10, fontSize, MAROON);
DrawRectangleRec(scrollBar, MAROON);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTextLines(lines, lineCount);
UnloadFileText(text);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

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