0
\$\begingroup\$

I have a client that sends data at 1KHz (i.e. 0.001 sec) to a master over Internet using UDP protocol. In Master, I need to draw an object, but the problem is that the update of GLUT is slower than the client's update. I have tried to use glutTimerFunc(0,glutIdle, 0); but still slow. Is there a way to speed up the update rate of drawing? I need to update Display() every 0.001 sec. Any suggestions? I'm using windows 7.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Regular screens aren't able to refresh every milliseconds. Are you sure you need this speed ? Couldn't you store the data and process it 60 times a second ? \$\endgroup\$
    – Heckel
    Commented Aug 18, 2014 at 23:23
  • \$\begingroup\$ @Heckel, I know but I need to call 'idle()' at 1KHz so that it receives data from socket at 1KHz. Otherwise, the object is moving every slow. 60 fps is enough for our eyes but this doesn't mean we can't call Display() at 1KHz. \$\endgroup\$
    – CroCo
    Commented Aug 18, 2014 at 23:30

1 Answer 1

2
\$\begingroup\$

With anything more than trivial rendering, you cannot realistically aim at having 1000+ fps framerate. Besides, that does not makes sense if you think about it - your display refresh rate is probably only 60Hz.

Instead you need to rethink your approach. So data can be displayed at 60fps max. The rest just needs to be discarded. Can you do that before rendering, or maybe even before processing UDP packet?

If you are sure that you need to process UDP packets on-the-fly - add a separate thread to your program to collect that data.

P.S. IIRC TCP/UDP implementations are usually made in threads and write into a buffer that you poll on regularly. Check that too.

\$\endgroup\$
1
  • \$\begingroup\$ It seems the problem from blocking and non blocking modes. Problem solved thanks. \$\endgroup\$
    – CroCo
    Commented Aug 19, 2014 at 18:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .