Inverting intensity

I’m currently dumping a screenshot of my rendered scene into the texture memory with this code:
glBindTexture(GL_TEXTURE_RECTANGLE_NV, rendered_texture_rectid);
if (tex_rect_width != m_nWidth | | tex_rect_height != m_nHeight)
{
tex_rect_width = m_nWidth;
tex_rect_height = m_nHeight;
if (bif)
bif = (GLubyte )realloc(bif,tex_rect_widthtex_rect_height4);
else
bif = (GLubyte )malloc(tex_rect_widthtex_rect_height
4);
glReadPixels(0, 0, tex_rect_width, tex_rect_height, GL_RGBA, GL_UNSIGNED_BYTE, bif);
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA,
tex_rect_width, tex_rect_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, bif);

		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	}
	else
		glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0, tex_rect_width, tex_rect_height);

Now I want to take all the pixels in my texture and invert the intensity. So I want all my dark pixel to become light, and the light ones to become dark.

Suggestions anyone???

Mogu

You can invert the texture later during application. Take a look at the ARB_texture_env_combine extension, or the NV_register_combiners or NV_texture_env_combine4 exteinsions.
Each one of these will allow you to invert the texture components ‘on the fly’.

Otherwise, you’ll have to invert the texture as a pre-processing step before passing it to glTexImage.

the texture env GL_BLEND with env color 1,1,1 and polygon color 0,0,0 should invert the texture too i guess… no need for extentions then.

thanks…

glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);

and after render

glBlendFunc(GL_ONE, GL_ZERO);

did the job