views:

2239

answers:

6

Hey,

I want to do the following:

Tap the screen and draw 3 cricles around the the tapped point. Is it better to do this with Core Animation or OpenGL ES?

Where do I start?

Regards

+1  A: 

This could best be done with Quartz 2D (also known as Core Graphics)

See Apple's Quartz programming guide

zPesk
+2  A: 

As mentioned, the Core Graphics framework is probably what you want. A good way to go about it would be to subclass UIView, then override the two methods drawRect: and touchesEnded:withEvent:.

When a touch event ends on the UIView, you can get the point of the last touch from the event passed to touchesEnded:withEvent:, and store it somehow in the instance of your subclassed UIView.

Then, in your implementation of drawRect:, you'll get the stored last touch point, and draw three circles around it using three calls to CGContextAddEllipseInRect, as discussed here: Quartz 2D Programming Guide: Paths (registration as Apple Developer required).

Tim
Wow, super methods and docu to start with! Thanks.
Stefan
+2  A: 

Core Graphics is definitely simpler, and better for 2D. OpenGL ES is made for 3D, but can also be used for 2D. Both can be used, so if you already know one, use that. It shouldn't really matter that much.

I already knew OpenGL, so I tend to use OpenGL ES even for 2D, but if you haven't used either before, go with Core Graphics.

Zifre
+4  A: 

My experience is this: the more complex my app became, the more I realized I should have had used OpenGL ES for what I was trying to do.

So, for your situation, If what you described is all there is, sure, Core Graphics does the trick. But, I'm guessing there's more to it than three circles.

With no experience with OpenGL at all, the learning curve for ES was about 20 days.

Thus, my advice is: OpenGL ES for pretty much every frame-to-frame graphics based app.

Kriem
Cool, 20 days would be ok. Did you use only Apple docu, or is there some book you would recommend?
Stefan
I recommend the Red Book (http://www.glprogramming.com/red/). Next to that, check out the OpenGL pages from Khronos (http://www.khronos.org/opengles/). And of course the thrustworthy Googles.
Kriem
+1  A: 

The advantage of learning OpenGL ES is that the time you put in to learn it will serve you well in the future on iPhone Apps and on other devices.

In OpenGL ES, there's no built-in way to draw a circle, so use sine and cosine to build your circles out of line segments.

Nosredna
Ok, OpenGL ES looks promising. I'll try it the next time, I get a couple of hours free.
Stefan
A: 

Asalam o alkum,

can any buddy give me the poject of opengl in which a ball is rotating around the window.. I am new in using opengl es in iphone..

if any buddy have this tuturial then send it to me...

plz