如何加快在Win32上使用大纹理的屏幕外OpenGL渲染?(How to speed up offscreen OpenGL rendering with large textures on Win3

编程入门 行业动态 更新时间:2024-10-21 23:27:56
如何加快在Win32上使用大纹理的屏幕外OpenGL渲染?(How to speed up offscreen OpenGL rendering with large textures on Win32?)

我正在开发一些C ++代码,可以在两幅图像之间做一些奇特的3D过渡效果,对此我认为OpenGL将是最佳选择。

我从一个DIB部分开始,并为OpenGL进行设置,并从输入图像创建两个纹理。

然后,对于每一帧我只画两个OpenGL四边形,以及相应的图像纹理。 DIB内容然后保存到文件。

例如,一个效果是将两个四边形(在三维空间中)定位为两个广告牌,一个在另一个的前面(遮挡它),然后向上,向下俯视相机,以便您可以看到第二个。

我的输入图像为1024x768左右,当四边形覆盖大部分视图时,需要很长时间才能渲染(100毫秒)。 如果相机很远,它会加速。

我试着将每个图像的四边形渲染为数百个单独的图块,但它只需要同一时间,它看起来取决于可见纹理像素的数量。

我认为OpenGL可以做一秒钟的无数个多边形。 有什么我在这里失踪?

使用其他方法会更好吗?

提前致谢...

编辑:

GL字符串显示为DIB版本:

供应商:Microsoft Corporation版本:1.1.0渲染器:GDI Generic

Onscreen版本显示:供应商:ATI Technologies Inc.版本:3.2.9756兼容性配置文件上下文渲染器:ATI Mobility Radeon HD 3400系列

所以我想我必须使用FBO,对于如何从FBO将渲染数据提取到DIB上,我有点困惑,任何指针(双关语)都是如此?

I'm developing some C++ code that can do some fancy 3D transition effects between two images, for which I thought OpenGL would be the best option.

I start with a DIB section and set it up for OpenGL, and I create two textures from input images.

Then for each frame I draw just two OpenGL quads, with the corresponding image texture. The DIB content is then saved to file.

For example one effect is to locate the two quads (in 3d space) like two billboards, one in front of the other(obscuring it), and then swoop the camera up, forward and down so you can see the second one.

My input images are 1024x768 or so and it takes a really long time to render (100 milliseconds) when the quads cover most of the view. It speeds up if the camera is far away.

I tried rendering each image quad as hundreds of individual tiles, but it takes just the same time, it seems like it depends on the number of visible textured pixels.

I assumed OpenGL could do zillions of polygons a second. Is there something I am missing here?

Would I be better off using some other approach?

Thanks in advance...

Edit :

The GL strings show up for the DIB version as :

Vendor : Microsoft Corporation Version: 1.1.0 Renderer : GDI Generic

The Onscreen version shows : Vendor : ATI Technologies Inc. Version : 3.2.9756 Compatibility Profile Context Renderer : ATI Mobility Radeon HD 3400 Series

So I guess I'll have to use FBO's , I'm a bit confused as to how to get the rendered data out from the FBO onto a DIB, any pointers (pun intended) on that?

最满意答案

这听起来像渲染到DIB正在强制渲染发生在软件中。 我渲染到一个帧缓冲区对象,然后从生成的纹理中提取数据。 Gamedev.net有一个相当不错的教程 。

但请记住,图形硬件主要面向在屏幕上绘图。 捕获渲染后的数据通常会比较慢,即使您获得硬件进行渲染 - 尽管它应该比软件渲染还快。

编辑:DominikGöddeke有一个教程 ,其中包含用于将纹理数据读回到CPU地址空间的代码。

It sounds like rendering to a DIB is forcing the rendering to happen in software. I'd render to a frame buffer object, and then extract the data from the generated texture. Gamedev.net has a pretty decent tutorial.

Keep in mind, however, that graphics hardware is oriented primarily toward drawing on the screen. Capturing rendered data will usually be slower that displaying it, even when you do get the hardware to do the rendering -- though it should still be quite a bit faster than software rendering.

Edit: Dominik Göddeke has a tutorial that includes code for reading back texture data to CPU address space.

更多推荐

本文发布于:2023-04-29 11:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336320.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:纹理   屏幕   OpenGL   speed   large

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!