Archive
Building SFML 2.0 with Make (GCC/Ubuntu)
I’ve now demonstrated how to build the SFML 2.0 binaries in an IDE and also with a build utility (better). However, all my tutorials have undoubtedly been Windows centric – I discussed Microsoft Visual C++ and MinGW, after all. Well now it’s time to make that right – in this article I’m going to explain how to build the latest versions of the SFML 2.0 binaries for Ubuntu, using GCC.
Other Unix Operating Systems
With the addition of the post, I’ve covered Windows – both MinGW and MSVC – and also GCC on Ubuntu, Linux Mint, Debian or an Ubuntu variant such as Xubuntu. But what about the rest of you? What if you’re on another Unix operating system? Well, the fact is that you should still have access to GCC. This means you should be able to invoke the actual build operation with the same commands. The other software we need – CMake – should also be available for most platforms. Thus the core elements of what I demonstrate here for GCC with Ubuntu should be applicable to GCC with other Unix platforms.
The thing that you will have to bear in mind, however, is that the other terminal commands I use (such as apt-get to install software) may not be available on your system. You may have a different terminal, and different package manager which is invoked via a different command and syntax. If you want to follow this tutorial, you’ll have to translate those commands into ones appropriate for your OS. Just remember that the invocation of cmake and make should be the same in most circumstances.
The Video
Read on the for textual tutorial. I suggest that even those of you who prefer videos read this one, as we’ll be working primarily with the terminal: something which is undoubtedly easier to talk about in writing. Read more…
Building SFML 2.0 with MinGW Make
In this tutorial I’m going to show you how to build the SFML 2.0 binaries from the source using MinGW Make, that is the MinGW make utility.
The Video
Read on for the textual tutorial. Even if you watch the video, it’s worth a look at the text as we will be using console commands.
Building SFML 2.0 with NMake (for Visual Studio)
In this tutorial I’m going to show you how to build the SFML 2.0 binaries from the source using NMake, that is the Visual Studio make utility. Here is a Windows batch file which should build SFML for you. Of course, it’s best to read the tutorial anyway as it will introduce you to CMake and NMake – two very useful development tools.
The Video
Read on for the textual tutorial. Even if you watch the video, it’s worth a look as we will be using console commands.
Empty Window: A Minimal SFML Application
This is the first of my SFML tutorials. In it I provide and explain a minimal SFML application which opens a moveable window and waits to be closed. We will build on this in each subsequent tutorial.
I’ll assume you’ve already got the SFML 2.0 binaries set up on your computer, and that you know how to create a project file in your IDE which uses SFML 2.0. If you are unsure about any of these steps, see my earlier posts, or watch some of the setup videos on my YouTube channel.
Here’s the video for this tutorial:
Creating a first SFML Project
In my last post, I provided videos to show you how to build SFML 2.0 from the source in Visual Studio or Code::Blocks. I also provided some general textual instructions for the same purpose.
Well today I present to you two more videos: this time on how to make a first project using SFML 2.0 in Visual Studio or Code::Blocks. This will include configuring search directories and adding libraries to the linker list, as well as compiling some sample code.
Following are some basic textual instruction on this process. It is split into three sections:
- Visual Studio/Visual C++
- Code::Blocks
- General (this applies to both, and hopefully other IDEs too) Read more…
Building SFML 2.0
| Note: this tutorial is deprecated. Please take a look at one of my new ones, either for Visual C++/NMake (Windows), MinGW (Windows) or GCC/Make (Ubuntu/other Unix). |
To set up SFML 2.0, there are a number of steps. If you want, you can watch SFML 2.0 build video for Code::Blocks, or for Visual Studio.
Otherwise, I shall outline the necessary steps here, before providing a few more details where necessary.
- Download CMake from the website, or go straight to the download page.
- Download the SFML 2.0 source, unzip the file, move it to an accessible location and rename the folder.
- Create a solution file for your IDE using CMake, setting BUILD_SHARED_LIBS to TRUE.
- Take note of the value of STATIC_STD_LIBS, as you must link the C runtime to your project in the same manner as it is linked to the SFML binaries
- Open the solution file in your IDE and build SFML 2.0 in Debug and Release configuration (if your IDE supports multiple configurations).
- Repeat steps 3 & 4, with BUILD_SHARED_LIBS set to false.
- If your IDE does not support multiple configurations, repeat steps 3 – 5, setting.
- Copy and paste the resulting libraries to a better location: put them all in a lib subdirectory of your main SFML 2 directory: c:/sfml/sfml2.
Read more…
Structuring an Engine
So, I have previously mentioned that we’ll be making a game engine, and I have put some resource management code up as well.
Now I don’t want to get into too much detail with the engine until we’ve seen a little more of SFML, but perhaps it would be nice if I gave you a vague idea of what I’m planning.
Well the first version of my engine will contain the following components:
- system
- graphics
- audio
- input Read more…
Tools of the Trade
So then. It’s time to pick our tools. You know we’re using everyone’s favourite object oriented language, C++
Assuming you’re familiar with C, you’ll know that we need at the least a compiler and linker, and preferably a whole IDE too. I suggest using Visual C++ 2010 Express edition if you’re on Windows. It’s free and has pretty good code prediction and correction features. It is also known for having a good debugger. Of course, you’re free to use another IDE if you’d prefer, or for example if you’re running a non Windows OS. If you cannot or do not want to use Visual C++ Express, then I would recommend Code::Blocks as another good choice.
I’m sure you could find the IDE via Google or some other search engine, but here’s a link anyway. http://www.microsoft.com/express/Downloads/#2010-Visual-CPP. If you want to find Code::Blocks, it’s at http://www.codeblocks.org.
Now for our library. I’ve already touched on this so you may now be aware we’re using SFML, the Simple and Fast Media Library. You can find it on the website at http://www.sfml-dev.org/. We’ll be using SFML 2.0, the most up to date version. It’s still in development and there are no official binaries yet, but don’t worry – it’s not too difficult to build them yourself (and I’ll be guiding you through the process). Therefore we shall be downloading the latest version of SFML 2.0 from GitHub.
Documentation
I’ll only be explaining the features of the library which I am using. If you want more detailed explanation then you may find it quite hard to find tutorials on the internet (although I’m sure there are some by now). However, you will find a comprehensive tutorial on the official website, along with doxygen generated documentation. This tutorial is for SFML 1.6, but there is as yet, no SFML 2.0 tutorial. I recommend you use the SFML 1.6 tutorial and use the documentation to bridge the gap between the two. You can, of course, also ask me any questions on this issue.
Well that’s all for today. Next time I’ll guide you through the process of building the SFML library yourself in Visual Studio. Then we’ll briefly discuss what an SFML project needs to work along with some other simple steps to get SFML set up for easiest usage.
Note: SFML License
Remember that SFML is under a license, if a very liberal one. It’s up to you to make sure you’re usage of SFML and any other libraries we use later conform to their respective licenses. Here’s a link to the SFML license - you may as well take a look as it’s comparatively short by many licenses’ standards.
What is to be done?
So now what? As you may have guessed from the title, the programming library I have chosen is SFML – the Simple and Fast Media Layer. But there’s one more thing we need to sort before we get down to specifics, so you’ll just have to wait a little longer…
The fact is that we need a plan. I’ve tried making a game engine before without a big plan and it just rambles on and on. We need to decide what we want before we start. Of course we can change it later if we need to, but an initial plan will keep us in the right direction. It’ll ensure we add all the essential features, and also stop us adding to many additional features without good reason. (It may not sound like a bad idea to continuously add new little features as you’re developing the engine, but if you don’t draw a boundary somewhere, then how will you know when to stop, and move on to the next engine component?) Maybe you have just thought of a cool new effect for your physics system. But it’ll just have to wait! Planning is everything… apart from the coding, of course
Planning
Right. It’s time to ask the Leninist question. What is to be done? We know we want to make a game. But how will we go about it? Well. Before we make a game, we need the means to make it. That is, we need a game engine. This engine will provide basic features like loading pictures, sounds and animations as well as playing them and processing input. As we go, we’ll add more features, though – as I suggested above – at a controlled rate!
First we’re going to make a 2D game engine with basic graphics, sound and input. We’ll be testing it along the way and when we’re done, we’ll write a short 2D game demo to showcase our new engine. Then I hope to tweak it a bit and finally move on to some more complicated stuff. At this stage, we’ll take a breather and look back at what we’ve done. We’ll review the engine’s capabilities and make sure there isn’t anything else we want to add to existing engine components.
That done, we will want to add 3D graphics and, if we’re feeling ambitious, perhaps we could finish things off with AI and physics. Then at last, we’ll be ready to make a full game. That’s enough planning for now – we’ll talk more about this game later. The best thing about doing things this way is that when we’re done we can reuse the engine for another game! Great!
Outline
- Core game engine
- Graphics
- Sound
- Input
- Our first (2D) game
Well as you saw above, there’s a lot more to it than that, but let’s leave our plan simple for now, eh? In my next post’s I’ll introduce our tools and then we’ll actually get to some coding. I’m going to do some sample applications and perhaps a very short (but complete) game such as noughts and crosses or battleships. Then, we can at last begin to design, implement and debug each engine component, step by step.
See you next time!
My Audience
So who am I writing this for? Well. Anyone is free to take a look, but I will assume familiarity with programming, in particular programming in C++. If you’re happy with C++ then great! But don’t worry if you’re not. There’s still time to learn! There’s plenty out there: you can try the textual tutorial on cplusplus.com, or the video primer series I have put on youtube.
So. You’re happy with C++. What else will you need? Well we’ll be using and IDE (integrated development environment) an it would be best if you knew how to use it beforehand. Otherwise, my video tutorials will get you started, and further videos I might release with blog posts, may illustrate particular post specific details.
Of course, the blog is all about how to write a game engine and eventually a game, so I won’t assume any familiarity with the actual constructs involved.
