Miro Krsjak
Miro Krsjak

Reputation: 363

Is it possible to draw primitives in OpenCL?

I'm trying to use a parallel kernel algorithm, but it needs to call OpenGL functions [like draw a line] directly from the kernel, is this possible? Drawing to a texture object. thx for clues

Upvotes: 0

Views: 1198

Answers (1)

karyon
karyon

Reputation: 2547

No, not really.

First of all, OpenGL drawing commands are issued on CPU side (glDrawArrays for instance). In OpenCL kernels you are operating on the GPU and cannot call these methods.

Additionally, in OpenCL you don't even have access to the fixed-function parts of the GPU rendering pipeline like the tessellation unit or rasterizer.

What you can do of course is create a 2D buffer in OpenCL, implement line rendering by yourself and paint "pixels" in there, but that's probably not what you want.

There are also extensions for OpenGL-OpenCL interoperability, a tutorial is here: https://software.intel.com/en-us/articles/opencl-and-opengl-interoperability-tutorial

Maybe if you tell us what you want to achieve we can give you better alternatives :)

Upvotes: 1

Related Questions