Slashdot Mirror


Graphics for Beginners (Using SDL)

Jari Komppa writes "Looking at how learning programming these days is much harder than when I was starting, I decided to write a tutorial on how to make graphics at pixel level. The aim for the tutorial is to show that programming can actually be fun."

15 of 51 comments (clear)

  1. SDL Rocks!! by trompete · · Score: 4, Interesting

    I used it for a game I wrote. It makes Threading, CDRoms, Joysticks, Keyboards, and graphics sooooo easy.

    If you're using SDL for games, you should also look into:
    NET2 - Fast Networking for SDLNet for multiplayer game programming. It basically has a separate thread that polls for Network traffic on your sockets and pushes events to your event queue. He even extends SDL events to be thread safe and FASTER.
    SDL rocks.

  2. Also... by eviltypeguy · · Score: 4, Informative

    Another great tutorial is the book called:

    http://www.nostarch.com/frameset.php?startat=plg

    One of the few programming books I've purchased that I didn't feel like I got ripped off in purchasing.

    Written by an Ex-Loki associated person John R. Hall

    1. Re:Also... by Krunch · · Score: 4, Informative

      Here it is. However it seems down for now but you can still grab it from archive.org.

      --
      No GNU has been Hurd during the making of this comment.
    2. Re:Also... by duckie13 · · Score: 3, Informative

      If you're looking for the actual text, I found it here:

      http://www.tux.org/pub/tux/plg/

      --
      "My days are less enjoyable because of people." ~ Johnny the Homicidal Maniac
  3. Back in my day... by Phatboy · · Score: 4, Funny
    We had to walk 500 miles uphill to get water than another 500 uphill back. We had to grind the flour with our hands, while it snowed. And it was proper snow then - so thick that you could hide cars in it most days, and that was in Summer. Now take programming, we had to write 500 lines of code to add two numbers together. And we liked it.

    And now you tell me programming was easier in my day? You, with your fancy SDL and OpenGL? I'd like to see you code once you've ploughed 300 fields in one day with your bare hands.

  4. There are a couple of Ruby/SDL games... by tcopeland · · Score: 3, Informative

    ...on RubyForge, including Magic Maze (which was inspired by Gauntlet) and Tadpoles.

    1. Re:There are a couple of Ruby/SDL games... by denthijs · · Score: 2
      WOW, there are????
      thats, like, SOO great

      I never would've thought anyone would actually use SDL...
      let alone from RUBY.....

      Don't tell me the perlmongers, pythons and/or javastics did it as well?
      WOW, they did????
      thats, like, SOO great

      I never wou.....
      Ad infinitum, ad nauseam

      </SARCASM>

  5. SDL == DirectX without the MS millstone by leonbrooks · · Score: 4, Informative
    OpenGL == Direct3D, SDL fills in the rest.

    It's an approximation, and there's some things which each set of software does markedly better than the other, but SDL+OpenGL is considerably easier to extend (e.g. the NET2 library mentioned above) so I'd expect to see it get better faster (cheaper :-).

    The big advantages are:
    • you're not tied to one platform, one manufacturer or a handful of languages; and
    • You can find out exactly what each function and parameter does; and
    • You can easily modify or extend anything (and no DMCA worries); and
    • You don't have to give away any rights before you start using it.

    These advantages are usually enough to handsomely compensate for any peripheral shortcomings (e.g. no force-feedback API, slightly smaller texturing envelope).

    --
    Got time? Spend some of it coding or testing
  6. Looks awesome! by breon.halling · · Score: 3, Interesting

    I've taken a quick glance at the tutorial, and it looks pretty good! As a Flash programmer, I've long been meaning to branch off into something more, um, sophisticated, and maybe this is the simple introduction that I've been waiting for!

    Many thanks, Jari Komppa!

    --
    "Yeah, well, Dracula called and he's coming over tonight for you and I said okay."
  7. SDL is overrated by Junks+Jerzey · · Score: 4, Insightful

    SDL has a couple of things going in its favor:

    1. It works.
    2. It's cross-platform.
    3. It's not trying to do too much.

    That said, SDL isn't particularly well-designed otherwise. It's awkward. There's too much underlying info exposed to the user. The "surface" abstraction is muddy, in that you can accidentally run without hardware acceleration too easily, and you do easily do other things that hurt performance simply because you didn't pay attention to barely documented flags.

    1. Re:SDL is overrated by ggambett · · Score: 2, Informative

      Well, what you say is true, but SDL is supposed to be a low level API. Things tend to get messy if you read the documentation, especially in a low level API.

      Other than that, I doubt anyone uses SDL directly. I wrote a high level framework on top of SDL, at a level of abstraction similar to Flash. It's quite good for doing that, precisely for being so low level and not forcing you to do things in a certain way. For the results, see my sig.

    2. Re:SDL is overrated by voodoo1man · · Score: 2, Interesting
      For a dead-simple graphics API, check out TinyPTC, which is unfortunately Windows-only. But the design is absolutely beautiful.
      Are you referring to the GPU shader-accelerated version of TinyPTC? The webpage itself states that the current version uses software blitting (and runs on a bunch of platforms) with optional MMX optimizations, which would make TinyPTC as fast as worst-case blitting in SDL. If you want to do hardware accelerated blitting with masking/alpha, I really can't see a better interface than what SDL provides - if you care about performance, call SDL_GetVideoInfo and use whatever mode the video card has acceleration for, and if not just use whatever you want and SDL will handle it in software with MMX optimizations like TinyPTC does in all cases. Sure, there are a few functions in SDL that I never use, but I wouldn't exactly call that poor design. I really am wondering why you think that graphics in SDL are so bad. If you said that about sound, I'd be inclined to agree with you, but when it comes to graphics I think SDL is really well designed, especially considering the alternatives.
      --

      In the great CONS chain of life, you can either be the CAR or be in the CDR.

  8. Re:Programming... harder?! by Anonymous Coward · · Score: 2, Funny

    I once wrote a program to "draw" pictures on punchcards by punching out holes.
    I wrote it in FORTRAN, though, not assembly.
    A friend of mine enhanced it to do flip-card animation, but the animation was pretty bad, due to the fact that (IBM) punch-card holes are pretty spaced out.

  9. HTML, anyone? by magefile · · Score: 3, Interesting

    I had a friend who did 2-player "TANKS" in HTML, Javascript and CSS, simply by having tons of 1 pixel divs. Quite impressive ...

  10. the 5k compo by Z-MaxX · · Score: 2, Informative
    Sounds like a common technique used in the 5k competition, a contest to make the coolest web page in 5 kilobytes.

    Check out some of the winners from the last 5k compo. Really cool stuff.

    --
    Dr Superlove 300ml. I use my powers for awesome