From c69c0c24919f23aa25cb4fd710056b5742ed03a6 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 5 Mar 2017 11:47:56 +0100 Subject: [PATCH] Updated raylib arquitecture (markdown) --- raylib-arquitecture.md | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/raylib-arquitecture.md b/raylib-arquitecture.md index 25619c2..f825b0b 100644 --- a/raylib-arquitecture.md +++ b/raylib-arquitecture.md @@ -1,22 +1,32 @@ -![image](https://cloud.githubusercontent.com/assets/5766837/15992278/62292086-30c9-11e6-8761-369c2f1010d9.png) +![image](https://github.com/raysan5/raylib/blob/master/docs/images/raylib_architecture.png) -I tried to make raylib as modular as posible, keeping a small number of specific and self-contained modules, organized by its main functionality (and avoiding hundreds of modules depending on other modules, like other C libraries). +raylib is a very modular library, defined by a small number of specific and self-contained modules. Every module is organized by its main functionality (avoiding hundreds of modules depending on other modules, like other C libraries). -raylib main modules are 7: - - `core`: Window / Graphic Context / Inputs management. - - `rlgl`: Graphic API direct access (OpenGL) and pseudo-OpenGL 1.1 translation layer. - - `shapes`: Basic 2D shapes drawing functions. - - `textures`: Textures / Image loading and management. - - `text`: Font data loading and text drawing. - - `models`: 3D models loading and drawing. - - `audio`: Audio device management and sounds / music loading and playing. +**raylib main modules are 7:** + - [`core`](https://github.com/raysan5/raylib/blob/master/src/core.c): Window / Graphic Context / Inputs management. + - [`rlgl`](https://github.com/raysan5/raylib/blob/master/src/rlgl.c): Graphic API (OpenGL) wrapper and pseudo-OpenGL 1.1 translation layer. + - [`shapes`](https://github.com/raysan5/raylib/blob/master/src/shapes.c): Basic 2D shapes drawing functions. + - [`textures`](https://github.com/raysan5/raylib/blob/master/src/textures.c): Textures / Image loading and management. + - [`text`](https://github.com/raysan5/raylib/blob/master/src/text.c): Font data loading and text drawing. + - [`models`](https://github.com/raysan5/raylib/blob/master/src/models.c): 3D models loading and drawing. + - [`audio`](https://github.com/raysan5/raylib/blob/master/src/audio.c): Audio device management and sounds / music loading and playing. -Those 7 modules share a common header: `raylib.h`, all user functions are defined in that header, despite the fact they are divided internally in 7 modules. That way, user just needs to include `raylib.h` to get all raylib functionality. Other libraries use multiple headers for every module or also headers that refer to other headers; I don't like that approach, I prefer to keep it simpler. +Those 7 modules share a common header: [`raylib.h`](https://github.com/raysan5/raylib/blob/master/src/raylib.h), all user functions are defined in that header, despite the fact they are divided internally in 7 modules. That way, user just needs to include `raylib.h` to get all raylib functionality. Other libraries use one headers for every module (that way user can choose included modules) or also headers that refer to other headers; raylib uses a simpler approach, easier for novice (and expert) users. -But there is more. In my design I also tried to keep modularity and independence between modules, so, there are some modules that can be used independently of raylib, as standalone libraries. Those modules are `rlgl` ([example](https://github.com/raysan5/raylib/blob/develop/examples/rlgl_standalone.c)) and `audio` ([example](https://github.com/raysan5/raylib/blob/develop/examples/audio_standalone.c)); since raylib 1.3, new standalone modules were also added to the library with some additional features: `camera`, `gestures` and `raygui`. Those modules can also be used as standalone (like `rlgl` and `audio`), so the available equivalent headers for the user... despite the fact that `camera`and `gestures` are currently included in `raylib.h`. +A part of those 7 main modules, some other modules have been implemented with additional features: + - [`camera`](https://github.com/raysan5/raylib/blob/develop/src/camera.h): 3D Camera system (free, 1st person, 3rd person, custom) + - [`gestures`](https://github.com/raysan5/raylib/blob/develop/src/gestures.h): Touch gestures detection and processing (Tap, Swipe, Drag, Pinch) + - [`raygui`](https://github.com/raysan5/raygui): Simple IMGUI system with several controls for tools development + - [`easings`](https://github.com/raysan5/raylib/blob/develop/src/easings.h): Easing functions for animations (based on [Robert Penner](http://robertpenner.com/easing/) implementation) + - [`physac`](https://github.com/victorfisac/Physac): 2D physics library (collision detection, resolution, dinamics...) + - [`rlua`](https://github.com/raysan5/raylib-lua): raylib Lua binding, supporting Lua scripting -But there is more. Some modules are defined as header-only files, like the well-known [stb libraries](https://github.com/nothings/stb). Being header-only means that header also contains the functions implementation; that's extremely useful in case you have a library (a bunch of functions) that you only want to drop on your code-base to cover a very specific functionality. Actually, raylib uses internally some [of those libraries](https://github.com/raysan5/raylib/tree/develop/src/external). Similar to stb libraries, raylib defines some modules in the same way: `raymath`, `physac`, `raygui` and `easings`. Right now only `raymath` is used internally by raylib, the other three are provided to the user. - -And that's currently the raylib internal structure. +Most of the modules have been designed to be as decoupled as possible from other modules, so, some modules can be used independently of raylib, as standalone libraries. Highlight two of those modules: `rlgl` ([example](https://github.com/raysan5/raylib/blob/develop/examples/rlgl_standalone.c)) and `audio` ([example](https://github.com/raysan5/raylib/blob/develop/examples/audio_standalone.c)). -Now, working in raylib 1.5, I'm reviewing part of that structure: `raygui`and `physac` have been ported to header-only independent modules and thinking to do the same with `camera` and `gestures`; but porting a module to header-only is not trivial, that module has to minimize external dependencies and global variables and give a very specific functionality; let's say it has to be completely portable. +Most of the secondary modules can also be used as standalone libraries: `raymath`, `camera`, `gestures`, `raygui`, `easings`, `physac`. All those modules are distributed as configurable single-file header-only libraries to be independently added to any project. Being header-only means that header also contains the functions implementation; that's extremely useful in case you have a library (a bunch of functions) that you only want to drop on your code-base to cover a very specific functionality. But creating a header-only module is not trivial, that module has to minimize external dependencies and global variables and give a very specific functionality; let's say it has to be completely portable. + +*NOTE: `raymath`, `camera` and `gestures` are included by default on raylib.* + +raylib also uses some external libraries, most of them included as single-file header-only, like the well-known [stb libraries](https://github.com/nothings/stb) or [similar ones](https://github.com/raysan5/raylib/tree/develop/src/external). + +And that's currently the raylib internal structure. \ No newline at end of file