Project Good Robot Part 9: Under The Hood

By Shamus Posted Wednesday Sep 4, 2013

Filed under: Good Robot 104 comments

My project depends on a number of external libraries. It wouldn’t be possible to get this much done without offloading some of the drudgery to a few low-level packages written by others. I can make windows without getting married to Microsoft, render polygons without worrying myself with the arcane details of the driver layer, and make sound effects while knowing not a blessed thing about audio hardware.

The downside of not writing your code yourself is that you’re dependent on other teams, who might not be all that dependable. A few people have asked what libraries I’m using. So here it is:

Image unrelated. Addendum: pew pew pew!


Good old Open Graphics Library. While the OpenGL shader language continues to be a mysterious heap of poorly-documented features, hidden keywords, and devious traps for the uninitiated, OpenGL itself is as rock-solid as ever. There are multiple versions of the documentation, there are incredible tutorials, and there’s even a comprehensive book you can read for free. If you’re looking for technical documentation online, this is about as good as it gets.

I’m not sure if I want to fool around with shaders at this point. I’m just not seeing the need. Sure, there are a lot of cool tricks you CAN do with shaders (I wouldn’t mind a quick-and-easy blur on the background layers in my game) but right now it’s just not worth the hassle. I could blow an afternoon fishing around search engines and wading through the tedious jackasses that sometimes answer your technical questions after they’re done insulting you, but that’s a low-productivity / high frustration road and I’m in no hurry to go down it.

Someday GLSL docs will be as thorough and ubiquitous as the OpenGL docs. But that day is not soon.

Question: How many robots I can spawn before the game slows down? Answer: About that many.


Simple DirectMedia Layer is another standby in my projects. Sadly, now is a bad time to be using SDL. The documentation seems to be in some sort of upheaval. As of this writing the documentation is focused on the new 2.0 version, and I don’t want to mess around with the new version. The old one does what I need, the new one might have bugs, and migration is time consuming.

On the other hand, the old docs are kind of sketchy and in shambles. I can’t tell what happened and I’m not going to go crawling around in the wayback machine to figure out where the docs are supposed to be and who moved them. All I know was that for a few weeks Google couldn’t find a dang thing. I’d enter SDL_Init into Google and I’d end up on a six-year-old forum where someone was asking a question and happened to have SDL_Init () in the text of their question. If you’re not a programmer: Imagine you want to know the meaning and spelling of a word, so you search for the definition. But the only result you get is where someone used the word in a sentence. And they did so in the process of asking why the sentence is incorrect. You have no way of knowing the definition and you can’t even tell if they spelled it right.

It’s a little better now. I have a pretty good chance of typing an SDL function into a search engine and ending up at a page that actually documents the thing, but if I want to do something and I don’t know what the function is called I’m basically screwed. I’ll either end up in the 2.0 docs, at a broken link in the old docs, or in a forum somewhere.



The Developer’s Image Library. I began using this way back in Project Frontier. I don’t need docs because the library is already doing everything I need it to do and I never have to touch my image-loading code.


I really thought that OpenAL was going to do for audio what OpenGL did for graphics. But no. The official page is GONE. Most of the docs out there are just little code snippets with links to that now-dead page.

I wouldn’t mind, but some clever monkey left me this present:

1>  audio.cpp
1>e:\source\goodrobot\goodrobot\audio.cpp(189): warning C4996: 'alutLoadWAVFile': was declared deprecated
1>          e:\sdk\openal\include\alut.h(113) : see declaration of 'alutLoadWAVFile'
1>e:\source\goodrobot\goodrobot\audio.cpp(199): warning C4996: 'alutUnloadWAV': was declared deprecated
1>          e:\sdk\openal\include\alut.h(116) : see declaration of 'alutUnloadWAV'
1>e:\source\goodrobot\goodrobot\audio.cpp(226): warning C4996: 'alutLoadWAVFile': was declared deprecated
1>          e:\sdk\openal\include\alut.h(113) : see declaration of 'alutLoadWAVFile'
1>e:\source\goodrobot\goodrobot\audio.cpp(237): warning C4996: 'alutUnloadWAV': was declared deprecated
1>          e:\sdk\openal\include\alut.h(116) : see declaration of 'alutUnloadWAV'
1>e:\source\goodrobot\goodrobot\audio.cpp(355): warning C4996: 'alutLoadWAVFile': was declared deprecated
1>          e:\sdk\openal\include\alut.h(113) : see declaration of 'alutLoadWAVFile'
1>e:\source\goodrobot\goodrobot\audio.cpp(365): warning C4996: 'alutUnloadWAV': was declared deprecated
1>          e:\sdk\openal\include\alut.h(116) : see declaration of 'alutUnloadWAV'
1>  Generating Code...
1>  GoodRobot.vcxproj -> E:\Source\GoodRobot\Debug\GoodRobot.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

That’s what I see every single time I do something that causes my audio system to recompile. The important phrase is this:

'alutLoadWAVFile': was declared deprecated

Maybe if I ignore them they’ll just go away.

alutLoadWAVFile is a function you use to load a wave file so you can use it in your program. That message is an OpenAL developer frantically waving a red flag saying, “Hey! You shouldn’t be using alutLoadWAVFile! That’s the old way of doing things and we don’t support it! You should re-write your code to use the new system, which I will not hint at or explain.”

