Friday, February 27, 2009

tac: 2D??

I was talking to a friend of mine about this project, and I mentioned the performance issues. His basic reply was, "I'm no programmer, but shouldn't the iPhone be able to handle a 15 year old 2D game with no problems?" I was almost going to start explaining why OpenGL was limited and why I'm using it and etc. etc. etc...but those are just excuses really. He's right. The iPhone should be able to handle something like this, so I must be doing something very wrong.

So I'm going to investigate 2D drawing on the iPhone again. Some experiments I just did with CoreGraphics and Quartz 2D (it's a little confusing what the distinction is really) weren't too promising, but there seem to be more options, such as CA/CGLayer. I'll look into those tomorrow. Surely I can just draw to the frame-buffer directly somehow! If I could do that, then performance shouldn't be an issue at all. Like, how does iBeer achieve its fast 2D animation, not to mention some fluid dynamics driving it? I should be able to do that - and I don't know how right now.

Why was I so tied to the OGL solution? I think I enjoyed the challenge of making something do something  it wasn't meant to do. The possibility of perfect, elegant zooming was also neat. But a single feature isn't worth all the work it would take to get it running fast. Lesson learned.

Nonetheless, I'll probably keep the slow OGL solution in the main branch and continue to add game-play features to that. I have one friend who wants to help design stuff, so the quicker I can get that pipeline together the better. I'll experiment with 2D drawing in a separate prototype.

UPDATE: There's an OpenGL extension supported by iPhone: GL_OES_draw_texture. It's meant for things like drawing font glyphs - just what I need! I knew about point sprites, but this is better than point sprites (you define a sub-region of the texture to draw) since it avoids texture switching. Maybe this is what I should use, since from what I gather, Quartz and Core Graphics are all built on OpenGL anyway. So this may be the lowest level possible.

No comments: