glReadPixels() not working with textures

Hello everyone,

I've been struggling for days with certain piece of code in C++ and OpenGL that were supposed to detect object selection. The code worked perfectly till I introduced textures and now I see no response.