rust_raylib/lib.rs
1#![doc = include_str!("../README.md")]
2
3/// Raw ffi bindings
4pub mod ffi;
5pub use ffi::{RAYLIB_VERSION, RAYLIB_VERSION_MAJOR, RAYLIB_VERSION_MINOR, RAYLIB_VERSION_PATCH};
6
7/// Audio
8pub mod audio;
9/// Collision checks between different shapes
10pub mod collision;
11/// Color type and color constants
12pub mod color;
13/// Drawing traits and functions
14pub mod drawing;
15/// Math types
16pub mod math;
17/// 3D models
18pub mod model;
19/// Shader type
20pub mod shader;
21/// Fonts and text related types and functions
22pub mod text;
23/// Images and textures
24pub mod texture;
25/// VR related types
26pub mod vr;
27
28mod core;
29pub use crate::core::*;
30
31/*
32 // Loser List: functions that aren't included in the wrapper, because there are better and more idiomatic solutions available
33
34 /// Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
35 pub fn TraceLog(logLevel: u32, text: *const core::ffi::c_char, ...) {}
36
37 /// Internal memory allocator
38 pub fn MemAlloc(size: core::ffi::c_uint) -> *mut core::ffi::c_void;
39
40 /// Internal memory reallocator
41 pub fn MemRealloc(ptr: *mut core::ffi::c_void, size: core::ffi::c_uint) -> *mut core::ffi::c_void;
42
43 /// Internal memory free
44 pub fn MemFree(ptr: *mut core::ffi::c_void) {}
45
46 /// Set custom trace log
47 pub fn SetTraceLogCallback(callback: TraceLogCallback) {}
48
49 /// Set custom file binary data loader
50 pub fn SetLoadFileDataCallback(callback: LoadFileDataCallback) {}
51
52 /// Set custom file binary data saver
53 pub fn SetSaveFileDataCallback(callback: SaveFileDataCallback) {}
54
55 /// Set custom file text data loader
56 pub fn SetLoadFileTextCallback(callback: LoadFileTextCallback) {}
57
58 /// Set custom file text data saver
59 pub fn SetSaveFileTextCallback(callback: SaveFileTextCallback) {}
60
61 /// Load file data as byte array (read)
62 pub fn LoadFileData(fileName: *const core::ffi::c_char, bytesRead: *mut core::ffi::c_uint) -> *mut core::ffi::c_uchar;
63
64 /// Unload file data allocated by LoadFileData()
65 pub fn UnloadFileData(data: *mut core::ffi::c_uchar) {}
66
67 /// Save data to file from byte array (write), returns true on success
68 pub fn SaveFileData(fileName: *const core::ffi::c_char, data: *mut core::ffi::c_void, bytesToWrite: core::ffi::c_uint) -> bool;
69
70 /// Export data to code (.h), returns true on success
71 pub fn ExportDataAsCode(data: *const core::ffi::c_uchar, size: core::ffi::c_uint, fileName: *const core::ffi::c_char) -> bool;
72
73 /// Load text data from file (read), returns a '\0' terminated string
74 pub fn LoadFileText(fileName: *const core::ffi::c_char) -> *mut core::ffi::c_char;
75
76 /// Unload file text data allocated by LoadFileText()
77 pub fn UnloadFileText(text: *mut core::ffi::c_char) {}
78
79 /// Save text data to file (write), string must be '\0' terminated, returns true on success
80 pub fn SaveFileText(fileName: *const core::ffi::c_char, text: *mut core::ffi::c_char) -> bool;
81
82 /// Check if file exists
83 pub fn FileExists(fileName: *const core::ffi::c_char) -> bool;
84
85 /// Check if a directory path exists
86 pub fn DirectoryExists(dirPath: *const core::ffi::c_char) -> bool;
87
88 /// Check file extension (including point: .png, .wav)
89 pub fn IsFileExtension(fileName: *const core::ffi::c_char, ext: *const core::ffi::c_char) -> bool;
90
91 /// Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
92 pub fn GetFileLength(fileName: *const core::ffi::c_char) -> u32;
93
94 /// Get pointer to extension for a file_name string (includes dot: '.png')
95 pub fn GetFileExtension(fileName: *const core::ffi::c_char) -> *const core::ffi::c_char;
96
97 /// Get pointer to file_name for a path string
98 pub fn GetFileName(filePath: *const core::ffi::c_char) -> *const core::ffi::c_char;
99
100 /// Get file_name string without extension (uses static string)
101 pub fn GetFileNameWithoutExt(filePath: *const core::ffi::c_char) -> *const core::ffi::c_char;
102
103 /// Get full path for a given fileName with path (uses static string)
104 pub fn GetDirectoryPath(filePath: *const core::ffi::c_char) -> *const core::ffi::c_char;
105
106 /// Get previous directory path for a given path (uses static string)
107 pub fn GetPrevDirectoryPath(dirPath: *const core::ffi::c_char) -> *const core::ffi::c_char;
108
109 /// Get current working directory (uses static string)
110 pub fn GetWorkingDirectory() -> *const core::ffi::c_char;
111
112 /// Get the directory if the running application (uses static string)
113 pub fn GetApplicationDirectory() -> *const core::ffi::c_char;
114
115 /// Change working directory, return true on success
116 pub fn ChangeDirectory(dir: *const core::ffi::c_char) -> bool;
117
118 /// Check if a given path is a file or a directory
119 pub fn IsPathFile(path: *const core::ffi::c_char) -> bool;
120
121 /// Load directory filepaths
122 pub fn LoadDirectoryFiles(dirPath: *const core::ffi::c_char) -> FilePathList;
123
124 /// Load directory filepaths with extension filtering and recursive directory scan
125 pub fn LoadDirectoryFilesEx(basePath: *const core::ffi::c_char, filter: *const core::ffi::c_char, scanSubdirs: bool) -> FilePathList;
126
127 /// Unload filepaths
128 pub fn UnloadDirectoryFiles(files: FilePathList) {}
129
130 /// Get file modification time (last write time)
131 pub fn GetFileModTime(fileName: *const core::ffi::c_char) -> core::ffi::c_long;
132
133 /// Compress data (DEFLATE algorithm), memory must be MemFree()
134 pub fn CompressData(data: *const core::ffi::c_uchar, dataSize: u32, compDataSize: *mut u32) -> *mut core::ffi::c_uchar;
135
136 /// Decompress data (DEFLATE algorithm), memory must be MemFree()
137 pub fn DecompressData(compData: *const core::ffi::c_uchar, compDataSize: u32, dataSize: *mut u32) -> *mut core::ffi::c_uchar;
138
139 /// Encode data to Base64 string, memory must be MemFree()
140 pub fn EncodeDataBase64(data: *const core::ffi::c_uchar, dataSize: u32, outputSize: *mut u32) -> *mut core::ffi::c_char;
141
142 /// Decode Base64 string data, memory must be MemFree()
143 pub fn DecodeDataBase64(data: *const core::ffi::c_uchar, outputSize: *mut u32) -> *mut core::ffi::c_uchar;
144
145 /// Load UTF-8 text encoded from codepoints array
146 pub fn LoadUTF8(codepoints: *const core::ffi::c_int, length: core::ffi::c_int, ) -> *mut core::ffi::c_char;
147
148 /// Unload UTF-8 text encoded from codepoints array
149 pub fn UnloadUTF8(text: *mut core::ffi::c_char, );
150
151 /// Load all codepoints from a UTF-8 text string, codepoints count returned by parameter
152 pub fn LoadCodepoints(text: *const core::ffi::c_char, count: *mut core::ffi::c_int, ) -> *mut core::ffi::c_int;
153
154 /// Unload codepoints data from memory
155 pub fn UnloadCodepoints(codepoints: *mut core::ffi::c_int, );
156
157 /// Get total number of codepoints in a UTF-8 encoded string
158 pub fn GetCodepointCount(text: *const core::ffi::c_char, ) -> core::ffi::c_int;
159
160 /// Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
161 pub fn GetCodepoint(text: *const core::ffi::c_char, codepointSize: *mut core::ffi::c_int, ) -> core::ffi::c_int;
162
163 /// Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
164 pub fn GetCodepointNext(text: *const core::ffi::c_char, codepointSize: *mut core::ffi::c_int, ) -> core::ffi::c_int;
165
166 /// Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
167 pub fn GetCodepointPrevious(text: *const core::ffi::c_char, codepointSize: *mut core::ffi::c_int, ) -> core::ffi::c_int;
168
169 /// Encode one codepoint into UTF-8 byte array (array length returned as parameter)
170 pub fn CodepointToUTF8(codepoint: core::ffi::c_int, utf8Size: *mut core::ffi::c_int, ) -> *const core::ffi::c_char;
171
172 /// Copy one string to another, returns bytes copied
173 pub fn TextCopy(dst: *mut core::ffi::c_char, src: *const core::ffi::c_char, ) -> core::ffi::c_int;
174
175 /// Check if two text string are equal
176 pub fn TextIsEqual(text1: *const core::ffi::c_char, text2: *const core::ffi::c_char, ) -> bool;
177
178 /// Get text length, checks for '\0' ending
179 pub fn TextLength(text: *const core::ffi::c_char, ) -> core::ffi::c_uint;
180
181 /// Text formatting with variables (sprintf() style)
182 pub fn TextFormat(text: *const core::ffi::c_char, ..., ) -> *const core::ffi::c_char;
183
184 /// Get a piece of a text string
185 pub fn TextSubtext(text: *const core::ffi::c_char, position: core::ffi::c_int, length: core::ffi::c_int, ) -> *const core::ffi::c_char;
186
187 /// Replace text string (WARNING: memory must be freed!)
188 pub fn TextReplace(text: *mut core::ffi::c_char, replace: *const core::ffi::c_char, by: *const core::ffi::c_char, ) -> *mut core::ffi::c_char;
189
190 /// Insert text in a position (WARNING: memory must be freed!)
191 pub fn TextInsert(text: *const core::ffi::c_char, insert: *const core::ffi::c_char, position: core::ffi::c_int, ) -> *mut core::ffi::c_char;
192
193 /// Join text strings with delimiter
194 pub fn TextJoin(textList: *const *const core::ffi::c_char, count: core::ffi::c_int, delimiter: *const core::ffi::c_char, ) -> *const core::ffi::c_char;
195
196 /// Split text into multiple strings
197 pub fn TextSplit(text: *const core::ffi::c_char, delimiter: core::ffi::c_char, count: *mut core::ffi::c_int, ) -> *const *const core::ffi::c_char;
198
199 /// Append text at specific position and move cursor!
200 pub fn TextAppend(text: *mut core::ffi::c_char, append: *const core::ffi::c_char, position: *mut core::ffi::c_int, );
201
202 /// Find first text occurrence within a string
203 pub fn TextFindIndex(text: *const core::ffi::c_char, find: *const core::ffi::c_char, ) -> core::ffi::c_int;
204
205 /// Get upper case version of provided string
206 pub fn TextToUpper(text: *const core::ffi::c_char, ) -> *const core::ffi::c_char;
207
208 /// Get lower case version of provided string
209 pub fn TextToLower(text: *const core::ffi::c_char, ) -> *const core::ffi::c_char;
210
211 /// Get Pascal case notation version of provided string
212 pub fn TextToPascal(text: *const core::ffi::c_char, ) -> *const core::ffi::c_char;
213
214 /// Get integer value from text (negative values not supported)
215 pub fn TextToInteger(text: *const core::ffi::c_char, ) -> core::ffi::c_int;
216*/