How to use OpenGL functions from multiples thread?

Posted by Robert on Game Development See other posts from Game Development or by Robert
Published on 2014-05-29T15:48:06Z Indexed on 2014/05/29 16:00 UTC
Read the original article Hit count: 253

Filed under:
|

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.

© Game Development or respective owner

Related posts about opengl

Related posts about multithreading