Re: Adding a background image to the GLPaint sample
Re: Adding a background image to the GLPaint sample
- Subject: Re: Adding a background image to the GLPaint sample
- From: David Duncan <email@hidden>
- Date: Wed, 28 Mar 2012 09:33:22 -0700
On Mar 28, 2012, at 6:22 AM, David Delmonte wrote:
> Hi, I'm trying to do the above. I've added a simple UIButton at the AppDelegate level (as there is no ViewController).
>
> When the button is tapped:
>
> - (IBAction)pictureButtonTapped:(id)sender {
> NSLog(@"%s", __FUNCTION__);
> drawingView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
> [drawingView playRay];
> }
>
> and this results in:
>
> <CAEAGLLayer: 0x6c4a640>: calling -display has no effect.
>
> I only know enough to be dangerous, so any advice on using the GLPaint sample (or alternatives) and this issue specifically, would be most welcome...
Given that you are working from GLPaint, the solution is to upload the image as a texture and draw it via OpenGL (at least, this is the most expedient and performant solution).
For some background since it explains the warning you got:
When you set a background color with a pattern on a UIView, UIKit will may need to draw that pattern via -drawRect:, which involves calling -setNeedsDisplay (and eventually -display) on the underlying CALayer. The CAEAGLLayer however doesn't draw via its -display method, and just logs the message above.
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden