Introducing Android OpenGL ES 2.0

There seems to be no clear support on the Internet on how to display text in OpenGL ES 2.0. JVitela answers: Draw text in OpenGL ES tells you to use Canvas and Paint Text to generate a bitmap, and then use GLUtils to render a text bitmap, but the answer only shows the part directly about painting the text, and not what else bypasses it .

I also tried to leave the lessons at http://www.learnopengles.com , in this case lesson 4, on basic textures.

How is the JVitela method passed to the vertex or fragment shader? Is the section on the background that is needed, or going out of the background, lead only to the text above the rest of the GL surface? What exactly is the textures variable that he used? I think this is a texture data handler (comparing its bind () with the learnopengles attribute), but why an array? Does it share with other textures?

I have a program with a bunch of things displayed on it already with OpenGL ES 2.0, and you need some basic text (some static, some updates every 1-5 Hz) printed over it. My understanding is that raster map graphics are quite expensive.

Are there any good tutorials for doing what I need? Any advice from anyone?

+6
source share
1 answer

How is the JVitela method passed to the vertex or fragment shader?

It is transmitted like any other texture:

  • Texture Creation
  • Set filtering and packaging
  • Data loading via GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);

Is the section on the background that is needed, or going out of the background, lead only to the text above the rest of the GL surface?

This is not necessary (there will only be a background), leaving it will write black pixels (because the code erases the raster pixels to black. If you just want to draw text, you need to enable blending or use a special shader that knows the color of the text.

What is the texture variable that he used?

This is int[1] , see API documents in GL10 .

I think this is a texture data handler (comparing its bind () with the learnopengles attribute), but why an array? Does it share with other textures?

Thus, using glGenTextures you can create more than one texture control.

+2
source

Source: https://habr.com/ru/post/915341/


All Articles