View Full Version : Changing Alpha Values in memory?
03-30-2001, 06:08 PM
After I have loaded my textures into memory using gluBuild2DMipmaps then deallocated my texture buffer how can I go in and changed the alpha values of my textures. I don't want to change all of the pixels just some of them.
03-31-2001, 08:38 PM
Ok, so no one has responded to my question yet. I figure my question is hard or to simple to waste people's time with. Let me know which one it is.
Your question is hard. I can't think of a simple way to do it.
I can think of two (possibly) kludgy ways:
1. Keep a local copy of your data, change only the alpha values you need to, and replace the texture with glTexSubImage2d(). This probably won't work if you're trying to auto-generate mipmaps.
2. This option is just a possibility....I have only used register combiners once so I'm not sure if they can be used in the way I'm about to propose. Enable multitexturing. Use one texture to hold your RGB values and the other to hold just the alpha. Try to combine these appropriately in the register combiners. I seem to remember that RGB and A are separate in the combiners, so you might have to make a luminance texture instead, and use it like alpha in the combiner.
Lastly, I wouldn't necessarily expect either of these methods to be much faster than just replacing the whole texture each time you need to.
04-01-2001, 10:30 AM
Thanks Zeno, but only the second would probably be the most feasible considering I'm using several textures and it would take up way to much memory.
Would it be possible to use glTexEnv*() solve my problem?
04-01-2001, 11:47 PM
I if you know the where u want to change the alpha values just draw your texture, than disable your rgb drawing in the color mask and than draw your alpha=0 values where you want to have them. Than use CopyTexSubImage to store the texture back in memory. Of cause you have to build your midmaps after that again.
[This message has been edited by DaViper (edited 04-02-2001).]
04-02-2001, 12:22 AM
I think Zeno's second suggestion should work. Use an RGB texture, and store the alpha as a separate luminance texture. Then configure the combiners like so:
// Enable the combiners for both RGB and alpha.
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE);
// RGB source is Texture0 color.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
// Alpha source is Texture1 color (should be a luminance texture).
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_COLOR);
You can then change your alpha texture with glTexSubImage2D() any time you want, without having to upload the full RGBA data.
[This message has been edited by Tom Nuydens (edited 04-02-2001).]
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.