Alex L
Alex L

Reputation: 8449

Cocos2d - apply GLImageProcessing effect to CCSprite

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.


Upvotes: 2

Views: 2751

Answers (3)

nalexn
nalexn

Reputation: 10811

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

Upvotes: 0

Kazuki Sakamoto
Kazuki Sakamoto

Reputation: 14009

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

Upvotes: 1

Vincent Guerci
Vincent Guerci

Reputation: 14429

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)

Upvotes: 4

Related Questions