0
\$\begingroup\$

I am using GLUT library for my research/game.

In my game I have 25 windows created using glutCreateWindow(title), and each of them have their own display callback registered using glutDisplayFunc(Draw).

I am trying to stream the screen of each of the 25 windows on my computer to another client which will do some processing with all the screen capture of the 25 windows.

Currently I am capturing the screen of each of the 25 windows with:

glReadPixels(0,0,Xres,Yres,GL_RGB,GL_UNSIGNED_BYTE,pixels);

Just doing the call to glReadPixels for each of the 25 windows slows my fps down to 7 fps.

However I require the fps to be at least 25 FPS, is there any way I can improve the fps?

\$\endgroup\$
  • 2
    \$\begingroup\$ Please don't tell me that you are trying to implement multiplayer by rendering the game server-sided and sending a video stream to each client. \$\endgroup\$ – Philipp Mar 24 '15 at 10:19
  • \$\begingroup\$ I am exploring a method of predictive gaming by rendering all the outcome on the server side and allowing the client to choose only the correct outcome to render. This would only be on a single server and a single client \$\endgroup\$ – Aspiring Game Dev Mar 24 '15 at 10:34
  • 4
    \$\begingroup\$ Moving data between RAM and VRAM is extremely expensive, and doing that 25 times per frame is going to kill any application's frame rate. Why can't you perform the server logic client-side? \$\endgroup\$ – fastinvsqrt Mar 24 '15 at 14:05
  • \$\begingroup\$ The main idea of my research is to have a totally dumb client that only does video streaming so i have to do all the processing on the server side. \$\endgroup\$ – Aspiring Game Dev Mar 25 '15 at 7:58
0
\$\begingroup\$

I found a solution to this.

Conventional glReadPixels() blocks the pipeline and waits until all pixel data are transferred.Then, it returns control to the application.

Thus we can overcome this by making glReadPixels() asynchronous .

glReadPixels() with Pixel buffer object (PBO) can schedule asynchronous DMA transfer and returns immediately without stall.

Read more here : https://www.opengl.org/wiki/Pixel_Buffer_Object

For even better performance, you can even implement double or triple PBO layers.

I read through many sites and found that this site has the most detailed and easy to implement details: http://www.songho.ca/opengl/gl_pbo.html

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.