After much searching I discover that alutCreateBufferFromFile () is the new hotness. I also discover that the new hotness way of doing things is busted, and the old way works just fine. And I can’t sort it out because all the documentation vanished with the website. So the developer of OpenAL metaphorically sabotaged the old version, destroyed the documentation, and killed himself.

What makes this even more fun are all the forum posts where someone asks a reasonable question and some smart-ass replies with: “Why don’t you just use this?” With a link to the now-missing docs. So the death of has also killed off a good percent of your fallback documentation.

In any case, I get a page of errors in my face whenever I do anything. It still works, but it will be hard if I need to change anything about how the audio system operates. And of course the error messages are annoying, like having a fire alarm go off every time you do something mundane.

A small ray of hope is that the new SDL was supposed to support audio. So if I do ever make the leap to SDL 2.0, it might let me drop OpenAL. That would be one less library to worry about. I don’t know if SDL 2.0 is ready for that yet and I’m in no hurry to mess with it now, but it’s probably going to be good news for developers when it happens.


From The Archives:

104 thoughts on “Project Good Robot Part 9: Under The Hood

  1. Jarenth says:

    Aren’t arcane compiler issues just the best thing? Especially if your program works regardless. It just feels so… I dunno, icky, to willfully ignore that whole list of red flags every compile. Like someone yelling I left my laced untied when I’m wearing velcro. Don’t… don’t think too much about that.

    You used the same mouse-over joke in the last two images. The second image doesn’t even have that meny boolits!

    1. Volfram says:

      That is probably my favorite thing about D. The Digital Mars compiler’s error messages are very helpful and even go out of their way to suggest what you might have been trying to do instead of what you actually did.

      hello.d|9|Error: undefined identifier Pants, did you mean variable pants?|

      Oh hey, I mis-capitalized a variable there!

      Granted, it can’t fix everything.

      1. Nathon says:

        That kind of error message is remarkably easy to make. I really wish the GCC people would try.

        Also: D is great!

        1. DrMcCoy says:

          Well, the error messages did improve in gcc 4.8. Though still not to this degree.

          I always here from people that clang is better in this regard.
          Me, personally, I am and always was fine with gcc, and I’ve been using it for over 10 years. But YMMV, of course.

          1. DrMcCoy says:

            Ah, yes, clang does do this:

            test.cpp:5:2: error: unknown type name ‘foo’; did you mean ‘Foo’?

            EDIT: Apparently, there’s no code- or pre-tag here, so I’m removing the bits that need proper alignment to make sense.

            1. Kerin says:

              One more for Clang, the error messages are great. I only ever compile in GCC when I need a really specific set of debug options built for Valgrind.

        2. Volfram says:

          I love D!

          Based on featureset comparison, it seems to basically be a cross-platform, hardware-compiled version of C#. They were even launched close together.

          Granted, I have done very little in C#, so I am perhaps not the best person to be making this comparison.

      2. kdansky says:

        I spend half my working day puzzling out arcane error messages that the VC++ compiler prints. I wish Microsoft would take a good hard look at clang.

        I will make a bold statement here, and say this: 50% of the reason people are much more productive with Java than with C++ is the fact that you get error messages very quickly, and rather accurately. If you type anything that’s crap, you will get a squiggly line, similar to what Word does when it does not know a word. That means you don’t need ever need to break your flow writing stuff and wait for the compiler to run (that takes 10 seconds easily, which is a very long time to wait every few minutes).

        That said, I still prefer Scala, even if the errors are a bit more arcane than Java. But C++ is just a nightmare: 50 times the same error, and all of them incorrect. It likes to tell you that “this class doesn’t have such a method”, when it means “you used the wrong variable”.

        1. Volfram says:

          That has more to do with the IDE than the language, but you’re correct in that there’s no reason a given IDE shouldn’t be able to highlight undeclared references for you the moment it spots them.

          Local references and un-imported libraries, at very least.

          I’m using Code::Blocks. The parsing engine is currently broken, so it’ll sit there all day trying to figure out which library I was referencing, with a “currently parsing…” tooltip blocking whatever it was I was JUST typing. I should probably see if there’s an update…

          1. kdansky says:

            In the case of C++, there is a very good reason why the IDE can’t highlight errors: It’s incredibly hard to parse C++ correctly due to how the preprocessor and the compiler work. You really can’t tell whether something is a macro or an expression until you’ve taken a good look at the complete code-base.

            For the non-programmer: C++ is so complicated, the computer cannot make sense of it at all if there is even a small mistake, and that is why the error messages suck.

            1. Kian says:

              Code::Blocks is pretty much abandoned, and has been for some time. However, NetBeans for C++, Eclipse for C++ and Visual C++ Express all have code completion, syntax highlighting, and yes, squiggly lines for mistakes. Visual’s syntax highlighting is the worst, it only highlights reserved words, comments and quoted strings, while the others will differentiate number constants, variables and functions, and highlight all instances of an identifier when you place the caret on them.

              It can take a bit of time for the IDEs to work through all the includes if it’s a large project, and the new C++11 options might be hard for some to parse properly, but it’s been a while since the tools have been so primitive.

              1. Ithilanor says:

                Unfortunately, schools don’t seem to have realized this…in my Object-Oriented Programming class, we’re stuck using emacs to edit code. I miss using a proper IDE.

    2. Piflik says:

      The best compiler errors I got while working with DirectX…the error message were just a unsorted (to me) amount of letters, numbers and symbols, over half of which were @. Really fun to try and debug that…

      1. Deoxy says:

        You mean a Microsoft product produced useless gibberish errors? In other news, water is still wet.

      2. Marcel says:

        Aren’t these always linking errors? For me such an error is a reminder to add the newly created code file to the linking command.

  2. rofltehcat says:

    Wow, those screenshots look amazing!
    But swastika-bot (screenshot 5) is rotating very fast, right? Otherwise it might look a bit awkward…

  3. Corpital says:

    No comment to the libraries due to the total absence of progamming knowledge, but I have to say I like the style of the game more and more with each screenshot. Bright colors! Glowing things that even look like they are sounding pew and wooosh and…I don’t even know, what I’m talking about. But I like it. ^-^

    1. Volfram says:

      Every new set of screenshots makes this look more like a game I want to play.

      I see we have basic health and ammunition displays, too, now.

    2. John Magnum says:

      Yeah. I hope we see the robots themselves refined yet further, but the backgrounds and laser blasts are looking incredibly nice.

  4. Xapi says:

    I fully endorse the inclusion of Nazi robots as antagonists.

    1. Lalaland says:

      Yup the power of history to forever change the meaning of an abstract symbol is quite potent. There are plenty of buildings and carvings in Europe that have the swastika in their design as part of the Mysticism movements of the late 19th and early 20th century (yup the hippies weren’t original in raiding Eastern philosophies for their wacky BS spiritualism). It’s very odd to be walking by a baptismal font that proudly displays swastikas, they’re not crooked as in the Nazi brand but still bloody weird.

      There’s a pretty clear difference from ‘robot with four crooked arms’ to ‘wall of superheroes with Hitler’ ( The question is though does the individual creating the art want the reactions to their art cluttered up with potential response to what could be construed as ‘neo-nazi imagery’.

      I’ve been reading Shamus’ output for long enough to believe that he doesn’t hold those views but it’s dangerous water to find yourself in. It’s overreaction to be sure but if there’s one topic that is prone to that kind of reaction its Nazis which is why they tend to be rather cartoonishly evil in games.

      I’d love to see a game like ‘Papers, Please’ that dealt with what Hannah Arendt’s concept of ‘the banality of evil’. Ever since I’ve read Michael Burleigh’s ‘The Third Reich: A New History’ I’ve been fascinated by the extent of the machinery that perpetuated the Holocaust and the tens of thousands who built careers on being the best functionary within that system. It seems that most media that deals with the topic can’t deal with the horror of a system that relied on the honest efforts of ‘good people’ to jointly enable a genocide.It’s that warping of honest effort to evil ends that really stuck out to me in that book (and the petty squabbling of every single department gives the lie to the ‘Nazis were efficient’ idea)

      TL;DR ‘Swastika-bot’ might get you attention you don’t want if it’s used out of context. Also assorted comments on the symbol and Papers, Please

      1. Shamus says:

        Naturally I didn’t intend any Nazi imagery. I didn’t even “see” the symbol until after the robot was designed. I might be able to get rid of some of the swastika-ness of it by fiddling with the proportions of the arms. It’s just a 64×64 image so there’s not a big expense to messing with it.

        1. Lalaland says:

          I imagined as much, I only saw it after reading Xapi’s comment too but once seen… :)

        2. Daemian Lucifer says:

          Or just swap the orientation.Not every swastika is a nazi thing.

          1. Lalaland says:

            Very true but they’re all open to misinterpretation, merely altering the arm length ratio would destroy the resemblance entirely. A lot of idiotic graffiti gets the Nazi version of the swastika the wrong way round too.

          2. Zukhramm says:

            Not every “non-flipped” swastika is either.

        3. Nick Powell says:

          You could just give it 3 or 5 arms.

        4. Hieronymus says:

          You could just reverse the direction of the points, making it a symbol for luck (or something like that), IIRC.

          1. Felblood says:

            Why guess when you have Wikipedia?

            TL;DR: Svastika literally means good luck.

        5. Bropocalypse says:

          Alternatively, you could rebrand this game as a WW2 shooter and keep the swastika bots as Hitler’s secret weapon.

          1. kdansky says:

            Then he would have to learn how to do shaders, so he can make everything brown/grey!

        6. Xapi says:

          For the record:

          1 – I knew it wasn’t intentional.

          2 – My comment was tongue-in-cheek (I think I’m using this phrase right)

          3 – Even if it WERE intentional, I personally wouldn’t mind at all.

          4 – I do believe it would be best to change it to avoid the wrong kind of attention and outcries for Shamus’ head.

          1. rofltehcat says:

            Same with me. Stuff like this can happen unintentionally and I’m sure Shamus can come up with another design for it!

      2. Deoxy says:

        I'd love to see a game like “˜Papers, Please' that dealt with what Hannah Arendt's concept of “˜the banality of evil'. Ever since I've read Michael Burleigh's “˜The Third Reich: A New History' I've been fascinated by the extent of the machinery that perpetuated the Holocaust and the tens of thousands who built careers on being the best functionary within that system. It seems that most media that deals with the topic can't deal with the horror of a system that relied on the honest efforts of “˜good people' to jointly enable a genocide.It's that warping of honest effort to evil ends that really stuck out to me in that book (and the petty squabbling of every single department gives the lie to the “˜Nazis were efficient' idea)

        You must not work in Corporate America. Dilbert exists for a reason, and it’s to mock how very true all that you just wrote about the Nazis is true in corporate America today…. minus the genocide, of course, but WHAT the system is doing is essentially irrelevant to the system itself.

        Genocide, widget production, whatever – that’s not my job. Making sure you fill out this paperwork is my job.

        I don’t mean to trivialize genocide, merely to point out the inherent absurdities of bureaucracy.

      3. Zak McKracken says:

        I didn’t think this was intentional either, but in addition to swastikas being synonymous with Nazis in most people’s memory (independent of orientation), you would for example not be allowed to sell (or otherwise distribute) this in Germany. It represents a period of our history we’re not proud of and while it would technically be legal to show an inverted swastika (or even the “evil” version, but only in documentaries), it would still raise questions from people who understand no jokes in this regard.

        … I personally think that not understanding jokes robs you of a very basic human ability, but yes, it’s a touchy subject.

        That said: yes, changing the proporions (or number of arms, or curving some parts) should do the job, so no big deal.

        1. Piflik says:

          It certainly is not a Swastika, it just resembles one. I don’t think that it would be a problem selling it here in Germany. I have seen tons of stuff being sold here that has something similar to a Swastika somewhere on it.

  5. Svick says:

    Couldn’t you just edit that alut.h file, so that it stops screaming?

    If I understand it correctly, removing ALUT_ATTRIBUTE_DEPRECATED from the declaration should do the trick.

    1. Kelhim says:

      That doesn’t make it any less deprecated.

      1. swenson says:

        However, “deprecated” does not mean “doesn’t work”, just “don’t use this”, so in this case, it doesn’t matter.

        1. DrMcCoy says:

          But deprecated means that it might vanish completely in later versions.

          1. Kian says:

            Which is less of a concern when the entire project vanishes, making future versions unlikely.

            1. DrMcCoy says:

              Only Creative’s OpenAL hardware implementation is bust. There’s still OpenAL Soft.

              See also this and its replies:

              Quoth an ex-Creative employee: “OpenAL-Soft is the banner-holder.”

              1. bucaneer says:

                And then there’s this message from a current Creative employee explaining what happened to the OpenAL website: (DNS issues, not permanent)

    2. lethal_guitar says:

      Well, there’s no need to edit the file, warnings can be disabled. I don’t know the exact syntax right now, but it’s something like:

      #pragma warning(disable: 4996)

      Just do this before including alut.h, and it won’t annoy you anymore. It’s also somehow possible to disable specific warnings via compiler options/project settings.

      Now, one might argue that every warning is there for a reason, and I can totally understand that – I strive for warning-free code almost all the time (using very high warning levels). But that wall of messages can make it harder to spot more important warnings coming from your own code, and it’s very likely not an issue anyway in this specific case.

  6. Knut says:

    If you still have trouble with OpenAL, perhaps the open-source implementation is better?
    *DISCLAMER* Haven’t used it myself *DISCLAMER*

    It seems the examples are bundled with the source though, in a typical open-source way of documenting things…

  7. DrMcCoy says:

    I'd enter SDL_Init into Google

    This is why I’m glad dev packages on most GNU/Linux systems come with documentation (basically, this: , + man-pages).

    OpenAL was pretty easy to grok just from reading the include files.
    And I generally write my own decoders. Well, okay, they’re basically either 1) copied from ScummVM 2) copied from FFmpeg or 3) small layers around a decoding library. :P
    Still, the WAV format is easy enough to decode yourself.

    Ditto with image formats, though there I did actually write the decoders myself for the most part. No need for DevIL.

  8. Kian says:

    So, only about 50 bots before the game slows down (alt text in the first image)? I’m guessing it’s not the graphics that are the bottleneck. Probably the collision detection. If you’re not doing any culling, the checks grow with the square of the number of objects. The AI shouldn’t be eating that many cycles, I think. Although it is a linear cost, and you can’t really cull those. Path-finding might be growing in complexity with that many objects, too, if they are checking for it.

    Are you using cache-friendly data structures? Vectors of objects instead of lists of pointers to heap objects, for instance. Or keeping like data together and batching operations that impact it instead of objects each with an update method that does everything. For example, having an UpdatePosition function that goes through a vector of position and acceleration data and updates the position of each entity, another UpdateAI, etc.

    It requires breaking down objects into their component elements and spreading those out (identified with some manner of object ID), but I’ve read that you can get significant performance improvements. It’s also threading friendly, since each component can run in parallel without worrying about race conditions, mutexes and the like.

    1. Shamus says:

      In case you’re curious:

      The above screenshot doesn’t really do the mob justice. There’s about ~250 active. (I have a command that spawns 300, and I’d blasted a good number of them before I took the shot.) But the slowdowns start at around 100+ bots in active combat, and I’m 95% certain the cause of the problem is actually the particle engine. A fight like this can generate 5k to 10k particles. (Bullets have sparkle trails, their impacts have debris, robots give off sparks when hit, smoke trails when dying, wreckage when exploding, etc.)

      Not using cache-friendly data structures. All of this is pretty far from optimized. 10k immediate mode polygons is going to make a mess of performance. Still thinking about how I’ll speed things up when the time comes.

      EDIT: Of course, it’s my fault for labeling the image “about that many” when that wasn’t technically true. I should have pulled the camera back.

      1. Volfram says:

        Post-optimization, I think it would be neat to see a massive horde of enemies show up at certain points in the game, just so show that you can.

      2. Kian says:

        Ah, of course. Immediate mode will do that. If you’re interested in taking a stab at shaders, the OpenGL SuperBible is an amazing resource. It has tutorials that ease you into every aspect of dealing with them, better than NeHe’s, even. With plenty of examples and a helper library to handle the heavy lifting. The code samples can even be gotten freely of the net, here:
        They come with visual studio solutions, as well.

        They’re generally well commented, so even without the book you can follow things along.

        The GLSL is pretty c-like, and documentation is plentiful nowadays. You can even get a few reference cards with every function and data structure laid out easily, here:

        OGL 3.2
        OGL 4.2
        OGL 4.3

        GLSL reference is at the bottom, after all the OGL bits.

      3. Piflik says:

        Not sure if this helps you, but in my last project for University (C++ & DirectX) we had to write a particle system. We created single vertices at the position of the particles, all in one single Draw Call and then used a Geometry Shader to turn these vertices into single quads looking in camera-Z direction. The only thing that took a modicum of CPU power was sorting them, but even that was barely noticeable (since the position changes during one frame was minimal, so the sorting algorithms were highly efficient).

        1. Shamus says:

          Never used a geometry shader before. That should like the right solution, though.

          I wonder how far back support for those goes? Is that a 2008 thing or a 2003 thing? I’ll have to see if the internet knows.

          1. Piflik says:

            Geometry Shaders were introduced in D3DX10 and OpenGL 3.2 (according to Wikipedia there were extensions to use them in OpenGL 2.0+), so it’s aquite young thing. Not sure if HLSL code helps, but if you want to see the shader, give a shout.

      4. kdansky says:

        Do some profiling? You can evaluate glowcode for 30 days, and that’s totally enough to learn how to use it (a few hours) and to get results (a few more hours).

        Never optimize blindly, always profile first. I feel like a broken record (do people even understand this metaphor still?!), but really, always profile when you run into performance issues.

  9. Volfram says: seems to have died within the past TWO MONTHS! Yipe!

    I was on the fence in my own game about whether I wanted to use OpenAL or SDL_Mixer. After some deliberation, I settled on OpenAL for absolutely no reason, and then saw that Shamus used it, and said “Well hey, if Shamus uses it, it’s probably good enough for me!”

    A quick Google search and Wikipedia check has revealed OpenAL Soft, an open-source version of the library.

    From the WIkipedia page, I suspect Creative Labs are deciding they don’t want their proprietary library to be open-source anymore. Which is kind of stupid and mean-spirited in this particular case.

    Love me some OGL and SDL. In my project, I’m mostly using SDL to get everything off the ground, and interfacing with OGL directly or writing my own stuff afterwards. This is probably a good thing, because I’m writing it in D, which means I’m reliant on Derelict for access to existing C/++ libraries, and that’s going through just as much upheaval as SDL right now. I’m not even going to check if he supports SDL2 yet, because I simply don’t know enough about the environment to make a switch to Derelict3 yet.

    Derelict has DevIL hooks. I took a quick look at my image loading code and concluded I didn’t really need it, though. SDL_Image is doing all the image loading grunt-work and just handing me a surface of RGBA values.

    Makes me feel good to see so many familiar faces in that list.

    1. Nathon says:

      The graphics-y project I wrote in D used Derelict2, which was new and shiny at the time. That’s the big down side of using less popular languages like D: the bindings for third-party libraries can be very unstable.

      1. Volfram says:

        Must admit, when you can track down all the component parts, Derelict works the way a 3rd-party library should. Build it on-system, plug it in, and go. Once you’ve got it all hooked up, it’s even (almost… I have found one or two glitches) completely transparent. Just call the SDL and OGL values like you would in C. Derelict will even, for the most part, translate the calling conventions over.(D strings to C null-terminated strings)

        I would estimate D has shaved a good 30-50% off my development time. Tracking down usable 3rd-party libraries has added a little back, but nothing compared to the time saved. I’m a little spoiled now.

    2. mewse says:

      For what it’s worth..

      Since you’re already using SDL, there are a couple SDL audio libraries worth considering:

      SDL_Mixer is dead simple. If all you want to do is load and play some music and some sound effects, it’s by far the easiest way I’ve found to do it. But if you want to do anything fancy (dynamically fade between music tracks, synchronise video to a music track, etc), then it probably won’t give you the tools you need to accomplish those things reliably.

      SDL_Audio is a much lower-level audio library. It doesn’t support a wide suite of special audio formats the way that SDL_Mixer does, but it lets you feed the audio buffers yourself, and provides useful functions for mixing audio channels. And it’s built straight into SDL2 with virtually no changes, so upgrading to SDL2 won’t require modifying code. (SDL2_Mixer is still a separate library, under SDL2)

      1. Volfram says:

        Fortunately for me, audio support was merely “in existence,” and not fully fleshed out. Not sure what I wanted for it yet.

        If the whole OpenAL thing goes pear-shaped I’ll probably take another look at SDL_Audio. If it doesn’t, I may still take a look at SDL_Audio, since it seems to fit my dynamic better.

  10. WILL says:

    In other news the game looks great.

    1. Corran says:

      I can’t believe it took this long in the comments before someone mentioned this.

      The screenshots are a little small but the game looks gorgeous.

  11. WillRiker says:

    SDL 1.2 has the SDL_Audio library for doing sound. I think these are the right docs for them:

    It’s unfortunate that all the 1.2 docs are in such disarray right now; they really should not expect everyone to immediately jump on the SDL2.0 bandwagon.

    1. mewse says:

      For what it’s worth, SDL_Audio’s API is almost identical to SDL2’s audio API. You should theoretically be able to use the SDL2 API documentation to write SDL_Audio code for SDL 1.2.

    2. Yeah, normal SDL audio functionality works fine as long as all you are doing is .wavs. I prefer the official extension library SDL_mixer because it gives you lots more formats and lots more things like channel controls. Heck all the official SDL extension libraries are pretty decent. SDL_Image nets you alternate formats like png painlessly (though I don’t know how well it interacts with opengl) SDL_net gets you solid if simplistic networking and SDL_ttf gets you ttf text rendering.

      The SDL docs themselves seem to be all there, you just don’t have the nice formatting anymore.

  12. Loki J says:

    Shamus, do need any beta testers? I actually know how to file a bug report.
    Also, have you considered monetizing this thing; looks good enough for some sideline income.

    Additional also, your widget correctly confirms that I have no writing errors.

    Edit. Weird; my website is actually linking into somebody else’s. Use this instead.

  13. Loki J says:

    While attempting to edit and post my correct URL, my comment got flagged as spam. My name in this reply has my correct site.

    1. Loki J says:

      Or not…apparently the URL is too long for the website box lol

      <a href=";

  14. adam says:

    Can you not suppress warnings about deprecated methods, at least temporarily so it’s not so bothersome?

    1. Rick C says:

      Deprecation warnings usually mean the library developer has put something in the header file to force the warning.

      For MSVC,
      #pragma warning(disable : 4996)
      will suppress the message (in theory until such time as you upgrade to a non-deprecated function, which may not always be possible.)

      1. Rick C says:

        I’d also like to take the time to point out that alutLoadWAVFile is an obnoxious function name and is what C++ namespaces are for. Had OpenAL put their functions in a namespace alut, Shamus would’ve been able to use using renames on the off chance he alrady had a LoadWAVFile.

        1. Rohit says:

          I think OpenAL is written in C.

          1. Rick C says:

            Maybe so–I just looked at Shamus’ code (or rather the error lines), which (indicate the code) is C++.

  15. Ok, so everyone is making a lot of sensible comments about OpenGL and sound libraries and stuff; do you mind if I complain for a moment about the site layout? I know you love tinkering with CSS while in the middle of an interesting project, so this must be a good time, right?

    Anyway! The title of your posts is a faded blue-grey that drops right into the slightly-different blue-grey that forms the background of your text box. It’s quite hard to see. However, the “Previous: FooSeries N-1” link under the title image is a hard blue that pops right out. I always find my eyes being drawn to the “Previous” link, seeing “Aw, I’ve already read that”, and then it takes me a couple of seconds to realise that no, this is new postness. Could you take half a day or so of your valuable coding time to fix this minor annoyance? Thanks!

    1. Cuthalion says:

      I second this. It may be because I’ve already visited the link, but I think I’ve noticed this lately with new posts, too. I’m using FF 23.0.1, if that helps.

      Anyway, no hurry. It’s only a minor annoyance, at least to me.

  16. Toastgoblin says:

    Shamus, I appreciate it might not work out, but have you tried ransacking the page for OpenAL? It seems to be reasonably well-archived when I took a look, but of course I don’t really know if it’ll help with what you need.

  17. Rohit says:

    If you just want to load .WAV files with SDL and OpenAL, here is my function.

    void loadWAV(const char* filename)
    SDL_AudioSpec wav_spec;
    Uint32 wav_length = 0;
    Uint8 *wav_buffer;

    if (SDL_LoadWAV(filename, &wav_spec, &wav_buffer, &wav_length) != NULL)
    ALenum format;
    case AUDIO_U8:
    case AUDIO_S8:
    format = wav_spec.channels == 2 ? AL_FORMAT_STEREO8 : AL_FORMAT_MONO8;
    case AUDIO_U16:
    case AUDIO_S16:
    format = wav_spec.channels == 2 ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16;

    ALuint buf;
    alGenBuffers(1, &buf);
    alBufferData(buf, format, wav_buffer, wav_length, wav_spec.freq);
    loadedBuffers.insert(std::pair(filename, buf));

    No deprecated functions, and allows me to play the sound by using a map and getting its filename.

    Also, is there support for code tags?

  18. Christian Severin says:

    Heads up: zipped copy of the old SDL 1.2 docs is under way.

  19. Diego says:

    For someone who wasn’t trying to make a good looking art this is turning out fantastic looking. Simple but more than just effective, it actually looks very nice.

    1. Paul Spooner says:

      Yeah, it’s really slick looking. Whenever my three year old daughter walks by while I’m reading these posts she leans way in and says “Daddy, I want you to play that game!”
      Super effective.

  20. Andy L says:

    I'm not sure if I want to fool around with shaders at this point. […] but right now it's just not worth the hassle.

    I feel like this phrase appears in every one of your (excellent) “let’s code” series.

    Perhaps your next series should be specifically chosen to put pixel shaders in your mental tool box.

  21. aldowyn says:

    I’m going to.. what, fifth or sixth the statement that those screenshots look awesome. This looks like a real game and that’s pretty cool. It’s hard to get a feel for this type of game from screenshots, but it’s looking pretty slick. Keep it up ;)

  22. Phantos says:

    I lurve the colours in the backgrounds. I wonder if that will affect the visibility of the enemies and projectiles, but for the time being it looks pretty.

  23. josearcadio says:

    The second screenshot looks a lot like badlands for the iphone

  24. Kranzky says:

    Great looking game Shamus; reminds me of Oids (ref: and Thrust on the c64. Any chance of gravity + collecting orbs and towing them to safety on a dangling rope? Ahhh…

  25. Paul Spooner says:

    Man, I feel your pain on library dependencies. I wrote my own Minecraft save file interface library from scratch, and then made all of my Minecraft scripts dependent on it. After a few updates of the Minecraft save file format I got tired of updating my own libraries, so now I just use MCEdit as an interface. Dependencies layered on dependencies!

    Really the trick seems to be to make a robust library translation layer (maybe there’s a technical term for this?), so you can simply switch the translator if you ever need to switch libraries, instead of overhauling all your application code. Of course then you start multiplying interfaces, and spend nearly all your time on interface code… but it’s better than hunting down all the broken dependencies when the libraries break.

    Obviously you’ve found a way around these problems though. Looking great!

  26. MaxEd says:

    I know it wouldn’t be much help now, but the next time you need 2D, try Allegro library instead of SDL. It’s far better documented, and I liked its API much more (although that’s a question of preferences). Unlike SDL, Allegro not only handles 2D rendering, but also image formats loading, font loading & rendering, audio, input and even virtual filesystem (loading stuff from ZIPs) if you need it, via a system of addons (or a single huge monolithic DLL, which I prefer).

    Stable version (5.0.x) lags behind WIP (5.1.x) somewhat, so I use WIPs (they are not too buggy usually, and docs are updated fairly quick), but even 5.0.x is quite good.

  27. Phantos says:

    Thinking back, I kind of wish I had something more tech-savvy to say about your progress, like most of the comments. But I’m a dumb-head who doesn’t understand the elf magic that goes into making the bleep bloops.

    So I will re-iterate that I like what I’m reading and seeing about this project so far, and will leave only with the suggestion that you find someone who can make a “Good Robot” theme song.

    Maybe get a kickstarter going so you can afford They Might Be Giants.

    (Or just get twenty bucks together and get Ninja Sex Party to do it.)

    1. I’d vote for Emerald Rose myself, but they are my favorite band (and a group of cool guys). Heck, don’t you know you never split the party?

      They do geek, celtic, and pagan music.

  28. Tometzky says:

    Maybe a Minecraft development model would be good for you. Make your game somewhat playable and begin to sell it for $5 in alpha stage, $10 in beta, $15 for full game for example. With free updates.

    1. Mac says:

      Seconded. If you make it a “pay what you want, as long as it’s at least $X”, I suspect you’ll get a bunch of extra money from people (like me) who love your blog but never got around to donating.

  29. Zak McKracken says:

    This post is a very very mean way of showing off the game without giving us lots of details…
    Can I maybe tease an explanation for the avatar’s trail out of you? Works extremely nice in the screenshots and makes them a lot more dynamic.

    Also, the mandatory unwelcome feature request, after seeing that screenshot with the tightly packed robots: If a robot explodes, it should do damage to its neighbours. Maybe not enough to kill them but still something significant (depending on distance of course). Would make for a very satisfying experience when shooting your way through a lump of enemies…

    1. Volfram says:

      Well the way I would do it is thus:

      I already have a “Polyline” class that I wrote several months ago. You feed it a set of points and a set of point widths and it processes everything else. So we feed it a set of widths that start wider(say bout 0.5) and go down to 0 along the length, then I give it the array of points.

      Every frame, I take every point in that array and move it back, drop off the last point, and then add Good Robot’s location to the front, call a rebuild on the polyline, done.

      Super easy!

      Hey, maybe I should try it out in my game engine. :D

  30. Looking into OpenAL Soft like others pointed out might be worth it, or audio i SDL. The original OpenAL was brilliant but Creative miss-managed it.

    Got a few suggestions/or some thoughts I got when looking at the screens.
    I assume the “health” bar is temporary?
    Even if not, myself I like games that has as little extra stuff in overlay as possible.

    So the health status could be indicated by a glowing color of the player character, with yellow, orange and red indicating how much health is left, and in addition to that maybe a pulsing effect. So that when you are about seconds away from dying it’s pulsing red very quickly. If the glow/effect is somewhat transparent it might look even better.

    Not entirely sure on say energy, but the eyes/lights on te player robot could be weaker /stronger depending on energy reserve? OR maybe that could be an ammo indicator instead?

    The only thing that would be very difficult to not overlay is a score.
    But personally I’d sort of float the score when the lil’robot transitions from one level to the next.
    Or simply allow the player to press the Tab key to show various stats/info (or Robot Diagnostics Table to keep in character :P ) After a few seconds this overlay could fade away.

    1. WillRiker says:

      Yeah, looks like OpenAL Soft is probably the way to go here–Shamus should be able to practically drop it in in place of the old OpenAL without having to do any major rewriting or rearchitecting of his code.

    2. Volfram says:

      After playing Fable 3, I REALLY like having a HUD. If a game had the settings you proposed, I would probably hold the Tab key down down the entire time.

      1. ” If a game had the settings you proposed, I would probably hold the Tab key down down the entire time.” well you did say “settings”, would be no issues having a few HUD options.

        The point I was making (and you missed) was that if you can get across the status in a more natural way then that is better. It would be stupid to put vital information under a hotkey without ensuring that the player is informed through some other means as well.

        Your eyes already are hovering around your player character.

        The distance your eye need to move is thus much shorter than having to move your eye down to the corners (where HUD elements usually are as they need to stay “out of the way”).

        Those who like to master and hone their gaming skills should welcome the improved reaction time this would give them, while those that do not care…do not care, and those that dislike it could just toggle an option and have a classic HUD.

        1. Volfram says:

          I understand the idea of making information readily available to the player(I play Half-Life 2 with the health and ammo counters around the reticle turned on), but I think it’s irrational to be so terrified of a HUD that you start finding any and all ways possible to get rid of it. Sometimes, the best way to deliver information to the user quickly is just to slap a bar on the screen and call it a day.

          And sometimes, the best way is to make the robot change colors according to your weapon charge.

          The problem is that far too often, like in Fable 3 or, IMO, Dead Space(though I haven’t played the latter), the developers were SO terrified of any sort of display elements that weren’t “in-world” that they either introduced fridge logic into the system(how useful is it to have your vital signs in a position that’s visible to everybody BUT you? What’s the point of having ammunition counters large enough to be seen by the guys you may need to be shooting at?) or replaced a perfectly good “attention ping” and “menu” system with an obnoxious dog and a set of 4 rooms that are slow to navigate.

          Sure, I got used to the “menu” system in Fable 3, but the dog was a stupid design decision.

          1. 3D games are a tad different. If the UI is “in-game” or in 3D space as well, something like the Occulus Rift would need be compatible with only minor changes.
            Games with 2D HUD’s just slapped on could have major issues working with such a device.

            Also, regardless of how information is portrayed, I prefer to be able to turn on/off what info to be displayed.

            In KOTOR I turn off a lot. In Skyrim too. In Mass Effect it is mostly concealed behind the spacebar.

            Screen space is expensive.

            But how the screen space is used/can be used depends a lot on the game itself. And don’t get me started on touch friendly UI’s, (speaking as a programmer, those are a nightmare to design for)

            1. Volfram says:

              I…don’t see how hard it could possibly be to get a 3D game with a 2D HUD working on a parallax screen. Set the HUD parallax to 0, make everything else parallax behind it? Pretty sure that’s what DiRT2 and Sonic Generations do.(Both have a plethora of 2D HUD elements on a 3D background, and DiRT2 was one of the first games I played with a stereo display)

              I know you’re right about the Touch UI thing if only because I’ve seen how often that’s done horribly horribly wrong. It’s one of the shortcomings of Windows 8: you need both a touchscreen AND a mouse to use both sides of it sufficiently frustration-free. Terrible design decision there.

  31. tranquil_madman says:

    You probably already know about this, but it might be useful to turn off ‘warning C4996’ inside the file you have all the OpenAL calls in, so you won’t need to see those warnings again: #pragma warning(disable:4996)

  32. James says:

    What’s worse than missing documentation or out of date stuff?

    Some idiot that ran their .h files through Doxygen and decided that’d do.

    Yes, I know the “crashAndExplode(int when)” function makes your computer crash and explode, and you can tell it when. Could you, I dunno… maybe give me a bit of a context, an example piece of code? It’s like trying to learn English by reading a dictionary – you know precisely how things are written, but not how to put them together.

  33. Cor'e says:

    Looks nice and fun. Best MMO for me personally, was Islandia,
    Btw, ResIL Resilient Image Library – successor to DevIL.

  34. damadmax says:

    Hi Shamus,

    sorry for digging out this nearly abandoned discussion. :)
    Just want to bring some attention to
    Jason’s OpenGL Tutorial if your still interested in doing some fancy vbo and shader stuff. After some weeks of reading the tut, fiddeling with my old crappy code and sleepless nights, I managed to do a complete rewrite of my “engine” and throw away all that deprecated stuff.

    sincerely damadmax

Thanks for joining the discussion. Be nice, don't post angry, and enjoy yourself. This is supposed to be fun. Your email address will not be published. Required fields are marked*

You can enclose spoilers in <strike> tags like so:
<strike>Darth Vader is Luke's father!</strike>

You can make things italics like this:
Can you imagine having Darth Vader as your <i>father</i>?

You can make things bold like this:
I'm <b>very</b> glad Darth Vader isn't my father.

You can make links like this:
I'm reading about <a href="">Darth Vader</a> on Wikipedia!

You can quote someone like this:
Darth Vader said <blockquote>Luke, I am your father.</blockquote>

Leave a Reply

Your email address will not be published.