Created How To: Multiple Windows (markdown)

Ray
2020-07-20 21:52:57 +02:00
parent e9ab210445
commit c4bb97cf3a

@ -0,0 +1,17 @@
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.
Those are the setps to follow to modify the raylib source code and add multi-window support:
- [core] Double the `CoreData.Window` struct into `CoreData.Window[2]` and add a `currentWindow` variable as global index to switch between the structures
- [core] Quick and dirt find/replace all for `CORE.Window` to `CORE.Window[CORE.currentWindow]`
- [rlgl] Double `rlglData RLGL` into `rlglData RLGL[2]` and add a `currentContext` variable as global index to switch between the structures
- [rlgl] Quick and dirt find/replace all for `RLGL` to `RLGL[currentContext]`
- [core] Change the final `glfwCreateWindow()` parameter to share resources from the first context to the second
- [core] Create a new `SetWindowCurrent()` function to `glfwMakeContextCurrent()` on the current window and to set the right `RLGL[]` and `Window[]`
- Write some other few hack lines of code to glue everything together (needs more info!)
That's it. To use it just call `InitWindow()` twice to get two windows. Then, just call `SetWindowCurrent(n)` to set current window for drawing (`BeginDrawing()`- `EndDrawing()`).