raylib does not support multiple Windows by default, it was designed with simplicity in main and multi-window option was not considered as a core feature.
raylib does not support multiple Windows by default, it was designed with simplicity in main and multi-window option was not considered as a core feature.
Fortunately raylib current design allows adding multi-window support in an easy way, in case some user requires this functionality.
Fortunately raylib's current design allows adding multi-window support in an easy way, in case some user requires this functionality.
Those are the steps to follow to modify the raylib source code and add multi-window support:
the steps to follow to modify the raylib source code and add multi-window support are as follows:
- [raylib.h] A `MAX_CONTEXTS` constant is defined to give the size of `RLGL[]` and `CoreData.Window[]`
- [raylib.h] A `MAX_CONTEXTS` constant is defined to give the size of `RLGL[]` and `CoreData.Window[]`
- [core] Change the `CoreData.Window` struct into `CoreData.Window[MAX_CONTEXTS]` and add a `currentWindow` variable as global index to switch between the structures, as well as a `numWindows` variable to keep count of the total number of windows
- [core] Change the `CoreData.Window` struct into `CoreData.Window[MAX_CONTEXTS]` and add a `currentWindow` variable as global index to switch between the structures, as well as a `numWindows` variable to keep count of the total number of windows
@ -15,4 +15,4 @@ Those are the steps to follow to modify the raylib source code and add multi-win
That's it. To use it just call `InitWindow()` twice to get two windows. Then, just call `BeginDrawing(n)` to set current window for drawing (`BeginDrawing(n)`- `EndDrawing()`).
That's it. To use it just call `InitWindow()` twice to get two windows. Then, just call `BeginDrawing(n)` to set current window for drawing (`BeginDrawing(n)`- `EndDrawing()`).
NOTE: This has been tested only on Microsoft Windows for recreational purpose.
NOTE: This has only been tested on Microsoft Windows for recreational purposes.