有时候我们需要判断自己所触摸的区域是否是透明的,这时就需要调用glReadPixels函数来进行rgb色值的提取了
白白原创,手游专栏http://blog.csdn.net/u010229677
Size size = Director::getInstance()->getVisibleSize(); CCRenderTexture* render = RenderTexture::create(size.width,size.height); render->beginWithClear(0,0); node->visit(); //白白原创 GLubyte pColor[4]; Point location = this ->convertTouchToNodeSpace(touch); glReadPixels(location.x,location.y,1,GL_RGBA,GL_UNSIGNED_BYTE,&pColor[0]); render->end(); log("r %d g %d b %d a %d",pColor[0],pColor[1],pColor[2],pColor[3]); if (!pColor[0]&&!pColor[1]&&!pColor[2]) { log("tou ming"); } else { log("bu tou ming"); }