Archive
SFML camelCase
Just a quick heads up. SFML has undergone some name changes. Class members are now named in camelCase. This just means that the first word of each member’s name is no longer capitalised. For example
sf::Window::IsOpen();
has become
sf::Window::isOpen();
If with new versions of SFML, you’ve been getting lots of errors like
XXX is not a member of class YYY
then this is probably why! I know it might be a pain to refactor all your code, but unfortunately if you want to keep up to date with SFML (and you should
) then you have no choice.
SFML 2.0 Release Candidate
Hi all! Sorry then new posts still haven’t come through. I am working on it, but things are still very very hectic. Anyway, some good news in the mean time! SFML 2.0 Release Candidate is out! So it’s just going through a last phase of testing and minor changes before release. That means two main things for us:
- prebuilt binaries on the official site (I think I’ll still provide them until the final release is out)
- few (if any) public interface changes, so no more problems with tutorials becoming outdated due to new function names, etc.
If you want to try it, head over to the SFML downloads page and get it right away.
More Restructuring
Okay, a quick update on the site’s pending rearrangement. Firstly, tutorials are in fact going to stay as posts, not pages. I decided I didn’t want a static front page, but I don’t want general “blog” content on the front page either, so thing’s will have to stay as they are. Secondly, I’m finding more and more as I write tutorials that I have to bother going into detail about which software to install and so on and so forth. This is not only time consuming for me, but also probably annoying for the majority of you who have the software already. But I have a solution: I’m going to write a few new posts about setting up “development environments” on Windows and Unix. Then, when I do a tutorial, I’ll just assume you’ve done all the setup in the other post. In fact, I’m thinking I might more generally put a little “prerequisites” and “recommended reading” section at the top of each tutorial. That way, we can focus on the new stuff, but all the background material is easily available to those who need it.
Summary of Content
Naturally there’ll be one for Windows and one for Linux/Unix, each with various subsections. Now, I don’t want to spend too long writing these setup tutorials, but I do want to keep everyone happy
So here’s a quick list of what I’ll cover in each one – lot me know if there’s anything you really want added!
Windows
- Visual C++
- MinGW
- Code::Blocks
- MSYS
Linux/Unix
- GCC
- Code::Blocks
- Text editor (e.g. vim)
Generic
- CMake
- Doxygen
- Git
- Subversion
These last few will be covered in both tutorials, although the specifics will be a little different of course.
Poised to Overclock
Right. Unfortunately I just haven’t had the time to write any posts about building Boost today… The computer’s been out of action all day so far as I’ve been replacing my broken motherboard and installing my after market heatsink and fan, which I I mentioned a few days back. So instead, I’ll just share a few words about that and Boost can wait until tomorrow.
I can certainly say that the fan is really, really quiet, and temperatures appear to be lower than with the stock cooler (I say stock – it certainly looks like Intel’s socket 775 stock cooler, but the fan has an Akasa sticker…). I haven’t had a chance to do any temperature readings under stress yet, so we’ll see how things go. When I have a chance I’ll be trying a little light overclocking too so I’ll let you know how that goes… I’m hoping to get my 2.83Ghz CPU up to a stable 3.4, but I haven’t overclocked before so I don’t know if that’s realistic with my relatively cheap cooler.
At present, I am just reinstalling all my Windows software. I’m hoping to have a minute to play around with ASUS Express Gate, since it appears not to be working out of the box… And then? Well it’s coming up to midnight local time and yet I’m still hoping to not only reinstall Linux Mint, but also successfully install Gentoo (which involves compiling my own kernel
). Still, I’ll see how things go, and I’ll try to sleep a little bit before my early start tomorrow…
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
- Boost Program Options – read program options from the command line and from config files
- Boost Filesystem – manipulate files and directories
- Boost Lexical Cast – safely and seamlessly convert the integer 5 to the string literal “5″ and back again
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!
Plans
Hi all! I’m currently enjoying my Easter break so – although there’s still a lot of work to do – I am more free than I have been for a while. Now, I would have liked to be uploading videos by now, but unfortunately that won’t be possible. Due to an annoying problem with my motherboard (it won’t detect the graphics card), I’m stuck with the awful integrated chip. Consequently, everything’s running really slowly. I certainly don’t want to try screen capture or 3D graphics (that’s right, I’m finally going to give my videos an intro sequence!).
Anyway, the replacement motherboard has arrived, as has my new budget CPU cooler, but I’m still waiting on the Arctic Silver thermal paste and solvents from Amazon… Don’t judge my choice of mainboard, by the way. I didn’t want to let my socket 775 Core 2 Quad (4 x 2.83Ghz stock) go just yet, so I had little choice. I got it really cheap, so it hardly matters anyway. But I digress… the upshot is, it’ll only be a few more days’ delay, hopefully.
In the mean time, I’ve decided the site needs a little overhaul. I think tutorials should be put up as pages not posts, so they don’t get lost behind random links and stuff that I post. So I’ll have a play around with settings and see what works. (I also realised recently that the menus at the top of the site no longer work because of the search box – I’ll see to that as well…)
From now on, the only things I’ll put in posts will be items which really class as “blog” material. Short tips, tech news, pointers to cool websites and videos, and so on. But obviously you do want to keep up with tutorials here at SFMLCoder too so when I release a new tutorial, I’ll make a post as well, but it’ll just provide a summary and link to the full tutorial. Yet another reason to subscribe by email – you’ll get tutorial summaries straight to your inbox!
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.
Raspberry Pi!
Chances are you’ve all heard about this great new project already. If not, it’s basically a (very basic) computer system, all on a single circuit board about the size of a credit card. It runs on an ARM CPU at 700MHz, but it also has a respectable video chip which can apparently cope with 1080p video. Video output is by HDMI or composite video. It has 256Mb RAM. As yet, only the “development version” is available. It comes case free: you just get a board with all the components sitting exposed on it. But hey, all the better for modding, right?
Oh, and did I mention - it’s selling for around £21/$35! That’s excluding sales tax, but still.
There’s no permanent storage on the PI. However, the version currently shipping sports 2 USB ports, an ethernet connection and an SD card slot. Booting is necessarily via the SD card: right now you need to image your own; when the “educational” version of the Pi comes out later this year, you’ll be able to get cards preinstalled with Debian and some other tools.
Otherwise, the Wiki is there to help, with growing instructions including the way to cross compile various Linux Distros on your main PC to run on the Pi’s ARM processor. When it comes to choosing an SD card, I’ve read that class 4/6 is the best choice (they are better than class 10 for lots of small files, and class 10 has issues with the Linux kernel). I’m planning on either an Integral or Transcend 8GB class 6.
Right now, it’s still difficult to get hold of the things. You just have to register your interest with one of the suppliers – Farnell Element 14 or RS Components. Then you’ll hear from them at the first possible opportunity. And due to the overwhelming popularity of the Pi (I heard Farnell sold out their initial stock within 3 minutes of availability), you should sign up for emails from both of them as soon as possible!
You may still be wondering if it’s worth the effort, low price tag or not. Well tomorrow, I’ll post again, and mention a few of the things you can (or can’t) do with it. And if you want to read more about it, head over the official website (or, of course, Wikipedia).
And in case you’re wondering. Yes. I have already pre-ordered mine
Sign up now for new SFML Binaries!
Later on today, I’ll be sending out some updated SFML binaries for Windows. Not only that, there’s going to be a brand new script for installing SFML on Unix (in particular, Ubuntu/Linux Mint, but I’m sure a little modification will have it running elsewhere). If you want to be the first to get hold of all this, remember to subscribe by email if you haven’t yet. Otherwise, they’ll be added to the downloads page in a few days.
