Take the 2-minute tour ×

I want to merge 5 "sublayers" to one single texture (you know, somethin' like Flatten Image in Photoshop) in OpenGL ES 1.x iPhone. I'm new to OpenGL, and just haven't find the answer yet.

share|improve this question
add comment

2 Answers

assuming they are images to begin with can't you just draw them sequentially onto an in memory image


share|improve this answer
add comment

You don't need GL to combine textures together. Just do the math on each texel in C.

Now, if you want to use GL, you'll want to render to a texture (your final result).

This is done with OES_framebuffer_object. Now how you draw to that texture is completely up to you. You could draw 5 quads, each with a single texture, and use blending to merge them (you'll have to specify which math you want to apply though), you can use multi-texturing to do the work in less passes (and use Texture Environments to specify how to merge).

What kind of flattening operation do you want ?

share|improve this answer
Simple 5 PNG with alpha. The last 2 image could be applied with ADD/SCREEN "blendmode" (I dont know the openGL names), I need just the white component from them. Multi-texturing/Texture Environmets stuff sounds ok, I saw something like that, but with an example you could help me a lot (thanks for the answer). –  Geri Jan 28 '10 at 18:19
Do I need this? - opengl.org/wiki/Texture%5FCombiners –  Geri Jan 28 '10 at 18:23
Yah, I forgot to metion there is no any offset between the subtextures, a simple sandwich I want to achieve. –  Geri Jan 28 '10 at 18:24
openGL does not handle PNGs. You'll have to load them as textures first. OpenGL specifies multi-texturing combination modes through glTexEnv. Whether you need the texture combiner extension or not depends on how exactly you want to combine those 5 textures (just like each layer in photoshop specifies how it combines with previous layers). Since you did not say, I can't answer that specific question. I did not get your last comment. –  Bahbar Jan 29 '10 at 9:41
Hey thanks! I see a willing to answer my question in you. I have a shadow layer, a PNG with alpha loaded into a texture called layer[0]. The next layer - layer[1] - is a simple colored polygon PNG with alpha, simple alpha blend with the previous needed. The 3rd and the 4th are the lighting layers - layer[2] and layer[3], they can be both opaque grayscale PNGs with ADDed blending, or white PNGs with alpha merged with simple alpha blending. The last two layer's opacity must be variable. That's what I want to do (7 times in a timestep since i have 7 puzzle piece). –  Geri Jan 29 '10 at 10:33
show 1 more comment

Your Answer


