How can I read float data with glReadPixels
问题 I've been trying to read float data for a couple of days with glReadPixels . My cpp code: //expanded to whole screen quad via vertex shader glDrawArrays( GL_TRIANGLES, 0, 3 ); int size = width * height; GLfloat* pixels = new GLfloat[ size ]; glReadPixels( 0, 0, width, height, GL_RED, GL_FLOAT, pixels ); pixelVector.resize( size ); for ( int i = 0; i < size; i++ ) { pixelVector[i] = (float) pixels[i]; } and my shader code: out float data; void main() { data = 0.02; } Strangely I get 0.0196078