简体   繁体   English

Cocos2d-将GLImageProcessing效果应用于CCSprite

[英]Cocos2d - apply GLImageProcessing effect to CCSprite

Apple's oplengl GLImageProcessing loads an image and applies image adjustments: brightness, saturation, contrast, hue and sharpness. 苹果公司的oplengl GLImageProcessing加载图像并应用图像调整:亮度,饱和度,对比度,色调和清晰度。

How can GLImageProcessing be used on a CCSprite? 如何在CCSprite上使用GLImageProcessing?

Any help would be appreciated! 任何帮助,将不胜感激!


Update: Cocos2d v2 has shader support. 更新:Cocos2d v2具有着色器支持。 For Image Effects look up GLSL shader called Photoshop Math. 对于图像效果,请查找称为Photoshop Math的GLSL着色器。


Cocos2D is an Objective-C framework wrapping openGL plain C API. Cocos2D是一个包含openGL普通C API的Objective-C框架。 GLImageProcessing Sample code is an example of using openGL. GLImageProcessing示例代码是使用openGL的示例。

To apply similar effects to a CCSprite , AFAIK, there is not hue, brightness or such image processing effects into Cocos2D. 要将类似的效果应用于CCSprite ,AFAIK,Cocos2D中没有色相,亮度或此类图像处理效果。 So I would suggest to override CCSprite and code your own drawing, inspiring from GLImageProcessing. 因此,我建议改写CCSprite并编写自己的图形,以启发GLImageProcessing。

The interesting entry points are, for CCSprite : 对于CCSprite ,有趣的入口点是:

-(void) draw

Which is responsible of openGL drawing of you sprite. 这负责您的sprite的openGL绘制。

For GLImageProcessing : 对于GLImageProcessing

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

There are several discussions to implement like GLImageProcessing with cocos2d. 有一些讨论要使用cocos2d来实现,例如GLImageProcessing。 You can call any GL API in cocos2d. 您可以在cocos2d中调用任何GL API。

I've applied approach from GLImageProcessing to change the hue of CCSpite and wrote a subclass of CCSprite for convenient usage. 我应用了GLImageProcessing的方法来更改CCSpite的色调,并编写了CCSprite的子类以方便使用。 Check this out: https://github.com/alex314/CCSpriteWithHue 看看这个: https : //github.com/alex314/CCSpriteWithHue

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM