Game Development in SDL

Beginner Graphics Questions

Page 1 of 1

9 Replies - 2473 Views - Last Post: 21 June 2009 - 08:23 AM Rate Topic: -----

#1 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5392
  • View blog
  • Posts: 27,387
  • Joined: 10-May 07

Game Development in SDL

Posted 17 June 2009 - 09:11 PM

So I have two beginner graphics questions, working with SDL (on Linux, but that shouldn't matter).

1.) Is it possible to make Transparencies on BMP files?
2.) Since BMP & Wav libraries are built in, where is the ideal place to get libraries for alternative formats, such as jpg/gif/png & mp3?

Thanks...
Is This A Good Question/Topic? 0
  • +

Replies To: Game Development in SDL

#2 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Game Development in SDL

Posted 17 June 2009 - 10:37 PM

Quote

Is it possible to make Transparencies on BMP files?
Yes and no. BMPs do support transparency, but the program you use to make the BMP may not. Investigate for whatever program you use to create the BMP format images. I'm not sure about SDL support directly (i.e., how much additional code you have to write). A Google search suggests it's not bad, and since the API keeps improving with new versions...

Quote

where is the ideal place to get libraries for alternative formats, such as jpg/gif/png & mp3?
There isn't one. You'll have to investigate each format separately and see what libraries exist for support.
Was This Post Helpful? 0
  • +
  • -

#3 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1385
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: Game Development in SDL

Posted 18 June 2009 - 12:58 AM

View PostOler1s, on 18 Jun, 2009 - 04:37 AM, said:

Quote

where is the ideal place to get libraries for alternative formats, such as jpg/gif/png & mp3?
There isn't one. You'll have to investigate each format separately and see what libraries exist for support.
Wrong. You'll find most of them on the SDL website. For image loading, try SDL_Image.

As for transparency, look at SDL_SetColorKey()
Was This Post Helpful? 1
  • +
  • -

#4 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1010
  • View blog
  • Posts: 4,214
  • Joined: 14-February 08

Re: Game Development in SDL

Posted 18 June 2009 - 02:38 AM

I would recommend using SDL image for your image loading definitely and also I would use .png files for your sprites, these files can use an alpha channel for transparency which looks a hell of a lot better than colour keying.

.png files can also be compacted very small, there are .png compressors all over the net if you just google them.

If you use a .png file with SDL_Image it will automatically use the alpha channel for transparency which is great.
Was This Post Helpful? 0
  • +
  • -

#5 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1385
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: Game Development in SDL

Posted 18 June 2009 - 03:29 AM

View Poststayscrisp, on 18 Jun, 2009 - 08:38 AM, said:

If you use a .png file with SDL_Image it will automatically use the alpha channel for transparency which is great.
That doesn't seem to happen for me, it just renders it on a black background. >.<
I'll give it another go when I get time (hopefully tomorrow on my NEW LAPTOP) *excited*

This post has been edited by gabehabe: 18 June 2009 - 03:29 AM

Was This Post Helpful? 0
  • +
  • -

#6 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1010
  • View blog
  • Posts: 4,214
  • Joined: 14-February 08

Re: Game Development in SDL

Posted 18 June 2009 - 03:44 AM

Thats weird, maybe you aren't creating the alpha channel correctly, this has an alpha channel try it out.

Attached Image
Was This Post Helpful? 0
  • +
  • -

#7 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1010
  • View blog
  • Posts: 4,214
  • Joined: 14-February 08

Re: Game Development in SDL

Posted 18 June 2009 - 08:00 AM

Is it worth writing up a tutorial on creating alpha channels and displaying transparency in SDL?
Was This Post Helpful? 0
  • +
  • -

#8 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Game Development in SDL

Posted 18 June 2009 - 09:19 AM

MP3 loading is tricky because of patents. Better to go with something like Ogg Vorbis (libvorbisfile) if you want compression, or just use WAV.

You should probably use DevIL or SDL_Image to load images, but writing your own loaders isn't hard. See my TGA, JPEG, and PNG loaders from Dagger3D for example.

Last time I checked, BMP doesn't support transparency but you can pick a color to be treated as transparent. This method won't let you have semi-transparent pixels though, which is probably going to make your sprites/textures a little jaggier along the edges. I recommend using a format that supports RGBA (like TGA) instead.

What are you using to make images? Are you sure you are actually making the background transparent?
Was This Post Helpful? 0
  • +
  • -

#9 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1385
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: Game Development in SDL

Posted 18 June 2009 - 10:36 AM

You were right! Just tested it with your png and one that I just created. Fuck knows what was up with it before. >.<
Was This Post Helpful? 0
  • +
  • -

#10 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1010
  • View blog
  • Posts: 4,214
  • Joined: 14-February 08

Re: Game Development in SDL

Posted 21 June 2009 - 08:23 AM

Created a tutorial for creating PNG files with transparency. Its in the photoshop tutorial section.

http://www.dreaminco...showforum44.htm
:D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1