views:

365

answers:

2

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.

A: 

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

code

PeanutPower
A: 

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 ?

Bahbar
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
Do I need this? - http://www.opengl.org/wiki/Texture%5FCombiners
Geri
Yah, I forgot to metion there is no any offset between the subtextures, a simple sandwich I want to achieve.
Geri
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
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
Flash pre-script here: http://gotoandplay.freeblog.hu/archives/2010/01/07/compactTangram_072_-_tan_rendering_labs/ (from the 5th paragraph)
Geri