texture data manipulation

Hi out there,

Like many others i need your help.
I googled for a couple of hours to solve my texture manipulation problem but i couldn’t find anything helpful, so i hope someone here can help me out.

I want to read out the data of a loaded texture (RGB8). In particular i want to read AND write data from and to it - i thought it maybe could be done in one step - but what i’m trying doesn’t seem to work. I must admit that i’m not a senior C/C++ programmer so maybe there lies the problem.

I have a terrain mesh which is textured using 2 “ordinary” textures and an “alpha map” which allows me to blend the 2 textures. What i want to do is: click on the terrain and change the alpha texture (value) at that pixel so that the second texture is more and more blended over the first.

Hello TheAtlasProject,

did you come across this thread?

http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=256768

Maybe that might be useful. :slight_smile:

Thanks matchStickMan,

that’s not excatly what i’m looking for but maybe it points me in the right direction :slight_smile: thx

Create the alpha texture with glTexImage2D, then update its content with glTexSubImage2D specifying the modified alpha texture data.

You can also rely on PBO for better performances concerning the texture data upload.

Thanks for your hint dletozeun. I’ll give it a try.

Is this the right way i’m using it?:

unsigned char* pdata = 0;

BindTexture(…);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB8, GL_UNSIGNED_BYTE, (GLvoid*)pdata);

BindTexture(…);
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 16, 16, GL_RGB8, GL_UNSIGNED_BYTE, (GLvoid*)pdata);

You need to allocate enough memory in the pData buffer.