Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-27-2009, 08:42 PM   #1 (permalink)
ob1
Registered Member
 
ob1's Avatar
 
Join Date: Mar 2009
Location: Switzerland
Age: 35
Posts: 97
Default 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
ob1 is offline   Reply With Quote
Old 05-28-2009, 02:12 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Menidi, Athens, Greece
Age: 25
Posts: 102
Default

Quote:
Originally Posted by ob1 View Post
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.
__________________
Visit me at Oramind Projects
Soulstorm is offline   Reply With Quote
Old 05-28-2009, 02:22 PM   #3 (permalink)
ob1
Registered Member
 
ob1's Avatar
 
Join Date: Mar 2009
Location: Switzerland
Age: 35
Posts: 97
Default

Quote:
Originally Posted by Soulstorm View Post
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
ob1 is offline   Reply With Quote
Old 05-28-2009, 02:24 PM   #4 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 234
Default

Quote:
Originally Posted by ob1 View Post
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.
warmi is offline   Reply With Quote
Old 05-28-2009, 02:26 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Menidi, Athens, Greece
Age: 25
Posts: 102
Default

Quote:
Originally Posted by ob1 View Post
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.
__________________
Visit me at Oramind Projects
Soulstorm is offline   Reply With Quote
Old 05-28-2009, 02:30 PM   #6 (permalink)
ob1
Registered Member
 
ob1's Avatar
 
Join Date: Mar 2009
Location: Switzerland
Age: 35
Posts: 97
Default

Quote:
Originally Posted by warmi View Post
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
ob1 is offline   Reply With Quote
Old 05-28-2009, 05:35 PM   #7 (permalink)
riq
Registered Member
 
Join Date: Oct 2008
Location: Buenos Aires, Argentina
Posts: 20
Default

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
riq is offline   Reply With Quote
Old 05-28-2009, 05:43 PM   #8 (permalink)
ob1
Registered Member
 
ob1's Avatar
 
Join Date: Mar 2009
Location: Switzerland
Age: 35
Posts: 97
Default

Quote:
Originally Posted by riq View Post
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
Thanks, but I prefer to wait for a stable version.
__________________
Isometric Traffic Management Game with stunning artwork:

AutoTrafego
ob1 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,768
Threads: 89,201
Posts: 380,575
Top Poster: BrianSlick (7,129)
Welcome to our newest member, lucileadair
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:01 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0