在屏幕上绘制二维三胞胎2D数组的最快方法是什么? [英] What is the fastest way to draw a 2D array of color triplets on screen?

查看:99
本文介绍了在屏幕上绘制二维三胞胎2D数组的最快方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标语言是C/C ++,该程序只能在Linux上运行,但是显然首选平台无关的解决方案.我运行Xorg,可以使用XVideo和OpenGL.

The target language is C/C++ and the program has only to work on Linux, but platform independent solutions are preferred obviously. I run Xorg, XVideo and OpenGL are available.

在带有Intel图形的Intel Core 2 Duo上,我可以在1024x768上获得多少FPS? (仅计数,考虑阵列已在RAM中准备就绪;不需要精确的预后)

How many FPS can I expect on 1024x768 on an Intel Core 2 Duo with Intel graphics? (ONLY drawing counts, consider the arrays to be ready in RAM; no precise prognosis needed)

推荐答案

绘制三元组二维数组的最快方法:

The fastest way to draw a 2D array of color triplets:

  1. 使用浮点存储( not 字节, not 两倍).每个三元组包含3个从0.0到1.0的浮点数.这是GPU最理想地实现的格式(但是在不需要色相时使用灰度GL_LUMINANCE存储-更快!)
  2. 使用glTexImage2D
  3. 将数组上载到纹理
  4. 确保将GL_TEXTURE_MIN_FILTER纹理参数设置为GL_NEAREST
  5. 将纹理映射到适当的四边形.
  1. Use float (not byte, not double) storage. Each triplet consists of 3 floats from 0.0 to 1.0 each. This is the format implemented most optimally by GPUs (but use greyscale GL_LUMINANCE storage when you don't need hue - much faster!)
  2. Upload the array to a texture with glTexImage2D
  3. Make sure that the GL_TEXTURE_MIN_FILTER texture parameter is set to GL_NEAREST
  4. Map the texture to an appropriate quad.

此方法比glDrawPixels(由于某种原因往往无法正确实施)要快一些,并且比使用平台的本地blitting快 .

This method is slightly faster than glDrawPixels (which for some reason tends to be badly implemented) and a lot faster than using the platform's native blitting.

此外,它使您可以选择在像素图没有更改的情况下重复执行第4步而不执行第2步,这当然要快得多.

Also, it gives you the option to repeatedly do step 4 without step 2 when your pixmap hasn't changed, which of course is much faster.

仅提供较慢的本机blitting的库包括:

Libraries that provide only slow native blitting include:

  • Windows的GDI
  • X11上的SDL(在Windows上,当使用HW_SURFACE时,它提供了一个快速的opengl后端)
  • Qt

对于FPS,可以预期的是,在具有Intel图形的Intel Core 2 Duo上绘制1024x768纹理:如果纹理每帧变化一次,则约为60FPS;如果纹理没有变化,则为> 100FPS.

As to the FPS you can expect, drawing a 1024x768 texture on an Intel Core 2 Duo with Intel graphics: about 60FPS if the texture changes every frame and >100FPS if it doesn't.

但是自己动手做吧;)

这篇关于在屏幕上绘制二维三胞胎2D数组的最快方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