View Full Version : Writing a porting layer (with mygl functions)for multiple clients

11-16-2015, 04:37 AM
I am trying to write a porting layer for multiple clients to run in a server. Every client has its own opengl code, but the output will be on a server (so as the graphics card).
First of all, I am using mygl API's rather than gl API's. I save all of the mygls in shared buffers, and while clients are filling their buffers, server is flushing. Let me try to explain:


myGLuint texture[5];
myglGenTextures(5, texture);


myglBindTexture(MY_GL_TEXTURE_2D, texture[2]);



/////////////////////Porting Layer ///////

myglGenTextures(.., ..)
// storing function name and params in a buffer

myglBindTexture(.., ..);
// storing function name and params in a shared buffer


myParsingBuffer() // parsing the shared buffer
if (function_name is myglBindTexture with param1, param2)
glBindTexture(param1, param2);
// the same for all gl APIs and params.


The problem is that, after calling glGenTextures(5, texture), I am calling glBindTextures but its texture parameter is always zero because I am setting it in server side. For example in normal conditions:

glGenTextures(5, texture); // texture[] is set to {1,2,3,4,5}


glBindTexture(GL_TEXTURE_2D, texture[2]); // texture[2] is 3 so real function call is glBindTexture(GL_TEXTURE_2D, 3)

But in my case:

myglGenTextures(5, texture); // texure is still {0,0,0,0,0} because real gl function is called and executed in server side


myglBindTexture(MY_GL_TEXTURE_2D, texture[2]); // texture[2] is 0 so real function call is myglBindTexture(GL_TEXTURE_2D, 0) which calls glBindTexture(GL_TEXTURE_2D, 0)

So do you have any idea about what to do, or another method for doing this?

Thank you!

Alfonse Reinheart
11-16-2015, 05:25 AM
OpenGL is designed around server/client relations like this. And the way to solve this is simple: `myglGenTextures`, like any OpenGL function that returns a value to the user, must wait until the server can complete at least the basic request. So you have to halt the client, send those commands to your server, and the client doesn't leave `myglGenTexture` until the server passes them back.

Alternatively, you could have your client create texture names on the client. That is, you have a distinction between "mygl" texture names and "OpenGL" texture names. When the server creates its texture names, the client creates a mapping between them and the client names. I'd say that this is probably more complicated than it's worth, but it would prevent the client from having to halt and wait for server generation operations.

Also, any function which immediately passes data back to the user will have to halt in this way. So every `myglGet*` function would have to do this.

11-16-2015, 06:03 AM
Actually because of perfomance problems, i can not apply your first solution.

Now i am trying to create the names in client side. I hope it works. Thanks!