Original Post
Hi - I want to do something rather simple - for which I have a solution, but it's not efficient. I hope someone can help me. I've set up red, green, blue, and alpha buffers usling OpenGL, with 8 bits each. Every pixel is cleared to (0,0,0,0) - making them it completely transparently. I render opaque lines, which are properly antialiased to the transparent background by using setting the alpha channel on the edges of the lines to something less than 1.0 - with the center of each line being completely opaque. I want to adjust alpha value everything in the buffer by some factor - say 0.45 - before drawing fully opaque labels and icons. What I do know is totally brunt force - I turn off all blending and anti-aliasing, read out all of the pixels using glReadPixels, multiply the alpha values, write them back using glDrawPixels, and turn anti-aliasing and blending back on. This seems horribly inefficient. However, I want to restrict myself to OpenGL functions, and I'm pretty sure I can't access the buffer directly. Is there a better way to do this? I played with convolution (with a 1-element 1-d array set by the multiplication facto), with glCopyPixels back to the same location - however, that appears to adjust the Red, Green, and Blue channels in addition to the Alpha channel - which I don't want. Any hope here? He's my sample code (pixelvalue being a large buffer, anti-aliasing and blending turned off): // Read full buffer glReadPixels(0,0,width,height,GL_RGBA,GL_UNSIGNED_BYTE,pixelvalue); // Iterate through positions pixelptr = pixelvalue + 3; for (row = 0; row < height; row++) { // Set the current position to the corner. for (col = 0; col < width; col++) { if (*pixelptr) { // Multiply non-zero alpha values by a factor *pixelptr = (*pixelptr) * factor; } pixelptr += 4; } } // Draw image back to buffer glRasterPos2i(0,0); glDrawPixels(width,height,GL_RGBA,GL_UNSIGNED_BYTE,pixelvalue); This is for rendering partially transparent images to be placed on top of photographic images. Thanks in advance.