├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── CONTRIBUTING.md ├── HACKING.md ├── LICENSE.md ├── README.md ├── USING_RAYLIB.md ├── crown.png ├── examples ├── audio │ ├── audio_module_playing.nim │ ├── audio_multichannel_sound.nim │ ├── audio_music_stream.nim │ ├── audio_raw_stream.nim │ └── resources │ │ ├── guitar_noodling.ogg │ │ ├── mini1111.xm │ │ ├── sound.wav │ │ └── tanatana.ogg ├── core │ ├── core_2d_camera.nim │ ├── core_2d_camera_platformer.nim │ ├── core_3d_camera_first_person.nim │ ├── core_3d_camera_free.nim │ ├── core_3d_camera_mode.nim │ ├── core_3d_picking.nim │ ├── core_basic_window.nim │ ├── core_custom_logging.nim │ ├── core_input_gamepad.nim │ ├── core_input_gestures.nim │ ├── core_input_keys.nim │ ├── core_input_mouse.nim │ ├── core_input_mouse_wheel.nim │ ├── core_loading_thread.nim │ ├── core_quat_conversion.nim │ ├── core_random_values.nim │ ├── core_scissor_test.nim │ ├── core_vr_simulator.nim │ ├── core_window_flags.nim │ ├── core_window_letterbox.nim │ ├── core_world_screen.nim │ └── resources │ │ ├── LICENSE │ │ ├── distortion100.fs │ │ ├── distortion330.fs │ │ ├── ps3.png │ │ └── xbox.png ├── emscripten │ ├── .gitignore │ ├── README.md │ ├── config.nims │ ├── emscripten_crown.nim │ ├── public │ │ └── .gitkeep │ └── resources │ │ └── ambient.ogg ├── models │ ├── models_first_person_maze.nim │ ├── models_geometric_shapes.nim │ ├── models_loading.nim │ ├── models_mesh_generation.nim │ ├── models_rlgl_solar_system.nim │ ├── models_waving_cubes.nim │ └── resources │ │ ├── castle.obj │ │ ├── castle_diffuse.png │ │ ├── cubicmap.png │ │ └── cubicmap_atlas.png ├── original │ ├── basic.nim │ └── crown.nim ├── physics │ ├── physics_demo.nim │ ├── physics_friction.nim │ ├── physics_movement.nim │ ├── physics_restitution.nim │ └── physics_shatter.nim ├── shaders │ ├── resources │ │ ├── fudesumi.png │ │ ├── mask.png │ │ ├── models │ │ │ ├── barracks_diffuse.png │ │ │ ├── church_diffuse.png │ │ │ └── watermill_diffuse.png │ │ ├── plasma.png │ │ ├── raysan.png │ │ ├── shaders │ │ │ ├── glsl100 │ │ │ │ ├── base.fs │ │ │ │ ├── base.vs │ │ │ │ ├── base_lighting.vs │ │ │ │ ├── bloom.fs │ │ │ │ ├── blur.fs │ │ │ │ ├── color_mix.fs │ │ │ │ ├── cross_hatching.fs │ │ │ │ ├── cross_stitching.fs │ │ │ │ ├── cubes_panning.fs │ │ │ │ ├── depth.fs │ │ │ │ ├── distortion.fs │ │ │ │ ├── dream_vision.fs │ │ │ │ ├── eratosthenes.fs │ │ │ │ ├── fisheye.fs │ │ │ │ ├── fog.fs │ │ │ │ ├── grayscale.fs │ │ │ │ ├── julia_set.fs │ │ │ │ ├── lighting.fs │ │ │ │ ├── mask.fs │ │ │ │ ├── palette_switch.fs │ │ │ │ ├── pixelizer.fs │ │ │ │ ├── posterization.fs │ │ │ │ ├── predator.fs │ │ │ │ ├── raymarching.fs │ │ │ │ ├── scanlines.fs │ │ │ │ ├── sobel.fs │ │ │ │ ├── spotlight.fs │ │ │ │ ├── swirl.fs │ │ │ │ └── wave.fs │ │ │ ├── glsl120 │ │ │ │ ├── base.fs │ │ │ │ ├── base.vs │ │ │ │ ├── base_lighting.vs │ │ │ │ ├── bloom.fs │ │ │ │ ├── blur.fs │ │ │ │ ├── cross_hatching.fs │ │ │ │ ├── cross_stitching.fs │ │ │ │ ├── distortion.fs │ │ │ │ ├── dream_vision.fs │ │ │ │ ├── fisheye.fs │ │ │ │ ├── fog.fs │ │ │ │ ├── grayscale.fs │ │ │ │ ├── palette_switch.fs │ │ │ │ ├── pixelizer.fs │ │ │ │ ├── posterization.fs │ │ │ │ ├── predator.fs │ │ │ │ ├── scanlines.fs │ │ │ │ ├── sobel.fs │ │ │ │ └── swirl.fs │ │ │ └── glsl330 │ │ │ │ ├── base.fs │ │ │ │ ├── base.vs │ │ │ │ ├── base_lighting.vs │ │ │ │ ├── base_lighting_instanced.vs │ │ │ │ ├── bloom.fs │ │ │ │ ├── blur.fs │ │ │ │ ├── color_mix.fs │ │ │ │ ├── cross_hatching.fs │ │ │ │ ├── cross_stitching.fs │ │ │ │ ├── cubes_panning.fs │ │ │ │ ├── depth.fs │ │ │ │ ├── distortion.fs │ │ │ │ ├── dream_vision.fs │ │ │ │ ├── eratosthenes.fs │ │ │ │ ├── fisheye.fs │ │ │ │ ├── fog.fs │ │ │ │ ├── grayscale.fs │ │ │ │ ├── julia_set.fs │ │ │ │ ├── lighting.fs │ │ │ │ ├── mask.fs │ │ │ │ ├── overdraw.fs │ │ │ │ ├── palette_switch.fs │ │ │ │ ├── pixelizer.fs │ │ │ │ ├── posterization.fs │ │ │ │ ├── predator.fs │ │ │ │ ├── raymarching.fs │ │ │ │ ├── reload.fs │ │ │ │ ├── scanlines.fs │ │ │ │ ├── sobel.fs │ │ │ │ ├── spotlight.fs │ │ │ │ ├── swirl.fs │ │ │ │ └── wave.fs │ │ ├── space.png │ │ └── texel_checker.png │ ├── rlights.h │ ├── rlights.nim │ ├── shaders_basic_lighting.nim │ ├── shaders_custom_uniform.nim │ ├── shaders_eratosthenes.nim │ ├── shaders_fog.nim │ ├── shaders_hot_reloading.nim │ ├── shaders_julia_set.nim │ ├── shaders_palette_switch.nim │ └── shaders_raymarching.nim ├── shapes │ ├── shapes_bouncing_ball.nim │ ├── shapes_draw_ring.nim │ └── shapes_following_eyes.nim ├── text │ ├── resources │ │ ├── pixantiqua.fnt │ │ ├── pixantiqua.png │ │ └── pixantiqua.ttf │ ├── text_font_loading.nim │ ├── text_format_text.nim │ ├── text_input_box.nim │ └── text_rectangle_bounds.nim └── textures │ ├── resources │ ├── KAISG.ttf │ ├── boom.wav │ ├── button.png │ ├── buttonfx.wav │ ├── cat.png │ ├── custom_jupiter_crash.png │ ├── cyberpunk_street_background.png │ ├── cyberpunk_street_foreground.png │ ├── cyberpunk_street_midground.png │ ├── explosion.png │ ├── fudesumi.png │ ├── fudesumi.raw │ ├── ninepatch_button.png │ ├── parrots.png │ ├── patterns.png │ ├── raylib_logo.png │ ├── scarfy.png │ ├── smoke.png │ ├── spark_flame.png │ └── wabbit_alpha.png │ ├── textures_background_scrolling.nim │ ├── textures_blend_modes.nim │ ├── textures_bunnymark.nim │ ├── textures_draw_tiled.nim │ ├── textures_image_drawing.nim │ ├── textures_image_generation.nim │ ├── textures_image_loading.nim │ ├── textures_image_processing.nim │ ├── textures_image_text.nim │ ├── textures_logo_raylib.nim │ ├── textures_mouse_painting.nim │ ├── textures_npatch_drawing.nim │ ├── textures_particles_blending.nim │ ├── textures_raw_data.nim │ ├── textures_rectangle.nim │ ├── textures_sprite_button.nim │ ├── textures_sprite_explosion.nim │ ├── textures_srcrec_dstrec.nim │ └── textures_to_image.nim ├── nimraylib_now.nimble ├── scripts ├── c2nim_example_converter.nim ├── find_missing_examples.nim ├── make_emscripten_tests_from_examples.nim ├── make_individual_tests_from_examples.nim └── make_tests_from_examples.nim ├── src ├── csources │ └── raylib_mangled │ │ ├── CMakeLists.txt │ │ ├── Makefile │ │ ├── build.zig │ │ ├── config.h │ │ ├── external │ │ ├── cgltf.h │ │ ├── dirent.h │ │ ├── dr_flac.h │ │ ├── dr_mp3.h │ │ ├── dr_wav.h │ │ ├── glad.h │ │ ├── glfw │ │ │ ├── .mailmap │ │ │ ├── CMake │ │ │ │ ├── GenerateMappings.cmake │ │ │ │ ├── Info.plist.in │ │ │ │ ├── MacOSXBundleInfo.plist.in │ │ │ │ ├── cmake_uninstall.cmake.in │ │ │ │ ├── glfw3.pc.in │ │ │ │ ├── glfw3Config.cmake.in │ │ │ │ ├── i686-w64-mingw32-clang.cmake │ │ │ │ ├── i686-w64-mingw32.cmake │ │ │ │ ├── modules │ │ │ │ │ ├── FindEpollShim.cmake │ │ │ │ │ ├── FindOSMesa.cmake │ │ │ │ │ ├── FindWaylandProtocols.cmake │ │ │ │ │ └── FindXKBCommon.cmake │ │ │ │ ├── x86_64-w64-mingw32-clang.cmake │ │ │ │ └── x86_64-w64-mingw32.cmake │ │ │ ├── CMakeLists.txt │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── deps │ │ │ │ ├── getopt.c │ │ │ │ ├── getopt.h │ │ │ │ ├── glad │ │ │ │ │ ├── gl.h │ │ │ │ │ ├── khrplatform.h │ │ │ │ │ ├── vk_platform.h │ │ │ │ │ └── vulkan.h │ │ │ │ ├── glad_gl.c │ │ │ │ ├── glad_vulkan.c │ │ │ │ ├── mingw │ │ │ │ │ ├── _mingw_dxhelper.h │ │ │ │ │ ├── dinput.h │ │ │ │ │ └── xinput.h │ │ │ │ └── vs2008 │ │ │ │ │ └── stdint.h │ │ │ ├── include │ │ │ │ └── GLFW │ │ │ │ │ ├── glfw3.h │ │ │ │ │ └── glfw3native.h │ │ │ └── src │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── cocoa_init.m │ │ │ │ ├── cocoa_joystick.h │ │ │ │ ├── cocoa_joystick.m │ │ │ │ ├── cocoa_monitor.m │ │ │ │ ├── cocoa_platform.h │ │ │ │ ├── cocoa_time.c │ │ │ │ ├── cocoa_window.m │ │ │ │ ├── context.c │ │ │ │ ├── egl_context.c │ │ │ │ ├── egl_context.h │ │ │ │ ├── glfw.rc.in │ │ │ │ ├── glfw_config.h.in │ │ │ │ ├── glx_context.c │ │ │ │ ├── glx_context.h │ │ │ │ ├── init.c │ │ │ │ ├── input.c │ │ │ │ ├── internal.h │ │ │ │ ├── linux_joystick.c │ │ │ │ ├── linux_joystick.h │ │ │ │ ├── mappings.h │ │ │ │ ├── mappings.h.in │ │ │ │ ├── monitor.c │ │ │ │ ├── nsgl_context.h │ │ │ │ ├── nsgl_context.m │ │ │ │ ├── null_init.c │ │ │ │ ├── null_joystick.c │ │ │ │ ├── null_joystick.h │ │ │ │ ├── null_monitor.c │ │ │ │ ├── null_platform.h │ │ │ │ ├── null_window.c │ │ │ │ ├── osmesa_context.c │ │ │ │ ├── osmesa_context.h │ │ │ │ ├── posix_thread.c │ │ │ │ ├── posix_thread.h │ │ │ │ ├── posix_time.c │ │ │ │ ├── posix_time.h │ │ │ │ ├── vulkan.c │ │ │ │ ├── wgl_context.c │ │ │ │ ├── wgl_context.h │ │ │ │ ├── win32_init.c │ │ │ │ ├── win32_joystick.c │ │ │ │ ├── win32_joystick.h │ │ │ │ ├── win32_monitor.c │ │ │ │ ├── win32_platform.h │ │ │ │ ├── win32_thread.c │ │ │ │ ├── win32_time.c │ │ │ │ ├── win32_window.c │ │ │ │ ├── window.c │ │ │ │ ├── wl_init.c │ │ │ │ ├── wl_monitor.c │ │ │ │ ├── wl_platform.h │ │ │ │ ├── wl_window.c │ │ │ │ ├── x11_init.c │ │ │ │ ├── x11_monitor.c │ │ │ │ ├── x11_platform.h │ │ │ │ ├── x11_window.c │ │ │ │ ├── xkb_unicode.c │ │ │ │ └── xkb_unicode.h │ │ ├── jar_mod.h │ │ ├── jar_xm.h │ │ ├── miniaudio.h │ │ ├── msf_gif.h │ │ ├── par_shapes.h │ │ ├── qoi.h │ │ ├── sdefl.h │ │ ├── sinfl.h │ │ ├── stb_image.h │ │ ├── stb_image_resize.h │ │ ├── stb_image_write.h │ │ ├── stb_rect_pack.h │ │ ├── stb_truetype.h │ │ ├── stb_vorbis.h │ │ ├── tinyobj_loader_c.h │ │ └── vox_loader.h │ │ ├── minshell.html │ │ ├── physac.h │ │ ├── raudio.c │ │ ├── raygui.h │ │ ├── raylib.dll.rc │ │ ├── raylib.dll.rc.data │ │ ├── raylib.h │ │ ├── raylib.ico │ │ ├── raylib.rc │ │ ├── raylib.rc.data │ │ ├── raymath.h │ │ ├── rcamera.h │ │ ├── rcore.c │ │ ├── rgestures.h │ │ ├── rglfw.c │ │ ├── rlgl.h │ │ ├── rmodels.c │ │ ├── rshapes.c │ │ ├── rtext.c │ │ ├── rtextures.c │ │ ├── shell.html │ │ ├── utils.c │ │ └── utils.h ├── generate_bindings.nim ├── nimraylib_now.nim ├── nimraylib_now │ ├── converters.nim │ ├── mangled │ │ ├── converters.nim │ │ ├── physac.h │ │ ├── physac.nim │ │ ├── raygui.h │ │ ├── raygui.nim │ │ ├── raylib.h │ │ ├── raylib.nim │ │ ├── raymath.h │ │ ├── raymath.nim │ │ ├── rlgl.h │ │ └── rlgl.nim │ ├── not_mangled │ │ ├── converters.nim │ │ ├── physac.h │ │ ├── physac.nim │ │ ├── raygui.h │ │ ├── raygui.nim │ │ ├── raylib.h │ │ ├── raylib.nim │ │ ├── raymath.h │ │ ├── raymath.nim │ │ ├── rlgl.h │ │ └── rlgl.nim │ ├── physac.nim │ ├── raygui.nim │ ├── raylib.nim │ ├── raymath.nim │ ├── rlgl.nim │ └── static_build.nim └── templates │ ├── base_converters.nim │ ├── raymath_shortcuts.nim │ └── static_build.nim └── tests ├── emscripten ├── config.nims └── t_emscripten_crown.nim ├── examples ├── rlights.h ├── rlights.nim ├── t_audio_module_playing.nim ├── t_audio_multichannel_sound.nim ├── t_audio_music_stream.nim ├── t_audio_raw_stream.nim ├── t_basic.nim ├── t_core_2d_camera.nim ├── t_core_2d_camera_platformer.nim ├── t_core_3d_camera_first_person.nim ├── t_core_3d_camera_free.nim ├── t_core_3d_camera_mode.nim ├── t_core_3d_picking.nim ├── t_core_basic_window.nim ├── t_core_custom_logging.nim ├── t_core_input_gamepad.nim ├── t_core_input_gestures.nim ├── t_core_input_keys.nim ├── t_core_input_mouse.nim ├── t_core_input_mouse_wheel.nim ├── t_core_loading_thread.nim ├── t_core_quat_conversion.nim ├── t_core_random_values.nim ├── t_core_scissor_test.nim ├── t_core_vr_simulator.nim ├── t_core_window_flags.nim ├── t_core_window_letterbox.nim ├── t_core_world_screen.nim ├── t_crown.nim ├── t_models_first_person_maze.nim ├── t_models_geometric_shapes.nim ├── t_models_loading.nim ├── t_models_mesh_generation.nim ├── t_models_rlgl_solar_system.nim ├── t_models_waving_cubes.nim ├── t_physics_demo.nim ├── t_physics_friction.nim ├── t_physics_movement.nim ├── t_physics_restitution.nim ├── t_physics_shatter.nim ├── t_shaders_basic_lighting.nim ├── t_shaders_custom_uniform.nim ├── t_shaders_eratosthenes.nim ├── t_shaders_fog.nim ├── t_shaders_hot_reloading.nim ├── t_shaders_julia_set.nim ├── t_shaders_palette_switch.nim ├── t_shaders_raymarching.nim ├── t_shapes_bouncing_ball.nim ├── t_shapes_draw_ring.nim ├── t_shapes_following_eyes.nim ├── t_text_font_loading.nim ├── t_text_format_text.nim ├── t_text_input_box.nim ├── t_text_rectangle_bounds.nim ├── t_textures_background_scrolling.nim ├── t_textures_blend_modes.nim ├── t_textures_bunnymark.nim ├── t_textures_draw_tiled.nim ├── t_textures_image_drawing.nim ├── t_textures_image_generation.nim ├── t_textures_image_loading.nim ├── t_textures_image_processing.nim ├── t_textures_image_text.nim ├── t_textures_logo_raylib.nim ├── t_textures_mouse_painting.nim ├── t_textures_npatch_drawing.nim ├── t_textures_particles_blending.nim ├── t_textures_raw_data.nim ├── t_textures_rectangle.nim ├── t_textures_sprite_button.nim ├── t_textures_sprite_explosion.nim ├── t_textures_srcrec_dstrec.nim └── t_textures_to_image.nim ├── nim.cfg ├── texamples.nim ├── texamples_shared.nim └── texamples_windows.nim /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Build examples 2 | on: [push] 3 | jobs: 4 | build: 5 | strategy: 6 | fail-fast: false 7 | matrix: 8 | os: [windows-latest, ubuntu-18.04, macos-latest] 9 | nim-version: ['1.4.2'] 10 | # include: 11 | # - os: ubuntu-latest 12 | # nim-version: '1.6.6' 13 | runs-on: ${{ matrix.os }} 14 | steps: 15 | - name: Check out repository code 16 | uses: actions/checkout@v2 17 | with: 18 | fetch-depth: 1 19 | submodules: true 20 | 21 | - name: Install Linux dependencies 22 | if: ${{ runner.os == 'Linux' }} 23 | run: | 24 | sudo apt-get update 25 | sudo apt-get install build-essential 26 | sudo apt-get install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev 27 | 28 | - name: Install shared Raylib library on Linux 29 | if: ${{ runner.os == 'Linux' }} 30 | run: | 31 | cd raylib/src 32 | make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED 33 | sudo make install RAYLIB_LIBTYPE=SHARED 34 | 35 | - name: Install shared Raylib library on MacOS 36 | if: ${{ runner.os == 'macOS' }} 37 | run: | 38 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 39 | brew install raylib 40 | 41 | - name: Install emsdk dependency 42 | uses: mymindstorm/setup-emsdk@v9 43 | 44 | - name: Install Nim 45 | uses: jiro4989/setup-nim-action@v1 46 | with: 47 | nim-version: ${{ matrix.nim-version }} 48 | 49 | - name: Install NimraylibNow! and dependencies 50 | run: nimble install --accept 51 | - name: Try compiling a file with local installation 52 | run: nim c examples/original/crown.nim 53 | 54 | - name: Install c2nim 55 | run: nimble install --accept c2nim 56 | - name: Generate bindings 57 | run: nimble genbindings 58 | - name: Check generated bindings 59 | run: nimble checkbindings 60 | 61 | - name: Generate tests 62 | run: nimble prepareTests 63 | 64 | - name: Run megatest 65 | run: nimble testExamples 66 | 67 | - name: Run emscripten test 68 | run: nimble testEmscriptenExample 69 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !**/ 3 | !*.* 4 | 5 | *.o 6 | *.obj 7 | *.ilk 8 | *.exp 9 | *.pdb 10 | *.lib 11 | *.dll 12 | *.exe 13 | *.so 14 | *.dylib 15 | *.zip 16 | *.iss 17 | *.log 18 | *.pdb 19 | *.wasm 20 | 21 | a.out 22 | 23 | /build 24 | /nimcache 25 | /tests/megatest.nim 26 | /outputGotten.txt 27 | /testresults 28 | /tests/emscripten/*.js 29 | .ccls-cache/ 30 | /issue*/ 31 | /notes 32 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "raygui"] 2 | path = raygui 3 | url = https://github.com/raysan5/raygui.git 4 | [submodule "raylib"] 5 | path = raylib 6 | url = https://github.com/raysan5/raylib.git 7 | [submodule "physac"] 8 | path = physac 9 | url = https://github.com/raysan5/physac.git 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Any ideas are welcome. Open an issue to ask a question or suggest an idea. 4 | 5 | How to contribute: 6 | - Read [how to properly contribute to open source projects on GitHub]. 7 | - Use a topic branch to easily amend a pull request later, if necessary. 8 | - Write [good commit messages]. 9 | - Use the same coding conventions as the rest of the project, mostly [NEP1]. 10 | - Open a [pull request] that relates to _only_ one subject with a clear title and description in grammatically correct, complete sentences. 11 | 12 | [how to properly contribute to open source projects on GitHub]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request 13 | [good commit messages]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html 14 | [pull request]: https://help.github.com/articles/using-pull-requests 15 | 16 | ## Documentation 17 | 18 | Any ideas on how to improve documentation are welcome! 19 | 20 | ## Convert examples 21 | 22 | Code in examples strives to be as close to [NEP1] style guide as possible. 23 | 24 | [NEP1]: https://nim-lang.org/docs/nep1.html 25 | 26 | You can help by converting missing examples from original C library doing 27 | the following: 28 | 29 | 1. Find a missing example in C, you can use a helper script for that: 30 | `nim r scripts/find_missing_examples.nim`. 31 | 2. Compile and run `nim r scripts/c2nim_example_converter.nim examplefile.c` 32 | on this C file, check out generated `examplefile.nim`, it should be very 33 | close to the desired file. 34 | 3. Edit resulting Nim file, make sure it runs `nim r examplefile.nim`. 35 | 4. Put this file into a correct category in the `examples` directory 36 | (`original` is for self-developed examples). 37 | 5. Run `nimble prepareTests` to include this example into a test suite. 38 | 6. Run `nimble testExamples` and make sure that your example passes the test. 39 | If it doesn't pass the test, create an issue or ask me any other way, I will 40 | help. 41 | 42 | I cannot port a number of examples: 43 | * `core_drop_files.c` - I can't test it on my machine (Wayland on Linux) 44 | * `core_input_multitouch.c` - probably requires a phone to test it? 45 | * `core_storage_values.c` - I can't compile the original C example, values 46 | are reset to 0,0 when I press Space 47 | * `core_basic_window_web.c` - we have emscripten example with more information 48 | 49 | ## Work on converter script 50 | 51 | If something is broken or you see an opportunity to improve the wrapper, you 52 | can help with converter script. See [HACKING](HACKING.md). 53 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Dmitry Matveyev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /crown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/crown.png -------------------------------------------------------------------------------- /examples/audio/resources/guitar_noodling.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/audio/resources/guitar_noodling.ogg -------------------------------------------------------------------------------- /examples/audio/resources/mini1111.xm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/audio/resources/mini1111.xm -------------------------------------------------------------------------------- /examples/audio/resources/sound.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/audio/resources/sound.wav -------------------------------------------------------------------------------- /examples/audio/resources/tanatana.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/audio/resources/tanatana.ogg -------------------------------------------------------------------------------- /examples/core/core_3d_camera_mode.nim: -------------------------------------------------------------------------------- 1 | # ****************************************************************************************** 2 | # 3 | # raylib [core] example - Initialize 3d camera mode 4 | # 5 | # This example has been created using raylib 1.0 (www.raylib.com) 6 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 7 | # 8 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 9 | # Converted in 2021 by greenfork 10 | # 11 | # ****************************************************************************************** 12 | 13 | import nimraylib_now 14 | 15 | ## Initialization 16 | ## -------------------------------------------------------------------------------------- 17 | var screenWidth = 800 18 | var screenHeight = 450 19 | initWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera mode") 20 | ## Define the camera to look into our 3d world 21 | var camera = Camera3D() 22 | camera.position = (0.0, 10.0, 10.0) # Camera position 23 | camera.target = (0.0, 0.0, 0.0) # Camera looking at point 24 | camera.up = (0.0, 1.0, 0.0) # Camera up vector (rotation towards target) 25 | camera.fovy = 45.0 26 | ## Camera field-of-view Y 27 | camera.projection = Perspective 28 | ## Camera mode type 29 | var cubePosition: Vector3 = (0.0, 0.0, 0.0) 30 | setTargetFPS(60) 31 | ## Set our game to run at 60 frames-per-second 32 | ## -------------------------------------------------------------------------------------- 33 | ## Main game loop 34 | while not windowShouldClose(): ## Detect window close button or ESC key 35 | ## Update 36 | ## ---------------------------------------------------------------------------------- 37 | ## TODO: Update your variables here 38 | ## ---------------------------------------------------------------------------------- 39 | ## Draw 40 | ## ---------------------------------------------------------------------------------- 41 | beginDrawing() 42 | clearBackground(Raywhite) 43 | beginMode3D(camera) 44 | drawCube(cubePosition, 2.0, 2.0, 2.0, Red) 45 | drawCubeWires(cubePosition, 2.0, 2.0, 2.0, Maroon) 46 | drawGrid(10, 1.0) 47 | endMode3D() 48 | drawText("Welcome to the third dimension!", 10, 40, 20, Darkgray) 49 | drawFPS(10, 10) 50 | endDrawing() 51 | ## ---------------------------------------------------------------------------------- 52 | ## De-Initialization 53 | ## -------------------------------------------------------------------------------------- 54 | closeWindow() 55 | ## Close window and OpenGL context 56 | ## -------------------------------------------------------------------------------------- 57 | -------------------------------------------------------------------------------- /examples/core/core_basic_window.nim: -------------------------------------------------------------------------------- 1 | # ****************************************************************************************** 2 | # 3 | # raylib [core] example - Basic window 4 | # 5 | # Welcome to raylib! 6 | # 7 | # To test examples, just press F6 and execute raylib_compile_execute script 8 | # Note that compiled executable is placed in the same folder as .c file 9 | # 10 | # You can find all basic examples on C:\raylib\raylib\examples folder or 11 | # raylib official webpage: www.raylib.com 12 | # 13 | # Enjoy using raylib. :) 14 | # 15 | # This example has been created using raylib 1.0 (www.raylib.com) 16 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 17 | # 18 | # Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) 19 | # Converted in 2021 by greenfork 20 | # 21 | # ****************************************************************************************** 22 | 23 | import nimraylib_now 24 | 25 | ## Initialization 26 | ## -------------------------------------------------------------------------------------- 27 | var screenWidth: int32 = 800 28 | var screenHeight: int32 = 450 29 | initWindow(screenWidth, screenHeight, "raylib [core] example - basic window") 30 | setTargetFPS(60) 31 | ## Set our game to run at 60 frames-per-second 32 | ## -------------------------------------------------------------------------------------- 33 | ## Main game loop 34 | while not windowShouldClose(): ## Detect window close button or ESC key 35 | ## Update 36 | ## ---------------------------------------------------------------------------------- 37 | ## TODO: Update your variables here 38 | ## ---------------------------------------------------------------------------------- 39 | ## Draw 40 | ## ---------------------------------------------------------------------------------- 41 | beginDrawing() 42 | clearBackground(Raywhite) 43 | drawText("Congrats! You created your first window!", 190, 200, 20, Lightgray) 44 | endDrawing() 45 | ## ---------------------------------------------------------------------------------- 46 | ## De-Initialization 47 | ## -------------------------------------------------------------------------------------- 48 | closeWindow() 49 | ## Close window and OpenGL context 50 | ## -------------------------------------------------------------------------------------- 51 | -------------------------------------------------------------------------------- /examples/core/core_input_keys.nim: -------------------------------------------------------------------------------- 1 | #******************************************************************************************* 2 | # 3 | # raylib [core] example - Keyboard input 4 | # 5 | # This example has been created using raylib 1.0 (www.raylib.com) 6 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 7 | # 8 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 9 | # /Converted in 2*20 by Guevara-chan. 10 | # Adapted in 2021 by greenfork 11 | # 12 | #******************************************************************************************* 13 | 14 | import nimraylib_now 15 | # Initialization 16 | #-------------------------------------------------------------------------------------- 17 | const screenWidth = 800 18 | const screenHeight = 450 19 | 20 | initWindow screenWidth, screenHeight, "raylib [core] example - keyboard input" 21 | 22 | var ballPosition: Vector2 = (x: screenWidth/2, y: screenHeight/2) 23 | 24 | 60.setTargetFPS # Set our game to run at 60 frames-per-second 25 | #-------------------------------------------------------------------------------------- 26 | 27 | # Main game loop 28 | while not windowShouldClose(): # Detect window close button or ESC key 29 | # Update 30 | # ---------------------------------------------------------------------------------- 31 | if isKeyDown(KeyboardKey.Right): ballPosition.x += 2.0 32 | if isKeyDown(KeyboardKey.Left): ballPosition.x -= 2.0 33 | if isKeyDown(Up): ballPosition.y -= 2.0 34 | if isKeyDown(Down): ballPosition.y += 2.0 35 | # ---------------------------------------------------------------------------------- 36 | 37 | # Draw 38 | # ---------------------------------------------------------------------------------- 39 | beginDrawing() 40 | clearBackground RAYWHITE 41 | 42 | drawText "move the ball with arrow keys", 10, 10, 20, DARKGRAY 43 | 44 | drawCircleV ballPosition, 50, MAROON 45 | 46 | endDrawing() 47 | # ---------------------------------------------------------------------------------- 48 | # De-Initialization 49 | # -------------------------------------------------------------------------------------- 50 | closeWindow() # Close window and OpenGL context 51 | # -------------------------------------------------------------------------------------- 52 | -------------------------------------------------------------------------------- /examples/core/core_input_mouse.nim: -------------------------------------------------------------------------------- 1 | # ****************************************************************************************** 2 | # 3 | # raylib [core] example - Mouse input 4 | # 5 | # This example has been created using raylib 1.0 (www.raylib.com) 6 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 7 | # 8 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 9 | # Converted in 2021 by greenfork 10 | # 11 | # ****************************************************************************************** 12 | 13 | import nimraylib_now 14 | 15 | ## Initialization 16 | ## -------------------------------------------------------------------------------------- 17 | var screenWidth: int32 = 800 18 | var screenHeight: int32 = 450 19 | initWindow(screenWidth, screenHeight, "raylib [core] example - mouse input") 20 | var ballPosition: Vector2 = (-100.0, -100.0) 21 | var ballColor: Color = Darkblue 22 | setTargetFPS(60) 23 | ## Set our game to run at 60 frames-per-second 24 | ## --------------------------------------------------------------------------------------- 25 | ## Main game loop 26 | while not windowShouldClose(): ## Detect window close button or ESC key 27 | ## Update 28 | ## ---------------------------------------------------------------------------------- 29 | ballPosition = getMousePosition() 30 | if isMouseButtonPressed(MouseButton.Left): 31 | ballColor = Maroon 32 | elif isMouseButtonPressed(MouseButton.Middle): 33 | ballColor = Lime 34 | elif isMouseButtonPressed(MouseButton.Right): 35 | ballColor = Darkblue 36 | ## ---------------------------------------------------------------------------------- 37 | ## Draw 38 | ## ---------------------------------------------------------------------------------- 39 | beginDrawing() 40 | clearBackground(Raywhite) 41 | drawCircleV(ballPosition, 40, ballColor) 42 | drawText("move ball with mouse and click mouse button to change color", 10, 43 | 10, 20, Darkgray) 44 | endDrawing() 45 | ## ---------------------------------------------------------------------------------- 46 | ## De-Initialization 47 | ## -------------------------------------------------------------------------------------- 48 | closeWindow() 49 | ## Close window and OpenGL context 50 | ## -------------------------------------------------------------------------------------- 51 | -------------------------------------------------------------------------------- /examples/core/core_input_mouse_wheel.nim: -------------------------------------------------------------------------------- 1 | # ****************************************************************************************** 2 | # 3 | # raylib [core] examples - Mouse wheel input 4 | # 5 | # This test has been created using raylib 1.1 (www.raylib.com) 6 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 7 | # 8 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 9 | # Converted in 2021 by greenfork 10 | # 11 | # ****************************************************************************************** 12 | 13 | import nimraylib_now 14 | 15 | ## Initialization 16 | ## -------------------------------------------------------------------------------------- 17 | var screenWidth: int32 = 800 18 | var screenHeight: int32 = 450 19 | initWindow(screenWidth, screenHeight, 20 | "raylib [core] example - input mouse wheel") 21 | var boxPositionY: int32 = screenHeight div 2 - 40 22 | var scrollSpeed: int32 = 4 23 | ## Scrolling speed in pixels 24 | setTargetFPS(60) 25 | ## Set our game to run at 60 frames-per-second 26 | ## -------------------------------------------------------------------------------------- 27 | ## Main game loop 28 | while not windowShouldClose(): ## Detect window close button or ESC key 29 | ## Update 30 | ## ---------------------------------------------------------------------------------- 31 | inc(boxPositionY, (getMouseWheelMove().int32 * scrollSpeed)) 32 | ## ---------------------------------------------------------------------------------- 33 | ## Draw 34 | ## ---------------------------------------------------------------------------------- 35 | beginDrawing() 36 | clearBackground(Raywhite) 37 | drawRectangle(screenWidth div 2 - 40, boxPositionY, 80, 80, Maroon) 38 | drawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, Gray) 39 | drawText(textFormat("Box position Y: %03i", boxPositionY), 10, 40, 20, Lightgray) 40 | endDrawing() 41 | ## ---------------------------------------------------------------------------------- 42 | ## De-Initialization 43 | ## -------------------------------------------------------------------------------------- 44 | closeWindow() 45 | ## Close window and OpenGL context 46 | ## -------------------------------------------------------------------------------------- 47 | -------------------------------------------------------------------------------- /examples/core/core_random_values.nim: -------------------------------------------------------------------------------- 1 | # ****************************************************************************************** 2 | # 3 | # raylib [core] example - Generate random values 4 | # 5 | # This example has been created using raylib 1.1 (www.raylib.com) 6 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 7 | # 8 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 9 | # Converted in 2021 by greenfork 10 | # 11 | # ****************************************************************************************** 12 | 13 | import nimraylib_now 14 | 15 | ## Initialization 16 | ## -------------------------------------------------------------------------------------- 17 | var screenWidth: int32 = 800 18 | var screenHeight: int32 = 450 19 | initWindow(screenWidth, screenHeight, 20 | "raylib [core] example - generate random values") 21 | var framesCounter: int32 = 0 ## Variable used to count frames 22 | var randValue: int32 = getRandomValue(-8, 5) ## Get a random integer number between -8 and 5 (both included) 23 | setTargetFPS(60) ## Set our game to run at 60 frames-per-second 24 | ## -------------------------------------------------------------------------------------- 25 | ## Main game loop 26 | while not windowShouldClose(): ## Detect window close button or ESC key 27 | ## Update 28 | ## ---------------------------------------------------------------------------------- 29 | inc(framesCounter) 30 | ## Every two seconds (120 frames) a new random value is generated 31 | if ((framesCounter div 120) mod 2) == 1: 32 | randValue = getRandomValue(-8, 5) 33 | framesCounter = 0 34 | beginDrawing() 35 | clearBackground(Raywhite) 36 | drawText("Every 2 seconds a new random value is generated:", 130, 100, 20, 37 | Maroon) 38 | drawText(textFormat("%i", randValue), 360, 180, 80, Lightgray) 39 | endDrawing() 40 | ## ---------------------------------------------------------------------------------- 41 | ## De-Initialization 42 | ## -------------------------------------------------------------------------------------- 43 | closeWindow() 44 | ## Close window and OpenGL context 45 | ## -------------------------------------------------------------------------------------- 46 | -------------------------------------------------------------------------------- /examples/core/resources/LICENSE: -------------------------------------------------------------------------------- 1 | | resource | author | licence | notes | 2 | | :------------ | :---------: | :------ | :---- | 3 | | ps3.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | 4 | | xbox.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | 5 | -------------------------------------------------------------------------------- /examples/core/resources/distortion100.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | uniform vec2 leftLensCenter; 15 | uniform vec2 rightLensCenter; 16 | uniform vec2 leftScreenCenter; 17 | uniform vec2 rightScreenCenter; 18 | uniform vec2 scale; 19 | uniform vec2 scaleIn; 20 | uniform vec4 hmdWarpParam; 21 | uniform vec4 chromaAbParam; 22 | 23 | void main() 24 | { 25 | // Compute lens distortion 26 | vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter; 27 | vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter; 28 | vec2 theta = (fragTexCoord - lensCenter)*scaleIn; 29 | float rSq = theta.x*theta.x + theta.y*theta.y; 30 | vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq); 31 | vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq); 32 | vec2 tcBlue = lensCenter + scale*thetaBlue; 33 | 34 | if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue))) 35 | { 36 | // Set black fragment for everything outside the lens border 37 | gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); 38 | } 39 | else 40 | { 41 | // Compute color chroma aberration 42 | float blue = texture2D(texture0, tcBlue).b; 43 | vec2 tcGreen = lensCenter + scale*theta1; 44 | float green = texture2D(texture0, tcGreen).g; 45 | 46 | vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq); 47 | vec2 tcRed = lensCenter + scale*thetaRed; 48 | 49 | float red = texture2D(texture0, tcRed).r; 50 | gl_FragColor = vec4(red, green, blue, 1.0); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/core/resources/distortion330.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | uniform vec2 leftLensCenter = vec2(0.288, 0.5); 16 | uniform vec2 rightLensCenter = vec2(0.712, 0.5); 17 | uniform vec2 leftScreenCenter = vec2(0.25, 0.5); 18 | uniform vec2 rightScreenCenter = vec2(0.75, 0.5); 19 | uniform vec2 scale = vec2(0.25, 0.45); 20 | uniform vec2 scaleIn = vec2(4, 2.2222); 21 | uniform vec4 hmdWarpParam = vec4(1, 0.22, 0.24, 0); 22 | uniform vec4 chromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); 23 | 24 | void main() 25 | { 26 | // Compute lens distortion 27 | vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter; 28 | vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter; 29 | vec2 theta = (fragTexCoord - lensCenter)*scaleIn; 30 | float rSq = theta.x*theta.x + theta.y*theta.y; 31 | vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq); 32 | vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq); 33 | vec2 tcBlue = lensCenter + scale*thetaBlue; 34 | 35 | if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue))) 36 | { 37 | // Set black fragment for everything outside the lens border 38 | finalColor = vec4(0.0, 0.0, 0.0, 1.0); 39 | } 40 | else 41 | { 42 | // Compute color chroma aberration 43 | float blue = texture(texture0, tcBlue).b; 44 | vec2 tcGreen = lensCenter + scale*theta1; 45 | float green = texture(texture0, tcGreen).g; 46 | 47 | vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq); 48 | vec2 tcRed = lensCenter + scale*thetaRed; 49 | 50 | float red = texture(texture0, tcRed).r; 51 | finalColor = vec4(red, green, blue, 1.0); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /examples/core/resources/ps3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/core/resources/ps3.png -------------------------------------------------------------------------------- /examples/core/resources/xbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/core/resources/xbox.png -------------------------------------------------------------------------------- /examples/emscripten/.gitignore: -------------------------------------------------------------------------------- 1 | /tmp 2 | /public/* 3 | -------------------------------------------------------------------------------- /examples/emscripten/README.md: -------------------------------------------------------------------------------- 1 | # Emscripten with NimraylibNow! 2 | 3 | This is experimental support for Emscripten. Please report any bugs. 4 | 5 | 1. Follow an amazing treeform's guide [Nim Emscripten tutorial]. As of 2021-05-08 6 | only steps 0, 1 and 2 work, it is okay if 3 and 4 do not compile. 7 | 2. Compile the Nim source file (`-d:release` for extra speed): 8 | ``` 9 | $ nim c -d:release -o:public/index.html emscripten_crown.nim 10 | ``` 11 | 3. Install and run `nimhttpd` server: 12 | ``` 13 | $ nimble install nimhttpd 14 | $ nimhttpd 15 | ``` 16 | 4. Open the output file in a browser http://localhost:1337/public/. 17 | 18 | [Nim Emscripten tutorial]: https://github.com/treeform/nim_emscripten_tutorial 19 | 20 | ## Tips and tricks 21 | 22 | - Make sure to include `config.nims` in the same directory as your source file 23 | and edit it if needed. 24 | - Replace `while not windowShouldClose():` used for native compilation 25 | with `emscriptenSetMainLoop` and a callback as in the example. 26 | - Music may not play if the window is not in focus, click on the game window to 27 | make it focused. 28 | 29 | ## Compile options 30 | 31 | ### NimraylibNowTotalMemory 32 | 33 | Use `NimraylibNowTotalMemory` define to override the memory size, the default is 34 | 134217728: 35 | ``` 36 | -d:NimraylibNowTotalMemory=64000 37 | ``` 38 | 39 | ### nimraylib_now_web_resources and NimraylibNowWebResourcesPath 40 | 41 | `config.nims` contains a `nimraylib_now_web_resources` define which includes 42 | files under "resources" directory into the virtual file system so that 43 | these files can be used inside your game, see [packaging](https://emscripten.org/docs/porting/files/packaging_files.html). 44 | 45 | In order to disable it, remove `--define:nimraylib_now_web_resources` from your 46 | config file. 47 | 48 | In order to change the path to "assets", add `--define:NimraylibNowWebResourcesPath=assets` 49 | to your config file. 50 | -------------------------------------------------------------------------------- /examples/emscripten/config.nims: -------------------------------------------------------------------------------- 1 | --define:emscripten # Specify target 2 | 3 | --os:linux # Emscripten pretends to be linux. 4 | --cpu:wasm32 # Emscripten is 32bits. 5 | --cc:clang # Emscripten is very close to clang, so we will replace it. 6 | when defined(windows): 7 | --clang.exe:emcc.bat # Replace C 8 | --clang.linkerexe:emcc.bat # Replace C linker 9 | --clang.cpp.exe:emcc.bat # Replace C++ 10 | --clang.cpp.linkerexe:emcc.bat # Replace C++ linker. 11 | else: 12 | --clang.exe:emcc # Replace C 13 | --clang.linkerexe:emcc # Replace C linker 14 | --clang.cpp.exe:emcc # Replace C++ 15 | --clang.cpp.linkerexe:emcc # Replace C++ linker. 16 | 17 | --gc:orc # GC:orc is friendlier with crazy platforms. 18 | --exceptions:goto # Goto exceptions are friendlier with crazy platforms. 19 | --define:noSignalHandler # Emscripten doesn't support signal handlers. 20 | 21 | --define:nimraylib_now_web_resources 22 | -------------------------------------------------------------------------------- /examples/emscripten/public/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/emscripten/public/.gitkeep -------------------------------------------------------------------------------- /examples/emscripten/resources/ambient.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/emscripten/resources/ambient.ogg -------------------------------------------------------------------------------- /examples/models/resources/castle_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/models/resources/castle_diffuse.png -------------------------------------------------------------------------------- /examples/models/resources/cubicmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/models/resources/cubicmap.png -------------------------------------------------------------------------------- /examples/models/resources/cubicmap_atlas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/models/resources/cubicmap_atlas.png -------------------------------------------------------------------------------- /examples/original/basic.nim: -------------------------------------------------------------------------------- 1 | # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # 2 | # Raylib Forever basic usage sample 3 | # Developed in 2*20 by Guevara-chan 4 | # Adapted in 2021 by greenfork 5 | # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # 6 | 7 | import nimraylib_now 8 | 9 | initWindow 800, 600, "[nim]RaylibNow!" 10 | 60.setTargetFPS 11 | 12 | # Camera setup. 13 | var camera = Camera( 14 | position: (x: 0.0, y: 10.0, z: -15.0), 15 | up: (x: 0.0, y: 0.5, z: 0.0), 16 | fovy: 45 17 | ) 18 | camera.setCameraMode Orbital 19 | 20 | # ==Main code== 21 | while not windowShouldClose(): 22 | camera.addr.updateCamera 23 | beginDrawing() 24 | label (x: 10.0, y: 0.0, width: 100.0, height: 25.0), "by V.A. Guevara" 25 | clearBackground(Black) 26 | beginMode3D(camera) 27 | drawGrid 10, 1.0 28 | drawSphere (0.0, 0.0, 0.0), 0.5, Red 29 | endMode3D() 30 | let 31 | slogan = "/Hello from Nim/" 32 | size = 20 33 | width = measureText(slogan, size) 34 | slogan.drawText( 35 | (getScreenWidth() - width) div 2, 36 | getScreenHeight() div 2 - 100, 37 | size, 38 | LightGray 39 | ) 40 | drawRectangleV( 41 | (x: 10.0, y: 10.0), 42 | (x: (getScreenWidth() - 20).float, y: (getScreenHeight() - 20).float), 43 | (r: 255, g: 0, b: 0, a: 20) 44 | ) 45 | endDrawing() 46 | -------------------------------------------------------------------------------- /examples/shaders/resources/fudesumi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/shaders/resources/fudesumi.png -------------------------------------------------------------------------------- /examples/shaders/resources/mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/shaders/resources/mask.png -------------------------------------------------------------------------------- /examples/shaders/resources/models/barracks_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/shaders/resources/models/barracks_diffuse.png -------------------------------------------------------------------------------- /examples/shaders/resources/models/church_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/shaders/resources/models/church_diffuse.png -------------------------------------------------------------------------------- /examples/shaders/resources/models/watermill_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/shaders/resources/models/watermill_diffuse.png -------------------------------------------------------------------------------- /examples/shaders/resources/plasma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/shaders/resources/plasma.png -------------------------------------------------------------------------------- /examples/shaders/resources/raysan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/shaders/resources/raysan.png -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/base.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | void main() 16 | { 17 | // Texel color fetching from texture sampler 18 | vec4 texelColor = texture2D(texture0, fragTexCoord); 19 | 20 | // NOTE: Implement here your fragment shader code 21 | 22 | gl_FragColor = texelColor*colDiffuse; 23 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/base.vs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | // Input vertex attributes 4 | attribute vec3 vertexPosition; 5 | attribute vec2 vertexTexCoord; 6 | attribute vec3 vertexNormal; 7 | attribute vec4 vertexColor; 8 | 9 | // Input uniform values 10 | uniform mat4 mvp; 11 | 12 | // Output vertex attributes (to fragment shader) 13 | varying vec2 fragTexCoord; 14 | varying vec4 fragColor; 15 | 16 | // NOTE: Add here your custom variables 17 | 18 | void main() 19 | { 20 | // Send vertex attributes to fragment shader 21 | fragTexCoord = vertexTexCoord; 22 | fragColor = vertexColor; 23 | 24 | // Calculate final vertex position 25 | gl_Position = mvp*vec4(vertexPosition, 1.0); 26 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/base_lighting.vs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | // Input vertex attributes 4 | attribute vec3 vertexPosition; 5 | attribute vec2 vertexTexCoord; 6 | attribute vec3 vertexNormal; 7 | attribute vec4 vertexColor; 8 | 9 | // Input uniform values 10 | uniform mat4 mvp; 11 | uniform mat4 matModel; 12 | 13 | // Output vertex attributes (to fragment shader) 14 | varying vec3 fragPosition; 15 | varying vec2 fragTexCoord; 16 | varying vec4 fragColor; 17 | varying vec3 fragNormal; 18 | 19 | // NOTE: Add here your custom variables 20 | 21 | // https://github.com/glslify/glsl-inverse 22 | mat3 inverse(mat3 m) 23 | { 24 | float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2]; 25 | float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2]; 26 | float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2]; 27 | 28 | float b01 = a22*a11 - a12*a21; 29 | float b11 = -a22*a10 + a12*a20; 30 | float b21 = a21*a10 - a11*a20; 31 | 32 | float det = a00*b01 + a01*b11 + a02*b21; 33 | 34 | return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11), 35 | b11, (a22*a00 - a02*a20), (-a12*a00 + a02*a10), 36 | b21, (-a21*a00 + a01*a20), (a11*a00 - a01*a10))/det; 37 | } 38 | 39 | // https://github.com/glslify/glsl-transpose 40 | mat3 transpose(mat3 m) 41 | { 42 | return mat3(m[0][0], m[1][0], m[2][0], 43 | m[0][1], m[1][1], m[2][1], 44 | m[0][2], m[1][2], m[2][2]); 45 | } 46 | 47 | void main() 48 | { 49 | // Send vertex attributes to fragment shader 50 | fragPosition = vec3(matModel*vec4(vertexPosition, 1.0)); 51 | fragTexCoord = vertexTexCoord; 52 | fragColor = vertexColor; 53 | 54 | mat3 normalMatrix = transpose(inverse(mat3(matModel))); 55 | fragNormal = normalize(normalMatrix*vertexNormal); 56 | 57 | // Calculate final vertex position 58 | gl_Position = mvp*vec4(vertexPosition, 1.0); 59 | } 60 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/bloom.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | const vec2 size = vec2(800, 450); // render size 16 | const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance 17 | const float quality = 2.5; // lower = smaller glow, better quality 18 | 19 | void main() 20 | { 21 | vec4 sum = vec4(0); 22 | vec2 sizeFactor = vec2(1)/size*quality; 23 | 24 | // Texel color fetching from texture sampler 25 | vec4 source = texture2D(texture0, fragTexCoord); 26 | 27 | const int range = 2; // should be = (samples - 1)/2; 28 | 29 | for (int x = -range; x <= range; x++) 30 | { 31 | for (int y = -range; y <= range; y++) 32 | { 33 | sum += texture2D(texture0, fragTexCoord + vec2(x, y)*sizeFactor); 34 | } 35 | } 36 | 37 | // Calculate final fragment color 38 | gl_FragColor = ((sum/(samples*samples)) + source)*colDiffuse; 39 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/blur.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | // NOTE: Render size values must be passed from code 16 | const float renderWidth = 800.0; 17 | const float renderHeight = 450.0; 18 | 19 | vec3 offset = vec3(0.0, 1.3846153846, 3.2307692308); 20 | vec3 weight = vec3(0.2270270270, 0.3162162162, 0.0702702703); 21 | 22 | void main() 23 | { 24 | // Texel color fetching from texture sampler 25 | vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight.x; 26 | 27 | tc += texture2D(texture0, fragTexCoord + vec2(offset.y)/renderWidth, 0.0).rgb*weight.y; 28 | tc += texture2D(texture0, fragTexCoord - vec2(offset.y)/renderWidth, 0.0).rgb*weight.y; 29 | 30 | tc += texture2D(texture0, fragTexCoord + vec2(offset.z)/renderWidth, 0.0).rgb*weight.z; 31 | tc += texture2D(texture0, fragTexCoord - vec2(offset.z)/renderWidth, 0.0).rgb*weight.z; 32 | 33 | gl_FragColor = vec4(tc, 1.0); 34 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/color_mix.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform sampler2D texture1; 12 | uniform vec4 colDiffuse; 13 | 14 | void main() 15 | { 16 | // Texel color fetching from texture sampler 17 | vec4 texelColor0 = texture2D(texture0, fragTexCoord); 18 | vec4 texelColor1 = texture2D(texture1, fragTexCoord); 19 | 20 | float x = fract(fragTexCoord.s); 21 | float out = smoothstep(0.4, 0.6, x); 22 | 23 | gl_FragColor = mix(texelColor0, texelColor1, out); 24 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/cross_hatching.fs: -------------------------------------------------------------------------------- 1 | # version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | float hatchOffsetY = 5.0; 16 | float lumThreshold01 = 0.9; 17 | float lumThreshold02 = 0.7; 18 | float lumThreshold03 = 0.5; 19 | float lumThreshold04 = 0.3; 20 | 21 | void main() 22 | { 23 | vec3 tc = vec3(1.0, 1.0, 1.0); 24 | float lum = length(texture2D(texture0, fragTexCoord).rgb); 25 | 26 | if (lum < lumThreshold01) 27 | { 28 | if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 29 | } 30 | 31 | if (lum < lumThreshold02) 32 | { 33 | if (mod(gl_FragCoord .x - gl_FragCoord .y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 34 | } 35 | 36 | if (lum < lumThreshold03) 37 | { 38 | if (mod(gl_FragCoord .x + gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 39 | } 40 | 41 | if (lum < lumThreshold04) 42 | { 43 | if (mod(gl_FragCoord .x - gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 44 | } 45 | 46 | gl_FragColor = vec4(tc, 1.0); 47 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/cross_stitching.fs: -------------------------------------------------------------------------------- 1 | # version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | // NOTE: Render size values must be passed from code 16 | const float renderWidth = 800.0; 17 | const float renderHeight = 450.0; 18 | 19 | float stitchingSize = 6.0; 20 | int invert = 0; 21 | 22 | vec4 PostFX(sampler2D tex, vec2 uv) 23 | { 24 | vec4 c = vec4(0.0); 25 | float size = stitchingSize; 26 | vec2 cPos = uv * vec2(renderWidth, renderHeight); 27 | vec2 tlPos = floor(cPos / vec2(size, size)); 28 | tlPos *= size; 29 | 30 | int remX = int(mod(cPos.x, size)); 31 | int remY = int(mod(cPos.y, size)); 32 | 33 | if (remX == 0 && remY == 0) tlPos = cPos; 34 | 35 | vec2 blPos = tlPos; 36 | blPos.y += (size - 1.0); 37 | 38 | if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y))))) 39 | { 40 | if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0); 41 | else c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4; 42 | } 43 | else 44 | { 45 | if (invert == 1) c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4; 46 | else c = vec4(0.0, 0.0, 0.0, 1.0); 47 | } 48 | 49 | return c; 50 | } 51 | 52 | void main() 53 | { 54 | vec3 tc = PostFX(texture0, fragTexCoord).rgb; 55 | 56 | gl_FragColor = vec4(tc, 1.0); 57 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/cubes_panning.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Custom variables 10 | const float PI = 3.14159265358979323846; 11 | uniform float uTime; 12 | 13 | float divisions = 5.0; 14 | float angle = 0.0; 15 | 16 | vec2 VectorRotateTime(vec2 v, float speed) 17 | { 18 | float time = uTime*speed; 19 | float localTime = fract(time); // The time domain this works on is 1 sec. 20 | 21 | if ((localTime >= 0.0) && (localTime < 0.25)) angle = 0.0; 22 | else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4.0*sin(2.0*PI*localTime - PI/2.0); 23 | else if ((localTime >= 0.50) && (localTime < 0.75)) angle = PI*0.25; 24 | else if ((localTime >= 0.75) && (localTime < 1.00)) angle = PI/4.0*sin(2.0*PI*localTime); 25 | 26 | // Rotate vector by angle 27 | v -= 0.5; 28 | v = mat2(cos(angle), -sin(angle), sin(angle), cos(angle))*v; 29 | v += 0.5; 30 | 31 | return v; 32 | } 33 | 34 | float Rectangle(in vec2 st, in float size, in float fill) 35 | { 36 | float roundSize = 0.5 - size/2.0; 37 | float left = step(roundSize, st.x); 38 | float top = step(roundSize, st.y); 39 | float bottom = step(roundSize, 1.0 - st.y); 40 | float right = step(roundSize, 1.0 - st.x); 41 | 42 | return (left*bottom*right*top)*fill; 43 | } 44 | 45 | void main() 46 | { 47 | vec2 fragPos = fragTexCoord; 48 | fragPos.xy += uTime/9.0; 49 | 50 | fragPos *= divisions; 51 | vec2 ipos = floor(fragPos); // Get the integer coords 52 | vec2 fpos = fract(fragPos); // Get the fractional coords 53 | 54 | fpos = VectorRotateTime(fpos, 0.2); 55 | 56 | float alpha = Rectangle(fpos, 0.216, 1.0); 57 | vec3 color = vec3(0.3, 0.3, 0.3); 58 | 59 | gl_FragColor = vec4(color, alpha); 60 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/depth.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; // Depth texture 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | void main() 16 | { 17 | float zNear = 0.01; // camera z near 18 | float zFar = 10.0; // camera z far 19 | float z = texture2D(texture0, fragTexCoord).x; 20 | 21 | // Linearize depth value 22 | float depth = (2.0*zNear)/(zFar + zNear - z*(zFar - zNear)); 23 | 24 | // Calculate final fragment color 25 | gl_FragColor = vec4(depth, depth, depth, 1.0f); 26 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/distortion.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | 8 | // Input uniform values 9 | uniform sampler2D texture0; 10 | 11 | // NOTE: Default parameters for Oculus Rift DK2 device 12 | const vec2 LeftLensCenter = vec2(0.2863248, 0.5); 13 | const vec2 RightLensCenter = vec2(0.7136753, 0.5); 14 | const vec2 LeftScreenCenter = vec2(0.25, 0.5); 15 | const vec2 RightScreenCenter = vec2(0.75, 0.5); 16 | const vec2 Scale = vec2(0.25, 0.45); 17 | const vec2 ScaleIn = vec2(4.0, 2.5); 18 | const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0); 19 | const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); 20 | 21 | void main() 22 | { 23 | // The following two variables need to be set per eye 24 | vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter; 25 | vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter; 26 | 27 | // Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter) 28 | vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1] 29 | float rSq = theta.x*theta.x + theta.y*theta.y; 30 | vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); 31 | //vec2 tc = LensCenter + Scale*theta1; 32 | 33 | // Detect whether blue texture coordinates are out of range since these will scaled out the furthest 34 | vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq); 35 | vec2 tcBlue = LensCenter + Scale*thetaBlue; 36 | 37 | if (any(bvec2(clamp(tcBlue, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tcBlue))) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); 38 | else 39 | { 40 | // Do blue texture lookup 41 | float blue = texture2D(texture0, tcBlue).b; 42 | 43 | // Do green lookup (no scaling) 44 | vec2 tcGreen = LensCenter + Scale*theta1; 45 | float green = texture2D(texture0, tcGreen).g; 46 | 47 | // Do red scale and lookup 48 | vec2 thetaRed = theta1*(ChromaAbParam.x + ChromaAbParam.y*rSq); 49 | vec2 tcRed = LensCenter + Scale*thetaRed; 50 | float red = texture2D(texture0, tcRed).r; 51 | 52 | gl_FragColor = vec4(red, green, blue, 1.0); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/dream_vision.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | void main() 16 | { 17 | vec4 color = texture2D(texture0, fragTexCoord); 18 | 19 | color += texture2D(texture0, fragTexCoord + 0.001); 20 | color += texture2D(texture0, fragTexCoord + 0.003); 21 | color += texture2D(texture0, fragTexCoord + 0.005); 22 | color += texture2D(texture0, fragTexCoord + 0.007); 23 | color += texture2D(texture0, fragTexCoord + 0.009); 24 | color += texture2D(texture0, fragTexCoord + 0.011); 25 | 26 | color += texture2D(texture0, fragTexCoord - 0.001); 27 | color += texture2D(texture0, fragTexCoord - 0.003); 28 | color += texture2D(texture0, fragTexCoord - 0.005); 29 | color += texture2D(texture0, fragTexCoord - 0.007); 30 | color += texture2D(texture0, fragTexCoord - 0.009); 31 | color += texture2D(texture0, fragTexCoord - 0.011); 32 | 33 | color.rgb = vec3((color.r + color.g + color.b)/3.0); 34 | color = color/9.5; 35 | 36 | gl_FragColor = color; 37 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/eratosthenes.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | /************************************************************************************* 6 | 7 | The Sieve of Eratosthenes -- a simple shader by ProfJski 8 | An early prime number sieve: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes 9 | 10 | The screen is divided into a square grid of boxes, each representing an integer value. 11 | Each integer is tested to see if it is a prime number. Primes are colored white. 12 | Non-primes are colored with a color that indicates the smallest factor which evenly divdes our integer. 13 | 14 | You can change the scale variable to make a larger or smaller grid. 15 | Total number of integers displayed = scale squared, so scale = 100 tests the first 10,000 integers. 16 | 17 | WARNING: If you make scale too large, your GPU may bog down! 18 | 19 | ***************************************************************************************/ 20 | 21 | // Input vertex attributes (from vertex shader) 22 | varying vec2 fragTexCoord; 23 | varying vec4 fragColor; 24 | 25 | // Make a nice spectrum of colors based on counter and maxSize 26 | vec4 Colorizer(float counter, float maxSize) 27 | { 28 | float red = 0.0, green = 0.0, blue = 0.0; 29 | float normsize = counter/maxSize; 30 | 31 | red = smoothstep(0.3, 0.7, normsize); 32 | green = sin(3.14159*normsize); 33 | blue = 1.0 - smoothstep(0.0, 0.4, normsize); 34 | 35 | return vec4(0.8*red, 0.8*green, 0.8*blue, 1.0); 36 | } 37 | 38 | void main() 39 | { 40 | vec4 color = vec4(1.0); 41 | float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid. 42 | float value = scale*floor(fragTexCoord.y*scale) + floor(fragTexCoord.x*scale); // Group pixels into boxes representing integer values 43 | int valuei = int(value); 44 | 45 | //if ((valuei == 0) || (valuei == 1) || (valuei == 2)) gl_FragColor = vec4(1.0); 46 | //else 47 | { 48 | //for (int i = 2; (i < int(max(2.0, sqrt(value) + 1.0))); i++) 49 | // NOTE: On GLSL 100 for loops are restricted and loop condition must be a constant 50 | // Tested on RPI, it seems loops are limited around 60 iteractions 51 | for (int i = 2; i < 48; i++) 52 | { 53 | if ((value - float(i)*floor(value/float(i))) <= 0.0) 54 | { 55 | gl_FragColor = Colorizer(float(i), scale); 56 | //break; // Uncomment to color by the largest factor instead 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/fisheye.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | const float PI = 3.1415926535; 16 | 17 | void main() 18 | { 19 | float aperture = 178.0; 20 | float apertureHalf = 0.5 * aperture * (PI / 180.0); 21 | float maxFactor = sin(apertureHalf); 22 | 23 | vec2 uv = vec2(0.0); 24 | vec2 xy = 2.0 * fragTexCoord.xy - 1.0; 25 | float d = length(xy); 26 | 27 | if (d < (2.0 - maxFactor)) 28 | { 29 | d = length(xy * maxFactor); 30 | float z = sqrt(1.0 - d * d); 31 | float r = atan(d, z) / PI; 32 | float phi = atan(xy.y, xy.x); 33 | 34 | uv.x = r * cos(phi) + 0.5; 35 | uv.y = r * sin(phi) + 0.5; 36 | } 37 | else 38 | { 39 | uv = fragTexCoord.xy; 40 | } 41 | 42 | gl_FragColor = texture2D(texture0, uv); 43 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/grayscale.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | void main() 16 | { 17 | // Texel color fetching from texture sampler 18 | vec4 texelColor = texture2D(texture0, fragTexCoord)*colDiffuse*fragColor; 19 | 20 | // Convert texel color to grayscale using NTSC conversion weights 21 | float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114)); 22 | 23 | // Calculate final fragment color 24 | gl_FragColor = vec4(gray, gray, gray, texelColor.a); 25 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/lighting.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec3 fragPosition; 7 | varying vec2 fragTexCoord; 8 | varying vec4 fragColor; 9 | varying vec3 fragNormal; 10 | 11 | // Input uniform values 12 | uniform sampler2D texture0; 13 | uniform vec4 colDiffuse; 14 | 15 | // NOTE: Add here your custom variables 16 | 17 | #define MAX_LIGHTS 4 18 | #define LIGHT_DIRECTIONAL 0 19 | #define LIGHT_POINT 1 20 | 21 | struct MaterialProperty { 22 | vec3 color; 23 | int useSampler; 24 | sampler2D sampler; 25 | }; 26 | 27 | struct Light { 28 | int enabled; 29 | int type; 30 | vec3 position; 31 | vec3 target; 32 | vec4 color; 33 | }; 34 | 35 | // Input lighting values 36 | uniform Light lights[MAX_LIGHTS]; 37 | uniform vec4 ambient; 38 | uniform vec3 viewPos; 39 | 40 | void main() 41 | { 42 | // Texel color fetching from texture sampler 43 | vec4 texelColor = texture2D(texture0, fragTexCoord); 44 | vec3 lightDot = vec3(0.0); 45 | vec3 normal = normalize(fragNormal); 46 | vec3 viewD = normalize(viewPos - fragPosition); 47 | vec3 specular = vec3(0.0); 48 | 49 | // NOTE: Implement here your fragment shader code 50 | 51 | for (int i = 0; i < MAX_LIGHTS; i++) 52 | { 53 | if (lights[i].enabled == 1) 54 | { 55 | vec3 light = vec3(0.0); 56 | 57 | if (lights[i].type == LIGHT_DIRECTIONAL) 58 | { 59 | light = -normalize(lights[i].target - lights[i].position); 60 | } 61 | 62 | if (lights[i].type == LIGHT_POINT) 63 | { 64 | light = normalize(lights[i].position - fragPosition); 65 | } 66 | 67 | float NdotL = max(dot(normal, light), 0.0); 68 | lightDot += lights[i].color.rgb*NdotL; 69 | 70 | float specCo = 0.0; 71 | if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16.0); // 16 refers to shine 72 | specular += specCo; 73 | } 74 | } 75 | 76 | vec4 finalColor = (texelColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0))); 77 | finalColor += texelColor*(ambient/10.0); 78 | 79 | // Gamma correction 80 | gl_FragColor = pow(finalColor, vec4(1.0/2.2)); 81 | } 82 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/mask.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform sampler2D mask; 12 | uniform vec4 colDiffuse; 13 | uniform int frame; 14 | 15 | // NOTE: Add here your custom variables 16 | 17 | void main() 18 | { 19 | vec4 maskColour = texture2D(mask, fragTexCoord + vec2(sin(-float(frame)/150.0)/10.0, cos(-float(frame)/170.0)/10.0)); 20 | if (maskColour.r < 0.25) discard; 21 | vec4 texelColor = texture2D(texture0, fragTexCoord + vec2(sin(float(frame)/90.0)/8.0, cos(float(frame)/60.0)/8.0)); 22 | 23 | gl_FragColor = texelColor*maskColour; 24 | } 25 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/palette_switch.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | const int colors = 8; 6 | 7 | // Input vertex attributes (from vertex shader) 8 | varying vec2 fragTexCoord; 9 | varying vec4 fragColor; 10 | 11 | // Input uniform values 12 | uniform sampler2D texture0; 13 | uniform ivec3 palette[colors]; 14 | 15 | void main() 16 | { 17 | // Texel color fetching from texture sampler 18 | vec4 texelColor = texture2D(texture0, fragTexCoord)*fragColor; 19 | 20 | // Convert the (normalized) texel color RED component (GB would work, too) 21 | // to the palette index by scaling up from [0, 1] to [0, 255]. 22 | int index = int(texelColor.r*255.0); 23 | 24 | ivec3 color = ivec3(0); 25 | 26 | // NOTE: On GLSL 100 we are not allowed to index a uniform array by a variable value, 27 | // a constantmust be used, so this logic... 28 | if (index == 0) color = palette[0]; 29 | else if (index == 1) color = palette[1]; 30 | else if (index == 2) color = palette[2]; 31 | else if (index == 3) color = palette[3]; 32 | else if (index == 4) color = palette[4]; 33 | else if (index == 5) color = palette[5]; 34 | else if (index == 6) color = palette[6]; 35 | else if (index == 7) color = palette[7]; 36 | 37 | // Calculate final fragment color. Note that the palette color components 38 | // are defined in the range [0, 255] and need to be normalized to [0, 1] 39 | // for OpenGL to work. 40 | gl_FragColor = vec4(float(color.x)/255.0, float(color.y)/255.0, float(color.z)/255.0, texelColor.a); 41 | } 42 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/pixelizer.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | // NOTE: Render size values must be passed from code 16 | const float renderWidth = 800.0; 17 | const float renderHeight = 450.0; 18 | 19 | float pixelWidth = 5.0; 20 | float pixelHeight = 5.0; 21 | 22 | void main() 23 | { 24 | float dx = pixelWidth*(1.0/renderWidth); 25 | float dy = pixelHeight*(1.0/renderHeight); 26 | 27 | vec2 coord = vec2(dx*floor(fragTexCoord.x/dx), dy*floor(fragTexCoord.y/dy)); 28 | 29 | vec3 tc = texture2D(texture0, coord).rgb; 30 | 31 | gl_FragColor = vec4(tc, 1.0); 32 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/posterization.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | float gamma = 0.6; 16 | float numColors = 8.0; 17 | 18 | void main() 19 | { 20 | vec3 color = texture2D(texture0, fragTexCoord.xy).rgb; 21 | 22 | color = pow(color, vec3(gamma, gamma, gamma)); 23 | color = color*numColors; 24 | color = floor(color); 25 | color = color/numColors; 26 | color = pow(color, vec3(1.0/gamma)); 27 | 28 | gl_FragColor = vec4(color, 1.0); 29 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/predator.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | void main() 16 | { 17 | vec3 color = texture2D(texture0, fragTexCoord).rgb; 18 | vec3 colors[3]; 19 | colors[0] = vec3(0.0, 0.0, 1.0); 20 | colors[1] = vec3(1.0, 1.0, 0.0); 21 | colors[2] = vec3(1.0, 0.0, 0.0); 22 | 23 | float lum = (color.r + color.g + color.b)/3.0; 24 | 25 | vec3 tc = vec3(0.0, 0.0, 0.0); 26 | 27 | if (lum < 0.5) tc = mix(colors[0], colors[1], lum/0.5); 28 | else tc = mix(colors[1], colors[2], (lum - 0.5)/0.5); 29 | 30 | gl_FragColor = vec4(tc, 1.0); 31 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/scanlines.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | float offset = 0.0; 16 | float frequency = 450.0/3.0; 17 | 18 | uniform float time; 19 | 20 | void main() 21 | { 22 | /* 23 | // Scanlines method 1 24 | float tval = 0; //time 25 | vec2 uv = 0.5 + (fragTexCoord - 0.5)*(0.9 + 0.01*sin(0.5*tval)); 26 | 27 | vec4 color = texture2D(texture0, fragTexCoord); 28 | 29 | color = clamp(color*0.5 + 0.5*color*color*1.2, 0.0, 1.0); 30 | color *= 0.5 + 0.5*16.0*uv.x*uv.y*(1.0 - uv.x)*(1.0 - uv.y); 31 | color *= vec4(0.8, 1.0, 0.7, 1); 32 | color *= 0.9 + 0.1*sin(10.0*tval + uv.y*1000.0); 33 | color *= 0.97 + 0.03*sin(110.0*tval); 34 | 35 | fragColor = color; 36 | */ 37 | // Scanlines method 2 38 | float globalPos = (fragTexCoord.y + offset) * frequency; 39 | float wavePos = cos((fract(globalPos) - 0.5)*3.14); 40 | 41 | vec4 color = texture2D(texture0, fragTexCoord); 42 | 43 | gl_FragColor = mix(vec4(0.0, 0.3, 0.0, 0.0), color, wavePos); 44 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/sobel.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | vec2 resolution = vec2(800.0, 450.0); 15 | 16 | void main() 17 | { 18 | float x = 1.0/resolution.x; 19 | float y = 1.0/resolution.y; 20 | 21 | vec4 horizEdge = vec4(0.0); 22 | horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; 23 | horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; 24 | horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; 25 | horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; 26 | horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; 27 | horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; 28 | 29 | vec4 vertEdge = vec4(0.0); 30 | vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; 31 | vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; 32 | vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; 33 | vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; 34 | vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; 35 | vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; 36 | 37 | vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); 38 | 39 | gl_FragColor = vec4(edge, texture2D(texture0, fragTexCoord).a); 40 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/spotlight.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | #define MAX_SPOTS 3 6 | 7 | struct Spot { 8 | vec2 pos; // window coords of spot 9 | float inner; // inner fully transparent centre radius 10 | float radius; // alpha fades out to this radius 11 | }; 12 | 13 | uniform Spot spots[MAX_SPOTS]; // Spotlight positions array 14 | uniform float screenWidth; // Width of the screen 15 | 16 | void main() 17 | { 18 | float alpha = 1.0; 19 | 20 | // Get the position of the current fragment (screen coordinates!) 21 | vec2 pos = vec2(gl_FragCoord.x, gl_FragCoord.y); 22 | 23 | // Find out which spotlight is nearest 24 | float d = 65000.0; // some high value 25 | int fi = -1; // found index 26 | 27 | for (int i = 0; i < MAX_SPOTS; i++) 28 | { 29 | for (int j = 0; j < MAX_SPOTS; j++) 30 | { 31 | float dj = distance(pos, spots[j].pos) - spots[j].radius + spots[i].radius; 32 | 33 | if (d > dj) 34 | { 35 | d = dj; 36 | fi = i; 37 | } 38 | } 39 | } 40 | 41 | // d now equals distance to nearest spot... 42 | // allowing for the different radii of all spotlights 43 | if (fi == 0) 44 | { 45 | if (d > spots[0].radius) alpha = 1.0; 46 | else 47 | { 48 | if (d < spots[0].inner) alpha = 0.0; 49 | else alpha = (d - spots[0].inner)/(spots[0].radius - spots[0].inner); 50 | } 51 | } 52 | else if (fi == 1) 53 | { 54 | if (d > spots[1].radius) alpha = 1.0; 55 | else 56 | { 57 | if (d < spots[1].inner) alpha = 0.0; 58 | else alpha = (d - spots[1].inner)/(spots[1].radius - spots[1].inner); 59 | } 60 | } 61 | else if (fi == 2) 62 | { 63 | if (d > spots[2].radius) alpha = 1.0; 64 | else 65 | { 66 | if (d < spots[2].inner) alpha = 0.0; 67 | else alpha = (d - spots[2].inner)/(spots[2].radius - spots[2].inner); 68 | } 69 | } 70 | 71 | // Right hand side of screen is dimly lit, 72 | // could make the threshold value user definable 73 | if ((pos.x > screenWidth/2.0) && (alpha > 0.9)) alpha = 0.9; 74 | 75 | // could make the black out colour user definable... 76 | gl_FragColor = vec4(0, 0, 0, alpha); 77 | } 78 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/swirl.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // NOTE: Add here your custom variables 14 | 15 | // NOTE: Render size values should be passed from code 16 | const float renderWidth = 800.0; 17 | const float renderHeight = 450.0; 18 | 19 | float radius = 250.0; 20 | float angle = 0.8; 21 | 22 | uniform vec2 center; 23 | 24 | void main() 25 | { 26 | vec2 texSize = vec2(renderWidth, renderHeight); 27 | vec2 tc = fragTexCoord*texSize; 28 | tc -= center; 29 | 30 | float dist = length(tc); 31 | 32 | if (dist < radius) 33 | { 34 | float percent = (radius - dist)/radius; 35 | float theta = percent*percent*angle*8.0; 36 | float s = sin(theta); 37 | float c = cos(theta); 38 | 39 | tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c))); 40 | } 41 | 42 | tc += center; 43 | vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;; 44 | 45 | gl_FragColor = vec4(color.rgb, 1.0);; 46 | } 47 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl100/wave.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | uniform float secondes; 14 | 15 | uniform vec2 size; 16 | 17 | uniform float freqX; 18 | uniform float freqY; 19 | uniform float ampX; 20 | uniform float ampY; 21 | uniform float speedX; 22 | uniform float speedY; 23 | 24 | void main() { 25 | float pixelWidth = 1.0 / size.x; 26 | float pixelHeight = 1.0 / size.y; 27 | float aspect = pixelHeight / pixelWidth; 28 | float boxLeft = 0.0; 29 | float boxTop = 0.0; 30 | 31 | vec2 p = fragTexCoord; 32 | p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth; 33 | p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight; 34 | 35 | gl_FragColor = texture2D(texture0, p)*colDiffuse*fragColor; 36 | } 37 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/base.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | uniform vec2 resolution = vec2(800, 450); 13 | 14 | void main() 15 | { 16 | // Texel color fetching from texture sampler 17 | vec4 texelColor = texture2D(texture0, fragTexCoord); 18 | 19 | // NOTE: Implement here your fragment shader code 20 | 21 | gl_FragColor = texelColor*colDiffuse; 22 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/base.vs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes 4 | attribute vec3 vertexPosition; 5 | attribute vec2 vertexTexCoord; 6 | attribute vec3 vertexNormal; 7 | attribute vec4 vertexColor; 8 | 9 | // Input uniform values 10 | uniform mat4 mvp; 11 | 12 | // Output vertex attributes (to fragment shader) 13 | varying vec2 fragTexCoord; 14 | varying vec4 fragColor; 15 | 16 | // NOTE: Add here your custom variables 17 | 18 | void main() 19 | { 20 | // Send vertex attributes to fragment shader 21 | fragTexCoord = vertexTexCoord; 22 | fragColor = vertexColor; 23 | 24 | // Calculate final vertex position 25 | gl_Position = mvp*vec4(vertexPosition, 1.0); 26 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/base_lighting.vs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes 4 | attribute vec3 vertexPosition; 5 | attribute vec2 vertexTexCoord; 6 | attribute vec3 vertexNormal; 7 | attribute vec4 vertexColor; 8 | 9 | // Input uniform values 10 | uniform mat4 mvp; 11 | uniform mat4 matModel; 12 | 13 | // Output vertex attributes (to fragment shader) 14 | varying vec3 fragPosition; 15 | varying vec2 fragTexCoord; 16 | varying vec4 fragColor; 17 | varying vec3 fragNormal; 18 | 19 | // NOTE: Add here your custom variables 20 | 21 | // https://github.com/glslify/glsl-inverse 22 | mat3 inverse(mat3 m) 23 | { 24 | float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2]; 25 | float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2]; 26 | float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2]; 27 | 28 | float b01 = a22*a11 - a12*a21; 29 | float b11 = -a22*a10 + a12*a20; 30 | float b21 = a21*a10 - a11*a20; 31 | 32 | float det = a00*b01 + a01*b11 + a02*b21; 33 | 34 | return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11), 35 | b11, (a22*a00 - a02*a20), (-a12*a00 + a02*a10), 36 | b21, (-a21*a00 + a01*a20), (a11*a00 - a01*a10))/det; 37 | } 38 | 39 | // https://github.com/glslify/glsl-transpose 40 | mat3 transpose(mat3 m) 41 | { 42 | return mat3(m[0][0], m[1][0], m[2][0], 43 | m[0][1], m[1][1], m[2][1], 44 | m[0][2], m[1][2], m[2][2]); 45 | } 46 | 47 | void main() 48 | { 49 | // Send vertex attributes to fragment shader 50 | fragPosition = vec3(matModel*vec4(vertexPosition, 1.0)); 51 | fragTexCoord = vertexTexCoord; 52 | fragColor = vertexColor; 53 | 54 | mat3 normalMatrix = transpose(inverse(mat3(matModel))); 55 | fragNormal = normalize(normalMatrix*vertexNormal); 56 | 57 | // Calculate final vertex position 58 | gl_Position = mvp*vec4(vertexPosition, 1.0); 59 | } 60 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/bloom.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | const vec2 size = vec2(800, 450); // render size 14 | const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance 15 | const float quality = 2.5; // lower = smaller glow, better quality 16 | 17 | void main() 18 | { 19 | vec4 sum = vec4(0); 20 | vec2 sizeFactor = vec2(1)/size*quality; 21 | 22 | // Texel color fetching from texture sampler 23 | vec4 source = texture2D(texture0, fragTexCoord); 24 | 25 | const int range = 2; // should be = (samples - 1)/2; 26 | 27 | for (int x = -range; x <= range; x++) 28 | { 29 | for (int y = -range; y <= range; y++) 30 | { 31 | sum += texture2D(texture0, fragTexCoord + vec2(x, y)*sizeFactor); 32 | } 33 | } 34 | 35 | // Calculate final fragment color 36 | gl_FragColor = ((sum/(samples*samples)) + source)*colDiffuse; 37 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/blur.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | // NOTE: Render size values must be passed from code 14 | const float renderWidth = 800.0; 15 | const float renderHeight = 450.0; 16 | 17 | vec3 offset = vec3(0.0, 1.3846153846, 3.2307692308); 18 | vec3 weight = vec3(0.2270270270, 0.3162162162, 0.0702702703); 19 | 20 | void main() 21 | { 22 | // Texel color fetching from texture sampler 23 | vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight.x; 24 | 25 | tc += texture2D(texture0, fragTexCoord + vec2(offset.y)/renderWidth, 0.0).rgb*weight.y; 26 | tc += texture2D(texture0, fragTexCoord - vec2(offset.y)/renderWidth, 0.0).rgb*weight.y; 27 | 28 | tc += texture2D(texture0, fragTexCoord + vec2(offset.z)/renderWidth, 0.0).rgb*weight.z; 29 | tc += texture2D(texture0, fragTexCoord - vec2(offset.z)/renderWidth, 0.0).rgb*weight.z; 30 | 31 | gl_FragColor = vec4(tc, 1.0); 32 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/cross_hatching.fs: -------------------------------------------------------------------------------- 1 | # version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | float hatchOffsetY = 5.0; 14 | float lumThreshold01 = 0.9; 15 | float lumThreshold02 = 0.7; 16 | float lumThreshold03 = 0.5; 17 | float lumThreshold04 = 0.3; 18 | 19 | void main() 20 | { 21 | vec3 tc = vec3(1.0, 1.0, 1.0); 22 | float lum = length(texture2D(texture0, fragTexCoord).rgb); 23 | 24 | if (lum < lumThreshold01) 25 | { 26 | if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 27 | } 28 | 29 | if (lum < lumThreshold02) 30 | { 31 | if (mod(gl_FragCoord .x - gl_FragCoord .y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 32 | } 33 | 34 | if (lum < lumThreshold03) 35 | { 36 | if (mod(gl_FragCoord .x + gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 37 | } 38 | 39 | if (lum < lumThreshold04) 40 | { 41 | if (mod(gl_FragCoord .x - gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 42 | } 43 | 44 | gl_FragColor = vec4(tc, 1.0); 45 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/cross_stitching.fs: -------------------------------------------------------------------------------- 1 | # version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | // NOTE: Render size values must be passed from code 14 | const float renderWidth = 800.0; 15 | const float renderHeight = 450.0; 16 | 17 | float stitchingSize = 6.0; 18 | int invert = 0; 19 | 20 | vec4 PostFX(sampler2D tex, vec2 uv) 21 | { 22 | vec4 c = vec4(0.0); 23 | float size = stitchingSize; 24 | vec2 cPos = uv * vec2(renderWidth, renderHeight); 25 | vec2 tlPos = floor(cPos / vec2(size, size)); 26 | tlPos *= size; 27 | 28 | int remX = int(mod(cPos.x, size)); 29 | int remY = int(mod(cPos.y, size)); 30 | 31 | if (remX == 0 && remY == 0) tlPos = cPos; 32 | 33 | vec2 blPos = tlPos; 34 | blPos.y += (size - 1.0); 35 | 36 | if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y))))) 37 | { 38 | if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0); 39 | else c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4; 40 | } 41 | else 42 | { 43 | if (invert == 1) c = texture2D(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4; 44 | else c = vec4(0.0, 0.0, 0.0, 1.0); 45 | } 46 | 47 | return c; 48 | } 49 | 50 | void main() 51 | { 52 | vec3 tc = PostFX(texture0, fragTexCoord).rgb; 53 | 54 | gl_FragColor = vec4(tc, 1.0); 55 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/distortion.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | 6 | // Input uniform values 7 | uniform sampler2D texture0; 8 | 9 | // NOTE: Default parameters for Oculus Rift DK2 device 10 | const vec2 LeftLensCenter = vec2(0.2863248, 0.5); 11 | const vec2 RightLensCenter = vec2(0.7136753, 0.5); 12 | const vec2 LeftScreenCenter = vec2(0.25, 0.5); 13 | const vec2 RightScreenCenter = vec2(0.75, 0.5); 14 | const vec2 Scale = vec2(0.25, 0.45); 15 | const vec2 ScaleIn = vec2(4.0, 2.5); 16 | const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0); 17 | const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); 18 | 19 | void main() 20 | { 21 | // The following two variables need to be set per eye 22 | vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter; 23 | vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter; 24 | 25 | // Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter) 26 | vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1] 27 | float rSq = theta.x*theta.x + theta.y*theta.y; 28 | vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); 29 | //vec2 tc = LensCenter + Scale*theta1; 30 | 31 | // Detect whether blue texture coordinates are out of range since these will scaled out the furthest 32 | vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq); 33 | vec2 tcBlue = LensCenter + Scale*thetaBlue; 34 | 35 | if (any(bvec2(clamp(tcBlue, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tcBlue))) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); 36 | else 37 | { 38 | // Do blue texture lookup 39 | float blue = texture2D(texture0, tcBlue).b; 40 | 41 | // Do green lookup (no scaling) 42 | vec2 tcGreen = LensCenter + Scale*theta1; 43 | float green = texture2D(texture0, tcGreen).g; 44 | 45 | // Do red scale and lookup 46 | vec2 thetaRed = theta1*(ChromaAbParam.x + ChromaAbParam.y*rSq); 47 | vec2 tcRed = LensCenter + Scale*thetaRed; 48 | float red = texture2D(texture0, tcRed).r; 49 | 50 | gl_FragColor = vec4(red, green, blue, 1.0); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/dream_vision.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | void main() 14 | { 15 | vec4 color = texture2D(texture0, fragTexCoord); 16 | 17 | color += texture2D(texture0, fragTexCoord + 0.001); 18 | color += texture2D(texture0, fragTexCoord + 0.003); 19 | color += texture2D(texture0, fragTexCoord + 0.005); 20 | color += texture2D(texture0, fragTexCoord + 0.007); 21 | color += texture2D(texture0, fragTexCoord + 0.009); 22 | color += texture2D(texture0, fragTexCoord + 0.011); 23 | 24 | color += texture2D(texture0, fragTexCoord - 0.001); 25 | color += texture2D(texture0, fragTexCoord - 0.003); 26 | color += texture2D(texture0, fragTexCoord - 0.005); 27 | color += texture2D(texture0, fragTexCoord - 0.007); 28 | color += texture2D(texture0, fragTexCoord - 0.009); 29 | color += texture2D(texture0, fragTexCoord - 0.011); 30 | 31 | color.rgb = vec3((color.r + color.g + color.b)/3.0); 32 | color = color/9.5; 33 | 34 | gl_FragColor = color; 35 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/fisheye.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | const float PI = 3.1415926535; 14 | 15 | void main() 16 | { 17 | float aperture = 178.0; 18 | float apertureHalf = 0.5 * aperture * (PI / 180.0); 19 | float maxFactor = sin(apertureHalf); 20 | 21 | vec2 uv = vec2(0.0); 22 | vec2 xy = 2.0 * fragTexCoord.xy - 1.0; 23 | float d = length(xy); 24 | 25 | if (d < (2.0 - maxFactor)) 26 | { 27 | d = length(xy * maxFactor); 28 | float z = sqrt(1.0 - d * d); 29 | float r = atan(d, z) / PI; 30 | float phi = atan(xy.y, xy.x); 31 | 32 | uv.x = r * cos(phi) + 0.5; 33 | uv.y = r * sin(phi) + 0.5; 34 | } 35 | else 36 | { 37 | uv = fragTexCoord.xy; 38 | } 39 | 40 | gl_FragColor = texture2D(texture0, uv); 41 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/grayscale.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | void main() 14 | { 15 | // Texel color fetching from texture sampler 16 | vec4 texelColor = texture2D(texture0, fragTexCoord)*colDiffuse*fragColor; 17 | 18 | // Convert texel color to grayscale using NTSC conversion weights 19 | float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114)); 20 | 21 | // Calculate final fragment color 22 | gl_FragColor = vec4(gray, gray, gray, texelColor.a); 23 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/palette_switch.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | const int colors = 8; 4 | 5 | // Input fragment attributes (from fragment shader) 6 | varying vec2 fragTexCoord; 7 | varying vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform ivec3 palette[colors]; 12 | 13 | void main() 14 | { 15 | // Texel color fetching from texture sampler 16 | vec4 texelColor = texture(texture0, fragTexCoord) * fragColor; 17 | 18 | // Convert the (normalized) texel color RED component (GB would work, too) 19 | // to the palette index by scaling up from [0, 1] to [0, 255]. 20 | int index = int(texelColor.r * 255.0); 21 | ivec3 color = palette[index]; 22 | 23 | // Calculate final fragment color. Note that the palette color components 24 | // are defined in the range [0, 255] and need to be normalized to [0, 1] 25 | // for OpenGL to work. 26 | gl_FragColor = vec4(color / 255.0, texelColor.a); 27 | } 28 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/pixelizer.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | // NOTE: Render size values must be passed from code 14 | const float renderWidth = 800.0; 15 | const float renderHeight = 450.0; 16 | 17 | float pixelWidth = 5.0; 18 | float pixelHeight = 5.0; 19 | 20 | void main() 21 | { 22 | float dx = pixelWidth*(1.0/renderWidth); 23 | float dy = pixelHeight*(1.0/renderHeight); 24 | 25 | vec2 coord = vec2(dx*floor(fragTexCoord.x/dx), dy*floor(fragTexCoord.y/dy)); 26 | 27 | vec3 tc = texture2D(texture0, coord).rgb; 28 | 29 | gl_FragColor = vec4(tc, 1.0); 30 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/posterization.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | float gamma = 0.6; 14 | float numColors = 8.0; 15 | 16 | void main() 17 | { 18 | vec3 color = texture2D(texture0, fragTexCoord.xy).rgb; 19 | 20 | color = pow(color, vec3(gamma, gamma, gamma)); 21 | color = color*numColors; 22 | color = floor(color); 23 | color = color/numColors; 24 | color = pow(color, vec3(1.0/gamma)); 25 | 26 | gl_FragColor = vec4(color, 1.0); 27 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/predator.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | void main() 14 | { 15 | vec3 color = texture2D(texture0, fragTexCoord).rgb; 16 | vec3 colors[3]; 17 | colors[0] = vec3(0.0, 0.0, 1.0); 18 | colors[1] = vec3(1.0, 1.0, 0.0); 19 | colors[2] = vec3(1.0, 0.0, 0.0); 20 | 21 | float lum = (color.r + color.g + color.b)/3.0; 22 | 23 | vec3 tc = vec3(0.0, 0.0, 0.0); 24 | 25 | if (lum < 0.5) tc = mix(colors[0], colors[1], lum/0.5); 26 | else tc = mix(colors[1], colors[2], (lum - 0.5)/0.5); 27 | 28 | gl_FragColor = vec4(tc, 1.0); 29 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/scanlines.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | float offset = 0.0; 14 | float frequency = 450.0/3.0; 15 | 16 | uniform float time; 17 | 18 | void main() 19 | { 20 | /* 21 | // Scanlines method 1 22 | float tval = 0; //time 23 | vec2 uv = 0.5 + (fragTexCoord - 0.5)*(0.9 + 0.01*sin(0.5*tval)); 24 | 25 | vec4 color = texture2D(texture0, fragTexCoord); 26 | 27 | color = clamp(color*0.5 + 0.5*color*color*1.2, 0.0, 1.0); 28 | color *= 0.5 + 0.5*16.0*uv.x*uv.y*(1.0 - uv.x)*(1.0 - uv.y); 29 | color *= vec4(0.8, 1.0, 0.7, 1); 30 | color *= 0.9 + 0.1*sin(10.0*tval + uv.y*1000.0); 31 | color *= 0.97 + 0.03*sin(110.0*tval); 32 | 33 | fragColor = color; 34 | */ 35 | // Scanlines method 2 36 | float globalPos = (fragTexCoord.y + offset) * frequency; 37 | float wavePos = cos((fract(globalPos) - 0.5)*3.14); 38 | 39 | vec4 color = texture2D(texture0, fragTexCoord); 40 | 41 | gl_FragColor = mix(vec4(0.0, 0.3, 0.0, 0.0), color, wavePos); 42 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/sobel.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | vec2 resolution = vec2(800.0, 450.0); 13 | 14 | void main() 15 | { 16 | float x = 1.0/resolution.x; 17 | float y = 1.0/resolution.y; 18 | 19 | vec4 horizEdge = vec4(0.0); 20 | horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; 21 | horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; 22 | horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; 23 | horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; 24 | horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; 25 | horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; 26 | 27 | vec4 vertEdge = vec4(0.0); 28 | vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; 29 | vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; 30 | vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; 31 | vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; 32 | vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; 33 | vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; 34 | 35 | vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); 36 | 37 | gl_FragColor = vec4(edge, texture2D(texture0, fragTexCoord).a); 38 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl120/swirl.fs: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | // Input vertex attributes (from vertex shader) 4 | varying vec2 fragTexCoord; 5 | varying vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // NOTE: Add here your custom variables 12 | 13 | // NOTE: Render size values should be passed from code 14 | const float renderWidth = 800; 15 | const float renderHeight = 450; 16 | 17 | float radius = 250.0; 18 | float angle = 0.8; 19 | 20 | uniform vec2 center; 21 | 22 | void main() 23 | { 24 | vec2 texSize = vec2(renderWidth, renderHeight); 25 | vec2 tc = fragTexCoord*texSize; 26 | tc -= center; 27 | 28 | float dist = length(tc); 29 | 30 | if (dist < radius) 31 | { 32 | float percent = (radius - dist)/radius; 33 | float theta = percent*percent*angle*8.0; 34 | float s = sin(theta); 35 | float c = cos(theta); 36 | 37 | tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c))); 38 | } 39 | 40 | tc += center; 41 | vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;; 42 | 43 | gl_FragColor = vec4(color.rgb, 1.0);; 44 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/base.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | void main() 17 | { 18 | // Texel color fetching from texture sampler 19 | vec4 texelColor = texture(texture0, fragTexCoord); 20 | 21 | // NOTE: Implement here your fragment shader code 22 | 23 | finalColor = texelColor*colDiffuse; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/base.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes 4 | in vec3 vertexPosition; 5 | in vec2 vertexTexCoord; 6 | in vec3 vertexNormal; 7 | in vec4 vertexColor; 8 | 9 | // Input uniform values 10 | uniform mat4 mvp; 11 | 12 | // Output vertex attributes (to fragment shader) 13 | out vec2 fragTexCoord; 14 | out vec4 fragColor; 15 | 16 | // NOTE: Add here your custom variables 17 | 18 | void main() 19 | { 20 | // Send vertex attributes to fragment shader 21 | fragTexCoord = vertexTexCoord; 22 | fragColor = vertexColor; 23 | 24 | // Calculate final vertex position 25 | gl_Position = mvp*vec4(vertexPosition, 1.0); 26 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/base_lighting.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes 4 | in vec3 vertexPosition; 5 | in vec2 vertexTexCoord; 6 | in vec3 vertexNormal; 7 | in vec4 vertexColor; 8 | 9 | // Input uniform values 10 | uniform mat4 mvp; 11 | uniform mat4 matModel; 12 | 13 | // Output vertex attributes (to fragment shader) 14 | out vec3 fragPosition; 15 | out vec2 fragTexCoord; 16 | out vec4 fragColor; 17 | out vec3 fragNormal; 18 | 19 | // NOTE: Add here your custom variables 20 | 21 | void main() 22 | { 23 | // Send vertex attributes to fragment shader 24 | fragPosition = vec3(matModel*vec4(vertexPosition, 1.0)); 25 | fragTexCoord = vertexTexCoord; 26 | fragColor = vertexColor; 27 | 28 | mat3 normalMatrix = transpose(inverse(mat3(matModel))); 29 | fragNormal = normalize(normalMatrix*vertexNormal); 30 | 31 | // Calculate final vertex position 32 | gl_Position = mvp*vec4(vertexPosition, 1.0); 33 | } 34 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/base_lighting_instanced.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes 4 | in vec3 vertexPosition; 5 | in vec2 vertexTexCoord; 6 | in vec3 vertexNormal; 7 | in vec4 vertexColor; 8 | 9 | layout (location = 12) in mat4 instance; 10 | 11 | // Input uniform values 12 | uniform mat4 mvp; 13 | 14 | // Output vertex attributes (to fragment shader) 15 | out vec3 fragPosition; 16 | out vec2 fragTexCoord; 17 | out vec4 fragColor; 18 | out vec3 fragNormal; 19 | 20 | // NOTE: Add here your custom variables 21 | 22 | void main() 23 | { 24 | // Send vertex attributes to fragment shader 25 | fragPosition = vec3(instance * vec4(vertexPosition, 1.0)); 26 | fragTexCoord = vertexTexCoord; 27 | fragColor = vertexColor; 28 | 29 | mat3 normalMatrix = transpose(inverse(mat3(instance))); 30 | fragNormal = normalize(normalMatrix * vertexNormal); 31 | 32 | mat4 mvpi = mvp * instance; 33 | 34 | // Calculate final vertex position 35 | gl_Position = mvpi * vec4(vertexPosition, 1.0); 36 | } 37 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/bloom.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | const vec2 size = vec2(800, 450); // render size 17 | const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance 18 | const float quality = 2.5; // lower = smaller glow, better quality 19 | 20 | void main() 21 | { 22 | vec4 sum = vec4(0); 23 | vec2 sizeFactor = vec2(1)/size*quality; 24 | 25 | // Texel color fetching from texture sampler 26 | vec4 source = texture(texture0, fragTexCoord); 27 | 28 | const int range = 2; // should be = (samples - 1)/2; 29 | 30 | for (int x = -range; x <= range; x++) 31 | { 32 | for (int y = -range; y <= range; y++) 33 | { 34 | sum += texture(texture0, fragTexCoord + vec2(x, y)*sizeFactor); 35 | } 36 | } 37 | 38 | // Calculate final fragment color 39 | finalColor = ((sum/(samples*samples)) + source)*colDiffuse; 40 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/blur.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | // NOTE: Render size values must be passed from code 17 | const float renderWidth = 800; 18 | const float renderHeight = 450; 19 | 20 | float offset[3] = float[](0.0, 1.3846153846, 3.2307692308); 21 | float weight[3] = float[](0.2270270270, 0.3162162162, 0.0702702703); 22 | 23 | void main() 24 | { 25 | // Texel color fetching from texture sampler 26 | vec3 texelColor = texture(texture0, fragTexCoord).rgb*weight[0]; 27 | 28 | for (int i = 1; i < 3; i++) 29 | { 30 | texelColor += texture(texture0, fragTexCoord + vec2(offset[i])/renderWidth, 0.0).rgb*weight[i]; 31 | texelColor += texture(texture0, fragTexCoord - vec2(offset[i])/renderWidth, 0.0).rgb*weight[i]; 32 | } 33 | 34 | finalColor = vec4(texelColor, 1.0); 35 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/color_mix.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec3 vertexPos; 5 | in vec2 fragTexCoord; 6 | in vec4 fragColor; 7 | 8 | // Input uniform values 9 | uniform sampler2D texture0; 10 | uniform sampler2D texture1; 11 | uniform vec4 colDiffuse; 12 | 13 | out vec4 finalColor; 14 | 15 | void main() 16 | { 17 | // Texel color fetching from texture sampler 18 | vec4 texelColor0 = texture(texture0, fragTexCoord); 19 | vec4 texelColor1 = texture(texture1, fragTexCoord); 20 | 21 | float x = fract(fragTexCoord.s); 22 | float out = smoothstep(0.4, 0.6, x); 23 | 24 | finalColor = mix(texelColor0, texelColor1, out); 25 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/cross_hatching.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | float hatchOffsetY = 5.0; 17 | float lumThreshold01 = 0.9; 18 | float lumThreshold02 = 0.7; 19 | float lumThreshold03 = 0.5; 20 | float lumThreshold04 = 0.3; 21 | 22 | void main() 23 | { 24 | vec3 tc = vec3(1.0, 1.0, 1.0); 25 | float lum = length(texture(texture0, fragTexCoord).rgb); 26 | 27 | if (lum < lumThreshold01) 28 | { 29 | if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 30 | } 31 | 32 | if (lum < lumThreshold02) 33 | { 34 | if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 35 | } 36 | 37 | if (lum < lumThreshold03) 38 | { 39 | if (mod(gl_FragCoord.x + gl_FragCoord.y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 40 | } 41 | 42 | if (lum < lumThreshold04) 43 | { 44 | if (mod(gl_FragCoord.x - gl_FragCoord.y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); 45 | } 46 | 47 | finalColor = vec4(tc, 1.0); 48 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/cross_stitching.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | // NOTE: Render size values must be passed from code 17 | const float renderWidth = 800.0; 18 | const float renderHeight = 450.0; 19 | 20 | float stitchingSize = 6.0; 21 | 22 | uniform int invert = 0; 23 | 24 | vec4 PostFX(sampler2D tex, vec2 uv) 25 | { 26 | vec4 c = vec4(0.0); 27 | float size = stitchingSize; 28 | vec2 cPos = uv * vec2(renderWidth, renderHeight); 29 | vec2 tlPos = floor(cPos / vec2(size, size)); 30 | tlPos *= size; 31 | 32 | int remX = int(mod(cPos.x, size)); 33 | int remY = int(mod(cPos.y, size)); 34 | 35 | if (remX == 0 && remY == 0) tlPos = cPos; 36 | 37 | vec2 blPos = tlPos; 38 | blPos.y += (size - 1.0); 39 | 40 | if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y))))) 41 | { 42 | if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0); 43 | else c = texture(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4; 44 | } 45 | else 46 | { 47 | if (invert == 1) c = texture(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4; 48 | else c = vec4(0.0, 0.0, 0.0, 1.0); 49 | } 50 | 51 | return c; 52 | } 53 | 54 | void main() 55 | { 56 | vec3 tc = PostFX(texture0, fragTexCoord).rgb; 57 | 58 | finalColor = vec4(tc, 1.0); 59 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/cubes_panning.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Output fragment color 8 | out vec4 finalColor; 9 | 10 | // Custom variables 11 | #define PI 3.14159265358979323846 12 | uniform float uTime = 0.0; 13 | 14 | float divisions = 5.0; 15 | float angle = 0.0; 16 | 17 | vec2 VectorRotateTime(vec2 v, float speed) 18 | { 19 | float time = uTime*speed; 20 | float localTime = fract(time); // The time domain this works on is 1 sec. 21 | 22 | if ((localTime >= 0.0) && (localTime < 0.25)) angle = 0.0; 23 | else if ((localTime >= 0.25) && (localTime < 0.50)) angle = PI/4*sin(2*PI*localTime - PI/2); 24 | else if ((localTime >= 0.50) && (localTime < 0.75)) angle = PI*0.25; 25 | else if ((localTime >= 0.75) && (localTime < 1.00)) angle = PI/4*sin(2*PI*localTime); 26 | 27 | // Rotate vector by angle 28 | v -= 0.5; 29 | v = mat2(cos(angle), -sin(angle), sin(angle), cos(angle))*v; 30 | v += 0.5; 31 | 32 | return v; 33 | } 34 | 35 | float Rectangle(in vec2 st, in float size, in float fill) 36 | { 37 | float roundSize = 0.5 - size/2.0; 38 | float left = step(roundSize, st.x); 39 | float top = step(roundSize, st.y); 40 | float bottom = step(roundSize, 1.0 - st.y); 41 | float right = step(roundSize, 1.0 - st.x); 42 | 43 | return (left*bottom*right*top)*fill; 44 | } 45 | 46 | void main() 47 | { 48 | vec2 fragPos = fragTexCoord; 49 | fragPos.xy += uTime/9.0; 50 | 51 | fragPos *= divisions; 52 | vec2 ipos = floor(fragPos); // Get the integer coords 53 | vec2 fpos = fract(fragPos); // Get the fractional coords 54 | 55 | fpos = VectorRotateTime(fpos, 0.2); 56 | 57 | float alpha = Rectangle(fpos, 0.216, 1.0); 58 | vec3 color = vec3(0.3, 0.3, 0.3); 59 | 60 | finalColor = vec4(color, alpha); 61 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/depth.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; // Depth texture 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | void main() 17 | { 18 | float zNear = 0.01; // camera z near 19 | float zFar = 10.0; // camera z far 20 | float z = texture(texture0, fragTexCoord).x; 21 | 22 | // Linearize depth value 23 | float depth = (2.0*zNear)/(zFar + zNear - z*(zFar - zNear)); 24 | 25 | // Calculate final fragment color 26 | finalColor = vec4(depth, depth, depth, 1.0f); 27 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/distortion.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | 6 | // Input uniform values 7 | uniform sampler2D texture0; 8 | 9 | // Output fragment color 10 | out vec4 finalColor; 11 | 12 | // NOTE: Default parameters for Oculus Rift DK2 device 13 | const vec2 LeftLensCenter = vec2(0.2863248, 0.5); 14 | const vec2 RightLensCenter = vec2(0.7136753, 0.5); 15 | const vec2 LeftScreenCenter = vec2(0.25, 0.5); 16 | const vec2 RightScreenCenter = vec2(0.75, 0.5); 17 | const vec2 Scale = vec2(0.25, 0.45); 18 | const vec2 ScaleIn = vec2(4.0, 2.5); 19 | const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0); 20 | const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); 21 | 22 | void main() 23 | { 24 | // The following two variables need to be set per eye 25 | vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter; 26 | vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter; 27 | 28 | // Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter) 29 | vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1] 30 | float rSq = theta.x*theta.x + theta.y*theta.y; 31 | vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); 32 | //vec2 tc = LensCenter + Scale*theta1; 33 | 34 | // Detect whether blue texture coordinates are out of range since these will scaled out the furthest 35 | vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq); 36 | vec2 tcBlue = LensCenter + Scale*thetaBlue; 37 | 38 | if (any(bvec2(clamp(tcBlue, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tcBlue))) finalColor = vec4(0.0, 0.0, 0.0, 1.0); 39 | else 40 | { 41 | // Do blue texture lookup 42 | float blue = texture(texture0, tcBlue).b; 43 | 44 | // Do green lookup (no scaling) 45 | vec2 tcGreen = LensCenter + Scale*theta1; 46 | float green = texture(texture0, tcGreen).g; 47 | 48 | // Do red scale and lookup 49 | vec2 thetaRed = theta1*(ChromaAbParam.x + ChromaAbParam.y*rSq); 50 | vec2 tcRed = LensCenter + Scale*thetaRed; 51 | float red = texture(texture0, tcRed).r; 52 | 53 | finalColor = vec4(red, green, blue, 1.0); 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/dream_vision.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec2 fragTexCoord; 4 | 5 | out vec4 fragColor; 6 | 7 | uniform sampler2D texture0; 8 | uniform vec4 colDiffuse; 9 | 10 | // NOTE: Add here your custom variables 11 | 12 | void main() 13 | { 14 | vec4 color = texture(texture0, fragTexCoord); 15 | 16 | color += texture(texture0, fragTexCoord + 0.001); 17 | color += texture(texture0, fragTexCoord + 0.003); 18 | color += texture(texture0, fragTexCoord + 0.005); 19 | color += texture(texture0, fragTexCoord + 0.007); 20 | color += texture(texture0, fragTexCoord + 0.009); 21 | color += texture(texture0, fragTexCoord + 0.011); 22 | 23 | color += texture(texture0, fragTexCoord - 0.001); 24 | color += texture(texture0, fragTexCoord - 0.003); 25 | color += texture(texture0, fragTexCoord - 0.005); 26 | color += texture(texture0, fragTexCoord - 0.007); 27 | color += texture(texture0, fragTexCoord - 0.009); 28 | color += texture(texture0, fragTexCoord - 0.011); 29 | 30 | color.rgb = vec3((color.r + color.g + color.b)/3.0); 31 | color = color/9.5; 32 | 33 | fragColor = color; 34 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/eratosthenes.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | /************************************************************************************* 4 | 5 | The Sieve of Eratosthenes -- a simple shader by ProfJski 6 | An early prime number sieve: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes 7 | 8 | The screen is divided into a square grid of boxes, each representing an integer value. 9 | Each integer is tested to see if it is a prime number. Primes are colored white. 10 | Non-primes are colored with a color that indicates the smallest factor which evenly divdes our integer. 11 | 12 | You can change the scale variable to make a larger or smaller grid. 13 | Total number of integers displayed = scale squared, so scale = 100 tests the first 10,000 integers. 14 | 15 | WARNING: If you make scale too large, your GPU may bog down! 16 | 17 | ***************************************************************************************/ 18 | 19 | // Input vertex attributes (from vertex shader) 20 | in vec2 fragTexCoord; 21 | in vec4 fragColor; 22 | 23 | // Output fragment color 24 | out vec4 finalColor; 25 | 26 | // Make a nice spectrum of colors based on counter and maxSize 27 | vec4 Colorizer(float counter, float maxSize) 28 | { 29 | float red = 0.0, green = 0.0, blue = 0.0; 30 | float normsize = counter/maxSize; 31 | 32 | red = smoothstep(0.3, 0.7, normsize); 33 | green = sin(3.14159*normsize); 34 | blue = 1.0 - smoothstep(0.0, 0.4, normsize); 35 | 36 | return vec4(0.8*red, 0.8*green, 0.8*blue, 1.0); 37 | } 38 | 39 | void main() 40 | { 41 | vec4 color = vec4(1.0); 42 | float scale = 1000.0; // Makes 100x100 square grid. Change this variable to make a smaller or larger grid. 43 | int value = int(scale*floor(fragTexCoord.y*scale)+floor(fragTexCoord.x*scale)); // Group pixels into boxes representing integer values 44 | 45 | if ((value == 0) || (value == 1) || (value == 2)) finalColor = vec4(1.0); 46 | else 47 | { 48 | for (int i = 2; (i < max(2, sqrt(value) + 1)); i++) 49 | { 50 | if ((value - i*floor(float(value)/float(i))) == 0) 51 | { 52 | color = Colorizer(float(i), scale); 53 | //break; // Uncomment to color by the largest factor instead 54 | } 55 | } 56 | 57 | finalColor = color; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/fisheye.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec2 fragTexCoord; 4 | 5 | out vec4 fragColor; 6 | 7 | uniform sampler2D texture0; 8 | uniform vec4 colDiffuse; 9 | 10 | // NOTE: Add here your custom variables 11 | 12 | const float PI = 3.1415926535; 13 | 14 | void main() 15 | { 16 | float aperture = 178.0; 17 | float apertureHalf = 0.5 * aperture * (PI / 180.0); 18 | float maxFactor = sin(apertureHalf); 19 | 20 | vec2 uv = vec2(0); 21 | vec2 xy = 2.0 * fragTexCoord.xy - 1.0; 22 | float d = length(xy); 23 | 24 | if (d < (2.0 - maxFactor)) 25 | { 26 | d = length(xy * maxFactor); 27 | float z = sqrt(1.0 - d * d); 28 | float r = atan(d, z) / PI; 29 | float phi = atan(xy.y, xy.x); 30 | 31 | uv.x = r * cos(phi) + 0.5; 32 | uv.y = r * sin(phi) + 0.5; 33 | } 34 | else 35 | { 36 | uv = fragTexCoord.xy; 37 | } 38 | 39 | fragColor = texture(texture0, uv); 40 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/grayscale.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | void main() 17 | { 18 | // Texel color fetching from texture sampler 19 | vec4 texelColor = texture(texture0, fragTexCoord)*colDiffuse*fragColor; 20 | 21 | // Convert texel color to grayscale using NTSC conversion weights 22 | float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114)); 23 | 24 | // Calculate final fragment color 25 | finalColor = vec4(gray, gray, gray, texelColor.a); 26 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/lighting.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec3 fragPosition; 5 | in vec2 fragTexCoord; 6 | in vec4 fragColor; 7 | in vec3 fragNormal; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // Output fragment color 14 | out vec4 finalColor; 15 | 16 | // NOTE: Add here your custom variables 17 | 18 | #define MAX_LIGHTS 4 19 | #define LIGHT_DIRECTIONAL 0 20 | #define LIGHT_POINT 1 21 | 22 | struct MaterialProperty { 23 | vec3 color; 24 | int useSampler; 25 | sampler2D sampler; 26 | }; 27 | 28 | struct Light { 29 | int enabled; 30 | int type; 31 | vec3 position; 32 | vec3 target; 33 | vec4 color; 34 | }; 35 | 36 | // Input lighting values 37 | uniform Light lights[MAX_LIGHTS]; 38 | uniform vec4 ambient; 39 | uniform vec3 viewPos; 40 | 41 | void main() 42 | { 43 | // Texel color fetching from texture sampler 44 | vec4 texelColor = texture(texture0, fragTexCoord); 45 | vec3 lightDot = vec3(0.0); 46 | vec3 normal = normalize(fragNormal); 47 | vec3 viewD = normalize(viewPos - fragPosition); 48 | vec3 specular = vec3(0.0); 49 | 50 | // NOTE: Implement here your fragment shader code 51 | 52 | for (int i = 0; i < MAX_LIGHTS; i++) 53 | { 54 | if (lights[i].enabled == 1) 55 | { 56 | vec3 light = vec3(0.0); 57 | 58 | if (lights[i].type == LIGHT_DIRECTIONAL) 59 | { 60 | light = -normalize(lights[i].target - lights[i].position); 61 | } 62 | 63 | if (lights[i].type == LIGHT_POINT) 64 | { 65 | light = normalize(lights[i].position - fragPosition); 66 | } 67 | 68 | float NdotL = max(dot(normal, light), 0.0); 69 | lightDot += lights[i].color.rgb*NdotL; 70 | 71 | float specCo = 0.0; 72 | if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16.0); // 16 refers to shine 73 | specular += specCo; 74 | } 75 | } 76 | 77 | finalColor = (texelColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0))); 78 | finalColor += texelColor*(ambient/10.0)*colDiffuse; 79 | 80 | // Gamma correction 81 | finalColor = pow(finalColor, vec4(1.0/2.2)); 82 | } 83 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/mask.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform sampler2D mask; 10 | uniform int frame; 11 | 12 | // Output fragment color 13 | out vec4 finalColor; 14 | 15 | void main() 16 | { 17 | vec4 maskColour = texture(mask, fragTexCoord + vec2(sin(-frame/150.0)/10.0, cos(-frame/170.0)/10.0)); 18 | if (maskColour.r < 0.25) discard; 19 | vec4 texelColor = texture(texture0, fragTexCoord + vec2(sin(frame/90.0)/8.0, cos(frame/60.0)/8.0)); 20 | 21 | finalColor = texelColor*maskColour; 22 | } 23 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/overdraw.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | void main() 17 | { 18 | // To show overdraw, we just render all the fragments 19 | // with a solid color and some transparency 20 | 21 | // NOTE: This is not a postpro render, 22 | // it will only render all screen texture in a plain color 23 | 24 | finalColor = vec4(1.0, 0.0, 0.0, 0.2); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/palette_switch.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | const int colors = 8; 4 | 5 | // Input fragment attributes (from fragment shader) 6 | in vec2 fragTexCoord; 7 | in vec4 fragColor; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform ivec3 palette[colors]; 12 | 13 | // Output fragment color 14 | out vec4 finalColor; 15 | 16 | void main() 17 | { 18 | // Texel color fetching from texture sampler 19 | vec4 texelColor = texture(texture0, fragTexCoord)*fragColor; 20 | 21 | // Convert the (normalized) texel color RED component (GB would work, too) 22 | // to the palette index by scaling up from [0, 1] to [0, 255]. 23 | int index = int(texelColor.r*255.0); 24 | ivec3 color = palette[index]; 25 | 26 | // Calculate final fragment color. Note that the palette color components 27 | // are defined in the range [0, 255] and need to be normalized to [0, 1] 28 | // for OpenGL to work. 29 | finalColor = vec4(color/255.0, texelColor.a); 30 | } 31 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/pixelizer.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | // NOTE: Render size values must be passed from code 17 | const float renderWidth = 800; 18 | const float renderHeight = 450; 19 | 20 | uniform float pixelWidth = 5.0; 21 | uniform float pixelHeight = 5.0; 22 | 23 | void main() 24 | { 25 | float dx = pixelWidth*(1.0/renderWidth); 26 | float dy = pixelHeight*(1.0/renderHeight); 27 | 28 | vec2 coord = vec2(dx*floor(fragTexCoord.x/dx), dy*floor(fragTexCoord.y/dy)); 29 | 30 | vec3 tc = texture(texture0, coord).rgb; 31 | 32 | finalColor = vec4(tc, 1.0); 33 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/posterization.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | float gamma = 0.6; 17 | float numColors = 8.0; 18 | 19 | void main() 20 | { 21 | // Texel color fetching from texture sampler 22 | vec3 texelColor = texture(texture0, fragTexCoord.xy).rgb; 23 | 24 | texelColor = pow(texelColor, vec3(gamma, gamma, gamma)); 25 | texelColor = texelColor*numColors; 26 | texelColor = floor(texelColor); 27 | texelColor = texelColor/numColors; 28 | texelColor = pow(texelColor, vec3(1.0/gamma)); 29 | 30 | finalColor = vec4(texelColor, 1.0); 31 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/predator.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | void main() 17 | { 18 | // Texel color fetching from texture sampler 19 | vec3 texelColor = texture(texture0, fragTexCoord).rgb; 20 | vec3 colors[3]; 21 | colors[0] = vec3(0.0, 0.0, 1.0); 22 | colors[1] = vec3(1.0, 1.0, 0.0); 23 | colors[2] = vec3(1.0, 0.0, 0.0); 24 | 25 | float lum = (texelColor.r + texelColor.g + texelColor.b)/3.0; 26 | 27 | int ix = (lum < 0.5)? 0:1; 28 | 29 | vec3 tc = mix(colors[ix], colors[ix + 1], (lum - float(ix)*0.5)/0.5); 30 | 31 | finalColor = vec4(tc, 1.0); 32 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/reload.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; // Texture coordinates (sampler2D) 5 | in vec4 fragColor; // Tint color 6 | 7 | // Output fragment color 8 | out vec4 finalColor; // Output fragment color 9 | 10 | // Uniform inputs 11 | uniform vec2 resolution; // Viewport resolution (in pixels) 12 | uniform vec2 mouse; // Mouse pixel xy coordinates 13 | uniform float time; // Total run time (in secods) 14 | 15 | // Draw circle 16 | vec4 DrawCircle(vec2 fragCoord, vec2 position, float radius, vec3 color) 17 | { 18 | float d = length(position - fragCoord) - radius; 19 | float t = clamp(d, 0.0, 1.0); 20 | return vec4(color, 1.0 - t); 21 | } 22 | 23 | void main() 24 | { 25 | vec2 fragCoord = gl_FragCoord.xy; 26 | vec2 position = vec2(mouse.x, resolution.y - mouse.y); 27 | float radius = 40.0; 28 | 29 | // Draw background layer 30 | vec4 colorA = vec4(0.2,0.2,0.8, 1.0); 31 | vec4 colorB = vec4(1.0,0.7,0.2, 1.0); 32 | vec4 layer1 = mix(colorA, colorB, abs(sin(time*0.1))); 33 | 34 | // Draw circle layer 35 | vec3 color = vec3(0.9, 0.16, 0.21); 36 | vec4 layer2 = DrawCircle(fragCoord, position, radius, color); 37 | 38 | // Blend the two layers 39 | finalColor = mix(layer1, layer2, layer2.a); 40 | } 41 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/scanlines.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | // NOTE: Render size values must be passed from code 17 | const float renderWidth = 800; 18 | const float renderHeight = 450; 19 | float offset = 0.0; 20 | 21 | uniform float time; 22 | 23 | void main() 24 | { 25 | float frequency = renderHeight/3.0; 26 | /* 27 | // Scanlines method 1 28 | float tval = 0; //time 29 | vec2 uv = 0.5 + (fragTexCoord - 0.5)*(0.9 + 0.01*sin(0.5*tval)); 30 | 31 | vec4 color = texture(texture0, fragTexCoord); 32 | 33 | color = clamp(color*0.5 + 0.5*color*color*1.2, 0.0, 1.0); 34 | color *= 0.5 + 0.5*16.0*uv.x*uv.y*(1.0 - uv.x)*(1.0 - uv.y); 35 | color *= vec4(0.8, 1.0, 0.7, 1); 36 | color *= 0.9 + 0.1*sin(10.0*tval + uv.y*1000.0); 37 | color *= 0.97 + 0.03*sin(110.0*tval); 38 | 39 | fragColor = color; 40 | */ 41 | // Scanlines method 2 42 | float globalPos = (fragTexCoord.y + offset) * frequency; 43 | float wavePos = cos((fract(globalPos) - 0.5)*3.14); 44 | 45 | // Texel color fetching from texture sampler 46 | vec4 texelColor = texture(texture0, fragTexCoord); 47 | 48 | finalColor = mix(vec4(0.0, 0.3, 0.0, 0.0), texelColor, wavePos); 49 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/sobel.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | uniform vec2 resolution = vec2(800, 450); 16 | 17 | void main() 18 | { 19 | float x = 1.0/resolution.x; 20 | float y = 1.0/resolution.y; 21 | 22 | vec4 horizEdge = vec4(0.0); 23 | horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; 24 | horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0; 25 | horizEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; 26 | horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; 27 | horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0; 28 | horizEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; 29 | 30 | vec4 vertEdge = vec4(0.0); 31 | vertEdge -= texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0; 32 | vertEdge -= texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0; 33 | vertEdge -= texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0; 34 | vertEdge += texture2D(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0; 35 | vertEdge += texture2D(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0; 36 | vertEdge += texture2D(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0; 37 | 38 | vec3 edge = sqrt((horizEdge.rgb*horizEdge.rgb) + (vertEdge.rgb*vertEdge.rgb)); 39 | 40 | finalColor = vec4(edge, texture2D(texture0, fragTexCoord).a); 41 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/spotlight.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Output fragment color 8 | out vec4 finalColor; 9 | 10 | // NOTE: Add here your custom variables 11 | 12 | #define MAX_SPOTS 3 13 | 14 | struct Spot { 15 | vec2 pos; // window coords of spot 16 | float inner; // inner fully transparent centre radius 17 | float radius; // alpha fades out to this radius 18 | }; 19 | 20 | uniform Spot spots[MAX_SPOTS]; // Spotlight positions array 21 | uniform float screenWidth; // Width of the screen 22 | 23 | void main() 24 | { 25 | float alpha = 1.0; 26 | 27 | // Get the position of the current fragment (screen coordinates!) 28 | vec2 pos = vec2(gl_FragCoord.x, gl_FragCoord.y); 29 | 30 | // Find out which spotlight is nearest 31 | float d = 65000; // some high value 32 | int fi = -1; // found index 33 | 34 | for (int i = 0; i < MAX_SPOTS; i++) 35 | { 36 | for (int j = 0; j < MAX_SPOTS; j++) 37 | { 38 | float dj = distance(pos, spots[j].pos) - spots[j].radius + spots[i].radius; 39 | 40 | if (d > dj) 41 | { 42 | d = dj; 43 | fi = i; 44 | } 45 | } 46 | } 47 | 48 | // d now equals distance to nearest spot... 49 | // allowing for the different radii of all spotlights 50 | if (fi != -1) 51 | { 52 | if (d > spots[fi].radius) alpha = 1.0; 53 | else 54 | { 55 | if (d < spots[fi].inner) alpha = 0.0; 56 | else alpha = (d - spots[fi].inner) / (spots[fi].radius - spots[fi].inner); 57 | } 58 | } 59 | 60 | // Right hand side of screen is dimly lit, 61 | // could make the threshold value user definable 62 | if ((pos.x > screenWidth/2.0) && (alpha > 0.9)) alpha = 0.9; 63 | 64 | finalColor = vec4(0, 0, 0, alpha); 65 | } 66 | -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/swirl.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | // NOTE: Add here your custom variables 15 | 16 | // NOTE: Render size values should be passed from code 17 | const float renderWidth = 800; 18 | const float renderHeight = 450; 19 | 20 | float radius = 250.0; 21 | float angle = 0.8; 22 | 23 | uniform vec2 center = vec2(200.0, 200.0); 24 | 25 | void main() 26 | { 27 | vec2 texSize = vec2(renderWidth, renderHeight); 28 | vec2 tc = fragTexCoord*texSize; 29 | tc -= center; 30 | 31 | float dist = length(tc); 32 | 33 | if (dist < radius) 34 | { 35 | float percent = (radius - dist)/radius; 36 | float theta = percent*percent*angle*8.0; 37 | float s = sin(theta); 38 | float c = cos(theta); 39 | 40 | tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c))); 41 | } 42 | 43 | tc += center; 44 | vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;; 45 | 46 | finalColor = vec4(color.rgb, 1.0);; 47 | } -------------------------------------------------------------------------------- /examples/shaders/resources/shaders/glsl330/wave.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec2 fragTexCoord; 5 | in vec4 fragColor; 6 | 7 | // Input uniform values 8 | uniform sampler2D texture0; 9 | uniform vec4 colDiffuse; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | uniform float secondes; 15 | 16 | uniform vec2 size; 17 | 18 | uniform float freqX; 19 | uniform float freqY; 20 | uniform float ampX; 21 | uniform float ampY; 22 | uniform float speedX; 23 | uniform float speedY; 24 | 25 | void main() { 26 | float pixelWidth = 1.0 / size.x; 27 | float pixelHeight = 1.0 / size.y; 28 | float aspect = pixelHeight / pixelWidth; 29 | float boxLeft = 0.0; 30 | float boxTop = 0.0; 31 | 32 | vec2 p = fragTexCoord; 33 | p.x += cos((fragTexCoord.y - boxTop) * freqX / ( pixelWidth * 750.0) + (secondes * speedX)) * ampX * pixelWidth; 34 | p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (secondes * speedY)) * ampY * pixelHeight; 35 | 36 | finalColor = texture(texture0, p)*colDiffuse*fragColor; 37 | } 38 | -------------------------------------------------------------------------------- /examples/shaders/resources/space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/shaders/resources/space.png -------------------------------------------------------------------------------- /examples/shaders/resources/texel_checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/shaders/resources/texel_checker.png -------------------------------------------------------------------------------- /examples/shaders/rlights.nim: -------------------------------------------------------------------------------- 1 | import nimraylib_now 2 | 3 | from os import parentDir, `/` 4 | const rlightsHeader = currentSourcePath().parentDir()/"rlights.h" 5 | {.passC: "-DRLIGHTS_IMPLEMENTATION".} 6 | 7 | const MAX_LIGHTS* = 4 8 | 9 | type 10 | Light* {.importc: "Light", header: rlightsHeader, bycopy.} = object 11 | `type`* {.importc: "type".}: cint 12 | position* {.importc: "position".}: Vector3 13 | target* {.importc: "target".}: Vector3 14 | color* {.importc: "color".}: Color 15 | enabled* {.importc: "enabled".}: bool ## Shader locations 16 | enabledLoc* {.importc: "enabledLoc".}: cint 17 | typeLoc* {.importc: "typeLoc".}: cint 18 | posLoc* {.importc: "posLoc".}: cint 19 | targetLoc* {.importc: "targetLoc".}: cint 20 | colorLoc* {.importc: "colorLoc".}: cint 21 | 22 | type 23 | LightType* {.size: sizeof(cint), pure.} = enum 24 | DIRECTIONAL, POINT 25 | converter LightTypeToInt*(self: LightType): cint = self.cint 26 | 27 | proc createLight*(`type`: cint; position: Vector3; target: Vector3; color: Color; 28 | shader: Shader): Light {.importc: "CreateLight", header: rlightsHeader.} 29 | 30 | proc updateLightValues*(shader: Shader; light: Light) {.importc: "UpdateLightValues", 31 | header: rlightsHeader.} 32 | -------------------------------------------------------------------------------- /examples/text/resources/pixantiqua.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/text/resources/pixantiqua.png -------------------------------------------------------------------------------- /examples/text/resources/pixantiqua.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/text/resources/pixantiqua.ttf -------------------------------------------------------------------------------- /examples/text/text_format_text.nim: -------------------------------------------------------------------------------- 1 | #******************************************************************************************* 2 | # 3 | # raylib [text] example - Text formatting 4 | # 5 | # This example has been created using raylib 1.1 (www.raylib.com) 6 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 7 | # 8 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 9 | # /Converted in 2*20 by Guevara-chan. 10 | # Adapted in 2021 by greenfork 11 | # 12 | #******************************************************************************************* 13 | 14 | import nimraylib_now 15 | 16 | # Initialization 17 | # -------------------------------------------------------------------------------------- 18 | const screenWidth = 800 19 | const screenHeight = 450 20 | 21 | initWindow screenWidth, screenHeight, "raylib [text] example - text formatting" 22 | 23 | let 24 | score = 100020 25 | hiscore = 200450 26 | lives = 5 27 | 28 | setTargetFPS(60) # Set our game to run at 60 frames-per-second 29 | # -------------------------------------------------------------------------------------- 30 | 31 | # Main game loop 32 | while not windowShouldClose(): # Detect window close button or ESC key 33 | # Update 34 | # ---------------------------------------------------------------------------------- 35 | # TODO: Update your variables here 36 | # ---------------------------------------------------------------------------------- 37 | 38 | # Draw 39 | # ---------------------------------------------------------------------------------- 40 | beginDrawing() 41 | 42 | clearBackground RAYWHITE 43 | 44 | drawText textFormat("Score: %08i", score), 200, 80, 20, RED 45 | 46 | drawText textFormat("HiScore: %08i", hiscore), 200, 120, 20, GREEN 47 | 48 | drawText textFormat("Lives: %02i", lives), 200, 160, 40, BLUE 49 | 50 | drawText textFormat("Elapsed Time: %02.02f ms", getFrameTime()*1000), 200, 220, 20, BLACK 51 | 52 | endDrawing() 53 | # ---------------------------------------------------------------------------------- 54 | 55 | # De-Initialization 56 | # -------------------------------------------------------------------------------------- 57 | closeWindow() # Close window and OpenGL context 58 | # -------------------------------------------------------------------------------------- 59 | -------------------------------------------------------------------------------- /examples/textures/resources/KAISG.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/KAISG.ttf -------------------------------------------------------------------------------- /examples/textures/resources/boom.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/boom.wav -------------------------------------------------------------------------------- /examples/textures/resources/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/button.png -------------------------------------------------------------------------------- /examples/textures/resources/buttonfx.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/buttonfx.wav -------------------------------------------------------------------------------- /examples/textures/resources/cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/cat.png -------------------------------------------------------------------------------- /examples/textures/resources/custom_jupiter_crash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/custom_jupiter_crash.png -------------------------------------------------------------------------------- /examples/textures/resources/cyberpunk_street_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/cyberpunk_street_background.png -------------------------------------------------------------------------------- /examples/textures/resources/cyberpunk_street_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/cyberpunk_street_foreground.png -------------------------------------------------------------------------------- /examples/textures/resources/cyberpunk_street_midground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/cyberpunk_street_midground.png -------------------------------------------------------------------------------- /examples/textures/resources/explosion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/explosion.png -------------------------------------------------------------------------------- /examples/textures/resources/fudesumi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/fudesumi.png -------------------------------------------------------------------------------- /examples/textures/resources/fudesumi.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/fudesumi.raw -------------------------------------------------------------------------------- /examples/textures/resources/ninepatch_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/ninepatch_button.png -------------------------------------------------------------------------------- /examples/textures/resources/parrots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/parrots.png -------------------------------------------------------------------------------- /examples/textures/resources/patterns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/patterns.png -------------------------------------------------------------------------------- /examples/textures/resources/raylib_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/raylib_logo.png -------------------------------------------------------------------------------- /examples/textures/resources/scarfy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/scarfy.png -------------------------------------------------------------------------------- /examples/textures/resources/smoke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/smoke.png -------------------------------------------------------------------------------- /examples/textures/resources/spark_flame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/spark_flame.png -------------------------------------------------------------------------------- /examples/textures/resources/wabbit_alpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/examples/textures/resources/wabbit_alpha.png -------------------------------------------------------------------------------- /examples/textures/textures_logo_raylib.nim: -------------------------------------------------------------------------------- 1 | # ****************************************************************************************** 2 | # 3 | # raylib [textures] example - Texture loading and drawing 4 | # 5 | # This example has been created using raylib 1.0 (www.raylib.com) 6 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 7 | # 8 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 9 | # Converted in 2021 by greenfork 10 | # 11 | # ****************************************************************************************** 12 | 13 | import nimraylib_now 14 | 15 | 16 | ## Initialization 17 | ## -------------------------------------------------------------------------------------- 18 | var screenWidth = 800 19 | var screenHeight = 450 20 | initWindow(screenWidth, screenHeight, 21 | "raylib [textures] example - texture loading and drawing") 22 | ## NOTE: Textures MUST be loaded after Window initialization (OpenGL context is requiRed) 23 | var texture: Texture2D = loadTexture("resources/raylib_logo.png") 24 | ## Texture loading 25 | ## --------------------------------------------------------------------------------------- 26 | ## Main game loop 27 | while not windowShouldClose(): ## Detect window close button or ESC key 28 | ## Update 29 | ## ---------------------------------------------------------------------------------- 30 | ## TODO: Update your variables here 31 | ## ---------------------------------------------------------------------------------- 32 | ## Draw 33 | ## ---------------------------------------------------------------------------------- 34 | beginDrawing() 35 | clearBackground(Raywhite) 36 | drawTexture(texture, screenWidth div 2 - texture.width div 2, 37 | screenHeight div 2 - texture.height div 2, White) 38 | drawText("this IS a texture!", 360, 370, 10, Gray) 39 | endDrawing() 40 | ## ---------------------------------------------------------------------------------- 41 | ## De-Initialization 42 | ## -------------------------------------------------------------------------------------- 43 | unloadTexture(texture) 44 | ## Texture unloading 45 | closeWindow() 46 | ## Close window and OpenGL context 47 | ## -------------------------------------------------------------------------------------- 48 | -------------------------------------------------------------------------------- /nimraylib_now.nimble: -------------------------------------------------------------------------------- 1 | # Package 2 | 3 | version = "0.15.0" 4 | author = "Dmitry Matveyev" 5 | description = "The Ultimate Raylib gaming library wrapper" 6 | license = "MIT" 7 | srcDir = "src" 8 | skipFiles = @["generate_bindings.nim"] 9 | skipDirs = @["templates"] 10 | backend = "c" 11 | 12 | # Dependencies 13 | 14 | requires "nim >= 1.4.2" 15 | requires "regex" 16 | 17 | from os import `/`, parentDir 18 | 19 | task genbindings, "generate bindings": 20 | exec "nim r src"/"generate_bindings.nim" 21 | 22 | task checkbindings, "nim check all generated bindings": 23 | const nimraylibNowDir = currentSourcePath().parentDir()/"src"/"nimraylib_now" 24 | exec "nim check " & nimraylibNowDir/"mangled"/"raylib.nim" 25 | exec "nim check " & nimraylibNowDir/"mangled"/"raygui.nim" 26 | exec "nim check " & nimraylibNowDir/"mangled"/"rlgl.nim" 27 | exec "nim check " & nimraylibNowDir/"mangled"/"raymath.nim" 28 | exec "nim check " & nimraylibNowDir/"mangled"/"physac.nim" 29 | exec "nim check " & nimraylibNowDir/"mangled"/"converters.nim" 30 | 31 | exec "nim check " & nimraylibNowDir/"not_mangled"/"raylib.nim" 32 | exec "nim check " & nimraylibNowDir/"not_mangled"/"raygui.nim" 33 | exec "nim check " & nimraylibNowDir/"not_mangled"/"rlgl.nim" 34 | exec "nim check " & nimraylibNowDir/"not_mangled"/"raymath.nim" 35 | exec "nim check " & nimraylibNowDir/"not_mangled"/"physac.nim" 36 | exec "nim check " & nimraylibNowDir/"not_mangled"/"converters.nim" 37 | 38 | task prepareTests, "generate tests from examples": 39 | exec "nim r " & "scripts"/"make_tests_from_examples.nim" 40 | exec "nim r " & "scripts"/"make_individual_tests_from_examples.nim" 41 | exec "nim r " & "scripts"/"make_emscripten_tests_from_examples.nim" 42 | 43 | task testExamples, "checks that all examples are correctly compiled": 44 | exec "testament pattern tests/texamples.nim" 45 | exec "testament pattern tests/texamples_shared.nim" 46 | exec "testament pattern tests/texamples_windows.nim" 47 | 48 | # Can fail on Windows due to globbing rules 49 | task testIndividualExamples, "slower but check that all examples compile individually": 50 | exec "testament pattern 'tests/examples/t_*.nim'" 51 | 52 | task testEmscriptenExample, "run a single test with emsdk installed": 53 | exec "testament pattern 'tests/emscripten/t_*.nim'" 54 | -------------------------------------------------------------------------------- /scripts/find_missing_examples.nim: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | const 4 | projectDir = currentSourcePath().parentDir().parentDir() 5 | originalRaylibExamplesDir = projectDir/"raylib"/"examples" 6 | nimraylibNowExamplesDir = projectDir/"examples" 7 | 8 | for dir in walkDirs(originalRaylibExamplesDir/"*"): 9 | for originalExample in walkFiles(dir/"*"): 10 | let (_, name, ext) = splitFile(originalExample) 11 | if ext == ".c": 12 | let 13 | category = originalExample.parentDir.lastPathPart 14 | nimExampleName = name & ".nim" 15 | if not fileExists(nimraylibNowExamplesDir/category/nimExampleName): 16 | echo "Missing: ", category/nimExampleName 17 | -------------------------------------------------------------------------------- /scripts/make_emscripten_tests_from_examples.nim: -------------------------------------------------------------------------------- 1 | import os, strutils 2 | 3 | const 4 | projectDir = currentSourcePath().parentDir().parentDir() 5 | emscriptenExampleDir = projectDir/"examples"/"emscripten" 6 | emscriptenTestDir = projectDir/"tests"/"emscripten" 7 | exampleFile = emscriptenExampleDir/"emscripten_crown.nim" 8 | 9 | removeDir(emscriptenTestDir) 10 | createDir(emscriptenTestDir) 11 | copyFileToDir(emscriptenExampleDir/"config.nims", emscriptenTestDir) 12 | 13 | const 14 | testTemplate = 15 | "discard \"\"\"\n" & 16 | " cmd: \"nim c -d:emscripten --listCmd $options $file\"\n" & 17 | " action: \"compile\"\n" & 18 | " joinable: false\n" & 19 | " matrix: \";-d:release\"\n" & 20 | "\"\"\"\n\n" 21 | 22 | var testContent = testTemplate 23 | let exampleContent = readFile(exampleFile) 24 | testContent &= exampleContent.replace( 25 | "import nimraylib_now", 26 | "import ../../src/nimraylib_now" 27 | ) 28 | 29 | let testName = "t_" & extractFilename(exampleFile) 30 | writeFile(emscriptenTestDir/testName, testContent) 31 | 32 | var configContent = readFile(emscriptenTestDir/"config.nims") 33 | configContent = configContent.replace("--define:nimraylib_now_web_resources", "") 34 | writeFile(emscriptenTestDir/"config.nims", configContent) 35 | -------------------------------------------------------------------------------- /scripts/make_individual_tests_from_examples.nim: -------------------------------------------------------------------------------- 1 | import os, strutils 2 | 3 | const 4 | projectDir = currentSourcePath().parentDir().parentDir() 5 | examplesDir = projectDir/"examples" 6 | examplesTestDir = projectDir/"tests"/"examples" 7 | 8 | # Collect all category names and create them in tests directory 9 | var exampleCategories: seq[string] 10 | for dir in walkDirs(examplesDir/"*"): 11 | let dirName = dir.lastPathPart 12 | if dirName != "emscripten": 13 | exampleCategories.add dirName 14 | 15 | removeDir(examplesTestDir) 16 | createDir(examplesTestDir) 17 | 18 | const 19 | testTemplate = 20 | "discard \"\"\"\n" & 21 | " action: \"compile\"\n" & 22 | " joinable: false\n" & 23 | " matrix: \"; -d:release; --gc:orc -d:release\"\n" & 24 | "\"\"\"\n\n" 25 | 26 | # Create test for each example 27 | for category in exampleCategories: 28 | for example in walkFiles(examplesDir/category/"*.nim"): 29 | if example.endsWith("rlights.nim"): continue 30 | 31 | var testContent = testTemplate 32 | let exampleContent = readFile(example) 33 | testContent &= exampleContent.replace( 34 | "import nimraylib_now", 35 | "import ../../src/nimraylib_now" 36 | ) 37 | 38 | let testName = "t_" & extractFilename(example) 39 | writeFile(examplesTestDir/testName, testContent) 40 | 41 | const 42 | rlightsnim = projectDir/"examples"/"shaders"/"rlights.nim" 43 | rlightsh = projectDir/"examples"/"shaders"/"rlights.h" 44 | 45 | copyFileToDir(rlightsnim, examplesTestDir) 46 | copyFileToDir(rlightsh, examplesTestDir) 47 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/.mailmap: -------------------------------------------------------------------------------- 1 | Camilla Löwy 2 | Camilla Löwy 3 | Camilla Löwy 4 | 5 | Emmanuel Gil Peyrot 6 | 7 | Marcus Geelnard 8 | Marcus Geelnard 9 | Marcus Geelnard 10 | 11 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/GenerateMappings.cmake: -------------------------------------------------------------------------------- 1 | # Usage: 2 | # cmake -P GenerateMappings.cmake 3 | 4 | set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt") 5 | set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt") 6 | set(template_path "${CMAKE_ARGV3}") 7 | set(target_path "${CMAKE_ARGV4}") 8 | 9 | if (NOT EXISTS "${template_path}") 10 | message(FATAL_ERROR "Failed to find template file ${template_path}") 11 | endif() 12 | 13 | file(DOWNLOAD "${source_url}" "${source_path}" 14 | STATUS download_status 15 | TLS_VERIFY on) 16 | 17 | list(GET download_status 0 status_code) 18 | list(GET download_status 1 status_message) 19 | 20 | if (status_code) 21 | message(FATAL_ERROR "Failed to download ${source_url}: ${status_message}") 22 | endif() 23 | 24 | file(STRINGS "${source_path}" lines) 25 | foreach(line ${lines}) 26 | if ("${line}" MATCHES "^[0-9a-fA-F].*$") 27 | set(GLFW_GAMEPAD_MAPPINGS "${GLFW_GAMEPAD_MAPPINGS}\"${line}\",\n") 28 | endif() 29 | endforeach() 30 | 31 | configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX) 32 | file(REMOVE "${source_path}") 33 | 34 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/Info.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${MACOSX_BUNDLE_EXECUTABLE_NAME} 9 | CFBundleGetInfoString 10 | ${MACOSX_BUNDLE_INFO_STRING} 11 | CFBundleIconFile 12 | ${MACOSX_BUNDLE_ICON_FILE} 13 | CFBundleIdentifier 14 | ${MACOSX_BUNDLE_GUI_IDENTIFIER} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleLongVersionString 18 | ${MACOSX_BUNDLE_LONG_VERSION_STRING} 19 | CFBundleName 20 | ${MACOSX_BUNDLE_BUNDLE_NAME} 21 | CFBundlePackageType 22 | APPL 23 | CFBundleShortVersionString 24 | ${MACOSX_BUNDLE_SHORT_VERSION_STRING} 25 | CFBundleSignature 26 | ???? 27 | CFBundleVersion 28 | ${MACOSX_BUNDLE_BUNDLE_VERSION} 29 | CSResourcesFileMapped 30 | 31 | LSRequiresCarbon 32 | 33 | NSHumanReadableCopyright 34 | ${MACOSX_BUNDLE_COPYRIGHT} 35 | NSHighResolutionCapable 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/MacOSXBundleInfo.plist.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${MACOSX_BUNDLE_EXECUTABLE_NAME} 9 | CFBundleGetInfoString 10 | ${MACOSX_BUNDLE_INFO_STRING} 11 | CFBundleIconFile 12 | ${MACOSX_BUNDLE_ICON_FILE} 13 | CFBundleIdentifier 14 | ${MACOSX_BUNDLE_GUI_IDENTIFIER} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleLongVersionString 18 | ${MACOSX_BUNDLE_LONG_VERSION_STRING} 19 | CFBundleName 20 | ${MACOSX_BUNDLE_BUNDLE_NAME} 21 | CFBundlePackageType 22 | APPL 23 | CFBundleShortVersionString 24 | ${MACOSX_BUNDLE_SHORT_VERSION_STRING} 25 | CFBundleSignature 26 | ???? 27 | CFBundleVersion 28 | ${MACOSX_BUNDLE_BUNDLE_VERSION} 29 | CSResourcesFileMapped 30 | 31 | LSRequiresCarbon 32 | 33 | NSHumanReadableCopyright 34 | ${MACOSX_BUNDLE_COPYRIGHT} 35 | NSHighResolutionCapable 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | 2 | if (NOT EXISTS "@GLFW_BINARY_DIR@/install_manifest.txt") 3 | message(FATAL_ERROR "Cannot find install manifest: \"@GLFW_BINARY_DIR@/install_manifest.txt\"") 4 | endif() 5 | 6 | file(READ "@GLFW_BINARY_DIR@/install_manifest.txt" files) 7 | string(REGEX REPLACE "\n" ";" files "${files}") 8 | 9 | foreach (file ${files}) 10 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 11 | if (EXISTS "$ENV{DESTDIR}${file}") 12 | exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 13 | OUTPUT_VARIABLE rm_out 14 | RETURN_VALUE rm_retval) 15 | if (NOT "${rm_retval}" STREQUAL 0) 16 | MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 17 | endif() 18 | elseif (IS_SYMLINK "$ENV{DESTDIR}${file}") 19 | EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 20 | OUTPUT_VARIABLE rm_out 21 | RETURN_VALUE rm_retval) 22 | if (NOT "${rm_retval}" STREQUAL 0) 23 | message(FATAL_ERROR "Problem when removing symlink \"$ENV{DESTDIR}${file}\"") 24 | endif() 25 | else() 26 | message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") 27 | endif() 28 | endforeach() 29 | 30 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/glfw3.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 4 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 5 | 6 | Name: GLFW 7 | Description: A multi-platform library for OpenGL, window and input 8 | Version: @GLFW_VERSION@ 9 | URL: https://www.glfw.org/ 10 | Requires.private: @GLFW_PKG_DEPS@ 11 | Libs: -L${libdir} -l@GLFW_LIB_NAME@ 12 | Libs.private: @GLFW_PKG_LIBS@ 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/glfw3Config.cmake.in: -------------------------------------------------------------------------------- 1 | include(CMakeFindDependencyMacro) 2 | find_dependency(Threads) 3 | include("${CMAKE_CURRENT_LIST_DIR}/glfw3Targets.cmake") 4 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/i686-w64-mingw32-clang.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross-compiling with 32-bit MinGW-w64 Clang 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "i686-w64-mingw32-clang") 5 | SET(CMAKE_CXX_COMPILER "i686-w64-mingw32-clang++") 6 | SET(CMAKE_RC_COMPILER "i686-w64-mingw32-windres") 7 | SET(CMAKE_RANLIB "i686-w64-mingw32-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/i686-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross-compiling with 32-bit MinGW-w64 GCC 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "i686-w64-mingw32-gcc") 5 | SET(CMAKE_CXX_COMPILER "i686-w64-mingw32-g++") 6 | SET(CMAKE_RC_COMPILER "i686-w64-mingw32-windres") 7 | SET(CMAKE_RANLIB "i686-w64-mingw32-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/modules/FindEpollShim.cmake: -------------------------------------------------------------------------------- 1 | # Find EpollShim 2 | # Once done, this will define 3 | # 4 | # EPOLLSHIM_FOUND - System has EpollShim 5 | # EPOLLSHIM_INCLUDE_DIRS - The EpollShim include directories 6 | # EPOLLSHIM_LIBRARIES - The libraries needed to use EpollShim 7 | 8 | find_path(EPOLLSHIM_INCLUDE_DIRS NAMES sys/epoll.h sys/timerfd.h HINTS /usr/local/include/libepoll-shim) 9 | find_library(EPOLLSHIM_LIBRARIES NAMES epoll-shim libepoll-shim HINTS /usr/local/lib) 10 | 11 | if (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES) 12 | set(EPOLLSHIM_FOUND TRUE) 13 | endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES) 14 | 15 | include(FindPackageHandleStandardArgs) 16 | find_package_handle_standard_args(EPOLLSHIM DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS) 17 | mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES) 18 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/modules/FindOSMesa.cmake: -------------------------------------------------------------------------------- 1 | # Try to find OSMesa on a Unix system 2 | # 3 | # This will define: 4 | # 5 | # OSMESA_LIBRARIES - Link these to use OSMesa 6 | # OSMESA_INCLUDE_DIR - Include directory for OSMesa 7 | # 8 | # Copyright (c) 2014 Brandon Schaefer 9 | 10 | if (NOT WIN32) 11 | 12 | find_package (PkgConfig) 13 | pkg_check_modules (PKG_OSMESA QUIET osmesa) 14 | 15 | set (OSMESA_INCLUDE_DIR ${PKG_OSMESA_INCLUDE_DIRS}) 16 | set (OSMESA_LIBRARIES ${PKG_OSMESA_LIBRARIES}) 17 | 18 | endif () 19 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/modules/FindWaylandProtocols.cmake: -------------------------------------------------------------------------------- 1 | find_package(PkgConfig) 2 | 3 | pkg_check_modules(WaylandProtocols QUIET wayland-protocols>=${WaylandProtocols_FIND_VERSION}) 4 | 5 | execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir wayland-protocols 6 | OUTPUT_VARIABLE WaylandProtocols_PKGDATADIR 7 | RESULT_VARIABLE _pkgconfig_failed) 8 | if (_pkgconfig_failed) 9 | message(FATAL_ERROR "Missing wayland-protocols pkgdatadir") 10 | endif() 11 | 12 | string(REGEX REPLACE "[\r\n]" "" WaylandProtocols_PKGDATADIR "${WaylandProtocols_PKGDATADIR}") 13 | 14 | find_package_handle_standard_args(WaylandProtocols 15 | FOUND_VAR 16 | WaylandProtocols_FOUND 17 | REQUIRED_VARS 18 | WaylandProtocols_PKGDATADIR 19 | VERSION_VAR 20 | WaylandProtocols_VERSION 21 | HANDLE_COMPONENTS 22 | ) 23 | 24 | set(WAYLAND_PROTOCOLS_FOUND ${WaylandProtocols_FOUND}) 25 | set(WAYLAND_PROTOCOLS_PKGDATADIR ${WaylandProtocols_PKGDATADIR}) 26 | set(WAYLAND_PROTOCOLS_VERSION ${WaylandProtocols_VERSION}) 27 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/modules/FindXKBCommon.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find XKBCommon 2 | # Once done, this will define 3 | # 4 | # XKBCOMMON_FOUND - System has XKBCommon 5 | # XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories 6 | # XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon 7 | # XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon 8 | 9 | find_package(PkgConfig) 10 | pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon) 11 | set(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER}) 12 | 13 | find_path(XKBCOMMON_INCLUDE_DIR 14 | NAMES xkbcommon/xkbcommon.h 15 | HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS} 16 | ) 17 | 18 | find_library(XKBCOMMON_LIBRARY 19 | NAMES xkbcommon 20 | HINTS ${PC_XKBCOMMON_LIBRARY} ${PC_XKBCOMMON_LIBRARY_DIRS} 21 | ) 22 | 23 | set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY}) 24 | set(XKBCOMMON_LIBRARY_DIRS ${XKBCOMMON_LIBRARY_DIRS}) 25 | set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIR}) 26 | 27 | include(FindPackageHandleStandardArgs) 28 | find_package_handle_standard_args(XKBCommon DEFAULT_MSG 29 | XKBCOMMON_LIBRARY 30 | XKBCOMMON_INCLUDE_DIR 31 | ) 32 | 33 | mark_as_advanced(XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR) 34 | 35 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross-compiling with 64-bit MinGW-w64 Clang 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "x86_64-w64-mingw32-clang") 5 | SET(CMAKE_CXX_COMPILER "x86_64-w64-mingw32-clang++") 6 | SET(CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres") 7 | SET(CMAKE_RANLIB "x86_64-w64-mingw32-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/CMake/x86_64-w64-mingw32.cmake: -------------------------------------------------------------------------------- 1 | # Define the environment for cross-compiling with 64-bit MinGW-w64 GCC 2 | SET(CMAKE_SYSTEM_NAME Windows) # Target system name 3 | SET(CMAKE_SYSTEM_VERSION 1) 4 | SET(CMAKE_C_COMPILER "x86_64-w64-mingw32-gcc") 5 | SET(CMAKE_CXX_COMPILER "x86_64-w64-mingw32-g++") 6 | SET(CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres") 7 | SET(CMAKE_RANLIB "x86_64-w64-mingw32-ranlib") 8 | 9 | # Configure the behaviour of the find commands 10 | SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32") 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | 3 | Copyright (c) 2006-2019 Camilla Löwy 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would 16 | be appreciated but is not required. 17 | 18 | 2. Altered source versions must be plainly marked as such, and must not 19 | be misrepresented as being the original software. 20 | 21 | 3. This notice may not be removed or altered from any source 22 | distribution. 23 | 24 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/deps/getopt.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, Kim Gräsman 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright notice, 7 | * this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright notice, 9 | * this list of conditions and the following disclaimer in the documentation 10 | * and/or other materials provided with the distribution. 11 | * * Neither the name of Kim Gräsman nor the names of contributors may be used 12 | * to endorse or promote products derived from this software without specific 13 | * prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT, 19 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef INCLUDED_GETOPT_PORT_H 28 | #define INCLUDED_GETOPT_PORT_H 29 | 30 | #if defined(__cplusplus) 31 | extern "C" { 32 | #endif 33 | 34 | extern const int no_argument; 35 | extern const int required_argument; 36 | extern const int optional_argument; 37 | 38 | extern char* optarg; 39 | extern int optind, opterr, optopt; 40 | 41 | struct option { 42 | const char* name; 43 | int has_arg; 44 | int* flag; 45 | int val; 46 | }; 47 | 48 | int getopt(int argc, char* const argv[], const char* optstring); 49 | 50 | int getopt_long(int argc, char* const argv[], 51 | const char* optstring, const struct option* longopts, int* longindex); 52 | 53 | #if defined(__cplusplus) 54 | } 55 | #endif 56 | 57 | #endif // INCLUDED_GETOPT_PORT_H 58 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/src/cocoa_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Cocoa - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns 33 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; } 34 | 35 | #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" 36 | 37 | // Cocoa-specific per-joystick data 38 | // 39 | typedef struct _GLFWjoystickNS 40 | { 41 | IOHIDDeviceRef device; 42 | CFMutableArrayRef axes; 43 | CFMutableArrayRef buttons; 44 | CFMutableArrayRef hats; 45 | } _GLFWjoystickNS; 46 | 47 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/src/cocoa_time.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 macOS - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2009-2016 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // It is fine to use C99 in this file because it will not be built with VS 27 | //======================================================================== 28 | 29 | #include "internal.h" 30 | 31 | #include 32 | 33 | 34 | ////////////////////////////////////////////////////////////////////////// 35 | ////// GLFW internal API ////// 36 | ////////////////////////////////////////////////////////////////////////// 37 | 38 | // Initialise timer 39 | // 40 | void _glfwInitTimerNS(void) 41 | { 42 | mach_timebase_info_data_t info; 43 | mach_timebase_info(&info); 44 | 45 | _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer; 46 | } 47 | 48 | 49 | ////////////////////////////////////////////////////////////////////////// 50 | ////// GLFW platform API ////// 51 | ////////////////////////////////////////////////////////////////////////// 52 | 53 | uint64_t _glfwPlatformGetTimerValue(void) 54 | { 55 | return mach_absolute_time(); 56 | } 57 | 58 | uint64_t _glfwPlatformGetTimerFrequency(void) 59 | { 60 | return _glfw.timer.ns.frequency; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/src/glfw.rc.in: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 6 | PRODUCTVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_NT_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE 0 12 | { 13 | BLOCK "StringFileInfo" 14 | { 15 | BLOCK "040904B0" 16 | { 17 | VALUE "CompanyName", "GLFW" 18 | VALUE "FileDescription", "GLFW @GLFW_VERSION@ DLL" 19 | VALUE "FileVersion", "@GLFW_VERSION@" 20 | VALUE "OriginalFilename", "glfw3.dll" 21 | VALUE "ProductName", "GLFW" 22 | VALUE "ProductVersion", "@GLFW_VERSION@" 23 | } 24 | } 25 | BLOCK "VarFileInfo" 26 | { 27 | VALUE "Translation", 0x409, 1200 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/src/linux_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs 32 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs 33 | 34 | #define _GLFW_PLATFORM_MAPPING_NAME "Linux" 35 | 36 | // Linux-specific joystick data 37 | // 38 | typedef struct _GLFWjoystickLinux 39 | { 40 | int fd; 41 | char path[PATH_MAX]; 42 | int keyMap[KEY_CNT - BTN_MISC]; 43 | int absMap[ABS_CNT]; 44 | struct input_absinfo absInfo[ABS_CNT]; 45 | int hats[4][2]; 46 | } _GLFWjoystickLinux; 47 | 48 | // Linux-specific joystick API data 49 | // 50 | typedef struct _GLFWlibraryLinux 51 | { 52 | int inotify; 53 | int watch; 54 | regex_t regex; 55 | GLFWbool dropped; 56 | } _GLFWlibraryLinux; 57 | 58 | void _glfwDetectJoystickConnectionLinux(void); 59 | 60 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/src/null_init.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016 Google Inc. 5 | // Copyright (c) 2016-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | // It is fine to use C99 in this file because it will not be built with VS 28 | //======================================================================== 29 | 30 | #include "internal.h" 31 | 32 | #include 33 | 34 | 35 | ////////////////////////////////////////////////////////////////////////// 36 | ////// GLFW platform API ////// 37 | ////////////////////////////////////////////////////////////////////////// 38 | 39 | int _glfwPlatformInit(void) 40 | { 41 | _glfwInitTimerPOSIX(); 42 | _glfwPollMonitorsNull(); 43 | 44 | return GLFW_TRUE; 45 | } 46 | 47 | void _glfwPlatformTerminate(void) 48 | { 49 | free(_glfw.null.clipboardString); 50 | _glfwTerminateOSMesa(); 51 | } 52 | 53 | const char* _glfwPlatformGetVersionString(void) 54 | { 55 | return _GLFW_VERSION_NUMBER " null OSMesa"; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/src/null_joystick.c: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2016-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | // It is fine to use C99 in this file because it will not be built with VS 27 | //======================================================================== 28 | 29 | #include "internal.h" 30 | 31 | 32 | ////////////////////////////////////////////////////////////////////////// 33 | ////// GLFW platform API ////// 34 | ////////////////////////////////////////////////////////////////////////// 35 | 36 | GLFWbool _glfwPlatformInitJoysticks(void) 37 | { 38 | return GLFW_TRUE; 39 | } 40 | 41 | void _glfwPlatformTerminateJoysticks(void) 42 | { 43 | } 44 | 45 | int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) 46 | { 47 | return GLFW_FALSE; 48 | } 49 | 50 | void _glfwPlatformUpdateGamepadGUID(char* guid) 51 | { 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/src/null_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; } 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "" 31 | 32 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/src/posix_thread.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #include 29 | 30 | #define _GLFW_PLATFORM_TLS_STATE _GLFWtlsPOSIX posix 31 | #define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexPOSIX posix 32 | 33 | 34 | // POSIX-specific thread local storage data 35 | // 36 | typedef struct _GLFWtlsPOSIX 37 | { 38 | GLFWbool allocated; 39 | pthread_key_t key; 40 | 41 | } _GLFWtlsPOSIX; 42 | 43 | // POSIX-specific mutex data 44 | // 45 | typedef struct _GLFWmutexPOSIX 46 | { 47 | GLFWbool allocated; 48 | pthread_mutex_t handle; 49 | 50 | } _GLFWmutexPOSIX; 51 | 52 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/src/posix_time.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 POSIX - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2002-2006 Marcus Geelnard 5 | // Copyright (c) 2006-2017 Camilla Löwy 6 | // 7 | // This software is provided 'as-is', without any express or implied 8 | // warranty. In no event will the authors be held liable for any damages 9 | // arising from the use of this software. 10 | // 11 | // Permission is granted to anyone to use this software for any purpose, 12 | // including commercial applications, and to alter it and redistribute it 13 | // freely, subject to the following restrictions: 14 | // 15 | // 1. The origin of this software must not be misrepresented; you must not 16 | // claim that you wrote the original software. If you use this software 17 | // in a product, an acknowledgment in the product documentation would 18 | // be appreciated but is not required. 19 | // 20 | // 2. Altered source versions must be plainly marked as such, and must not 21 | // be misrepresented as being the original software. 22 | // 23 | // 3. This notice may not be removed or altered from any source 24 | // distribution. 25 | // 26 | //======================================================================== 27 | 28 | #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix 29 | 30 | #include 31 | 32 | 33 | // POSIX-specific global timer data 34 | // 35 | typedef struct _GLFWtimerPOSIX 36 | { 37 | GLFWbool monotonic; 38 | uint64_t frequency; 39 | 40 | } _GLFWtimerPOSIX; 41 | 42 | 43 | void _glfwInitTimerPOSIX(void); 44 | 45 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/src/win32_joystick.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Win32 - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2006-2017 Camilla Löwy 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 28 | #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } 29 | 30 | #define _GLFW_PLATFORM_MAPPING_NAME "Windows" 31 | 32 | // Joystick element (axis, button or slider) 33 | // 34 | typedef struct _GLFWjoyobjectWin32 35 | { 36 | int offset; 37 | int type; 38 | } _GLFWjoyobjectWin32; 39 | 40 | // Win32-specific per-joystick data 41 | // 42 | typedef struct _GLFWjoystickWin32 43 | { 44 | _GLFWjoyobjectWin32* objects; 45 | int objectCount; 46 | IDirectInputDevice8W* device; 47 | DWORD index; 48 | GUID guid; 49 | } _GLFWjoystickWin32; 50 | 51 | void _glfwDetectJoystickConnectionWin32(void); 52 | void _glfwDetectJoystickDisconnectionWin32(void); 53 | 54 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/external/glfw/src/xkb_unicode.h: -------------------------------------------------------------------------------- 1 | //======================================================================== 2 | // GLFW 3.4 Linux - www.glfw.org 3 | //------------------------------------------------------------------------ 4 | // Copyright (c) 2014 Jonas Ådahl 5 | // 6 | // This software is provided 'as-is', without any express or implied 7 | // warranty. In no event will the authors be held liable for any damages 8 | // arising from the use of this software. 9 | // 10 | // Permission is granted to anyone to use this software for any purpose, 11 | // including commercial applications, and to alter it and redistribute it 12 | // freely, subject to the following restrictions: 13 | // 14 | // 1. The origin of this software must not be misrepresented; you must not 15 | // claim that you wrote the original software. If you use this software 16 | // in a product, an acknowledgment in the product documentation would 17 | // be appreciated but is not required. 18 | // 19 | // 2. Altered source versions must be plainly marked as such, and must not 20 | // be misrepresented as being the original software. 21 | // 22 | // 3. This notice may not be removed or altered from any source 23 | // distribution. 24 | // 25 | //======================================================================== 26 | 27 | long _glfwKeySym2Unicode(unsigned int keysym); 28 | 29 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/raylib.dll.rc: -------------------------------------------------------------------------------- 1 | GLFW_ICON ICON "raylib.ico" 2 | 3 | 1 VERSIONINFO 4 | FILEVERSION 4,2,0,0 5 | PRODUCTVERSION 4,2,0,0 6 | BEGIN 7 | BLOCK "StringFileInfo" 8 | BEGIN 9 | //BLOCK "080904E4" // English UK 10 | BLOCK "040904E4" // English US 11 | BEGIN 12 | //VALUE "CompanyName", "raylib technologies" 13 | VALUE "FileDescription", "raylib dynamic library (www.raylib.com)" 14 | VALUE "FileVersion", "4.2.0" 15 | VALUE "InternalName", "raylib.dll" 16 | VALUE "LegalCopyright", "(c) 2022 Ramon Santamaria (@raysan5)" 17 | VALUE "OriginalFilename", "raylib.dll" 18 | VALUE "ProductName", "raylib" 19 | VALUE "ProductVersion", "4.2.0" 20 | END 21 | END 22 | BLOCK "VarFileInfo" 23 | BEGIN 24 | //VALUE "Translation", 0x809, 1252 // English UK 25 | VALUE "Translation", 0x409, 1252 // English US 26 | END 27 | END 28 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/raylib.dll.rc.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/src/csources/raylib_mangled/raylib.dll.rc.data -------------------------------------------------------------------------------- /src/csources/raylib_mangled/raylib.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/src/csources/raylib_mangled/raylib.ico -------------------------------------------------------------------------------- /src/csources/raylib_mangled/raylib.rc: -------------------------------------------------------------------------------- 1 | GLFW_ICON ICON "raylib.ico" 2 | 3 | 1 VERSIONINFO 4 | FILEVERSION 4,2,0,0 5 | PRODUCTVERSION 4,2,0,0 6 | BEGIN 7 | BLOCK "StringFileInfo" 8 | BEGIN 9 | //BLOCK "080904E4" // English UK 10 | BLOCK "040904E4" // English US 11 | BEGIN 12 | //VALUE "CompanyName", "raylib technologies" 13 | VALUE "FileDescription", "raylib application (www.raylib.com)" 14 | VALUE "FileVersion", "4.2.0" 15 | VALUE "InternalName", "raylib app" 16 | VALUE "LegalCopyright", "(c) 2022 Ramon Santamaria (@raysan5)" 17 | //VALUE "OriginalFilename", "raylib_app.exe" 18 | VALUE "ProductName", "raylib app" 19 | VALUE "ProductVersion", "4.2.0" 20 | END 21 | END 22 | BLOCK "VarFileInfo" 23 | BEGIN 24 | //VALUE "Translation", 0x809, 1252 // English UK 25 | VALUE "Translation", 0x409, 1252 // English US 26 | END 27 | END 28 | -------------------------------------------------------------------------------- /src/csources/raylib_mangled/raylib.rc.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/greenfork/nimraylib_now/baf57c23da279de7c518edc124a791c77495b452/src/csources/raylib_mangled/raylib.rc.data -------------------------------------------------------------------------------- /src/nimraylib_now.nim: -------------------------------------------------------------------------------- 1 | ## Import necessary modules 2 | 3 | import nimraylib_now/raylib 4 | import nimraylib_now/raymath 5 | import nimraylib_now/physac 6 | import nimraylib_now/raygui 7 | import nimraylib_now/converters 8 | 9 | export raylib 10 | export raymath 11 | export physac 12 | export raygui 13 | export converters 14 | -------------------------------------------------------------------------------- /src/nimraylib_now/converters.nim: -------------------------------------------------------------------------------- 1 | when defined(nimraylib_now_shared) or defined(nimraylib_now_linkingOverride): 2 | import not_mangled/converters 3 | else: 4 | import mangled/converters 5 | 6 | export converters 7 | -------------------------------------------------------------------------------- /src/nimraylib_now/physac.nim: -------------------------------------------------------------------------------- 1 | when defined(nimraylib_now_shared) or defined(nimraylib_now_linkingOverride): 2 | import not_mangled/physac 3 | else: 4 | import mangled/physac 5 | 6 | export physac 7 | -------------------------------------------------------------------------------- /src/nimraylib_now/raygui.nim: -------------------------------------------------------------------------------- 1 | when defined(nimraylib_now_shared) or defined(nimraylib_now_linkingOverride): 2 | import not_mangled/raygui 3 | else: 4 | import mangled/raygui 5 | 6 | export raygui 7 | -------------------------------------------------------------------------------- /src/nimraylib_now/raylib.nim: -------------------------------------------------------------------------------- 1 | when defined(nimraylib_now_shared) or defined(nimraylib_now_linkingOverride): 2 | import not_mangled/raylib 3 | else: 4 | import mangled/raylib 5 | 6 | export raylib 7 | -------------------------------------------------------------------------------- /src/nimraylib_now/raymath.nim: -------------------------------------------------------------------------------- 1 | when defined(nimraylib_now_shared) or defined(nimraylib_now_linkingOverride): 2 | import not_mangled/raymath 3 | else: 4 | import mangled/raymath 5 | 6 | export raymath 7 | -------------------------------------------------------------------------------- /src/nimraylib_now/rlgl.nim: -------------------------------------------------------------------------------- 1 | when defined(nimraylib_now_shared) or defined(nimraylib_now_linkingOverride): 2 | import not_mangled/rlgl 3 | else: 4 | import mangled/rlgl 5 | 6 | export rlgl 7 | -------------------------------------------------------------------------------- /src/templates/base_converters.nim: -------------------------------------------------------------------------------- 1 | import ./raylib 2 | import ./rlgl 3 | import ./raygui 4 | 5 | converter toCint*(self: int): cint = self.cint 6 | converter toInt*(self: cint): int = self.int 7 | 8 | # Conversions from tuple to object for Vector2, Vector3, Vector4, 9 | # Matrix and Rectangle. Quaternion is same as Vector4, so works too. 10 | converter tupleToColor*(self: tuple[r,g,b,a: int]): Color = 11 | Color(r: self.r.uint8, g: self.g.uint8, b: self.b.uint8, a: self.a.uint8) 12 | 13 | converter tupleToColor*(self: tuple[r,g,b: int]): Color = 14 | Color(r: self.r.uint8, g: self.g.uint8, b: self.b.uint8, a: 255) 15 | 16 | converter tupleToVector2*(self: tuple[x,y: float]): Vector2 = 17 | Vector2(x: self.x.cfloat, y: self.y.cfloat) 18 | 19 | converter tupleToVector3*(self: tuple[x,y,z: float]): Vector3 = 20 | Vector3(x: self.x.cfloat, y: self.y.cfloat, z: self.z.cfloat) 21 | 22 | converter tupleToVector4*(self: tuple[x,y,z,w: float]): Vector4 = 23 | Vector4(x: self.x.cfloat, y: self.y.cfloat, z: self.z.cfloat, w: self.w.cfloat) 24 | 25 | converter tupleToMatrix*(self: 26 | tuple[m0,m4,m8, m12, 27 | m1,m5,m9, m13, 28 | m2,m6,m10,m14, 29 | m3,m7,m11,m15: float] 30 | ): Matrix = 31 | Matrix( 32 | m0: self.m0.cfloat, m4: self.m4.cfloat, m8: self.m8.cfloat, m12: self.m12.cfloat, 33 | m1: self.m1.cfloat, m5: self.m5.cfloat, m9: self.m9.cfloat, m13: self.m13.cfloat, 34 | m2: self.m2.cfloat, m6: self.m6.cfloat, m10: self.m10.cfloat, m14: self.m14.cfloat, 35 | m3: self.m3.cfloat, m7: self.m7.cfloat, m11: self.m11.cfloat, m15: self.m15.cfloat, 36 | ) 37 | 38 | converter tupleToRectangle*(self: tuple[x,y,width,height: float]): Rectangle = 39 | Rectangle(x: self.x.cfloat, y: self.y.cfloat, width: self.width.cfloat, height: self.height.cfloat) 40 | -------------------------------------------------------------------------------- /src/templates/raymath_shortcuts.nim: -------------------------------------------------------------------------------- 1 | template `+`*[T: Vector2 | Vector3 | Quaternion | Matrix](v1, v2: T): T = add(v1, v2) 2 | template `+=`*[T: Vector2 | Vector3 | Quaternion | Matrix](v1: var T, v2: T) = v1 = add(v1, v2) 3 | template `+`*[T: Vector2 | Vector3 | Quaternion](v1: T, value: cfloat): T = addValue(v1, value) 4 | template `+=`*[T: Vector2 | Vector3 | Quaternion](v1: var T, value: cfloat) = v1 = addValue(v1, value) 5 | 6 | template `-`*[T: Vector2 | Vector3 | Quaternion | Matrix](v1, v2: T): T = subtract(v1, v2) 7 | template `-=`*[T: Vector2 | Vector3 | Quaternion | Matrix](v1: var T, v2: T) = v1 = subtract(v1, v2) 8 | template `-`*[T: Vector2 | Vector3 | Quaternion](v1: T, value: cfloat): T = subtractValue(v1, value) 9 | template `-=`*[T: Vector2 | Vector3 | Quaternion](v1: var T, value: cfloat) = v1 = subtractValue(v1, value) 10 | 11 | template `*`*[T: Vector2 | Vector3 | Quaternion | Matrix](v1, v2: T): T = multiply(v1, v2) 12 | template `*=`*[T: Vector2 | Vector3 | Quaternion | Matrix](v1: var T, v2: T) = v1 = multiply(v1, v2) 13 | template `*`*[T: Vector2 | Vector3 | Quaternion](v1: T, value: cfloat): T = scale(v1, value) 14 | template `*=`*[T: Vector2 | Vector3 | Quaternion](v1: var T, value: cfloat) = v1 = scale(v1, value) 15 | 16 | template `/`*[T: Vector2 | Vector3 | Quaternion | Matrix](v1, v2: T): T = divide(v1, v2) 17 | template `/=`*[T: Vector2 | Vector3 | Quaternion | Matrix](v1: var T, v2: T) = v1 = divide(v1, v2) 18 | template `/`*[T: Vector2 | Vector3 | Quaternion](v1: T, value: cfloat): T = scale(v1, 1.0/value) 19 | template `/=`*[T: Vector2 | Vector3 | Quaternion](v1: var T, value: cfloat) = v1 = scale(v1, 1.0/value) 20 | 21 | template `-`*[T: Vector2 | Vector3](v1: T): T = negate(v1) 22 | -------------------------------------------------------------------------------- /tests/emscripten/config.nims: -------------------------------------------------------------------------------- 1 | --define:emscripten # Specify target 2 | 3 | --os:linux # Emscripten pretends to be linux. 4 | --cpu:wasm32 # Emscripten is 32bits. 5 | --cc:clang # Emscripten is very close to clang, so we will replace it. 6 | when defined(windows): 7 | --clang.exe:emcc.bat # Replace C 8 | --clang.linkerexe:emcc.bat # Replace C linker 9 | --clang.cpp.exe:emcc.bat # Replace C++ 10 | --clang.cpp.linkerexe:emcc.bat # Replace C++ linker. 11 | else: 12 | --clang.exe:emcc # Replace C 13 | --clang.linkerexe:emcc # Replace C linker 14 | --clang.cpp.exe:emcc # Replace C++ 15 | --clang.cpp.linkerexe:emcc # Replace C++ linker. 16 | 17 | --gc:orc # GC:orc is friendlier with crazy platforms. 18 | --exceptions:goto # Goto exceptions are friendlier with crazy platforms. 19 | --define:noSignalHandler # Emscripten doesn't support signal handlers. 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/examples/rlights.nim: -------------------------------------------------------------------------------- 1 | import ../../src/nimraylib_now 2 | 3 | from os import parentDir, `/` 4 | const rlightsHeader = currentSourcePath().parentDir()/"rlights.h" 5 | {.passC: "-DRLIGHTS_IMPLEMENTATION".} 6 | 7 | const MAX_LIGHTS* = 4 8 | 9 | type 10 | Light* {.importc: "Light", header: rlightsHeader, bycopy.} = object 11 | `type`* {.importc: "type".}: cint 12 | position* {.importc: "position".}: Vector3 13 | target* {.importc: "target".}: Vector3 14 | color* {.importc: "color".}: Color 15 | enabled* {.importc: "enabled".}: bool ## Shader locations 16 | enabledLoc* {.importc: "enabledLoc".}: cint 17 | typeLoc* {.importc: "typeLoc".}: cint 18 | posLoc* {.importc: "posLoc".}: cint 19 | targetLoc* {.importc: "targetLoc".}: cint 20 | colorLoc* {.importc: "colorLoc".}: cint 21 | 22 | type 23 | LightType* {.size: sizeof(cint), pure.} = enum 24 | DIRECTIONAL, POINT 25 | converter LightTypeToInt*(self: LightType): cint = self.cint 26 | 27 | proc createLight*(`type`: cint; position: Vector3; target: Vector3; color: Color; 28 | shader: Shader): Light {.importc: "CreateLight", header: rlightsHeader.} 29 | 30 | proc updateLightValues*(shader: Shader; light: Light) {.importc: "UpdateLightValues", 31 | header: rlightsHeader.} 32 | -------------------------------------------------------------------------------- /tests/examples/t_basic.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | joinable: false 4 | matrix: "; -d:release; --gc:orc -d:release" 5 | """ 6 | 7 | # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # 8 | # Raylib Forever basic usage sample 9 | # Developed in 2*20 by Guevara-chan 10 | # Adapted in 2021 by greenfork 11 | # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # 12 | 13 | import ../../src/nimraylib_now 14 | 15 | initWindow 800, 600, "[nim]RaylibNow!" 16 | 60.setTargetFPS 17 | 18 | # Camera setup. 19 | var camera = Camera( 20 | position: (x: 0.0, y: 10.0, z: -15.0), 21 | up: (x: 0.0, y: 0.5, z: 0.0), 22 | fovy: 45 23 | ) 24 | camera.setCameraMode Orbital 25 | 26 | # ==Main code== 27 | while not windowShouldClose(): 28 | camera.addr.updateCamera 29 | beginDrawing() 30 | label (x: 10.0, y: 0.0, width: 100.0, height: 25.0), "by V.A. Guevara" 31 | clearBackground(Black) 32 | beginMode3D(camera) 33 | drawGrid 10, 1.0 34 | drawSphere (0.0, 0.0, 0.0), 0.5, Red 35 | endMode3D() 36 | let 37 | slogan = "/Hello from Nim/" 38 | size = 20 39 | width = measureText(slogan, size) 40 | slogan.drawText( 41 | (getScreenWidth() - width) div 2, 42 | getScreenHeight() div 2 - 100, 43 | size, 44 | LightGray 45 | ) 46 | drawRectangleV( 47 | (x: 10.0, y: 10.0), 48 | (x: (getScreenWidth() - 20).float, y: (getScreenHeight() - 20).float), 49 | (r: 255, g: 0, b: 0, a: 20) 50 | ) 51 | endDrawing() 52 | -------------------------------------------------------------------------------- /tests/examples/t_core_basic_window.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | joinable: false 4 | matrix: "; -d:release; --gc:orc -d:release" 5 | """ 6 | 7 | # ****************************************************************************************** 8 | # 9 | # raylib [core] example - Basic window 10 | # 11 | # Welcome to raylib! 12 | # 13 | # To test examples, just press F6 and execute raylib_compile_execute script 14 | # Note that compiled executable is placed in the same folder as .c file 15 | # 16 | # You can find all basic examples on C:\raylib\raylib\examples folder or 17 | # raylib official webpage: www.raylib.com 18 | # 19 | # Enjoy using raylib. :) 20 | # 21 | # This example has been created using raylib 1.0 (www.raylib.com) 22 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 23 | # 24 | # Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) 25 | # Converted in 2021 by greenfork 26 | # 27 | # ****************************************************************************************** 28 | 29 | import ../../src/nimraylib_now 30 | 31 | ## Initialization 32 | ## -------------------------------------------------------------------------------------- 33 | var screenWidth: int32 = 800 34 | var screenHeight: int32 = 450 35 | initWindow(screenWidth, screenHeight, "raylib [core] example - basic window") 36 | setTargetFPS(60) 37 | ## Set our game to run at 60 frames-per-second 38 | ## -------------------------------------------------------------------------------------- 39 | ## Main game loop 40 | while not windowShouldClose(): ## Detect window close button or ESC key 41 | ## Update 42 | ## ---------------------------------------------------------------------------------- 43 | ## TODO: Update your variables here 44 | ## ---------------------------------------------------------------------------------- 45 | ## Draw 46 | ## ---------------------------------------------------------------------------------- 47 | beginDrawing() 48 | clearBackground(Raywhite) 49 | drawText("Congrats! You created your first window!", 190, 200, 20, Lightgray) 50 | endDrawing() 51 | ## ---------------------------------------------------------------------------------- 52 | ## De-Initialization 53 | ## -------------------------------------------------------------------------------------- 54 | closeWindow() 55 | ## Close window and OpenGL context 56 | ## -------------------------------------------------------------------------------------- 57 | -------------------------------------------------------------------------------- /tests/examples/t_core_input_keys.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | joinable: false 4 | matrix: "; -d:release; --gc:orc -d:release" 5 | """ 6 | 7 | #******************************************************************************************* 8 | # 9 | # raylib [core] example - Keyboard input 10 | # 11 | # This example has been created using raylib 1.0 (www.raylib.com) 12 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 13 | # 14 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 15 | # /Converted in 2*20 by Guevara-chan. 16 | # Adapted in 2021 by greenfork 17 | # 18 | #******************************************************************************************* 19 | 20 | import ../../src/nimraylib_now 21 | # Initialization 22 | #-------------------------------------------------------------------------------------- 23 | const screenWidth = 800 24 | const screenHeight = 450 25 | 26 | initWindow screenWidth, screenHeight, "raylib [core] example - keyboard input" 27 | 28 | var ballPosition: Vector2 = (x: screenWidth/2, y: screenHeight/2) 29 | 30 | 60.setTargetFPS # Set our game to run at 60 frames-per-second 31 | #-------------------------------------------------------------------------------------- 32 | 33 | # Main game loop 34 | while not windowShouldClose(): # Detect window close button or ESC key 35 | # Update 36 | # ---------------------------------------------------------------------------------- 37 | if isKeyDown(KeyboardKey.Right): ballPosition.x += 2.0 38 | if isKeyDown(KeyboardKey.Left): ballPosition.x -= 2.0 39 | if isKeyDown(Up): ballPosition.y -= 2.0 40 | if isKeyDown(Down): ballPosition.y += 2.0 41 | # ---------------------------------------------------------------------------------- 42 | 43 | # Draw 44 | # ---------------------------------------------------------------------------------- 45 | beginDrawing() 46 | clearBackground RAYWHITE 47 | 48 | drawText "move the ball with arrow keys", 10, 10, 20, DARKGRAY 49 | 50 | drawCircleV ballPosition, 50, MAROON 51 | 52 | endDrawing() 53 | # ---------------------------------------------------------------------------------- 54 | # De-Initialization 55 | # -------------------------------------------------------------------------------------- 56 | closeWindow() # Close window and OpenGL context 57 | # -------------------------------------------------------------------------------------- 58 | -------------------------------------------------------------------------------- /tests/examples/t_core_input_mouse.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | joinable: false 4 | matrix: "; -d:release; --gc:orc -d:release" 5 | """ 6 | 7 | # ****************************************************************************************** 8 | # 9 | # raylib [core] example - Mouse input 10 | # 11 | # This example has been created using raylib 1.0 (www.raylib.com) 12 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 13 | # 14 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 15 | # Converted in 2021 by greenfork 16 | # 17 | # ****************************************************************************************** 18 | 19 | import ../../src/nimraylib_now 20 | 21 | ## Initialization 22 | ## -------------------------------------------------------------------------------------- 23 | var screenWidth: int32 = 800 24 | var screenHeight: int32 = 450 25 | initWindow(screenWidth, screenHeight, "raylib [core] example - mouse input") 26 | var ballPosition: Vector2 = (-100.0, -100.0) 27 | var ballColor: Color = Darkblue 28 | setTargetFPS(60) 29 | ## Set our game to run at 60 frames-per-second 30 | ## --------------------------------------------------------------------------------------- 31 | ## Main game loop 32 | while not windowShouldClose(): ## Detect window close button or ESC key 33 | ## Update 34 | ## ---------------------------------------------------------------------------------- 35 | ballPosition = getMousePosition() 36 | if isMouseButtonPressed(MouseButton.Left): 37 | ballColor = Maroon 38 | elif isMouseButtonPressed(MouseButton.Middle): 39 | ballColor = Lime 40 | elif isMouseButtonPressed(MouseButton.Right): 41 | ballColor = Darkblue 42 | ## ---------------------------------------------------------------------------------- 43 | ## Draw 44 | ## ---------------------------------------------------------------------------------- 45 | beginDrawing() 46 | clearBackground(Raywhite) 47 | drawCircleV(ballPosition, 40, ballColor) 48 | drawText("move ball with mouse and click mouse button to change color", 10, 49 | 10, 20, Darkgray) 50 | endDrawing() 51 | ## ---------------------------------------------------------------------------------- 52 | ## De-Initialization 53 | ## -------------------------------------------------------------------------------------- 54 | closeWindow() 55 | ## Close window and OpenGL context 56 | ## -------------------------------------------------------------------------------------- 57 | -------------------------------------------------------------------------------- /tests/examples/t_core_input_mouse_wheel.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | joinable: false 4 | matrix: "; -d:release; --gc:orc -d:release" 5 | """ 6 | 7 | # ****************************************************************************************** 8 | # 9 | # raylib [core] examples - Mouse wheel input 10 | # 11 | # This test has been created using raylib 1.1 (www.raylib.com) 12 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 13 | # 14 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 15 | # Converted in 2021 by greenfork 16 | # 17 | # ****************************************************************************************** 18 | 19 | import ../../src/nimraylib_now 20 | 21 | ## Initialization 22 | ## -------------------------------------------------------------------------------------- 23 | var screenWidth: int32 = 800 24 | var screenHeight: int32 = 450 25 | initWindow(screenWidth, screenHeight, 26 | "raylib [core] example - input mouse wheel") 27 | var boxPositionY: int32 = screenHeight div 2 - 40 28 | var scrollSpeed: int32 = 4 29 | ## Scrolling speed in pixels 30 | setTargetFPS(60) 31 | ## Set our game to run at 60 frames-per-second 32 | ## -------------------------------------------------------------------------------------- 33 | ## Main game loop 34 | while not windowShouldClose(): ## Detect window close button or ESC key 35 | ## Update 36 | ## ---------------------------------------------------------------------------------- 37 | inc(boxPositionY, (getMouseWheelMove().int32 * scrollSpeed)) 38 | ## ---------------------------------------------------------------------------------- 39 | ## Draw 40 | ## ---------------------------------------------------------------------------------- 41 | beginDrawing() 42 | clearBackground(Raywhite) 43 | drawRectangle(screenWidth div 2 - 40, boxPositionY, 80, 80, Maroon) 44 | drawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, Gray) 45 | drawText(textFormat("Box position Y: %03i", boxPositionY), 10, 40, 20, Lightgray) 46 | endDrawing() 47 | ## ---------------------------------------------------------------------------------- 48 | ## De-Initialization 49 | ## -------------------------------------------------------------------------------------- 50 | closeWindow() 51 | ## Close window and OpenGL context 52 | ## -------------------------------------------------------------------------------------- 53 | -------------------------------------------------------------------------------- /tests/examples/t_core_random_values.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | joinable: false 4 | matrix: "; -d:release; --gc:orc -d:release" 5 | """ 6 | 7 | # ****************************************************************************************** 8 | # 9 | # raylib [core] example - Generate random values 10 | # 11 | # This example has been created using raylib 1.1 (www.raylib.com) 12 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 13 | # 14 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 15 | # Converted in 2021 by greenfork 16 | # 17 | # ****************************************************************************************** 18 | 19 | import ../../src/nimraylib_now 20 | 21 | ## Initialization 22 | ## -------------------------------------------------------------------------------------- 23 | var screenWidth: int32 = 800 24 | var screenHeight: int32 = 450 25 | initWindow(screenWidth, screenHeight, 26 | "raylib [core] example - generate random values") 27 | var framesCounter: int32 = 0 ## Variable used to count frames 28 | var randValue: int32 = getRandomValue(-8, 5) ## Get a random integer number between -8 and 5 (both included) 29 | setTargetFPS(60) ## Set our game to run at 60 frames-per-second 30 | ## -------------------------------------------------------------------------------------- 31 | ## Main game loop 32 | while not windowShouldClose(): ## Detect window close button or ESC key 33 | ## Update 34 | ## ---------------------------------------------------------------------------------- 35 | inc(framesCounter) 36 | ## Every two seconds (120 frames) a new random value is generated 37 | if ((framesCounter div 120) mod 2) == 1: 38 | randValue = getRandomValue(-8, 5) 39 | framesCounter = 0 40 | beginDrawing() 41 | clearBackground(Raywhite) 42 | drawText("Every 2 seconds a new random value is generated:", 130, 100, 20, 43 | Maroon) 44 | drawText(textFormat("%i", randValue), 360, 180, 80, Lightgray) 45 | endDrawing() 46 | ## ---------------------------------------------------------------------------------- 47 | ## De-Initialization 48 | ## -------------------------------------------------------------------------------------- 49 | closeWindow() 50 | ## Close window and OpenGL context 51 | ## -------------------------------------------------------------------------------------- 52 | -------------------------------------------------------------------------------- /tests/examples/t_text_format_text.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | joinable: false 4 | matrix: "; -d:release; --gc:orc -d:release" 5 | """ 6 | 7 | #******************************************************************************************* 8 | # 9 | # raylib [text] example - Text formatting 10 | # 11 | # This example has been created using raylib 1.1 (www.raylib.com) 12 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 13 | # 14 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 15 | # /Converted in 2*20 by Guevara-chan. 16 | # Adapted in 2021 by greenfork 17 | # 18 | #******************************************************************************************* 19 | 20 | import ../../src/nimraylib_now 21 | 22 | # Initialization 23 | # -------------------------------------------------------------------------------------- 24 | const screenWidth = 800 25 | const screenHeight = 450 26 | 27 | initWindow screenWidth, screenHeight, "raylib [text] example - text formatting" 28 | 29 | let 30 | score = 100020 31 | hiscore = 200450 32 | lives = 5 33 | 34 | setTargetFPS(60) # Set our game to run at 60 frames-per-second 35 | # -------------------------------------------------------------------------------------- 36 | 37 | # Main game loop 38 | while not windowShouldClose(): # Detect window close button or ESC key 39 | # Update 40 | # ---------------------------------------------------------------------------------- 41 | # TODO: Update your variables here 42 | # ---------------------------------------------------------------------------------- 43 | 44 | # Draw 45 | # ---------------------------------------------------------------------------------- 46 | beginDrawing() 47 | 48 | clearBackground RAYWHITE 49 | 50 | drawText textFormat("Score: %08i", score), 200, 80, 20, RED 51 | 52 | drawText textFormat("HiScore: %08i", hiscore), 200, 120, 20, GREEN 53 | 54 | drawText textFormat("Lives: %02i", lives), 200, 160, 40, BLUE 55 | 56 | drawText textFormat("Elapsed Time: %02.02f ms", getFrameTime()*1000), 200, 220, 20, BLACK 57 | 58 | endDrawing() 59 | # ---------------------------------------------------------------------------------- 60 | 61 | # De-Initialization 62 | # -------------------------------------------------------------------------------------- 63 | closeWindow() # Close window and OpenGL context 64 | # -------------------------------------------------------------------------------------- 65 | -------------------------------------------------------------------------------- /tests/examples/t_textures_logo_raylib.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | joinable: false 4 | matrix: "; -d:release; --gc:orc -d:release" 5 | """ 6 | 7 | # ****************************************************************************************** 8 | # 9 | # raylib [textures] example - Texture loading and drawing 10 | # 11 | # This example has been created using raylib 1.0 (www.raylib.com) 12 | # raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 13 | # 14 | # Copyright (c) 2014 Ramon Santamaria (@raysan5) 15 | # Converted in 2021 by greenfork 16 | # 17 | # ****************************************************************************************** 18 | 19 | import ../../src/nimraylib_now 20 | 21 | 22 | ## Initialization 23 | ## -------------------------------------------------------------------------------------- 24 | var screenWidth = 800 25 | var screenHeight = 450 26 | initWindow(screenWidth, screenHeight, 27 | "raylib [textures] example - texture loading and drawing") 28 | ## NOTE: Textures MUST be loaded after Window initialization (OpenGL context is requiRed) 29 | var texture: Texture2D = loadTexture("resources/raylib_logo.png") 30 | ## Texture loading 31 | ## --------------------------------------------------------------------------------------- 32 | ## Main game loop 33 | while not windowShouldClose(): ## Detect window close button or ESC key 34 | ## Update 35 | ## ---------------------------------------------------------------------------------- 36 | ## TODO: Update your variables here 37 | ## ---------------------------------------------------------------------------------- 38 | ## Draw 39 | ## ---------------------------------------------------------------------------------- 40 | beginDrawing() 41 | clearBackground(Raywhite) 42 | drawTexture(texture, screenWidth div 2 - texture.width div 2, 43 | screenHeight div 2 - texture.height div 2, White) 44 | drawText("this IS a texture!", 360, 370, 10, Gray) 45 | endDrawing() 46 | ## ---------------------------------------------------------------------------------- 47 | ## De-Initialization 48 | ## -------------------------------------------------------------------------------------- 49 | unloadTexture(texture) 50 | ## Texture unloading 51 | closeWindow() 52 | ## Close window and OpenGL context 53 | ## -------------------------------------------------------------------------------------- 54 | -------------------------------------------------------------------------------- /tests/nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on 2 | --------------------------------------------------------------------------------