Giter VIP home page Giter VIP logo

sfml-game-development-book's Introduction

#####################
SFML Game Development
Code Base
#####################

This file explains how to build the code accompanying the book SFML Game Development.

There are 10 directories that correspond to each of the chapters in the book. For example, 02_Resources contains the code for Chapter 2. The code for all chapters can be built at once.


================
I. Install CMake
================
Install CMake, preferably CMake-GUI (www.cmake.org or the cmake-gui package in Linux).


================
II. Install SFML
================
Download SFML 2 (www.sfml-dev.org). We recommend using a precompiled version of SFML which can be directly downloaded. 

It is also possible to build SFML yourself, in this case make sure that it is *installed* (make install, or compile the INSTALL project). Refer to the online tutorials for more details.

Eventually, you should have a directory with at least the subdirectories "include" and "lib" that contain headers and binaries of the SFML library, for example C:\SFML in Windows or /usr/local in Linux.


=====================================
III. Generate the build configuration
=====================================
1. Start cmake-gui.

2. In the field "Where is the source code", enter the path of the directory containing this ReadMe.txt file. Use forward slashes.

3. In the field "Where to build the binaries", enter a different path, where you want the intermediate build files of the book's code to be generated.

4. Click "Configure" and choose your compiler.

5. After, an error message might appear, telling that SFML is not found. This is intended. In order to fix it, enter the path to SFML in the field next to the SFML_ROOT variable. This is the directory mentioned in step II with the "lib" and "include" subdirectories (e.g. C:/SFML or /usr/local).

6. Choose your build configuration by setting CMAKE_BUILD_TYPE to either "Release" or "Debug". We recommend "Release" (it should be the default).

7. In Windows, check the box next to SFML_STATIC_LIBRARIES if you want to link SFML statically. Leave it unchecked if you prefer linking SFML dynamically and using DLL files.

8. Set the CMAKE_INSTALL_PREFIX to the path where you want the executables of the book's code to be installed. Choose a different directory (it can be a subdirectory of this one).

9. Click again "Configure". Now, there should be no more error messages.

10. Click "Generate".


====================
IV. Compile the code
====================
1. Switch to the build directory (the one you entered in "Where to build the binaries").

2. Now you should see the files required to compile the code. 

   For g++ or clang, this will be a Makefile. In the terminal, type "make install".
   If you use MinGW on Windows, you might have to type "mingw32-make install" instead.

   For Visual Studio, you will see a .sln solution. Open it, choose the correct build configuration ("Release" or "Debug") and build the INSTALL project.
   
   For other integrated development environments, it will be similar. Compile the INSTALL project.

3. After compiling, the executables and media files should be output to the directory you specified with CMAKE_INSTALL_PREFIX.


==========
V. Results
==========
The executables for each chapter are located in the install directory (CMAKE_INSTALL_PREFIX).

If you like to inspect the code itself, the current directory comes with 10 subdirectories, each containing the source and header files of the corresponding chapter. Also, the media files can be found for each chapter.

sfml-game-development-book's People

Contributors

bromeon avatar groogy avatar laurentgomila avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sfml-game-development-book's Issues

SFML High DPI

Not an issue, just a question.
SFML don't support high dpi and the only solution right now is to set NSHighResolutionCapable to false, that way we get low resolution but the actual window size.
I'm not really interested in making my own games, but I'm very interested in reading this book!
Is there a way that you can edit CMakeList to support creating an app bundle for OSX?

Right now I'm on a MacBook Pro and it is imposible to work through the book, sadly I don't have the knowledge to edit the CMake files myself and share it with other people.

Thanks!

Command.hpp - derivedAction wont compile in VS2013 Express

template <typename GameObject, typename Function>
Command::Action derivedAction(Function fn)
{
    return [=] (SceneNode& node, sf::Time dt)
    {
        // Check if cast is safe
        assert(dynamic_cast<GameObject*>(&node) != nullptr);

        // Downcast node and invoke function on it
        fn(static_cast<GameObject&>(node), dt);
    };
}

This function produces a compiler error C3848 in VS2013 Express on Windows 7.
It's line 33

fn(static_cast<GameObject&>(node), dt);

a non-const function is invoked by const function

No virtual destructor in SceneNode

No SceneNode class contains a virtual destructor declaration, while it is a base class with many other virtual functions. I suppose it is a bug, causing memory leaks.

CMake compatibility issues

get this warning when configuring cmake:

CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.

Editing CMakeLists.txt:2 to "cmake_minimum_required(VERSION 2.8...3.5)" prevents the error message,
but the compatibility issues are not solves.

At the SFML-Game-Development-Book-master\CMake directory there is a FindSFML.cmake file,
which is said to no longer be supported anymore, but rather SFMLConfig.cmake is now used instead.

Brightness.frag fails to load visual studio 2017

sample code compiled with visual studio 2017 fails to load shader, to fix change Brightness.frag line 12
from:
sourceFragment *= clamp(luminance - Threshold, 0.0, 1.0) * Factor;
to:
sourceFragment *= clamp(luminance - Threshold, 0.f, 1.f) * Factor;

CMake script and SFML_ROOT

The CMake script provides the SFML_ROOT variable to provide the location of SFML when installed outside of the system's default locations. However, find_path() is implemented to look in system default location first, and looks in the custom paths provided in PATHS only if no match is found in the system default. This means that if the system contains a version of SFML but the user has a (supposedly newer) version manually installed somewhere else that they want to use instead, the (older) system version will always be picked first.

To fix this, I would suggest specifying SFML_ROOT in HINTS instead of PATHS. Indeed, contrary to PATHS, HINTS are looked up before the system locations.

# find the SFML include directory
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
          PATH_SUFFIXES include
          HINTS ${SFML_ROOT} $ENV{SFML_ROOT}
          PATHS ${FIND_SFML_PATHS})

The same should then be done for the find_library() calls, and SFML_ROOT should be removed from FIND_SFML_PATHS.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.