Use draw in surface


I’m fairly new to Cinder. I wanted to use Opencv in combination with cinder to make an iOS app. I would like to use the draw function in cinder to first draw a circle and further use the GaussianBlur from opencv to blur the edges. I seem to be able to import images as surfaces and blur them on cinder but cannot seem to be able to blur output of a draw function (in this case gl::drawSolidCircle). How do I draw on a surface or use the existing screen display as a surface to blur the circle on it?

Thanks a lot for your help.



a Surface is an image bitmap in system memory, so it’s just a big piece of memory that you can read from and write to from your C++ code. The functions in Cinder’s ip namespace can work with that data and so can OpenCV. However, the data can not be read (directly) by the GPU. You would need to create a gl::Texture2d first.

In contrast, the functions in Cinder’s gl namespace all use the OpenGL backend. All drawing is handled by the GPU and therefor hardware accelerated. The drawSolidCircle, for example, tells OpenGL to draw a bunch of thin, solid triangles that together look like a circle. This is not done in system memory, but in so-called device memory (video memory). You could in theory copy the result back to system memory, but this is notoriously slow (in computer terms).

The solution is to either use OpenGL for everything (including using a shader to perform the Gaussian blur in real-time), or draw a circle yourself. In that case, have a look at the Cairo backend, which offers a lot of cool drawing tools to render things in system memory.

I am not entirely sure Cairo is supported on iOS, but it’s worth checking out.

Thanks for the quick response Paul. I’ll look into Cairo and if it supports iOS