koffi 2.1.0 → 2.1.2
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 +13 -1
- package/build/qemu/2.1.2/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/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/call.cc +2 -2
- package/src/call.hh +1 -1
- package/src/ffi.hh +1 -1
- package/src/util.hh +6 -0
- package/test/raylib.js +37 -5
- package/vendor/libcc/libcc.cc +488 -254
- package/vendor/libcc/libcc.hh +1463 -1277
- 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.0/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0/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 [shapes] example - rectangle scaling by mouse
|
|
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 2.5
|
|
7
6
|
*
|
|
8
7
|
* Example contributed by Vlad Adrian (@demizdor) 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) 2018-2022 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5)
|
|
11
13
|
*
|
|
12
14
|
********************************************************************************************/
|
|
13
15
|
|
|
@@ -15,6 +17,9 @@
|
|
|
15
17
|
|
|
16
18
|
#define MOUSE_SCALE_MARK_SIZE 12
|
|
17
19
|
|
|
20
|
+
//------------------------------------------------------------------------------------
|
|
21
|
+
// Program main entry point
|
|
22
|
+
//------------------------------------------------------------------------------------
|
|
18
23
|
int main(void)
|
|
19
24
|
{
|
|
20
25
|
// Initialization
|
|
@@ -41,8 +46,7 @@ int main(void)
|
|
|
41
46
|
//----------------------------------------------------------------------------------
|
|
42
47
|
mousePosition = GetMousePosition();
|
|
43
48
|
|
|
44
|
-
if (CheckCollisionPointRec(mousePosition, rec)
|
|
45
|
-
CheckCollisionPointRec(mousePosition, (Rectangle){ rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, rec.y + rec.height - MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE }))
|
|
49
|
+
if (CheckCollisionPointRec(mousePosition, (Rectangle){ rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, rec.y + rec.height - MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE }))
|
|
46
50
|
{
|
|
47
51
|
mouseScaleReady = true;
|
|
48
52
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) mouseScaleMode = true;
|
|
@@ -56,8 +60,13 @@ int main(void)
|
|
|
56
60
|
rec.width = (mousePosition.x - rec.x);
|
|
57
61
|
rec.height = (mousePosition.y - rec.y);
|
|
58
62
|
|
|
63
|
+
// Check minimum rec size
|
|
59
64
|
if (rec.width < MOUSE_SCALE_MARK_SIZE) rec.width = MOUSE_SCALE_MARK_SIZE;
|
|
60
65
|
if (rec.height < MOUSE_SCALE_MARK_SIZE) rec.height = MOUSE_SCALE_MARK_SIZE;
|
|
66
|
+
|
|
67
|
+
// Check maximum rec size
|
|
68
|
+
if (rec.width > (GetScreenWidth() - rec.x)) rec.width = GetScreenWidth() - rec.x;
|
|
69
|
+
if (rec.height > (GetScreenHeight() - rec.y)) rec.height = GetScreenHeight() - rec.y;
|
|
61
70
|
|
|
62
71
|
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) mouseScaleMode = false;
|
|
63
72
|
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/*******************************************************************************************
|
|
2
|
+
*
|
|
3
|
+
* raylib [shapes] example - top down lights
|
|
4
|
+
*
|
|
5
|
+
* Example originally created with raylib 4.2, last time updated with raylib 4.2
|
|
6
|
+
*
|
|
7
|
+
* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5)
|
|
8
|
+
*
|
|
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) 2022 Jeffery Myers (@JeffM2501)
|
|
13
|
+
*
|
|
14
|
+
********************************************************************************************/
|
|
15
|
+
|
|
16
|
+
#include "raylib.h"
|
|
17
|
+
#include "raymath.h"
|
|
18
|
+
#include "rlgl.h"
|
|
19
|
+
|
|
20
|
+
// Custom Blend Modes
|
|
21
|
+
#define RLGL_SRC_ALPHA 0x0302
|
|
22
|
+
#define RLGL_MIN 0x8007
|
|
23
|
+
#define RLGL_MAX 0x8008
|
|
24
|
+
|
|
25
|
+
#define MAX_BOXES 20
|
|
26
|
+
#define MAX_SHADOWS MAX_BOXES*3 // MAX_BOXES *3. Each box can cast up to two shadow volumes for the edges it is away from, and one for the box itself
|
|
27
|
+
#define MAX_LIGHTS 16
|
|
28
|
+
|
|
29
|
+
// Shadow geometry type
|
|
30
|
+
typedef struct ShadowGeometry {
|
|
31
|
+
Vector2 vertices[4];
|
|
32
|
+
} ShadowGeometry;
|
|
33
|
+
|
|
34
|
+
// Light info type
|
|
35
|
+
typedef struct LightInfo {
|
|
36
|
+
bool active; // Is this light slot active?
|
|
37
|
+
bool dirty; // Does this light need to be updated?
|
|
38
|
+
bool valid; // Is this light in a valid position?
|
|
39
|
+
|
|
40
|
+
Vector2 position; // Light position
|
|
41
|
+
RenderTexture mask; // Alpha mask for the light
|
|
42
|
+
float outerRadius; // The distance the light touches
|
|
43
|
+
Rectangle bounds; // A cached rectangle of the light bounds to help with culling
|
|
44
|
+
|
|
45
|
+
ShadowGeometry shadows[MAX_SHADOWS];
|
|
46
|
+
int shadowCount;
|
|
47
|
+
} LightInfo;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
LightInfo lights[MAX_LIGHTS] = { 0 };
|
|
51
|
+
|
|
52
|
+
// Move a light and mark it as dirty so that we update it's mask next frame
|
|
53
|
+
void MoveLight(int slot, float x, float y)
|
|
54
|
+
{
|
|
55
|
+
lights[slot].dirty = true;
|
|
56
|
+
lights[slot].position.x = x;
|
|
57
|
+
lights[slot].position.y = y;
|
|
58
|
+
|
|
59
|
+
// update the cached bounds
|
|
60
|
+
lights[slot].bounds.x = x - lights[slot].outerRadius;
|
|
61
|
+
lights[slot].bounds.y = y - lights[slot].outerRadius;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Compute a shadow volume for the edge
|
|
65
|
+
// It takes the edge and projects it back by the light radius and turns it into a quad
|
|
66
|
+
void ComputeShadowVolumeForEdge(int slot, Vector2 sp, Vector2 ep)
|
|
67
|
+
{
|
|
68
|
+
if (lights[slot].shadowCount >= MAX_SHADOWS) return;
|
|
69
|
+
|
|
70
|
+
float extension = lights[slot].outerRadius*2;
|
|
71
|
+
|
|
72
|
+
Vector2 spVector = Vector2Normalize(Vector2Subtract(sp, lights[slot].position));
|
|
73
|
+
Vector2 spProjection = Vector2Add(sp, Vector2Scale(spVector, extension));
|
|
74
|
+
|
|
75
|
+
Vector2 epVector = Vector2Normalize(Vector2Subtract(ep, lights[slot].position));
|
|
76
|
+
Vector2 epProjection = Vector2Add(ep, Vector2Scale(epVector, extension));
|
|
77
|
+
|
|
78
|
+
lights[slot].shadows[lights[slot].shadowCount].vertices[0] = sp;
|
|
79
|
+
lights[slot].shadows[lights[slot].shadowCount].vertices[1] = ep;
|
|
80
|
+
lights[slot].shadows[lights[slot].shadowCount].vertices[2] = epProjection;
|
|
81
|
+
lights[slot].shadows[lights[slot].shadowCount].vertices[3] = spProjection;
|
|
82
|
+
|
|
83
|
+
lights[slot].shadowCount++;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Draw the light and shadows to the mask for a light
|
|
87
|
+
void DrawLightMask(int slot)
|
|
88
|
+
{
|
|
89
|
+
// Use the light mask
|
|
90
|
+
BeginTextureMode(lights[slot].mask);
|
|
91
|
+
|
|
92
|
+
ClearBackground(WHITE);
|
|
93
|
+
|
|
94
|
+
// Force the blend mode to only set the alpha of the destination
|
|
95
|
+
rlSetBlendFactors(RLGL_SRC_ALPHA, RLGL_SRC_ALPHA, RLGL_MIN);
|
|
96
|
+
rlSetBlendMode(BLEND_CUSTOM);
|
|
97
|
+
|
|
98
|
+
// If we are valid, then draw the light radius to the alpha mask
|
|
99
|
+
if (lights[slot].valid) DrawCircleGradient((int)lights[slot].position.x, (int)lights[slot].position.y, lights[slot].outerRadius, ColorAlpha(WHITE, 0), WHITE);
|
|
100
|
+
|
|
101
|
+
rlDrawRenderBatchActive();
|
|
102
|
+
|
|
103
|
+
// Cut out the shadows from the light radius by forcing the alpha to maximum
|
|
104
|
+
rlSetBlendMode(BLEND_ALPHA);
|
|
105
|
+
rlSetBlendFactors(RLGL_SRC_ALPHA, RLGL_SRC_ALPHA, RLGL_MAX);
|
|
106
|
+
rlSetBlendMode(BLEND_CUSTOM);
|
|
107
|
+
|
|
108
|
+
// Draw the shadows to the alpha mask
|
|
109
|
+
for (int i = 0; i < lights[slot].shadowCount; i++)
|
|
110
|
+
{
|
|
111
|
+
DrawTriangleFan(lights[slot].shadows[i].vertices, 4, WHITE);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
rlDrawRenderBatchActive();
|
|
115
|
+
|
|
116
|
+
// Go back to normal blend mode
|
|
117
|
+
rlSetBlendMode(BLEND_ALPHA);
|
|
118
|
+
|
|
119
|
+
EndTextureMode();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Setup a light
|
|
123
|
+
void SetupLight(int slot, float x, float y, float radius)
|
|
124
|
+
{
|
|
125
|
+
lights[slot].active = true;
|
|
126
|
+
lights[slot].valid = false; // The light must prove it is valid
|
|
127
|
+
lights[slot].mask = LoadRenderTexture(GetScreenWidth(), GetScreenHeight());
|
|
128
|
+
lights[slot].outerRadius = radius;
|
|
129
|
+
|
|
130
|
+
lights[slot].bounds.width = radius * 2;
|
|
131
|
+
lights[slot].bounds.height = radius * 2;
|
|
132
|
+
|
|
133
|
+
MoveLight(slot, x, y);
|
|
134
|
+
|
|
135
|
+
// Force the render texture to have something in it
|
|
136
|
+
DrawLightMask(slot);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// See if a light needs to update it's mask
|
|
140
|
+
bool UpdateLight(int slot, Rectangle* boxes, int count)
|
|
141
|
+
{
|
|
142
|
+
if (!lights[slot].active || !lights[slot].dirty) return false;
|
|
143
|
+
|
|
144
|
+
lights[slot].dirty = false;
|
|
145
|
+
lights[slot].shadowCount = 0;
|
|
146
|
+
lights[slot].valid = false;
|
|
147
|
+
|
|
148
|
+
for (int i = 0; i < count; i++)
|
|
149
|
+
{
|
|
150
|
+
// Are we in a box? if so we are not valid
|
|
151
|
+
if (CheckCollisionPointRec(lights[slot].position, boxes[i])) return false;
|
|
152
|
+
|
|
153
|
+
// If this box is outside our bounds, we can skip it
|
|
154
|
+
if (!CheckCollisionRecs(lights[slot].bounds, boxes[i])) continue;
|
|
155
|
+
|
|
156
|
+
// Check the edges that are on the same side we are, and cast shadow volumes out from them
|
|
157
|
+
|
|
158
|
+
// Top
|
|
159
|
+
Vector2 sp = (Vector2){ boxes[i].x, boxes[i].y };
|
|
160
|
+
Vector2 ep = (Vector2){ boxes[i].x + boxes[i].width, boxes[i].y };
|
|
161
|
+
|
|
162
|
+
if (lights[slot].position.y > ep.y) ComputeShadowVolumeForEdge(slot, sp, ep);
|
|
163
|
+
|
|
164
|
+
// Right
|
|
165
|
+
sp = ep;
|
|
166
|
+
ep.y += boxes[i].height;
|
|
167
|
+
if (lights[slot].position.x < ep.x) ComputeShadowVolumeForEdge(slot, sp, ep);
|
|
168
|
+
|
|
169
|
+
// Bottom
|
|
170
|
+
sp = ep;
|
|
171
|
+
ep.x -= boxes[i].width;
|
|
172
|
+
if (lights[slot].position.y < ep.y) ComputeShadowVolumeForEdge(slot, sp, ep);
|
|
173
|
+
|
|
174
|
+
// Left
|
|
175
|
+
sp = ep;
|
|
176
|
+
ep.y -= boxes[i].height;
|
|
177
|
+
if (lights[slot].position.x > ep.x) ComputeShadowVolumeForEdge(slot, sp, ep);
|
|
178
|
+
|
|
179
|
+
// The box itself
|
|
180
|
+
lights[slot].shadows[lights[slot].shadowCount].vertices[0] = (Vector2){ boxes[i].x, boxes[i].y };
|
|
181
|
+
lights[slot].shadows[lights[slot].shadowCount].vertices[1] = (Vector2){ boxes[i].x, boxes[i].y + boxes[i].height };
|
|
182
|
+
lights[slot].shadows[lights[slot].shadowCount].vertices[2] = (Vector2){ boxes[i].x + boxes[i].width, boxes[i].y + boxes[i].height };
|
|
183
|
+
lights[slot].shadows[lights[slot].shadowCount].vertices[3] = (Vector2){ boxes[i].x + boxes[i].width, boxes[i].y };
|
|
184
|
+
lights[slot].shadowCount++;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
lights[slot].valid = true;
|
|
188
|
+
|
|
189
|
+
DrawLightMask(slot);
|
|
190
|
+
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Set up some boxes
|
|
195
|
+
void SetupBoxes(Rectangle *boxes, int *count)
|
|
196
|
+
{
|
|
197
|
+
boxes[0] = (Rectangle){ 150,80, 40, 40 };
|
|
198
|
+
boxes[1] = (Rectangle){ 1200, 700, 40, 40 };
|
|
199
|
+
boxes[2] = (Rectangle){ 200, 600, 40, 40 };
|
|
200
|
+
boxes[3] = (Rectangle){ 1000, 50, 40, 40 };
|
|
201
|
+
boxes[4] = (Rectangle){ 500, 350, 40, 40 };
|
|
202
|
+
|
|
203
|
+
for (int i = 5; i < MAX_BOXES; i++)
|
|
204
|
+
{
|
|
205
|
+
boxes[i] = (Rectangle){(float)GetRandomValue(0,GetScreenWidth()), (float)GetRandomValue(0,GetScreenHeight()), (float)GetRandomValue(10,100), (float)GetRandomValue(10,100) };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
*count = MAX_BOXES;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
//------------------------------------------------------------------------------------
|
|
212
|
+
// Program main entry point
|
|
213
|
+
//------------------------------------------------------------------------------------
|
|
214
|
+
int main(void)
|
|
215
|
+
{
|
|
216
|
+
// Initialization
|
|
217
|
+
//--------------------------------------------------------------------------------------
|
|
218
|
+
const int screenWidth = 800;
|
|
219
|
+
const int screenHeight = 450;
|
|
220
|
+
|
|
221
|
+
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - top down lights");
|
|
222
|
+
|
|
223
|
+
// Initialize our 'world' of boxes
|
|
224
|
+
int boxCount = 0;
|
|
225
|
+
Rectangle boxes[MAX_BOXES] = { 0 };
|
|
226
|
+
SetupBoxes(boxes, &boxCount);
|
|
227
|
+
|
|
228
|
+
// Create a checkerboard ground texture
|
|
229
|
+
Image img = GenImageChecked(64, 64, 32, 32, DARKBROWN, DARKGRAY);
|
|
230
|
+
Texture2D backgroundTexture = LoadTextureFromImage(img);
|
|
231
|
+
UnloadImage(img);
|
|
232
|
+
|
|
233
|
+
// Create a global light mask to hold all the blended lights
|
|
234
|
+
RenderTexture lightMask = LoadRenderTexture(GetScreenWidth(), GetScreenHeight());
|
|
235
|
+
|
|
236
|
+
// Setup initial light
|
|
237
|
+
SetupLight(0, 600, 400, 300);
|
|
238
|
+
int nextLight = 1;
|
|
239
|
+
|
|
240
|
+
bool showLines = false;
|
|
241
|
+
|
|
242
|
+
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
243
|
+
//--------------------------------------------------------------------------------------
|
|
244
|
+
|
|
245
|
+
// Main game loop
|
|
246
|
+
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
247
|
+
{
|
|
248
|
+
// Update
|
|
249
|
+
//----------------------------------------------------------------------------------
|
|
250
|
+
// Drag light 0
|
|
251
|
+
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) MoveLight(0, GetMousePosition().x, GetMousePosition().y);
|
|
252
|
+
|
|
253
|
+
// Make a new light
|
|
254
|
+
if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) && (nextLight < MAX_LIGHTS))
|
|
255
|
+
{
|
|
256
|
+
SetupLight(nextLight, GetMousePosition().x, GetMousePosition().y, 200);
|
|
257
|
+
nextLight++;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Toggle debug info
|
|
261
|
+
if (IsKeyPressed(KEY_F1)) showLines = !showLines;
|
|
262
|
+
|
|
263
|
+
// Update the lights and keep track if any were dirty so we know if we need to update the master light mask
|
|
264
|
+
bool dirtyLights = false;
|
|
265
|
+
for (int i = 0; i < MAX_LIGHTS; i++)
|
|
266
|
+
{
|
|
267
|
+
if (UpdateLight(i, boxes, boxCount)) dirtyLights = true;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Update the light mask
|
|
271
|
+
if (dirtyLights)
|
|
272
|
+
{
|
|
273
|
+
// Build up the light mask
|
|
274
|
+
BeginTextureMode(lightMask);
|
|
275
|
+
|
|
276
|
+
ClearBackground(BLACK);
|
|
277
|
+
|
|
278
|
+
// Force the blend mode to only set the alpha of the destination
|
|
279
|
+
rlSetBlendFactors(RLGL_SRC_ALPHA, RLGL_SRC_ALPHA, RLGL_MIN);
|
|
280
|
+
rlSetBlendMode(BLEND_CUSTOM);
|
|
281
|
+
|
|
282
|
+
// Merge in all the light masks
|
|
283
|
+
for (int i = 0; i < MAX_LIGHTS; i++)
|
|
284
|
+
{
|
|
285
|
+
if (lights[i].active) DrawTextureRec(lights[i].mask.texture, (Rectangle){ 0, 0, (float)GetScreenWidth(), -(float)GetScreenHeight() }, Vector2Zero(), WHITE);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
rlDrawRenderBatchActive();
|
|
289
|
+
|
|
290
|
+
// Go back to normal blend
|
|
291
|
+
rlSetBlendMode(BLEND_ALPHA);
|
|
292
|
+
EndTextureMode();
|
|
293
|
+
}
|
|
294
|
+
//----------------------------------------------------------------------------------
|
|
295
|
+
|
|
296
|
+
// Draw
|
|
297
|
+
//----------------------------------------------------------------------------------
|
|
298
|
+
BeginDrawing();
|
|
299
|
+
|
|
300
|
+
ClearBackground(BLACK);
|
|
301
|
+
|
|
302
|
+
// Draw the tile background
|
|
303
|
+
DrawTextureRec(backgroundTexture, (Rectangle){ 0, 0, (float)GetScreenWidth(), (float)GetScreenHeight() }, Vector2Zero(), WHITE);
|
|
304
|
+
|
|
305
|
+
// Overlay the shadows from all the lights
|
|
306
|
+
DrawTextureRec(lightMask.texture, (Rectangle){ 0, 0, (float)GetScreenWidth(), -(float)GetScreenHeight() }, Vector2Zero(), ColorAlpha(WHITE, showLines? 0.75f : 1.0f));
|
|
307
|
+
|
|
308
|
+
// Draw the lights
|
|
309
|
+
for (int i = 0; i < MAX_LIGHTS; i++)
|
|
310
|
+
{
|
|
311
|
+
if (lights[i].active) DrawCircle((int)lights[i].position.x, (int)lights[i].position.y, 10, (i == 0)? YELLOW : WHITE);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (showLines)
|
|
315
|
+
{
|
|
316
|
+
for (int s = 0; s < lights[0].shadowCount; s++)
|
|
317
|
+
{
|
|
318
|
+
DrawTriangleFan(lights[0].shadows[s].vertices, 4, DARKPURPLE);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
for (int b = 0; b < boxCount; b++)
|
|
322
|
+
{
|
|
323
|
+
if (CheckCollisionRecs(boxes[b],lights[0].bounds)) DrawRectangleRec(boxes[b], PURPLE);
|
|
324
|
+
|
|
325
|
+
DrawRectangleLines((int)boxes[b].x, (int)boxes[b].y, (int)boxes[b].width, (int)boxes[b].height, DARKBLUE);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
DrawText("(F1) Hide Shadow Volumes", 10, 50, 10, GREEN);
|
|
329
|
+
}
|
|
330
|
+
else
|
|
331
|
+
{
|
|
332
|
+
DrawText("(F1) Show Shadow Volumes", 10, 50, 10, GREEN);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
DrawFPS(screenWidth - 80, 10);
|
|
336
|
+
DrawText("Drag to move light #1", 10, 10, 10, DARKGREEN);
|
|
337
|
+
DrawText("Right click to add new light", 10, 30, 10, DARKGREEN);
|
|
338
|
+
EndDrawing();
|
|
339
|
+
//----------------------------------------------------------------------------------
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// De-Initialization
|
|
343
|
+
//--------------------------------------------------------------------------------------
|
|
344
|
+
UnloadTexture(backgroundTexture);
|
|
345
|
+
UnloadRenderTexture(lightMask);
|
|
346
|
+
for (int i = 0; i < MAX_LIGHTS; i++)
|
|
347
|
+
{
|
|
348
|
+
if (lights[i].active) UnloadRenderTexture(lights[i].mask);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
CloseWindow(); // Close window and OpenGL context
|
|
352
|
+
//--------------------------------------------------------------------------------------
|
|
353
|
+
|
|
354
|
+
return 0;
|
|
355
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2020 The DotGothic16 Project Authors (https://github.com/fontworks-fonts/DotGothic16)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
| fonts/setback.png | [Brian Kent (AEnigma)](https://www.dafont.com/es/aenigma.d188) | [Freeware](https://www.dafont.com/es/setback.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
|
|
7
7
|
| fonts/jupiter_crash.png | [Brian Kent (AEnigma)](https://www.dafont.com/es/aenigma.d188) | [Freeware](https://www.dafont.com/es/jupiter-crash.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
|
|
8
8
|
| fonts/mecha.png | Captain Falcon | [Freeware](https://www.dafont.com/es/mecha-cf.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
|
|
9
|
-
| fonts/pixelplay.png | Aleksander Shevchuk | [Freeware](https://www.dafont.com/es/pixelplay.
|
|
9
|
+
| fonts/pixelplay.png | Aleksander Shevchuk | [Freeware](https://www.dafont.com/es/pixelplay.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
|
|
10
10
|
| fonts/pixantiqua.ttf | Gerhard Großmann | [Freeware](https://www.dafont.com/es/pixantiqua.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
|
|
11
11
|
| anonymous_pro_bold.ttf | [Mark Simonson](https://fonts.google.com/specimen/Anonymous+Pro) | [Open Font License](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL) | - |
|
|
12
12
|
| custom_alagard.png | [Brian Kent (AEnigma)](https://www.dafont.com/es/aenigma.d188) | [Freeware](https://www.dafont.com/es/jupiter-crash.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*******************************************************************************************
|
|
2
|
+
*
|
|
3
|
+
* raylib [text] example - Codepoints loading
|
|
4
|
+
*
|
|
5
|
+
* Example originally created with raylib 4.2, last time updated with raylib 2.5
|
|
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: calloc(), realloc(), free()
|
|
17
|
+
#include <string.h> // Required for: memcpy()
|
|
18
|
+
|
|
19
|
+
// Text to be displayed, must be UTF-8 (save this code file as UTF-8)
|
|
20
|
+
// NOTE: It can contain all the required text for the game,
|
|
21
|
+
// this text will be scanned to get all the required codepoints
|
|
22
|
+
static char *text = "いろはにほへと ちりぬるを\nわかよたれそ つねならむ\nうゐのおくやま けふこえて\nあさきゆめみし ゑひもせす";
|
|
23
|
+
|
|
24
|
+
// Remove codepoint duplicates if requested
|
|
25
|
+
static int *CodepointRemoveDuplicates(int *codepoints, int codepointCount, int *codepointResultCount);
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
//------------------------------------------------------------------------------------
|
|
29
|
+
// Program main entry point
|
|
30
|
+
//------------------------------------------------------------------------------------
|
|
31
|
+
int main(void)
|
|
32
|
+
{
|
|
33
|
+
// Initialization
|
|
34
|
+
//--------------------------------------------------------------------------------------
|
|
35
|
+
const int screenWidth = 800;
|
|
36
|
+
const int screenHeight = 450;
|
|
37
|
+
|
|
38
|
+
InitWindow(screenWidth, screenHeight, "raylib [text] example - codepoints loading");
|
|
39
|
+
|
|
40
|
+
// Get codepoints from text
|
|
41
|
+
int codepointCount = 0;
|
|
42
|
+
int *codepoints = LoadCodepoints(text, &codepointCount);
|
|
43
|
+
|
|
44
|
+
// Removed duplicate codepoints to generate smaller font atlas
|
|
45
|
+
int codepointsNoDupsCount = 0;
|
|
46
|
+
int *codepointsNoDups = CodepointRemoveDuplicates(codepoints, codepointCount, &codepointsNoDupsCount);
|
|
47
|
+
UnloadCodepoints(codepoints);
|
|
48
|
+
|
|
49
|
+
// Load font containing all the provided codepoint glyphs
|
|
50
|
+
// A texture font atlas is automatically generated
|
|
51
|
+
Font font = LoadFontEx("resources/DotGothic16-Regular.ttf", 36, codepointsNoDups, codepointsNoDupsCount);
|
|
52
|
+
|
|
53
|
+
// Set bilinear scale filter for better font scaling
|
|
54
|
+
SetTextureFilter(font.texture, TEXTURE_FILTER_BILINEAR);
|
|
55
|
+
|
|
56
|
+
// Free codepoints, atlas has already been generated
|
|
57
|
+
free(codepointsNoDups);
|
|
58
|
+
|
|
59
|
+
bool showFontAtlas = false;
|
|
60
|
+
|
|
61
|
+
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
62
|
+
//--------------------------------------------------------------------------------------
|
|
63
|
+
|
|
64
|
+
// Main game loop
|
|
65
|
+
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
66
|
+
{
|
|
67
|
+
// Update
|
|
68
|
+
//----------------------------------------------------------------------------------
|
|
69
|
+
if (IsKeyPressed(KEY_SPACE)) showFontAtlas = !showFontAtlas;
|
|
70
|
+
//----------------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
// Draw
|
|
73
|
+
//----------------------------------------------------------------------------------
|
|
74
|
+
BeginDrawing();
|
|
75
|
+
|
|
76
|
+
ClearBackground(RAYWHITE);
|
|
77
|
+
|
|
78
|
+
DrawRectangle(0, 0, GetScreenWidth(), 70, BLACK);
|
|
79
|
+
DrawText(TextFormat("Total codepoints contained in provided text: %i", codepointCount), 10, 10, 20, GREEN);
|
|
80
|
+
DrawText(TextFormat("Total codepoints required for font atlas (duplicates excluded): %i", codepointsNoDupsCount), 10, 40, 20, GREEN);
|
|
81
|
+
|
|
82
|
+
if (showFontAtlas)
|
|
83
|
+
{
|
|
84
|
+
// Draw generated font texture atlas containing provided codepoints
|
|
85
|
+
DrawTexture(font.texture, 150, 100, BLACK);
|
|
86
|
+
DrawRectangleLines(150, 100, font.texture.width, font.texture.height, BLACK);
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
{
|
|
90
|
+
// Draw provided text with laoded font, containing all required codepoint glyphs
|
|
91
|
+
DrawTextEx(font, text, (Vector2) { 160, 110 }, 48, 5, BLACK);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
DrawText("Press SPACE to toggle font atlas view!", 10, GetScreenHeight() - 30, 20, GRAY);
|
|
95
|
+
|
|
96
|
+
EndDrawing();
|
|
97
|
+
//----------------------------------------------------------------------------------
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// De-Initialization
|
|
101
|
+
//--------------------------------------------------------------------------------------
|
|
102
|
+
UnloadFont(font); // Unload font
|
|
103
|
+
|
|
104
|
+
CloseWindow(); // Close window and OpenGL context
|
|
105
|
+
//--------------------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Remove codepoint duplicates if requested
|
|
111
|
+
// WARNING: This process could be a bit slow if there text to process is very long
|
|
112
|
+
static int *CodepointRemoveDuplicates(int *codepoints, int codepointCount, int *codepointsResultCount)
|
|
113
|
+
{
|
|
114
|
+
int codepointsNoDupsCount = codepointCount;
|
|
115
|
+
int *codepointsNoDups = (int *)calloc(codepointCount, sizeof(int));
|
|
116
|
+
memcpy(codepointsNoDups, codepoints, codepointCount*sizeof(int));
|
|
117
|
+
|
|
118
|
+
// Remove duplicates
|
|
119
|
+
for (int i = 0; i < codepointsNoDupsCount; i++)
|
|
120
|
+
{
|
|
121
|
+
for (int j = i + 1; j < codepointsNoDupsCount; j++)
|
|
122
|
+
{
|
|
123
|
+
if (codepointsNoDups[i] == codepointsNoDups[j])
|
|
124
|
+
{
|
|
125
|
+
for (int k = j; k < codepointsNoDupsCount; k++) codepointsNoDups[k] = codepointsNoDups[k + 1];
|
|
126
|
+
|
|
127
|
+
codepointsNoDupsCount--;
|
|
128
|
+
j--;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// NOTE: The size of codepointsNoDups is the same as original array but
|
|
134
|
+
// only required positions are filled (codepointsNoDupsCount)
|
|
135
|
+
|
|
136
|
+
*codepointsResultCount = codepointsNoDupsCount;
|
|
137
|
+
return codepointsNoDups;
|
|
138
|
+
}
|
|
Binary file
|