Threading with SDL

Adrian Preuß adrian.preuss at icloud.com
Tue Nov 19 09:08:46 UTC 2024


Hey,

I'm looking at **D** right now because I find it much easier to 
create native applications as opposed to C++.

I have the following project structure:
```
     - main.d (Booting)
     - client.d
     - Renderer.d
         - Manager
             - SDL2.d
             - GLFW.d
         - RenderingTargets
             - DirectX.d
             - Vulkan.d
             - OpenGL.d
```

A new client instance is created in main.d. This will later serve 
as the “main game” instance.

A new instance of Renderer.d is created here. This contains the 
window manager (e.g. via `SDL2` or `GLFW`) and the respective 
rendering engine (`Vulkan`, `DirectX`, `OpenGL`, etc.).

However, as soon as I initialize the window in SDL2.d and then 
want to render it, the whole thing blocks the client.

The RenderingTarget must create `SDL2` or `GLFW` as an instance 
here, as there are differences between the individual graphics 
interfaces and `GLFW`, for example, does not support DirectX.

How can I implement the whole thing thread-based so that the 
client functions are executed as soon as `SDL2` blocks the 
application?



More information about the Digitalmars-d-learn mailing list