How to use OpenGL functions from multiples thread?
- by Robert
I'm writing a small game using OpenGL.
I'm implementing basic networking in this game and I'm facing a problem.
I have a thread in my client socket class that check for available data, when there are data I raise an event like this :
immutable int len = this.m_socket.receive(data);
if(len > 0)
{
this.m_onDataEvent(data);
}
Then on my game class, I have a function that handle and parse data like this :
switch(msgId)
{
case ProtocolID.CharacterData:
// Load terrain with opengl, character model....
Im not able to call opengl functions because my opengl context is created from a different thread.
But I really don't know how I can solve this problem, I tried Google but it's really hard to find a solution.
I'm using D programming language if it can help.