How to get image pixel at a specified location?

Ok i Solved the problem by using CustomCommand:

auto pixelPos = CC_POINT_POINTS_TO_PIXELS(center);

cmd = new CustomCommand();

cmd->func = [=]() {
	glPixelStorei(GL_PACK_ALIGNMENT, 1);
	glReadPixels(pixelPos.x, pixelPos.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
};

rt->beginWithClear(0, 0, 0, 0);
spr1->visit();
_director->getRenderer()->addCommand(cmd);
rt->end();
4 Likes