koffi 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog.md +12 -0
- package/build/qemu/2.1.3/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_win32_x64.tar.gz +0 -0
- package/doc/templates/badges.html +3 -0
- package/package.json +2 -2
- package/src/abi_arm64.cc +35 -1
- package/src/abi_x64_win.cc +2 -8
- package/src/abi_x86.cc +1 -7
- package/src/ffi.cc +2 -2
- package/src/ffi.hh +1 -1
- package/src/util.hh +6 -0
- package/test/raylib.js +37 -5
- package/vendor/libcc/libcc.cc +430 -196
- package/vendor/libcc/libcc.hh +1417 -1283
- package/vendor/raylib/BINDINGS.md +87 -70
- package/vendor/raylib/CHANGELOG +263 -50
- package/vendor/raylib/CMakeLists.txt +12 -0
- package/vendor/raylib/CMakeOptions.txt +8 -1
- package/vendor/raylib/CONVENTIONS.md +2 -3
- package/vendor/raylib/FAQ.md +137 -0
- package/vendor/raylib/HISTORY.md +62 -29
- package/vendor/raylib/LICENSE +1 -1
- package/vendor/raylib/README.md +22 -17
- package/vendor/raylib/ROADMAP.md +8 -7
- package/vendor/raylib/cmake/CompileDefinitions.cmake +19 -15
- package/vendor/raylib/cmake/GlfwImport.cmake +2 -0
- package/vendor/raylib/cmake/LibraryConfigurations.cmake +22 -16
- package/vendor/raylib/cmake/raylib-config.cmake +52 -49
- package/vendor/raylib/examples/CMakeLists.txt +14 -9
- package/vendor/raylib/examples/Makefile +112 -125
- package/vendor/raylib/examples/Makefile.Android +1 -1
- package/vendor/raylib/examples/Makefile.Web +145 -158
- package/vendor/raylib/examples/README.md +141 -141
- package/vendor/raylib/examples/audio/audio_module_playing.c +9 -4
- package/vendor/raylib/examples/audio/audio_multichannel_sound.c +8 -3
- package/vendor/raylib/examples/audio/audio_music_stream.c +16 -11
- package/vendor/raylib/examples/audio/audio_raw_stream.c +57 -9
- package/vendor/raylib/examples/audio/audio_sound_loading.c +8 -3
- package/vendor/raylib/examples/audio/audio_stream_effects.c +179 -0
- package/vendor/raylib/examples/audio/audio_stream_effects.png +0 -0
- package/vendor/raylib/examples/build.zig +17 -6
- package/vendor/raylib/examples/core/core_2d_camera.c +8 -4
- package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.c +105 -0
- package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.png +0 -0
- package/vendor/raylib/examples/core/core_2d_camera_platformer.c +11 -6
- package/vendor/raylib/examples/core/core_3d_camera_first_person.c +9 -4
- package/vendor/raylib/examples/core/core_3d_camera_free.c +9 -4
- package/vendor/raylib/examples/core/core_3d_camera_mode.c +8 -3
- package/vendor/raylib/examples/core/core_3d_picking.c +9 -4
- package/vendor/raylib/examples/core/core_basic_screen_manager.c +9 -7
- package/vendor/raylib/examples/core/core_basic_window.c +8 -3
- package/vendor/raylib/examples/core/core_basic_window_web.c +13 -11
- package/vendor/raylib/examples/core/core_custom_frame_control.c +9 -4
- package/vendor/raylib/examples/core/core_custom_logging.c +12 -8
- package/vendor/raylib/examples/core/core_drop_files.c +20 -12
- package/vendor/raylib/examples/core/core_input_gamepad.c +20 -15
- package/vendor/raylib/examples/core/core_input_gestures.c +19 -15
- package/vendor/raylib/examples/core/core_input_keys.c +8 -3
- package/vendor/raylib/examples/core/core_input_mouse.c +8 -3
- package/vendor/raylib/examples/core/core_input_mouse_wheel.c +8 -3
- package/vendor/raylib/examples/core/core_input_multitouch.c +8 -3
- package/vendor/raylib/examples/core/core_loading_thread.c +10 -6
- package/vendor/raylib/examples/core/core_random_values.c +8 -3
- package/vendor/raylib/examples/core/core_scissor_test.c +8 -3
- package/vendor/raylib/examples/core/core_smooth_pixelperfect.c +9 -4
- package/vendor/raylib/examples/core/core_split_screen.c +8 -3
- package/vendor/raylib/examples/core/core_storage_values.c +109 -3
- package/vendor/raylib/examples/core/core_vr_simulator.c +15 -7
- package/vendor/raylib/examples/core/core_window_flags.c +8 -3
- package/vendor/raylib/examples/core/core_window_letterbox.c +13 -18
- package/vendor/raylib/examples/core/core_window_should_close.c +77 -0
- package/vendor/raylib/examples/core/core_window_should_close.png +0 -0
- package/vendor/raylib/examples/core/core_world_screen.c +9 -4
- package/vendor/raylib/examples/examples_template.c +8 -3
- package/vendor/raylib/examples/models/models_animation.c +11 -7
- package/vendor/raylib/examples/models/models_billboard.c +9 -4
- package/vendor/raylib/examples/models/models_box_collisions.c +8 -3
- package/vendor/raylib/examples/models/models_cubicmap.c +9 -4
- package/vendor/raylib/examples/models/models_first_person_maze.c +9 -4
- package/vendor/raylib/examples/models/models_geometric_shapes.c +8 -3
- package/vendor/raylib/examples/models/models_heightmap.c +9 -4
- package/vendor/raylib/examples/models/models_loading.c +21 -17
- package/vendor/raylib/examples/models/models_loading_gltf.c +15 -41
- package/vendor/raylib/examples/models/models_loading_vox.c +9 -4
- package/vendor/raylib/examples/models/models_mesh_generation.c +71 -58
- package/vendor/raylib/examples/models/models_mesh_picking.c +25 -7
- package/vendor/raylib/examples/models/models_orthographic_projection.c +8 -5
- package/vendor/raylib/examples/models/models_rlgl_solar_system.c +6 -4
- package/vendor/raylib/examples/models/models_skybox.c +16 -12
- package/vendor/raylib/examples/models/models_waving_cubes.c +9 -4
- package/vendor/raylib/examples/models/models_yaw_pitch_roll.c +12 -7
- package/vendor/raylib/examples/models/resources/LICENSE.md +9 -10
- package/vendor/raylib/examples/models/resources/models/gltf/LICENSE +2 -23
- package/vendor/raylib/examples/models/resources/models/gltf/{raylib_32x32.glb → raylib_logo_3d.glb} +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/robot.blend +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/robot.glb +0 -0
- package/vendor/raylib/examples/others/easings_testbed.c +10 -8
- package/vendor/raylib/examples/others/easings_testbed.png +0 -0
- package/vendor/raylib/examples/others/embedded_files_loading.c +10 -5
- package/vendor/raylib/examples/others/embedded_files_loading.png +0 -0
- package/vendor/raylib/examples/others/raylib_opengl_interop.c +10 -6
- package/vendor/raylib/{src/extras/easings.h → examples/others/reasings.h} +38 -38
- package/vendor/raylib/examples/others/rlgl_compute_shader.c +21 -20
- package/vendor/raylib/examples/others/rlgl_compute_shader.png +0 -0
- package/vendor/raylib/examples/others/rlgl_standalone.c +4 -4
- package/vendor/raylib/examples/others/rlgl_standalone.png +0 -0
- package/vendor/raylib/examples/raylib_compile_execute.bat +2 -2
- package/vendor/raylib/examples/shaders/resources/shaders/glsl330/lighting.fs +1 -1
- package/vendor/raylib/examples/shaders/resources/shaders/glsl330/{base_lighting_instanced.vs → lighting_instancing.vs} +2 -2
- package/vendor/raylib/examples/shaders/rlights.h +14 -27
- package/vendor/raylib/examples/shaders/shaders_basic_lighting.c +24 -26
- package/vendor/raylib/examples/shaders/shaders_custom_uniform.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_eratosthenes.c +13 -8
- package/vendor/raylib/examples/shaders/shaders_fog.c +8 -12
- package/vendor/raylib/examples/shaders/shaders_hot_reloading.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_julia_set.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_mesh_instancing.c +45 -119
- package/vendor/raylib/examples/shaders/shaders_model_shader.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_multi_sample2d.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_palette_switch.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_postprocessing.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_raymarching.c +14 -11
- package/vendor/raylib/examples/shaders/shaders_shapes_textures.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_simple_mask.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_spotlight.c +10 -6
- package/vendor/raylib/examples/shaders/shaders_texture_drawing.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_texture_outline.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_texture_waves.c +8 -3
- package/vendor/raylib/{src/extras → examples/shapes}/raygui.h +1290 -1141
- package/vendor/raylib/examples/{others/easings.h → shapes/reasings.h} +40 -40
- package/vendor/raylib/examples/shapes/shapes_basic_shapes.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_bouncing_ball.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_collision_area.c +10 -4
- package/vendor/raylib/examples/shapes/shapes_colors_palette.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_draw_circle_sector.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_draw_rectangle_rounded.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_draw_ring.c +10 -6
- package/vendor/raylib/examples/shapes/shapes_easings_ball_anim.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_easings_box_anim.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_easings_rectangle_array.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_following_eyes.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_lines_bezier.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_logo_raylib.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_logo_raylib_anim.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_rectangle_scaling.c +14 -5
- package/vendor/raylib/examples/shapes/shapes_top_down_lights.c +355 -0
- package/vendor/raylib/examples/shapes/shapes_top_down_lights.png +0 -0
- package/vendor/raylib/examples/text/resources/DotGothic16-Regular.ttf +0 -0
- package/vendor/raylib/examples/text/resources/DotGothic16-Regular_OFL.txt +93 -0
- package/vendor/raylib/examples/text/resources/LICENSE.md +1 -1
- package/vendor/raylib/examples/text/text_codepoints_loading.c +138 -0
- package/vendor/raylib/examples/text/text_codepoints_loading.png +0 -0
- package/vendor/raylib/examples/text/text_draw_3d.c +42 -33
- package/vendor/raylib/examples/text/text_font_filters.c +14 -11
- package/vendor/raylib/examples/text/text_font_loading.c +9 -4
- package/vendor/raylib/examples/text/text_font_sdf.c +9 -4
- package/vendor/raylib/examples/text/text_font_spritefont.c +12 -6
- package/vendor/raylib/examples/text/text_format_text.c +8 -3
- package/vendor/raylib/examples/text/text_input_box.c +8 -3
- package/vendor/raylib/examples/text/text_raylib_fonts.c +9 -4
- package/vendor/raylib/examples/text/text_rectangle_bounds.c +9 -5
- package/vendor/raylib/examples/text/text_unicode.c +9 -7
- package/vendor/raylib/examples/text/text_writing_anim.c +8 -3
- package/vendor/raylib/examples/textures/resources/scarfy_run.gif +0 -0
- package/vendor/raylib/examples/textures/textures_background_scrolling.c +8 -3
- package/vendor/raylib/examples/textures/textures_blend_modes.c +8 -3
- package/vendor/raylib/examples/textures/textures_bunnymark.c +8 -3
- package/vendor/raylib/examples/textures/textures_draw_tiled.c +14 -10
- package/vendor/raylib/examples/textures/textures_fog_of_war.c +154 -0
- package/vendor/raylib/examples/textures/textures_fog_of_war.png +0 -0
- package/vendor/raylib/examples/textures/textures_gif_player.c +121 -0
- package/vendor/raylib/examples/textures/textures_gif_player.png +0 -0
- package/vendor/raylib/examples/textures/textures_image_drawing.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_generation.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_loading.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_processing.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_text.c +8 -3
- package/vendor/raylib/examples/textures/textures_logo_raylib.c +8 -3
- package/vendor/raylib/examples/textures/textures_mouse_painting.c +9 -4
- package/vendor/raylib/examples/textures/textures_npatch_drawing.c +8 -3
- package/vendor/raylib/examples/textures/textures_particles_blending.c +8 -3
- package/vendor/raylib/examples/textures/textures_polygon.c +9 -5
- package/vendor/raylib/examples/textures/textures_raw_data.c +8 -3
- package/vendor/raylib/examples/textures/{textures_rectangle.c → textures_sprite_anim.c} +11 -5
- package/vendor/raylib/examples/textures/{textures_rectangle.png → textures_sprite_anim.png} +0 -0
- package/vendor/raylib/examples/textures/textures_sprite_button.c +8 -3
- package/vendor/raylib/examples/textures/textures_sprite_explosion.c +8 -3
- package/vendor/raylib/examples/textures/textures_srcrec_dstrec.c +8 -3
- package/vendor/raylib/examples/textures/textures_to_image.c +8 -3
- package/vendor/raylib/parser/LICENSE +1 -1
- package/vendor/raylib/parser/Makefile +28 -0
- package/vendor/raylib/parser/README.md +49 -5
- package/vendor/raylib/parser/output/raylib_api.json +10717 -0
- package/vendor/raylib/parser/output/raylib_api.lua +7435 -0
- package/vendor/raylib/parser/{raylib_api.txt → output/raylib_api.txt} +1371 -824
- package/vendor/raylib/parser/{raylib_api.xml → output/raylib_api.xml} +827 -595
- package/vendor/raylib/parser/raylib_parser.c +1174 -196
- package/vendor/raylib/projects/4coder/Makefile +2 -4
- package/vendor/raylib/projects/4coder/main.c +0 -1
- package/vendor/raylib/projects/CMake/CMakeLists.txt +13 -16
- package/vendor/raylib/projects/CMake/README.md +27 -0
- package/vendor/raylib/projects/CMake/core_basic_window.c +52 -31
- package/vendor/raylib/projects/CodeBlocks/README.md +4 -4
- package/vendor/raylib/projects/Geany/core_basic_window.c +1 -1
- package/vendor/raylib/projects/Notepad++/c_raylib.xml +168 -128
- package/vendor/raylib/projects/Notepad++/npes_saved_tcc.txt +0 -0
- package/vendor/raylib/projects/Notepad++/npes_saved_w64devkit.txt +0 -0
- package/vendor/raylib/projects/Notepad++/npes_saved_zig.txt +0 -0
- package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_npp.xml +168 -84
- package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +67 -51
- package/vendor/raylib/projects/README.md +1 -1
- package/vendor/raylib/projects/VSCode/.vscode/c_cpp_properties.json +1 -1
- package/vendor/raylib/projects/VSCode/Makefile +8 -11
- package/vendor/raylib/projects/VSCode/main.c +53 -26
- package/vendor/raylib/projects/VSCode/resources/LICENSE +1 -0
- package/vendor/raylib/projects/scripts/build-linux.sh +6 -6
- package/vendor/raylib/projects/scripts/build-osx.sh +6 -6
- package/vendor/raylib/projects/scripts/build-rpi.sh +6 -6
- package/vendor/raylib/projects/scripts/build-windows.bat +2 -2
- package/vendor/raylib/src/CMakeLists.txt +6 -7
- package/vendor/raylib/src/Makefile +209 -103
- package/vendor/raylib/src/build.zig +56 -20
- package/vendor/raylib/src/config.h +32 -27
- package/vendor/raylib/src/external/cgltf.h +342 -104
- package/vendor/raylib/src/external/dr_wav.h +487 -225
- package/vendor/raylib/src/external/glfw/src/posix_time.c +1 -3
- package/vendor/raylib/src/external/glfw/src/wl_init.c +1 -3
- package/vendor/raylib/src/external/jar_xm.h +2 -1
- package/vendor/raylib/src/external/miniaudio.h +62251 -42061
- package/vendor/raylib/src/external/qoi.h +671 -0
- package/vendor/raylib/src/external/stb_vorbis.h +1 -1
- package/vendor/raylib/src/external/vox_loader.h +30 -25
- package/vendor/raylib/src/minshell.html +82 -0
- package/vendor/raylib/src/raudio.c +359 -201
- package/vendor/raylib/src/raylib.dll.rc +5 -5
- package/vendor/raylib/src/raylib.dll.rc.data +0 -0
- package/vendor/raylib/src/raylib.h +95 -63
- package/vendor/raylib/src/raylib.rc +5 -5
- package/vendor/raylib/src/raylib.rc.data +0 -0
- package/vendor/raylib/src/raymath.h +391 -133
- package/vendor/raylib/src/rcamera.h +32 -41
- package/vendor/raylib/src/rcore.c +775 -471
- package/vendor/raylib/src/rgestures.h +5 -5
- package/vendor/raylib/src/rglfw.c +3 -3
- package/vendor/raylib/src/rlgl.h +184 -144
- package/vendor/raylib/src/rmodels.c +207 -144
- package/vendor/raylib/src/rshapes.c +105 -47
- package/vendor/raylib/src/rtext.c +255 -38
- package/vendor/raylib/src/rtextures.c +167 -71
- package/vendor/raylib/src/shell.html +63 -63
- package/vendor/raylib/src/utils.c +49 -3
- package/vendor/raylib/src/utils.h +3 -3
- package/build/qemu/2.1.1/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_x64.tar.gz +0 -0
- package/vendor/raylib/CONTRIBUTORS.md +0 -63
- package/vendor/raylib/SPONSORS.md +0 -68
- package/vendor/raylib/examples/core/core_quat_conversion.c +0 -132
- package/vendor/raylib/examples/core/core_quat_conversion.png +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/AnimatedMorphCube.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/AnimatedTriangle.gltf +0 -118
- package/vendor/raylib/examples/models/resources/models/gltf/BoxAnimated.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/girl.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/rigged_figure.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/vertex_colored_object.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/iqm/vertex_colored_object.iqm +0 -0
- package/vendor/raylib/examples/models/rlights.h +0 -183
- package/vendor/raylib/examples/others/raudio_standalone.c +0 -152
- package/vendor/raylib/examples/others/resources/audio/country.mp3 +0 -0
- package/vendor/raylib/examples/others/resources/audio/target.ogg +0 -0
- package/vendor/raylib/examples/others/resources/audio/weird.wav +0 -0
- package/vendor/raylib/examples/physics/physics_demo.c +0 -128
- package/vendor/raylib/examples/physics/physics_demo.png +0 -0
- package/vendor/raylib/examples/physics/physics_friction.c +0 -142
- package/vendor/raylib/examples/physics/physics_friction.png +0 -0
- package/vendor/raylib/examples/physics/physics_movement.c +0 -128
- package/vendor/raylib/examples/physics/physics_movement.png +0 -0
- package/vendor/raylib/examples/physics/physics_restitution.c +0 -129
- package/vendor/raylib/examples/physics/physics_restitution.png +0 -0
- package/vendor/raylib/examples/physics/physics_shatter.c +0 -111
- package/vendor/raylib/examples/physics/physics_shatter.png +0 -0
- package/vendor/raylib/parser/raylib_api.json +0 -6668
- package/vendor/raylib/projects/VS2019/raylib/raylib.rc +0 -0
- package/vendor/raylib/projects/VS2019/raylib/resource.h +0 -14
- package/vendor/raylib/src/extras/physac.h +0 -1977
- package/vendor/raylib/src/extras/rmem.h +0 -751
- package/vendor/raylib/src/raudio.h +0 -198
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
*
|
|
3
3
|
* raylib [audio] example - Raw audio streaming
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
5
|
+
* Example originally created with raylib 1.6, last time updated with raylib 4.2
|
|
7
6
|
*
|
|
8
7
|
* Example created by Ramon Santamaria (@raysan5) and reviewed by James Hofmann (@triplefox)
|
|
9
8
|
*
|
|
10
|
-
*
|
|
9
|
+
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
10
|
+
* BSD-like license that allows static linking with closed source software
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox)
|
|
11
13
|
*
|
|
12
14
|
********************************************************************************************/
|
|
13
15
|
|
|
@@ -20,6 +22,38 @@
|
|
|
20
22
|
#define MAX_SAMPLES 512
|
|
21
23
|
#define MAX_SAMPLES_PER_UPDATE 4096
|
|
22
24
|
|
|
25
|
+
// Cycles per second (hz)
|
|
26
|
+
float frequency = 440.0f;
|
|
27
|
+
|
|
28
|
+
// Audio frequency, for smoothing
|
|
29
|
+
float audioFrequency = 440.0f;
|
|
30
|
+
|
|
31
|
+
// Previous value, used to test if sine needs to be rewritten, and to smoothly modulate frequency
|
|
32
|
+
float oldFrequency = 1.0f;
|
|
33
|
+
|
|
34
|
+
// Index for audio rendering
|
|
35
|
+
float sineIdx = 0.0f;
|
|
36
|
+
|
|
37
|
+
// Audio input processing callback
|
|
38
|
+
void AudioInputCallback(void *buffer, unsigned int frames)
|
|
39
|
+
{
|
|
40
|
+
audioFrequency = frequency + (audioFrequency - frequency)*0.95f;
|
|
41
|
+
audioFrequency += 1.0f;
|
|
42
|
+
audioFrequency -= 1.0f;
|
|
43
|
+
float incr = audioFrequency/44100.0f;
|
|
44
|
+
short *d = (short *)buffer;
|
|
45
|
+
|
|
46
|
+
for (int i = 0; i < frames; i++)
|
|
47
|
+
{
|
|
48
|
+
d[i] = (short)(32000.0f*sinf(2*PI*sineIdx));
|
|
49
|
+
sineIdx += incr;
|
|
50
|
+
if (sineIdx > 1.0f) sineIdx -= 1.0f;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//------------------------------------------------------------------------------------
|
|
55
|
+
// Program main entry point
|
|
56
|
+
//------------------------------------------------------------------------------------
|
|
23
57
|
int main(void)
|
|
24
58
|
{
|
|
25
59
|
// Initialization
|
|
@@ -33,9 +67,11 @@ int main(void)
|
|
|
33
67
|
|
|
34
68
|
SetAudioStreamBufferSizeDefault(MAX_SAMPLES_PER_UPDATE);
|
|
35
69
|
|
|
36
|
-
// Init raw audio stream (sample rate:
|
|
70
|
+
// Init raw audio stream (sample rate: 44100, sample size: 16bit-short, channels: 1-mono)
|
|
37
71
|
AudioStream stream = LoadAudioStream(44100, 16, 1);
|
|
38
72
|
|
|
73
|
+
SetAudioStreamCallback(stream, AudioInputCallback);
|
|
74
|
+
|
|
39
75
|
// Buffer for the single cycle waveform we are synthesizing
|
|
40
76
|
short *data = (short *)malloc(sizeof(short)*MAX_SAMPLES);
|
|
41
77
|
|
|
@@ -47,6 +83,7 @@ int main(void)
|
|
|
47
83
|
// Position read in to determine next frequency
|
|
48
84
|
Vector2 mousePosition = { -100.0f, -100.0f };
|
|
49
85
|
|
|
86
|
+
/*
|
|
50
87
|
// Cycles per second (hz)
|
|
51
88
|
float frequency = 440.0f;
|
|
52
89
|
|
|
@@ -55,6 +92,7 @@ int main(void)
|
|
|
55
92
|
|
|
56
93
|
// Cursor to read and copy the samples of the sine wave buffer
|
|
57
94
|
int readCursor = 0;
|
|
95
|
+
*/
|
|
58
96
|
|
|
59
97
|
// Computed size in samples of the sine wave
|
|
60
98
|
int waveLength = 1;
|
|
@@ -77,29 +115,38 @@ int main(void)
|
|
|
77
115
|
{
|
|
78
116
|
float fp = (float)(mousePosition.y);
|
|
79
117
|
frequency = 40.0f + (float)(fp);
|
|
118
|
+
|
|
119
|
+
float pan = (float)(mousePosition.x) / (float)screenWidth;
|
|
120
|
+
SetAudioStreamPan(stream, pan);
|
|
80
121
|
}
|
|
81
122
|
|
|
82
|
-
// Rewrite the sine wave
|
|
123
|
+
// Rewrite the sine wave
|
|
83
124
|
// Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc.
|
|
84
125
|
if (frequency != oldFrequency)
|
|
85
126
|
{
|
|
86
127
|
// Compute wavelength. Limit size in both directions.
|
|
87
|
-
int oldWavelength = waveLength;
|
|
128
|
+
//int oldWavelength = waveLength;
|
|
88
129
|
waveLength = (int)(22050/frequency);
|
|
89
130
|
if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2;
|
|
90
131
|
if (waveLength < 1) waveLength = 1;
|
|
91
132
|
|
|
92
|
-
// Write sine wave
|
|
133
|
+
// Write sine wave
|
|
93
134
|
for (int i = 0; i < waveLength*2; i++)
|
|
94
135
|
{
|
|
95
136
|
data[i] = (short)(sinf(((2*PI*(float)i/waveLength)))*32000);
|
|
96
137
|
}
|
|
138
|
+
// Make sure the rest of the line is flat
|
|
139
|
+
for (int j = waveLength*2; j < MAX_SAMPLES; j++)
|
|
140
|
+
{
|
|
141
|
+
data[j] = (short)0;
|
|
142
|
+
}
|
|
97
143
|
|
|
98
144
|
// Scale read cursor's position to minimize transition artifacts
|
|
99
|
-
readCursor = (int)(readCursor * ((float)waveLength / (float)oldWavelength));
|
|
145
|
+
//readCursor = (int)(readCursor * ((float)waveLength / (float)oldWavelength));
|
|
100
146
|
oldFrequency = frequency;
|
|
101
147
|
}
|
|
102
148
|
|
|
149
|
+
/*
|
|
103
150
|
// Refill audio stream if required
|
|
104
151
|
if (IsAudioStreamProcessed(stream))
|
|
105
152
|
{
|
|
@@ -128,6 +175,7 @@ int main(void)
|
|
|
128
175
|
// Copy finished frame to audio stream
|
|
129
176
|
UpdateAudioStream(stream, writeBuf, MAX_SAMPLES_PER_UPDATE);
|
|
130
177
|
}
|
|
178
|
+
*/
|
|
131
179
|
//----------------------------------------------------------------------------------
|
|
132
180
|
|
|
133
181
|
// Draw
|
|
@@ -137,7 +185,7 @@ int main(void)
|
|
|
137
185
|
ClearBackground(RAYWHITE);
|
|
138
186
|
|
|
139
187
|
DrawText(TextFormat("sine frequency: %i",(int)frequency), GetScreenWidth() - 220, 10, 20, RED);
|
|
140
|
-
DrawText("click mouse button to change frequency", 10, 10, 20, DARKGRAY);
|
|
188
|
+
DrawText("click mouse button to change frequency or pan", 10, 10, 20, DARKGRAY);
|
|
141
189
|
|
|
142
190
|
// Draw the current buffer state proportionate to the screen
|
|
143
191
|
for (int i = 0; i < screenWidth; i++)
|
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
*
|
|
3
3
|
* raylib [audio] example - Sound loading and playing
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
5
|
+
* Example originally created with raylib 1.1, last time updated with raylib 3.5
|
|
7
6
|
*
|
|
8
|
-
*
|
|
7
|
+
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
8
|
+
* BSD-like license that allows static linking with closed source software
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
|
|
9
11
|
*
|
|
10
12
|
********************************************************************************************/
|
|
11
13
|
|
|
12
14
|
#include "raylib.h"
|
|
13
15
|
|
|
16
|
+
//------------------------------------------------------------------------------------
|
|
17
|
+
// Program main entry point
|
|
18
|
+
//------------------------------------------------------------------------------------
|
|
14
19
|
int main(void)
|
|
15
20
|
{
|
|
16
21
|
// Initialization
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*******************************************************************************************
|
|
2
|
+
*
|
|
3
|
+
* raylib [audio] example - Music stream processing effects
|
|
4
|
+
*
|
|
5
|
+
* Example originally created with raylib 4.2, last time updated with raylib 4.2
|
|
6
|
+
*
|
|
7
|
+
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
8
|
+
* BSD-like license that allows static linking with closed source software
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2022 Ramon Santamaria (@raysan5)
|
|
11
|
+
*
|
|
12
|
+
********************************************************************************************/
|
|
13
|
+
|
|
14
|
+
#include "raylib.h"
|
|
15
|
+
|
|
16
|
+
#include <stdlib.h> // Required for: NULL
|
|
17
|
+
|
|
18
|
+
// Required delay effect variables
|
|
19
|
+
static float *delayBuffer = NULL;
|
|
20
|
+
static unsigned int delayBufferSize = 0;
|
|
21
|
+
static unsigned int delayReadIndex = 2;
|
|
22
|
+
static unsigned int delayWriteIndex = 0;
|
|
23
|
+
|
|
24
|
+
//------------------------------------------------------------------------------------
|
|
25
|
+
// Module Functions Declaration
|
|
26
|
+
//------------------------------------------------------------------------------------
|
|
27
|
+
static void AudioProcessEffectLPF(void *buffer, unsigned int frames); // Audio effect: lowpass filter
|
|
28
|
+
static void AudioProcessEffectDelay(void *buffer, unsigned int frames); // Audio effect: delay
|
|
29
|
+
|
|
30
|
+
//------------------------------------------------------------------------------------
|
|
31
|
+
// Program main entry point
|
|
32
|
+
//------------------------------------------------------------------------------------
|
|
33
|
+
int main(void)
|
|
34
|
+
{
|
|
35
|
+
// Initialization
|
|
36
|
+
//--------------------------------------------------------------------------------------
|
|
37
|
+
const int screenWidth = 800;
|
|
38
|
+
const int screenHeight = 450;
|
|
39
|
+
|
|
40
|
+
InitWindow(screenWidth, screenHeight, "raylib [audio] example - stream effects");
|
|
41
|
+
|
|
42
|
+
InitAudioDevice(); // Initialize audio device
|
|
43
|
+
|
|
44
|
+
Music music = LoadMusicStream("resources/country.mp3");
|
|
45
|
+
|
|
46
|
+
// Allocate buffer for the delay effect
|
|
47
|
+
delayBufferSize = 48000*2; // 1 second delay (device sampleRate*channels)
|
|
48
|
+
delayBuffer = (float *)RL_CALLOC(delayBufferSize, sizeof(float));
|
|
49
|
+
|
|
50
|
+
PlayMusicStream(music);
|
|
51
|
+
|
|
52
|
+
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
|
|
53
|
+
bool pause = false; // Music playing paused
|
|
54
|
+
|
|
55
|
+
bool enableEffectLPF = false; // Enable effect low-pass-filter
|
|
56
|
+
bool enableEffectDelay = false; // Enable effect delay (1 second)
|
|
57
|
+
|
|
58
|
+
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
59
|
+
//--------------------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
// Main game loop
|
|
62
|
+
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
63
|
+
{
|
|
64
|
+
// Update
|
|
65
|
+
//----------------------------------------------------------------------------------
|
|
66
|
+
UpdateMusicStream(music); // Update music buffer with new stream data
|
|
67
|
+
|
|
68
|
+
// Restart music playing (stop and play)
|
|
69
|
+
if (IsKeyPressed(KEY_SPACE))
|
|
70
|
+
{
|
|
71
|
+
StopMusicStream(music);
|
|
72
|
+
PlayMusicStream(music);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Pause/Resume music playing
|
|
76
|
+
if (IsKeyPressed(KEY_P))
|
|
77
|
+
{
|
|
78
|
+
pause = !pause;
|
|
79
|
+
|
|
80
|
+
if (pause) PauseMusicStream(music);
|
|
81
|
+
else ResumeMusicStream(music);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Add/Remove effect: lowpass filter
|
|
85
|
+
if (IsKeyPressed(KEY_F))
|
|
86
|
+
{
|
|
87
|
+
enableEffectLPF = !enableEffectLPF;
|
|
88
|
+
if (enableEffectLPF) AttachAudioStreamProcessor(music.stream, AudioProcessEffectLPF);
|
|
89
|
+
else DetachAudioStreamProcessor(music.stream, AudioProcessEffectLPF);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Add/Remove effect: delay
|
|
93
|
+
if (IsKeyPressed(KEY_D))
|
|
94
|
+
{
|
|
95
|
+
enableEffectDelay = !enableEffectDelay;
|
|
96
|
+
if (enableEffectDelay) AttachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
|
|
97
|
+
else DetachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Get normalized time played for current music stream
|
|
101
|
+
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music);
|
|
102
|
+
|
|
103
|
+
if (timePlayed > 1.0f) timePlayed = 1.0f; // Make sure time played is no longer than music
|
|
104
|
+
//----------------------------------------------------------------------------------
|
|
105
|
+
|
|
106
|
+
// Draw
|
|
107
|
+
//----------------------------------------------------------------------------------
|
|
108
|
+
BeginDrawing();
|
|
109
|
+
|
|
110
|
+
ClearBackground(RAYWHITE);
|
|
111
|
+
|
|
112
|
+
DrawText("MUSIC SHOULD BE PLAYING!", 245, 150, 20, LIGHTGRAY);
|
|
113
|
+
|
|
114
|
+
DrawRectangle(200, 180, 400, 12, LIGHTGRAY);
|
|
115
|
+
DrawRectangle(200, 180, (int)(timePlayed*400.0f), 12, MAROON);
|
|
116
|
+
DrawRectangleLines(200, 180, 400, 12, GRAY);
|
|
117
|
+
|
|
118
|
+
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 230, 20, LIGHTGRAY);
|
|
119
|
+
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 260, 20, LIGHTGRAY);
|
|
120
|
+
|
|
121
|
+
DrawText(TextFormat("PRESS F TO TOGGLE LPF EFFECT: %s", enableEffectLPF? "ON" : "OFF"), 200, 320, 20, GRAY);
|
|
122
|
+
DrawText(TextFormat("PRESS D TO TOGGLE DELAY EFFECT: %s", enableEffectDelay? "ON" : "OFF"), 180, 350, 20, GRAY);
|
|
123
|
+
|
|
124
|
+
EndDrawing();
|
|
125
|
+
//----------------------------------------------------------------------------------
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// De-Initialization
|
|
129
|
+
//--------------------------------------------------------------------------------------
|
|
130
|
+
UnloadMusicStream(music); // Unload music stream buffers from RAM
|
|
131
|
+
|
|
132
|
+
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
|
|
133
|
+
|
|
134
|
+
RL_FREE(delayBuffer); // Free delay buffer
|
|
135
|
+
|
|
136
|
+
CloseWindow(); // Close window and OpenGL context
|
|
137
|
+
//--------------------------------------------------------------------------------------
|
|
138
|
+
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//------------------------------------------------------------------------------------
|
|
143
|
+
// Module Functions Definition
|
|
144
|
+
//------------------------------------------------------------------------------------
|
|
145
|
+
// Audio effect: lowpass filter
|
|
146
|
+
static void AudioProcessEffectLPF(void *buffer, unsigned int frames)
|
|
147
|
+
{
|
|
148
|
+
static float low[2] = { 0.0f, 0.0f };
|
|
149
|
+
static const float cutoff = 70.0f / 44100.0f; // 70 Hz lowpass filter
|
|
150
|
+
const float k = cutoff / (cutoff + 0.1591549431f); // RC filter formula
|
|
151
|
+
|
|
152
|
+
for (unsigned int i = 0; i < frames*2; i += 2)
|
|
153
|
+
{
|
|
154
|
+
float l = ((float *)buffer)[i], r = ((float *)buffer)[i + 1];
|
|
155
|
+
low[0] += k * (l - low[0]);
|
|
156
|
+
low[1] += k * (r - low[1]);
|
|
157
|
+
((float *)buffer)[i] = low[0];
|
|
158
|
+
((float *)buffer)[i + 1] = low[1];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Audio effect: delay
|
|
163
|
+
static void AudioProcessEffectDelay(void *buffer, unsigned int frames)
|
|
164
|
+
{
|
|
165
|
+
for (unsigned int i = 0; i < frames*2; i += 2)
|
|
166
|
+
{
|
|
167
|
+
float leftDelay = delayBuffer[delayReadIndex++]; // ERROR: Reading buffer -> WHY??? Maybe thread related???
|
|
168
|
+
float rightDelay = delayBuffer[delayReadIndex++];
|
|
169
|
+
|
|
170
|
+
if (delayReadIndex == delayBufferSize) delayReadIndex = 0;
|
|
171
|
+
|
|
172
|
+
((float *)buffer)[i] = 0.5f*((float *)buffer)[i] + 0.5f*leftDelay;
|
|
173
|
+
((float *)buffer)[i + 1] = 0.5f*((float *)buffer)[i + 1] + 0.5f*rightDelay;
|
|
174
|
+
|
|
175
|
+
delayBuffer[delayWriteIndex++] = ((float *)buffer)[i];
|
|
176
|
+
delayBuffer[delayWriteIndex++] = ((float *)buffer)[i + 1];
|
|
177
|
+
if (delayWriteIndex == delayBufferSize) delayWriteIndex = 0;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
Binary file
|
|
@@ -7,10 +7,7 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
|
|
|
7
7
|
const mode = b.standardReleaseOptions();
|
|
8
8
|
|
|
9
9
|
const all = b.step(module, "All " ++ module ++ " examples");
|
|
10
|
-
const dir = try std.fs.cwd().
|
|
11
|
-
module,
|
|
12
|
-
.{ .iterate = true },
|
|
13
|
-
);
|
|
10
|
+
const dir = try std.fs.cwd().openIterableDir(module, .{});
|
|
14
11
|
var iter = dir.iterate();
|
|
15
12
|
while (try iter.next()) |entry| {
|
|
16
13
|
if (entry.kind != .File) continue;
|
|
@@ -21,13 +18,20 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
|
|
|
21
18
|
// zig's mingw headers do not include pthread.h
|
|
22
19
|
if (std.mem.eql(u8, "core_loading_thread", name) and target.getOsTag() == .windows) continue;
|
|
23
20
|
|
|
24
|
-
const exe = b.addExecutable(name,
|
|
21
|
+
const exe = b.addExecutable(name, null);
|
|
22
|
+
exe.addCSourceFile(path, switch (target.getOsTag()) {
|
|
23
|
+
.windows => &[_][]const u8{},
|
|
24
|
+
.linux => &[_][]const u8{},
|
|
25
|
+
.macos => &[_][]const u8{"-DPLATFORM_DESKTOP"},
|
|
26
|
+
else => @panic("Unsupported OS"),
|
|
27
|
+
});
|
|
25
28
|
exe.setTarget(target);
|
|
26
29
|
exe.setBuildMode(mode);
|
|
27
30
|
exe.linkLibC();
|
|
28
31
|
exe.addObjectFile(switch (target.getOsTag()) {
|
|
29
32
|
.windows => "../src/raylib.lib",
|
|
30
33
|
.linux => "../src/libraylib.a",
|
|
34
|
+
.macos => "../src/libraylib.a",
|
|
31
35
|
else => @panic("Unsupported OS"),
|
|
32
36
|
});
|
|
33
37
|
|
|
@@ -49,6 +53,14 @@ fn add_module(comptime module: []const u8, b: *std.build.Builder, target: std.zi
|
|
|
49
53
|
exe.linkSystemLibrary("m");
|
|
50
54
|
exe.linkSystemLibrary("X11");
|
|
51
55
|
},
|
|
56
|
+
.macos => {
|
|
57
|
+
exe.linkFramework("Foundation");
|
|
58
|
+
exe.linkFramework("Cocoa");
|
|
59
|
+
exe.linkFramework("OpenGL");
|
|
60
|
+
exe.linkFramework("CoreAudio");
|
|
61
|
+
exe.linkFramework("CoreVideo");
|
|
62
|
+
exe.linkFramework("IOKit");
|
|
63
|
+
},
|
|
52
64
|
else => {
|
|
53
65
|
@panic("Unsupported OS");
|
|
54
66
|
},
|
|
@@ -78,7 +90,6 @@ pub fn build(b: *std.build.Builder) !void {
|
|
|
78
90
|
all.dependOn(try add_module("core", b, target));
|
|
79
91
|
all.dependOn(try add_module("models", b, target));
|
|
80
92
|
all.dependOn(try add_module("others", b, target));
|
|
81
|
-
all.dependOn(try add_module("physics", b, target));
|
|
82
93
|
all.dependOn(try add_module("shaders", b, target));
|
|
83
94
|
all.dependOn(try add_module("shapes", b, target));
|
|
84
95
|
all.dependOn(try add_module("text", b, target));
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
*
|
|
3
3
|
* raylib [core] example - 2d camera
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
5
|
+
* Example originally created with raylib 1.5, last time updated with raylib 3.0
|
|
7
6
|
*
|
|
8
|
-
*
|
|
7
|
+
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
8
|
+
* BSD-like license that allows static linking with closed source software
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2016-2022 Ramon Santamaria (@raysan5)
|
|
9
11
|
*
|
|
10
12
|
********************************************************************************************/
|
|
11
13
|
|
|
@@ -13,6 +15,9 @@
|
|
|
13
15
|
|
|
14
16
|
#define MAX_BUILDINGS 100
|
|
15
17
|
|
|
18
|
+
//------------------------------------------------------------------------------------
|
|
19
|
+
// Program main entry point
|
|
20
|
+
//------------------------------------------------------------------------------------
|
|
16
21
|
int main(void)
|
|
17
22
|
{
|
|
18
23
|
// Initialization
|
|
@@ -54,7 +59,6 @@ int main(void)
|
|
|
54
59
|
{
|
|
55
60
|
// Update
|
|
56
61
|
//----------------------------------------------------------------------------------
|
|
57
|
-
|
|
58
62
|
// Player movement
|
|
59
63
|
if (IsKeyDown(KEY_RIGHT)) player.x += 2;
|
|
60
64
|
else if (IsKeyDown(KEY_LEFT)) player.x -= 2;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/*******************************************************************************************
|
|
2
|
+
*
|
|
3
|
+
* raylib [core] example - 2d camera mouse zoom
|
|
4
|
+
*
|
|
5
|
+
* Example originally created with raylib 4.2, last time updated with raylib 4.2
|
|
6
|
+
*
|
|
7
|
+
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
8
|
+
* BSD-like license that allows static linking with closed source software
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2022 Jeffery Myers (@JeffM2501)
|
|
11
|
+
*
|
|
12
|
+
********************************************************************************************/
|
|
13
|
+
|
|
14
|
+
#include "raylib.h"
|
|
15
|
+
|
|
16
|
+
#include "rlgl.h"
|
|
17
|
+
#include "raymath.h"
|
|
18
|
+
|
|
19
|
+
//------------------------------------------------------------------------------------
|
|
20
|
+
// Program main entry point
|
|
21
|
+
//------------------------------------------------------------------------------------
|
|
22
|
+
int main ()
|
|
23
|
+
{
|
|
24
|
+
// Initialization
|
|
25
|
+
//--------------------------------------------------------------------------------------
|
|
26
|
+
const int screenWidth = 800;
|
|
27
|
+
const int screenHeight = 450;
|
|
28
|
+
|
|
29
|
+
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera mouse zoom");
|
|
30
|
+
|
|
31
|
+
Camera2D camera = { 0 };
|
|
32
|
+
camera.zoom = 1.0f;
|
|
33
|
+
|
|
34
|
+
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
35
|
+
//--------------------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
// Main game loop
|
|
38
|
+
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
39
|
+
{
|
|
40
|
+
// Update
|
|
41
|
+
//----------------------------------------------------------------------------------
|
|
42
|
+
// Translate based on mouse right click
|
|
43
|
+
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
|
|
44
|
+
{
|
|
45
|
+
Vector2 delta = GetMouseDelta();
|
|
46
|
+
delta = Vector2Scale(delta, -1.0f/camera.zoom);
|
|
47
|
+
|
|
48
|
+
camera.target = Vector2Add(camera.target, delta);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Zoom based on mouse wheel
|
|
52
|
+
float wheel = GetMouseWheelMove();
|
|
53
|
+
if (wheel != 0)
|
|
54
|
+
{
|
|
55
|
+
// Get the world point that is under the mouse
|
|
56
|
+
Vector2 mouseWorldPos = GetScreenToWorld2D(GetMousePosition(), camera);
|
|
57
|
+
|
|
58
|
+
// Set the offset to where the mouse is
|
|
59
|
+
camera.offset = GetMousePosition();
|
|
60
|
+
|
|
61
|
+
// Set the target to match, so that the camera maps the world space point
|
|
62
|
+
// under the cursor to the screen space point under the cursor at any zoom
|
|
63
|
+
camera.target = mouseWorldPos;
|
|
64
|
+
|
|
65
|
+
// Zoom increment
|
|
66
|
+
const float zoomIncrement = 0.125f;
|
|
67
|
+
|
|
68
|
+
camera.zoom += (wheel*zoomIncrement);
|
|
69
|
+
if (camera.zoom < zoomIncrement) camera.zoom = zoomIncrement;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//----------------------------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
// Draw
|
|
75
|
+
//----------------------------------------------------------------------------------
|
|
76
|
+
BeginDrawing();
|
|
77
|
+
ClearBackground(BLACK);
|
|
78
|
+
|
|
79
|
+
BeginMode2D(camera);
|
|
80
|
+
|
|
81
|
+
// Draw the 3d grid, rotated 90 degrees and centered around 0,0
|
|
82
|
+
// just so we have something in the XY plane
|
|
83
|
+
rlPushMatrix();
|
|
84
|
+
rlTranslatef(0, 25*50, 0);
|
|
85
|
+
rlRotatef(90, 1, 0, 0);
|
|
86
|
+
DrawGrid(100, 50);
|
|
87
|
+
rlPopMatrix();
|
|
88
|
+
|
|
89
|
+
// Draw a reference circle
|
|
90
|
+
DrawCircle(100, 100, 50, YELLOW);
|
|
91
|
+
|
|
92
|
+
EndMode2D();
|
|
93
|
+
|
|
94
|
+
DrawText("Mouse right button drag to move, mouse wheel to zoom", 10, 10, 20, WHITE);
|
|
95
|
+
|
|
96
|
+
EndDrawing();
|
|
97
|
+
//----------------------------------------------------------------------------------
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// De-Initialization
|
|
101
|
+
//--------------------------------------------------------------------------------------
|
|
102
|
+
CloseWindow(); // Close window and OpenGL context
|
|
103
|
+
//--------------------------------------------------------------------------------------
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
Binary file
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
*
|
|
3
3
|
* raylib [core] example - 2d camera platformer
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
5
|
+
* Example originally created with raylib 2.5, last time updated with raylib 3.0
|
|
7
6
|
*
|
|
8
7
|
* Example contributed by arvyy (@arvyy) and reviewed by Ramon Santamaria (@raysan5)
|
|
9
8
|
*
|
|
10
|
-
*
|
|
9
|
+
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
10
|
+
* BSD-like license that allows static linking with closed source software
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2019-2022 arvyy (@arvyy)
|
|
11
13
|
*
|
|
12
14
|
********************************************************************************************/
|
|
13
15
|
|
|
@@ -30,16 +32,19 @@ typedef struct EnvItem {
|
|
|
30
32
|
Color color;
|
|
31
33
|
} EnvItem;
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
//----------------------------------------------------------------------------------
|
|
36
|
+
// Module functions declaration
|
|
37
|
+
//----------------------------------------------------------------------------------
|
|
34
38
|
void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float delta);
|
|
35
|
-
|
|
36
39
|
void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
|
37
40
|
void UpdateCameraCenterInsideMap(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
|
38
41
|
void UpdateCameraCenterSmoothFollow(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
|
39
42
|
void UpdateCameraEvenOutOnLanding(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
|
40
43
|
void UpdateCameraPlayerBoundsPush(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
|
|
41
44
|
|
|
42
|
-
|
|
45
|
+
//------------------------------------------------------------------------------------
|
|
46
|
+
// Program main entry point
|
|
47
|
+
//------------------------------------------------------------------------------------
|
|
43
48
|
int main(void)
|
|
44
49
|
{
|
|
45
50
|
// Initialization
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
*
|
|
3
3
|
* raylib [core] example - 3d camera first person
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
5
|
+
* Example originally created with raylib 1.3, last time updated with raylib 1.3
|
|
7
6
|
*
|
|
8
|
-
*
|
|
7
|
+
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
8
|
+
* BSD-like license that allows static linking with closed source software
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
|
|
9
11
|
*
|
|
10
12
|
********************************************************************************************/
|
|
11
13
|
|
|
@@ -13,6 +15,9 @@
|
|
|
13
15
|
|
|
14
16
|
#define MAX_COLUMNS 20
|
|
15
17
|
|
|
18
|
+
//------------------------------------------------------------------------------------
|
|
19
|
+
// Program main entry point
|
|
20
|
+
//------------------------------------------------------------------------------------
|
|
16
21
|
int main(void)
|
|
17
22
|
{
|
|
18
23
|
// Initialization
|
|
@@ -52,7 +57,7 @@ int main(void)
|
|
|
52
57
|
{
|
|
53
58
|
// Update
|
|
54
59
|
//----------------------------------------------------------------------------------
|
|
55
|
-
UpdateCamera(&camera);
|
|
60
|
+
UpdateCamera(&camera);
|
|
56
61
|
//----------------------------------------------------------------------------------
|
|
57
62
|
|
|
58
63
|
// Draw
|
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
*
|
|
3
3
|
* raylib [core] example - Initialize 3d camera free
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
5
|
+
* Example originally created with raylib 1.3, last time updated with raylib 1.3
|
|
7
6
|
*
|
|
8
|
-
*
|
|
7
|
+
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
8
|
+
* BSD-like license that allows static linking with closed source software
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015-2022 Ramon Santamaria (@raysan5)
|
|
9
11
|
*
|
|
10
12
|
********************************************************************************************/
|
|
11
13
|
|
|
12
14
|
#include "raylib.h"
|
|
13
15
|
|
|
16
|
+
//------------------------------------------------------------------------------------
|
|
17
|
+
// Program main entry point
|
|
18
|
+
//------------------------------------------------------------------------------------
|
|
14
19
|
int main(void)
|
|
15
20
|
{
|
|
16
21
|
// Initialization
|
|
@@ -40,7 +45,7 @@ int main(void)
|
|
|
40
45
|
{
|
|
41
46
|
// Update
|
|
42
47
|
//----------------------------------------------------------------------------------
|
|
43
|
-
UpdateCamera(&camera);
|
|
48
|
+
UpdateCamera(&camera);
|
|
44
49
|
|
|
45
50
|
if (IsKeyDown('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
|
46
51
|
//----------------------------------------------------------------------------------
|