I think i’m not enough clear about what my solution do. I will publish you a fictive example in C/C++
This is a “normal” drawing function on the opengl thread
glUniform4fv (16, 9, (const float *)Colors);
for ( int i = 0 ; i < BodyCount ; i ++ )
{
glUniformMatrix4fv (0, 4, GL_FALSE, (const float *)BonesMatrix);
glDrawArrays (GL_TRIANGLES, 0, TrianglesCount);
}
i replace by this commands on an other thread
GLoffline->Uniform4fv (16, 9, (const float *)Colors);
for ( int i = 0 ; i < BodyCount ; i ++ ) // BodyCount = 2 for exemple
{
GLoffline->UniformMatrix4fv (0, 4, GL_FALSE, (const float *)BonesMatrix[i]);
GLoffline->DrawArrays (GL_TRIANGLES, 0, TrianglesCount); // TrianglesCount = 727 for exemple
}
Each function of the GLoffline object only add correct hexadecimal instructions for arguments and the call of the right opengl function. But it doesn’t execute the opengl command, else program crash of course because it hasn’t been executed on the opengl thread ;). Of course, it also add the ret instruction at the end for the return. The result function is like that.
void dynamicFunc (void)
{
glUniform4fv (16, 9, 0x56be79c4);
glUniformMatrix4fv (0, 4, GL_FALSE, 0x56be7000);
glDrawArrays (GL_TRIANGLES, 0, 727);
glUniformMatrix4fv (0, 4, GL_FALSE, 0x56be7800);
glDrawArrays (GL_TRIANGLES, 0, 727);
return ;
}
You can see, this function do not compute, loop or test, it has only opengl calls with arguments ready to be pop in the CPU stacks to calls opengl functions pointers, and then this function is executed on the opengl threads. Any problems like display list (which are deprecated) on an other opengl context.
This is simply work like that, multithreaded submission
Here, this example doesn’t really need a such techniques, because it’s very easy, but some rendering who required a lot of opengl calls can win performances. (Very nice on CPU which has 4 or more cores)
Do you understand what i mean ?