mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Update this page to raylib 5.0?
@ -1,4 +1,4 @@
|
||||
**WARNING: This analysis has been made on `raylib 3.8-dev` that exposes a total of `470 functions`. Latest version of the library, `raylib 4.1-dev` exposes `+500 functions`. This information could be not updated.**
|
||||
This analysis has been made on `raylib 5.1-dev` that exposes a total of `558 functions`.
|
||||
|
||||
raylib is a simple and easy-to-use library to enjoy videogames programing... but, **what makes the library simple and easy-to-use?** For many users the first approach to the library is through its API, so, here it is a small analysis of the API from a **syntactic point of view**.
|
||||
|
||||
@ -36,7 +36,7 @@ Checking the available **functions** with more detail, they can be divided into
|
||||
|
||||
### 1.1. Functions following a common pattern
|
||||
|
||||
Most of the functions of the library go into this first group **(359 functions)**, there is some common `<Action>` that prepends the name of most of the functions:
|
||||
Most of the functions of the library go into this first group **(416 functions)**, there is some common `<Action>` that prepends the name of most of the functions:
|
||||
|
||||
pattern | function format | API count | examples
|
||||
:--: | :----- | :---: | :----------
|
||||
@ -44,26 +44,26 @@ pattern | function format | API count | examples
|
||||
02 | `void Close*()` | 2 | `CloseWindow()`, `CloseAudioDevice()`
|
||||
03 | `void Begin*()` | 8 | `BeginDrawing()`, `BeginBlendMode()`
|
||||
04 | `void End*()` | 8 | `EndDrawing()`, `EndBlendMode()`
|
||||
05 | `TYPE Get*()` | **79** | `GetKeyPressed()`, `GetMouseX()`, `GetRayCollision*()`
|
||||
06 | `void Set*()` | **46** | `SetWindowTitle()`, `SetTargetFPS()`, `SetMouseScale()`
|
||||
07 | `bool Is*()` | **33** | `IsKeyPressed()`, `IsGamepadAvailable()`, `IsSoundPlaying()`
|
||||
08 | `TYPE Gen<TYPE>*()` | 20 | `GenImage*()`, `GenMesh*()`
|
||||
05 | `TYPE Get*()` | **93** | `GetKeyPressed()`, `GetMouseX()`, `GetRayCollision*()`
|
||||
06 | `void Set*()` | **52** | `SetWindowTitle()`, `SetTargetFPS()`, `SetMouseScale()`
|
||||
07 | `bool Is*()` | **45** | `IsKeyPressed()`, `IsGamepadAvailable()`, `IsSoundPlaying()`
|
||||
08 | `TYPE Gen<TYPE>*()` | 23 | `GenImage*()`, `GenMesh*()`
|
||||
09 | `TYPE Load<TYPE>*()` | **34** | `LoadImage*()`, `LoadTexture*()`, `LoadSound*()`
|
||||
10 | `void Unload<TYPE>*(<TYPE>)` | 22 | `UnloadImage()`, `UnloadTexture()`, `UnloadSound()`
|
||||
11 | `void Update<TYPE>*(<TYPE>, *)` | 8 | `UpdateTexture()`, `UpdateCamera()`
|
||||
12 | `bool Save*()` | 3 | `SaveFileData()`, `SaveFileText()`, `SaveStorageValue()`
|
||||
13 | `bool Export*()` | 5 | `ExportImage()`, `ExportImageAsCode()`, `ExportMesh()`, `ExportWave()`, `ExportWaveAsCode()`
|
||||
14 | `void Draw*()` | **79** | `DrawRectangle()`, `DrawTexture*()`, `DrawModel*()`
|
||||
15 | `bool Check*()` | 10 | `CheckCollisionRecs()`, `CheckCollisionCircles()`, `CheckCollisionBoxSphere()`
|
||||
10 | `void Unload<TYPE>*(<TYPE>)` | 28 | `UnloadImage()`, `UnloadTexture()`, `UnloadSound()`
|
||||
11 | `void Update<TYPE>*(<TYPE>, *)` | 9 | `UpdateTexture()`, `UpdateCamera()`
|
||||
12 | `bool Save*()` | 2 | `SaveFileData()`, `SaveFileText()`, `SaveStorageValue()`
|
||||
13 | `bool Export*()` | 9 | `ExportImage()`, `ExportImageAsCode()`, `ExportMesh()`, `ExportWave()`, `ExportWaveAsCode()`
|
||||
14 | `void Draw*()` | **89** | `DrawRectangle()`, `DrawTexture*()`, `DrawModel*()`
|
||||
15 | `bool Check*()` | 12 | `CheckCollisionRecs()`, `CheckCollisionCircles()`, `CheckCollisionBoxSphere()`
|
||||
|
||||
### 1.2. Functions operating over specific type of data
|
||||
|
||||
Those functions **(68 in total)** operate over a specific data type, so, it was decided to prepend the `DataType` to the function name, they are an exception over the main syntax rule followed by the API:
|
||||
Those functions **(74 in total)** operate over a specific data type, so, it was decided to prepend the `DataType` to the function name, they are an exception over the main syntax rule followed by the API:
|
||||
|
||||
pattern | function format | API count | examples
|
||||
:--: | :----- | :---: | :----------
|
||||
01 | `TYPE Color*()` | 7 | `ColorAlpha()`, `ColorFromHSV()`, `ColorToHSV()`
|
||||
02 | `Image Image*()`<br>`void Image*()` | **40** | `ImageFormat()`, `ImageCrop()`, `ImageResize()`,` ImageFlipVertical()`
|
||||
01 | `TYPE Color*()` | 10 | `ColorAlpha()`, `ColorFromHSV()`, `ColorToHSV()`
|
||||
02 | `Image Image*()`<br>`void Image*()` | **45** | `ImageFormat()`, `ImageCrop()`, `ImageResize()`,` ImageFlipVertical()`
|
||||
03 | `TYPE Text*()` | **16** | `TextFormat()`, `TextReplace()`, `TextSplit()`, `TextToLower()`
|
||||
04 | `Wave Wave*()`<br>`void Wave*()` | 3 | `WaveFormat()`, `WaveCopy()`, `WaveCrop()`
|
||||
|
||||
@ -71,23 +71,30 @@ _NOTE: Maybe some of them are renamed in the future for consistency._
|
||||
|
||||
### 1.3. Functions with unique pattern
|
||||
|
||||
Remaining functions **(43 in total)** follow a unique pattern, still, **most of them** follow the standard syntax pattern of `<Verb><Subject><Complement>`.
|
||||
Remaining functions **(57 in total)** follow a unique pattern, still, **most of them** follow the standard syntax pattern of `<Verb><Subject><Complement>`.
|
||||
|
||||
```c
|
||||
// core.c
|
||||
WindowShouldClose(); // Not following pattern
|
||||
ClearWindowState();
|
||||
ToggleFullscreen();
|
||||
ToggleBorderlessWindowed();
|
||||
MaximizeWindow();
|
||||
MinimizeWindow();
|
||||
RestoreWindow();
|
||||
EnableEventWaiting();
|
||||
DisableEventWaiting();
|
||||
ShowCursor();
|
||||
HideCursor();
|
||||
EnableCursor();
|
||||
DisableCursor();
|
||||
ClearBackground();
|
||||
SwapScreenBuffer();
|
||||
PollInputEvents();
|
||||
WaitTime();
|
||||
TakeScreenshot();
|
||||
TraceLog(); // Not following pattern
|
||||
OpenURL();
|
||||
MemAlloc(); // Data-type pattern?
|
||||
MemRealloc(); // Data-type pattern?
|
||||
MemFree(); // Data-type pattern?
|
||||
@ -95,10 +102,13 @@ FileExists(); // Not following pattern -> IsFileAvailable()?
|
||||
DirectoryExists(); // Not following pattern -> IsDirectoryAvailable()?
|
||||
ClearDirectoryFiles();
|
||||
ChangeDirectory();
|
||||
ClearDroppedFiles();
|
||||
CompressData();
|
||||
DecompressData();
|
||||
OpenURL();
|
||||
EncodeDataBase64();
|
||||
DecodeDataBase64();
|
||||
StartAutomationEventRecording();
|
||||
StopAutomationEventRecording();
|
||||
PlayAutomationEvent();
|
||||
|
||||
// textures.c
|
||||
Fade(); // Superseded by ColorAlpha()
|
||||
@ -116,16 +126,20 @@ PlaySound();
|
||||
StopSound();
|
||||
PauseSound();
|
||||
ResumeSound();
|
||||
PlaySoundMulti();
|
||||
StopSoundMulti();
|
||||
PlayMusicStream();
|
||||
StopMusicStream();
|
||||
PauseMusicStream();
|
||||
ResumeMusicStream();
|
||||
SeekMusicStream();
|
||||
PlayAudioStream();
|
||||
StopAudioStream();
|
||||
PauseAudioStream();
|
||||
ResumeAudioStream();
|
||||
SeekAudioStream();
|
||||
AttachAudioStreamProcessor();
|
||||
DetachAudioStreamProcessor();
|
||||
AttachAudioMixedProcessor();
|
||||
DetachAudioMixedProcessor();
|
||||
```
|
||||
|
||||
### 1.4. Functions suffixes
|
||||
@ -137,10 +151,12 @@ A part from the function prefixes that we can find in many functions names (1. c
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// rcore.c
|
||||
void SetShaderValueV();
|
||||
Vector2 GetMouseWheelMoveV();
|
||||
// rshapes.c
|
||||
void DrawPixelV();
|
||||
void DrawLineV();
|
||||
void DrawCircleV();
|
||||
void DrawCircleLinesV();
|
||||
void DrawRectangleV();
|
||||
void DrawRectangleGradientV();
|
||||
// rtextures.c
|
||||
@ -172,6 +188,8 @@ void DrawTextEx();
|
||||
Vector2 MeasureTextEx();
|
||||
// rmodels.c
|
||||
void DrawSphereEx();
|
||||
void DrawCylinderEx();
|
||||
void DrawCylinderWiresEx();
|
||||
void DrawModelEx();
|
||||
void DrawModelWiresEx();
|
||||
|
||||
@ -197,12 +215,15 @@ Rectangle GetCollisionRec();
|
||||
void ImageDrawRectangleRec();
|
||||
void UpdateTextureRec();
|
||||
void DrawTextureRec();
|
||||
// rtext.c
|
||||
Rectangle GetGlyphAtlasRec();
|
||||
// rmodels.c
|
||||
void DrawBillboardRec();
|
||||
|
||||
// Suffix: *FromMemory() -> Used for functions loading data "from memory" instead of from files
|
||||
//------------------------------------------------------------------------------------------------
|
||||
Shader LoadShaderFromMemory();
|
||||
Image LoadImageAnimFromMemory();
|
||||
Image LoadImageFromMemory();
|
||||
Font LoadFontFromMemory();
|
||||
Wave LoadWaveFromMemory();
|
||||
@ -215,6 +236,7 @@ void SetLoadFileDataCallback();
|
||||
void SetSaveFileDataCallback();
|
||||
void SetLoadFileTextCallback();
|
||||
void SetSaveFileTextCallback();
|
||||
void SetAudioStreamCallback();
|
||||
```
|
||||
|
||||
### 1.5. Functions naming
|
||||
@ -233,13 +255,20 @@ count| function | words | comments
|
||||
008 | `SetLoadFileTextCallback()` | 5 | _Callback function_
|
||||
009 | `SetSaveFileTextCallback()` | 5 | _Callback function_
|
||||
010 | `GetFileNameWithoutExt()` | 5 |
|
||||
011 | `SetCameraSmoothZoomControl()` | 5 | TODO: Review!!!
|
||||
012 | `ImageToPOT()` | 3 | _Acronym used_
|
||||
013 | `ImageRotateCCW()` | 3 | _Acronym used_
|
||||
014 | `ColorToHSV()` | 3 | _Acronym used_
|
||||
015 | `ColorFromHSV()` | 3 | _Acronym used_
|
||||
016 | `LoadMusicStreamFromMemory()` | 5 | _*FromMemory() set of functions_
|
||||
017 | `SetAudioStreamBufferSizeDefault()` | **6** | **TODO: Review!!!**
|
||||
011 | `SetAutomationEventBaseFrame()` | 5 | TODO: Review!!!
|
||||
012 | `DrawSplineSegmentCatmullRom()` | 5 |
|
||||
013 | `DrawSplineSegmentBezierQuadratic()` | 5 |
|
||||
014 | `DrawSplineSegmentBezierCubic()` | 5 |
|
||||
015 | `GetSplinePointCatmullRom()` | 5 |
|
||||
016 | `GetSplinePointBezierQuad()` | 5 |
|
||||
017 | `GetSplinePointBezierCubic()` | 5 |
|
||||
018 | `LoadImageAnimFromMemory()` | 5 |
|
||||
019 | `ImageToPOT()` | 3 | _Acronym used_
|
||||
020 | `ImageRotateCCW()` | 3 | _Acronym used_
|
||||
021 | `ColorToHSV()` | 3 | _Acronym used_
|
||||
022 | `ColorFromHSV()` | 3 | _Acronym used_
|
||||
023 | `LoadMusicStreamFromMemory()` | 5 | _*FromMemory() set of functions_
|
||||
024 | `SetAudioStreamBufferSizeDefault()` | **6** | **TODO: Review!!!**
|
||||
|
||||
### 1.6. Functions parameters
|
||||
|
||||
@ -247,42 +276,46 @@ Most functions are limited to **5 or less input parameters**. I think 5 or less
|
||||
|
||||
count| function | param count | comments
|
||||
:--: | :----- | :--: | :----------
|
||||
001 | `SetCameraMoveControls()` | 6 |
|
||||
002 | `DrawCircleSector()` | 6 |
|
||||
003 | `DrawCircleSectorLines()` | 6 |
|
||||
004 | `DrawRing()` | 7 | _WARNING: >6 parameters_
|
||||
005 | `DrawRingLines()` | 7 | _WARNING: >6 parameters_
|
||||
006 | `DrawRectangleGradientV()` | 6 |
|
||||
007 | `DrawRectangleGradientH()` | 6 |
|
||||
008 | `DrawPolyLinesEx()` | 6 |
|
||||
009 | `GenImageChecked()` | 6 |
|
||||
010 | `ImageResizeCanvas()` | 6 |
|
||||
011 | `ImageDrawLine()` | 6 |
|
||||
012 | `ImageDrawRectangle()` | 6 |
|
||||
013 | `ImageDrawText()` | 6 |
|
||||
014 | `ImageDrawTextEx()` | 7 | _WARNING: >6 parameters_
|
||||
015 | `DrawTextureTiled()` | 7 | _WARNING: >6 parameters_
|
||||
016 | `DrawTexturePro()` | 6 |
|
||||
017 | `DrawTextureNPatch()` | 6 |
|
||||
018 | `DrawTexturePoly()` | 6 |
|
||||
019 | `LoadFontFromMemory()` | 6 |
|
||||
020 | `LoadFontData()` | 6 |
|
||||
021 | `GenImageFontAtlas()` | 6 |
|
||||
022 | `DrawTextEx()` | 6 |
|
||||
023 | `DrawTextPro()` | **8** | _WARNING: >7 parameters_
|
||||
024 | `DrawCubeTexture()` | 6 |
|
||||
025 | `DrawCylinder()` | 6 |
|
||||
026 | `DrawCylinderWires()` | 6 |
|
||||
027 | `DrawModelEx()` | 6 |
|
||||
028 | `DrawModelWiresEx()` | 6 |
|
||||
029 | `DrawBillboardRec()` | 6 |
|
||||
030 | `DrawBillboardPro()` | **8** | _WARNING: >7 parameters_
|
||||
008 | `DrawPolyLinesEx()` | 6 |
|
||||
009 | `DrawSplineSegmentBasis()` | 6 |
|
||||
010 | `DrawSplineSegmentCatmullRom()` | 6 |
|
||||
011 | `DrawSplineSegmentBezierCubic()` | 6 |
|
||||
012 | `GenImageChecked()` | 6 |
|
||||
013 | `ImageResizeCanvas()` | 6 |
|
||||
014 | `ImageDrawLine()` | 6 |
|
||||
015 | `ImageDrawRectangle()` | 6 |
|
||||
016 | `ImageDrawText()` | 6 |
|
||||
017 | `ImageDrawTextEx()` | 7 | _WARNING: >6 parameters_
|
||||
018 | `DrawTexturePro()` | 6 |
|
||||
019 | `DrawTextureNPatch()` | 6 |
|
||||
020 | `LoadFontFromMemory()` | 6 |
|
||||
021 | `LoadFontData()` | 6 |
|
||||
022 | `GenImageFontAtlas()` | 6 |
|
||||
023 | `DrawTextEx()` | 6 |
|
||||
024 | `DrawTextPro()` | **8** | _WARNING: >7 parameters_
|
||||
025 | `DrawTextCodepoints()` | 7 | _WARNING: >6 parameters_
|
||||
026 | `DrawCylinder()` | 6 |
|
||||
027 | `DrawCylinderEx()` | 6 |
|
||||
028 | `DrawCylinderWires()` | 6 |
|
||||
029 | `DrawCylinderWiresEx()` | 6 |
|
||||
030 | `DrawCapsule()` | 6 |
|
||||
031 | `DrawCapsuleWires()` | 6 |
|
||||
032 | `DrawModelEx()` | 6 |
|
||||
033 | `DrawModelWiresEx()` | 6 |
|
||||
034 | `DrawBillboardRec()` | 6 |
|
||||
035 | `DrawBillboardPro()` | **9** | _WARNING: >8 parameters_
|
||||
|
||||
Note that **only 6 function out of 470** require more than 6 parameters. This is what makes raylib so special.
|
||||
|
||||
## 2. Structures
|
||||
|
||||
raylib defines a total of **31 struct data types**, most of those structs use a single word to define the type and some of them use two words.
|
||||
raylib defines a total of **34 struct data types**, most of those structs use a single word to define the type and some of them use two words.
|
||||
|
||||
raylib tries to provide generic data types for most common use scenarios, only some of those structs are required for specific examples: `NPatchInfo`, `VrDeviceInfo`, `VrStereoConfig`.
|
||||
|
||||
@ -304,52 +337,56 @@ count | struct name | fields count | comments
|
||||
12 | `Font` | 6 |
|
||||
13 | `Camera3D` | 5 |
|
||||
14 | `Camera2D` | 4 |
|
||||
15 | `Mesh` | **15** |
|
||||
15 | `Mesh` | **21** |
|
||||
16 | `Shader` | 2 |
|
||||
17 | `MaterialMap` | 3 | _2 words name_
|
||||
18 | `Material` | 3 |
|
||||
19 | `Transform` | 3 |
|
||||
20 | `BoneInfo` | 2 | _2 words name_
|
||||
21 | `Model` | **9** |
|
||||
22 | `ModelAnimation` | 4 | _2 words name_
|
||||
21 | `Model` | **12** |
|
||||
22 | `ModelAnimation` | 5 | _2 words name_
|
||||
23 | `Ray` | 2 |
|
||||
24 | `RayCollision` | 4 | _2 words name_
|
||||
25 | `BoundingBox` | 2 | _2 words name_
|
||||
26 | `Wave` | 5 |
|
||||
27 | `AudioStream` | 4 | _2 words name_
|
||||
27 | `AudioStream` | 6 | _2 words name_
|
||||
28 | `Sound` | 2 |
|
||||
29 | `Music` | 5 |
|
||||
30 | `VrDeviceInfo` | **10** | _3 words name_
|
||||
29 | `Music` | 6 |
|
||||
30 | `VrDeviceInfo` | **9** | _3 words name_
|
||||
31 | `VrStereoConfig` | **8** | _3 words name_
|
||||
32 | `FilePathList` | 3 | _3 words name_
|
||||
33 | `AutomationEvent` | 3 | _2 words name_
|
||||
34 | `AutomationEventList` | 3 | _3 words name_
|
||||
|
||||
## 3. Enumerations
|
||||
|
||||
raylib defines **20 enumerations** for convenience. Enum names and contained value names are kept simple and clear. Most of those values are only required to be used by some very specific functions, for a detailed list check Wiki entry: [raylib enumerated types](https://github.com/raysan5/raylib/wiki/raylib-enumerated-types).
|
||||
raylib defines **21 enumerations** for convenience. Enum names and contained value names are kept simple and clear. Most of those values are only required to be used by some very specific functions, for a detailed list check Wiki entry: [raylib enumerated types](https://github.com/raysan5/raylib/wiki/raylib-enumerated-types).
|
||||
|
||||
Personally, I tried to avoid enum values requirement as much as possible within the library, actually, **only 35 function in raylib could require using some enum value on some of its input parameters**.
|
||||
|
||||
count | enum name | values count | comments
|
||||
:--:| :---------: | :-------: | :--------
|
||||
01 | `ConfigFlags` | 14 |
|
||||
01 | `ConfigFlags` | 16 |
|
||||
02 | `TraceLogLevel` | 8 | _3 words name_
|
||||
03 | `KeyboardKey` | **110** |
|
||||
04 | `MouseButton` | 8 |
|
||||
03 | `KeyboardKey` | **114** |
|
||||
04 | `MouseButton` | 7 |
|
||||
05 | `MouseCursor` | 11 |
|
||||
06 | `GamepadButton` | **18** |
|
||||
07 | `GamepadAxis` | 6 |
|
||||
08 | `MaterialMapIndex` | 11 | _3 words name_
|
||||
09 | `ShaderLocationIndex` | **26** | _3 words name_
|
||||
10 | `ShaderUniformDataType` | 9 | **_4 words name_**
|
||||
11 | `PixelFormat` | **21** |
|
||||
12 | `TextureFilter` | 6 |
|
||||
13 | `TextureWrap` | 4 |
|
||||
14 | `CubemapLayout` | 6 |
|
||||
15 | `FontType` | 3 |
|
||||
16 | `BlendMode` | 6 |
|
||||
17 | `Gesture` | 11 |
|
||||
18 | `CameraMode` | 5 |
|
||||
19 | `CameraProjection` | 2 |
|
||||
20 | `NPatchLayout` | 3 | _3 words name_
|
||||
11 | `ShaderAttributeDataType` | 4 | **_4 words name_**
|
||||
12 | `PixelFormat` | **24** |
|
||||
13 | `TextureFilter` | 6 |
|
||||
14 | `TextureWrap` | 4 |
|
||||
15 | `CubemapLayout` | 6 |
|
||||
16 | `FontType` | 3 |
|
||||
17 | `BlendMode` | 8 |
|
||||
18 | `Gesture` | 11 |
|
||||
19 | `CameraMode` | 5 |
|
||||
20 | `CameraProjection` | 2 |
|
||||
21 | `NPatchLayout` | 3 | _3 words name_
|
||||
|
||||
## Conclusion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user