Prototype game engine for Heroes of Might & Magic, featuring a gameplay plot-twist...
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

214 lines
13KB

  1. -- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
  2. --
  3. -- GNU General Public Licence (version 3 or later)
  4. with interfaces.c, system;
  5. use interfaces.c, system;
  6. package ray is
  7. pragma preelaborate;
  8. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  9. type pointer is access all system.address;
  10. type colour_range is range 0 .. 2 ** 8 - 1;
  11. type logical is new boolean;
  12. for logical'size use 32;
  13. for colour_range'size use 8;
  14. type pixels is array (natural range <>) of colour_range;
  15. type window_flag is (
  16. flag_none,
  17. flag_fullscreen_mode,
  18. flag_window_resizable,
  19. flag_window_undecorated,
  20. flag_window_transparent,
  21. flag_msaa_x4_hint,
  22. flag_vsync_hint,
  23. flag_window_hidden,
  24. flag_window_always_run,
  25. flag_window_minimized,
  26. flag_window_maximized,
  27. flag_window_unfocused,
  28. flag_window_topmost,
  29. flag_window_high_dpi,
  30. flag_window_mouse_passthrough,
  31. flag_borderless_windowed_mode,
  32. flag_interlaced_hint
  33. ) with convention => c;
  34. for window_flag use (
  35. flag_none => 16#00000000#, -- 0
  36. flag_fullscreen_mode => 16#00000002#, -- 2
  37. flag_window_resizable => 16#00000004#, -- 4
  38. flag_window_undecorated => 16#00000008#, -- 8
  39. flag_window_transparent => 16#00000010#, -- 16
  40. flag_msaa_x4_hint => 16#00000020#, -- 32
  41. flag_vsync_hint => 16#00000040#, -- 64
  42. flag_window_hidden => 16#00000080#, -- 128
  43. flag_window_always_run => 16#00000100#, -- 256
  44. flag_window_minimized => 16#00000200#, -- 512
  45. flag_window_maximized => 16#00000400#, -- 1024
  46. flag_window_unfocused => 16#00000800#, -- 2048
  47. flag_window_topmost => 16#00001000#, -- 4096
  48. flag_window_high_dpi => 16#00002000#, -- 8192
  49. flag_window_mouse_passthrough => 16#00004000#, -- 16384
  50. flag_borderless_windowed_mode => 16#00008000#, -- 32768
  51. flag_interlaced_hint => 16#00010000# -- 65536
  52. );
  53. type trace_log_level is (
  54. log_all, log_trace, log_debug, log_info, log_warning, log_error,
  55. log_fatal, log_none
  56. ) with convention => c;
  57. type mouse_button is (
  58. mouse_button_left, mouse_button_right, mouse_button_middle, mouse_button_side, mouse_button_extra, mouse_button_forward,
  59. mouse_button_back
  60. ) with convention => c;
  61. type vector is record x, y : float; end record with convention => c_pass_by_copy;
  62. type colour is record r, g, b, a : colour_range; end record with convention => c_pass_by_copy;
  63. type rectangle is record x ,y, width, height : float; end record with convention => c_pass_by_copy;
  64. type texture is record id : natural; width, height, mipmaps, format : integer; end record with convention => c_pass_by_copy;
  65. type image is record data : access pixels; width, height, mipmaps : integer; format : integer := 7; end record with convention => c_pass_by_copy;
  66. type font is record base, count, pad : integer; data : texture; squares : pointer; glyphs : pointer; end record with convention => c_pass_by_copy;
  67. type stream is record buffer, processor : pointer; rate, size, channels : natural; end record with convention => c_pass_by_copy;
  68. type sound is record data : stream; frame : natural; end record with convention => c_pass_by_copy;
  69. no_texture : texture;
  70. no_font : font;
  71. no_sound : sound;
  72. procedure set_window_flags (flags : window_flag := flag_none) with import => true, convention => c, external_name => "SetConfigFlags";
  73. procedure open_window (width, height : in integer; title : in string) with import => true, convention => c, external_name => "InitWindow";
  74. procedure close_window with import => true, convention => c, external_name => "CloseWindow";
  75. procedure open_audio_device with import => true, convention => c, external_name => "InitAudioDevice";
  76. procedure close_audio_device with import => true, convention => c, external_name => "CloseAudioDevice";
  77. procedure set_exit_key (key : in integer) with import => true, convention => c, external_name => "SetExitKey";
  78. function exit_key_is_pressed return logical with import => true, convention => c, external_name => "WindowShouldClose";
  79. function get_key_pressed return integer with import => true, convention => c, external_name => "GetKeyPressed";
  80. function mouse_button_is_pressed (button : in mouse_button) return logical with import => true, convention => c, external_name => "IsMouseButtonPressed";
  81. function mouse_button_is_released (button : in mouse_button) return logical with import => true, convention => c, external_name => "IsMouseButtonReleased";
  82. function get_mouse_x return integer with import => true, convention => c, external_name => "GetMouseX";
  83. function get_mouse_y return integer with import => true, convention => c, external_name => "GetMouseY";
  84. function get_mouse_vector return vector with import => true, convention => c, external_name => "GetMousePosition";
  85. function get_screen_width return integer with import => true, convention => c, external_name => "GetScreenWidth";
  86. function get_screen_height return integer with import => true, convention => c, external_name => "GetScreenHeight";
  87. procedure clear_background (tint : in colour) with import => true, convention => c, external_name => "ClearBackground";
  88. procedure begin_drawing with import => true, convention => c, external_name => "BeginDrawing";
  89. procedure end_drawing with import => true, convention => c, external_name => "EndDrawing";
  90. procedure set_target_fps (fps : in integer) with import => true, convention => c, external_name => "SetTargetFPS";
  91. function get_fps return integer with import => true, convention => c, external_name => "GetFPS";
  92. procedure draw_fps (x, y : in integer) with import => true, convention => c, external_name => "DrawFPS";
  93. procedure randomization (seed : in natural) with import => true, convention => c, external_name => "SetRandomSeed";
  94. function get_random (minimum, maximum : in integer) return integer with import => true, convention => c, external_name => "GetRandomValue";
  95. procedure take_screenshot (file_path : in string := "screenshot.png") with import => true, convention => c, external_name => "TakeScreenshot";
  96. procedure set_trace_log_level (level : in trace_log_level) with import => true, convention => c, external_name => "SetTraceLogLevel";
  97. function load_texture (file_path : in string) return texture with import => true, convention => c, external_name => "LoadTexture";
  98. function load_sound (file_path : in string) return sound with import => true, convention => c, external_name => "LoadSound";
  99. function load_font (file_path : in string) return font with import => true, convention => c, external_name => "LoadFont";
  100. function load_image (file_path : in string) return image with import => true, convention => c, external_name => "LoadImage";
  101. procedure unload_texture (data : in texture) with import => true, convention => c, external_name => "UnloadTexture";
  102. procedure unload_sound (data : in sound) with import => true, convention => c, external_name => "UnloadSound";
  103. procedure unload_font (data : in font) with import => true, convention => c, external_name => "UnloadFont";
  104. procedure unload_image (data : in image) with import => true, convention => c, external_name => "UnloadImage";
  105. function image_colour (width, height : in integer; tint : in colour) return image with import => true, convention => c, external_name => "GenImageColor";
  106. function image_import (data : in texture) return image with import => true, convention => c, external_name => "LoadImageFromTexture";
  107. function image_deport (data : in image) return texture with import => true, convention => c, external_name => "LoadTextureFromImage";
  108. procedure image_delete (data : in image) with import => true, convention => c, external_name => "UnloadImage";
  109. function image_export (data : in image; file_path : in string) return integer with import => true, convention => c, external_name => "ExportImage";
  110. procedure image_pixel (data : in out image; x, y : in integer; tint : in colour) with import => true, convention => c, external_name => "ImageDrawPixel";
  111. procedure image_render (data : in out image;
  112. copy : in image;
  113. from : in rectangle := (others => 0.0);
  114. to : in rectangle := (others => 0.0);
  115. tint : in colour := (others => 255)
  116. ) with import => true, convention => c, external_name => "ImageDraw";
  117. procedure draw_line (x0, y0, x1, y1 : in integer; tint : in colour) with import => true, convention => c, external_name => "DrawLine";
  118. procedure draw_rectangle (x, y, width, height : in integer; tint : in colour) with import => true, convention => c, external_name => "DrawRectangle";
  119. procedure draw_text (
  120. data : in font := no_font;
  121. text : in string := "--";
  122. view : in vector := (0.0, 0.0);
  123. origin : in vector := (0.0, 0.0);
  124. rotate : in float := 0.0;
  125. scale : in float := 0.0;
  126. space : in float := 0.0;
  127. tint : in colour := (others => 255)
  128. ) with import => true, convention => c, external_name => "DrawTextPro";
  129. procedure draw_texture (
  130. data : in texture := no_texture;
  131. uv : in rectangle := (others => 0.0);
  132. view : in rectangle := (others => 0.0);
  133. origin : in vector := (0.0, 0.0);
  134. rotate : in float := 0.0;
  135. tint : in colour := (others => 255)
  136. ) with import => true, convention => c, external_name => "DrawTexturePro";
  137. procedure play_sound (data : in sound) with import => true, convention => c, external_name => "PlaySound";
  138. procedure stop_sound (data : in sound) with import => true, convention => c, external_name => "StopSound";
  139. procedure pause_sound (data : in sound) with import => true, convention => c, external_name => "PauseSound";
  140. procedure resume_sound (data : in sound) with import => true, convention => c, external_name => "ResumeSound";
  141. procedure toggle_fullscreen with import => true, convention => c, external_name => "ToggleFullscreen";
  142. procedure window_icon (icon : in image) with import => true, convention => c, external_name => "SetWindowIcon";
  143. procedure show_cursor with import => true, convention => c, external_name => "ShowCursor";
  144. procedure hide_cursor with import => true, convention => c, external_name => "HideCursor";
  145. procedure set_window_minimal_size (width, height : in integer) with import => true, convention => c, external_name => "SetWindowMinSize";
  146. procedure set_window_maximal_size (width, height : in integer) with import => true, convention => c, external_name => "SetWindowMaxSize";
  147. procedure set_window_size (width, height : in integer) with import => true, convention => c, external_name => "SetWindowSize";
  148. function get_time return long_float with import => true, convention => c, external_name => "GetTime";
  149. function load_text (file : in string) return access char_array with import => true, convention => c, external_name => "LoadFileText";
  150. function mouse_wheel_move return float with import => true, convention => c, external_name => "GetMouseWheelMove";
  151. --~void OpenURL(const char *url);
  152. --~procedure unload_file (data : in access string) with import => true, convention => c, external_name => "UnloadFileText";
  153. --~bool SaveFileText(const char *fileName, char *text);
  154. --~FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs);
  155. --~void UnloadDirectoryFiles(FilePathList files);
  156. function compress (data : in pointer; size : in integer; used : out integer) return pointer with import => true, convention => c, external_name => "CompressData";
  157. function decompress (data : in pointer; size : in integer; used : out integer) return pointer with import => true, convention => c, external_name => "DecompressData";
  158. --~Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing);
  159. --~void SetMasterVolume(float volume);
  160. --~Music LoadMusicStream(const char *fileName);
  161. --~void UnloadMusicStream(Music music);
  162. --~void PlayMusicStream(Music music);
  163. --~void PauseMusicStream(Music music);
  164. --~void ResumeMusicStream(Music music);
  165. --~void SetMusicVolume(Music music, float volume);
  166. --~float GetMusicTimeLength(Music music);
  167. --~RLAPI float GetMusicTimePlayed(Music music);
  168. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  169. end ray;