├── .github
└── workflows
│ └── build.yml
├── .gitignore
├── LICENSE
├── README.md
├── easings
├── README.md
├── easings.go
└── go.mod
├── examples
├── README.md
├── audio
│ ├── mixed_processor
│ │ ├── coin.wav
│ │ ├── country.mp3
│ │ └── main.go
│ ├── module_playing
│ │ ├── main.go
│ │ └── mini1111.xm
│ ├── music_stream
│ │ ├── guitar_noodling.ogg
│ │ └── main.go
│ ├── raw_stream
│ │ └── main.go
│ ├── sound_loading
│ │ ├── main.go
│ │ ├── tanatana.ogg
│ │ └── weird.wav
│ └── sound_multi
│ │ ├── main.go
│ │ └── sound.wav
├── core
│ ├── 2d_camera
│ │ └── main.go
│ ├── 2d_camera_mouse_zoom
│ │ └── main.go
│ ├── 2d_camera_platformer
│ │ └── main.go
│ ├── 2d_camera_splitscreen
│ │ └── main.go
│ ├── 2d_paint
│ │ └── main.go
│ ├── 3d_camera_first_person
│ │ └── main.go
│ ├── 3d_camera_free
│ │ └── main.go
│ ├── 3d_camera_splitscreen
│ │ └── main.go
│ ├── 3d_mode
│ │ └── main.go
│ ├── 3d_picking
│ │ └── main.go
│ ├── basic_window
│ │ └── main.go
│ ├── basic_window_manager
│ │ └── main.go
│ ├── color_select
│ │ └── main.go
│ ├── core_split_screen
│ │ └── main.go
│ ├── custom_frame_control
│ │ └── main.go
│ ├── custom_logging
│ │ └── main.go
│ ├── drop_files
│ │ └── main.go
│ ├── gestures_detection
│ │ └── main.go
│ ├── input_gamepad
│ │ ├── main.go
│ │ ├── ps3.png
│ │ └── xbox.png
│ ├── input_keys
│ │ └── main.go
│ ├── input_mouse
│ │ └── main.go
│ ├── mouse_wheel
│ │ └── main.go
│ ├── random_values
│ │ └── main.go
│ ├── scissor_test
│ │ └── main.go
│ ├── smooth_pixelperfect
│ │ └── main.go
│ ├── storage_values
│ │ └── main.go
│ ├── vr_simulator
│ │ ├── distortion100.fs
│ │ ├── distortion330.fs
│ │ └── main.go
│ ├── window_flags
│ │ └── main.go
│ ├── window_letterbox
│ │ └── main.go
│ ├── window_should_close
│ │ └── main.go
│ └── world_screen
│ │ └── main.go
├── easings
│ └── easings
│ │ ├── easings.gif
│ │ └── main.go
├── games
│ ├── arkanoid
│ │ └── main.go
│ ├── floppy
│ │ ├── README.md
│ │ ├── images
│ │ │ ├── README
│ │ │ ├── clouds.png
│ │ │ ├── smoke.png
│ │ │ └── sprite.png
│ │ ├── main.go
│ │ └── sounds
│ │ │ ├── click.wav
│ │ │ ├── flap.wav
│ │ │ ├── point.wav
│ │ │ └── slap.wav
│ ├── life
│ │ └── main.go
│ ├── pong
│ │ └── main.go
│ └── snake
│ │ └── main.go
├── go.mod
├── go.sum
├── gui
│ ├── button
│ │ └── main.go
│ ├── controls_test_suite
│ │ ├── controls_test_suite.go
│ │ └── controls_test_suite.png
│ ├── icons
│ │ ├── README.md
│ │ ├── default_icons_with_255.rgi
│ │ ├── main.go
│ │ └── screenshot.png
│ ├── portable_window
│ │ └── portable_window.go
│ └── scroll_panel
│ │ ├── scroll_panel.go
│ │ └── scroll_panel.png
├── models
│ ├── animation
│ │ ├── guy.iqm
│ │ ├── guyanim.iqm
│ │ ├── guytex.png
│ │ └── main.go
│ ├── billboard
│ │ ├── billboard.png
│ │ └── main.go
│ ├── box_collisions
│ │ └── main.go
│ ├── cubicmap
│ │ ├── cubicmap.png
│ │ ├── cubicmap_atlas.png
│ │ └── main.go
│ ├── draw_cube_texture
│ │ ├── cubicmap_atlas.png
│ │ └── main.go
│ ├── first_person_maze
│ │ ├── cubicmap.png
│ │ ├── cubicmap_atlas.png
│ │ └── main.go
│ ├── geometric_shapes
│ │ └── main.go
│ ├── gltf_loading
│ │ ├── main.go
│ │ └── robot.glb
│ ├── heightmap
│ │ ├── heightmap.png
│ │ └── main.go
│ ├── m3d_loading
│ │ ├── cesium_man.m3d
│ │ └── main.go
│ ├── mesh_generation
│ │ └── main.go
│ ├── mesh_picking
│ │ ├── main.go
│ │ ├── turret.obj
│ │ └── turret_diffuse.png
│ ├── obj_loading
│ │ ├── castle.obj
│ │ ├── castle_diffuse.png
│ │ └── main.go
│ ├── orthographic
│ │ └── main.go
│ ├── rlgl_solar_system
│ │ └── main.go
│ ├── skybox
│ │ ├── main.go
│ │ ├── skybox.fs
│ │ ├── skybox.png
│ │ └── skybox.vs
│ ├── vox_loading
│ │ ├── knight.vox
│ │ ├── main.go
│ │ ├── monument.vox
│ │ └── sword.vox
│ ├── waving_cubes
│ │ └── main.go
│ └── yaw_pitch_roll
│ │ ├── main.go
│ │ ├── plane.obj
│ │ └── plane_diffuse.png
├── others
│ ├── android
│ │ └── example
│ │ │ ├── README.md
│ │ │ ├── android
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── assets
│ │ │ │ ├── alagard.rbmf
│ │ │ │ ├── ambient.ogg
│ │ │ │ ├── coin.wav
│ │ │ │ └── raylib_logo.png
│ │ │ ├── build.gradle
│ │ │ └── res
│ │ │ │ ├── drawable-hdpi
│ │ │ │ └── icon.png
│ │ │ │ ├── drawable-ldpi
│ │ │ │ └── icon.png
│ │ │ │ ├── drawable-mdpi
│ │ │ │ └── icon.png
│ │ │ │ └── values
│ │ │ │ └── strings.xml
│ │ │ ├── androidcompile.bat
│ │ │ ├── build.gradle
│ │ │ ├── gradle
│ │ │ └── wrapper
│ │ │ │ ├── gradle-wrapper.jar
│ │ │ │ └── gradle-wrapper.properties
│ │ │ ├── gradlew
│ │ │ ├── gradlew.bat
│ │ │ ├── main.go
│ │ │ └── settings.gradle
│ ├── bunnymark
│ │ ├── main.go
│ │ └── wabbit_alpha.png
│ └── utils
│ │ └── utils.go
├── physics
│ ├── box2d
│ │ └── main.go
│ ├── chipmunk
│ │ └── main.go
│ └── physac
│ │ ├── demo
│ │ └── main.go
│ │ ├── friction
│ │ └── main.go
│ │ ├── movement
│ │ └── main.go
│ │ ├── restitution
│ │ └── main.go
│ │ └── shatter
│ │ └── main.go
├── shaders
│ ├── basic_lighting
│ │ ├── light.go
│ │ ├── lighting.fs
│ │ ├── lighting.vs
│ │ └── main.go
│ ├── custom_uniform
│ │ ├── barracks.obj
│ │ ├── barracks_diffuse.png
│ │ ├── glsl330
│ │ │ ├── base.vs
│ │ │ └── swirl.fs
│ │ └── main.go
│ ├── eratosthenes
│ │ ├── eratosthenes.fs
│ │ └── main.go
│ ├── mesh_instancing
│ │ ├── glsl330
│ │ │ ├── base_lighting_instanced.vs
│ │ │ └── lighting.fs
│ │ ├── light.go
│ │ └── main.go
│ ├── model_shader
│ │ ├── dwarf.obj
│ │ ├── dwarf_diffuse.png
│ │ ├── glsl330
│ │ │ ├── base.vs
│ │ │ └── grayscale.fs
│ │ └── main.go
│ ├── multi_sample2d
│ │ ├── color_mix.fs
│ │ └── main.go
│ ├── pbr
│ │ ├── glsl330
│ │ │ ├── pbr.fs
│ │ │ └── pbr.vs
│ │ ├── light.go
│ │ ├── main.go
│ │ ├── models
│ │ │ ├── old_car_d.png
│ │ │ ├── old_car_e.png
│ │ │ ├── old_car_mra.png
│ │ │ ├── old_car_n.png
│ │ │ ├── old_car_new.glb
│ │ │ ├── plane.glb
│ │ │ ├── road_a.png
│ │ │ ├── road_mra.png
│ │ │ └── road_n.png
│ │ └── pbr.go
│ ├── postprocessing
│ │ ├── church.obj
│ │ ├── church_diffuse.png
│ │ ├── glsl330
│ │ │ ├── bloom.fs
│ │ │ ├── blur.fs
│ │ │ ├── cross_hatching.fs
│ │ │ ├── cross_stitching.fs
│ │ │ ├── dream_vision.fs
│ │ │ ├── fisheye.fs
│ │ │ ├── grayscale.fs
│ │ │ ├── pixelizer.fs
│ │ │ ├── posterization.fs
│ │ │ ├── predator.fs
│ │ │ ├── scanlines.fs
│ │ │ └── sobel.fs
│ │ └── main.go
│ ├── raymarching
│ │ ├── main.go
│ │ └── raymarching.fs
│ ├── shapes_textures
│ │ ├── fudesumi.png
│ │ ├── glsl330
│ │ │ ├── base.vs
│ │ │ └── grayscale.fs
│ │ └── main.go
│ ├── texture_drawing
│ │ ├── cubes_panning.fs
│ │ └── main.go
│ ├── texture_outline
│ │ ├── gopher.png
│ │ ├── main.go
│ │ └── outline.fs
│ ├── texture_tiling
│ │ ├── cubicmap_atlas.png
│ │ ├── main.go
│ │ └── tiling.fs
│ ├── texture_waves
│ │ ├── main.go
│ │ ├── space.png
│ │ └── wave.fs
│ └── vertex_displacement
│ │ ├── glsl100
│ │ ├── vertex_displacement.fs
│ │ └── vertex_displacement.vs
│ │ ├── glsl330
│ │ ├── vertex_displacement.fs
│ │ └── vertex_displacement.vs
│ │ └── main.go
├── shapes
│ ├── basic_shapes
│ │ └── main.go
│ ├── bouncing_ball
│ │ └── main.go
│ ├── collision_area
│ │ └── main.go
│ ├── colors_pallete
│ │ └── main.go
│ ├── draw_circle_sector
│ │ └── main.go
│ ├── draw_ring
│ │ └── main.go
│ ├── easings_ball_anim
│ │ └── main.go
│ ├── easings_box_anim
│ │ └── main.go
│ ├── easings_rectangle_array
│ │ └── main.go
│ ├── following_eyes
│ │ └── main.go
│ ├── lines_bezier
│ │ └── main.go
│ ├── logo_raylib
│ │ └── main.go
│ ├── logo_raylib_anim
│ │ └── main.go
│ └── rectangle_scaling
│ │ └── main.go
├── text
│ ├── bmfont_ttf
│ │ ├── fonts
│ │ │ ├── bmfont.fnt
│ │ │ ├── bmfont.png
│ │ │ └── pixantiqua.ttf
│ │ └── main.go
│ ├── bmfont_unordered
│ │ ├── fonts
│ │ │ ├── pixantiqua.fnt
│ │ │ └── pixantiqua_0.png
│ │ └── main.go
│ ├── codepoints_loading
│ │ ├── DotGothic16-Regular.ttf
│ │ └── main.go
│ ├── draw_3d
│ │ ├── alpha_discard.fs
│ │ └── main.go
│ ├── font_filters
│ │ ├── KAISG.ttf
│ │ └── main.go
│ ├── font_loading
│ │ ├── main.go
│ │ ├── pixantiqua.fnt
│ │ ├── pixantiqua.png
│ │ └── pixantiqua.ttf
│ ├── font_sdf
│ │ ├── AnonymousPro-Bold.ttf
│ │ ├── OFL.txt
│ │ ├── main.go
│ │ └── sdf.fs
│ ├── format_text
│ │ └── main.go
│ ├── input_box
│ │ └── main.go
│ ├── raylib_fonts
│ │ ├── fonts
│ │ │ ├── alagard.png
│ │ │ ├── alpha_beta.png
│ │ │ ├── jupiter_crash.png
│ │ │ ├── mecha.png
│ │ │ ├── pixantiqua.png
│ │ │ ├── pixelplay.png
│ │ │ ├── romulus.png
│ │ │ └── setback.png
│ │ └── main.go
│ ├── rectangle_bounds
│ │ └── main.go
│ ├── sprite_fonts
│ │ ├── fonts
│ │ │ ├── custom_alagard.png
│ │ │ ├── custom_jupiter_crash.png
│ │ │ └── custom_mecha.png
│ │ └── main.go
│ ├── ttf_loading
│ │ ├── fonts
│ │ │ └── KAISG.ttf
│ │ └── main.go
│ ├── unicode
│ │ ├── main.go
│ │ ├── resources
│ │ │ ├── dejavu.fnt
│ │ │ ├── dejavu.png
│ │ │ ├── noto_cjk.fnt
│ │ │ ├── noto_cjk.png
│ │ │ ├── symbola.fnt
│ │ │ └── symbola.png
│ │ └── unicode.go
│ └── writing_anim
│ │ └── main.go
└── textures
│ ├── background_scrolling
│ ├── cyberpunk_street_background.png
│ ├── cyberpunk_street_foreground.png
│ ├── cyberpunk_street_midground.png
│ └── main.go
│ ├── blend_modes
│ ├── cyberpunk_street_background.png
│ ├── cyberpunk_street_foreground.png
│ └── main.go
│ ├── draw_tiled
│ ├── main.go
│ └── patterns.png
│ ├── image_drawing
│ ├── cat.png
│ ├── main.go
│ └── parrots.png
│ ├── image_generation
│ └── main.go
│ ├── image_image
│ ├── main.go
│ └── raylib_logo.png
│ ├── image_loading
│ ├── main.go
│ └── raylib_logo.png
│ ├── image_processing
│ ├── main.go
│ └── parrots.png
│ ├── image_text
│ ├── fonts
│ │ └── KAISG.ttf
│ ├── main.go
│ └── parrots.png
│ ├── logo_raylib
│ ├── main.go
│ └── raylib_logo.png
│ ├── mouse_painting
│ └── main.go
│ ├── npatch_drawing
│ ├── main.go
│ └── ninepatch_button.png
│ ├── particles_blending
│ ├── main.go
│ └── smoke.png
│ ├── raw_data
│ ├── main.go
│ └── texture_formats
│ │ └── fudesumi.raw
│ ├── sprite_button
│ ├── button.png
│ ├── buttonfx.wav
│ └── main.go
│ ├── sprite_explosion
│ ├── boom.wav
│ ├── explosion.png
│ └── main.go
│ ├── srcrec_dstrec
│ ├── main.go
│ └── scarfy.png
│ ├── textured_curve
│ ├── main.go
│ └── road.png
│ ├── textures_gif_player
│ ├── main.go
│ └── scarfy_run.gif
│ ├── textures_sprite_anim
│ ├── main.go
│ └── scarfy.png
│ └── to_image
│ ├── main.go
│ └── raylib_logo.png
├── physics
├── README.md
├── go.mod
├── go.sum
└── physics.go
├── raygui
├── README.md
├── cgo.go
├── cstring.go
├── go.mod
├── go.sum
├── raygui.go
├── raygui.h
└── raylib.h
├── raylib
├── cgo.go
├── cgo_android.go
├── cgo_darwin.go
├── cgo_darwin_rgfw.go
├── cgo_darwin_sdl.go
├── cgo_freebsd.go
├── cgo_freebsd_rgfw.go
├── cgo_freebsd_sdl.go
├── cgo_linux.go
├── cgo_linux_drm.go
├── cgo_linux_rgfw.go
├── cgo_linux_sdl.go
├── cgo_openbsd.go
├── cgo_openbsd_rgfw.go
├── cgo_openbsd_sdl.go
├── cgo_vendor.go
├── cgo_windows.go
├── cgo_windows_rgfw.go
├── cgo_windows_sdl.go
├── compat.go
├── compat_compat.go
├── config.h
├── external
│ ├── RGFW.h
│ ├── android
│ │ └── native_app_glue
│ │ │ ├── NOTICE
│ │ │ ├── android_native_app_glue.c
│ │ │ ├── android_native_app_glue.h
│ │ │ └── vendor.go
│ ├── cgltf.h
│ ├── dirent.h
│ ├── dr_flac.h
│ ├── dr_mp3.h
│ ├── dr_wav.h
│ ├── glad.h
│ ├── glad_gles2.h
│ ├── glfw
│ │ ├── LICENSE.md
│ │ ├── include
│ │ │ └── GLFW
│ │ │ │ ├── glfw3.h
│ │ │ │ ├── glfw3native.h
│ │ │ │ └── vendor.go
│ │ └── src
│ │ │ ├── cocoa_init.m
│ │ │ ├── cocoa_joystick.h
│ │ │ ├── cocoa_joystick.m
│ │ │ ├── cocoa_monitor.m
│ │ │ ├── cocoa_platform.h
│ │ │ ├── cocoa_time.c
│ │ │ ├── cocoa_time.h
│ │ │ ├── cocoa_window.m
│ │ │ ├── context.c
│ │ │ ├── egl_context.c
│ │ │ ├── fractional-scale-v1-client-protocol-code.h
│ │ │ ├── fractional-scale-v1-client-protocol.h
│ │ │ ├── glx_context.c
│ │ │ ├── idle-inhibit-unstable-v1-client-protocol-code.h
│ │ │ ├── idle-inhibit-unstable-v1-client-protocol.h
│ │ │ ├── init.c
│ │ │ ├── input.c
│ │ │ ├── internal.h
│ │ │ ├── linux_joystick.c
│ │ │ ├── linux_joystick.h
│ │ │ ├── mappings.h
│ │ │ ├── mappings.h.in
│ │ │ ├── monitor.c
│ │ │ ├── nsgl_context.m
│ │ │ ├── null_init.c
│ │ │ ├── null_joystick.c
│ │ │ ├── null_joystick.h
│ │ │ ├── null_monitor.c
│ │ │ ├── null_platform.h
│ │ │ ├── null_window.c
│ │ │ ├── osmesa_context.c
│ │ │ ├── platform.c
│ │ │ ├── platform.h
│ │ │ ├── pointer-constraints-unstable-v1-client-protocol-code.h
│ │ │ ├── pointer-constraints-unstable-v1-client-protocol.h
│ │ │ ├── posix_module.c
│ │ │ ├── posix_poll.c
│ │ │ ├── posix_poll.h
│ │ │ ├── posix_thread.c
│ │ │ ├── posix_thread.h
│ │ │ ├── posix_time.c
│ │ │ ├── posix_time.h
│ │ │ ├── relative-pointer-unstable-v1-client-protocol-code.h
│ │ │ ├── relative-pointer-unstable-v1-client-protocol.h
│ │ │ ├── vendor.go
│ │ │ ├── viewporter-client-protocol-code.h
│ │ │ ├── viewporter-client-protocol.h
│ │ │ ├── vulkan.c
│ │ │ ├── wayland-client-protocol-code.h
│ │ │ ├── wayland-client-protocol.h
│ │ │ ├── wgl_context.c
│ │ │ ├── win32_init.c
│ │ │ ├── win32_joystick.c
│ │ │ ├── win32_joystick.h
│ │ │ ├── win32_module.c
│ │ │ ├── win32_monitor.c
│ │ │ ├── win32_platform.h
│ │ │ ├── win32_thread.c
│ │ │ ├── win32_thread.h
│ │ │ ├── win32_time.c
│ │ │ ├── win32_time.h
│ │ │ ├── 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
│ │ │ ├── xdg-activation-v1-client-protocol-code.h
│ │ │ ├── xdg-activation-v1-client-protocol.h
│ │ │ ├── xdg-decoration-unstable-v1-client-protocol-code.h
│ │ │ ├── xdg-decoration-unstable-v1-client-protocol.h
│ │ │ ├── xdg-shell-client-protocol-code.h
│ │ │ ├── xdg-shell-client-protocol.h
│ │ │ ├── xkb_unicode.c
│ │ │ └── xkb_unicode.h
│ ├── jar_mod.h
│ ├── jar_xm.h
│ ├── m3d.h
│ ├── miniaudio.h
│ ├── msf_gif.h
│ ├── par_shapes.h
│ ├── qoa.h
│ ├── qoaplay.c
│ ├── qoi.h
│ ├── rl_gputex.h
│ ├── rprand.h
│ ├── scripts
│ │ └── glfw-generate-wayland.sh
│ ├── sdefl.h
│ ├── sinfl.h
│ ├── stb_image.h
│ ├── stb_image_resize2.h
│ ├── stb_image_write.h
│ ├── stb_perlin.h
│ ├── stb_rect_pack.h
│ ├── stb_truetype.h
│ ├── stb_vorbis.c
│ ├── tinyobj_loader_c.h
│ ├── vendor.go
│ ├── vox_loader.h
│ └── win32_clipboard.h
├── go.mod
├── go.sum
├── platform_android.go
├── platform_desktop.go
├── platform_desktop_rgfw.go
├── platform_desktop_sdl.go
├── platform_drm.go
├── platforms
│ ├── rcore_android.c
│ ├── rcore_desktop_glfw.c
│ ├── rcore_desktop_rgfw.c
│ ├── rcore_desktop_sdl.c
│ ├── rcore_drm.c
│ └── vendor.go
├── purego_windows.go
├── raudio.c
├── raudio.go
├── raylib.go
├── raylib.h
├── raylib_purego.go
├── raymath.go
├── raymath.h
├── rcamera.go
├── rcamera.h
├── rcore.c
├── rcore.go
├── rgestures.go
├── rgestures.h
├── rlgl.go
├── rlgl.h
├── rlgl_cgo.go
├── rlgl_purego.go
├── rmodels.c
├── rmodels.go
├── rshapes.c
├── rshapes.go
├── rtext.c
├── rtext.go
├── rtextures.c
├── rtextures.go
├── utils.c
├── utils.go
├── utils.h
├── utils_android.go
├── utils_log.c
├── utils_log.go
└── utils_log.h
└── rres
├── README.md
├── cgo.go
├── external
├── aes.c
├── aes.h
├── lz4.c
├── lz4.h
├── monocypher.c
├── monocypher.h
├── qoi.h
└── vendor.go
├── go.mod
├── go.sum
├── raylib.h
├── rres-raylib.go
├── rres-raylib.h
├── rres.go
├── rres.h
└── vendor.go
/.gitignore:
--------------------------------------------------------------------------------
1 | # IDE folders
2 | .idea
3 | .vsc
4 | .vs
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2016 Milan Nikolic (gen2brain)
2 |
3 | This software is provided 'as-is', without any express or implied
4 | warranty. In no event will the authors be held liable for any damages
5 | arising from the use of this software.
6 |
7 | Permission is granted to anyone to use this software for any purpose,
8 | including commercial applications, and to alter it and redistribute it
9 | freely, subject to the following restrictions:
10 |
11 | 1. The origin of this software must not be misrepresented; you must not
12 | claim that you wrote the original software. If you use this software
13 | in a product, an acknowledgment in the product documentation would be
14 | appreciated but is not required.
15 | 2. Altered source versions must be plainly marked as such, and must not be
16 | misrepresented as being the original software.
17 | 3. This notice may not be removed or altered from any source distribution.
18 |
--------------------------------------------------------------------------------
/easings/README.md:
--------------------------------------------------------------------------------
1 | ## easings [](https://godoc.org/github.com/gen2brain/raylib-go/easings)
2 |
3 | Useful easing functions for values animation.
4 |
5 | A port of Robert Penner's [easing equations](http://robertpenner.com/easing/).
6 |
7 | 
8 |
--------------------------------------------------------------------------------
/easings/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/gen2brain/raylib-go/easings
2 |
3 | go 1.21
4 |
--------------------------------------------------------------------------------
/examples/README.md:
--------------------------------------------------------------------------------
1 | ## Examples
2 |
3 | Live (web/emscripten) examples are available on [raylib website](http://www.raylib.com/examples.html).
4 |
--------------------------------------------------------------------------------
/examples/audio/mixed_processor/coin.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/audio/mixed_processor/coin.wav
--------------------------------------------------------------------------------
/examples/audio/mixed_processor/country.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/audio/mixed_processor/country.mp3
--------------------------------------------------------------------------------
/examples/audio/module_playing/mini1111.xm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/audio/module_playing/mini1111.xm
--------------------------------------------------------------------------------
/examples/audio/music_stream/guitar_noodling.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/audio/music_stream/guitar_noodling.ogg
--------------------------------------------------------------------------------
/examples/audio/music_stream/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | rl.InitWindow(800, 450, "raylib [audio] example - music playing (streaming)")
9 | rl.InitAudioDevice()
10 |
11 | music := rl.LoadMusicStream("guitar_noodling.ogg")
12 | pause := false
13 |
14 | rl.PlayMusicStream(music)
15 |
16 | rl.SetTargetFPS(60)
17 |
18 | for !rl.WindowShouldClose() {
19 | rl.UpdateMusicStream(music) // Update music buffer with new stream data
20 |
21 | // Restart music playing (stop and play)
22 | if rl.IsKeyPressed(rl.KeySpace) {
23 | rl.StopMusicStream(music)
24 | rl.PlayMusicStream(music)
25 | }
26 |
27 | // Pause/Resume music playing
28 | if rl.IsKeyPressed(rl.KeyP) {
29 | pause = !pause
30 |
31 | if pause {
32 | rl.PauseMusicStream(music)
33 | } else {
34 | rl.ResumeMusicStream(music)
35 | }
36 | }
37 |
38 | // Get timePlayed scaled to bar dimensions (400 pixels)
39 | timePlayed := rl.GetMusicTimePlayed(music) / rl.GetMusicTimeLength(music) * 100 * 4
40 |
41 | rl.BeginDrawing()
42 |
43 | rl.ClearBackground(rl.RayWhite)
44 | rl.DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, rl.LightGray)
45 |
46 | rl.DrawRectangle(200, 200, 400, 12, rl.LightGray)
47 | rl.DrawRectangle(200, 200, int32(timePlayed), 12, rl.Maroon)
48 | rl.DrawRectangleLines(200, 200, 400, 12, rl.Gray)
49 |
50 | rl.DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, rl.LightGray)
51 | rl.DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, rl.LightGray)
52 |
53 | rl.EndDrawing()
54 | }
55 |
56 | rl.UnloadMusicStream(music) // Unload music stream buffers from RAM
57 | rl.CloseAudioDevice() // Close audio device (music streaming is automatically stopped)
58 |
59 | rl.CloseWindow()
60 | }
61 |
--------------------------------------------------------------------------------
/examples/audio/sound_loading/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | rl.InitWindow(800, 450, "raylib [audio] example - sound loading and playing")
9 |
10 | rl.InitAudioDevice()
11 |
12 | fxWav := rl.LoadSound("weird.wav")
13 | fxOgg := rl.LoadSound("tanatana.ogg")
14 |
15 | rl.SetTargetFPS(60)
16 |
17 | for !rl.WindowShouldClose() {
18 | if rl.IsKeyPressed(rl.KeySpace) {
19 | rl.PlaySound(fxWav)
20 | }
21 | if rl.IsKeyPressed(rl.KeyEnter) {
22 | rl.PlaySound(fxOgg)
23 | }
24 |
25 | rl.BeginDrawing()
26 |
27 | rl.ClearBackground(rl.RayWhite)
28 |
29 | rl.DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, rl.LightGray)
30 | rl.DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, rl.LightGray)
31 |
32 | rl.EndDrawing()
33 | }
34 |
35 | rl.UnloadSound(fxWav)
36 | rl.UnloadSound(fxOgg)
37 |
38 | rl.CloseAudioDevice()
39 |
40 | rl.CloseWindow()
41 | }
42 |
--------------------------------------------------------------------------------
/examples/audio/sound_loading/tanatana.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/audio/sound_loading/tanatana.ogg
--------------------------------------------------------------------------------
/examples/audio/sound_loading/weird.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/audio/sound_loading/weird.wav
--------------------------------------------------------------------------------
/examples/audio/sound_multi/sound.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/audio/sound_multi/sound.wav
--------------------------------------------------------------------------------
/examples/core/3d_camera_free/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | rl.InitWindow(800, 450, "raylib [core] example - 3d camera free")
9 |
10 | camera := rl.Camera3D{}
11 | camera.Position = rl.NewVector3(10.0, 10.0, 10.0)
12 | camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
13 | camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
14 | camera.Fovy = 45.0
15 | camera.Projection = rl.CameraPerspective
16 |
17 | cubePosition := rl.NewVector3(0.0, 0.0, 0.0)
18 |
19 | rl.SetTargetFPS(60)
20 |
21 | for !rl.WindowShouldClose() {
22 | rl.UpdateCamera(&camera, rl.CameraFree) // Update camera with free camera mode
23 |
24 | if rl.IsKeyDown(rl.KeyZ) {
25 | camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
26 | }
27 |
28 | rl.BeginDrawing()
29 |
30 | rl.ClearBackground(rl.RayWhite)
31 |
32 | rl.BeginMode3D(camera)
33 |
34 | rl.DrawCube(cubePosition, 2.0, 2.0, 2.0, rl.Red)
35 | rl.DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, rl.Maroon)
36 |
37 | rl.DrawGrid(10, 1.0)
38 |
39 | rl.EndMode3D()
40 |
41 | rl.DrawRectangle(10, 10, 320, 133, rl.Fade(rl.SkyBlue, 0.5))
42 | rl.DrawRectangleLines(10, 10, 320, 133, rl.Blue)
43 |
44 | rl.DrawText("Free camera default controls:", 20, 20, 10, rl.Black)
45 | rl.DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, rl.DarkGray)
46 | rl.DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, rl.DarkGray)
47 | rl.DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, rl.DarkGray)
48 |
49 | rl.EndDrawing()
50 | }
51 |
52 | rl.CloseWindow()
53 | }
54 |
--------------------------------------------------------------------------------
/examples/core/3d_mode/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | rl.InitWindow(800, 450, "raylib [core] example - 3d mode")
9 |
10 | camera := rl.Camera3D{}
11 | camera.Position = rl.NewVector3(0.0, 10.0, 10.0)
12 | camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
13 | camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
14 | camera.Fovy = 45.0
15 | camera.Projection = rl.CameraPerspective
16 |
17 | cubePosition := rl.NewVector3(0.0, 0.0, 0.0)
18 |
19 | rl.SetTargetFPS(60)
20 |
21 | for !rl.WindowShouldClose() {
22 | rl.BeginDrawing()
23 |
24 | rl.ClearBackground(rl.RayWhite)
25 |
26 | rl.BeginMode3D(camera)
27 |
28 | rl.DrawCube(cubePosition, 2.0, 2.0, 2.0, rl.Red)
29 | rl.DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, rl.Maroon)
30 |
31 | rl.DrawGrid(10, 1.0)
32 |
33 | rl.EndMode3D()
34 |
35 | rl.DrawText("Welcome to the third dimension!", 10, 40, 20, rl.DarkGray)
36 |
37 | rl.DrawFPS(10, 10)
38 |
39 | rl.EndDrawing()
40 | }
41 |
42 | rl.CloseWindow()
43 | }
44 |
--------------------------------------------------------------------------------
/examples/core/basic_window/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "github.com/gen2brain/raylib-go/raylib"
4 |
5 | func main() {
6 | rl.SetConfigFlags(rl.FlagVsyncHint)
7 | rl.InitWindow(800, 450, "raylib [core] example - basic window")
8 |
9 | //rl.SetTargetFPS(60)
10 |
11 | for !rl.WindowShouldClose() {
12 | rl.BeginDrawing()
13 |
14 | rl.ClearBackground(rl.RayWhite)
15 |
16 | rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LightGray)
17 |
18 | rl.EndDrawing()
19 | }
20 |
21 | rl.CloseWindow()
22 | }
23 |
--------------------------------------------------------------------------------
/examples/core/custom_logging/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "time"
6 |
7 | rl "github.com/gen2brain/raylib-go/raylib"
8 | )
9 |
10 | const (
11 | screenWidth = 800
12 | screenHeight = 450
13 | )
14 |
15 | func main() {
16 | // Set custom logger
17 | rl.SetTraceLogCallback(customLog)
18 |
19 | rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - Custom Logging")
20 |
21 | rl.SetTargetFPS(60)
22 |
23 | for !rl.WindowShouldClose() {
24 | rl.BeginDrawing()
25 | rl.ClearBackground(rl.RayWhite)
26 | rl.DrawText("Check the console output to see the custom logger in action!", 60, 200, 20, rl.LightGray)
27 | rl.EndDrawing()
28 | }
29 |
30 | rl.CloseWindow()
31 | }
32 |
33 | // Custom logging function
34 | func customLog(msgType int, text string) {
35 | now := time.Now()
36 |
37 | switch rl.TraceLogLevel(msgType) {
38 | case rl.LogInfo:
39 | fmt.Println("[INFO] : ", now, text)
40 | case rl.LogError:
41 | fmt.Println("[ERROR] : ", now, text)
42 | case rl.LogWarning:
43 | fmt.Println("[WARNING] : ", now, text)
44 | case rl.LogDebug:
45 | fmt.Println("[DEBUG] : ", now, text)
46 | default:
47 | fmt.Println("[UNKNOWN] : ", now, text)
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/examples/core/drop_files/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files")
12 |
13 | rl.SetTargetFPS(60)
14 |
15 | var count int
16 | var droppedFiles []string
17 |
18 | for !rl.WindowShouldClose() {
19 | if rl.IsFileDropped() {
20 | droppedFiles = rl.LoadDroppedFiles()
21 | count = len(droppedFiles)
22 | }
23 |
24 | rl.BeginDrawing()
25 |
26 | rl.ClearBackground(rl.RayWhite)
27 | if count == 0 {
28 | rl.DrawText("Drop your files to this window!", 100, 40, 20, rl.DarkGray)
29 | } else {
30 | rl.DrawText("Dropped files:", 100, 40, 20, rl.DarkGray)
31 |
32 | for i := 0; i < count; i++ {
33 | if i%2 == 0 {
34 | rl.DrawRectangle(0, int32(85+40*i), screenWidth, 40, rl.Fade(rl.LightGray, 0.5))
35 | } else {
36 | rl.DrawRectangle(0, int32(85+40*i), screenWidth, 40, rl.Fade(rl.LightGray, 0.3))
37 | }
38 |
39 | rl.DrawText(droppedFiles[i], 120, int32(100+i*40), 10, rl.Gray)
40 | }
41 |
42 | rl.DrawText("Drop new files...", 100, int32(150+count*40), 20, rl.DarkGray)
43 | }
44 |
45 | rl.EndDrawing()
46 | }
47 |
48 | rl.UnloadDroppedFiles()
49 |
50 | rl.CloseWindow()
51 | }
52 |
--------------------------------------------------------------------------------
/examples/core/input_gamepad/ps3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/core/input_gamepad/ps3.png
--------------------------------------------------------------------------------
/examples/core/input_gamepad/xbox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/core/input_gamepad/xbox.png
--------------------------------------------------------------------------------
/examples/core/input_keys/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input")
12 |
13 | ballPosition := rl.NewVector2(float32(screenWidth)/2, float32(screenHeight)/2)
14 |
15 | rl.SetTargetFPS(60)
16 |
17 | for !rl.WindowShouldClose() {
18 | if rl.IsKeyDown(rl.KeyRight) {
19 | ballPosition.X += 0.8
20 | }
21 | if rl.IsKeyDown(rl.KeyLeft) {
22 | ballPosition.X -= 0.8
23 | }
24 | if rl.IsKeyDown(rl.KeyUp) {
25 | ballPosition.Y -= 0.8
26 | }
27 | if rl.IsKeyDown(rl.KeyDown) {
28 | ballPosition.Y += 0.8
29 | }
30 |
31 | rl.BeginDrawing()
32 | rl.ClearBackground(rl.RayWhite)
33 |
34 | rl.DrawText("move the ball with arrow keys", 10, 10, 20, rl.DarkGray)
35 | rl.DrawCircleV(ballPosition, 50, rl.Maroon)
36 |
37 | rl.EndDrawing()
38 | }
39 |
40 | rl.CloseWindow()
41 | }
42 |
--------------------------------------------------------------------------------
/examples/core/input_mouse/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | rl.InitWindow(800, 450, "raylib [core] example - mouse input")
9 | rl.SetTargetFPS(60)
10 |
11 | ballColor := rl.DarkBlue
12 |
13 | for !rl.WindowShouldClose() {
14 | ballPosition := rl.GetMousePosition()
15 |
16 | if rl.IsMouseButtonPressed(rl.MouseLeftButton) {
17 | ballColor = rl.Maroon
18 | } else if rl.IsMouseButtonPressed(rl.MouseMiddleButton) {
19 | ballColor = rl.Lime
20 | } else if rl.IsMouseButtonPressed(rl.MouseRightButton) {
21 | ballColor = rl.DarkBlue
22 | }
23 |
24 | rl.BeginDrawing()
25 |
26 | rl.ClearBackground(rl.RayWhite)
27 | rl.DrawCircleV(ballPosition, 40, ballColor)
28 |
29 | rl.DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, rl.DarkGray)
30 |
31 | rl.EndDrawing()
32 | }
33 |
34 | rl.CloseWindow()
35 | }
36 |
--------------------------------------------------------------------------------
/examples/core/mouse_wheel/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 |
6 | rl "github.com/gen2brain/raylib-go/raylib"
7 | )
8 |
9 | func main() {
10 | screenWidth := int32(800)
11 | screenHeight := int32(450)
12 |
13 | rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse wheel")
14 |
15 | boxPositionY := screenHeight/2 - 40
16 | scrollSpeed := int32(4) // Scrolling speed in pixels
17 |
18 | rl.SetTargetFPS(60)
19 |
20 | for !rl.WindowShouldClose() {
21 | boxPositionY -= int32(rl.GetMouseWheelMove()) * scrollSpeed
22 |
23 | rl.BeginDrawing()
24 |
25 | rl.ClearBackground(rl.RayWhite)
26 |
27 | rl.DrawRectangle(screenWidth/2-40, boxPositionY, 80, 80, rl.Maroon)
28 |
29 | rl.DrawText("Use mouse wheel to move the square up and down!", 10, 10, 20, rl.Gray)
30 | rl.DrawText(fmt.Sprintf("Box position Y: %d", boxPositionY), 10, 40, 20, rl.LightGray)
31 |
32 | rl.EndDrawing()
33 | }
34 |
35 | rl.CloseWindow()
36 | }
37 |
--------------------------------------------------------------------------------
/examples/core/random_values/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 |
6 | "github.com/gen2brain/raylib-go/raylib"
7 | )
8 |
9 | func main() {
10 | rl.InitWindow(800, 450, "raylib [core] example - generate random values")
11 |
12 | framesCounter := 0 // Variable used to count frames
13 | randValue := rl.GetRandomValue(-8, 5) // Get a random integer number between -8 and 5 (both included)
14 |
15 | rl.SetTargetFPS(60)
16 |
17 | for !rl.WindowShouldClose() {
18 | framesCounter++
19 |
20 | // Every two seconds (120 frames) a new random value is generated
21 | if ((framesCounter / 120) % 2) == 1 {
22 | randValue = rl.GetRandomValue(-8, 5)
23 | framesCounter = 0
24 | }
25 |
26 | rl.BeginDrawing()
27 |
28 | rl.ClearBackground(rl.RayWhite)
29 |
30 | rl.DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, rl.Maroon)
31 |
32 | rl.DrawText(fmt.Sprintf("%d", randValue), 360, 180, 80, rl.LightGray)
33 |
34 | rl.EndDrawing()
35 | }
36 |
37 | rl.CloseWindow()
38 | }
39 |
--------------------------------------------------------------------------------
/examples/core/scissor_test/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | var (
8 | screenW = int32(800)
9 | screenH = int32(450)
10 | )
11 |
12 | func main() {
13 |
14 | rl.InitWindow(screenW, screenH, "raylib [core] example - scissor test")
15 |
16 | scissorArea := rl.NewRectangle(0, 0, 300, 300)
17 | scissorMode := true
18 |
19 | rl.SetTargetFPS(60)
20 |
21 | for !rl.WindowShouldClose() {
22 |
23 | if rl.IsKeyPressed(rl.KeyS) {
24 | scissorMode = !scissorMode
25 | }
26 |
27 | scissorArea.X = float32(rl.GetMouseX())
28 | scissorArea.Y = float32(rl.GetMouseY())
29 |
30 | rl.BeginDrawing()
31 |
32 | rl.ClearBackground(rl.RayWhite)
33 |
34 | if scissorMode {
35 | rl.BeginScissorMode(scissorArea.ToInt32().X, scissorArea.ToInt32().Y, scissorArea.ToInt32().Width, scissorArea.ToInt32().Height)
36 | }
37 |
38 | rl.DrawRectangle(0, 0, screenW, screenH, rl.Red)
39 | rl.DrawText("MOVE MOUSE TO REVEAL TEXT", 190, 200, 20, rl.Black)
40 |
41 | if scissorMode {
42 | rl.EndScissorMode()
43 | }
44 |
45 | rl.DrawRectangleLinesEx(scissorArea, 1, rl.Black)
46 | rl.DrawText("S KEY TO TOGGLE MODE", 10, 10, 20, rl.Black)
47 |
48 | rl.EndDrawing()
49 | }
50 |
51 | rl.CloseWindow()
52 | }
53 |
--------------------------------------------------------------------------------
/examples/core/vr_simulator/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 deviceWarpParam;
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*(deviceWarpParam.x + deviceWarpParam.y*rSq + deviceWarpParam.z*rSq*rSq + deviceWarpParam.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/vr_simulator/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 deviceWarpParam = 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*(deviceWarpParam.x + deviceWarpParam.y*rSq + deviceWarpParam.z*rSq*rSq + deviceWarpParam.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/window_should_close/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import rl "github.com/gen2brain/raylib-go/raylib"
4 |
5 | const (
6 | screenWidth = 850
7 | screenHeight = 480
8 | )
9 |
10 | func main() {
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - window should close")
12 |
13 | rl.SetExitKey(rl.KeyNull) // Disable KEY_ESCAPE to close window, X-button still works
14 |
15 | exitWindowRequested := false // Flag to request window to exit
16 | exitWindow := false // Flag to set window to exit
17 |
18 | rl.SetTargetFPS(60) // Set our game to run at 60 frames-per-second
19 |
20 | for !exitWindow {
21 | if rl.WindowShouldClose() || rl.IsMouseButtonPressed(rl.KeyEscape) {
22 | exitWindowRequested = true
23 | }
24 |
25 | if exitWindowRequested {
26 | if rl.IsKeyPressed(rl.KeyY) {
27 | exitWindow = true
28 | } else if rl.IsKeyPressed(rl.KeyN) {
29 | exitWindowRequested = false
30 | }
31 | }
32 |
33 | rl.BeginDrawing()
34 | rl.ClearBackground(rl.RayWhite)
35 |
36 | if exitWindowRequested {
37 | rl.DrawRectangle(0, 100, screenWidth, 200, rl.Black)
38 | rl.DrawText("Are you sure you want to exit the program? [Y/N]", 40, 180, 30, rl.White)
39 | } else {
40 | rl.DrawText("Try to close the window to get confirmation message!", 120, 200, 20, rl.LightGray)
41 | }
42 |
43 | rl.EndDrawing()
44 | }
45 |
46 | rl.CloseWindow() // Close window and OpenGL context
47 | }
48 |
--------------------------------------------------------------------------------
/examples/core/world_screen/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free")
12 |
13 | camera := rl.Camera{}
14 | camera.Position = rl.NewVector3(10.0, 10.0, 10.0) // Camera position
15 | camera.Target = rl.NewVector3(0.0, 0.0, 0.0) // Camera looking at point
16 | camera.Up = rl.NewVector3(0.0, 1.0, 0.0) // Camera up vector (rotation towards target)
17 | camera.Fovy = 45.0 // Camera field-of-view Y
18 |
19 | cubePosition := rl.NewVector3(0.0, 0.0, 0.0)
20 | cubeScreenPosition := rl.Vector2{}
21 |
22 | rl.SetTargetFPS(60)
23 |
24 | for !rl.WindowShouldClose() {
25 | rl.UpdateCamera(&camera, rl.CameraFree) // Update camera with free camera mode
26 |
27 | // Calculate cube screen space position (with a little offset to be in top)
28 | cubeScreenPosition = rl.GetWorldToScreen(rl.NewVector3(cubePosition.X, cubePosition.Y+2.5, cubePosition.Z), camera)
29 |
30 | rl.BeginDrawing()
31 |
32 | rl.ClearBackground(rl.RayWhite)
33 |
34 | rl.BeginMode3D(camera)
35 |
36 | rl.DrawCube(cubePosition, 2.0, 2.0, 2.0, rl.Red)
37 | rl.DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, rl.Maroon)
38 |
39 | rl.DrawGrid(10, 1.0)
40 |
41 | rl.EndMode3D()
42 |
43 | rl.DrawText("Enemy: 100 / 100", int32(cubeScreenPosition.X)-rl.MeasureText("Enemy: 100 / 100", 20)/2, int32(cubeScreenPosition.Y), 20, rl.Black)
44 | rl.DrawText("Text is always on top of the cube", (screenWidth-rl.MeasureText("Text is always on top of the cube", 20))/2, 25, 20, rl.Gray)
45 |
46 | rl.EndDrawing()
47 | }
48 |
49 | rl.CloseWindow()
50 | }
51 |
--------------------------------------------------------------------------------
/examples/easings/easings/easings.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/easings/easings/easings.gif
--------------------------------------------------------------------------------
/examples/games/floppy/README.md:
--------------------------------------------------------------------------------
1 | ## Floppy Gopher
2 |
3 | 
4 |
5 | [Android APK](https://gist.github.com/gen2brain/ae96bc92d2c2e307af35f5583f30ea25)
6 |
--------------------------------------------------------------------------------
/examples/games/floppy/images/README:
--------------------------------------------------------------------------------
1 | The Gopher sprites were created by Renee French and are distributed
2 | under the Creative Commons Attributions 3.0 license.
3 |
--------------------------------------------------------------------------------
/examples/games/floppy/images/clouds.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/games/floppy/images/clouds.png
--------------------------------------------------------------------------------
/examples/games/floppy/images/smoke.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/games/floppy/images/smoke.png
--------------------------------------------------------------------------------
/examples/games/floppy/images/sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/games/floppy/images/sprite.png
--------------------------------------------------------------------------------
/examples/games/floppy/sounds/click.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/games/floppy/sounds/click.wav
--------------------------------------------------------------------------------
/examples/games/floppy/sounds/flap.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/games/floppy/sounds/flap.wav
--------------------------------------------------------------------------------
/examples/games/floppy/sounds/point.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/games/floppy/sounds/point.wav
--------------------------------------------------------------------------------
/examples/games/floppy/sounds/slap.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/games/floppy/sounds/slap.wav
--------------------------------------------------------------------------------
/examples/go.mod:
--------------------------------------------------------------------------------
1 | module examples
2 |
3 | go 1.21
4 |
5 | replace github.com/gen2brain/raylib-go/raylib => ../raylib
6 |
7 | replace github.com/gen2brain/raylib-go/raygui => ../raygui
8 |
9 | replace github.com/gen2brain/raylib-go/easings => ../easings
10 |
11 | replace github.com/gen2brain/raylib-go/physics => ../physics
12 |
13 | require (
14 | github.com/gen2brain/raylib-go/easings v0.0.0-00010101000000-000000000000
15 | github.com/gen2brain/raylib-go/physics v0.0.0-00010101000000-000000000000
16 | github.com/gen2brain/raylib-go/raygui v0.0.0-00010101000000-000000000000
17 | github.com/gen2brain/raylib-go/raylib v0.0.0-20241202103652-5d50abe7c65b
18 | github.com/jakecoffman/cp v1.2.1
19 | github.com/neguse/go-box2d-lite v0.0.0-20170921151050-5d8ed9b7272b
20 | )
21 |
22 | require (
23 | github.com/ebitengine/purego v0.8.1 // indirect
24 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
25 | golang.org/x/sys v0.27.0 // indirect
26 | )
27 |
--------------------------------------------------------------------------------
/examples/go.sum:
--------------------------------------------------------------------------------
1 | github.com/ebitengine/purego v0.8.1 h1:sdRKd6plj7KYW33EH5As6YKfe8m9zbN9JMrOjNVF/BE=
2 | github.com/ebitengine/purego v0.8.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
3 | github.com/jakecoffman/cp v1.2.1 h1:zkhc2Gpo9l4NLUZfeG3j33+3bQD7MkqPa+n5PdX+5mI=
4 | github.com/jakecoffman/cp v1.2.1/go.mod h1:JjY/Fp6d8E1CHnu74gWNnU0+b9VzEdUVPoJxg2PsTQg=
5 | github.com/neguse/go-box2d-lite v0.0.0-20170921151050-5d8ed9b7272b h1:+67TGbwfgeB5o03Rx+ZBW44zAQ+wUujcwdRA0p9CbJI=
6 | github.com/neguse/go-box2d-lite v0.0.0-20170921151050-5d8ed9b7272b/go.mod h1:kvKwD9codtns5mvpA53V3vLnqFb/Ahcu8zgkGM0SIbI=
7 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
8 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
9 | golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
10 | golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
11 |
--------------------------------------------------------------------------------
/examples/gui/button/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 |
6 | gui "github.com/gen2brain/raylib-go/raygui"
7 | rl "github.com/gen2brain/raylib-go/raylib"
8 | )
9 |
10 | func main() {
11 | rl.InitWindow(800, 450, "raygui - button")
12 |
13 | rl.SetTargetFPS(60)
14 |
15 | var button bool
16 |
17 | for !rl.WindowShouldClose() {
18 | rl.BeginDrawing()
19 |
20 | rl.ClearBackground(rl.Black)
21 |
22 | button = gui.Button(rl.NewRectangle(50, 150, 100, 40), "Click")
23 | if button {
24 | fmt.Println("Clicked on button")
25 | }
26 |
27 | rl.EndDrawing()
28 | }
29 |
30 | rl.CloseWindow()
31 | }
32 |
--------------------------------------------------------------------------------
/examples/gui/controls_test_suite/controls_test_suite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/gui/controls_test_suite/controls_test_suite.png
--------------------------------------------------------------------------------
/examples/gui/icons/README.md:
--------------------------------------------------------------------------------
1 | This example loads a custom .rgi-file and draws the 255th icon. You can use the [rGuiIcons](https://raylibtech.itch.io/rguiicons) tool to view or create icon files.
2 |
3 | 
4 |
--------------------------------------------------------------------------------
/examples/gui/icons/default_icons_with_255.rgi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/gui/icons/default_icons_with_255.rgi
--------------------------------------------------------------------------------
/examples/gui/icons/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raygui"
5 | rl "github.com/gen2brain/raylib-go/raylib"
6 | )
7 |
8 | func main() {
9 | rl.InitWindow(800, 600, "raylib-go - icons example")
10 | defer rl.CloseWindow()
11 |
12 | raygui.LoadIcons("default_icons_with_255.rgi", false)
13 |
14 | for !rl.WindowShouldClose() {
15 | rl.BeginDrawing()
16 | rl.ClearBackground(rl.RayWhite)
17 | raygui.DrawIcon(raygui.ICON_255, 100, 100, 8, rl.Gray)
18 | rl.EndDrawing()
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/examples/gui/icons/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/gui/icons/screenshot.png
--------------------------------------------------------------------------------
/examples/gui/scroll_panel/scroll_panel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/gui/scroll_panel/scroll_panel.png
--------------------------------------------------------------------------------
/examples/models/animation/guy.iqm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/animation/guy.iqm
--------------------------------------------------------------------------------
/examples/models/animation/guyanim.iqm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/animation/guyanim.iqm
--------------------------------------------------------------------------------
/examples/models/animation/guytex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/animation/guytex.png
--------------------------------------------------------------------------------
/examples/models/billboard/billboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/billboard/billboard.png
--------------------------------------------------------------------------------
/examples/models/cubicmap/cubicmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/cubicmap/cubicmap.png
--------------------------------------------------------------------------------
/examples/models/cubicmap/cubicmap_atlas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/cubicmap/cubicmap_atlas.png
--------------------------------------------------------------------------------
/examples/models/draw_cube_texture/cubicmap_atlas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/draw_cube_texture/cubicmap_atlas.png
--------------------------------------------------------------------------------
/examples/models/first_person_maze/cubicmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/first_person_maze/cubicmap.png
--------------------------------------------------------------------------------
/examples/models/first_person_maze/cubicmap_atlas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/first_person_maze/cubicmap_atlas.png
--------------------------------------------------------------------------------
/examples/models/geometric_shapes/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes")
12 |
13 | camera := rl.Camera{}
14 | camera.Position = rl.NewVector3(0.0, 10.0, 10.0)
15 | camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
16 | camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
17 | camera.Fovy = 45.0
18 |
19 | rl.SetTargetFPS(60)
20 |
21 | for !rl.WindowShouldClose() {
22 | rl.BeginDrawing()
23 |
24 | rl.ClearBackground(rl.RayWhite)
25 |
26 | rl.BeginMode3D(camera)
27 |
28 | rl.DrawCube(rl.NewVector3(-4.0, 0.0, 2.0), 2.0, 5.0, 2.0, rl.Red)
29 | rl.DrawCubeWires(rl.NewVector3(-4.0, 0.0, 2.0), 2.0, 5.0, 2.0, rl.Gold)
30 | rl.DrawCubeWires(rl.NewVector3(-4.0, 0.0, -2.0), 3.0, 6.0, 2.0, rl.Maroon)
31 |
32 | rl.DrawSphere(rl.NewVector3(-1.0, 0.0, -2.0), 1.0, rl.Green)
33 | rl.DrawSphereWires(rl.NewVector3(1.0, 0.0, 2.0), 2.0, 16, 16, rl.Lime)
34 |
35 | rl.DrawCylinder(rl.NewVector3(4.0, 0.0, -2.0), 1.0, 2.0, 3.0, 4, rl.SkyBlue)
36 | rl.DrawCylinderWires(rl.NewVector3(4.0, 0.0, -2.0), 1.0, 2.0, 3.0, 4, rl.DarkBlue)
37 | rl.DrawCylinderWires(rl.NewVector3(4.5, -1.0, 2.0), 1.0, 1.0, 2.0, 6, rl.Brown)
38 |
39 | rl.DrawCylinder(rl.NewVector3(1.0, 0.0, -4.0), 0.0, 1.5, 3.0, 8, rl.Gold)
40 | rl.DrawCylinderWires(rl.NewVector3(1.0, 0.0, -4.0), 0.0, 1.5, 3.0, 8, rl.Pink)
41 |
42 | rl.DrawGrid(10, 1.0) // Draw a grid
43 |
44 | rl.EndMode3D()
45 |
46 | rl.DrawFPS(10, 10)
47 |
48 | rl.EndDrawing()
49 | }
50 |
51 | rl.CloseWindow()
52 | }
53 |
--------------------------------------------------------------------------------
/examples/models/gltf_loading/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 |
6 | rl "github.com/gen2brain/raylib-go/raylib"
7 | )
8 |
9 | func main() {
10 | screenWidth := int32(1280)
11 | screenHeight := int32(720)
12 |
13 | rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - gltf loading")
14 |
15 | camera := rl.Camera{}
16 | camera.Position = rl.NewVector3(5.0, 5.0, 5.0)
17 | camera.Target = rl.NewVector3(0.0, 2.0, 0.0)
18 | camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
19 | camera.Fovy = 45.0
20 | camera.Projection = rl.CameraPerspective
21 |
22 | model := rl.LoadModel("robot.glb")
23 |
24 | animIndex := 0
25 | animCurrentFrame := 0
26 |
27 | modelAnims := rl.LoadModelAnimations("robot.glb")
28 |
29 | position := rl.NewVector3(0, 0, 0)
30 | rl.DisableCursor()
31 |
32 | rl.SetTargetFPS(60)
33 |
34 | for !rl.WindowShouldClose() {
35 |
36 | rl.UpdateCamera(&camera, rl.CameraOrbital)
37 |
38 | if rl.IsKeyPressed(rl.KeyUp) {
39 | animIndex++
40 | if animIndex >= len(modelAnims) {
41 | animIndex = 0
42 | }
43 | }
44 | if rl.IsKeyPressed(rl.KeyDown) {
45 | animIndex--
46 | if animIndex < 0 {
47 | animIndex = len(modelAnims) - 1
48 | }
49 | }
50 |
51 | animPlaying := modelAnims[animIndex]
52 | animCurrentFrame = (animCurrentFrame + 1) % int(animPlaying.FrameCount)
53 | rl.UpdateModelAnimation(model, animPlaying, int32(animCurrentFrame))
54 |
55 | rl.BeginDrawing()
56 |
57 | rl.ClearBackground(rl.RayWhite)
58 |
59 | rl.BeginMode3D(camera)
60 |
61 | rl.DrawModel(model, position, 0.8, rl.White)
62 |
63 | rl.EndMode3D()
64 |
65 | rl.DrawText(fmt.Sprintf("current animation: %s [%d]", animPlaying.GetName(), animIndex), 10, 10, 10, rl.Black)
66 | rl.DrawText("UP/DOWN ARROW KEYS CHANGE ANIMATION", 10, 30, 10, rl.Black)
67 |
68 | rl.EndDrawing()
69 | }
70 |
71 | rl.UnloadModel(model)
72 |
73 | rl.CloseWindow()
74 | }
75 |
--------------------------------------------------------------------------------
/examples/models/gltf_loading/robot.glb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/gltf_loading/robot.glb
--------------------------------------------------------------------------------
/examples/models/heightmap/heightmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/heightmap/heightmap.png
--------------------------------------------------------------------------------
/examples/models/heightmap/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | //"fmt"
5 |
6 | rl "github.com/gen2brain/raylib-go/raylib"
7 | )
8 |
9 | func main() {
10 | screenWidth := int32(800)
11 | screenHeight := int32(450)
12 |
13 | rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing")
14 |
15 | camera := rl.Camera{}
16 | camera.Position = rl.NewVector3(18.0, 16.0, 18.0)
17 | camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
18 | camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
19 | camera.Fovy = 45.0
20 |
21 | image := rl.LoadImage("heightmap.png") // Load heightmap image (RAM)
22 | texture := rl.LoadTextureFromImage(image) // Convert image to texture (VRAM)
23 |
24 | mesh := rl.GenMeshHeightmap(*image, rl.NewVector3(16, 8, 16)) // Generate heightmap mesh (RAM and VRAM)
25 | model := rl.LoadModelFromMesh(mesh) // Load model from generated mesh
26 |
27 | rl.SetMaterialTexture(model.Materials, rl.MapDiffuse, texture) // Set map diffuse texture
28 |
29 | mapPosition := rl.NewVector3(-8.0, 0.0, -8.0) // Set model position
30 |
31 | rl.UnloadImage(image) // Unload heightmap image from RAM, already uploaded to VRAM
32 |
33 | rl.SetTargetFPS(60)
34 |
35 | for !rl.WindowShouldClose() {
36 | // Update
37 |
38 | rl.UpdateCamera(&camera, rl.CameraOrbital) // Update camera with orbital camera mode
39 |
40 | // Draw
41 |
42 | rl.BeginDrawing()
43 |
44 | rl.ClearBackground(rl.RayWhite)
45 |
46 | rl.BeginMode3D(camera)
47 |
48 | rl.DrawModel(model, mapPosition, 1.0, rl.Red)
49 |
50 | rl.DrawGrid(20, 1.0)
51 |
52 | rl.EndMode3D()
53 |
54 | rl.DrawTexture(texture, screenWidth-texture.Width-20, 20, rl.White)
55 | rl.DrawRectangleLines(screenWidth-texture.Width-20, 20, texture.Width, texture.Height, rl.Green)
56 |
57 | rl.DrawFPS(10, 10)
58 |
59 | rl.EndDrawing()
60 | }
61 |
62 | rl.UnloadTexture(texture) // Unload map texture
63 | rl.UnloadModel(model) // Unload map model
64 |
65 | rl.CloseWindow()
66 | }
67 |
--------------------------------------------------------------------------------
/examples/models/m3d_loading/cesium_man.m3d:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/m3d_loading/cesium_man.m3d
--------------------------------------------------------------------------------
/examples/models/mesh_picking/turret_diffuse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/mesh_picking/turret_diffuse.png
--------------------------------------------------------------------------------
/examples/models/obj_loading/castle_diffuse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/obj_loading/castle_diffuse.png
--------------------------------------------------------------------------------
/examples/models/skybox/skybox.fs:
--------------------------------------------------------------------------------
1 | #version 330
2 |
3 | // input vertex attributes (from vertex shader)
4 | in vec3 fragPosition;
5 |
6 | // input uniform values
7 | uniform samplerCube environmentMap;
8 |
9 | // output fragment color
10 | out vec4 finalColor;
11 |
12 | void main()
13 | {
14 | // fetch color from texture map
15 | vec3 color = texture(environmentMap, fragPosition).rgb;
16 |
17 | // calculate final fragment color
18 | finalColor = vec4(color, 1.0);
19 | }
--------------------------------------------------------------------------------
/examples/models/skybox/skybox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/skybox/skybox.png
--------------------------------------------------------------------------------
/examples/models/skybox/skybox.vs:
--------------------------------------------------------------------------------
1 | #version 330
2 |
3 | // input vertex attributes
4 | in vec3 vertexPosition;
5 |
6 | // input uniform values
7 | uniform mat4 matProjection;
8 | uniform mat4 matView;
9 |
10 | // output vertex attributes (to fragment shader)
11 | out vec3 fragPosition;
12 |
13 | void main()
14 | {
15 | // calculate fragment position based on model transformations
16 | fragPosition = vertexPosition;
17 |
18 | // remove translation from the view matrix
19 | mat4 rotView = mat4(mat3(matView));
20 | vec4 clipPos = matProjection*rotView*vec4(vertexPosition, 1.0);
21 |
22 | // calculate final vertex position
23 | gl_Position = clipPos;
24 | }
--------------------------------------------------------------------------------
/examples/models/vox_loading/knight.vox:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/vox_loading/knight.vox
--------------------------------------------------------------------------------
/examples/models/vox_loading/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(1280)
9 | screenHeight := int32(720)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - voxel loading")
12 |
13 | camera := rl.Camera{}
14 | camera.Position = rl.NewVector3(10.0, 10.0, 10.0)
15 | camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
16 | camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
17 | camera.Fovy = 45.0
18 | camera.Projection = rl.CameraPerspective
19 |
20 | voxFiles := []string{"knight.vox", "sword.vox", "monument.vox"}
21 |
22 | var models []rl.Model
23 |
24 | for i := 0; i < len(voxFiles); i++ {
25 | models = append(models, rl.LoadModel(voxFiles[i]))
26 | bb := rl.GetModelBoundingBox(models[i])
27 | center := rl.Vector3Zero()
28 | center.X = bb.Min.X + ((bb.Max.X - bb.Min.X) / 2)
29 | center.Z = bb.Min.Z + ((bb.Max.Z - bb.Min.Z) / 2)
30 |
31 | matTranslate := rl.MatrixTranslate(-center.X, 0, -center.Z)
32 | models[i].Transform = matTranslate
33 | }
34 |
35 | currentModel := 0
36 |
37 | rl.DisableCursor()
38 |
39 | rl.SetTargetFPS(60)
40 |
41 | for !rl.WindowShouldClose() {
42 |
43 | rl.UpdateCamera(&camera, rl.CameraOrbital)
44 |
45 | if rl.IsKeyPressed(rl.KeyUp) {
46 | currentModel++
47 | if currentModel >= len(models) {
48 | currentModel = 0
49 | }
50 |
51 | }
52 | if rl.IsKeyPressed(rl.KeyDown) {
53 | currentModel--
54 | if currentModel < 0 {
55 | currentModel = len(models) - 1
56 | }
57 |
58 | }
59 |
60 | rl.BeginDrawing()
61 |
62 | rl.ClearBackground(rl.RayWhite)
63 |
64 | rl.BeginMode3D(camera)
65 |
66 | rl.DrawModel(models[currentModel], rl.Vector3Zero(), 1, rl.White)
67 |
68 | rl.EndMode3D()
69 |
70 | rl.DrawText("current voxel file: "+voxFiles[currentModel], 10, 10, 10, rl.Black)
71 | rl.DrawText("UP/DOWN ARROW KEYS CHANGE FILE", 10, 30, 10, rl.Black)
72 | rl.DrawText("MOUSE SCROLL OR KEYPAD + / - TO CHANGE ZOOM", 10, 50, 10, rl.Black)
73 |
74 | rl.EndDrawing()
75 | }
76 |
77 | for i := 0; i < len(models); i++ {
78 | rl.UnloadModel(models[i])
79 | }
80 |
81 | rl.CloseWindow()
82 | }
83 |
--------------------------------------------------------------------------------
/examples/models/vox_loading/monument.vox:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/vox_loading/monument.vox
--------------------------------------------------------------------------------
/examples/models/vox_loading/sword.vox:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/vox_loading/sword.vox
--------------------------------------------------------------------------------
/examples/models/waving_cubes/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "math"
5 |
6 | rl "github.com/gen2brain/raylib-go/raylib"
7 | )
8 |
9 | func main() {
10 | screenWidth := int32(1280)
11 | screenHeight := int32(720)
12 |
13 | rl.InitWindow(screenWidth, screenHeight, "raylib [models] example - waving cubes")
14 |
15 | camera := rl.Camera{}
16 | camera.Position = rl.NewVector3(30.0, 20.0, 30.0)
17 | camera.Target = rl.NewVector3(0.0, 0.0, 0.0)
18 | camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
19 | camera.Fovy = 70.0
20 | camera.Projection = rl.CameraPerspective
21 |
22 | numBloks := 15
23 |
24 | rl.SetTargetFPS(60)
25 |
26 | for !rl.WindowShouldClose() {
27 |
28 | time := rl.GetTime()
29 |
30 | scale := (2 + float32(math.Sin(time))) * 0.7
31 |
32 | camTime := time * 0.3
33 |
34 | camera.Position.X = float32(math.Cos(camTime)) * 40
35 | camera.Position.Z = float32(math.Sin(camTime)) * 40
36 |
37 | rl.BeginDrawing()
38 |
39 | rl.ClearBackground(rl.RayWhite)
40 |
41 | rl.BeginMode3D(camera)
42 |
43 | rl.DrawGrid(10, 5)
44 |
45 | for x := 0; x < numBloks; x++ {
46 |
47 | for y := 0; y < numBloks; y++ {
48 |
49 | for z := 0; z < numBloks; z++ {
50 |
51 | blockScale := float32((x + y + z)) / 30
52 |
53 | scatter := math.Sin(float64(blockScale*20) + (time * 4))
54 |
55 | cubePos := rl.NewVector3(float32((x-numBloks/2))*(scale*3)+float32(scatter), float32((y-numBloks/2))*(scale*2)+float32(scatter), float32((z-numBloks/2))*(scale*3)+float32(scatter))
56 |
57 | cubeColor := rl.ColorFromHSV(float32(((x+y+z)*18)%360), 0.75, 0.9)
58 |
59 | cubeSize := (2.4 - scale) * blockScale
60 |
61 | rl.DrawCube(cubePos, cubeSize, cubeSize, cubeSize, cubeColor)
62 |
63 | }
64 | }
65 | }
66 |
67 | rl.EndMode3D()
68 |
69 | rl.DrawFPS(10, 10)
70 |
71 | rl.EndDrawing()
72 | }
73 |
74 | rl.CloseWindow()
75 | }
76 |
--------------------------------------------------------------------------------
/examples/models/yaw_pitch_roll/plane_diffuse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/models/yaw_pitch_roll/plane_diffuse.png
--------------------------------------------------------------------------------
/examples/others/android/example/android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
14 |
15 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/examples/others/android/example/android/assets/alagard.rbmf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/others/android/example/android/assets/alagard.rbmf
--------------------------------------------------------------------------------
/examples/others/android/example/android/assets/ambient.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/others/android/example/android/assets/ambient.ogg
--------------------------------------------------------------------------------
/examples/others/android/example/android/assets/coin.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/others/android/example/android/assets/coin.wav
--------------------------------------------------------------------------------
/examples/others/android/example/android/assets/raylib_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/others/android/example/android/assets/raylib_logo.png
--------------------------------------------------------------------------------
/examples/others/android/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | namespace = "com.example.android"
5 | compileSdkVersion 34
6 | buildToolsVersion '34.0.0'
7 |
8 | defaultConfig {
9 | applicationId "com.example.android"
10 | minSdkVersion 16
11 | targetSdkVersion 34
12 | versionCode 1
13 | versionName '1.0'
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | zipAlignEnabled true
20 | }
21 | }
22 |
23 | sourceSets {
24 | main {
25 | jniLibs.srcDirs = ['libs']
26 | res.srcDirs = ['res']
27 | assets.srcDirs = ['assets']
28 |
29 | manifest.srcFile 'AndroidManifest.xml'
30 | }
31 | }
32 | }
33 |
34 | dependencies {
35 | }
36 |
--------------------------------------------------------------------------------
/examples/others/android/example/android/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/others/android/example/android/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/examples/others/android/example/android/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/others/android/example/android/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/examples/others/android/example/android/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/others/android/example/android/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/examples/others/android/example/android/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | raylib-go
4 |
5 |
--------------------------------------------------------------------------------
/examples/others/android/example/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | jcenter()
4 | google()
5 | }
6 | dependencies {
7 | classpath 'com.android.tools.build:gradle:8.2.2'
8 | }
9 | }
10 |
11 | allprojects {
12 | repositories {
13 | jcenter()
14 | google()
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/examples/others/android/example/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/others/android/example/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/others/android/example/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Nov 13 02:02:23 CET 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
7 |
--------------------------------------------------------------------------------
/examples/others/android/example/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':android'
2 |
--------------------------------------------------------------------------------
/examples/others/bunnymark/wabbit_alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/others/bunnymark/wabbit_alpha.png
--------------------------------------------------------------------------------
/examples/others/utils/utils.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "log"
5 |
6 | rl "github.com/gen2brain/raylib-go/raylib"
7 | )
8 |
9 | func main() {
10 | rl.SetTraceLogCallback(func(logType int, str string) {
11 | level := ""
12 | switch rl.TraceLogLevel(logType) {
13 | case rl.LogDebug:
14 | level = "Debug"
15 | case rl.LogError:
16 | level = "Error"
17 | case rl.LogInfo:
18 | level = "Info"
19 | case rl.LogTrace:
20 | level = "Trace"
21 | case rl.LogWarning:
22 | level = "Warning"
23 | case rl.LogFatal:
24 | level = "Fatal"
25 | }
26 | if rl.TraceLogLevel(logType) != rl.LogFatal {
27 | log.Printf("%s - %s", level, str)
28 | } else {
29 | log.Fatalf("%s - %s", level, str)
30 | }
31 | })
32 |
33 | rl.SetConfigFlags(rl.FlagVsyncHint)
34 | rl.InitWindow(800, 450, "raylib [utils] example - SetTraceLogCallback")
35 |
36 | for !rl.WindowShouldClose() {
37 | rl.BeginDrawing()
38 |
39 | rl.ClearBackground(rl.RayWhite)
40 |
41 | rl.DrawText("The raylib trace log is controlled in GO!", 190, 200, 20, rl.LightGray)
42 |
43 | rl.EndDrawing()
44 | }
45 |
46 | rl.CloseWindow()
47 | }
48 |
--------------------------------------------------------------------------------
/examples/shaders/basic_lighting/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 | uniform mat4 matNormal;
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(matModel*vec4(vertexPosition, 1.0));
26 | fragTexCoord = vertexTexCoord;
27 | fragColor = vertexColor;
28 | fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
29 |
30 | // Calculate final vertex position
31 | gl_Position = mvp*vec4(vertexPosition, 1.0);
32 | }
33 |
--------------------------------------------------------------------------------
/examples/shaders/custom_uniform/barracks_diffuse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/custom_uniform/barracks_diffuse.png
--------------------------------------------------------------------------------
/examples/shaders/custom_uniform/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/custom_uniform/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: Render size values should be passed from code
15 | const float renderWidth = 800;
16 | const float renderHeight = 450;
17 |
18 | float radius = 250.0;
19 | float angle = 0.8;
20 |
21 | // NOTE: center is connected to the golang code
22 | uniform vec2 center = vec2(200.0, 200.0);
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 = texture(texture0, tc/texSize)*colDiffuse*fragColor;;
44 |
45 | finalColor = vec4(color.rgb, 1.0);;
46 | }
--------------------------------------------------------------------------------
/examples/shaders/eratosthenes/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Eratosthenes")
12 |
13 | shader := rl.LoadShader("", "eratosthenes.fs")
14 | target := rl.LoadRenderTexture(screenWidth, screenHeight)
15 |
16 | rl.SetTargetFPS(60)
17 |
18 | for !rl.WindowShouldClose() {
19 |
20 | rl.BeginTextureMode(target)
21 | rl.ClearBackground(rl.Black)
22 | rl.DrawRectangle(0, 0, int32(rl.GetScreenWidth()), int32(rl.GetScreenHeight()), rl.Black)
23 | rl.EndTextureMode()
24 |
25 | rl.BeginDrawing()
26 |
27 | rl.ClearBackground(rl.RayWhite)
28 |
29 | rl.BeginShaderMode(shader)
30 |
31 | rl.DrawTextureRec(target.Texture, rl.NewRectangle(0, 0, float32(target.Texture.Width), float32(target.Texture.Height)), rl.Vector2Zero(), rl.White)
32 |
33 | rl.EndShaderMode()
34 |
35 | rl.EndDrawing()
36 | }
37 |
38 | rl.UnloadShader(shader)
39 | rl.UnloadRenderTexture(target)
40 |
41 | rl.CloseWindow()
42 | }
43 |
--------------------------------------------------------------------------------
/examples/shaders/mesh_instancing/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 | in mat4 instanceTransform;
10 |
11 | // Input uniform values
12 | uniform mat4 mvp;
13 | uniform mat4 matNormal;
14 |
15 | // Output vertex attributes (to fragment shader)
16 | out vec3 fragPosition;
17 | out vec2 fragTexCoord;
18 | out vec4 fragColor;
19 | out vec3 fragNormal;
20 |
21 | // NOTE: Add here your custom variables
22 |
23 | void main()
24 | {
25 | // Compute MVP for current instance
26 | mat4 mvpi = mvp*instanceTransform;
27 |
28 | // Send vertex attributes to fragment shader
29 | fragPosition = vec3(mvpi*vec4(vertexPosition, 1.0));
30 | fragTexCoord = vertexTexCoord;
31 | fragColor = vertexColor;
32 | fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
33 |
34 | // Calculate final vertex position
35 | gl_Position = mvpi*vec4(vertexPosition, 1.0);
36 | }
37 |
--------------------------------------------------------------------------------
/examples/shaders/model_shader/dwarf_diffuse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/model_shader/dwarf_diffuse.png
--------------------------------------------------------------------------------
/examples/shaders/model_shader/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/model_shader/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/model_shader/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 |
6 | rl "github.com/gen2brain/raylib-go/raylib"
7 | )
8 |
9 | func main() {
10 | screenWidth := int32(800)
11 | screenHeight := int32(450)
12 |
13 | rl.SetConfigFlags(rl.FlagMsaa4xHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
14 |
15 | rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader")
16 |
17 | camera := rl.Camera{}
18 | camera.Position = rl.NewVector3(3.0, 3.0, 3.0)
19 | camera.Target = rl.NewVector3(0.0, 1.5, 0.0)
20 | camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
21 | camera.Fovy = 45.0
22 |
23 | dwarf := rl.LoadModel("dwarf.obj") // Load OBJ model
24 | texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
25 | shader := rl.LoadShader("glsl330/base.vs", "glsl330/grayscale.fs") // Load model shader
26 |
27 | rl.SetMaterialTexture(dwarf.Materials, rl.MapDiffuse, texture)
28 | dwarf.Materials.Shader = shader // Set shader effect to 3d model
29 |
30 | position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
31 |
32 | rl.SetTargetFPS(60)
33 |
34 | for !rl.WindowShouldClose() {
35 | rl.UpdateCamera(&camera, rl.CameraFree) // Update camera with free camera mode
36 |
37 | rl.BeginDrawing()
38 |
39 | rl.ClearBackground(rl.RayWhite)
40 |
41 | rl.BeginMode3D(camera)
42 |
43 | rl.DrawModel(dwarf, position, 2.0, rl.White) // Draw 3d model with texture
44 |
45 | rl.DrawGrid(10, 1.0) // Draw a grid
46 |
47 | rl.EndMode3D()
48 |
49 | rl.DrawText("(c) Dwarf 3D model by David Moreno", screenWidth-200, screenHeight-20, 10, rl.Gray)
50 |
51 | rl.DrawText(fmt.Sprintf("Camera position: (%.2f, %.2f, %.2f)", camera.Position.X, camera.Position.Y, camera.Position.Z), 600, 20, 10, rl.Black)
52 | rl.DrawText(fmt.Sprintf("Camera target: (%.2f, %.2f, %.2f)", camera.Target.X, camera.Target.Y, camera.Target.Z), 600, 40, 10, rl.Gray)
53 |
54 | rl.DrawFPS(10, 10)
55 |
56 | rl.EndDrawing()
57 | }
58 |
59 | rl.UnloadShader(shader) // Unload shader
60 | rl.UnloadTexture(texture) // Unload texture
61 | rl.UnloadModel(dwarf) // Unload model
62 |
63 | rl.CloseWindow()
64 | }
65 |
--------------------------------------------------------------------------------
/examples/shaders/multi_sample2d/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 | uniform float divider = 0.5;
14 |
15 | out vec4 finalColor;
16 |
17 | void main()
18 | {
19 | // Texel color fetching from texture sampler
20 | vec4 texelColor0 = texture(texture0, fragTexCoord);
21 | vec4 texelColor1 = texture(texture1, fragTexCoord);
22 |
23 | float x = fract(fragTexCoord.s);
24 | float final = smoothstep(divider - 0.1, divider + 0.1, x);
25 |
26 | finalColor = mix(texelColor0, texelColor1, final);
27 | }
--------------------------------------------------------------------------------
/examples/shaders/multi_sample2d/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.SetConfigFlags(rl.FlagMsaa4xHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
12 |
13 | rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - multiple sample2D")
14 |
15 | imRed := rl.GenImageColor(int(screenWidth), int(screenHeight), rl.NewColor(uint8(255), uint8(0), uint8(0), uint8(255)))
16 | texRed := rl.LoadTextureFromImage(imRed)
17 | rl.UnloadImage(imRed)
18 |
19 | imBlue := rl.GenImageColor(int(screenWidth), int(screenHeight), rl.NewColor(uint8(0), uint8(0), uint8(255), uint8(255)))
20 | texBlue := rl.LoadTextureFromImage(imBlue)
21 | rl.UnloadImage(imBlue)
22 |
23 | shader := rl.LoadShader("", "color_mix.fs")
24 |
25 | texBlueLoc := rl.GetShaderLocation(shader, "texture1")
26 | dividerLoc := rl.GetShaderLocation(shader, "divider")
27 | dividerValue := []float32{0.5}
28 |
29 | rl.SetTargetFPS(60)
30 |
31 | for !rl.WindowShouldClose() {
32 |
33 | if rl.IsKeyDown(rl.KeyRight) {
34 | dividerValue[0] += 0.01
35 | } else if rl.IsKeyDown(rl.KeyLeft) {
36 | dividerValue[0] -= 0.01
37 | }
38 |
39 | if dividerValue[0] < 0 {
40 | dividerValue[0] = 0
41 | } else if dividerValue[0] > 1 {
42 | dividerValue[0] = 1
43 | }
44 |
45 | rl.SetShaderValue(shader, dividerLoc, dividerValue, rl.ShaderUniformFloat)
46 |
47 | rl.BeginDrawing()
48 |
49 | rl.ClearBackground(rl.RayWhite)
50 |
51 | rl.BeginShaderMode(shader)
52 |
53 | rl.SetShaderValueTexture(shader, texBlueLoc, texBlue)
54 | rl.DrawTexture(texRed, 0, 0, rl.White)
55 |
56 | rl.EndShaderMode()
57 |
58 | rl.DrawText("USE LEFT/RIGHT ARROW KEYS TO MIX COLORS", 15, 17, 20, rl.Black)
59 | rl.DrawText("USE LEFT/RIGHT ARROW KEYS TO MIX COLORS", 16, 16, 20, rl.White)
60 |
61 | rl.EndDrawing()
62 | }
63 |
64 | rl.UnloadShader(shader) // Unload shader
65 | rl.UnloadTexture(texRed) // Unload texture
66 | rl.UnloadTexture(texBlue) // Unload texture
67 |
68 | rl.CloseWindow()
69 | }
70 |
--------------------------------------------------------------------------------
/examples/shaders/pbr/glsl330/pbr.vs:
--------------------------------------------------------------------------------
1 | #version 330
2 |
3 | // Input vertex attributes
4 | in vec3 vertexPosition;
5 | in vec2 vertexTexCoord;
6 | in vec3 vertexNormal;
7 | in vec3 vertexTangent;
8 | in vec4 vertexColor;
9 |
10 | // Input uniform values
11 | uniform mat4 mvp;
12 | uniform mat4 matModel;
13 | uniform mat4 matNormal;
14 | uniform vec3 lightPos;
15 | uniform vec4 difColor;
16 |
17 | // Output vertex attributes (to fragment shader)
18 | out vec3 fragPosition;
19 | out vec2 fragTexCoord;
20 | out vec2 fragTexCoord2;
21 | out vec4 fragColor;
22 | out vec3 fragNormal;
23 | out mat3 TBN;
24 |
25 | const float normalOffset = 0.1;
26 |
27 | void main()
28 | {
29 | // Compute binormal from vertex normal and tangent
30 | vec3 vertexBinormal = cross(vertexNormal, vertexTangent);
31 |
32 | // Compute fragment normal based on normal transformations
33 | mat3 normalMatrix = transpose(inverse(mat3(matModel)));
34 |
35 | // Compute fragment position based on model transformations
36 | fragPosition = vec3(matModel*vec4(vertexPosition, 1.0f));
37 |
38 | fragTexCoord = vertexTexCoord;
39 | fragNormal = normalize(normalMatrix*vertexNormal);
40 | vec3 fragTangent = normalize(normalMatrix*vertexTangent);
41 | fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal);
42 | vec3 fragBinormal = normalize(normalMatrix*vertexBinormal);
43 | fragBinormal = cross(fragNormal, fragTangent);
44 |
45 | TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal));
46 |
47 | // Calculate final vertex position
48 | gl_Position = mvp*vec4(vertexPosition, 1.0);
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/examples/shaders/pbr/models/old_car_d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/pbr/models/old_car_d.png
--------------------------------------------------------------------------------
/examples/shaders/pbr/models/old_car_e.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/pbr/models/old_car_e.png
--------------------------------------------------------------------------------
/examples/shaders/pbr/models/old_car_mra.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/pbr/models/old_car_mra.png
--------------------------------------------------------------------------------
/examples/shaders/pbr/models/old_car_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/pbr/models/old_car_n.png
--------------------------------------------------------------------------------
/examples/shaders/pbr/models/old_car_new.glb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/pbr/models/old_car_new.glb
--------------------------------------------------------------------------------
/examples/shaders/pbr/models/plane.glb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/pbr/models/plane.glb
--------------------------------------------------------------------------------
/examples/shaders/pbr/models/road_a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/pbr/models/road_a.png
--------------------------------------------------------------------------------
/examples/shaders/pbr/models/road_mra.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/pbr/models/road_mra.png
--------------------------------------------------------------------------------
/examples/shaders/pbr/models/road_n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/pbr/models/road_n.png
--------------------------------------------------------------------------------
/examples/shaders/postprocessing/church_diffuse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/postprocessing/church_diffuse.png
--------------------------------------------------------------------------------
/examples/shaders/postprocessing/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/postprocessing/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/postprocessing/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/postprocessing/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/postprocessing/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/postprocessing/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/postprocessing/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/postprocessing/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/postprocessing/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/postprocessing/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/postprocessing/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/postprocessing/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 -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
24 | horizEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y ))*2.0;
25 | horizEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0;
26 | horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0;
27 | horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y ))*2.0;
28 | horizEdge += texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y + y))*1.0;
29 |
30 | vec4 vertEdge = vec4(0.0);
31 | vertEdge -= texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y - y))*1.0;
32 | vertEdge -= texture(texture0, vec2(fragTexCoord.x , fragTexCoord.y - y))*2.0;
33 | vertEdge -= texture(texture0, vec2(fragTexCoord.x + x, fragTexCoord.y - y))*1.0;
34 | vertEdge += texture(texture0, vec2(fragTexCoord.x - x, fragTexCoord.y + y))*1.0;
35 | vertEdge += texture(texture0, vec2(fragTexCoord.x , fragTexCoord.y + y))*2.0;
36 | vertEdge += texture(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, texture(texture0, fragTexCoord).a);
41 | }
--------------------------------------------------------------------------------
/examples/shaders/shapes_textures/fudesumi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/shapes_textures/fudesumi.png
--------------------------------------------------------------------------------
/examples/shaders/shapes_textures/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/shapes_textures/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/texture_drawing/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/texture_drawing/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing")
12 |
13 | imBlank := rl.GenImageColor(1024, 1024, rl.Blank)
14 | texture := rl.LoadTextureFromImage(imBlank)
15 | rl.UnloadImage(imBlank)
16 |
17 | shader := rl.LoadShader("", "cubes_panning.fs")
18 |
19 | time := []float32{0}
20 |
21 | timeLoc := rl.GetShaderLocation(shader, "uTime")
22 |
23 | rl.SetShaderValue(shader, timeLoc, time, rl.ShaderUniformFloat)
24 |
25 | rl.SetTargetFPS(60)
26 |
27 | for !rl.WindowShouldClose() {
28 |
29 | time = nil
30 | time = []float32{float32(rl.GetTime())}
31 | rl.SetShaderValue(shader, timeLoc, time, rl.ShaderUniformFloat)
32 |
33 | rl.BeginDrawing()
34 |
35 | rl.ClearBackground(rl.RayWhite)
36 |
37 | rl.BeginShaderMode(shader)
38 | rl.DrawTexture(texture, 0, 0, rl.White)
39 | rl.EndShaderMode()
40 |
41 | rl.DrawText("BACKGROUND is PAINTED and ANIMATED on SHADER!", 10, 10, 20, rl.Maroon)
42 |
43 | rl.EndDrawing()
44 | }
45 |
46 | rl.UnloadShader(shader) // Unload shader
47 |
48 | rl.CloseWindow()
49 | }
50 |
--------------------------------------------------------------------------------
/examples/shaders/texture_outline/gopher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/texture_outline/gopher.png
--------------------------------------------------------------------------------
/examples/shaders/texture_outline/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture outline")
12 |
13 | texture := rl.LoadTexture("gopher.png")
14 |
15 | shader := rl.LoadShader("", "outline.fs")
16 |
17 | cnt := rl.NewVector2(float32(screenWidth/2), float32(screenHeight/2))
18 |
19 | outlineSize := []float32{2}
20 | outlineColor := []float32{1, 0, 0, 1}
21 | textureSize := []float32{float32(texture.Width), float32(texture.Height)}
22 |
23 | outlineSizeLoc := rl.GetShaderLocation(shader, "outlineSize")
24 | outlineColorLoc := rl.GetShaderLocation(shader, "outlineColor")
25 | textureSizeLoc := rl.GetShaderLocation(shader, "textureSize")
26 |
27 | rl.SetShaderValue(shader, outlineSizeLoc, outlineSize, rl.ShaderUniformFloat)
28 | rl.SetShaderValue(shader, outlineColorLoc, outlineColor, rl.ShaderUniformVec4)
29 | rl.SetShaderValue(shader, textureSizeLoc, textureSize, rl.ShaderUniformVec2)
30 |
31 | rl.SetTargetFPS(60)
32 |
33 | for !rl.WindowShouldClose() {
34 |
35 | if rl.IsKeyPressed(rl.KeyUp) {
36 | outlineSize[0]++
37 | } else if rl.IsKeyPressed(rl.KeyDown) {
38 | outlineSize[0]--
39 | if outlineSize[0] < 1 {
40 | outlineSize[0] = 1
41 | }
42 | }
43 |
44 | rl.SetShaderValue(shader, outlineSizeLoc, outlineSize, rl.ShaderUniformFloat)
45 |
46 | rl.BeginDrawing()
47 |
48 | rl.ClearBackground(rl.RayWhite)
49 |
50 | rl.BeginShaderMode(shader)
51 |
52 | rl.DrawTexture(texture, int32(cnt.X)-texture.Width/2, int32(cnt.Y)-texture.Height/2, rl.White)
53 |
54 | rl.EndShaderMode()
55 |
56 | rl.DrawText("UP/DOWN ARROW KEYS INCREASE OUTLINE THICKNESS", 10, 10, 10, rl.Black)
57 |
58 | rl.EndDrawing()
59 | }
60 |
61 | rl.UnloadShader(shader)
62 | rl.UnloadTexture(texture)
63 |
64 | rl.CloseWindow()
65 | }
66 |
--------------------------------------------------------------------------------
/examples/shaders/texture_outline/outline.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 | uniform vec2 textureSize;
12 | uniform float outlineSize;
13 | uniform vec4 outlineColor;
14 |
15 | // Output fragment color
16 | out vec4 finalColor;
17 |
18 | void main()
19 | {
20 | vec4 texel = texture(texture0, fragTexCoord); // Get texel color
21 | vec2 texelScale = vec2(0.0);
22 | texelScale.x = outlineSize/textureSize.x;
23 | texelScale.y = outlineSize/textureSize.y;
24 |
25 | // We sample four corner texels, but only for the alpha channel (this is for the outline)
26 | vec4 corners = vec4(0.0);
27 | corners.x = texture(texture0, fragTexCoord + vec2(texelScale.x, texelScale.y)).a;
28 | corners.y = texture(texture0, fragTexCoord + vec2(texelScale.x, -texelScale.y)).a;
29 | corners.z = texture(texture0, fragTexCoord + vec2(-texelScale.x, texelScale.y)).a;
30 | corners.w = texture(texture0, fragTexCoord + vec2(-texelScale.x, -texelScale.y)).a;
31 |
32 | float outline = min(dot(corners, vec4(1.0)), 1.0);
33 | vec4 color = mix(vec4(0.0), outlineColor, outline);
34 | finalColor = mix(color, texel, texel.a);
35 | }
--------------------------------------------------------------------------------
/examples/shaders/texture_tiling/cubicmap_atlas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/texture_tiling/cubicmap_atlas.png
--------------------------------------------------------------------------------
/examples/shaders/texture_tiling/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture tiling")
12 |
13 | cam := rl.Camera3D{}
14 | cam.Position = rl.NewVector3(4, 4, 4)
15 | cam.Target = rl.NewVector3(0, 0.5, 0)
16 | cam.Up = rl.NewVector3(0, 1, 0)
17 | cam.Fovy = 45
18 | cam.Projection = rl.CameraPerspective
19 |
20 | cube := rl.GenMeshCube(1, 1, 1)
21 | model := rl.LoadModelFromMesh(cube)
22 |
23 | texture := rl.LoadTexture("cubicmap_atlas.png")
24 | rl.SetMaterialTexture(model.Materials, rl.MapDiffuse, texture)
25 |
26 | tiling := []float32{3, 3}
27 | shader := rl.LoadShader("", "tiling.fs")
28 | rl.SetShaderValue(shader, rl.GetShaderLocation(shader, "tiling"), tiling, rl.ShaderUniformVec2)
29 | model.Materials.Shader = shader
30 |
31 | rl.DisableCursor()
32 |
33 | rl.SetTargetFPS(60)
34 |
35 | for !rl.WindowShouldClose() {
36 |
37 | rl.UpdateCamera(&cam, rl.CameraOrbital)
38 |
39 | if rl.IsKeyPressed(rl.KeyZ) {
40 | cam.Target = rl.NewVector3(0, 0.5, 0)
41 | }
42 |
43 | rl.BeginDrawing()
44 |
45 | rl.ClearBackground(rl.RayWhite)
46 |
47 | rl.BeginMode3D(cam)
48 |
49 | rl.BeginShaderMode(shader)
50 | rl.DrawModel(model, rl.Vector3Zero(), 2, rl.White)
51 | rl.EndShaderMode()
52 |
53 | rl.DrawGrid(10, 1)
54 |
55 | rl.EndMode3D()
56 |
57 | rl.EndDrawing()
58 | }
59 |
60 | rl.UnloadShader(shader)
61 | rl.UnloadModel(model)
62 | rl.UnloadTexture(texture)
63 |
64 | rl.CloseWindow()
65 | }
66 |
--------------------------------------------------------------------------------
/examples/shaders/texture_tiling/tiling.fs:
--------------------------------------------------------------------------------
1 | #version 330 core
2 |
3 | uniform sampler2D diffuseMap;
4 | uniform vec2 tiling;
5 |
6 | in vec2 fragTexCoord;
7 |
8 | out vec4 fragColor;
9 |
10 | void main()
11 | {
12 | vec2 texCoord = fragTexCoord * tiling;
13 | fragColor = texture(diffuseMap, texCoord);
14 | }
15 |
--------------------------------------------------------------------------------
/examples/shaders/texture_waves/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture waves")
12 |
13 | texture := rl.LoadTexture("space.png")
14 |
15 | shader := rl.LoadShader("", "wave.fs")
16 |
17 | secondsLoc := rl.GetShaderLocation(shader, "seconds")
18 | freqXLoc := rl.GetShaderLocation(shader, "freqX")
19 | freqYLoc := rl.GetShaderLocation(shader, "freqY")
20 | ampXLoc := rl.GetShaderLocation(shader, "ampX")
21 | ampYLoc := rl.GetShaderLocation(shader, "ampY")
22 | speedXLoc := rl.GetShaderLocation(shader, "speedX")
23 | speedYLoc := rl.GetShaderLocation(shader, "speedY")
24 |
25 | freqX := []float32{25}
26 | freqY := []float32{25}
27 | ampX := []float32{5}
28 | ampY := []float32{5}
29 | speedX := []float32{8}
30 | speedY := []float32{8}
31 |
32 | screensize := []float32{float32(rl.GetScreenWidth()), float32(rl.GetScreenHeight())}
33 |
34 | rl.SetShaderValue(shader, rl.GetShaderLocation(shader, "size"), screensize, rl.ShaderUniformVec2)
35 | rl.SetShaderValue(shader, freqXLoc, freqX, rl.ShaderUniformFloat)
36 | rl.SetShaderValue(shader, freqYLoc, freqY, rl.ShaderUniformFloat)
37 | rl.SetShaderValue(shader, ampXLoc, ampX, rl.ShaderUniformFloat)
38 | rl.SetShaderValue(shader, ampYLoc, ampY, rl.ShaderUniformFloat)
39 | rl.SetShaderValue(shader, speedXLoc, speedX, rl.ShaderUniformFloat)
40 | rl.SetShaderValue(shader, speedYLoc, speedY, rl.ShaderUniformFloat)
41 |
42 | seconds := []float32{0}
43 |
44 | rl.SetTargetFPS(60)
45 |
46 | for !rl.WindowShouldClose() {
47 |
48 | seconds[0] += rl.GetFrameTime()
49 | rl.SetShaderValue(shader, secondsLoc, seconds, rl.ShaderUniformFloat)
50 |
51 | rl.BeginDrawing()
52 |
53 | rl.ClearBackground(rl.RayWhite)
54 |
55 | rl.BeginShaderMode(shader)
56 | rl.DrawTexture(texture, 0, 0, rl.White)
57 | rl.DrawTexture(texture, texture.Width, 0, rl.White)
58 | rl.EndShaderMode()
59 |
60 | rl.EndDrawing()
61 | }
62 |
63 | rl.UnloadShader(shader)
64 | rl.UnloadTexture(texture)
65 |
66 | rl.CloseWindow()
67 | }
68 |
--------------------------------------------------------------------------------
/examples/shaders/texture_waves/space.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/shaders/texture_waves/space.png
--------------------------------------------------------------------------------
/examples/shaders/texture_waves/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 seconds;
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) + (seconds * speedX)) * ampX * pixelWidth;
34 | p.y += sin((fragTexCoord.x - boxLeft) * freqY * aspect / ( pixelHeight * 750.0) + (seconds * speedY)) * ampY * pixelHeight;
35 |
36 | finalColor = texture(texture0, p)*colDiffuse*fragColor;
37 | }
38 |
--------------------------------------------------------------------------------
/examples/shaders/vertex_displacement/glsl100/vertex_displacement.fs:
--------------------------------------------------------------------------------
1 | #version 100
2 |
3 | precision mediump float;
4 |
5 | // Input vertex attributes (from fragment shader)
6 | varying vec2 fragTexCoord;
7 | varying float height;
8 |
9 |
10 | void main()
11 | {
12 | vec4 darkblue = vec4(0.0, 0.13, 0.18, 1.0);
13 | vec4 lightblue = vec4(1.0, 1.0, 1.0, 1.0);
14 | // Interpolate between two colors based on height
15 | vec4 finalColor = mix(darkblue, lightblue, height);
16 |
17 | gl_FragColor = finalColor;
18 | }
19 |
--------------------------------------------------------------------------------
/examples/shaders/vertex_displacement/glsl100/vertex_displacement.vs:
--------------------------------------------------------------------------------
1 | #version 100
2 |
3 | precision mediump float;
4 |
5 | // Input vertex attributes
6 | attribute vec3 vertexPosition;
7 | attribute vec2 vertexTexCoord;
8 | attribute vec3 vertexNormal;
9 | attribute vec4 vertexColor;
10 |
11 | // Input uniform values
12 | uniform mat4 mvp;
13 | uniform mat4 matModel;
14 | uniform mat4 matNormal;
15 |
16 | uniform float time;
17 |
18 | uniform sampler2D perlinNoiseMap;
19 |
20 | // Output vertex attributes (to fragment shader)
21 | varying vec3 fragPosition;
22 | varying vec2 fragTexCoord;
23 | varying vec3 fragNormal;
24 | varying float height;
25 |
26 | void main()
27 | {
28 | // Calculate animated texture coordinates based on time and vertex position
29 | vec2 animatedTexCoord = sin(vertexTexCoord + vec2(sin(time + vertexPosition.x * 0.1), cos(time + vertexPosition.z * 0.1)) * 0.3);
30 |
31 | // Normalize animated texture coordinates to range [0, 1]
32 | animatedTexCoord = animatedTexCoord * 0.5 + 0.5;
33 |
34 | // Fetch displacement from the perlin noise map
35 | float displacement = texture2D(perlinNoiseMap, animatedTexCoord).r * 7.0; // Amplified displacement
36 |
37 | // Displace vertex position
38 | vec3 displacedPosition = vertexPosition + vec3(0.0, displacement, 0.0);
39 |
40 | // Send vertex attributes to fragment shader
41 | fragPosition = vec3(matModel * vec4(displacedPosition, 1.0));
42 | fragTexCoord = vertexTexCoord;
43 | fragNormal = normalize(vec3(matNormal * vec4(vertexNormal, 1.0)));
44 | height = displacedPosition.y * 0.2; // Send height to fragment shader for coloring
45 |
46 | // Calculate final vertex position
47 | gl_Position = mvp * vec4(displacedPosition, 1.0);
48 | }
49 |
--------------------------------------------------------------------------------
/examples/shaders/vertex_displacement/glsl330/vertex_displacement.fs:
--------------------------------------------------------------------------------
1 | #version 330
2 |
3 | // Input fragment attributes (from fragment shader)
4 | in vec2 fragTexCoord;
5 | in float height;
6 |
7 | // Output fragment color
8 | out vec4 finalColor;
9 |
10 | void main()
11 | {
12 | vec4 darkblue = vec4(0.0, 0.13, 0.18, 1.0);
13 | vec4 lightblue = vec4(1.0, 1.0, 1.0, 1.0);
14 | // Interpolate between two colors based on height
15 | finalColor = mix(darkblue, lightblue, height);
16 | }
17 |
--------------------------------------------------------------------------------
/examples/shaders/vertex_displacement/glsl330/vertex_displacement.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 | uniform mat4 matNormal;
13 |
14 | uniform float time;
15 |
16 | uniform sampler2D perlinNoiseMap;
17 |
18 | // Output vertex attributes (to fragment shader)
19 | out vec3 fragPosition;
20 | out vec2 fragTexCoord;
21 | out vec3 fragNormal;
22 | out float height;
23 |
24 | void main()
25 | {
26 | // Calculate animated texture coordinates based on time and vertex position
27 | vec2 animatedTexCoord = sin(vertexTexCoord + vec2(sin(time + vertexPosition.x * 0.1), cos(time + vertexPosition.z * 0.1)) * 0.3);
28 |
29 | // Normalize animated texture coordinates to range [0, 1]
30 | animatedTexCoord = animatedTexCoord * 0.5 + 0.5;
31 |
32 | // Fetch displacement from the perlin noise map
33 | float displacement = texture(perlinNoiseMap, animatedTexCoord).r * 7.0; // Amplified displacement
34 |
35 | // Displace vertex position
36 | vec3 displacedPosition = vertexPosition + vec3(0.0, displacement, 0.0);
37 |
38 | // Send vertex attributes to fragment shader
39 | fragPosition = vec3(matModel * vec4(displacedPosition, 1.0));
40 | fragTexCoord = vertexTexCoord;
41 | fragNormal = normalize(vec3(matNormal * vec4(vertexNormal, 1.0)));
42 | height = displacedPosition.y * 0.2; // Send height to fragment shader for coloring
43 |
44 | // Calculate final vertex position
45 | gl_Position = mvp * vec4(displacedPosition, 1.0);
46 | }
47 |
--------------------------------------------------------------------------------
/examples/shapes/basic_shapes/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing")
12 |
13 | rl.SetTargetFPS(60)
14 |
15 | for !rl.WindowShouldClose() {
16 | rl.BeginDrawing()
17 | rl.ClearBackground(rl.RayWhite)
18 |
19 | rl.DrawText("some basic shapes available on raylib", 20, 20, 20, rl.DarkGray)
20 |
21 | rl.DrawLine(18, 42, screenWidth-18, 42, rl.Black)
22 |
23 | rl.DrawCircle(screenWidth/4, 120, 35, rl.DarkBlue)
24 | rl.DrawCircleGradient(screenWidth/4, 220, 60, rl.Green, rl.SkyBlue)
25 | rl.DrawCircleLines(screenWidth/4, 340, 80, rl.DarkBlue)
26 |
27 | rl.DrawRectangle(screenWidth/4*2-60, 100, 120, 60, rl.Red)
28 | rl.DrawRectangleGradientH(screenWidth/4*2-90, 170, 180, 130, rl.Maroon, rl.Gold)
29 | rl.DrawRectangleLines(screenWidth/4*2-40, 320, 80, 60, rl.Orange)
30 |
31 | rl.DrawTriangle(rl.NewVector2(float32(screenWidth)/4*3, 80),
32 | rl.NewVector2(float32(screenWidth)/4*3-60, 150),
33 | rl.NewVector2(float32(screenWidth)/4*3+60, 150), rl.Violet)
34 |
35 | rl.DrawTriangleLines(rl.NewVector2(float32(screenWidth)/4*3, 160),
36 | rl.NewVector2(float32(screenWidth)/4*3-20, 230),
37 | rl.NewVector2(float32(screenWidth)/4*3+20, 230), rl.DarkBlue)
38 |
39 | rl.DrawPoly(rl.NewVector2(float32(screenWidth)/4*3, 320), 6, 80, 0, rl.Brown)
40 |
41 | rl.EndDrawing()
42 | }
43 |
44 | rl.CloseWindow()
45 | }
46 |
--------------------------------------------------------------------------------
/examples/shapes/bouncing_ball/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(1280)
9 | screenHeight := int32(720)
10 |
11 | rl.SetConfigFlags(rl.FlagMsaa4xHint)
12 |
13 | rl.InitWindow(screenWidth, screenHeight, "raylib [shapes] example - bouncing ball")
14 |
15 | ballPos := rl.NewVector2(float32(screenWidth)/2, float32(screenHeight)/2)
16 | ballSpeed := rl.NewVector2(5, 4)
17 | ballRadius := 20
18 |
19 | pause := false
20 | frames := 0
21 |
22 | rl.SetTargetFPS(60)
23 |
24 | rl.SetMousePosition(0, 0)
25 |
26 | for !rl.WindowShouldClose() {
27 |
28 | if rl.IsKeyPressed(rl.KeySpace) {
29 | pause = !pause
30 | }
31 |
32 | if !pause {
33 | ballPos.X += ballSpeed.X
34 | ballPos.Y += ballSpeed.Y
35 | if ballPos.X >= float32(screenWidth)-float32(ballRadius) || ballPos.X <= float32(ballRadius) {
36 | ballSpeed.X *= -1
37 | }
38 | if ballPos.Y >= float32(screenHeight)-float32(ballRadius) || ballPos.Y <= float32(ballRadius) {
39 | ballSpeed.Y *= -1
40 | }
41 | } else {
42 | frames++
43 | }
44 |
45 | rl.BeginDrawing()
46 | rl.ClearBackground(rl.RayWhite)
47 |
48 | rl.DrawText("SPACE key to pause", 10, 10, 20, rl.Black)
49 |
50 | rl.DrawCircleV(ballPos, float32(ballRadius), rl.Red)
51 |
52 | if pause && (frames/30)%2 == 0 {
53 | rl.DrawText("PAUSED", 10, screenHeight-40, 30, rl.Black)
54 | }
55 |
56 | rl.DrawFPS(screenWidth-100, 10)
57 |
58 | rl.EndDrawing()
59 |
60 | }
61 |
62 | rl.CloseWindow()
63 | }
64 |
--------------------------------------------------------------------------------
/examples/shapes/easings_ball_anim/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | ez "github.com/gen2brain/raylib-go/easings"
5 | rl "github.com/gen2brain/raylib-go/raylib"
6 | )
7 |
8 | func main() {
9 | screenWidth := int32(800)
10 | screenHeight := int32(450)
11 |
12 | rl.SetConfigFlags(rl.FlagMsaa4xHint)
13 |
14 | rl.InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings ball anim")
15 |
16 | ballPosX := -100
17 | ballRadius := 20
18 | ballAlpha := float32(0)
19 |
20 | state := 0
21 | frames := 0
22 |
23 | rl.SetTargetFPS(60)
24 |
25 | for !rl.WindowShouldClose() {
26 |
27 | if state == 0 {
28 |
29 | frames++
30 | ballPosX = int(ez.ElasticOut(float32(frames), -100, float32(screenWidth/2)+100, 100))
31 |
32 | if frames >= 100 {
33 | frames = 0
34 | state = 1
35 | }
36 |
37 | } else if state == 1 {
38 | frames++
39 | ballRadius = int(ez.ElasticIn(float32(frames), 20, 500, 150))
40 |
41 | if frames >= 150 {
42 | frames = 0
43 | state = 2
44 | }
45 | } else if state == 2 {
46 | frames++
47 | ballAlpha = ez.CubicOut(float32(frames), 0, 1, 150)
48 |
49 | if frames >= 150 {
50 | frames = 0
51 | state = 3
52 | }
53 | } else if state == 3 {
54 | if rl.IsKeyPressed(rl.KeyEnter) {
55 | ballPosX = -100
56 | ballRadius = 20
57 | ballAlpha = 0
58 | state = 0
59 | }
60 |
61 | }
62 |
63 | if rl.IsKeyPressed(rl.KeyR) {
64 | frames = 0
65 | }
66 |
67 | rl.BeginDrawing()
68 | rl.ClearBackground(rl.RayWhite)
69 |
70 | if state >= 2 {
71 | rl.DrawRectangle(0, 0, screenWidth, screenHeight, rl.Green)
72 | }
73 |
74 | rl.DrawCircle(int32(ballPosX), 200, float32(ballRadius), rl.Fade(rl.Red, 1-ballAlpha))
75 |
76 | if state == 3 {
77 | textlen := rl.MeasureText("press ENTER to replay", 20)
78 | rl.DrawText("press ENTER to replay", (screenWidth/2)-textlen/2, 200, 20, rl.Black)
79 | }
80 |
81 | rl.EndDrawing()
82 |
83 | }
84 |
85 | rl.CloseWindow()
86 | }
87 |
--------------------------------------------------------------------------------
/examples/shapes/lines_bezier/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines")
12 |
13 | start := rl.NewVector2(0, 0)
14 | end := rl.NewVector2(float32(screenWidth), float32(screenHeight))
15 |
16 | rl.SetTargetFPS(60)
17 |
18 | for !rl.WindowShouldClose() {
19 | if rl.IsMouseButtonDown(rl.MouseLeftButton) {
20 | start = rl.GetMousePosition()
21 | } else if rl.IsMouseButtonDown(rl.MouseRightButton) {
22 | end = rl.GetMousePosition()
23 | }
24 |
25 | rl.BeginDrawing()
26 | rl.ClearBackground(rl.RayWhite)
27 |
28 | rl.DrawText("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, rl.Gray)
29 |
30 | rl.DrawLineBezier(start, end, 2.0, rl.Red)
31 |
32 | rl.EndDrawing()
33 | }
34 |
35 | rl.CloseWindow()
36 | }
37 |
--------------------------------------------------------------------------------
/examples/shapes/logo_raylib/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes")
12 |
13 | rl.SetTargetFPS(60)
14 |
15 | for !rl.WindowShouldClose() {
16 | rl.BeginDrawing()
17 | rl.ClearBackground(rl.RayWhite)
18 |
19 | rl.DrawRectangle(screenWidth/2-128, screenHeight/2-128, 256, 256, rl.Black)
20 | rl.DrawRectangle(screenWidth/2-112, screenHeight/2-112, 224, 224, rl.RayWhite)
21 | rl.DrawText("raylib", screenWidth/2-44, screenHeight/2+48, 50, rl.Black)
22 |
23 | rl.DrawText("this is NOT a texture!", 350, 370, 10, rl.Gray)
24 |
25 | rl.EndDrawing()
26 | }
27 |
28 | rl.CloseWindow()
29 | }
30 |
--------------------------------------------------------------------------------
/examples/text/bmfont_ttf/fonts/bmfont.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/bmfont_ttf/fonts/bmfont.png
--------------------------------------------------------------------------------
/examples/text/bmfont_ttf/fonts/pixantiqua.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/bmfont_ttf/fonts/pixantiqua.ttf
--------------------------------------------------------------------------------
/examples/text/bmfont_ttf/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading")
12 |
13 | msgBm := "THIS IS AN AngelCode SPRITE FONT"
14 | msgTtf := "THIS SPRITE FONT has been GENERATED from a TTF"
15 |
16 | // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
17 | fontBm := rl.LoadFont("fonts/bmfont.fnt") // BMFont (AngelCode)
18 | fontTtf := rl.LoadFont("fonts/pixantiqua.ttf") // TTF font
19 |
20 | fontPosition := rl.Vector2{}
21 |
22 | fontPosition.X = float32(screenWidth)/2 - rl.MeasureTextEx(fontBm, msgBm, float32(fontBm.BaseSize), 0).X/2
23 | fontPosition.Y = float32(screenHeight)/2 - float32(fontBm.BaseSize)/2 - 80
24 |
25 | rl.SetTargetFPS(60)
26 |
27 | for !rl.WindowShouldClose() {
28 | rl.BeginDrawing()
29 |
30 | rl.ClearBackground(rl.RayWhite)
31 |
32 | rl.DrawTextEx(fontBm, msgBm, fontPosition, float32(fontBm.BaseSize), 0, rl.Maroon)
33 | rl.DrawTextEx(fontTtf, msgTtf, rl.NewVector2(75.0, 240.0), float32(fontTtf.BaseSize)*0.8, 2, rl.Lime)
34 |
35 | rl.EndDrawing()
36 | }
37 |
38 | rl.UnloadFont(fontBm) // AngelCode Font unloading
39 | rl.UnloadFont(fontTtf) // TTF Font unloading
40 |
41 | rl.CloseWindow()
42 | }
43 |
--------------------------------------------------------------------------------
/examples/text/bmfont_unordered/fonts/pixantiqua_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/bmfont_unordered/fonts/pixantiqua_0.png
--------------------------------------------------------------------------------
/examples/text/bmfont_unordered/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 |
6 | "github.com/gen2brain/raylib-go/raylib"
7 | )
8 |
9 | func main() {
10 | screenWidth := int32(800)
11 | screenHeight := int32(450)
12 |
13 | rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont unordered loading and drawing")
14 |
15 | // NOTE: Using chars outside the [32..127] limits!
16 | // NOTE: If a character is not found in the font, it just renders a space
17 | msg := "ASCII extended characters:\n¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ\nÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæ\nçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
18 |
19 | // NOTE: Loaded font has an unordered list of characters (chars in the range 32..255)
20 | font := rl.LoadFont("fonts/pixantiqua.fnt") // BMFont (AngelCode)
21 |
22 | rl.SetTargetFPS(60)
23 |
24 | for !rl.WindowShouldClose() {
25 | rl.BeginDrawing()
26 |
27 | rl.ClearBackground(rl.RayWhite)
28 |
29 | rl.DrawText("Font name: PixAntiqua", 40, 50, 20, rl.Gray)
30 | rl.DrawText(fmt.Sprintf("Font base size: %d", font.BaseSize), 40, 80, 20, rl.Gray)
31 | rl.DrawText(fmt.Sprintf("Font chars number: %d", font.CharsCount), 40, 110, 20, rl.Gray)
32 |
33 | rl.DrawTextEx(font, msg, rl.NewVector2(40, 180), float32(font.BaseSize), 0, rl.Maroon)
34 |
35 | rl.EndDrawing()
36 | }
37 |
38 | rl.UnloadFont(font) // AngelCode Font unloading
39 |
40 | rl.CloseWindow()
41 | }
42 |
--------------------------------------------------------------------------------
/examples/text/codepoints_loading/DotGothic16-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/codepoints_loading/DotGothic16-Regular.ttf
--------------------------------------------------------------------------------
/examples/text/draw_3d/alpha_discard.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 | void main()
15 | {
16 | vec4 texelColor = texture(texture0, fragTexCoord);
17 | if (texelColor.a == 0.0) discard;
18 | finalColor = texelColor * fragColor * colDiffuse;
19 | }
20 |
--------------------------------------------------------------------------------
/examples/text/font_filters/KAISG.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/font_filters/KAISG.ttf
--------------------------------------------------------------------------------
/examples/text/font_loading/pixantiqua.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/font_loading/pixantiqua.png
--------------------------------------------------------------------------------
/examples/text/font_loading/pixantiqua.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/font_loading/pixantiqua.ttf
--------------------------------------------------------------------------------
/examples/text/font_sdf/AnonymousPro-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/font_sdf/AnonymousPro-Bold.ttf
--------------------------------------------------------------------------------
/examples/text/font_sdf/sdf.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 | // NOTE: Calculate alpha using signed distance field (SDF)
20 | float distanceFromOutline = texture(texture0, fragTexCoord).a - 0.5;
21 | float distanceChangePerFragment = length(vec2(dFdx(distanceFromOutline), dFdy(distanceFromOutline)));
22 | float alpha = smoothstep(-distanceChangePerFragment, distanceChangePerFragment, distanceFromOutline);
23 |
24 | // Calculate final fragment color
25 | finalColor = vec4(fragColor.rgb, fragColor.a*alpha);
26 | }
27 |
--------------------------------------------------------------------------------
/examples/text/format_text/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 |
6 | "github.com/gen2brain/raylib-go/raylib"
7 | )
8 |
9 | func main() {
10 | screenWidth := int32(800)
11 | screenHeight := int32(450)
12 |
13 | rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting")
14 |
15 | score := 100020
16 | hiscore := 200450
17 | lives := 5
18 |
19 | rl.SetTargetFPS(60)
20 |
21 | for !rl.WindowShouldClose() {
22 | rl.BeginDrawing()
23 |
24 | rl.ClearBackground(rl.RayWhite)
25 |
26 | rl.DrawText(fmt.Sprintf("Score: %08d", score), 200, 80, 20, rl.Red)
27 |
28 | rl.DrawText(fmt.Sprintf("HiScore: %08d", hiscore), 200, 120, 20, rl.Green)
29 |
30 | rl.DrawText(fmt.Sprintf("Lives: %02d", lives), 200, 160, 40, rl.Blue)
31 |
32 | rl.DrawText(fmt.Sprintf("Elapsed Time: %02.02f ms", rl.GetFrameTime()*1000), 200, 220, 20, rl.Black)
33 |
34 | rl.EndDrawing()
35 | }
36 |
37 | rl.CloseWindow()
38 | }
39 |
--------------------------------------------------------------------------------
/examples/text/raylib_fonts/fonts/alagard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/raylib_fonts/fonts/alagard.png
--------------------------------------------------------------------------------
/examples/text/raylib_fonts/fonts/alpha_beta.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/raylib_fonts/fonts/alpha_beta.png
--------------------------------------------------------------------------------
/examples/text/raylib_fonts/fonts/jupiter_crash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/raylib_fonts/fonts/jupiter_crash.png
--------------------------------------------------------------------------------
/examples/text/raylib_fonts/fonts/mecha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/raylib_fonts/fonts/mecha.png
--------------------------------------------------------------------------------
/examples/text/raylib_fonts/fonts/pixantiqua.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/raylib_fonts/fonts/pixantiqua.png
--------------------------------------------------------------------------------
/examples/text/raylib_fonts/fonts/pixelplay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/raylib_fonts/fonts/pixelplay.png
--------------------------------------------------------------------------------
/examples/text/raylib_fonts/fonts/romulus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/raylib_fonts/fonts/romulus.png
--------------------------------------------------------------------------------
/examples/text/raylib_fonts/fonts/setback.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/raylib_fonts/fonts/setback.png
--------------------------------------------------------------------------------
/examples/text/sprite_fonts/fonts/custom_alagard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/sprite_fonts/fonts/custom_alagard.png
--------------------------------------------------------------------------------
/examples/text/sprite_fonts/fonts/custom_jupiter_crash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/sprite_fonts/fonts/custom_jupiter_crash.png
--------------------------------------------------------------------------------
/examples/text/sprite_fonts/fonts/custom_mecha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/sprite_fonts/fonts/custom_mecha.png
--------------------------------------------------------------------------------
/examples/text/sprite_fonts/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage")
12 |
13 | msg1 := "THIS IS A custom SPRITE FONT..."
14 | msg2 := "...and this is ANOTHER CUSTOM font..."
15 | msg3 := "...and a THIRD one! GREAT! :D"
16 |
17 | // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
18 | font1 := rl.LoadFont("fonts/custom_mecha.png") // Font loading
19 | font2 := rl.LoadFont("fonts/custom_alagard.png") // Font loading
20 | font3 := rl.LoadFont("fonts/custom_jupiter_crash.png") // Font loading
21 |
22 | var fontPosition1, fontPosition2, fontPosition3 rl.Vector2
23 |
24 | fontPosition1.X = float32(screenWidth)/2 - rl.MeasureTextEx(font1, msg1, float32(font1.BaseSize), -3).X/2
25 | fontPosition1.Y = float32(screenHeight)/2 - float32(font1.BaseSize)/2 - 80
26 |
27 | fontPosition2.X = float32(screenWidth)/2 - rl.MeasureTextEx(font2, msg2, float32(font2.BaseSize), -2).X/2
28 | fontPosition2.Y = float32(screenHeight)/2 - float32(font2.BaseSize)/2 - 10
29 |
30 | fontPosition3.X = float32(screenWidth)/2 - rl.MeasureTextEx(font3, msg3, float32(font3.BaseSize), 2).X/2
31 | fontPosition3.Y = float32(screenHeight)/2 - float32(font3.BaseSize)/2 + 50
32 |
33 | rl.SetTargetFPS(60)
34 |
35 | for !rl.WindowShouldClose() {
36 | rl.BeginDrawing()
37 |
38 | rl.ClearBackground(rl.RayWhite)
39 |
40 | rl.DrawTextEx(font1, msg1, fontPosition1, float32(font1.BaseSize), -3, rl.White)
41 | rl.DrawTextEx(font2, msg2, fontPosition2, float32(font2.BaseSize), -2, rl.White)
42 | rl.DrawTextEx(font3, msg3, fontPosition3, float32(font3.BaseSize), 2, rl.White)
43 |
44 | rl.EndDrawing()
45 | }
46 |
47 | rl.UnloadFont(font1) // Font unloading
48 | rl.UnloadFont(font2) // Font unloading
49 | rl.UnloadFont(font3) // Font unloading
50 |
51 | rl.CloseWindow()
52 | }
53 |
--------------------------------------------------------------------------------
/examples/text/ttf_loading/fonts/KAISG.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/ttf_loading/fonts/KAISG.ttf
--------------------------------------------------------------------------------
/examples/text/unicode/resources/dejavu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/unicode/resources/dejavu.png
--------------------------------------------------------------------------------
/examples/text/unicode/resources/noto_cjk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/unicode/resources/noto_cjk.png
--------------------------------------------------------------------------------
/examples/text/unicode/resources/symbola.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/text/unicode/resources/symbola.png
--------------------------------------------------------------------------------
/examples/text/writing_anim/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim")
12 |
13 | message := "This sample illustrates a text writing\nanimation effect! Check it out! ;)"
14 | length := len(message)
15 |
16 | framesCounter := 0
17 |
18 | rl.SetTargetFPS(60)
19 |
20 | for !rl.WindowShouldClose() {
21 | // Update
22 | if rl.IsKeyDown(rl.KeySpace) {
23 | framesCounter += 8
24 | } else {
25 | framesCounter++
26 | }
27 |
28 | if rl.IsKeyPressed(rl.KeyEnter) {
29 | framesCounter = 0
30 | }
31 |
32 | if framesCounter/10 > length {
33 | framesCounter = length * 10
34 | }
35 |
36 | // Draw
37 | rl.BeginDrawing()
38 |
39 | rl.ClearBackground(rl.RayWhite)
40 |
41 | rl.DrawText(message[0:framesCounter/10], 210, 160, 20, rl.Maroon)
42 |
43 | rl.DrawText("PRESS [ENTER] to RESTART!", 240, 260, 20, rl.LightGray)
44 | rl.DrawText("PRESS [SPACE] to SPEED UP!", 239, 300, 20, rl.LightGray)
45 |
46 | rl.EndDrawing()
47 | }
48 |
49 | rl.CloseWindow()
50 | }
51 |
--------------------------------------------------------------------------------
/examples/textures/background_scrolling/cyberpunk_street_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/background_scrolling/cyberpunk_street_background.png
--------------------------------------------------------------------------------
/examples/textures/background_scrolling/cyberpunk_street_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/background_scrolling/cyberpunk_street_foreground.png
--------------------------------------------------------------------------------
/examples/textures/background_scrolling/cyberpunk_street_midground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/background_scrolling/cyberpunk_street_midground.png
--------------------------------------------------------------------------------
/examples/textures/background_scrolling/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | var (
8 | screenW = int32(1280)
9 | screenH = int32(500)
10 | )
11 |
12 | func main() {
13 |
14 | rl.InitWindow(screenW, screenH, "raylib [textures] example - background scrolling")
15 |
16 | background := rl.LoadTexture("cyberpunk_street_background.png")
17 | midground := rl.LoadTexture("cyberpunk_street_midground.png")
18 | foreground := rl.LoadTexture("cyberpunk_street_foreground.png")
19 |
20 | scrollBack := float32(0)
21 | scrollMid := float32(0)
22 | scrollFore := float32(0)
23 |
24 | rl.SetTargetFPS(60)
25 |
26 | for !rl.WindowShouldClose() {
27 |
28 | scrollBack -= 0.1
29 | scrollMid -= 0.5
30 | scrollFore -= 1
31 |
32 | if scrollBack <= -float32(background.Width)*2 {
33 | scrollBack = 0
34 | }
35 |
36 | if scrollMid <= -float32(midground.Width)*2 {
37 | scrollMid = 0
38 | }
39 |
40 | if scrollFore <= -float32(foreground.Width)*2 {
41 | scrollFore = 0
42 | }
43 |
44 | rl.BeginDrawing()
45 | rl.ClearBackground(rl.RayWhite)
46 |
47 | rl.DrawTextureEx(background, rl.NewVector2(scrollBack, 20), 0, 2, rl.White)
48 | rl.DrawTextureEx(background, rl.NewVector2(float32(background.Width*2)+scrollBack, 20), 0, 2, rl.White)
49 |
50 | rl.DrawTextureEx(midground, rl.NewVector2(scrollMid, 20), 0, 2, rl.White)
51 | rl.DrawTextureEx(midground, rl.NewVector2(float32(midground.Width*2)+scrollMid, 20), 0, 2, rl.White)
52 |
53 | rl.DrawTextureEx(foreground, rl.NewVector2(scrollFore, 20), 0, 2, rl.White)
54 | rl.DrawTextureEx(foreground, rl.NewVector2(float32(foreground.Width*2)+scrollFore, 20), 0, 2, rl.White)
55 |
56 | txt := "BACKGROUND SCROLLING & PARALLAX"
57 | txtlen := rl.MeasureText(txt, 20)
58 | rl.DrawText(txt, (screenW/2)-txtlen/2, screenH-50, 20, rl.Black)
59 | txt = "(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)"
60 | txtlen = rl.MeasureText(txt, 10)
61 | rl.DrawText(txt, (screenW/2)-txtlen/2, screenH-25, 10, rl.Black)
62 |
63 | rl.EndDrawing()
64 | }
65 |
66 | rl.CloseWindow()
67 | }
68 |
--------------------------------------------------------------------------------
/examples/textures/blend_modes/cyberpunk_street_background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/blend_modes/cyberpunk_street_background.png
--------------------------------------------------------------------------------
/examples/textures/blend_modes/cyberpunk_street_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/blend_modes/cyberpunk_street_foreground.png
--------------------------------------------------------------------------------
/examples/textures/draw_tiled/patterns.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/draw_tiled/patterns.png
--------------------------------------------------------------------------------
/examples/textures/image_drawing/cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/image_drawing/cat.png
--------------------------------------------------------------------------------
/examples/textures/image_drawing/parrots.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/image_drawing/parrots.png
--------------------------------------------------------------------------------
/examples/textures/image_image/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "image/png"
5 | "os"
6 |
7 | rl "github.com/gen2brain/raylib-go/raylib"
8 | )
9 |
10 | func main() {
11 | screenWidth := int32(800)
12 | screenHeight := int32(450)
13 |
14 | rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture from image.Image")
15 |
16 | r, err := os.Open("raylib_logo.png")
17 | if err != nil {
18 | rl.TraceLog(rl.LogError, err.Error())
19 | }
20 | defer r.Close()
21 |
22 | img, err := png.Decode(r)
23 | if err != nil {
24 | rl.TraceLog(rl.LogError, err.Error())
25 | }
26 |
27 | // Create rl.Image from Go image.Image and create texture
28 | im := rl.NewImageFromImage(img)
29 | texture := rl.LoadTextureFromImage(im)
30 |
31 | // Unload CPU (RAM) image data
32 | rl.UnloadImage(im)
33 |
34 | rl.SetTargetFPS(60)
35 |
36 | for !rl.WindowShouldClose() {
37 | if rl.IsKeyPressed(rl.KeyS) {
38 | rimg := rl.LoadImageFromTexture(texture)
39 |
40 | f, err := os.Create("image_saved.png")
41 | if err != nil {
42 | rl.TraceLog(rl.LogError, err.Error())
43 | }
44 |
45 | err = png.Encode(f, rimg.ToImage())
46 | if err != nil {
47 | rl.TraceLog(rl.LogError, err.Error())
48 | }
49 |
50 | f.Close()
51 | }
52 |
53 | rl.BeginDrawing()
54 |
55 | rl.ClearBackground(rl.RayWhite)
56 |
57 | rl.DrawText("PRESS S TO SAVE IMAGE FROM TEXTURE", 20, 20, 12, rl.LightGray)
58 | rl.DrawTexture(texture, screenWidth/2-texture.Width/2, screenHeight/2-texture.Height/2, rl.White)
59 | rl.DrawText("this IS a texture loaded from an image.Image!", 285, 370, 10, rl.Gray)
60 |
61 | rl.EndDrawing()
62 | }
63 |
64 | rl.UnloadTexture(texture)
65 |
66 | rl.CloseWindow()
67 | }
68 |
--------------------------------------------------------------------------------
/examples/textures/image_image/raylib_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/image_image/raylib_logo.png
--------------------------------------------------------------------------------
/examples/textures/image_loading/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - image loading")
12 |
13 | // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
14 |
15 | image := rl.LoadImage("raylib_logo.png") // Loaded in CPU memory (RAM)
16 | texture := rl.LoadTextureFromImage(image) // Image converted to texture, GPU memory (VRAM)
17 |
18 | rl.UnloadImage(image) // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
19 |
20 | rl.SetTargetFPS(60)
21 |
22 | for !rl.WindowShouldClose() {
23 | rl.BeginDrawing()
24 |
25 | rl.ClearBackground(rl.RayWhite)
26 |
27 | rl.DrawTexture(texture, screenWidth/2-texture.Width/2, screenHeight/2-texture.Height/2, rl.White)
28 |
29 | rl.DrawText("this IS a texture loaded from an image!", 300, 370, 10, rl.Gray)
30 |
31 | rl.EndDrawing()
32 | }
33 |
34 | rl.UnloadTexture(texture)
35 |
36 | rl.CloseWindow()
37 | }
38 |
--------------------------------------------------------------------------------
/examples/textures/image_loading/raylib_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/image_loading/raylib_logo.png
--------------------------------------------------------------------------------
/examples/textures/image_processing/parrots.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/image_processing/parrots.png
--------------------------------------------------------------------------------
/examples/textures/image_text/fonts/KAISG.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/image_text/fonts/KAISG.ttf
--------------------------------------------------------------------------------
/examples/textures/image_text/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - image text drawing")
12 |
13 | // TTF Font loading with custom generation parameters
14 | font := rl.LoadFontEx("fonts/KAISG.ttf", 64, nil)
15 |
16 | parrots := rl.LoadImage("parrots.png") // Load image in CPU memory (RAM)
17 |
18 | // Draw over image using custom font
19 | rl.ImageDrawTextEx(parrots, rl.NewVector2(20, 20), font, "[Parrots font drawing]", float32(font.BaseSize), 0, rl.White)
20 |
21 | texture := rl.LoadTextureFromImage(parrots) // Image converted to texture, uploaded to GPU memory (VRAM)
22 |
23 | rl.UnloadImage(parrots) // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
24 |
25 | position := rl.NewVector2(float32(screenWidth)/2-float32(texture.Width)/2, float32(screenHeight)/2-float32(texture.Height)/2-20)
26 |
27 | showFont := false
28 |
29 | rl.SetTargetFPS(60)
30 |
31 | for !rl.WindowShouldClose() {
32 | if rl.IsKeyDown(rl.KeySpace) {
33 | showFont = true
34 | } else {
35 | showFont = false
36 | }
37 |
38 | rl.BeginDrawing()
39 |
40 | rl.ClearBackground(rl.RayWhite)
41 |
42 | if !showFont {
43 | // Draw texture with text already drawn inside
44 | rl.DrawTextureV(texture, position, rl.White)
45 |
46 | // Draw text directly using sprite font
47 | rl.DrawTextEx(font, "[Parrots font drawing]", rl.NewVector2(position.X+20, position.Y+20+280), float32(font.BaseSize), 0, rl.White)
48 | } else {
49 | rl.DrawTexture(font.Texture, screenWidth/2-font.Texture.Width/2, 50, rl.Black)
50 | }
51 |
52 | rl.DrawText("PRESS SPACE to SEE USED SPRITEFONT ", 290, 420, 10, rl.DarkGray)
53 |
54 | rl.EndDrawing()
55 | }
56 |
57 | rl.UnloadTexture(texture)
58 | rl.UnloadFont(font)
59 |
60 | rl.CloseWindow()
61 | }
62 |
--------------------------------------------------------------------------------
/examples/textures/image_text/parrots.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/image_text/parrots.png
--------------------------------------------------------------------------------
/examples/textures/logo_raylib/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing")
12 |
13 | // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
14 | texture := rl.LoadTexture("raylib_logo.png")
15 |
16 | rl.SetTargetFPS(60)
17 |
18 | for !rl.WindowShouldClose() {
19 | rl.BeginDrawing()
20 |
21 | rl.ClearBackground(rl.RayWhite)
22 | rl.DrawTexture(texture, screenWidth/2-texture.Width/2, screenHeight/2-texture.Height/2, rl.White)
23 | rl.DrawText("this IS a texture!", 360, 370, 10, rl.Gray)
24 |
25 | rl.EndDrawing()
26 | }
27 |
28 | rl.UnloadTexture(texture)
29 |
30 | rl.CloseWindow()
31 | }
32 |
--------------------------------------------------------------------------------
/examples/textures/logo_raylib/raylib_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/logo_raylib/raylib_logo.png
--------------------------------------------------------------------------------
/examples/textures/npatch_drawing/ninepatch_button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/npatch_drawing/ninepatch_button.png
--------------------------------------------------------------------------------
/examples/textures/particles_blending/smoke.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/particles_blending/smoke.png
--------------------------------------------------------------------------------
/examples/textures/raw_data/texture_formats/fudesumi.raw:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/raw_data/texture_formats/fudesumi.raw
--------------------------------------------------------------------------------
/examples/textures/sprite_button/button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/sprite_button/button.png
--------------------------------------------------------------------------------
/examples/textures/sprite_button/buttonfx.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/sprite_button/buttonfx.wav
--------------------------------------------------------------------------------
/examples/textures/sprite_explosion/boom.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/sprite_explosion/boom.wav
--------------------------------------------------------------------------------
/examples/textures/sprite_explosion/explosion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/sprite_explosion/explosion.png
--------------------------------------------------------------------------------
/examples/textures/sprite_explosion/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | var (
8 | numFramesPerLine, numLines = 5, 5
9 | )
10 |
11 | func main() {
12 | screenWidth := int32(1280)
13 | screenHeight := int32(720)
14 |
15 | rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - sprite explosion")
16 |
17 | rl.InitAudioDevice()
18 | fxBoom := rl.LoadSound("boom.wav")
19 | explosion := rl.LoadTexture("explosion.png")
20 |
21 | frameW := float32(explosion.Width / int32(numFramesPerLine))
22 | frameH := float32(explosion.Height / int32(numLines))
23 |
24 | currentFrame, currentLine := 0, 0
25 |
26 | frameRec := rl.NewRectangle(0, 0, frameW, frameH)
27 | position := rl.NewVector2(0, 0)
28 |
29 | active := false
30 | framesCount := 0
31 |
32 | rl.SetTargetFPS(120)
33 |
34 | for !rl.WindowShouldClose() {
35 |
36 | if rl.IsMouseButtonPressed(rl.MouseLeftButton) && !active {
37 | position = rl.GetMousePosition()
38 | active = true
39 | position.X -= frameW / 2
40 | position.Y -= frameH / 2
41 | rl.PlaySound(fxBoom)
42 | }
43 |
44 | if active {
45 | framesCount++
46 | if framesCount > 2 {
47 | currentFrame++
48 | if currentFrame >= numFramesPerLine {
49 | currentFrame = 0
50 | currentLine++
51 | if currentLine >= numLines {
52 | currentLine = 0
53 | active = false
54 | }
55 | }
56 |
57 | framesCount = 0
58 | }
59 | }
60 |
61 | frameRec.X = frameW * float32(currentFrame)
62 | frameRec.Y = frameH * float32(currentLine)
63 |
64 | rl.BeginDrawing()
65 | rl.ClearBackground(rl.RayWhite)
66 |
67 | rl.DrawText("click left mouse on screen to explode", 19, 21, 20, rl.Red)
68 | rl.DrawText("click left mouse on screen to explode", 20, 20, 20, rl.Black)
69 |
70 | if active {
71 | rl.DrawTextureRec(explosion, frameRec, position, rl.White)
72 | }
73 |
74 | rl.EndDrawing()
75 | }
76 |
77 | rl.UnloadTexture(explosion)
78 | rl.UnloadSound(fxBoom)
79 | rl.CloseAudioDevice()
80 |
81 | rl.CloseWindow()
82 | }
83 |
--------------------------------------------------------------------------------
/examples/textures/srcrec_dstrec/scarfy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/srcrec_dstrec/scarfy.png
--------------------------------------------------------------------------------
/examples/textures/textured_curve/road.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/textured_curve/road.png
--------------------------------------------------------------------------------
/examples/textures/textures_gif_player/scarfy_run.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/textures_gif_player/scarfy_run.gif
--------------------------------------------------------------------------------
/examples/textures/textures_sprite_anim/scarfy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/textures_sprite_anim/scarfy.png
--------------------------------------------------------------------------------
/examples/textures/to_image/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | rl "github.com/gen2brain/raylib-go/raylib"
5 | )
6 |
7 | func main() {
8 | screenWidth := int32(800)
9 | screenHeight := int32(450)
10 |
11 | rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture to image")
12 |
13 | image := rl.LoadImage("raylib_logo.png") // Load image data into CPU memory (RAM)
14 | texture := rl.LoadTextureFromImage(image) // Image converted to texture, GPU memory (RAM -> VRAM)
15 | rl.UnloadImage(image) // Unload image data from CPU memory (RAM)
16 |
17 | image = rl.LoadImageFromTexture(texture) // Retrieve image data from GPU memory (VRAM -> RAM)
18 | rl.UnloadTexture(texture) // Unload texture from GPU memory (VRAM)
19 |
20 | texture = rl.LoadTextureFromImage(image) // Recreate texture from retrieved image data (RAM -> VRAM)
21 | rl.UnloadImage(image) // Unload retrieved image data from CPU memory (RAM)
22 |
23 | rl.SetTargetFPS(60)
24 |
25 | for !rl.WindowShouldClose() {
26 | rl.BeginDrawing()
27 |
28 | rl.ClearBackground(rl.RayWhite)
29 |
30 | rl.DrawTexture(texture, screenWidth/2-texture.Width/2, screenHeight/2-texture.Height/2, rl.White)
31 | rl.DrawText("this IS a texture loaded from an image!", 300, 370, 10, rl.Gray)
32 |
33 | rl.EndDrawing()
34 | }
35 |
36 | rl.UnloadTexture(texture)
37 |
38 | rl.CloseWindow()
39 | }
40 |
--------------------------------------------------------------------------------
/examples/textures/to_image/raylib_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gen2brain/raylib-go/fca3bf26c5680238753ee90d6c2905805d87127a/examples/textures/to_image/raylib_logo.png
--------------------------------------------------------------------------------
/physics/README.md:
--------------------------------------------------------------------------------
1 | ## physics [](https://godoc.org/github.com/gen2brain/raylib-go/physics)
2 |
3 | 2D Physics library for videogames.
4 |
5 | A port of Victor Fisac's [physac engine](https://github.com/raysan5/physac/blob/master/src/physac.h).
6 |
--------------------------------------------------------------------------------
/physics/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/gen2brain/raylib-go/physics
2 |
3 | go 1.21
4 |
5 | require github.com/gen2brain/raylib-go/raylib v0.0.0-20241202103652-5d50abe7c65b
6 |
7 | require (
8 | github.com/ebitengine/purego v0.8.1 // indirect
9 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
10 | golang.org/x/sys v0.27.0 // indirect
11 | )
12 |
--------------------------------------------------------------------------------
/physics/go.sum:
--------------------------------------------------------------------------------
1 | github.com/ebitengine/purego v0.8.1 h1:sdRKd6plj7KYW33EH5As6YKfe8m9zbN9JMrOjNVF/BE=
2 | github.com/ebitengine/purego v0.8.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
3 | github.com/gen2brain/raylib-go/raylib v0.0.0-20241202103652-5d50abe7c65b h1:wK8D9x3f+BX1xFGgjj399dYx2eskikDZHxlRaSSA19Q=
4 | github.com/gen2brain/raylib-go/raylib v0.0.0-20241202103652-5d50abe7c65b/go.mod h1:BaY76bZk7nw1/kVOSQObPY1v1iwVE1KHAGMfvI6oK1Q=
5 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
6 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
7 | golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
8 | golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
9 |
--------------------------------------------------------------------------------
/raygui/README.md:
--------------------------------------------------------------------------------
1 | ## raygui [](https://godoc.org/github.com/gen2brain/raylib-go/raygui)
2 |
3 | raygui is simple and easy-to-use IMGUI (immediate mode GUI API) library.
4 |
5 |
6 | ### controls_test_suite
7 |
8 | 
9 |
10 |
11 | ### scroll_panel
12 |
13 | 
14 |
--------------------------------------------------------------------------------
/raygui/cgo.go:
--------------------------------------------------------------------------------
1 | package raygui
2 |
3 | /*
4 | #cgo CFLAGS: -std=gnu99 -Wno-unused-result
5 | */
6 | import "C"
7 |
--------------------------------------------------------------------------------
/raygui/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/gen2brain/raylib-go/raygui
2 |
3 | go 1.21
4 |
5 | require github.com/gen2brain/raylib-go/raylib v0.0.0-20241202103652-5d50abe7c65b
6 |
7 | require (
8 | github.com/ebitengine/purego v0.8.1 // indirect
9 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
10 | golang.org/x/sys v0.27.0 // indirect
11 | )
12 |
--------------------------------------------------------------------------------
/raygui/go.sum:
--------------------------------------------------------------------------------
1 | github.com/ebitengine/purego v0.8.1 h1:sdRKd6plj7KYW33EH5As6YKfe8m9zbN9JMrOjNVF/BE=
2 | github.com/ebitengine/purego v0.8.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
3 | github.com/gen2brain/raylib-go/raylib v0.0.0-20241202103652-5d50abe7c65b h1:wK8D9x3f+BX1xFGgjj399dYx2eskikDZHxlRaSSA19Q=
4 | github.com/gen2brain/raylib-go/raylib v0.0.0-20241202103652-5d50abe7c65b/go.mod h1:BaY76bZk7nw1/kVOSQObPY1v1iwVE1KHAGMfvI6oK1Q=
5 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
6 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
7 | golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
8 | golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
9 |
--------------------------------------------------------------------------------
/raylib/cgo.go:
--------------------------------------------------------------------------------
1 | package rl
2 |
3 | /*
4 | #cgo CFLAGS: -std=gnu99 -Wno-missing-braces -Wno-unused-result -Wno-implicit-function-declaration -Wno-int-to-pointer-cast
5 | */
6 | import "C"
7 |
--------------------------------------------------------------------------------
/raylib/cgo_android.go:
--------------------------------------------------------------------------------
1 | //go:build android
2 | // +build android
3 |
4 | package rl
5 |
6 | /*
7 | #include "external/android/native_app_glue/android_native_app_glue.c"
8 |
9 | #cgo android LDFLAGS: -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lm
10 | #cgo android CFLAGS: -DPLATFORM_ANDROID -DGRAPHICS_API_OPENGL_ES2 -Iexternal/android/native_app_glue -Wno-implicit-const-int-float-conversion
11 |
12 | #cgo android,arm CFLAGS: -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
13 | */
14 | import "C"
15 |
--------------------------------------------------------------------------------
/raylib/cgo_darwin.go:
--------------------------------------------------------------------------------
1 | //go:build darwin && !rgfw && !sdl && !sdl3
2 | // +build darwin,!rgfw,!sdl,!sdl3
3 |
4 | package rl
5 |
6 | /*
7 | #include "external/glfw/src/context.c"
8 | #include "external/glfw/src/init.c"
9 | #include "external/glfw/src/input.c"
10 | #include "external/glfw/src/monitor.c"
11 | #include "external/glfw/src/platform.c"
12 | #include "external/glfw/src/vulkan.c"
13 | #include "external/glfw/src/window.c"
14 |
15 | #include "external/glfw/src/cocoa_init.m"
16 | #include "external/glfw/src/cocoa_joystick.m"
17 | #include "external/glfw/src/cocoa_monitor.m"
18 | #include "external/glfw/src/cocoa_time.c"
19 | #include "external/glfw/src/cocoa_window.m"
20 | #include "external/glfw/src/posix_module.c"
21 | #include "external/glfw/src/posix_thread.c"
22 | #include "external/glfw/src/nsgl_context.m"
23 | #include "external/glfw/src/egl_context.c"
24 | #include "external/glfw/src/osmesa_context.c"
25 |
26 | GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform) {
27 | return GLFW_TRUE;
28 | }
29 |
30 | #cgo darwin LDFLAGS: -framework Cocoa -framework IOKit -framework CoreVideo -framework CoreFoundation
31 | #cgo darwin CFLAGS: -x objective-c -Iexternal/glfw/include -D_GLFW_COCOA -D_GLFW_USE_CHDIR -D_GLFW_USE_MENUBAR -D_GLFW_USE_RETINA -Wno-deprecated-declarations -Wno-implicit-const-int-float-conversion -DPLATFORM_DESKTOP
32 |
33 | #cgo darwin,!es2,!es3 LDFLAGS: -framework OpenGL
34 |
35 | #cgo darwin,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
36 | #cgo darwin,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
37 | #cgo darwin,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
38 | #cgo darwin,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
39 | #cgo darwin,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
40 | #cgo darwin,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
41 | */
42 | import "C"
43 |
--------------------------------------------------------------------------------
/raylib/cgo_darwin_rgfw.go:
--------------------------------------------------------------------------------
1 | //go:build darwin && rgfw && !sdl && !sdl3
2 | // +build darwin,rgfw,!sdl,!sdl3
3 |
4 | package rl
5 |
6 | /*
7 | #cgo darwin LDFLAGS: -framework Foundation -framework AppKit -framework CoreVideo
8 | #cgo darwin CFLAGS: -DPLATFORM_DESKTOP_RGFW -Wno-deprecated-declarations -Wno-implicit-const-int-float-conversion -Wno-typedef-redefinition -Wno-extern-initializer -Wno-unused-value
9 | #cgo darwin CFLAGS: -Wno-incompatible-pointer-types -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types-discards-qualifiers -Wno-macro-redefined
10 |
11 | #cgo darwin,!es2,!es3 LDFLAGS: -framework OpenGL
12 |
13 | #cgo darwin,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
14 | #cgo darwin,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
15 | #cgo darwin,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
16 | #cgo darwin,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
17 | #cgo darwin,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
18 | #cgo darwin,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
19 | */
20 | import "C"
21 |
--------------------------------------------------------------------------------
/raylib/cgo_darwin_sdl.go:
--------------------------------------------------------------------------------
1 | //go:build darwin && (sdl || sdl3) && !rgfw
2 | // +build darwin
3 | // +build sdl sdl3
4 | // +build !rgfw
5 |
6 | package rl
7 |
8 | /*
9 | #cgo darwin LDFLAGS: -framework Cocoa -framework IOKit -framework CoreVideo -framework CoreFoundation
10 | #cgo darwin CFLAGS: -Wno-deprecated-declarations -Wno-implicit-const-int-float-conversion
11 | #cgo darwin,sdl CFLAGS: -DPLATFORM_DESKTOP_SDL
12 | #cgo darwin,sdl3 CFLAGS: -DPLATFORM_DESKTOP_SDL -DPLATFORM_DESKTOP_SDL3
13 | #cgo darwin,sdl pkg-config: sdl2
14 | #cgo darwin,sdl3 pkg-config: sdl3
15 |
16 | #cgo darwin,!es2,!es3 LDFLAGS: -framework OpenGL
17 |
18 | #cgo darwin,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
19 | #cgo darwin,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
20 | #cgo darwin,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
21 | #cgo darwin,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
22 | #cgo darwin,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
23 | #cgo darwin,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
24 | */
25 | import "C"
26 |
--------------------------------------------------------------------------------
/raylib/cgo_freebsd.go:
--------------------------------------------------------------------------------
1 | //go:build freebsd && !linux && !rgfw && !drm && !sdl && !sdl3 && !android
2 | // +build freebsd,!linux,!rgfw,!drm,!sdl,!sdl3,!android
3 |
4 | package rl
5 |
6 | /*
7 | #include "external/glfw/src/context.c"
8 | #include "external/glfw/src/init.c"
9 | #include "external/glfw/src/input.c"
10 | #include "external/glfw/src/monitor.c"
11 | #include "external/glfw/src/platform.c"
12 | #include "external/glfw/src/vulkan.c"
13 | #include "external/glfw/src/window.c"
14 |
15 | #include "external/glfw/src/x11_init.c"
16 | #include "external/glfw/src/x11_monitor.c"
17 | #include "external/glfw/src/x11_window.c"
18 | #include "external/glfw/src/glx_context.c"
19 |
20 | #include "external/glfw/src/null_joystick.c"
21 | #include "external/glfw/src/posix_module.c"
22 | #include "external/glfw/src/posix_poll.c"
23 | #include "external/glfw/src/posix_thread.c"
24 | #include "external/glfw/src/posix_time.c"
25 | #include "external/glfw/src/xkb_unicode.c"
26 | #include "external/glfw/src/egl_context.c"
27 | #include "external/glfw/src/osmesa_context.c"
28 |
29 | GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform) {
30 | return GLFW_TRUE;
31 | }
32 |
33 | #cgo freebsd CFLAGS: -I. -I/usr/local/include -Iexternal/glfw/include -DPLATFORM_DESKTOP -D_GLFW_X11
34 | #cgo freebsd LDFLAGS: -L/usr/local/lib -lm -pthread -ldl -lrt -lX11
35 |
36 | #cgo freebsd,!es2,!es3 LDFLAGS: -lGL
37 |
38 | #cgo freebsd,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
39 | #cgo freebsd,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
40 | #cgo freebsd,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
41 | #cgo freebsd,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
42 | #cgo freebsd,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
43 | #cgo freebsd,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
44 | */
45 | import "C"
46 |
--------------------------------------------------------------------------------
/raylib/cgo_freebsd_rgfw.go:
--------------------------------------------------------------------------------
1 | //go:build freebsd && rgfw && !linux && !drm && !sdl && !sdl3 && !android
2 | // +build freebsd,rgfw,!linux,!drm,!sdl,!sdl3,!android
3 |
4 | package rl
5 |
6 | /*
7 | #cgo freebsd CFLAGS: -I. -I/usr/local/include -DPLATFORM_DESKTOP_RGFW
8 | #cgo freebsd LDFLAGS: -L/usr/local/lib -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -lpthread -ldl -lrt
9 |
10 | #cgo freebsd,!es2,!es3 LDFLAGS: -lGL
11 |
12 | #cgo freebsd,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
13 | #cgo freebsd,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
14 | #cgo freebsd,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
15 | #cgo freebsd,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
16 | #cgo freebsd,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
17 | #cgo freebsd,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
18 | */
19 | import "C"
20 |
--------------------------------------------------------------------------------
/raylib/cgo_freebsd_sdl.go:
--------------------------------------------------------------------------------
1 | //go:build freebsd && !linux && (sdl || sdl3) && !rgfw && !drm && !android
2 | // +build freebsd
3 | // +build !linux
4 | // +build sdl sdl3
5 | // +build !rgfw
6 | // +build !drm
7 | // +build !android
8 |
9 | package rl
10 |
11 | /*
12 | #cgo freebsd CFLAGS: -I. -I/usr/local/include
13 | #cgo freebsd,sdl CFLAGS: -DPLATFORM_DESKTOP_SDL
14 | #cgo freebsd,sdl3 CFLAGS: -DPLATFORM_DESKTOP_SDL -DPLATFORM_DESKTOP_SDL3
15 | #cgo freebsd LDFLAGS: -L/usr/local/lib
16 |
17 | #cgo freebsd,sdl pkg-config: sdl2
18 | #cgo freebsd,sdl3 pkg-config: sdl3
19 |
20 | #cgo freebsd,!es2,!es3 LDFLAGS: -lGL
21 |
22 | #cgo freebsd,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
23 | #cgo freebsd,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
24 | #cgo freebsd,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
25 | #cgo freebsd,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
26 | #cgo freebsd,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
27 | #cgo freebsd,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
28 | */
29 | import "C"
30 |
--------------------------------------------------------------------------------
/raylib/cgo_linux_drm.go:
--------------------------------------------------------------------------------
1 | //go:build linux && drm && !rgfw && !sdl && !sdl3 && !android
2 | // +build linux,drm,!rgfw,!sdl,!sdl3,!android
3 |
4 | package rl
5 |
6 | /*
7 | #cgo linux,drm LDFLAGS: -lGLESv2 -lEGL -ldrm -lgbm -lpthread -lrt -lm -ldl
8 | #cgo linux,drm CFLAGS: -DPLATFORM_DRM -DGRAPHICS_API_OPENGL_ES2 -DEGL_NO_X11 -I/usr/include/libdrm
9 | */
10 | import "C"
11 |
--------------------------------------------------------------------------------
/raylib/cgo_linux_rgfw.go:
--------------------------------------------------------------------------------
1 | //go:build linux && rgfw && !drm && !sdl && !sdl3 && !android
2 | // +build linux,rgfw,!drm,!sdl,!sdl3,!android
3 |
4 | package rl
5 |
6 | /*
7 | #cgo linux,!es2 LDFLAGS: -lm
8 | #cgo linux CFLAGS: -DPLATFORM_DESKTOP_RGFW -Wno-builtin-declaration-mismatch -Wno-discarded-qualifiers -Wno-int-conversion
9 | #cgo linux LDFLAGS: -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -lpthread -ldl -lrt
10 |
11 | #cgo linux,!es2,!es3 LDFLAGS: -lGL
12 |
13 | #cgo linux,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
14 | #cgo linux,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
15 | #cgo linux,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
16 | #cgo linux,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
17 | #cgo linux,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
18 | #cgo linux,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
19 | */
20 | import "C"
21 |
--------------------------------------------------------------------------------
/raylib/cgo_linux_sdl.go:
--------------------------------------------------------------------------------
1 | //go:build linux && (sdl || sdl3) && !rgfw && !drm && !android
2 | // +build linux
3 | // +build sdl sdl3
4 | // +build !rgfw
5 | // +build !drm
6 | // +build !android
7 |
8 | package rl
9 |
10 | /*
11 | #cgo linux,!es2 LDFLAGS: -lm
12 | #cgo linux CFLAGS: -Wno-stringop-overflow
13 | #cgo linux,sdl CFLAGS: -DPLATFORM_DESKTOP_SDL
14 | #cgo linux,sdl3 CFLAGS: -DPLATFORM_DESKTOP_SDL -DPLATFORM_DESKTOP_SDL3
15 | #cgo linux,sdl pkg-config: sdl2
16 | #cgo linux,sdl3 pkg-config: sdl3
17 |
18 | #cgo linux,!es2,!es3 LDFLAGS: -lGL
19 |
20 | #cgo linux,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
21 | #cgo linux,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
22 | #cgo linux,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
23 | #cgo linux,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
24 | #cgo linux,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
25 | #cgo linux,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
26 | */
27 | import "C"
28 |
--------------------------------------------------------------------------------
/raylib/cgo_openbsd.go:
--------------------------------------------------------------------------------
1 | //go:build openbsd && !linux && !rgfw && !drm && !sdl && !sdl3 && !android
2 | // +build openbsd,!linux,!rgfw,!drm,!sdl,!sdl3,!android
3 |
4 | package rl
5 |
6 | /*
7 | #include "external/glfw/src/context.c"
8 | #include "external/glfw/src/init.c"
9 | #include "external/glfw/src/input.c"
10 | #include "external/glfw/src/monitor.c"
11 | #include "external/glfw/src/platform.c"
12 | #include "external/glfw/src/vulkan.c"
13 | #include "external/glfw/src/window.c"
14 |
15 | #include "external/glfw/src/x11_init.c"
16 | #include "external/glfw/src/x11_monitor.c"
17 | #include "external/glfw/src/x11_window.c"
18 | #include "external/glfw/src/glx_context.c"
19 |
20 | #include "external/glfw/src/null_joystick.c"
21 | #include "external/glfw/src/posix_module.c"
22 | #include "external/glfw/src/posix_poll.c"
23 | #include "external/glfw/src/posix_thread.c"
24 | #include "external/glfw/src/posix_time.c"
25 | #include "external/glfw/src/xkb_unicode.c"
26 | #include "external/glfw/src/egl_context.c"
27 | #include "external/glfw/src/osmesa_context.c"
28 |
29 | GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform) {
30 | return GLFW_TRUE;
31 | }
32 |
33 | #cgo openbsd CFLAGS: -I. -I/usr/X11R6/include -Iexternal/glfw/include -DPLATFORM_DESKTOP -D_GLFW_X11
34 | #cgo openbsd LDFLAGS: -L/usr/X11R6/lib -lm -pthread -lX11
35 |
36 | #cgo openbsd,!es2,!es3 LDFLAGS: -lGL
37 |
38 | #cgo openbsd,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
39 | #cgo openbsd,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
40 | #cgo openbsd,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
41 | #cgo openbsd,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
42 | #cgo openbsd,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
43 | #cgo openbsd,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
44 | */
45 | import "C"
46 |
--------------------------------------------------------------------------------
/raylib/cgo_openbsd_rgfw.go:
--------------------------------------------------------------------------------
1 | //go:build openbsd && rgfw && !linux && !sdl && !sdl3 && !drm && !android
2 | // +build openbsd,rgfw,!linux,!sdl,!sdl3,!drm,!android
3 |
4 | package rl
5 |
6 | /*
7 | #cgo openbsd CFLAGS: -I. -I/usr/X11R6/include -DPLATFORM_DESKTOP_RGFW
8 | #cgo openbsd LDFLAGS: -L/usr/X11R6/lib -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -lpthread -ldl -lrt
9 |
10 | #cgo openbsd,!es2,!es3 LDFLAGS: -lGL
11 |
12 | #cgo openbsd,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
13 | #cgo openbsd,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
14 | #cgo openbsd,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
15 | #cgo openbsd,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
16 | #cgo openbsd,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
17 | #cgo openbsd,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
18 | */
19 | import "C"
20 |
--------------------------------------------------------------------------------
/raylib/cgo_openbsd_sdl.go:
--------------------------------------------------------------------------------
1 | //go:build openbsd && !linux && (sdl || sdl3) && !rgfw && !drm && !android
2 | // +build openbsd
3 | // +build !linux
4 | // +build sdl sdl3
5 | // +build !rgfw
6 | // +build !drm
7 | // +build !android
8 |
9 | package rl
10 |
11 | /*
12 | #cgo openbsd CFLAGS: -I. -I/usr/X11R6/include
13 | #cgo openbsd,sdl CFLAGS: -DPLATFORM_DESKTOP_SDL
14 | #cgo openbsd,sdl3 CFLAGS: -DPLATFORM_DESKTOP_SDL -DPLATFORM_DESKTOP_SDL3
15 | #cgo openbsd LDFLAGS: -L/usr/X11R6/lib
16 |
17 | #cgo openbsd,sdl pkg-config: sdl2
18 | #cgo openbsd,sdl3 pkg-config: sdl3
19 |
20 | #cgo openbsd,!es2,!es3 LDFLAGS: -lGL
21 |
22 | #cgo openbsd,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
23 | #cgo openbsd,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
24 | #cgo openbsd,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
25 | #cgo openbsd,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
26 | #cgo openbsd,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
27 | #cgo openbsd,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
28 | */
29 | import "C"
30 |
--------------------------------------------------------------------------------
/raylib/cgo_vendor.go:
--------------------------------------------------------------------------------
1 | //go:build required
2 | // +build required
3 |
4 | package rl
5 |
6 | import (
7 | _ "github.com/gen2brain/raylib-go/raylib/external"
8 | _ "github.com/gen2brain/raylib-go/raylib/external/android/native_app_glue"
9 | _ "github.com/gen2brain/raylib-go/raylib/external/glfw/include/GLFW"
10 | _ "github.com/gen2brain/raylib-go/raylib/external/glfw/src"
11 | _ "github.com/gen2brain/raylib-go/raylib/platforms"
12 | )
13 |
--------------------------------------------------------------------------------
/raylib/cgo_windows.go:
--------------------------------------------------------------------------------
1 | //go:build windows && !rgfw && !sdl && !sdl3
2 | // +build windows,!rgfw,!sdl,!sdl3
3 |
4 | package rl
5 |
6 | /*
7 | #include "external/glfw/src/context.c"
8 | #include "external/glfw/src/init.c"
9 | #include "external/glfw/src/input.c"
10 | #include "external/glfw/src/monitor.c"
11 | #include "external/glfw/src/platform.c"
12 | #include "external/glfw/src/vulkan.c"
13 | #include "external/glfw/src/window.c"
14 |
15 | #include "external/glfw/src/win32_init.c"
16 | #include "external/glfw/src/win32_joystick.c"
17 | #include "external/glfw/src/win32_module.c"
18 | #include "external/glfw/src/win32_monitor.c"
19 | #include "external/glfw/src/win32_thread.c"
20 | #include "external/glfw/src/win32_time.c"
21 | #include "external/glfw/src/win32_window.c"
22 | #include "external/glfw/src/wgl_context.c"
23 | #include "external/glfw/src/egl_context.c"
24 | #include "external/glfw/src/osmesa_context.c"
25 |
26 | GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform) {
27 | return GLFW_TRUE;
28 | }
29 |
30 | #cgo windows LDFLAGS: -lgdi32 -lwinmm -lole32
31 | #cgo windows CFLAGS: -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP -D_GLFW_WIN32 -Wno-stringop-overflow
32 |
33 | #cgo windows,!es2,!es3 LDFLAGS: -lopengl32
34 |
35 | #cgo windows,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
36 | #cgo windows,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
37 | #cgo windows,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
38 | #cgo windows,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
39 | #cgo windows,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
40 | #cgo windows,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
41 | */
42 | import "C"
43 |
--------------------------------------------------------------------------------
/raylib/cgo_windows_rgfw.go:
--------------------------------------------------------------------------------
1 | //go:build windows && rgfw && !sdl && !sdl3
2 | // +build windows,rgfw,!sdl,!sdl3
3 |
4 | package rl
5 |
6 | /*
7 | #cgo windows LDFLAGS: -lgdi32 -lwinmm
8 | #cgo windows CFLAGS: -Iexternal -DPLATFORM_DESKTOP_RGFW -Wno-stringop-overflow -Wno-discarded-qualifiers
9 |
10 | #cgo windows,!es2,!es3 LDFLAGS: -lopengl32
11 |
12 | #cgo windows,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
13 | #cgo windows,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
14 | #cgo windows,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
15 | #cgo windows,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
16 | #cgo windows,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
17 | #cgo windows,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
18 | */
19 | import "C"
20 |
--------------------------------------------------------------------------------
/raylib/cgo_windows_sdl.go:
--------------------------------------------------------------------------------
1 | //go:build windows && (sdl || sdl3) && !rgfw
2 | // +build windows
3 | // +build sdl sdl3
4 | // +build !rgfw
5 |
6 | package rl
7 |
8 | /*
9 | #cgo windows LDFLAGS: -lgdi32 -lwinmm -lole32
10 | #cgo windows,sdl LDFLAGS: -lSDL2
11 | #cgo windows,sdl3 LDFLAGS: -lSDL3
12 | #cgo windows CFLAGS: -Iexternal -Wno-stringop-overflow
13 | #cgo windows,sdl CFLAGS: -DPLATFORM_DESKTOP_SDL
14 | #cgo windows,sdl3 CFLAGS: -DPLATFORM_DESKTOP_SDL -DPLATFORM_DESKTOP_SDL3
15 |
16 | #cgo windows,!es2,!es3 LDFLAGS: -lopengl32
17 |
18 | #cgo windows,opengl11,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_11
19 | #cgo windows,opengl21,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_21
20 | #cgo windows,opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_43
21 | #cgo windows,!opengl11,!opengl21,!opengl43,!es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_33
22 | #cgo windows,es2,!es3 CFLAGS: -DGRAPHICS_API_OPENGL_ES2
23 | #cgo windows,es3,!es2 CFLAGS: -DGRAPHICS_API_OPENGL_ES3
24 | */
25 | import "C"
26 |
--------------------------------------------------------------------------------
/raylib/external/android/native_app_glue/NOTICE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2016 The Android Open Source Project
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/raylib/external/android/native_app_glue/vendor.go:
--------------------------------------------------------------------------------
1 | //go:build required
2 | // +build required
3 |
4 | package vendor
5 |
--------------------------------------------------------------------------------
/raylib/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 |
--------------------------------------------------------------------------------
/raylib/external/glfw/include/GLFW/vendor.go:
--------------------------------------------------------------------------------
1 | //go:build required
2 | // +build required
3 |
4 | package vendor
5 |
--------------------------------------------------------------------------------
/raylib/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 |
31 | #define GLFW_COCOA_JOYSTICK_STATE _GLFWjoystickNS ns;
32 | #define GLFW_COCOA_LIBRARY_JOYSTICK_STATE
33 |
34 | // Cocoa-specific per-joystick data
35 | //
36 | typedef struct _GLFWjoystickNS
37 | {
38 | IOHIDDeviceRef device;
39 | CFMutableArrayRef axes;
40 | CFMutableArrayRef buttons;
41 | CFMutableArrayRef hats;
42 | } _GLFWjoystickNS;
43 |
44 | GLFWbool _glfwInitJoysticksCocoa(void);
45 | void _glfwTerminateJoysticksCocoa(void);
46 | GLFWbool _glfwPollJoystickCocoa(_GLFWjoystick* js, int mode);
47 | const char* _glfwGetMappingNameCocoa(void);
48 | void _glfwUpdateGamepadGUIDCocoa(char* guid);
49 |
50 |
--------------------------------------------------------------------------------
/raylib/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 |
27 | #include "internal.h"
28 |
29 | #if defined(GLFW_BUILD_COCOA_TIMER)
30 |
31 | #include
32 |
33 |
34 | //////////////////////////////////////////////////////////////////////////
35 | ////// GLFW platform API //////
36 | //////////////////////////////////////////////////////////////////////////
37 |
38 | void _glfwPlatformInitTimer(void)
39 | {
40 | mach_timebase_info_data_t info;
41 | mach_timebase_info(&info);
42 |
43 | _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
44 | }
45 |
46 | uint64_t _glfwPlatformGetTimerValue(void)
47 | {
48 | return mach_absolute_time();
49 | }
50 |
51 | uint64_t _glfwPlatformGetTimerFrequency(void)
52 | {
53 | return _glfw.timer.ns.frequency;
54 | }
55 |
56 | #endif // GLFW_BUILD_COCOA_TIMER
57 |
58 |
--------------------------------------------------------------------------------
/raylib/external/glfw/src/cocoa_time.h:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // GLFW 3.4 macOS - www.glfw.org
3 | //------------------------------------------------------------------------
4 | // Copyright (c) 2009-2021 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_COCOA_LIBRARY_TIMER_STATE _GLFWtimerNS ns;
28 |
29 | // Cocoa-specific global timer data
30 | //
31 | typedef struct _GLFWtimerNS
32 | {
33 | uint64_t frequency;
34 | } _GLFWtimerNS;
35 |
36 |
--------------------------------------------------------------------------------
/raylib/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 |
27 | #include "internal.h"
28 |
29 |
30 | //////////////////////////////////////////////////////////////////////////
31 | ////// GLFW platform API //////
32 | //////////////////////////////////////////////////////////////////////////
33 |
34 | GLFWbool _glfwInitJoysticksNull(void)
35 | {
36 | return GLFW_TRUE;
37 | }
38 |
39 | void _glfwTerminateJoysticksNull(void)
40 | {
41 | }
42 |
43 | GLFWbool _glfwPollJoystickNull(_GLFWjoystick* js, int mode)
44 | {
45 | return GLFW_FALSE;
46 | }
47 |
48 | const char* _glfwGetMappingNameNull(void)
49 | {
50 | return "";
51 | }
52 |
53 | void _glfwUpdateGamepadGUIDNull(char* guid)
54 | {
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/raylib/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 | GLFWbool _glfwInitJoysticksNull(void);
28 | void _glfwTerminateJoysticksNull(void);
29 | GLFWbool _glfwPollJoystickNull(_GLFWjoystick* js, int mode);
30 | const char* _glfwGetMappingNameNull(void);
31 | void _glfwUpdateGamepadGUIDNull(char* guid);
32 |
33 |
--------------------------------------------------------------------------------
/raylib/external/glfw/src/posix_module.c:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // GLFW 3.4 POSIX - www.glfw.org
3 | //------------------------------------------------------------------------
4 | // Copyright (c) 2021 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 "internal.h"
28 |
29 | #if defined(GLFW_BUILD_POSIX_MODULE)
30 |
31 | #include
32 |
33 | //////////////////////////////////////////////////////////////////////////
34 | ////// GLFW platform API //////
35 | //////////////////////////////////////////////////////////////////////////
36 |
37 | void* _glfwPlatformLoadModule(const char* path)
38 | {
39 | return dlopen(path, RTLD_LAZY | RTLD_LOCAL);
40 | }
41 |
42 | void _glfwPlatformFreeModule(void* module)
43 | {
44 | dlclose(module);
45 | }
46 |
47 | GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name)
48 | {
49 | return dlsym(module, name);
50 | }
51 |
52 | #endif // GLFW_BUILD_POSIX_MODULE
53 |
54 |
--------------------------------------------------------------------------------
/raylib/external/glfw/src/posix_poll.h:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // GLFW 3.4 POSIX - www.glfw.org
3 | //------------------------------------------------------------------------
4 | // Copyright (c) 2022 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 |
29 | GLFWbool _glfwPollPOSIX(struct pollfd* fds, nfds_t count, double* timeout);
30 |
31 |
--------------------------------------------------------------------------------
/raylib/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_POSIX_TLS_STATE _GLFWtlsPOSIX posix;
31 | #define GLFW_POSIX_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 | } _GLFWtlsPOSIX;
41 |
42 | // POSIX-specific mutex data
43 | //
44 | typedef struct _GLFWmutexPOSIX
45 | {
46 | GLFWbool allocated;
47 | pthread_mutex_t handle;
48 | } _GLFWmutexPOSIX;
49 |
50 |
--------------------------------------------------------------------------------
/raylib/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_POSIX_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix;
29 |
30 | #include
31 | #include
32 |
33 |
34 | // POSIX-specific global timer data
35 | //
36 | typedef struct _GLFWtimerPOSIX
37 | {
38 | clockid_t clock;
39 | uint64_t frequency;
40 | } _GLFWtimerPOSIX;
41 |
42 |
--------------------------------------------------------------------------------
/raylib/external/glfw/src/vendor.go:
--------------------------------------------------------------------------------
1 | //go:build required
2 | // +build required
3 |
4 | package vendor
5 |
--------------------------------------------------------------------------------
/raylib/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_WIN32_JOYSTICK_STATE _GLFWjoystickWin32 win32;
28 | #define GLFW_WIN32_LIBRARY_JOYSTICK_STATE
29 |
30 | // Joystick element (axis, button or slider)
31 | //
32 | typedef struct _GLFWjoyobjectWin32
33 | {
34 | int offset;
35 | int type;
36 | } _GLFWjoyobjectWin32;
37 |
38 | // Win32-specific per-joystick data
39 | //
40 | typedef struct _GLFWjoystickWin32
41 | {
42 | _GLFWjoyobjectWin32* objects;
43 | int objectCount;
44 | IDirectInputDevice8W* device;
45 | DWORD index;
46 | GUID guid;
47 | } _GLFWjoystickWin32;
48 |
49 | void _glfwDetectJoystickConnectionWin32(void);
50 | void _glfwDetectJoystickDisconnectionWin32(void);
51 |
52 |
--------------------------------------------------------------------------------
/raylib/external/glfw/src/win32_module.c:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // GLFW 3.4 Win32 - www.glfw.org
3 | //------------------------------------------------------------------------
4 | // Copyright (c) 2021 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 "internal.h"
28 |
29 | #if defined(GLFW_BUILD_WIN32_MODULE)
30 |
31 | //////////////////////////////////////////////////////////////////////////
32 | ////// GLFW platform API //////
33 | //////////////////////////////////////////////////////////////////////////
34 |
35 | void* _glfwPlatformLoadModule(const char* path)
36 | {
37 | return LoadLibraryA(path);
38 | }
39 |
40 | void _glfwPlatformFreeModule(void* module)
41 | {
42 | FreeLibrary((HMODULE) module);
43 | }
44 |
45 | GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name)
46 | {
47 | return (GLFWproc) GetProcAddress((HMODULE) module, name);
48 | }
49 |
50 | #endif // GLFW_BUILD_WIN32_MODULE
51 |
52 |
--------------------------------------------------------------------------------
/raylib/external/glfw/src/win32_time.c:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // GLFW 3.4 Win32 - 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 "internal.h"
29 |
30 | #if defined(GLFW_BUILD_WIN32_TIMER)
31 |
32 | //////////////////////////////////////////////////////////////////////////
33 | ////// GLFW platform API //////
34 | //////////////////////////////////////////////////////////////////////////
35 |
36 | void _glfwPlatformInitTimer(void)
37 | {
38 | QueryPerformanceFrequency((LARGE_INTEGER*) &_glfw.timer.win32.frequency);
39 | }
40 |
41 | uint64_t _glfwPlatformGetTimerValue(void)
42 | {
43 | uint64_t value;
44 | QueryPerformanceCounter((LARGE_INTEGER*) &value);
45 | return value;
46 | }
47 |
48 | uint64_t _glfwPlatformGetTimerFrequency(void)
49 | {
50 | return _glfw.timer.win32.frequency;
51 | }
52 |
53 | #endif // GLFW_BUILD_WIN32_TIMER
54 |
55 |
--------------------------------------------------------------------------------
/raylib/external/glfw/src/win32_time.h:
--------------------------------------------------------------------------------
1 | //========================================================================
2 | // GLFW 3.4 Win32 - 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 | // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
29 | // example to allow applications to correctly declare a GL_KHR_debug callback)
30 | // but windows.h assumes no one will define APIENTRY before it does
31 | #undef APIENTRY
32 |
33 | #include
34 |
35 | #define GLFW_WIN32_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32;
36 |
37 | // Win32-specific global timer data
38 | //
39 | typedef struct _GLFWtimerWin32
40 | {
41 | uint64_t frequency;
42 | } _GLFWtimerWin32;
43 |
44 |
--------------------------------------------------------------------------------
/raylib/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 | #define GLFW_INVALID_CODEPOINT 0xffffffffu
28 |
29 | uint32_t _glfwKeySym2Unicode(unsigned int keysym);
30 |
31 |
--------------------------------------------------------------------------------
/raylib/external/vendor.go:
--------------------------------------------------------------------------------
1 | //go:build required
2 | // +build required
3 |
4 | package vendor
5 |
--------------------------------------------------------------------------------
/raylib/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/gen2brain/raylib-go/raylib
2 |
3 | go 1.21
4 |
5 | require (
6 | github.com/ebitengine/purego v0.7.1
7 | golang.org/x/sys v0.20.0
8 | )
9 |
10 | require golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
11 |
--------------------------------------------------------------------------------
/raylib/go.sum:
--------------------------------------------------------------------------------
1 | github.com/ebitengine/purego v0.7.1 h1:6/55d26lG3o9VCZX8lping+bZcmShseiqlh2bnUDiPA=
2 | github.com/ebitengine/purego v0.7.1/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
3 | golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
4 | golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
5 | golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
6 | golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
7 |
--------------------------------------------------------------------------------
/raylib/platform_drm.go:
--------------------------------------------------------------------------------
1 | //go:build linux && drm && !rgfw && !sdl && !sdl3 && !android
2 | // +build linux,drm,!rgfw,!sdl,!sdl3,!android
3 |
4 | package rl
5 |
6 | /*
7 | #include "raylib.h"
8 | #include
9 | */
10 | import "C"
11 |
12 | import (
13 | "os"
14 | "unsafe"
15 | )
16 |
17 | // InitWindow - Initialize Window and OpenGL Graphics
18 | func InitWindow(width int32, height int32, title string) {
19 | cwidth := (C.int)(width)
20 | cheight := (C.int)(height)
21 |
22 | ctitle := C.CString(title)
23 | defer C.free(unsafe.Pointer(ctitle))
24 |
25 | C.InitWindow(cwidth, cheight, ctitle)
26 | }
27 |
28 | // SetCallbackFunc - Sets callback function
29 | func SetCallbackFunc(func()) {
30 | return
31 | }
32 |
33 | // ShowCursor - Shows cursor
34 | func ShowCursor() {
35 | C.ShowCursor()
36 | }
37 |
38 | // HideCursor - Hides cursor
39 | func HideCursor() {
40 | C.HideCursor()
41 | }
42 |
43 | // IsCursorHidden - Returns true if cursor is not visible
44 | func IsCursorHidden() bool {
45 | ret := C.IsCursorHidden()
46 | v := bool(ret)
47 | return v
48 | }
49 |
50 | // IsCursorOnScreen - Check if cursor is on the current screen.
51 | func IsCursorOnScreen() bool {
52 | ret := C.IsCursorOnScreen()
53 | v := bool(ret)
54 | return v
55 | }
56 |
57 | // EnableCursor - Enables cursor
58 | func EnableCursor() {
59 | C.EnableCursor()
60 | }
61 |
62 | // DisableCursor - Disables cursor
63 | func DisableCursor() {
64 | C.DisableCursor()
65 | }
66 |
67 | // IsFileDropped - Check if a file have been dropped into window
68 | func IsFileDropped() bool {
69 | return false
70 | }
71 |
72 | // LoadDroppedFiles - Load dropped filepaths
73 | func LoadDroppedFiles() (files []string) {
74 | return
75 | }
76 |
77 | // UnloadDroppedFiles - Unload dropped filepaths
78 | func UnloadDroppedFiles() {
79 | return
80 | }
81 |
82 | // OpenAsset - Open asset
83 | func OpenAsset(name string) (Asset, error) {
84 | f, err := os.Open(name)
85 | if err != nil {
86 | return nil, err
87 | }
88 | return f, nil
89 | }
90 |
--------------------------------------------------------------------------------
/raylib/platforms/vendor.go:
--------------------------------------------------------------------------------
1 | //go:build required
2 | // +build required
3 |
4 | package vendor
5 |
--------------------------------------------------------------------------------
/raylib/purego_windows.go:
--------------------------------------------------------------------------------
1 | //go:build !cgo && windows
2 | // +build !cgo,windows
3 |
4 | package rl
5 |
6 | import (
7 | "fmt"
8 | "syscall"
9 | "unsafe"
10 |
11 | "github.com/ebitengine/purego"
12 | "golang.org/x/sys/windows"
13 | )
14 |
15 | const (
16 | libname = "raylib.dll"
17 | requiredVersion = "5.5"
18 | )
19 |
20 | var wvsprintfA uintptr
21 |
22 | func init() {
23 | handle, err := windows.LoadLibrary("user32.dll")
24 | if err == nil {
25 | wvsprintfA, _ = windows.GetProcAddress(handle, "wvsprintfA")
26 | }
27 | }
28 |
29 | // loadLibrary loads the raylib dll and panics on error
30 | func loadLibrary() uintptr {
31 | handle, err := windows.LoadLibrary(libname)
32 | if err != nil {
33 | panic(fmt.Errorf("cannot load library %s: %w", libname, err))
34 | }
35 |
36 | proc, err := windows.GetProcAddress(handle, "raylib_version")
37 | if err != nil {
38 | panic(err)
39 | }
40 |
41 | version := windows.BytePtrToString(**(***byte)(unsafe.Pointer(&proc)))
42 | if version != requiredVersion {
43 | panic(fmt.Errorf("version %s of %s doesn't match the required version %s", version, libname, requiredVersion))
44 | }
45 |
46 | return uintptr(handle)
47 | }
48 |
49 | func traceLogCallbackWrapper(fn TraceLogCallbackFun) uintptr {
50 | return purego.NewCallback(func(logLevel int32, text *byte, args unsafe.Pointer) uintptr {
51 | if wvsprintfA != 0 {
52 | var buffer [1024]byte // Max size is 1024 (see https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-wvsprintfa)
53 | _, _, errno := syscall.SyscallN(wvsprintfA, uintptr(unsafe.Pointer(&buffer[0])), uintptr(unsafe.Pointer(text)), uintptr(args))
54 | if errno == 0 {
55 | text = &buffer[0]
56 | }
57 | }
58 | fn(int(logLevel), windows.BytePtrToString(text))
59 | return 0
60 | })
61 | }
62 |
--------------------------------------------------------------------------------
/raylib/rgestures.go:
--------------------------------------------------------------------------------
1 | package rl
2 |
3 | /*
4 | #include "raylib.h"
5 | */
6 | import "C"
7 | import "unsafe"
8 |
9 | // SetGesturesEnabled - Enable a set of gestures using flags
10 | func SetGesturesEnabled(gestureFlags uint32) {
11 | cgestureFlags := (C.uint)(gestureFlags)
12 | C.SetGesturesEnabled(cgestureFlags)
13 | }
14 |
15 | // IsGestureDetected - Check if a gesture have been detected
16 | func IsGestureDetected(gesture Gestures) bool {
17 | cgesture := (C.uint)(gesture)
18 | ret := C.IsGestureDetected(cgesture)
19 | v := bool(ret)
20 | return v
21 | }
22 |
23 | // GetGestureDetected - Get latest detected gesture
24 | func GetGestureDetected() Gestures {
25 | ret := C.GetGestureDetected()
26 | v := (Gestures)(ret)
27 | return v
28 | }
29 |
30 | // GetGestureHoldDuration - Get gesture hold time in milliseconds
31 | func GetGestureHoldDuration() float32 {
32 | ret := C.GetGestureHoldDuration()
33 | v := (float32)(ret)
34 | return v
35 | }
36 |
37 | // GetGestureDragVector - Get gesture drag vector
38 | func GetGestureDragVector() Vector2 {
39 | ret := C.GetGestureDragVector()
40 | v := newVector2FromPointer(unsafe.Pointer(&ret))
41 | return v
42 | }
43 |
44 | // GetGestureDragAngle - Get gesture drag angle
45 | func GetGestureDragAngle() float32 {
46 | ret := C.GetGestureDragAngle()
47 | v := (float32)(ret)
48 | return v
49 | }
50 |
51 | // GetGesturePinchVector - Get gesture pinch delta
52 | func GetGesturePinchVector() Vector2 {
53 | ret := C.GetGesturePinchVector()
54 | v := newVector2FromPointer(unsafe.Pointer(&ret))
55 | return v
56 | }
57 |
58 | // GetGesturePinchAngle - Get gesture pinch angle
59 | func GetGesturePinchAngle() float32 {
60 | ret := C.GetGesturePinchAngle()
61 | v := (float32)(ret)
62 | return v
63 | }
64 |
--------------------------------------------------------------------------------
/raylib/utils.go:
--------------------------------------------------------------------------------
1 | //go:build !android
2 | // +build !android
3 |
4 | package rl
5 |
6 | /*
7 | #include "stdlib.h"
8 | #include "raylib.h"
9 | void TraceLogWrapper(int logLevel, const char *text)
10 | {
11 | TraceLog(logLevel, text);
12 | }
13 | */
14 | import "C"
15 |
16 | import (
17 | "fmt"
18 | "os"
19 | "unsafe"
20 | )
21 |
22 | // SetTraceLogLevel - Set the current threshold (minimum) log level
23 | func SetTraceLogLevel(logLevel TraceLogLevel) {
24 | clogLevel := (C.int)(logLevel)
25 | C.SetTraceLogLevel(clogLevel)
26 | }
27 |
28 | // TraceLog - Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
29 | func TraceLog(logLevel TraceLogLevel, text string, v ...interface{}) {
30 | ctext := C.CString(fmt.Sprintf(text, v...))
31 | defer C.free(unsafe.Pointer(ctext))
32 | clogLevel := (C.int)(logLevel)
33 | C.TraceLogWrapper(clogLevel, ctext)
34 | }
35 |
36 | // HomeDir - Returns user home directory
37 | // NOTE: On Android this returns internal data path and must be called after InitWindow
38 | func HomeDir() string {
39 | if homeDir, err := os.UserHomeDir(); err == nil {
40 | return homeDir
41 | }
42 | return ""
43 | }
44 |
--------------------------------------------------------------------------------
/raylib/utils_android.go:
--------------------------------------------------------------------------------
1 | //go:build android
2 | // +build android
3 |
4 | package rl
5 |
6 | /*
7 | #include "stdlib.h"
8 | #include "raylib.h"
9 | void TraceLogWrapper(int logLevel, const char *text)
10 | {
11 | TraceLog(logLevel, text);
12 | }
13 | */
14 | import "C"
15 |
16 | import (
17 | "fmt"
18 | "unsafe"
19 | )
20 |
21 | // SetTraceLogLevel - Set the current threshold (minimum) log level
22 | func SetTraceLogLevel(logLevel TraceLogLevel) {
23 | clogLevel := (C.int)(logLevel)
24 | C.SetTraceLogLevel(clogLevel)
25 | }
26 |
27 | // TraceLog - Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
28 | func TraceLog(logLevel TraceLogLevel, text string, v ...interface{}) {
29 | ctext := C.CString(fmt.Sprintf(text, v...))
30 | defer C.free(unsafe.Pointer(ctext))
31 | clogLevel := (C.int)(logLevel)
32 | C.TraceLogWrapper(clogLevel, ctext)
33 | }
34 |
35 | // HomeDir - Returns user home directory
36 | // NOTE: On Android this returns internal data path and must be called after InitWindow
37 | func HomeDir() string {
38 | return getInternalStoragePath()
39 | }
40 |
--------------------------------------------------------------------------------
/raylib/utils_log.c:
--------------------------------------------------------------------------------
1 | #include "raylib.h"
2 | #include "utils_log.h"
3 | #include // Required for: vprintf()
4 | #include // Required for: strcpy(), strcat()
5 |
6 | #define MAX_TRACELOG_BUFFER_SIZE 256 // As defined in utils.c from raylib
7 |
8 | void rayLogWrapperCallback(int logType, const char *text, va_list args) {
9 | char buffer[MAX_TRACELOG_BUFFER_SIZE] = { 0 };
10 |
11 | vsprintf(buffer, text, args);
12 |
13 | internalTraceLogCallbackGo(logType, buffer, strlen(buffer));
14 | }
15 |
16 | void setLogCallbackWrapper(void) {
17 | SetTraceLogCallback(rayLogWrapperCallback);
18 | }
19 |
--------------------------------------------------------------------------------
/raylib/utils_log.go:
--------------------------------------------------------------------------------
1 | package rl
2 |
3 | /*
4 | #include "utils_log.h"
5 | */
6 | import "C"
7 |
8 | import "unsafe"
9 |
10 | var internalTraceLogCallbackFun TraceLogCallbackFun = func(int, string) {}
11 |
12 | // SetTraceLogCallback - set a call-back function for trace log
13 | func SetTraceLogCallback(fn TraceLogCallbackFun) {
14 | internalTraceLogCallbackFun = fn
15 | C.setLogCallbackWrapper()
16 | }
17 |
18 | //export internalTraceLogCallbackGo
19 | func internalTraceLogCallbackGo(logType C.int, cstr unsafe.Pointer, length C.int) {
20 | str := string(C.GoBytes(cstr, length))
21 | lt := int(logType)
22 | internalTraceLogCallbackFun(lt, str)
23 | }
24 |
--------------------------------------------------------------------------------
/raylib/utils_log.h:
--------------------------------------------------------------------------------
1 | #if defined(__cplusplus)
2 | extern "C" { // Prevents name mangling of functions
3 | #endif
4 |
5 |
6 | void setLogCallbackWrapper(void); // enable the call-back
7 |
8 | #if defined(__cplusplus)
9 | }
10 | #endif
11 |
--------------------------------------------------------------------------------
/rres/README.md:
--------------------------------------------------------------------------------
1 | ## rres [](https://godoc.org/github.com/gen2brain/raylib-go/rres)
2 |
3 | Golang cgo bindings for [raysan5's rres](https://github.com/raysan5/rres)
4 |
--------------------------------------------------------------------------------
/rres/cgo.go:
--------------------------------------------------------------------------------
1 | package rres
2 |
3 | /*
4 | #cgo CFLAGS: -std=gnu99 -Wno-unused-result -Wno-implicit-function-declaration -Wno-deprecated-declarations
5 | */
6 | import "C"
7 |
--------------------------------------------------------------------------------
/rres/external/vendor.go:
--------------------------------------------------------------------------------
1 | //go:build required
2 | // +build required
3 |
4 | package vendor
5 |
--------------------------------------------------------------------------------
/rres/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/gen2brain/raylib-go/rres
2 |
3 | go 1.21
4 |
5 | require github.com/gen2brain/raylib-go/raylib v0.0.0-20241202103652-5d50abe7c65b
6 |
7 | require (
8 | github.com/ebitengine/purego v0.8.1 // indirect
9 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
10 | golang.org/x/sys v0.27.0 // indirect
11 | )
12 |
--------------------------------------------------------------------------------
/rres/go.sum:
--------------------------------------------------------------------------------
1 | github.com/ebitengine/purego v0.8.1 h1:sdRKd6plj7KYW33EH5As6YKfe8m9zbN9JMrOjNVF/BE=
2 | github.com/ebitengine/purego v0.8.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
3 | github.com/gen2brain/raylib-go/raylib v0.0.0-20241202103652-5d50abe7c65b h1:wK8D9x3f+BX1xFGgjj399dYx2eskikDZHxlRaSSA19Q=
4 | github.com/gen2brain/raylib-go/raylib v0.0.0-20241202103652-5d50abe7c65b/go.mod h1:BaY76bZk7nw1/kVOSQObPY1v1iwVE1KHAGMfvI6oK1Q=
5 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
6 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
7 | golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
8 | golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
9 |
--------------------------------------------------------------------------------
/rres/vendor.go:
--------------------------------------------------------------------------------
1 | //go:build required
2 | // +build required
3 |
4 | package rres
5 |
6 | import (
7 | _ "github.com/gen2brain/raylib-go/rres/external"
8 | )
9 |
--------------------------------------------------------------------------------