Archive

Archive for the ‘Links and Libraries’ Category

All About Boost

Given the hint I dropped yesterday about game data files, you may be wondering what lead to the  change in subject of today’s post. Well I’ll first reassure you that data files will come up in a day or to. I shan’t tell you what serialization library we’ll be using just yet, but given the title of the present post, I’m sure you can make an informed guess ;)

Regardless, we’ll be using the Boost libraries a fair bit anyway, so I thought I should take a second to make sure you know exactly what they are. I did post about them once before, but it was really just a brief mention. But Boost offers us so much extra – and often highly desirable – functionality that I felt it deserved a slightly longer introduction.

So, I’m sure by now you’ve worked out that by “Boost”, I refer to the Boost C++ Libraries. These 80 or so libraries, united under the Boost “flag”, are open source and peer reviewed. They are generally licensed under the Boost Software Licence, which allows for both commercial and non commercial use, in open source and closed source projects. Moreover, several prominent Boost authors are on the C++ standards committee and indeed many features of the Boost libraries have made it into the C++11 standard. While smart pointers may be new to standard C++, they’ve been in Boost for years. The same is true of lambda functions, threads, and more. (Of course, you should choose the standard C++ versions over the Boost versions now whenever possible.)

You probably want to know a few things you can do with Boost… Well, I’ll not say much for now. But here are a few of my favourite libraries

If you want to see a complete list of Boost libraries, just visit the Boost libraries page. Many are entirely header based, meaning you don’t have to compile any binaries. A few, however, involve source code as well so you’ll need to compile them into static or dynamic libraries. And to the “compile shy” ones among you, don’t think you can’t just skip it. Some of the most useful Boost libraries of all require compilation, and you’ll need them eventually. But don’t worry. It’s really not that hard, and over the next few days I’ll show both Windows and Unix users how.

Oh, and one other thing. I’m thinking of having a “Boost Week” in a bit. I’ll tell you about a library a day. I already have a few favourites I want to share with you, but if you want to know about any particular Boost library component, then just let me know in the comments! :)

ArrayWars

I’ve decided it’d be good to write a few very simple – but complete – games to show you. The first and simplest is essentially noughts and crosses, though I’ve gone ahead and called it ArrayWars. (If you’re wondering, my reasoning is that noughts and crosses is basically just a little struggle over an array of 9 squares…)

Anyway, the actual game is clearly quite simple here. However, I’m going to try and illustrate a couple of useful techniques that would be useful in a more general and more advanced setting. For example, it’s going to have customizable settings, as well as player stats. Both of these need to be saved and loaded from a file (I’ve found a library which makes this really simple, but more about that tomorrow…) Naturally, there’ll be a main menu, plus sub menus for the settings, the stats, creating a game and so on. This means we’ll need simple GUI elements: primarily buttons and text boxes.

Under the hood, there’ll also be application logging (for bugtesting and diagnostic purposes) and if I find the time I might make a simple in game console. If you’re interested, the code is already in a repository on GitHub. And, needless to say, the sound, windowing, graphics and input will all be handled by SFML!

Automatic SFML 2.0 Build – Unix

As you know, I’ve been providing prebuilt SFML 2.0 binaries for Windows (both MinGW and MSVC) for a while now (new ones will be out soon, by the way…)

I don’t really want to provide prebuilt binaries on Unix right now, but instead I’ve written a little script which will build them for you. All you do is run the script. Then it goes ahead and downloads the source, runs CMake and then builds and installs the binaries, header files, examples and documentation. You can go ahead and download the script, but read on a bit so you know what you’re doing. And of course, if you don’t trust me, you can always read through the script yourself :)

I’m sure it’s not very robust at the moment, so let me know if you have any issues with it. I’ll try to fix them as soon as possible. If you do come up against problems, you can probably just delete the directory it created and run it again. Oh, and you can run it a second time to check for source code updates and recompile.

Anyway, all you have to do is download the script, put it in the desired directory, e.g. ~/Development,  make it executable and run it (probably with no options, but see below for details).

chmod +x InstallSFML.sh
./InstallSFML.sh

Warning: If you install SFML to the default location of /usr/local, it will override any older versions (e.g. SFML 1.6) already installed in /usr. If you wish to continue using an already installed older version, read on to learn how to install SFML to an alternate location.

Usage Notes

There are just a few details of usage which I’d like to share. Firstly, as you probably know,  certain tools and libraries are required for the build. Namely, the script invokes CMake, make, git and doxygen. In fact, the script can have a go at installing these for you. Just run it with the -t switch. However, it handles this in a very primitive way. It installs them using apt-get so it’s specific to Ubuntu, Linux Mint and the like. Also, of course, the package names may change a little in the future (for example, git-core recently became simply git).

As for the libraries, you can try the -l switch. However, I’d say this is even less reliable. Again, it relies on apt-get and moreover it depends on the particular package names. However, I’ll try to keep these up to date so that it works on Ubuntu-like OSs at least. Anyway, if you have trouble with installation of packages or tools, let me know so I can look into it.

If you can’t get these features to work, don’t worry. The rest of the script should run fine, you’ll just need to ensure that the following tools are installed, along with the dependencies specified here.

  • CMake
  • GCC/Make
  • doxygen
  • git

