CGMutuablePath and GLPaint

122 Views Asked by At

Referring to this question :OpenGL ES Fill Effect I am trying to do the samething , but I have Custom UIView , which contains different CGMutuablePath and only drawing is enabled in selected UIView.

I have used GLPaint, PaintingView class and used it as a custom class to even draw different paths, everthing is working fine. except that I need to fill those paths too. When he user want to use a bucket paint effect. As I am using defined CG closed paths, is it possible to fill those paths using EAGLContext . I have tried in many ways to fill it with CGContextRef , but it always end up with "Invalid context" , I guess its not possible to use 2 differnt context in single view.

Can any body help me with this problem? How can I fill my path using EAGLContext ?

1

There are 1 best solutions below

0
Mohammad Haseeb On

It's a bit hard to grasp the problem here without any actual example of your code/app. However, it seems you're trying to fill a stroked path.

Firstly, I don't know why you're suggesting two contexts here? You're drawing CGMutablePaths using a CGContext but you're trying to fill them using EAGLContext? That's quite a far fetched solution to the problem. EAGLContext is OpenGL ES (usually 3d stuff) and CGContext is Quartz 2D. Unless you have specific reasons to do so, I wouldn't recommend mixing both contexts in a single view without proper application.

You say you've tried everything to fill the paths? Which means you've already tried CGContextEOFillPath and CGContextFillPath? Anyhow, this should work with CGMutablePaths:

// Draw your CGMutablePath

CGContextAddPath(yourcgcontext, yourcgmpath); //Adds a previously created Quartz path. 
CGContextClosePath(yourcgcontext); //Closes and terminates the current path’s subpath.
CGContextClip(yourcgcontext); Modifies the current clipping path.

// Fill a solid or a gradient or an image, that should be clipped to your path.