Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-03-2010, 02:33 PM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 5
Default Bug in Apple’s ‘GLPaint’ sample - dot always drawn before line!

I was just messing around with Apple's GLPaint sample app to learn more about OpenGL, and I noticed that whenever you draw a line, it's always preceded by a dot. Basically, it looks like:

.________

Does anyone know why this happens? I'm guessing it's some weirdness with touchesBegan/Moved/Ended, but I can't verify. It's been driving me crazy all morning!
hypertext is offline   Reply With Quote
Old 05-03-2010, 02:54 PM   #2 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

I havent look at the code, but just on top of my head,
I think that is because the detection of

touchesbegan (doing the dot)

and touchesmoved. (doing the line)

just remove the drawing code for touchesbegan. but u wont be able to create dots..
rocotilos is offline   Reply With Quote
Old 05-03-2010, 03:23 PM   #3 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 5
Default

Quote:
Originally Posted by rocotilos View Post
I havent look at the code, but just on top of my head,
I think that is because the detection of

touchesbegan (doing the dot)

and touchesmoved. (doing the line)

just remove the drawing code for touchesbegan. but u wont be able to create dots..
That's the weird part... touchesBegan just sets the start point, doesn't do any drawing. Wish I could post the code, but since it's an Apple sample I don't think they'd like that
hypertext is offline   Reply With Quote
Old 05-03-2010, 06:56 PM   #4 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 916
Default

I was curious about this so I downloaded the sample code, I am not running into this dot issue, everything works just fine, I tried on both the device and simulator, no problem on either one?
lukeca is offline   Reply With Quote
Old 07-29-2010, 03:26 PM   #5 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 2
Default Problem solved

I ran into the same problem, particularly when decreasing the size of the brush.

The solution is simple. Remove the conditional part of this code...

Code:
if (firstTouch) {
	firstTouch = NO;
	previousLocation = [touch previousLocationInView:self];
	previousLocation.y = bounds.size.height - previousLocation.y;
} else {
	location = [touch locationInView:self];
        location.y = bounds.size.height - location.y;
	previousLocation = [touch previousLocationInView:self];
	previousLocation.y = bounds.size.height - previousLocation.y;
}
to become this...

Code:
location = [touch locationInView:self];
location.y = bounds.size.height - location.y;
previousLocation = [touch previousLocationInView:self];
previousLocation.y = bounds.size.height - previousLocation.y;
The firstTouch part apparently doesn't do anything except draw the first dot, usually in a different place from the rest of the line.
onemoreanimal is offline   Reply With Quote
Reply

Bookmarks

Tags
glpaint, opengl, sample, touchesmoved

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 270
18 members and 252 guests
14DEV, ADY, ArtieFufkin10, Dani77, HemiMG, IphoneSdk, jakerocheleau, JasonR, jimbo, MACralik, NSeven, prchn4christ, Rudy, silverwiz, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:56 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0