Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Should i use PBO ?

This topic is 2147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hiya, im almost done rebuilding an app i've made and changed the design a lot. As a result, im facing some kind of a dilema, let me explain.


First of all, my program is networked and multithreaded, so when a connection is made, i start a thread to handle the read/write stuff over a socket. In the past, i could just create my OpenGL classes that handle all the graphic part when the thread started, and shutdown it just before the thread finished it's job, and do the rendering and texture loading on the thread too.


But in my new design, the thread function is kinda used by both applications(client and server), and only the client need the opengl part.


This complicate things. For example, if i call Initialize()/Shutdown() opengl in the main thread, the LoadTexture() and Render() functions don't work. I know it has something to do with glMakeCurrent() but i dont want to switch context all the time.


I guess i could overload 2 virtual functions in the client side, to initialise/shutdown opengl, and do the same for the server, but leaving the functions empty, that way it would work but it wouldn't still solve all the issues im having.


Then, i just came upon PBO. From what i've read, they could be perfect for the job. Just call Initialise()/Shutdown() and Render() in the main thread, and load the texture asycronously from the worker thread. But, wouldn't i need to call glMakeCurrent() for this to work too?


Not to mention that i don't have a clue at the momment about how to setup a PBO.


Thx for taking time to respond to this thread.




EDIT: I just added a simple diagram to show how the code is layered. And here's the code for RemotePC.cpp, RemotePCServer.cpp and RemotePCClient.cpp if anyone want to get a closer look at what im doing exactly.

Edited by Vortez

Share this post

Link to post
Share on other sites

Actually, it's the opposite, i already have all the win32 code to take the screenshot and send it over a network, the problem is on the other side, where i draw the image using opengl.


I used to be able to create the opengl manager in the tread initialization, and only use it there, but with my new design, it would be a bit weird to do it that way.


So instead of initalizing opengl in the 2nd thread (where i recv the screenshot data), i though it would be great to let the main thread initialise/shutdown/render the texture,

and use the async ability of PBO to load that texture from the 2nd thread when it recieve one, while rendering continously in the main tread using a timer, for example.


Hope that make more sense.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!