如何避免使用X11在图形绘图中闪烁

时间:2022-10-16 12:02:27

We are drawing graph in a window. We are updating the curves for every 50ms with the values received from hardware say like sensors. We need to display the values in graphical format. So we are updating the graph for every 50ms. This gives flickering issue. We are writing the code in X11. Is there a way to avoid flickering in graphical drawing in X11. Thanks in advance.

我们在窗户上画图形。我们正在更新每50ms的曲线,使用从硬件接收到的值,比如传感器。我们需要以图形格式显示值。所以我们每50ms更新一个图形。这给了闪烁的问题。我们用X11写代码。有没有一种方法可以避免在X11的图形绘制中闪烁。提前谢谢。

2 个解决方案

#1


1  

The keyword here is double-buffering. But I don't know if x11 offers this out-of-the-box or you need to implement it yourself, so I'll leave the google search for you ;)

这里的关键字是双缓冲。但我不知道x11是否提供了这个开箱即用的功能,或者您需要自己实现它,所以我将为您保留谷歌搜索;

Apart from that you may consider updating less often. Perhaps it's enough to update with a 250, 500 or 1000ms period? That depends on your use-case of course.

除此之外,你可以考虑不经常更新。也许更新250、500或1000ms就足够了?这当然取决于你的用例。

#2


1  

You're welcome. Hmm. Well, in that case I'd check out the X-Server settings for the machines that will run it. I recently got a new vid card and found that openGL apps were running a higher number of frames/second, but that the quality was terrible - there was visible 'tearing' of the image - you could consistantly see a combination of the last and the current frames at the same time. After I enabled wait for VSynch in the XServer's settings, the problem dissapeared. However, it sounds more like a problem I've experienced under MS windows in the past. In that particular case, each time I sent a new image to the control, windows was redrawing the background of the window/dialog that was under the image window. So, instead of simply replacing the old image, it would erase the image to the stock-grey before then going on to replace the image (grrr). If you've got access to fast enough screen-recording software, you can video the app whilst running, then play back the video frame-by-frame. Alternatly, you may get some traction if you search for "disable window background redrawing/erasing X11" or something similar. :)

你是受欢迎的。嗯。在这种情况下,我将检查运行它的机器的x -服务器设置。我最近得到了一个新的视频卡,发现openGL应用程序运行更高的帧数/秒,但质量是可怕的,可见“撕裂”的形象,你可以看到最后的组合技术,并在同一时间和当前帧。在XServer的设置中启用等待VSynch之后,问题消失了。然而,这听起来更像是我过去在MS windows下遇到的一个问题。在这种情况下,每当我向控件发送一个新图像时,窗口就会重新绘制在图像窗口下的窗口/对话框的背景。因此,它不会简单地替换旧图像,而是将图像删除到stock-grey,然后再替换图像(grrr)。如果你有足够快的屏幕录制软件,你可以一边运行一边录制,然后逐帧回放视频。相反,如果你搜索“禁用窗口背景重绘/擦除X11”或类似的东西,你可能会得到一些牵引力。:)

Guess it would also depend on whether or not you used Gtk+, wxWidgets or just raw X11 code.

我猜这也取决于您是否使用了Gtk+、wxWidgets或原始的X11代码。

#1


1  

The keyword here is double-buffering. But I don't know if x11 offers this out-of-the-box or you need to implement it yourself, so I'll leave the google search for you ;)

这里的关键字是双缓冲。但我不知道x11是否提供了这个开箱即用的功能,或者您需要自己实现它,所以我将为您保留谷歌搜索;

Apart from that you may consider updating less often. Perhaps it's enough to update with a 250, 500 or 1000ms period? That depends on your use-case of course.

除此之外,你可以考虑不经常更新。也许更新250、500或1000ms就足够了?这当然取决于你的用例。

#2


1  

You're welcome. Hmm. Well, in that case I'd check out the X-Server settings for the machines that will run it. I recently got a new vid card and found that openGL apps were running a higher number of frames/second, but that the quality was terrible - there was visible 'tearing' of the image - you could consistantly see a combination of the last and the current frames at the same time. After I enabled wait for VSynch in the XServer's settings, the problem dissapeared. However, it sounds more like a problem I've experienced under MS windows in the past. In that particular case, each time I sent a new image to the control, windows was redrawing the background of the window/dialog that was under the image window. So, instead of simply replacing the old image, it would erase the image to the stock-grey before then going on to replace the image (grrr). If you've got access to fast enough screen-recording software, you can video the app whilst running, then play back the video frame-by-frame. Alternatly, you may get some traction if you search for "disable window background redrawing/erasing X11" or something similar. :)

你是受欢迎的。嗯。在这种情况下,我将检查运行它的机器的x -服务器设置。我最近得到了一个新的视频卡,发现openGL应用程序运行更高的帧数/秒,但质量是可怕的,可见“撕裂”的形象,你可以看到最后的组合技术,并在同一时间和当前帧。在XServer的设置中启用等待VSynch之后,问题消失了。然而,这听起来更像是我过去在MS windows下遇到的一个问题。在这种情况下,每当我向控件发送一个新图像时,窗口就会重新绘制在图像窗口下的窗口/对话框的背景。因此,它不会简单地替换旧图像,而是将图像删除到stock-grey,然后再替换图像(grrr)。如果你有足够快的屏幕录制软件,你可以一边运行一边录制,然后逐帧回放视频。相反,如果你搜索“禁用窗口背景重绘/擦除X11”或类似的东西,你可能会得到一些牵引力。:)

Guess it would also depend on whether or not you used Gtk+, wxWidgets or just raw X11 code.

我猜这也取决于您是否使用了Gtk+、wxWidgets或原始的X11代码。