开发者

How to modify a bound texture in OpenGL ES 1.1

My platform is iPhone - OpenGL ES 1.1

开发者_C百科

I'm looking for the tutorial about modifying or drawing to a texture. For example:

I have a background texture: (Just blank blue-white gradiant image)

and a object texture:

How to modify a bound texture in OpenGL ES 1.1

I need to draw the object to background many times so to optimize the performance I want to draw it to the background texture like this:

How to modify a bound texture in OpenGL ES 1.1

does anyone know the fastest way to do this ? Thanks a lot !


Do you want to draw it into the background texture, and then keep that, or overlay it, or what? I'm not entirely sure the question.

To draw onto the background and then reuse that, you'll want to create another texture, or a pbuffer/fbo, and bind that. Draw a full-screen quad with your background image, then draw additional quads with the overlays as needed. The bound texture should then have the results, composited as necessary, and can be used as a texture or copied into a file. This is typically known as render-to-texture, and is commonly used to combine images or other dynamic image effects.

To optimize the performance here, you'll want to reuse the texture containing the final results. This will reduce the render cost from whatever it may have been (1 background + 4 faces) to a single background draw.

Edit: This article seems to have a rather good breakdown of OpenGL ES RTT. Some good information in this one as well, though not ES-specific.

To overlay the decals, you simply need to draw them over the background. This is the same drawing method as in RTT, but without binding a texture as the render target. This will not persist, it exists only in the backbuffer, but will give the same effect.

To optimize this method, you'll want to batch drawing the decals as much as possible. Assuming they all have the same properties and source texture, this is pretty easy. Bind all the textures and set properties as needed, fill a chunk of memory with the corners, and just draw a lot of quads. You can also draw them individually, in immediate mode, but this is somewhat more expensive.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