glReadPixels problem

Discussion in 'iOS Programming' started by mlady, Oct 2, 2008.

  1. mlady macrumors member

    Sep 18, 2008

    I want to use something like this:
    	GLvoid* pixelColor[4];
    	glReadPixels(x, y, 1, 1, GL_RGBA, GL_FLOAT, &pixelColor);
    	NSLog(@"%f %f %f",pixelColor[0],pixelColor[1],pixelColor[2]);
    And this is inside my render function.

    No matter if I clear the background or whatever is on background it's giving me same (disordered) values.

    I wanted to use glReadBuffer(), but it seems Xcode does not know this method. How many buffers are in iPhone?

    basically I want to use this in my 2d racing game to determine, if still inside the track.

    Anyone can help?
  2. mlady thread starter macrumors member

    Sep 18, 2008
    just got it working!
    Should be:
    	Byte pixelColor[4];
    	glReadPixels(x,y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixelColor[0]);
    	NSLog(@"%d %d %d",pixelColor[0],pixelColor[1],pixelColor[2]);

Share This Page