I have been making paint application and i have implemented successfully drawing with paint brush..My problem is I do not want color to be redrawn on the screen where color is already been painted..Have a look in screenshot..I am using OpenGl ES.. I tried to match screens pixels’ color with current brush’s color but I could not get it right..Can anyone tell me where i am going wrong?? Thanks..
Screenshot for probliem : http://imageshack.us/photo/my-images/842/screenshot20110726at601.png/
I am pasting my code here:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
CGRect bounds =[self bounds];
UITouch *touch = [[event touchesForView:self] anyObject];
//glDisable(GL_BLEND);
glEnable(GL_BLEND);
Byte pixel[4];
glReadPixels(location.x,location.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
NSLog(@"%d %d %d %d",pixel[0],pixel[1],pixel[2],pixel[3]);
r_comp=(float)pixel[0]/255;
g_comp=(float)pixel[1]/255;
b_comp=(float)pixel[2]/255;
artbrushAppDelegate *app=(artbrushAppDelegate *)[[UIApplication sharedApplication]delegate];
if(r_comp==app.rg && g_comp==app.gg && b_comp==app.bg)
// app.rg,app.bg,app.gg are brush colors saved in global varable
{
glEnable(GL_BLEND);
}
else
{
glDisable(GL_BLEND);
}
You can apply “layers” mechanism, where the paint is opaque but they layer as a whole is partly transparent.. I read it in forum somewhere..