Writing game engine in C++, considering switching to D

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Sat Feb 21 09:14:40 PST 2015


On Friday, 20 February 2015 at 17:49:22 UTC, ponce wrote:
> On Friday, 20 February 2015 at 15:26:02 UTC, John Colvin wrote:
>>
>> However, if you make the context current in the GC thread 
>> that's cleaning up, then you should be fine. There's nothing 
>> wrong with having the same context current in multiple threads 
>> as long as you don't access it concurrently.
>
> I'm sorry but there is two problems with your solution:
>
> - first an OpenGL context cannot be bound to more than one 
> thread simultaneously
>
> https://msdn.microsoft.com/en-us/library/windows/desktop/dd374387%28v=vs.85%29.aspx
> "A rendering context can be current to only one thread at a 
> time."
>
> Looks odd since compute APIs do not have this limitation.

The OS X documentation makes it seem possible:
https://developer.apple.com/library/mac/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_threading/opengl_threading.html

> - At the point where destructors are called by the GC, all 
> other threads have been resumed. http://dlang.org/garbage.html
> So concurrent OpenGL calls may happen for the same context 
> which is forbidden.
>
>
> Really such ressources should not be freed by the GC, and I 
> with it would not call destructors at all.

Ah, yes, you're right.


More information about the Digitalmars-d mailing list