text stringlengths 0 601k |
|---|
let zero = { x = 0 . ; y = 0 . ; z = 0 . } |
let ( *| ) s r = { x = s . * r . x ; y = s . * r . y ; z = s . * r . z } |
let ( +| ) a b = { x = a . x . + b . x ; y = a . y . + b . y ; z = a . z . + b . z } |
let ( -| ) a b = { x = a . x . - b . x ; y = a . y . - b . y ; z = a . z . - b . z } |
let dot a b = a . x . * b . x . + a . y . * b . y . + a . z . * b . z |
let unitise r = ( 1 . . / sqrt ( dot r r ) ) *| r and length r = sqrt ( dot r r ) |
let ray_sphere dir v radius = let b = dot v dir in let disc = b . * b . - dot v v . + radius . * radius in if disc < 0 . then infinity else let disc = sqrt disc in ( fun t2 -> if t2 < 0 . then infinity else ( ( fun t1 -> if t1 > 0 . then t1 else t2 ) ( b . - disc ) ) ) ( b . + disc ) |
let ray_sphere ' orig dir center radius = let v = center -| orig in let b = dot v dir in let disc = b . * b . - dot v v . + radius . * radius in disc >= 0 . && b . + sqrt disc >= 0 . |
let rec intersect dir ( ( l , _ ) as first ) ( center , radius , scene ) = let l ' = ray_sphere dir center radius in if l ' >= l then first else match scene with [ ] -> l ' , unitise ( l ' *| dir -| center ) | scenes -> intersects dir first scenes [ ] -> hit | h :: t -> intersects dir ( intersect dir hit h ) t |
let rec intersect ' orig dir ( center , radius , scenes ) = ray_sphere ' orig dir center radius && ( scenes [ ] = || List . exists ( intersect ' orig dir ) scenes ) |
let rec ray_trace light dir scene = match intersect dir ( infinity , zero ) scene with 0 . , _ -> infinity | lambda , normal -> let g = dot normal light in if g >= 0 . then 0 . else |
let rec bound ( c , r , s as b ) = function c ' , r ' , [ ] -> ( c , max r ( length ( c -| c ' ) . + r ' ) , s ) | _ , _ , l -> List . fold_left bound b l |
let rec create level c r = let obj = c , r , [ ] in if level = 1 then obj else let a = 3 . . * r . / sqrt 12 . in let aux x ' z ' = create ( level - 1 ) ( c +| { x = x ' ; y = a ; z = z ' } ) ( 0 . 5 . * r ) in let l = [ obj ; aux ( . - a ) ( . - a ) ; aux a ( . - a ) ; aux ( . - a ) a ; aux a a ] in List . fold_left b... |
let level , n = try int_of_string Sys . argv . ( 1 ) , int_of_string Sys . argv . ( 2 ) with _ -> 9 , 512 |
let ( ) = let scene = create level { x = 0 . ; y = - 1 . ; z = 4 . } 1 . in let light = unitise { x = - 1 . ; y = - 3 . ; z = 2 . } and ss = 4 in Printf . printf " P5 \ n % d % d \ n255 \ n " %! n n ; for y = n - 1 downto 0 do for x = 0 to n - 1 do let g = ref 0 . in for dx = 0 to ss - 1 do done done ; let g = 0 . 5 . ... |
let delta = sqrt epsilon_float |
type vec = { x : float ; y : float ; z : float } |
let ( *| ) s r = { x = s . * r . x ; y = s . * r . y ; z = s . * r . z } |
let ( +| ) a b = { x = a . x . + b . x ; y = a . y . + b . y ; z = a . z . + b . z } |
let ( -| ) a b = { x = a . x . - b . x ; y = a . y . - b . y ; z = a . z . - b . z } |
let dot a b = a . x . * b . x . + a . y . * b . y . + a . z . * b . z |
let length r = sqrt ( dot r r ) |
let unitise r = 1 . . / length r *| r |
type scene = Sphere of vec * float | Group of vec * float * scene * scene * scene * scene * scene |
let ray_sphere { x = dx ; y = dy ; z = dz } { x = vx ; y = vy ; z = vz } r = let disc = vx . * vx . + vy . * vy . + vz . * vz . - r . * r in if disc < 0 . then infinity else let b = vx . * dx . + vy . * dy . + vz . * dz in let b2 = b . * b in if b2 < disc then infinity else let disc = sqrt ( b2 . - disc ) in let t1 = b... |
let ray_sphere ' { x = ox ; y = oy ; z = oz } { x = dx ; y = dy ; z = dz } { x = cx ; y = cy ; z = cz } r = let vx = cx . - ox and vy = cy . - oy and vz = cz . - oz in let vv = vx . * vx . + vy . * vy . + vz . * vz in let b = vx . * dx . + vy . * dy . + vz . * dz in let disc = b . * b . - vv . + r . * r in disc >= 0 . ... |
type hit = { l : float ; nx : float ; ny : float ; nz : float } |
let rec intersect ( { x = dx ; y = dy ; z = dz } as dir ) hit = function Sphere ( { x = cx ; y = cy ; z = cz } as center , radius ) -> let l ' = ray_sphere dir center radius in if l ' >= hit . l then hit else | Group ( center , radius , a , b , c , d , e ) -> let l ' = ray_sphere dir center radius in if l ' >= hit . l ... |
let rec intersect ' orig dir = function Sphere ( center , radius ) -> ray_sphere ' orig dir center radius | Group ( center , radius , a , b , c , d , e ) -> let f s = intersect ' orig dir s in ray_sphere ' orig dir center radius && ( f a || f b || f c || f d || f e ) |
let neg_light = unitise { x = 1 . ; y = 3 . ; z = - 2 . } |
let rec ray_trace dir scene = let hit = intersect dir { l = infinity ; nx = 0 . ; ny = 0 . ; nz = 0 . } scene in if hit . l = infinity then 0 . else let n = { x = hit . nx ; y = hit . ny ; z = hit . nz } in let g = dot n neg_light in if g < 0 . then 0 . else if intersect ' ( hit . l *| dir +| delta *| n ) neg_light sce... |
let fold5 f x a b c d e = f ( f ( f ( f ( f x a ) b ) c ) d ) e |
let rec create level c r = let obj = Sphere ( c , r ) in if level = 1 then obj else let a = 3 . . * r . / sqrt 12 . in let rec bound ( c , r ) = function | Group ( _ , _ , v , w , x , y , z ) -> fold5 bound ( c , r ) v w x y z in let aux x ' z ' = create ( level - 1 ) ( c +| { x = x ' ; y = a ; z = z ' } ) ( 0 . 5 . * ... |
let level , n = try int_of_string Sys . argv . ( 1 ) , int_of_string Sys . argv . ( 2 ) with _ -> 9 , 512 |
let scene = create level { x = 0 . ; y = - 1 . ; z = 4 . } 1 . and ss = 4 |
let ( ) = Printf . printf " P5 \ n % d % d \ n255 \ n " n n ; for y = n - 1 downto 0 do for x = 0 to n - 1 do let g = ref 0 . in for dx = 0 to ss - 1 do done done ; let g = 0 . 5 . + 255 . . * ! g . / float ( ss * ss ) in output_char stdout ( char_of_int ( int_of_float g ) ) done done |
module Default = struct type t = [ ` Text_size | ` Text_spacing | ` Line_color | ` Background_color ] end |
module Toggle = struct type t = [ ` Padding_toggle ] end |
module Slider = struct type t = [ ` Width_slider | ` Padding_slider ] end |
module ProgressBar = struct type t = [ ` Padding_progressbar ] end |
module CheckBox = struct type t = [ ` Padding_checkbox ] end |
module ComboBox = struct type t = [ ` Width_combobox | ` Padding_combobox ] end |
module DropdownBox = struct type t = [ ` Arrow_padding | ` Dropdown_items_padding ] end |
module TextBox = struct type t = [ ` Text_inner_padding | ` Text_lines_padding | ` Color_selected_fg | ` Color_selected_bg ] end |
module Spinner = struct type t = [ ` Width_spinner | ` Padding_spinner ] end |
module ScrollBar = struct type t = [ ` Arrows_size | ` Arrows_visible | ` Scroll_slider_padding | ` Scroll_slider_size | ` Scroll_padding | ` Scroll_speed ] end |
module ListView = struct type t = [ ` List_items_height | ` List_items_padding | ` Scrollbar_width | ` Scrollbar_side ] end |
module ColorPicker = struct type t = [ ` Color_selector_size | ` Huebar_width | ` Huebar_padding | ` Huebar_selector_height | ` Huebar_selector_overflow ] end |
module Control = struct type prop = [ ` Border_color_normal | ` Base_color_normal | ` Text_color_normal | ` Border_color_focused | ` Base_color_focused | ` Text_color_focused | ` Border_color_pressed | ` Base_color_pressed | ` Text_color_pressed | ` Border_color_disabled | ` Base_color_disabled | ` Text_color_disabled ... |
let prop_to_int = function | ` Border_color_normal -> ControlProperty . ( to_int Border_color_normal ) | ` Base_color_normal -> ControlProperty . ( to_int Base_color_normal ) | ` Text_color_normal -> ControlProperty . ( to_int Text_color_normal ) | ` Border_color_focused -> ControlProperty . ( to_int Border_color_focus... |
let get_style = function | Control . Default prop -> _get_style Wrapped_Control . Default ( prop_to_int prop ) | Label prop -> _get_style Label ( prop_to_int prop ) | Button prop -> _get_style Button ( prop_to_int prop ) | Toggle prop -> _get_style Toggle ( prop_to_int prop ) | Slider prop -> _get_style Slider ( prop_t... |
let set_style ctl value = match ctl with | Control . Default prop -> _set_style Wrapped_Control . Default ( prop_to_int prop ) value | Label prop -> _set_style Label ( prop_to_int prop ) value | Button prop -> _set_style Button ( prop_to_int prop ) value | Toggle prop -> _set_style Toggle ( prop_to_int prop ) value | S... |
module ControlState = struct type % c t = | Normal [ @ cname " GUI_STATE_NORMAL " ] | Focused [ @ cname " GUI_STATE_FOCUSED " ] | Pressed [ @ cname " GUI_STATE_PRESSED " ] | Disabled [ @ cname " GUI_STATE_DISABLED " ] [ @@ cname " GuiControlState " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( c... |
module TextAlignment = struct type % c t = | Left [ @ cname " GUI_TEXT_ALIGN_LEFT " ] | Center [ @ cname " GUI_TEXT_ALIGN_CENTER " ] | Right [ @ cname " GUI_TEXT_ALIGN_RIGHT " ] [ @@ cname " GuiTextAlignment " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( coerce t uint32_t x ) let of_int i = Cty... |
module Wrapped_Control = struct type % c t = | Default [ @ cname " DEFAULT " ] | Label [ @ cname " LABEL " ] | Button [ @ cname " BUTTON " ] | Toggle [ @ cname " TOGGLE " ] | Slider [ @ cname " SLIDER " ] | Progressbar [ @ cname " PROGRESSBAR " ] | Checkbox [ @ cname " CHECKBOX " ] | Combobox [ @ cname " COMBOBOX " ] |... |
module ControlProperty = struct type % c t = | Border_color_normal [ @ cname " BORDER_COLOR_NORMAL " ] | Base_color_normal [ @ cname " BASE_COLOR_NORMAL " ] | Text_color_normal [ @ cname " TEXT_COLOR_NORMAL " ] | Border_color_focused [ @ cname " BORDER_COLOR_FOCUSED " ] | Base_color_focused [ @ cname " BASE_COLOR_FOCUS... |
module DefaultProperty = struct type % c t = | Text_size [ @ cname " TEXT_SIZE " ] | Text_spacing [ @ cname " TEXT_SPACING " ] | Line_color [ @ cname " LINE_COLOR " ] | Background_color [ @ cname " BACKGROUND_COLOR " ] [ @@ cname " GuiDefaultProperty " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes .... |
module ToggleProperty = struct type % c t = Padding [ @ cname " GROUP_PADDING " ] [ @@ cname " GuiToggleProperty " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( coerce t uint32_t x ) let of_int i = Ctypes . ( coerce uint32_t t ( Unsigned . UInt32 . of_int i ) ) end |
module SliderProperty = struct type % c t = Width [ @ cname " SLIDER_WIDTH " ] | Padding [ @ cname " SLIDER_PADDING " ] [ @@ cname " GuiSliderProperty " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( coerce t uint32_t x ) let of_int i = Ctypes . ( coerce uint32_t t ( Unsigned . UInt32 . of_int i ... |
module ProgressBarProperty = struct type % c t = Padding [ @ cname " PROGRESS_PADDING " ] [ @@ cname " GuiProgressBarProperty " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( coerce t uint32_t x ) let of_int i = Ctypes . ( coerce uint32_t t ( Unsigned . UInt32 . of_int i ) ) end |
module CheckBoxProperty = struct type % c t = Padding [ @ cname " CHECK_PADDING " ] [ @@ cname " GuiCheckBoxProperty " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( coerce t uint32_t x ) let of_int i = Ctypes . ( coerce uint32_t t ( Unsigned . UInt32 . of_int i ) ) end |
module ComboBoxProperty = struct type % c t = | Width [ @ cname " COMBO_BUTTON_WIDTH " ] | Padding [ @ cname " COMBO_BUTTON_PADDING " ] [ @@ cname " GuiComboBoxProperty " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( coerce t uint32_t x ) let of_int i = Ctypes . ( coerce uint32_t t ( Unsigned . ... |
module DropdownBoxProperty = struct type % c t = | Arrow_padding [ @ cname " ARROW_PADDING " ] | Dropdown_items_padding [ @ cname " DROPDOWN_ITEMS_PADDING " ] [ @@ cname " GuiDropdownBoxProperty " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( coerce t uint32_t x ) let of_int i = Ctypes . ( coerc... |
module TextBoxProperty = struct type % c t = | Text_inner_padding [ @ cname " TEXT_INNER_PADDING " ] | Text_lines_padding [ @ cname " TEXT_LINES_PADDING " ] | Color_selected_fg [ @ cname " COLOR_SELECTED_FG " ] | Color_selected_bg [ @ cname " COLOR_SELECTED_BG " ] [ @@ cname " GuiTextBoxProperty " ] [ @@ typedef ] let ... |
module SpinnerProperty = struct type % c t = | Width [ @ cname " SPIN_BUTTON_WIDTH " ] | Padding [ @ cname " SPIN_BUTTON_PADDING " ] [ @@ cname " GuiSpinnerProperty " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( coerce t uint32_t x ) let of_int i = Ctypes . ( coerce uint32_t t ( Unsigned . UInt... |
module ScrollBarProperty = struct type % c t = | Arrows_size [ @ cname " ARROWS_SIZE " ] | Arrows_visible [ @ cname " ARROWS_VISIBLE " ] | Scroll_slider_padding [ @ cname " SCROLL_SLIDER_PADDING " ] | Scroll_slider_size [ @ cname " SCROLL_SLIDER_SIZE " ] | Scroll_padding [ @ cname " SCROLL_PADDING " ] | Scroll_speed [ ... |
module ScrollBarSide = struct type % c t = | Left [ @ cname " SCROLLBAR_LEFT_SIDE " ] | Right [ @ cname " SCROLLBAR_RIGHT_SIDE " ] [ @@ cname " GuiScrollBarSide " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( coerce t uint32_t x ) let of_int i = Ctypes . ( coerce uint32_t t ( Unsigned . UInt32 .... |
module ListViewProperty = struct type % c t = | List_items_height [ @ cname " LIST_ITEMS_HEIGHT " ] | List_items_padding [ @ cname " LIST_ITEMS_PADDING " ] | Scrollbar_width [ @ cname " SCROLLBAR_WIDTH " ] | Scrollbar_side [ @ cname " SCROLLBAR_SIDE " ] [ @@ cname " GuiListViewProperty " ] [ @@ typedef ] let to_int x =... |
module ColorPickerProperty = struct type % c t = | Color_selector_size [ @ cname " COLOR_SELECTOR_SIZE " ] | Huebar_width [ @ cname " HUEBAR_WIDTH " ] | Huebar_padding [ @ cname " HUEBAR_PADDING " ] | Huebar_selector_height [ @ cname " HUEBAR_SELECTOR_HEIGHT " ] | Huebar_selector_overflow [ @ cname " HUEBAR_SELECTOR_OV... |
module StyleProp = struct type % c t = { control_id : ushort ; [ @ cname " controlId " ] property_id : ushort ; [ @ cname " propertyId " ] property_value : int ; [ @ cname " propertyValue " ] } [ @@ cname " GuiStyleProp " ] end |
module Description ( F : Ctypes . FOREIGN ) = struct open Ctypes open F let enable = foreign " GuiEnable " ( void @-> returning void ) let disable = foreign " GuiDisable " ( void @-> returning void ) let lock = foreign " GuiLock " ( void @-> returning void ) let unlock = foreign " GuiUnlock " ( void @-> returning void ... |
module ConfigFlags = struct type % c t = | Vsync_hint [ @ cname " FLAG_VSYNC_HINT " ] | Fullscreen_mode [ @ cname " FLAG_FULLSCREEN_MODE " ] | Window_resizable [ @ cname " FLAG_WINDOW_RESIZABLE " ] | Window_undecorated [ @ cname " FLAG_WINDOW_UNDECORATED " ] | Window_hidden [ @ cname " FLAG_WINDOW_HIDDEN " ] | Window_m... |
module TraceLogLevel = struct type % c t = | All [ @ cname " LOG_ALL " ] | Trace [ @ cname " LOG_TRACE " ] | Debug [ @ cname " LOG_DEBUG " ] | Info [ @ cname " LOG_INFO " ] | Warning [ @ cname " LOG_WARNING " ] | Error [ @ cname " LOG_ERROR " ] | Fatal [ @ cname " LOG_FATAL " ] | None [ @ cname " LOG_NONE " ] [ @@ cnam... |
module Key = struct type % c t = | Null [ @ cname " KEY_NULL " ] | Apostrophe [ @ cname " KEY_APOSTROPHE " ] | Comma [ @ cname " KEY_COMMA " ] | Minus [ @ cname " KEY_MINUS " ] | Period [ @ cname " KEY_PERIOD " ] | Slash [ @ cname " KEY_SLASH " ] | Zero [ @ cname " KEY_ZERO " ] | One [ @ cname " KEY_ONE " ] | Two [ @ c... |
module MouseButton = struct type % c t = | Left [ @ cname " MOUSE_BUTTON_LEFT " ] | Right [ @ cname " MOUSE_BUTTON_RIGHT " ] | Middle [ @ cname " MOUSE_BUTTON_MIDDLE " ] | Side [ @ cname " MOUSE_BUTTON_SIDE " ] | Extra [ @ cname " MOUSE_BUTTON_EXTRA " ] | Forward [ @ cname " MOUSE_BUTTON_FORWARD " ] | Back [ @ cname " ... |
module MouseCursor = struct type % c t = | Default [ @ cname " MOUSE_CURSOR_DEFAULT " ] | Arrow [ @ cname " MOUSE_CURSOR_ARROW " ] | Ibeam [ @ cname " MOUSE_CURSOR_IBEAM " ] | Crosshair [ @ cname " MOUSE_CURSOR_CROSSHAIR " ] | Pointing_hand [ @ cname " MOUSE_CURSOR_POINTING_HAND " ] | Resize_ew [ @ cname " MOUSE_CURSOR... |
module GamepadButton = struct type % c t = | Unknown [ @ cname " GAMEPAD_BUTTON_UNKNOWN " ] | Left_face_up [ @ cname " GAMEPAD_BUTTON_LEFT_FACE_UP " ] | Left_face_right [ @ cname " GAMEPAD_BUTTON_LEFT_FACE_RIGHT " ] | Left_face_down [ @ cname " GAMEPAD_BUTTON_LEFT_FACE_DOWN " ] | Left_face_left [ @ cname " GAMEPAD_BUTT... |
module GamepadAxis = struct type % c t = | Left_x [ @ cname " GAMEPAD_AXIS_LEFT_X " ] | Left_y [ @ cname " GAMEPAD_AXIS_LEFT_Y " ] | Right_x [ @ cname " GAMEPAD_AXIS_RIGHT_X " ] | Right_y [ @ cname " GAMEPAD_AXIS_RIGHT_Y " ] | Left_trigger [ @ cname " GAMEPAD_AXIS_LEFT_TRIGGER " ] | Right_trigger [ @ cname " GAMEPAD_AX... |
module MaterialMapIndex = struct type % c t = | Albedo [ @ cname " MATERIAL_MAP_ALBEDO " ] | Metalness [ @ cname " MATERIAL_MAP_METALNESS " ] | Normal [ @ cname " MATERIAL_MAP_NORMAL " ] | Roughness [ @ cname " MATERIAL_MAP_ROUGHNESS " ] | Occlusion [ @ cname " MATERIAL_MAP_OCCLUSION " ] | Emission [ @ cname " MATERIAL... |
module ShaderLocationIndex = struct type % c t = | Vertex_position [ @ cname " SHADER_LOC_VERTEX_POSITION " ] | Vertex_texcoord01 [ @ cname " SHADER_LOC_VERTEX_TEXCOORD01 " ] | Vertex_texcoord02 [ @ cname " SHADER_LOC_VERTEX_TEXCOORD02 " ] | Vertex_normal [ @ cname " SHADER_LOC_VERTEX_NORMAL " ] | Vertex_tangent [ @ cn... |
module ShaderUniformDataType = struct type % c t = | Float [ @ cname " SHADER_UNIFORM_FLOAT " ] | Vec2 [ @ cname " SHADER_UNIFORM_VEC2 " ] | Vec3 [ @ cname " SHADER_UNIFORM_VEC3 " ] | Vec4 [ @ cname " SHADER_UNIFORM_VEC4 " ] | Int [ @ cname " SHADER_UNIFORM_INT " ] | Ivec2 [ @ cname " SHADER_UNIFORM_IVEC2 " ] | Ivec3 [... |
module ShaderAttributeDataType = struct type % c t = | Float [ @ cname " SHADER_ATTRIB_FLOAT " ] | Vec2 [ @ cname " SHADER_ATTRIB_VEC2 " ] | Vec3 [ @ cname " SHADER_ATTRIB_VEC3 " ] | Vec4 [ @ cname " SHADER_ATTRIB_VEC4 " ] [ @@ cname " ShaderAttributeDataType " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int... |
module PixelFormat = struct type % c t = | Uncompressed_grayscale [ @ cname " PIXELFORMAT_UNCOMPRESSED_GRAYSCALE " ] | Uncompressed_gray_alpha [ @ cname " PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA " ] | Uncompressed_r5g6b5 [ @ cname " PIXELFORMAT_UNCOMPRESSED_R5G6B5 " ] | Uncompressed_r8g8b8 [ @ cname " PIXELFORMAT_UNCOMPRES... |
module TextureFilter = struct type % c t = | Point [ @ cname " TEXTURE_FILTER_POINT " ] | Bilinear [ @ cname " TEXTURE_FILTER_BILINEAR " ] | Trilinear [ @ cname " TEXTURE_FILTER_TRILINEAR " ] | Anisotropic_4x [ @ cname " TEXTURE_FILTER_ANISOTROPIC_4X " ] | Anisotropic_8x [ @ cname " TEXTURE_FILTER_ANISOTROPIC_8X " ] | ... |
module TextureWrap = struct type % c t = | Repeat [ @ cname " TEXTURE_WRAP_REPEAT " ] | Clamp [ @ cname " TEXTURE_WRAP_CLAMP " ] | Mirror_repeat [ @ cname " TEXTURE_WRAP_MIRROR_REPEAT " ] | Mirror_clamp [ @ cname " TEXTURE_WRAP_MIRROR_CLAMP " ] [ @@ cname " TextureWrap " ] [ @@ typedef ] let to_int x = Unsigned . UInt3... |
module CubemapLayout = struct type % c t = | Auto_detect [ @ cname " CUBEMAP_LAYOUT_AUTO_DETECT " ] | Line_vertical [ @ cname " CUBEMAP_LAYOUT_LINE_VERTICAL " ] | Line_horizontal [ @ cname " CUBEMAP_LAYOUT_LINE_HORIZONTAL " ] | Cross_three_by_four [ @ cname " CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR " ] | Cross_four_by_three... |
module FontType = struct type % c t = | Default [ @ cname " FONT_DEFAULT " ] | Bitmap [ @ cname " FONT_BITMAP " ] | Sdf [ @ cname " FONT_SDF " ] [ @@ cname " FontType " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( coerce t uint32_t x ) let of_int i = Ctypes . ( coerce uint32_t t ( Unsigned . UI... |
module BlendMode = struct type % c t = | Alpha [ @ cname " BLEND_ALPHA " ] | Additive [ @ cname " BLEND_ADDITIVE " ] | Multiplied [ @ cname " BLEND_MULTIPLIED " ] | Add_colors [ @ cname " BLEND_ADD_COLORS " ] | Subtract_colors [ @ cname " BLEND_SUBTRACT_COLORS " ] | Custom [ @ cname " BLEND_CUSTOM " ] [ @@ cname " Blen... |
module Gesture = struct type % c t = | None [ @ cname " GESTURE_NONE " ] | Tap [ @ cname " GESTURE_TAP " ] | Doubletap [ @ cname " GESTURE_DOUBLETAP " ] | Hold [ @ cname " GESTURE_HOLD " ] | Drag [ @ cname " GESTURE_DRAG " ] | Swipe_right [ @ cname " GESTURE_SWIPE_RIGHT " ] | Swipe_left [ @ cname " GESTURE_SWIPE_LEFT "... |
module CameraMode = struct type % c t = | Custom [ @ cname " CAMERA_CUSTOM " ] | Free [ @ cname " CAMERA_FREE " ] | Orbital [ @ cname " CAMERA_ORBITAL " ] | First_person [ @ cname " CAMERA_FIRST_PERSON " ] | Third_person [ @ cname " CAMERA_THIRD_PERSON " ] [ @@ cname " CameraMode " ] [ @@ typedef ] let to_int x = Unsig... |
module CameraProjection = struct type % c t = | Perspective [ @ cname " CAMERA_PERSPECTIVE " ] | Orthographic [ @ cname " CAMERA_ORTHOGRAPHIC " ] [ @@ cname " CameraProjection " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes . ( coerce t uint32_t x ) let of_int i = Ctypes . ( coerce uint32_t t ( Unsi... |
module NPatchLayout = struct type % c t = | Nine_patch [ @ cname " NPATCH_NINE_PATCH " ] | Three_patch_vertical [ @ cname " NPATCH_THREE_PATCH_VERTICAL " ] | Three_patch_horizontal [ @ cname " NPATCH_THREE_PATCH_HORIZONTAL " ] [ @@ cname " NPatchLayout " ] [ @@ typedef ] let to_int x = Unsigned . UInt32 . to_int Ctypes... |
let max_material_maps = [ % c constant " MAX_MATERIAL_MAPS " camlint ] |
let max_shader_locations = [ % c constant " RL_MAX_SHADER_LOCATIONS " camlint ] |
module Description ( F : Ctypes . FOREIGN ) = struct open Ctypes open F open Raylib_generated_types open Raylib_generated_constants let init_window = foreign " InitWindow " ( int @-> int @-> string @-> returning void ) let window_should_close = foreign " WindowShouldClose " ( void @-> returning bool ) let close_window ... |
type name = { name : string ; cname : string } |
module Enum = struct type t = { name : name ; values : name list ; bitmask : bool } let def s = String . ( lowercase_ascii s |> capitalize_ascii ) let strip_1st cname = let start = String . index cname ' _ ' in String . drop ( start + 1 ) cname let strip_2nd cname = strip_1st cname |> strip_1st let rstrip_1st cname = l... |
module Naming = struct let is_uppercase = function ' A ' . . ' Z ' -> true | _ -> false let to_snake_case s = let rec aux first acc = function | hd :: _ as lst when is_uppercase hd && not first -> aux true ( ' _ ' :: acc ) lst | hd :: tl when is_uppercase hd && first -> aux first ( Char . lowercase_ascii hd :: acc ) tl... |
module Typing = struct module StrTbl = Hashtbl . Make ( String ) type t = | C of string | Ray of string | Forw_decl of name | Array of int * string | Ptr of t let is_builtin = function | " int " | " uint " | " char " | " uchar " | " float " | " bool " | " void " | " short " | " ushort " -> true | " const char " -> true... |
module Type = struct type field = { name : name ; typ : Typing . t ; desc : string option } type t = { name : name ; fields : field list } let strip_array name = match String . index_opt name ' [ ' with | None -> ( name , None ) | Some start -> let end_ = String . index name ' ] ' in let size = String . sub name ( star... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.