Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to Google for what I've mentioned in the title, but somehow I couldn't find it. This should not be that hard, should it?

What I am looking for is a way to gain access to an OpenGL ES texture on iPhone, and a way to get/set pixel with it. What are the OpenGL ES functions I am looking for?

like image 895
Karl Avatar asked Dec 29 '22 01:12

Karl


1 Answers

Before OpenGL ES is able to see your texture, you should have loaded it in memory already, generated texture names(glGenTextures), and bound it(glBindTexture). Your texture data is just a big array in memory.

Therefore, should you with to change a single texel, you can manipulate it in-memory and then bind it again. This approach is usually done for procedural texture generation. There are many available resources on the net about it, for instance: 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'd need to use it for interactive applications(screen capture comes to mind). It absolutely destroys performance. And still won't give you back the original textures, but instead will return a block of the framebuffer.

I have no idea what kind of effect you are looking for. However, if you are targeting a device that supports pixel shaders, perhaps a custom pixel shader can do what you want.

Of course, I am working under the assumption you didn't mean pixel as in screen coordinates.

like image 129
Stephen Eilert Avatar answered Jan 03 '23 15:01

Stephen Eilert