I want to modify Texture Objects in real time.

Is It possible to draw a MASKED bitmap in to an Already loaded texture object ?

I tried to draw a bitmap into my Loaded texture with next commands.
I am trying to solve the problem by glTexSubImage2D. This function is modifying
my loaded texture but the result is not MASKED. It modifies my texture by
drawing all the pixels but for example I dont want to draw Black areas of my
second bitmap.


// I am first binding my original texture
glBindTexture(GL_TEXTURE_2D, Texture1);

// Now I am drawing my bitmap into Texture1
// (Mypbits is a pointer to my second image pixels)
glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_BGRA, GL_UNSIGNED_BYTE,


p.s.: I have also tried Enabling ALPHA and setting Alpha Function at the
begining of code , but it doesn’t worked.
My second image is in RGBA format. And I want to use Alpha or some color mask.

Could you helpme ?

OpenGL just copies the bits you hand it when
it “images” a texture (binds the bits to a
texture ID). There is no operation on the
bits themselves, except possible stretching
with SubImage. Once you’ve uploaded the bits,
you can delete your copy of the texture
storage, if you want to. (This “feature” of
OpenGL may lead to larger memory usage than
if you could directly poke into texture
memory, but on the other hand allows the
hardware to convert the texture data when it
gets uploaded).

Thus, you have to do the masking when you put
your new bits into the texture data before
you re-upload the texture. In Direct3D, you
can have the card help you, because 3D
textures are 2D surfaces; no such luck in
general on OpenGL.

Thank you bgl. I am trying to write an Old Amiga demo with OpenGL. If this was ok than I could use the hardware acceleration. But if thats all with OpenGL than I will just say it Bye.