How to set / get pixel on texture in OpenGL ES on iPhone?

I try Google for what I mentioned in the name, but for some reason could not find it. It should not be so difficult if?

What I'm looking for is a way to access OpenGL ES texture on iPhone and a way to get / set a pixel with it. What features of OpenGL ES am I looking for?

+4
source share
2 answers

I don't know about setting up a single pixel, but glReadPixels can read a block of pixels from the frame buffer ( http://www.khronos.org/opengles/sdk/docs/man/glReadPixels.xml ). Your search engine problem may be caused by the fact that texture pixels are often shortened to texels.

+4
source

Before OpenGL ES could see your texture, you had to load it into memory already, the generated texture names (glGenTextures) and bind it (glBindTexture). Your texture data is just a large array in memory.

Therefore, if you want to change one texel, you can manipulate it in memory and then bind it again. This approach is usually performed to generate a procedural texture. There are many resources available on the network, for example: http://www.blumtnwerx.com/blog/2009/06/opengl-es-texture-mapping-for-iphone-oolong-powervr/

While glReadPixels is available, there are very few situations where you will need to use it for interactive applications (the screen comes to the screen). This absolutely destroys performance. And it will not return the original textures, but instead will return a framebuffer block.

I do not know what effect you are looking for. However, if you target a device that supports pixel shaders, perhaps a custom pixel shader may do what you need.

Of course, I work under the assumption that you did not mean a pixel, as in screen coordinates.

+6
source

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


All Articles