Showing posts with label opengl. Show all posts
Showing posts with label opengl. Show all posts

Thursday, October 1, 2009

iPhone drawing

I'm not sure whether I just got bad at googling things but apparently, when I first researched bits and pieces about rendering stuff on iPhone, I did not find the way of rendering I was so desperately looking for:

Instead of diving into OpenGL ES right from the start, I was looking for a rendering mechanism similar to what J2ME offers: subclassing Canvas, overriding the paint() method and adding all of your drawing calls to that method.

For iPhone I expected to find a similar way of rendering and, sure enough, came across Quartz as iPhone's 2D rendering library of choice. What I did not find, however, was the part where I subclass and add the statements to a particular function in my code. Now, reading the first few lines of Dave Mark's and Jeff LaMarche's chapter on Quartz and OpenGL ES (from their book Beginning iPhone 3 Development), I finally found the missing piece:

  1. Subclass UIView
  2. Override drawRect:
  3. Add Quartz-calls

If you're wondering where you can get a handle to the Graphics context (that you'll get automatically as an argument to the method in J2ME), you use UIGraphicsGetCurrentContext() to get a handle to it.

Maybe this post looks dead-simple, I just hope some people will find it in their quest to discover the information I was looking for myself :-)

Sunday, July 19, 2009

OpenGL origin

Looks like OpenGL is just doing what all the other 3D frameworks are doing, too. At least this article implies that 3D frameworks generally adopt the maths view of having the origin in the lower left. Good to know!