Cocos2d - apply GLImageProcessing effect to CCSprite

烂漫一生 提交于 2019-12-06 11:11:06

问题


Apple's oplengl GLImageProcessing loads an image and applies image adjustments: brightness, saturation, contrast, hue and sharpness.

How can GLImageProcessing be used on a CCSprite?

Any help would be appreciated!


Update: Cocos2d v2 has shader support. For Image Effects look up GLSL shader called Photoshop Math.



回答1:


I've applied approach from GLImageProcessing to change the hue of CCSpite and wrote a subclass of CCSprite for convenient usage. Check this out: https://github.com/alex314/CCSpriteWithHue




回答2:


Cocos2D is an Objective-C framework wrapping openGL plain C API. GLImageProcessing Sample code is an example of using openGL.

To apply similar effects to a CCSprite, AFAIK, there is not hue, brightness or such image processing effects into Cocos2D. So I would suggest to override CCSprite and code your own drawing, inspiring from GLImageProcessing.

The interesting entry points are, for CCSprite :

-(void) draw

Which is responsible of openGL drawing of you sprite.

For GLImageProcessing :

 void drawGL(int wide, int high, float val, int mode)



回答3:


There are several discussions to implement like GLImageProcessing with cocos2d. You can call any GL API in cocos2d.

  • texture modulation
  • Using a texture combiner to render CCSprite in greyscale?
  • Gaussian BLUR implemented in cocos2d!


来源:https://stackoverflow.com/questions/4664706/cocos2d-apply-glimageprocessing-effect-to-ccsprite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!