1 //          Copyright Michael D. Parker 2018.
2 // Distributed under the Boost Software License, Version 1.0.
3 //    (See accompanying file LICENSE_1_0.txt or copy at
4 //          http://www.boost.org/LICENSE_1_0.txt)
5 
6 module bindbc.sfml;
7 
8 public import bindbc.sfml.config,
9               bindbc.sfml.system;
10 static if(bindSFMLAudio) public import bindbc.sfml.audio;
11 static if(bindSFMLGraphics) public import bindbc.sfml.graphics;
12 static if(bindSFMLNetwork) public import bindbc.sfml.network;
13 static if(bindSFMLWindow) public import bindbc.sfml.window;
14 
15 static if(!staticSFML):
16 /**
17     A convenience function that attempts to load all configured SFML binding.
18 
19     This function will always call `loadSFMLSystem` and will call the load function
20     of every binding that is configured. If `SFML_Graphics` is configured, both
21     `loadSFMLWindow` and `loadSFMLGraphics` will be called. This function will
22     return false as soon as one of the load functions returns `SFMLSupport.noLibrary`
23     or `SFMLSupport.badLibrary`.
24 
25     There is no variation of this function allowing for alternative shared library
26     file names.
27 
28     Returns: `true` if all libraries loaded successfully, `false` if any library
29     failed to load.
30 */
31 bool loadSFML() {
32     bool isBad(SFMLSupport val) {
33         return val == SFMLSupport.noLibrary || val == SFMLSupport.badLibrary;
34     }
35 
36     auto ret = loadSFMLSystem();
37     if(isBad(ret)) return false;
38 
39     static if(bindSFMLAudio) {
40         ret = loadSFMLAudio();
41         if(isBad(ret)) return false;
42     }
43     static if(bindSFMLNetwork) {
44         ret = loadSFMLNetwork();
45         if(isBad(ret)) return false;
46     }
47     static if(bindSFMLWindow) {
48         ret = loadSFMLWindow();
49         if(isBad(ret)) return false;
50     }
51     static if(bindSFMLGraphics) {
52         ret = loadSFMLGraphics();
53         if(isBad(ret)) return false;
54     }
55 
56     return true;
57 }