I'm trying to read the pixel at the user's cursor when they right click on a triangular gradient, but glReadPixel is only returning black. If I make it a flat color instead of a gradient, it works, so I don't know what's wrong.
I have lighting and depth_test disabled. I'm using GL_Blend for the shade model and changing it to GL_Flat doesn't fix it. I also tried both glReadBuffer(GL_Front) and glReadBuffer(GL_Back). This project is using SDL_GL but I doubt that's the problem since flat colors get picked just fine.Code:glBegin(GL_TRIANGLES); glColor3f(1.0f, 0.0f, 0.0f); glVertex2i(0, 0); glColor3f(0.0f, 1.0f, 0.0f); glVertex2i(128, 0); glColor3f(0.0f, 0.0f, 1.0f); glVertex2i(64, 128); glEnd(); glColor3f(1.0f, 1.0f, 1.0f); //This next part only happens when they right click, but I removed that stuff for now for simplicity. This happens right after the triangle is drawn, though GLubyte pixel; glReadPixels(mPos, cheight - mPos, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);