There are just two last options. You can specify -D directory to have SFML installed into directory rather than the default location of /usr/local. And you can specify -S directory to have the SFML source downloaded into directory rather than a new subdirectory called SFML of the active directory. If you specify an existing directory (or if you use the defaults and there is an existing directory called SFML in the current active directory) then the script will check if it’s a Git repository. If so, it will update the repo and then build and install as normal; if it’s not a repo, it will give you the choice to cancel the operation or to delete the directory and re-clone the source from Git Hub.

SFML Uploads

02.02.2012 2 comments

Just a quick link - http://www.sfmluploads.org/

It’s a great little community site where you can upload your SFML projects, and check out other people’s. Take a look when you have the chance. Remember, you can also find various SFML programs and classes in the sources section of the SFML Wiki.

Categories: Links and Libraries, SFML

Singletons

Here’s another little something to keep you entertained while you’re waiting for things to get underway here again (it’ll happen eventually, I promise!).

The Happy Singleton

The Happy Singleton

SFML 2.0 Builds

25.12.2011 2 comments

It’s like Christmas come early! Well on time anyway… I’ve finally been able to compile some more SFML binaries for Windows – for Visual C++ 2008, Visual C++ 2010 and MinGW. There’s also optional documentation, and all the official example programs, compiled with MinGW and linked to dynamic release SFML binaries.

The best bit is, it’s not a messy archive any more. It’s a full installer now, so everything should be much smoother for you. Just pick the components you want, and it’ll install them to program files, or wherever else you want them put. Just remember – you still have to add compiler and linker search directories in your IDE.

By default all the files will be installed to C:\Program Files\SFML (or C:\Program Files (x86)\SFML), but you can change this. You’ll still need to add compiler and linker search paths in your IDE of choice and to provide the appropriate DLLs in your project directory.

And remember, this program is provided for your convenience only. It comes with no warranty of any kind and I cannot be held responsible for its suitability for purpose, nor can I be held liable for any damages caused by it, even if I was advised of such. You get the idea…

Well, have fun with the binaries. Here’s the link:
http://bit.ly/rCDGTn
(There is, of course, an updated link on the Downloads page too.)

And, of course, HAPPY CHRISTMAS from SFML Coder!

Renewed SFML 2.0 Builds

Remember all that time ago when I promised regular SFML 2.0 builds to blog subscribers, plus occasional builds for everyone else, as well? I sent out an initial build, but that was it. Anyway, I’m going to try and get that underway again. So, all current email subscribers will be emailed it – drop me an email if you want to opt out. And if you’re not yet subscribed by email, but would like to get the new builds as soon as possible, then please do subscribe now. But don’t worry if you really don’t want to give your email; I’ll provide a link to the build on the downloads page shortly as well.

Initially, the binaries will just be for VC++ 2008, VC++ 2010 and MinGW as before. I do want to provide Unix binaries as well, but it’s a little tricky with dependencies and stuff so I’ve go to decide how best to go about it. Ultimately I think I’ll try and create a Debian package for users of Debian, Ubuntu and Mint; otherwise it’ll probably have to be binaries without dependencies provided (you’d have to go to your package manager and find them yourself). As for MacOS, I’d like to provide binaries there too, just for the sake of completeness, but it’s not an OS I have – or ever into to have – access to, so I’d have to look into cross compiling it from Linux or Windows.

So anyway, you can look forward to updated Windows binaries this afternoon, and I’ll let you know when I can get some build for other platforms. Just remember than while I will keep you up to date with posts and the downloads page, the quickest and easiest way to hear about updates (and new posts) is to subscribe. So go ahead and do it! You’ll get your binaries soon ;-)

PS: I’m providing these files for convenience (and to make the site more popular :D ), but it’s still a great learning experience to build them yourself at least once. So check out my building SFML tutorials, for Windows/MinGW, Windows/VC or Linux/GCC. Oh, and just so you know, they’ll be updated with some new information soon too!

Pure Virtuals with Bodies

Here is the link to a fascinating article by Herb Sutter which discusses some circumstances in which one might want to write a pure virtual function with a body. Enjoy!

Categories: C++, Links and Libraries

C++ Articles

22.06.2011 5 comments

My favourite C++ website, the C++ Resource Network, has just received a revamp – giving it a brand new article system. Articles can now be rated and categorised, and their content can now contain HTML. Not to mention, once can upload files to be attached to the article. All in all it’s a massive improvement, and I can but give my most heartfelt thanks to the site’s operators.

Check out the new articles section now! And you can find my article on there – about C++0x suffix return types. It’s on the blog too, of course ;)

Windows Setup Files

When it comes to distribution, it is obviously advantageous to be able to use setup files to distribute on Windows. You can automate the install process, and also package any necessary redistributable files and dlls (license permitting) in a single file. But how do we make such setup files?

Well here are the links to two options: InnoSetup and NSIS. Both are free (check their licenses for details). In the past I have used InnoSetup.

It has a wizard which makes the creation of a generic installer very quick and easy – that includes readme and license files, installation of multiple files, password protection and control of shortcut creation. However, you can also write scripts directly, providing a greater degree of control over the generated installer.

Follow

Get every new post delivered to your Inbox.

Join 72 other followers