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.
Here’s the code:
void MouseFunc(int x, int y)
glutSetWindow(id) //I have several subwindows glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glDisable(GL_TEXTURE_2D); glDrawBuffer(GL_BACK); //code that draws a single colored figure unsigned char pixel; GLint viewport; glGetIntergv(GL_VIEWPORT, viewport); glReadBuffer(GL_BACK); glReadPixels(x, viewport - y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel); //code for comparison between read and stored colors glEnable(GL_LIGHTING); gLEnable(GL_COLOR_MATERIAL); glEnable(GL_TEXtURE_2D);