快速像素绘图库

发布于 2024-10-05 00:54:22 字数 656 浏览 0 评论 0原文

我的应用程序以每像素的方式生成“动画”,因此我需要有效地绘制它们。我尝试过不同的策略/库,但结果并不令人满意,尤其是在更高分辨率的情况下。

这是我尝试过的:

  • SDL:好的,但是慢;

  • OpenGL:低效的像素操作;

  • xlib:更好,但仍然太慢;

  • svgalibdirectfb(其他帧缓冲区实现):它们看起来很完美,但对于最终用户来说设置起来确实太棘手。< /p>

(注意:我对这些断言可能是错误的,如果是这样请纠正我)

我需要的是以下内容:

  • 快速像素绘制,其性能可与 OpenGL 渲染;

  • 它应该在 Linux 上运行(跨平台作为奖励功能);

  • 应支持双缓冲和垂直同步;

  • 对于涉及硬件的内容,它应该是可移植的;

  • 它应该是开源的。

你能给我一些启示/想法/建议吗?

My application produces an "animation" in a per-pixel manner, so i need to efficiently draw them. I've tried different strategies/libraries with unsatisfactory results especially at higher resolutions.

Here's what I've tried:

  • SDL: ok, but slow;

  • OpenGL: inefficient pixel operations;

  • xlib: better, but still too slow;

  • svgalib, directfb, (other frame buffer implementations): they seem perfect but definitely too tricky to setup for the end user.

(NOTE: I'm maybe wrong about these assertions, if it's so please correct me)

What I need is the following:

  • fast pixel drawing with performances comparable to OpenGL rendering;

  • it should work on Linux (cross-platform as a bonus feature);

  • it should support double buffering and vertical synchronization;

  • it should be portable for what concerns the hardware;

  • it should be open source.

Can you please give me some enlightenment/ideas/suggestions?

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

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

发布评论

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

评论(3

不即不离 2024-10-12 00:54:22

您的像素是稀疏还是密集(例如位图)?如果您要使用像素创建密集位图,则另一种选择是将位图转换为 OpenGL 纹理并使用 OpenGL API 以某个帧速率进行渲染。

基本问题是图形硬件在不同的硬件平台上会有很大的不同。要么选择一个抽象层,这会减慢速度,要么编写更接近现有图形硬件类型的代码,但这是不可移植的。

Are your pixels sparse or dense (e.g. a bitmap)? If you are creating dense bitmaps out of pixels, then another option is to convert the bitmap into an OpenGL texture and use OpenGL APIs to render at some framerate.

The basic problem is that graphics hardware will be very different on different hardware platforms. Either you pick an abstraction layer, which slows things down, or code more closely to the type of graphics hardware present, which isn't portable.

小…红帽 2024-10-12 00:54:22

我不完全确定你做错了什么,但可能是你一次将一个像素写入显示表面。

不要那样做。

相反,应在主内存中以与要渲染的显示表面相同的格式创建渲染表面,然后通过单个操作将整个渲染图像复制到显示器。现代 GPU 的每个事务速度非常慢,但可以在单个操作中非常快速地移动大量数据。

I'm not totally sure what you're doing wrong, but it could be that you are writing pixels one at a time to the display surface.

Don't do that.

Instead, create a rendering surface in main memory in the same format as the display surface to render to, and then copy the whole, rendered image to the display in a single operation. Modern GPU's are very slow per transaction, but can move lots of data very quickly in a single operation.

A君 2024-10-12 00:54:22

看起来您将窗口管理器(SDL 和 xlib)与渲染库(opengl)混淆了。

只需选择一个窗口管理器(如果您喜欢挑战,可以选择 SDL、Glut 或 xlib),激活双缓冲模式,并确保获得直接渲染。

你有什么类型的显卡?它很可能会在 GPU 上处理像素。了解如何在 opengl 中创建像素着色器。像素着色器按像素进行处理。

Looks like you are confusing window manager (SDL and xlib) with rendering library (opengl).

Just pick a window manager (SDL, glut, or xlib if you like a challenge), activate double buffer mode, and make sure that you got direct rendering.

What kind of graphical card do you have? Most likely it will process pixels on the GPU. Look up how to create pixel shaders in opengl. Pixel shaders are processing per pixel.

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