5 Replies - 888 Views - Last Post: 02 October 2012 - 02:45 AM Rate Topic: -----

#1 Galaxy_Stranger  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 100
  • Joined: 07-February 06

SDL and Color Keying

Posted 26 September 2012 - 09:04 AM

If SDL displays .png's with alpha transparency, do you need to bother with color keying? Or is color keying more efficient than displaying a .png with transparency?
Is This A Good Question/Topic? 0
  • +

Replies To: SDL and Color Keying

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: SDL and Color Keying

Posted 26 September 2012 - 09:48 AM

Well, this is an art question really. Secondly you need to know the specifics of how your graphics engine supports .png files in terms of the type and magnitude of the effects you wish to create.
Was This Post Helpful? 0
  • +
  • -

#3 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 999
  • View blog
  • Posts: 4,175
  • Joined: 14-February 08

Re: SDL and Color Keying

Posted 26 September 2012 - 01:34 PM

I guess there are a few things to consider here, one is that .png transparency will probably look nicer but the file sizes will be slightly bigger due to the alpha channel. Colour-keying is also a little faster due to it just completely skipping a certain colour and not even sending it to the back buffer. With that said though, the difference will be extremely negligible when developing on a modern PC unless your game is ridiculously graphics intensive with loads of different game objects flying around the place.

You don't go into any detail about what type of game you're developing or anything. What kind of experience do you have? have you developed any games before?

If you're really serious about getting the best performance then you will have to run these tests yourself. You never know, it might be a fun learning experience.
Was This Post Helpful? 3
  • +
  • -

#4 Galaxy_Stranger  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 100
  • Joined: 07-February 06

Re: SDL and Color Keying

Posted 27 September 2012 - 08:19 AM

No, it's not an art question. It's a programming question.

Ok - so the answer is, "Color Keying is faster".

I'm just now getting into SDL. I want to be able to display as many sprites as I would ever want on screen at any given time. I just noticed that displaying transparent .png images used a different function and figured there had to be a performance difference.

I'm not working on any specific game right now, just learning to manipulate images and surfaces and pocketing things away in my own functions and classes. I thought it would be fun to start with something like a Galaxian clone and learn how to make neat looking visual effects that classic arcade techniques used.

So, this is good information. Normally, I would want to use color keying, but I can always use .png alpha transparency for cool effects like glass or other transparent effects. Meh, I dunno. If I'm replicating the same image over and over again, like lasers or whatever, it may not matter I suppose.
Was This Post Helpful? -1
  • +
  • -

#5 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 999
  • View blog
  • Posts: 4,175
  • Joined: 14-February 08

Re: SDL and Color Keying

Posted 28 September 2012 - 01:25 AM

View PostGalaxy_Stranger, on 27 September 2012 - 04:19 PM, said:

Ok - so the answer is, "Color Keying is faster".


I didn't exactly put it as bluntly as that, there are other things to consider.
Was This Post Helpful? 0
  • +
  • -

#6 yothsoggoth  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 19
  • View blog
  • Posts: 49
  • Joined: 19-June 12

Re: SDL and Color Keying

Posted 02 October 2012 - 02:45 AM

Colour keying would generally be slightly faster, being that all it has to do is check if the pixel is (X) colour, and if so, don't bother copying it onto the viewport.

Alpha blending is a little bit slower, as it involves actually calculating the end-colour, but allows for "partial transparency" which is useful for effects etc. (like you mentioned glass and such).

Alpha cutout, however, is almost identical to colour keying, except that you don't limit yourself to not using a particular colour (which can be useful when using very small colour pallets with an ARGB format.)


Usually, though, it's common practice to just use alpha blending, unless you have a particular reason not to.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1