Threading with SDL
user1234
user1234 at 12.de
Tue Nov 19 11:15:02 UTC 2024
On Tuesday, 19 November 2024 at 09:08:46 UTC, Adrian Preuß wrote:
> 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
Well given the informations> - 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?
Given the information it's hard to reply but I'd say pass a
delegate instead of using static constructors, so that when the
basement is there, the basement can launch what depends on it.
More information about the Digitalmars-d-learn
mailing list