raylib 6 bindings for c3
c3 raylib graphics bindings
0

Configure Feed

Select the types of activity you want to include in your feed.

add most of the callback aliases. covered approximately 50% of the api (im 50% through raylib.h). compilation works on test run, but i'm not testing much hehe :3

ellie nil (Jul 14, 2026, 9:22 AM EDT) 9b7f84cd 56ccc8c2

+299 -12
hrm

This is a binary file and will not be displayed.

+289 -6
src/raylib.c3i
··· 1 + /** 2 + * Raylib 6.0 bindings for C3 by Ellie Nil. 3 + * Copyright (c) 2026 Ellie Nil. See LICENSE for terms. 4 + * 5 + * WHAT IS THIS? 6 + * 7 + * This is my (Ellie Nil's) personal set of bindings to 8 + * @raysan5's Raylib library (version 6.0) for C3. 9 + * 10 + * DOESN'T C3 HAVE RAYLIB BINDINGS ALREADY? 11 + * 12 + * Yes, as of C3 version 0.8.1 (current as of writing this), 13 + * there are bindings for both Raylib versions 4 and 5. I'm 14 + * not doing this because I think my bindings should be 15 + * incorporated into C3 or Raylib itself, but mostly as a 16 + * project to become more familiar with C3, Raylib, and 17 + * graphics programming. If they want these bindings, though, 18 + * they're licensed exactly like Raylib itself. 19 + * 20 + * AM I GOOD AT PROGRAMMING? 21 + * 22 + * Not in the slightest. 23 + **/ 24 + 1 25 module raylib6::rl; 2 26 3 27 alias Color = char[<4>]; ··· 248 272 AutomationEvent *events; 249 273 } 250 274 251 - constdef ConfigFlags { 275 + constdef ConfigFlag { 252 276 VSYNC_HINT = 0x00000040, 253 277 FULLSCREEN_MODE = 0x00000002, 254 278 WINDOW_RESIZABLE = 0x00000004, ··· 615 639 THREE_PATCH_HORIZONTAL 616 640 } 617 641 642 + // Callback aliases 643 + alias TraceLogCallback = fn void(TraceLogLevel level, char *text, ...); 644 + alias LoadFileDataCallback = fn char *(char *file_name, int *data_size); 645 + alias SaveFileDataCallback = fn bool(char *file_name, void *data, int data_size); 646 + alias LoadFileTextCallback = fn char *(char *file_name); 647 + alias SaveFileTextCallback = fn bool(char *file_name, char *text); 648 + 649 + // Window-related functions 618 650 extern fn void init_window(int width, int height, char *title) @cname("InitWindow"); 619 651 extern fn void close_window() @cname("CloseWindow"); 620 652 extern fn bool window_should_close() @cname("WindowShouldClose"); ··· 625 657 extern fn bool is_window_maximized() @cname("IsWindowMaximized"); 626 658 extern fn bool is_window_focused() @cname("IsWindowFocused"); 627 659 extern fn bool is_window_resized() @cname("IsWindowResized"); 628 - extern fn bool is_window_state(uint flag) @cname("IsWindowState"); 629 - extern fn void set_window_state(uint flags) @cname("SetWindowState"); 630 - extern fn void clear_window_state(uint flags) @cname("ClearWindowState"); 660 + extern fn bool is_window_state(ConfigFlag flag) @cname("IsWindowState"); 661 + extern fn void set_window_state(ConfigFlag flags) @cname("SetWindowState"); 662 + extern fn void clear_window_state(ConfigFlag flags) @cname("ClearWindowState"); 631 663 extern fn void toggle_fullscreen() @cname("ToggleFullscreen"); 632 664 extern fn void toggle_borderless_windowed() @cname("ToggleBorderlessWindowed"); 633 665 extern fn void maximize_window() @cname("MaximizeWindow"); ··· 664 696 extern fn Image get_clipboard_image() @cname("GetClipboardImage"); 665 697 extern fn void enable_event_waiting() @cname("EnableEventWaiting"); 666 698 extern fn void disable_event_waiting() @cname("DisableEventWaiting"); 699 + 700 + // Cursor-related functions 667 701 extern fn void show_cursor() @cname("ShowCursor"); 668 702 extern fn void hide_cursor() @cname("HideCursor"); 669 703 extern fn bool is_cursor_hidden() @cname("IsCursorHidden"); 670 704 extern fn void enable_cursor() @cname("EnableCursor"); 671 705 extern fn void disable_cursor() @cname("DisableCursor"); 672 706 extern fn bool is_cursor_on_screen() @cname("IsCursorOnScreen"); 707 + 708 + // Drawing-related functions 673 709 extern fn void clear_background(Color color) @cname("ClearBackground"); 674 710 extern fn void begin_drawing() @cname("BeginDrawing"); 675 711 extern fn void end_drawing() @cname("EndDrawing"); ··· 687 723 extern fn void end_scissor_mode() @cname("EndScissorMode"); 688 724 extern fn void begin_vr_stereo_mode(VrStereoConfig config) @cname("BeginVrStereoMode"); 689 725 extern fn void end_vr_stereo_mode() @cname("EndVrStereoMode"); 726 + 727 + // VR stereo config functions 690 728 extern fn VrStereoConfig load_vr_stereo_config(VrDeviceInfo device) @cname("LoadVrStereoConfig"); 691 729 extern fn void unload_vr_stereo_config(VrStereoConfig config) @cname("UnloadVrStereoConfig"); 692 - // to be continued 730 + 731 + // Shader management functions 732 + extern fn Shader load_shader(char *vs_file_name, char *fs_file_name) @cname("LoadShader"); 733 + extern fn Shader load_shader_from_memory(char *cs_code, char *fs_code) @cname("LoadShaderFromMemory"); 734 + extern fn int get_shader_location(Shader shader, char *uniform_name) @cname("GetShaderLocation"); 735 + extern fn int get_shader_location_attrib(Shader shader, char *attrib_name) @cname("GetShaderLocationAttrib"); 736 + extern fn void set_shader_value(Shader shader, int loc_index, void *value, int uniform_type) @cname("SetShaderValue"); 737 + extern fn void set_shader_value_v(Shader shader, int loc_index, void *value, int unirform_type, int count) @cname("GetShaderValueV"); 738 + extern fn void set_shader_value_matrix(Shader shader, int loc_index, Matrix mat) @cname("SetShaderValueMatrix"); 739 + extern fn void set_shader_value_texture(Shader shader, int loc_index, Texture2D texture) @cname("SetShaderValueTexture"); 740 + extern fn void unload_shader(Shader shader) @cname("UnloadShader"); 741 + 742 + // Screen-space-related functions 743 + extern fn Ray get_screen_to_world_ray(Vector2 position, Camera camera) @cname("GetScreenToWorldRay"); 744 + extern fn Ray get_screen_to_world_ray_ex(Vector2 position, Camera camera, int width, int height) @cname("GetScreenToWorldRayEx"); 745 + extern fn Vector2 get_world_to_screen(Vector3 postion, Camera camera) @cname("GetWorldToScreen"); 746 + extern fn Vector2 get_world_to_screen_ex(Vector4 position, Camera camera, int width, int height) @cname("GetWorldToScreenEx"); 747 + extern fn Vector2 get_world_to_screen_2d(Vector2 position, Camera2D camera) @cname("GetWorldToScreen2D"); 748 + extern fn Vector2 get_screen_to_world_2d(Vector2 position, Camera2D camera) @cname("GetScreenToWorld2D"); 749 + extern fn Matrix get_camera_matrix(Camera camera) @cname("GetCameraMatrix"); 750 + extern fn Matrix get_camera_matrix_2d(Camera2D camera) @cname("GetCameraMatrix2D"); 751 + 752 + // Timing-related functions 753 + extern fn void set_target_fps(int fps) @cname("SetTargetFPS"); 754 + extern fn float get_frame_time() @cname("GetFrameTime"); 755 + extern fn double get_time() @cname("GetTime"); 756 + extern fn int get_fps() @cname("GetFPS"); 757 + 758 + // Custom frame control functions 759 + extern fn void swap_screen_buffer() @cname("SwapScreenBuffer"); 760 + extern fn void poll_input_events() @cname("PollInputEvents"); 761 + extern fn void wait_time(double seconds) @cname("WaitTime"); 762 + 763 + // Random values generation functions 764 + extern fn void set_random_seed(uint seed) @cname("SetRandomSeed"); 765 + extern fn int get_random_value(int min, int max) @cname("GetRandomValue"); 766 + extern fn int *load_random_sequence(uint count, int min, int max) @cname("LoadRandomSequence"); 767 + extern fn void unload_random_sequence(int *sequence) @cname("UnloadRandomSequence"); 768 + 769 + // Misc. functions 770 + extern fn void take_screenshot(char *file_name) @cname("TakeScreenshot"); 771 + extern fn void set_config_flags(ConfigFlag flags) @cname("SetConfigFlags"); 772 + extern fn void open_url(char *url) @cname("OpenURL"); 773 + 774 + // Logging system 775 + extern fn void set_trace_log_level(TraceLogLevel level) @cname("SetTraceLogLevel"); 776 + extern fn void trace_log(TraceLogLevel level, char *text, ...) @cname("TraceLog"); 777 + extern fn void set_trace_log_callback(TraceLogCallback callback) @cname("SetTraceLogCallback"); 778 + 779 + 780 + // Memory management, using internal allocators 781 + extern fn void *mem_alloc(uint size) @cname("MemAlloc"); 782 + extern fn void *mem_realloc(void *ptr, uint size) @cname("MemRealloc"); 783 + extern fn void mem_free(void *ptr) @cname("MemFree"); 784 + 785 + // File system management functions 786 + extern fn char *load_file_data(char *file_name, int *data_size) @cname("LoadFileData"); 787 + extern fn void unload_file_data(char *data) @cname("UnloadFileData"); 788 + extern fn bool save_file_data(char *file_name, void *data, int data_size) @cname("SaveFileData"); 789 + extern fn bool export_data_as_code(char *data, int data_size, char *file_name) @cname("ExportDataAsCode"); 790 + extern fn char *load_file_text(char *file_name) @cname("LoadFileText"); 791 + extern fn void unload_file_text(char *text) @cname("UnloadFileText"); 792 + extern fn bool save_file_text(char *file_name, char *text) @cname("SaveFileText"); 793 + 794 + // File access custom callbacks 795 + extern fn void set_load_file_data_callback(LoadFileDataCallback callback) @cname("SetLoadFileDataCallback"); 796 + extern fn void set_save_file_data_callback(SaveFileDataCallback callback) @cname("SetSaveFileDataCallback"); 797 + extern fn void set_load_file_text_callback(LoadFileTextCallback callback) @cname("SetLoadFileTextCallback"); 798 + extern fn void set_save_file_text_callback(SaveFileTextCallback callback) @cname("SetSaveFileTextCallback"); 799 + 800 + extern fn int file_rename(char *file_name, char *file_rename) @cname("FileRename"); 801 + extern fn int file_remove(char *file_name) @cname("FileRemove"); 802 + extern fn int file_copy(char *source_path, char *dest_path) @cname("FileCopy"); 803 + extern fn int file_move(char *source_path, char *dest_path) @cname("FileMove"); 804 + extern fn int file_text_replace(char *file_name, char *search, char *replacement) @cname("FileTextReplace"); 805 + extern fn int file_text_find_index(char *file_name, char *search) @cname("FileTextFindIndex"); 806 + extern fn bool file_exists(char *file_name) @cname("FileExists"); 807 + extern fn bool directory_exists(char *dir_path) @cname("DirectoryExists"); 808 + extern fn bool is_file_extension(char *file_name, char *ext) @cname("IsFileExtension"); 809 + extern fn int get_file_length(char *file_name) @cname("GetFileLength"); 810 + extern fn long get_file_mod_time(char *file_name) @cname("GetFileModTime"); 811 + extern fn char *get_file_extension(char *file_name) @cname("GetFileExtension"); 812 + extern fn char *get_file_name(char *file_path) @cname("GetFileName"); 813 + extern fn char *get_file_name_without_ext(char *file_path) @cname("GetFileNameWithoutExt"); 814 + extern fn char *get_directory_path(char *dir_path) @cname("GetDirectoryPath"); 815 + extern fn char *get_prev_directory_path(char *dir_path) @cname("GetPrevDirectoryPath"); 816 + extern fn char *get_working_directory() @cname("GetWorkingDirectory"); 817 + extern fn char *get_application_directory() @cname("GetApplicationDirectory"); 818 + extern fn int make_directory(char *dir_path) @cname("MakeDirectory"); 819 + extern fn bool change_directory(char *dir_path) @cname("ChangeDirectory"); 820 + extern fn bool is_path_file(char *path) @cname("IsPathFile"); 821 + extern fn bool is_file_name_valid(char *file_name) @cname("IsFileNameValid"); 822 + extern fn FilePathList load_directory_files(char *dir_path) @cname("LoadDirectoryFiles"); 823 + extern fn FilePathList load_directory_files_ex(char *base_path, char *filter, bool scan_subdirs) @cname("LoadDirectoryFilesEx"); 824 + extern fn void unload_directory_files(FilePathList files) @cname("UnloadDirectoryFiles"); 825 + extern fn bool is_file_dropped() @cname("IsFileDropped"); 826 + extern fn FilePathList load_dropped_files() @cname("LoadDroppedFiles"); 827 + extern fn void unload_dropped_files(FilePathList files) @cname("UnloadDroppedFiles"); 828 + extern fn uint get_directory_file_count(char *dir_path) @cname("GetDirectoryFileCount"); 829 + extern fn uint get_directory_file_count_ex(char *base_path, char *filter, bool scan_subdirs) @cname("GetDirectoryFileCountEx"); 830 + 831 + // Compression/Encoding functionality 832 + // ... 833 + 834 + // Automation events functionality 835 + // ... 836 + 837 + /** 838 + * Input handling functions 839 + **/ 840 + 841 + // Keyboard input functions 842 + // ... 843 + extern fn bool is_key_pressed(KeyboardKey key) @cname("IsKeyPressed"); 844 + 845 + // Gamepad input functions 846 + // ... 847 + 848 + // Mouse input functions 849 + // ... 850 + 851 + // Touch input functions 852 + // ... 853 + 854 + /** 855 + * Gesture and touch handling functions 856 + **/ 857 + //... 858 + 859 + /** 860 + * Camera system functions 861 + **/ 862 + 863 + /** 864 + * Basic shape drawing functions 865 + **/ 866 + 867 + // Basic shapes 868 + extern fn void draw_pixel(int pos_x, int pos_y, Color color) @cname("DrawPixel"); 693 869 extern fn void draw_rectangle(Rectangle rec, Color color) @cname("DrawRectangleRec"); 694 870 extern fn void draw_poly(Vector2 center, int sides, float radius, float rotation, Color color) @cname("DrawPoly"); 695 - extern fn void draw_pixel(int pos_x, int pos_y, Color color) @cname("DrawPixel"); 871 + //... 872 + 873 + // Splines drawing functions 874 + // ... 875 + 876 + // Spline segment point evaluation functions, for a given t [0.0f .. 1.0f] 877 + // ... 878 + 879 + // Basic shapes collision detection functions 880 + // ... 881 + 882 + /** 883 + * Texture Loading and Drawing Functions 884 + **/ 885 + 886 + // Image loading functions 887 + // ... 888 + 889 + // Image manipulation functions 890 + // ... 891 + 892 + // Image drawing functions 893 + // ... 894 + 895 + // Texture loading functions 896 + // ... 897 + 898 + // Texture configuration functions 899 + // ... 900 + 901 + // Texture drawing functions 902 + // ... 903 + 904 + // Color/pixel related functions 905 + // ... 906 + 907 + /** 908 + * Font Loading and Text Drawing functions 909 + **/ 910 + 911 + // Font loading/unloading functions 912 + // ... 913 + 914 + // Text drawing functions 915 + // ... 916 + 917 + // Text font info functions 918 + // ... 919 + 920 + // Text codepoint management functions (uncode "chars") 921 + // ... 922 + 923 + // Text strings management functions (byte chars only) 924 + // ... 925 + 926 + /** 927 + * Basic 3D Shapes drawing functions 928 + **/ 929 + 930 + // Basic geometric 3D shapes drawing functions 931 + // ... 932 + 933 + /** 934 + * Model 3D Loading and Drawing functions 935 + **/ 936 + 937 + // Model management functions 938 + // ... 939 + 940 + // Model drawing functions 941 + // ... 942 + 943 + // Mesh management functions 944 + // ... 945 + 946 + // Mesh generation functions 947 + // ... 948 + 949 + // Material loading/unloading functions 950 + // ... 951 + 952 + // Model animations loading/unloading functions 953 + // ... 954 + 955 + // Collision detection functions 956 + // ... 957 + 958 + /** 959 + * Audio Loading and Playing Functions 960 + **/ 961 + // some kind of typedef of void to a callback??? 962 + 963 + // Audio device management functions 964 + // ... 965 + 966 + // Wave/Sound loading/unlaoding functions 967 + // ... 968 + 969 + // Wave/Sound management functions 970 + // ... 971 + 972 + // Music management functions 973 + // ... 974 + 975 + // AudioStream management functions 976 + // ... 977 + 978 + /* end raylib6 */
+10 -6
test/test.c3
··· 9 9 10 10 fn void main() 11 11 { 12 - Rectangle rect = {50, 30, 20.0, 20.0}; 13 - Color red = {255, 0, 0, 255}; 14 - Color pink = {255, 200, 200, 255}; 15 - Vector2 true_origin = {400, 300}; 16 - rl::init_window(800, 600, "penis"); 12 + // Rectangle rect = {100, 100, 120.0, 120.0}; 13 + // Color red = {255, 0, 0, 255}; 14 + // Color pink = {255, 200, 200, 255}; 15 + rl::init_window(1280, 720, "raylib6.c3 test"); 16 + float mult = 1.0; 17 + rl::set_target_fps(10000); 18 + rl::set_window_state(WINDOW_RESIZABLE); 17 19 while (!rl::window_should_close()) { 18 20 int screen_height = rl::get_screen_height(); 19 21 int screen_width = rl::get_screen_width(); 20 22 rl::begin_drawing(); 21 23 for(int i = 0; i < screen_width; i++) { 22 24 for (int j = 0; j < screen_height; j++) { 23 - rl::draw_pixel(i, j, random_color()); 25 + char x = (char)i; 26 + char y = (char)j; 27 + rl::draw_pixel(i, j, {x, y, x | y, x & y}); 24 28 } 25 29 } 26 30 rl::end_drawing();