0
\$\begingroup\$

I have been using the glDrawTexf extension to draw labels in my Android app using OpenGL ES 1.1.

But I have now moved to OpenGL ES 2.0 and can't figure out what is the equivalent of this call? I could create triangles to hold the texture and draw it like a regular texture. But the glDrawTexf was very convenient:

  • It didn't require any triangles/quads to be setup.
  • You could give it screen co-ordinates.
  • You could specify cropping parameters to pick smaller areas from a large texture.
\$\endgroup\$

1 Answer 1

5
\$\begingroup\$

However "convenient" it may have been, it was only ever that: a convenience. All it was ever doing was just drawing textured triangles.

OpenGL ES 2.0 doesn't have very many convenience functions. It's a bare-bones, relatively low-level rendering API. So that means you're going to have to build those convenience features yourself.

You can easily set up an orthographic projection matrix that provides a 1:1 correspondence between vertex coordinates a pixels. This allows you to work directly in pixel coordinates. The texture coordinates of your vertex data "crop" which texels of the texture are drawn.

\$\endgroup\$
1
  • \$\begingroup\$ I feared that would be the answer. I had already started coding a shader while I was waiting for someone to respond :) \$\endgroup\$
    – HRJ
    Oct 12, 2011 at 19:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .