加速 2d 绘图

发布于 2024-08-10 13:13:12 字数 809 浏览 2 评论 0原文

我正在尝试制作 2D 实时绘图。我尝试修改qwt的示波器示例,尝试使用QGraphicsView和QPainter来达到高帧率绘图。我使用 8 个通道来绘制来自 rs232 端口的数据。我每 10 毫秒采样一次。 也许我以错误的方式使用了 QPainter,但我画得不是很快。对于 qwt 示例,在不更新整个屏幕的情况下,绘图速度很好,尤其是在使用 Qt::WA_PaintOutsidePaintEvent 和 Qt::WA_PaintOnScreen 的 X11 中。

现在我正在对 QGLWidget 进行子类化,并且达到了可接受的速度。但我想知道我是否可以改进它。

每次我收到一个新点时,我都会存储它,并调用 updateGL(); 在这种情况下,我只收到 y 坐标,但我将收到整个坐标对。

void Plot::addPoint(int y)
{
   points[t].x=t;
   points[t].y=y;
   t++;
   updateGL();
}

在 DrawGL() 中,我检查线条是否到达屏幕末端,如果为 True,则擦除屏幕 如果没有,我只画线的新部分。

  glBegin(GL_LINES);
    glVertex2i( points[t-1].x, points[t-1].y);
    glVertex2i( points[t-2].x, points[t-2].y);
 glEnd();

我已经禁用了抖动和多重采样,并且我正在使用平面阴影。 我正在使用正射投影。

有什么方法可以画得更快吗?也许使用 opengl 进行离屏绘图并显示相应的像素图? 有类似的项目吗?

I'm triying to make a 2D real-time plot. I've tried with modifying the osciloscope example of qwt, tried to use QGraphicsView, and QPainter to reach high framerate drawing. I'm using 8 channels to plot data wich is arriving from a rs232 port. I take a sample every 10 ms.
Maybe i've used the QPainter in a wrong way, but i couldn't draw very fast. With the qwt example, in wich doesn't update the whole screen the drawing speed was good, especially in X11 with Qt::WA_PaintOutsidePaintEvent and Qt::WA_PaintOnScreen.

Now i'm subclassing the QGLWidget, and i'm reaching a acceptable speed. But i'm wondering if i could improve it.

Every time I recived a new point i stored it, and the call updateGL();
In this case i recived only the y coordinate, buth i'm going to recive the whole pair.

void Plot::addPoint(int y)
{
   points[t].x=t;
   points[t].y=y;
   t++;
   updateGL();
}

In DrawGL() i check if the line reach the end of the screen, if is True i erase the screen
if not, i draw only the the new part of the line.

  glBegin(GL_LINES);
    glVertex2i( points[t-1].x, points[t-1].y);
    glVertex2i( points[t-2].x, points[t-2].y);
 glEnd();

I've disabled the Dithering and multisampling, and i'm using flat shades.
i'm using an ortographic projection.

is there some way to draw faster? maybe using opengl for off-screen drawing and the showing the corresponding pixmap?
is the a project similar to this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月无声 2024-08-17 13:13:12

顶点缓冲区对象(也许还有显示列表)将对此有所帮助。基本上,您需要一种减少 GL 调用次数的方法,并且速度会变得更快。

Vertex buffer objects (and perhaps display lists) would help this. Basically you need a way of reducing the number of GL calls you make, and it'll get fast.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文