Hell o all,
I made native activity and i want to draw some text. what is the easiest way to do this? can i do this by using openGL and if yes how?
Thanks for help.
Hell o all,
I made native activity and i want to draw some text. what is the easiest way to do this? can i do this by using openGL and if yes how?
Thanks for help.
The simplest way is to create texture with text and render it over (or not) scene. You can also create your own text engine, but it is more complicated.
You're going to need to write your own text renderer in OpenGL. If you have a finite list of strings it may be easier to just pre-prepare them all in a single texture, and render them as single quads per word, or else you could have an atlas of characters and have a single quad per character. Alternatively, you could leverage a library to render to draw the text into a buffer at runtime and then render this to a quad.
If none of this makes sense, I suggest you go do some basic OpenGL tutorials. Google is your friend. A very feature rich font library is FreeType: http://freetype.sourceforge.net/index2.html.
@Override protected void onDraw(Canvas canvas) {
canvas.drawColor(0xffffffff);
Paint p = new Paint();
p.setColor(Color.BLACK);
p.setTextSize(25);
int left = 100;
int top = 200;
// draws text beginning at pixel 100,200
canvas.drawText(" some text ", left, top, p);