![]() NSString *fragmentShaderSource = encoding:NSUTF8StringEncoding error:nil] Ĭonst char *fragmentShaderSourceCString = GlShaderSource(_vertexShader, 1, &vertexShaderSourceCString, NULL) GLuint _vertexShader = glCreateShader(GL_VERTEX_SHADER) NSString *vertexShaderSource = encoding:NSUTF8StringEncoding error:nil] Ĭonst char *vertexShaderSourceCString = GlFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderbuffer) GlBindFramebuffer(GL_FRAMEBUFFER, framebuffer) GlBindRenderbuffer(GL_RENDERBUFFER, renderbuffer) ![]() This is the method drawing the square: - (void)drawStencil Right now, I'm just trying to draw a square in the stencil buffer and see if I can limit my drawing only to that square. GlStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ) GlColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ) ![]() GlStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE) ![]() GlColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ) This is my stencil buffer setup: glClearStencil(0) One of the tasks is to not let the brush spill out of the contour in which the user started drawing.Īfter reading and understanding some OpenGL basics, I found that using the stencil buffer is the right solution. I'm working on an iOS app, a coloring book for kids and I haven't stumbled upon OpenGL before (more precisely OpenGLES 2.0) so there's a big chance there's stuff I don't actually get in my code. Do a good deed and help get someone (me) out of their misery, since it's New Year's Eve soon.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |