如何使用OpenGL在屏幕上绘制OpenCL计算的像素? [英] How to draw OpenCL calculated pixels to the screen with OpenGL?

查看:183
本文介绍了如何使用OpenGL在屏幕上绘制OpenCL计算的像素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不会使用OpenCL进行一些计算得出的pixelart,而直接在显示器上显示它,而无需CPU往返.我可以使用OpenCL与OpenGL的互操作性,并写入GPU的纹理库,并使用OpenGL显示纹理.我想知道什么是最好的方法,因为我不需要任何3D东西,只需2d pixelart.

I wan't to do some calculated pixelart with OpenCL and display this directly on the display without CPU roundtripping. I could use interoperability of OpenCL with OpenGL and write to the texture-banks of the GPU and display the texture with OpenGL. I was wondering what would be the best way to do this, since I do not need any 3d stuff, just 2d pixelart.

推荐答案

如果您的OpenCL实现支持,最好的方法是使用OpenCL/OpenGL互操作.这使OpenCL可以访问某些OpenGL对象(缓冲区对象和纹理/渲染缓冲区).您将无法直接访问默认的OpenGL帧缓冲区(即显示),但是将能够访问绑定到

The best way would be to use OpenCL/OpenGL interop, if your OpenCL implementation supports it. This allows OpenCL to access certain OpenGL objects (buffer objects and textures/renderbuffers). You won't be able to directly access the default OpenGL framebuffer (ie: the display), but you will be able to access an image bound to a framebuffer object. From there, you can, in OpenGL, do a framebuffer blit to the default framebuffer. Nothing will touch CPU memory.

您必须在

You'll have to look up the specifics on CL/GL interop to learn the details however. The basic idea is that you create a renderbuffer in OpenGL (which you bind to an FBO). Then you hand that renderbuffer off to OpenCL, and do your computations into the renderbuffer. Once that's complete, you perform a glBlitFramebuffer to copy the data from the renderbuffer to the default framebuffer, then swap buffers to display it.

这篇关于如何使用OpenGL在屏幕上绘制OpenCL计算的像素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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