cocoa touch - General iOS graphics efficiency -
i'm working on simple program has 500 "particles" have x , y coordinate. move around screen , respond touches. go past 500 particles app starts running slower. using cpu sampler discovered drawing particles taking cpu time.
this drawing code:
cgcontextsetfillcolorwithcolor(context, [uicolor colorwithred:red/255 green:green/255 blue:blue/255 alpha:1].cgcolor); cgrect rectangle = cgrectmake(xpos,ypos,9,9); cgcontextaddellipseinrect(context, rectangle); cgcontextfillpath(context);
red,green,and blue floats used change color of particles based on speed, isn't problem.
this how taught use quartz , works fine drawing, code executed 500+ times , game starts slowing down. i've run program cpu sampler drawing code commented out , there hardly cpu usage despite math going on in background.
is there more efficient way draw circles in ios?
you can try 2 different approaches speed performance...
- use prerendered uiimage/cgimage instead of points (won't give ability change colors/sizes dynamically, maybe need limited range app)
- use opengl, gl_points
quartz slower opengl path based drawing research i've done on iphone. refer iphone dev forums , you'll see general consensus this.
Comments
Post a Comment