 |
 |
|
 |
05-27-2009, 08:42 PM
|
#1 (permalink)
|
|
Registered Member
Join Date: Mar 2009
Location: Switzerland
Age: 33
Posts: 97
|
Cocos2D OpenGL Blend
I am totally new at OpenGL (and Cocos2D for that matter) and I have a little problem with my game.
One of the sprite that the gfx guy gave me needs the equivalent of the Photoshop "screen" blending. I read on forums that you can have the equivalent in OpenGl by changing the parameters of glBlendFunc.
Now, if I change the blend values in ccMacros, this sprite is perfect, but of course others are totally off. So my question is, how do I set the blendFunc for just one sprite ?
Thanks.
__________________
Isometric Traffic Management Game with stunning artwork:
AutoTrafego
|
|
|
05-28-2009, 02:12 PM
|
#2 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Location: Menidi, Athens, Greece
Age: 23
Posts: 73
|
Quote:
Originally Posted by ob1
I am totally new at OpenGL (and Cocos2D for that matter) and I have a little problem with my game.
One of the sprite that the gfx guy gave me needs the equivalent of the Photoshop "screen" blending. I read on forums that you can have the equivalent in OpenGl by changing the parameters of glBlendFunc.
Now, if I change the blend values in ccMacros, this sprite is perfect, but of course others are totally off. So my question is, how do I set the blendFunc for just one sprite ?
Thanks.
|
I don't fully understand what you are saying, but that may be because by changing those values, you are changing the blend values for every sprite that is created in Cocos2D. Try to find a way to change the blend values when your sprite is drawn and restore them after it is displayed.
Or, you can use custom OpenGL code to draw your texture, by overriding the -draw method of the CocosNode class. Cocos2D will render everything that doesn't belong to the -draw function as it should.
|
|
|
05-28-2009, 02:22 PM
|
#3 (permalink)
|
|
Registered Member
Join Date: Mar 2009
Location: Switzerland
Age: 33
Posts: 97
|
Quote:
Originally Posted by Soulstorm
Try to find a way to change the blend values when your sprite is drawn and restore them after it is displayed.
.
|
Well, I was asking if there was a "sanctionned" way to do it in Cocos2D. But as you said, I ended up hacking up the draw method. Not pretty.
__________________
Isometric Traffic Management Game with stunning artwork:
AutoTrafego
|
|
|
05-28-2009, 02:24 PM
|
#4 (permalink)
|
|
Registered Member
Join Date: Nov 2008
Posts: 127
|
Quote:
Originally Posted by ob1
I am totally new at OpenGL (and Cocos2D for that matter) and I have a little problem with my game.
One of the sprite that the gfx guy gave me needs the equivalent of the Photoshop "screen" blending. I read on forums that you can have the equivalent in OpenGl by changing the parameters of glBlendFunc.
Now, if I change the blend values in ccMacros, this sprite is perfect, but of course others are totally off. So my question is, how do I set the blendFunc for just one sprite ?
Thanks.
|
You need to group your sprites based on their blending properties.
This is generally handled by using a separate sprite atlas for different blending modes.
|
|
|
05-28-2009, 02:26 PM
|
#5 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Location: Menidi, Athens, Greece
Age: 23
Posts: 73
|
Quote:
Originally Posted by ob1
Well, I was asking if there was a "sanctionned" way to do it in Cocos2D. But as you said, I ended up hacking up the draw method. Not pretty.
|
I know, Cocos2D doesn't solve all problems. I mainly try to use it as a wrapper of my own OpenGL ES code. I mainly override the -draw functions. I use Cocos2D for background drawing or doing simple things like moving an actor.
|
|
|
05-28-2009, 02:30 PM
|
#6 (permalink)
|
|
Registered Member
Join Date: Mar 2009
Location: Switzerland
Age: 33
Posts: 97
|
Quote:
Originally Posted by warmi
You need to group your sprites based on their blending properties.
This is generally handled by using a separate sprite atlas for different blending modes.
|
You are speaking Chinese to me here.
__________________
Isometric Traffic Management Game with stunning artwork:
AutoTrafego
|
|
|
05-28-2009, 05:35 PM
|
#7 (permalink)
|
|
Registered Member
Join Date: Oct 2008
Location: Buenos Aires, Argentina
Posts: 18
|
cocos2d v0.8 supports setting the a blend function for a particular sprite.
Please see the Texture2dTest.m to see how to use it.
To use it, you need the latest revision from the SVN:
Source Checkout - cocos2d-iphone - Google Code
|
|
|
05-28-2009, 05:43 PM
|
#8 (permalink)
|
|
Registered Member
Join Date: Mar 2009
Location: Switzerland
Age: 33
Posts: 97
|
Quote:
Originally Posted by riq
|
Thanks, but I prefer to wait for a stable version.
__________________
Isometric Traffic Management Game with stunning artwork:
AutoTrafego
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 492 |
| 49 members and 443 guests |
| Abdel, ackpth, activ8, AjohnB, Alchemda, BostonMerlin, BrianSlick, Centurion Games, ChrisMayer, CoolApps, Corey, dbarrett, dda, designomatt, dmf1978, eatenbyrats, Gamer211, gonk, greenuns, Gudus, imsatasia, IphoneSdk, jharrah, Kalimba, Knertified, LemonMeringue, Link, markbuchanan, MiniRobinho, montage, msudan, naomipunkclan, NeilB, nibby, Noise, P2k, pashik, ryguy2503, simpsonaty, Snappy, StefanL, svguerin3, tcarte04, the1nz4ne, treazer, TunaNugget, Tuszy, victorsk, ZunePod |
| Most users ever online was 779, 05-11-2009 at 10:55 AM. |
» Stats |
Members: 21,510
Threads: 35,793
Posts: 156,804
Top Poster: smasher (2,449)
|
| Welcome to our newest member, dmf1978 |
|