MoonBit bindings for raylib
| Platform | C Compiler |
|---|---|
| macOS | Xcode Command Line Tools (xcode-select --install) |
| Linux | GCC or Clang (e.g., apt install build-essential) |
| Windows | MSVC or MinGW-w64 (GCC) — see below |
| Android | Android NDK |
moon add tonyfettes/raylibfn main {
@raylib.init_window(800, 450, "Hello Raylib")
@raylib.set_target_fps(60)
while not(@raylib.window_should_close()) {
@raylib.begin_drawing()
@raylib.clear_background(@raylib.raywhite)
@raylib.draw_text("Hello, MoonBit!", 190, 200, 20, @raylib.lightgray)
@raylib.end_drawing()
}
@raylib.close_window()
}moon run --target native main/# Build a specific example
moon -C examples build --target native raylib_core_basic_window/
# Run a specific example
moon -C examples run --target native raylib_demo/
# Run the bunnymark benchmark
moon -C examples run --target native raylib_textures_bunnymark/// Window management
@raylib.init_window(width, height, title)
@raylib.close_window()
@raylib.set_target_fps(60)
// Drawing
@raylib.begin_drawing()
@raylib.end_drawing()
@raylib.clear_background(@raylib.skyblue)
// Shapes
@raylib.draw_rectangle(x, y, width, height, @raylib.red)
@raylib.draw_circle(x, y, radius, @raylib.blue)
// Textures
let texture = @raylib.load_texture("sprite.png")
@raylib.draw_texture(texture, x, y, @raylib.white)
// Input
@raylib.is_key_pressed(@raylib.KeySpace)
@raylib.is_mouse_button_down(@raylib.MouseButtonLeft)
@raylib.get_mouse_position() // -> Vector2
// Audio
@raylib.init_audio_device()
let sound = @raylib.load_sound("hit.wav")
@raylib.play_sound(sound)
// 3D
@raylib.begin_mode_3d(camera)
@raylib.draw_cube(position, width, height, length, @raylib.red)
@raylib.end_mode_3d()type AudioStream#as_free_fn(attach_audio_stream_processor)
fn AudioStream::attach_processor(self : AudioStream, processor : FuncRef[(AudioBuffer, UInt) -> Unit]) -> Unit#as_free_fn(detach_audio_stream_processor)
fn AudioStream::detach_processor(self : AudioStream, processor : FuncRef[(AudioBuffer, UInt) -> Unit]) -> Unit#as_free_fn(load_audio_stream)
fn AudioStream::load(sample_rate : Int, sample_size : Int, channels : Int) -> AudioStream#as_free_fn(set_audio_stream_pitch)
fn AudioStream::set_pitch(self : AudioStream, pitch : Float) -> Unit#as_free_fn(set_audio_stream_volume)
fn AudioStream::set_volume(self : AudioStream, volume : Float) -> Unit#as_free_fn(update_audio_stream)
fn AudioStream::update(self : AudioStream, data : Bytes, frame_count : Int) -> Unitpub struct AutomationEvent {
frame : Int
type_ : Int
params : FixedArray[Int]
}impl Show for AutomationEventtype AutomationEventList#as_free_fn(automation_event_list_count)
fn AutomationEventList::count(self : AutomationEventList) -> Int#as_free_fn(export_automation_event_list)
fn AutomationEventList::export_(self : AutomationEventList, file_name : String) -> Bool#as_free_fn(automation_event_list_get)
fn AutomationEventList::get(self : AutomationEventList, index : Int) -> AutomationEvent#as_free_fn(load_automation_event_list)
fn AutomationEventList::load(file_name : String) -> AutomationEventList#as_free_fn(set_automation_event_list)
fn AutomationEventList::set(self : AutomationEventList) -> Unit#as_free_fn(unload_automation_event_list)
fn AutomationEventList::unload(self : AutomationEventList) -> Unitpub struct Color {
r : Byte
g : Byte
b : Byte
a : Byte
}type FilePathListtype FloatArraytype Fontpub struct GlyphInfo {
value : Int
offset_x : Int
offset_y : Int
advance_x : Int
}type GlyphInfoArray#as_free_fn(gen_image_font_atlas)
fn GlyphInfoArray::gen_image_atlas(self : GlyphInfoArray, font_size : Int, padding : Int, pack_method : Int) -> Image#as_free_fn(glyph_info_array_get)
fn GlyphInfoArray::get(self : GlyphInfoArray, index : Int) -> GlyphInfo#as_free_fn(load_font_data)
fn GlyphInfoArray::load(file_data : Bytes, data_size : Int, font_size : Int, font_type : Int) -> GlyphInfoArraytype Imagetype Materialtype MaterialMaptype MaterialMapArraytype MaterialsArray#as_free_fn(materials_array_get)
fn MaterialsArray::get(self : MaterialsArray, index : Int) -> Materialpub struct Matrix {
m0 : Float
m1 : Float
m2 : Float
m3 : Float
m4 : Float
m5 : Float
m6 : Float
m7 : Float
m8 : Float
m9 : Float
m10 : Float
m11 : Float
m12 : Float
m13 : Float
m14 : Float
m15 : Float
}type MatrixArraytype Meshtype Model#as_free_fn(is_model_animation_valid)
fn Model::is_animation_valid(self : Model, anims : ModelAnimations, index : Int) -> Bool#as_free_fn(update_model_animation)
fn Model::update_animation(self : Model, anims : ModelAnimations, index : Int, frame : Int) -> Unit#as_free_fn(update_model_animation_bones)
fn Model::update_animation_bones(self : Model, anims : ModelAnimations, index : Int, frame : Int) -> Unittype ModelAnimations#as_free_fn(get_model_animation_bone_count)
fn ModelAnimations::bone_count(self : ModelAnimations, anim_index : Int) -> Int#as_free_fn(get_model_animation_bone_parent)
fn ModelAnimations::bone_parent(self : ModelAnimations, anim_index : Int, bone_index : Int) -> Int#as_free_fn(get_model_animation_frame_count)
fn ModelAnimations::frame_count(self : ModelAnimations, anim_index : Int) -> Int#as_free_fn(get_model_animation_frame_pose_rotation)
fn ModelAnimations::frame_pose_rotation(self : ModelAnimations, anim_index : Int, frame : Int, bone_index : Int) -> Vector4#as_free_fn(get_model_animation_frame_pose_translation)
fn ModelAnimations::frame_pose_translation(self : ModelAnimations, anim_index : Int, frame : Int, bone_index : Int) -> Vector3type Musicpub struct NPatchInfo {
source : Rectangle
left : Int
top : Int
right : Int
bottom : Int
layout : Int
}impl Eq for NPatchInfoimpl Show for NPatchInfofn NPatchInfo::new(source : Rectangle, left : Int, top : Int, right : Int, bottom : Int, layout : Int) -> NPatchInfoimpl Eq for RayCollisionimpl Show for RayCollisionfn RayCollision::new(hit : Bool, distance : Float, point : Vector3, normal : Vector3) -> RayCollisionpub struct Rectangle {
x : Float
y : Float
width : Float
height : Float
}type RenderTexture#as_free_fn(draw_render_texture_ex)
fn RenderTexture::draw_ex(self : RenderTexture, position : Vector2, rotation : Float, scale : Float, tint : Color) -> Unit#as_free_fn(draw_render_texture_pro)
fn RenderTexture::draw_pro(self : RenderTexture, source : Rectangle, dest : Rectangle, origin : Vector2, rotation : Float, tint : Color) -> Unit#as_free_fn(draw_render_texture_rec)
fn RenderTexture::draw_rec(self : RenderTexture, source : Rectangle, position : Vector2, tint : Color) -> Unit#deprecated("Use RenderTexture::id instead")
#as_free_fn(get_render_texture_fbo_id, deprecated="Use RenderTexture::id instead")
fn RenderTexture::fbo_id(self : RenderTexture) -> UInt#deprecated("Use RenderTexture::new with @rl helpers instead")
#as_free_fn(load_render_texture_depth_tex, deprecated="Use RenderTexture::new with @rl helpers instead")
fn RenderTexture::load_depth_tex(width : Int, height : Int) -> RenderTexture#deprecated("Use RenderTexture::new with @rl helpers instead")
#as_free_fn(load_shadowmap_render_texture, deprecated="Use RenderTexture::new with @rl helpers instead")
fn RenderTexture::load_shadowmap(width : Int, height : Int) -> RenderTexture#as_free_fn(new_render_texture)
fn RenderTexture::new(id : UInt, texture : Texture, depth : Texture) -> RenderTexture#as_free_fn(set_render_texture_filter)
fn RenderTexture::set_filter(self : RenderTexture, filter : Int) -> Unit#deprecated("Use RenderTexture::unload instead")
#as_free_fn(unload_render_texture_depth_tex, deprecated="Use RenderTexture::unload instead")
fn RenderTexture::unload_depth_tex(self : RenderTexture) -> Unit#deprecated("Use RenderTexture::unload instead")
#as_free_fn(unload_shadowmap_render_texture, deprecated="Use RenderTexture::unload instead")
fn RenderTexture::unload_shadowmap(self : RenderTexture) -> Unittype Shadertype Soundtype Texturetype UByteArraytype UShortArraypub struct Vector2 {
x : Float
y : Float
}pub struct Vector3 {
x : Float
y : Float
z : Float
}pub struct Vector4 {
x : Float
y : Float
z : Float
w : Float
}pub struct VrDeviceInfo {
h_resolution : Int
v_resolution : Int
h_screen_size : Float
v_screen_size : Float
eye_to_screen_distance : Float
lens_separation_distance : Float
interpupillary_distance : Float
lens_distortion_values : FixedArray[Float]
chroma_ab_correction : FixedArray[Float]
}impl Show for VrDeviceInfofn VrDeviceInfo::new(h_resolution : Int, v_resolution : Int, h_screen_size : Float, v_screen_size : Float, eye_to_screen_distance : Float, lens_separation_distance : Float, interpupillary_distance : Float, lens_distortion_values : FixedArray[Float], chroma_ab_correction : FixedArray[Float]) -> VrDeviceInfotype VrStereoConfigtype Wave#deprecated("Use @rl.AttachmentColorChannel0 from tonyfettes/raylib/rl instead")
let RlAttachmentColorChannel0 : Int#deprecated("Use @rl.AttachmentColorChannel1 from tonyfettes/raylib/rl instead")
let RlAttachmentColorChannel1 : Int#deprecated("Use @rl.AttachmentColorChannel2 from tonyfettes/raylib/rl instead")
let RlAttachmentColorChannel2 : Int#deprecated("Use @rl.AttachmentColorChannel3 from tonyfettes/raylib/rl instead")
let RlAttachmentColorChannel3 : Int#deprecated("Use @rl.AttachmentCubemapNegativeX from tonyfettes/raylib/rl instead")
let RlAttachmentCubemapNegativeX : Int#deprecated("Use @rl.AttachmentCubemapNegativeY from tonyfettes/raylib/rl instead")
let RlAttachmentCubemapNegativeY : Int#deprecated("Use @rl.AttachmentCubemapNegativeZ from tonyfettes/raylib/rl instead")
let RlAttachmentCubemapNegativeZ : Int#deprecated("Use @rl.AttachmentCubemapPositiveX from tonyfettes/raylib/rl instead")
let RlAttachmentCubemapPositiveX : Int#deprecated("Use @rl.AttachmentCubemapPositiveY from tonyfettes/raylib/rl instead")
let RlAttachmentCubemapPositiveY : Int#deprecated("Use @rl.AttachmentCubemapPositiveZ from tonyfettes/raylib/rl instead")
let RlAttachmentCubemapPositiveZ : Int#deprecated("Use @rl.AttachmentDepth from tonyfettes/raylib/rl instead")
let RlAttachmentDepth : Int#deprecated("Use @rl.AttachmentRenderbuffer from tonyfettes/raylib/rl instead")
let RlAttachmentRenderbuffer : Int#deprecated("Use @rl.AttachmentStencil from tonyfettes/raylib/rl instead")
let RlAttachmentStencil : Int#deprecated("Use @rl.AttachmentTexture2d from tonyfettes/raylib/rl instead")
let RlAttachmentTexture2d : Int#deprecated("Use @rl.DrawFramebuffer from tonyfettes/raylib/rl instead")
let RlDrawFramebuffer : UInt#deprecated("Use @rl.ReadFramebuffer from tonyfettes/raylib/rl instead")
let RlReadFramebuffer : UInt#deprecated("Use @rl.Triangles from tonyfettes/raylib/rl instead")
let RlTriangles : Intfn attach_music_stream_processor(music : Music, processor : FuncRef[(AudioBuffer, UInt) -> Unit]) -> Unitfn detach_music_stream_processor(music : Music, processor : FuncRef[(AudioBuffer, UInt) -> Unit]) -> Unitfn draw_ellipse(center_x : Int, center_y : Int, radius_h : Float, radius_v : Float, color : Color) -> Unitfn draw_ellipse_lines(center_x : Int, center_y : Int, radius_h : Float, radius_v : Float, color : Color) -> Unitfn export_data_as_code(data : Bytes, data_size : Int, file_name : String) -> Bool#deprecated("Use font.texture().gen_mipmaps() instead")
fn gen_font_texture_mipmaps(font : Font) -> Unitfn is_cursor_hidden() -> Boolfn is_window_hidden() -> Boolfn load_directory_files_ex(base_path : String, filter : String, scan_subdirs : Bool) -> FilePathList#deprecated("Use Image::load_anim instead (returns (Image, Int) with frame count)")
fn load_image_anim(file_name : String) -> Image#deprecated("Use Image::load_anim_from_memory instead (returns (Image, Int) with frame count)")
fn load_image_anim_from_memory(file_type : String, file_data : Bytes, data_size : Int) -> Image#deprecated("Use @rl.active_draw_buffers from tonyfettes/raylib/rl instead")
fn rl_active_draw_buffers(count : Int) -> Unit#deprecated("Use @rl.active_texture_slot from tonyfettes/raylib/rl instead")
fn rl_active_texture_slot(slot : Int) -> Unit#deprecated("Use @rl.begin from tonyfettes/raylib/rl instead")
fn rl_begin(mode : Int) -> Unit#deprecated("Use @rl.bind_framebuffer from tonyfettes/raylib/rl instead")
fn rl_bind_framebuffer(target : UInt, fbo : UInt) -> Unit#deprecated("Use @rl.blit_framebuffer from tonyfettes/raylib/rl instead")
fn rl_blit_framebuffer(src_x : Int, src_y : Int, src_w : Int, src_h : Int, dst_x : Int, dst_y : Int, dst_w : Int, dst_h : Int, buffer_mask : Int) -> Unit#deprecated("Use @rl.check_render_batch_limit from tonyfettes/raylib/rl instead")
fn rl_check_render_batch_limit(v_count : Int) -> Bool#deprecated("Use @rl.clear_screen_buffers from tonyfettes/raylib/rl instead")
fn rl_clear_screen_buffers() -> Unit#deprecated("Use @rl.color4ub from tonyfettes/raylib/rl instead")
fn rl_color4ub(r : Byte, g : Byte, b : Byte, a : Byte) -> Unit#deprecated("Use @rl.disable_backface_culling from tonyfettes/raylib/rl instead")
fn rl_disable_backface_culling() -> Unit#deprecated("Use @rl.disable_color_blend from tonyfettes/raylib/rl instead")
fn rl_disable_color_blend() -> Unit#deprecated("Use @rl.disable_depth_mask from tonyfettes/raylib/rl instead")
fn rl_disable_depth_mask() -> Unit#deprecated("Use @rl.disable_depth_test from tonyfettes/raylib/rl instead")
fn rl_disable_depth_test() -> Unit#deprecated("Use @rl.disable_framebuffer from tonyfettes/raylib/rl instead")
fn rl_disable_framebuffer() -> Unit#deprecated("Use @rl.disable_shader from tonyfettes/raylib/rl instead")
fn rl_disable_shader() -> Unit#deprecated("Use @rl.disable_texture from tonyfettes/raylib/rl instead")
fn rl_disable_texture() -> Unit#deprecated("Use @rl.draw_render_batch_active from tonyfettes/raylib/rl instead")
fn rl_draw_render_batch_active() -> Unit#deprecated("Use @rl.enable_backface_culling from tonyfettes/raylib/rl instead")
fn rl_enable_backface_culling() -> Unit#deprecated("Use @rl.enable_color_blend from tonyfettes/raylib/rl instead")
fn rl_enable_color_blend() -> Unit#deprecated("Use @rl.enable_depth_mask from tonyfettes/raylib/rl instead")
fn rl_enable_depth_mask() -> Unit#deprecated("Use @rl.enable_depth_test from tonyfettes/raylib/rl instead")
fn rl_enable_depth_test() -> Unit#deprecated("Use @rl.enable_framebuffer from tonyfettes/raylib/rl instead")
fn rl_enable_framebuffer(id : UInt) -> Unit#deprecated("Use @rl.enable_shader from tonyfettes/raylib/rl instead")
fn rl_enable_shader(id : UInt) -> Unit#deprecated("Use @rl.enable_texture from tonyfettes/raylib/rl instead")
fn rl_enable_texture(id : UInt) -> Unit#deprecated("Use @rl.framebuffer_attach from tonyfettes/raylib/rl instead")
fn rl_framebuffer_attach(fbo_id : UInt, tex_id : UInt, attach_type : Int, tex_type : Int, mip_level : Int) -> Unit#deprecated("Use @rl.framebuffer_complete from tonyfettes/raylib/rl instead")
fn rl_framebuffer_complete(id : UInt) -> Bool#deprecated("Use @rl.get_framebuffer_height from tonyfettes/raylib/rl instead")
fn rl_get_framebuffer_height() -> Int#deprecated("Use @rl.get_framebuffer_width from tonyfettes/raylib/rl instead")
fn rl_get_framebuffer_width() -> Int#deprecated("Use @rl.get_location_uniform from tonyfettes/raylib/rl instead")
fn rl_get_location_uniform(shader_id : UInt, uniform_name : String) -> Int#deprecated("Use @rl.get_matrix_modelview from tonyfettes/raylib/rl instead")
fn rl_get_matrix_modelview() -> Matrix#deprecated("Use @rl.get_matrix_projection from tonyfettes/raylib/rl instead")
fn rl_get_matrix_projection() -> Matrix#deprecated("Use @rl.get_shader_id_default from tonyfettes/raylib/rl instead")
fn rl_get_shader_id_default() -> UInt#deprecated("Use @rl.load_draw_cube from tonyfettes/raylib/rl instead")
fn rl_load_draw_cube() -> Unit#deprecated("Use @rl.load_draw_quad from tonyfettes/raylib/rl instead")
fn rl_load_draw_quad() -> Unit#deprecated("Use @rl.load_framebuffer from tonyfettes/raylib/rl instead")
fn rl_load_framebuffer() -> UInt#deprecated("Use @rl.load_texture from tonyfettes/raylib/rl instead")
fn rl_load_texture(width : Int, height : Int, format : Int, mipmap_count : Int) -> UInt#deprecated("Use @rl.load_texture_depth from tonyfettes/raylib/rl instead")
fn rl_load_texture_depth(width : Int, height : Int, use_render_buffer : Bool) -> UInt#deprecated("Use @rl.mult_matrixf from tonyfettes/raylib/rl instead")
fn rl_mult_matrixf(matf : Bytes) -> Unit#deprecated("Use @rl.normal3f from tonyfettes/raylib/rl instead")
fn rl_normal3f(x : Float, y : Float, z : Float) -> Unit#deprecated("Use @rl.pop_matrix from tonyfettes/raylib/rl instead")
fn rl_pop_matrix() -> Unit#deprecated("Use @rl.push_matrix from tonyfettes/raylib/rl instead")
fn rl_push_matrix() -> Unit#deprecated("Use @rl.rotatef from tonyfettes/raylib/rl instead")
fn rl_rotatef(angle : Float, x : Float, y : Float, z : Float) -> Unit#deprecated("Use @rl.scalef from tonyfettes/raylib/rl instead")
fn rl_scalef(x : Float, y : Float, z : Float) -> Unit#deprecated("Use @rl.set_blend_factors from tonyfettes/raylib/rl instead")
fn rl_set_blend_factors(gl_src_factor : Int, gl_dst_factor : Int, gl_equation : Int) -> Unit#deprecated("Use @rl.set_blend_mode from tonyfettes/raylib/rl instead")
fn rl_set_blend_mode(mode : Int) -> Unit#deprecated("Use @rl.set_texture from tonyfettes/raylib/rl instead")
fn rl_set_texture(id : UInt) -> Unit#deprecated("Use @rl.set_uniform from tonyfettes/raylib/rl instead")
fn rl_set_uniform(loc_index : Int, value : Bytes, uniform_type : Int, count : Int) -> Unit#deprecated("Use @rl.set_uniform_sampler from tonyfettes/raylib/rl instead")
fn rl_set_uniform_sampler(loc_index : Int, texture_id : UInt) -> Unit#deprecated("Use @rl.tex_coord2f from tonyfettes/raylib/rl instead")
fn rl_tex_coord2f(x : Float, y : Float) -> Unit#deprecated("Use @rl.translatef from tonyfettes/raylib/rl instead")
fn rl_translatef(x : Float, y : Float, z : Float) -> Unit#deprecated("Use @rl.unload_framebuffer from tonyfettes/raylib/rl instead")
fn rl_unload_framebuffer(id : UInt) -> Unit#deprecated("Use @rl.unload_texture from tonyfettes/raylib/rl instead")
fn rl_unload_texture(id : UInt) -> Unit#deprecated("Use @rl.vertex2f from tonyfettes/raylib/rl instead")
fn rl_vertex2f(x : Float, y : Float) -> Unit#deprecated("Use @rl.vertex3f from tonyfettes/raylib/rl instead")
fn rl_vertex3f(x : Float, y : Float, z : Float) -> Unit#deprecated("Use @rl.viewport from tonyfettes/raylib/rl instead")
fn rl_viewport(x : Int, y : Int, width : Int, height : Int) -> Unitfn set_audio_stream_buffer_size_default(size : Int) -> Unit#deprecated("Use font.texture().set_filter(filter) instead")
fn set_font_texture_filter(font : Font, filter : Int) -> Unitfn set_gamepad_vibration(gamepad : Int, left_motor : Float, right_motor : Float, duration : Float) -> Unit#deprecated("Use Shader::set_value instead")
fn set_shader_value(shader : Shader, loc_index : Int, value : Bytes, uniform_type : Int) -> Unit#deprecated("Use Shader::set_value_v instead")
fn set_shader_value_v(shader : Shader, loc_index : Int, value : Bytes, uniform_type : Int, count : Int) -> Unit#deprecated("Use VrStereoConfig::left_lens_center instead")
fn vr_stereo_config_left_lens_center(config : VrStereoConfig) -> Bytes#deprecated("Use VrStereoConfig::left_screen_center instead")
fn vr_stereo_config_left_screen_center(config : VrStereoConfig) -> Bytes#deprecated("Use VrStereoConfig::right_lens_center instead")
fn vr_stereo_config_right_lens_center(config : VrStereoConfig) -> Bytes#deprecated("Use VrStereoConfig::right_screen_center instead")
fn vr_stereo_config_right_screen_center(config : VrStereoConfig) -> Bytes#deprecated("Use VrStereoConfig::scale instead")
fn vr_stereo_config_scale(config : VrStereoConfig) -> Bytes#deprecated("Use VrStereoConfig::scale_in instead")
fn vr_stereo_config_scale_in(config : VrStereoConfig) -> BytesMoonBit bindings for raylib