Pick Pixel

Hi, I am displaying .PNG image on the OpenGL window. The image itself contains some transparent pixels (alpha value is 0). Now I want to pick the RGBA value of the pixel, whcih is at the location (x, y). For this I am using glReadPixels, but every time I get the alpha value 255. How to get the correct alpha value? Is there any glEnable setting to access this?

Are you passing GL_RGBA into the ‘format’ parameter or glReadPixels? Is your pointer to the pixel data 4 bytes per pixel? Also, make sure when you’re loading your image that when you call glTexImage2D you specify GL_RGBA. These may sound kind of stupid, but i forget to do them sometimes. It might be something else though. Maybe you could post your code.

You also need a destination alpha channel, and you usually don’t get one unless you explicitly ask for it when setting the pixel format.