What does glLoadIdentity() do in OpenGL?

The identity matrix, in terms of the projection and modelview matrices, essentially resets the matrix back to its default state. As you hopefully know, glTranslate and glRotate are always relative to the matrix’s current state. So for instance, if you call glTranslate, you are translating from the matrix’s current ‘position’, not from the origin. But … Read more

Measuring text height to be drawn on Canvas ( Android )

There are different ways to measure the height depending on what you need. #1 getTextBounds If you are doing something like precisely centering a small amount of fixed text, you probably want getTextBounds. You can get the bounding rectangle like this Rect bounds = new Rect(); mTextPaint.getTextBounds(mText, 0, mText.length(), bounds); int height = bounds.height(); As … Read more

What does PorterDuff.Mode mean in android graphics.What does it do?

Here’s an excellent article with illustrations by a Google engineer: http://ssp.impulsetrain.com/porterduff.html PorterDuff is described as a way of combining images as if they were “irregular shaped pieces of cardboard” overlayed on each other, as well as a scheme for blending the overlapping parts. The default Android way of composing images is PorterDuff.Mode.SRC_OVER, which equates to … Read more