├── .github └── FUNDING.yml ├── .gitignore ├── dub.sdl ├── LICENSE_1_0.txt ├── source └── bindbc │ └── sfml │ ├── config.d │ ├── package.d │ ├── system.d │ ├── window.d │ ├── audio.d │ └── network.d └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: BindBC 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib 2 | dub.selections.json 3 | .dub 4 | dscanner.ini 5 | *.kate-swp 6 | .directory 7 | .DS_Store 8 | -------------------------------------------------------------------------------- /dub.sdl: -------------------------------------------------------------------------------- 1 | name "bindbc-sfml" 2 | description "Static & dynamic bindings to the SFML2 libraries, compatible with BetterC, @nogc, and nothrow." 3 | authors "Mike Parker" 4 | license "BSL-1.0" 5 | 6 | targetType "staticLibrary" 7 | targetPath "lib" 8 | targetName "BindBC_SFML" 9 | 10 | configuration "dynamic" { 11 | dependency "bindbc-loader" version="~>1.1.0" 12 | } 13 | 14 | configuration "dynamicBC" { 15 | dependency "bindbc-loader" version="~>1.1.0" 16 | subConfiguration "bindbc-loader" "yesBC" 17 | buildOptions "betterC" 18 | } 19 | 20 | configuration "static" { 21 | versions "BindSFML_Static" 22 | excludedSourceFiles "source/bindbc/sfml/dynload.d" 23 | } 24 | 25 | configuration "staticBC" { 26 | versions "BindSFML_Static" 27 | buildOptions "betterC" 28 | excludedSourceFiles "source/bindbc/sfml/dynload.d" 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE_1_0.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /source/bindbc/sfml/config.d: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2020 - 2021 Michael D. Parker 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | module bindbc.sfml.config; 8 | 9 | enum SFMLSupport{ 10 | noLibrary, 11 | badLibrary, 12 | sfml200 = 2_0_0, 13 | sfml210 = 2_1_0, 14 | sfml220 = 2_2_0, 15 | sfml230 = 2_3_0, 16 | sfml240 = 2_4_0, 17 | sfml250 = 2_5_0, 18 | sfml252 = 2_5_2, 19 | } 20 | 21 | version(BindBC_Static) version = BindSFML_Static; 22 | version(BindSFML_Static) enum staticSFML = true; 23 | else enum staticSFML = false; 24 | 25 | version(SFML_250) enum sfmlSupport = SFMLSupport.sfml250; 26 | else version(SFML_240) enum sfmlSupport = SFMLSupport.sfml240; 27 | else version(SFML_230) enum sfmlSupport = SFMLSupport.sfml230; 28 | else version(SFML_220) enum sfmlSupport = SFMLSupport.sfml220; 29 | else version(SFML_210) enum sfmlSupport = SFMLSupport.sfml210; 30 | else enum sfmlSupport = SFMLSupport.sfml200; 31 | 32 | version(SFML_Audio) enum bindSFMLAudio = true; 33 | else enum bindSFMLAudio = false; 34 | 35 | version(SFML_Network) enum bindSFMLNetwork = true; 36 | else enum bindSFMLNetwork = false; 37 | 38 | version(SFML_Graphics){ 39 | version = SFML_Window; 40 | enum bindSFMLGraphics = true; 41 | } 42 | else enum bindSFMLGraphics = false; 43 | 44 | version(SFML_Window) enum bindSFMLWindow = true; 45 | else enum bindSFMLWindow = false; 46 | 47 | enum expandEnum(EnumType, string fqnEnumType = EnumType.stringof) = (){ 48 | string expandEnum = "enum{"; 49 | foreach(m;__traits(allMembers, EnumType)){ 50 | expandEnum ~= m ~ " = " ~ fqnEnumType ~ "." ~ m ~ ","; 51 | } 52 | expandEnum ~= "}"; 53 | return expandEnum; 54 | }(); 55 | -------------------------------------------------------------------------------- /source/bindbc/sfml/package.d: -------------------------------------------------------------------------------- 1 | // Copyright 2020 - 2021 Michael D. Parker 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, bindbc.sfml.system; 9 | static if(bindSFMLAudio) public import bindbc.sfml.audio; 10 | static if(bindSFMLGraphics) public import bindbc.sfml.graphics; 11 | static if(bindSFMLNetwork) public import bindbc.sfml.network; 12 | static if(bindSFMLWindow) public import bindbc.sfml.window; 13 | 14 | static if(!staticSFML): 15 | /** 16 | A convenience function that attempts to load all configured SFML binding. 17 | 18 | This function will always call `loadSFMLSystem` and will call the load function 19 | of every binding that is configured. If `SFML_Graphics` is configured, both 20 | `loadSFMLWindow` and `loadSFMLGraphics` will be called. This function will 21 | return false as soon as one of the load functions returns `SFMLSupport.noLibrary` 22 | or `SFMLSupport.badLibrary`. 23 | 24 | There is no variation of this function allowing for alternative shared library 25 | file names. 26 | 27 | Returns: `true` if all libraries loaded successfully, `false` if any library 28 | failed to load. 29 | */ 30 | bool loadSFML(){ 31 | bool isBad(SFMLSupport val){ 32 | return val == SFMLSupport.noLibrary || val == SFMLSupport.badLibrary; 33 | } 34 | 35 | auto ret = loadSFMLSystem(); 36 | if(isBad(ret)) return false; 37 | 38 | static if(bindSFMLAudio){ 39 | ret = loadSFMLAudio(); 40 | if(isBad(ret)) return false; 41 | } 42 | static if(bindSFMLNetwork){ 43 | ret = loadSFMLNetwork(); 44 | if(isBad(ret)) return false; 45 | } 46 | static if(bindSFMLWindow){ 47 | ret = loadSFMLWindow(); 48 | if(isBad(ret)) return false; 49 | } 50 | static if(bindSFMLGraphics){ 51 | ret = loadSFMLGraphics(); 52 | if(isBad(ret)) return false; 53 | } 54 | 55 | return true; 56 | } 57 | -------------------------------------------------------------------------------- /source/bindbc/sfml/system.d: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2020 - 2021 Michael D. Parker 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | module bindbc.sfml.system; 8 | 9 | import bindbc.sfml.config; 10 | 11 | // Config.h 12 | enum CSFML_VERSION_MAJOR = 2; 13 | 14 | static if(sfmlSupport == SFMLSupport.sfml252){ 15 | enum CSFML_VERSION_MINOR = 5; 16 | enum CSFML_VERSION_PATCH = 2; 17 | }else static if(sfmlSupport == SFMLSupport.sfml250){ 18 | enum CSFML_VERSION_MINOR = 5; 19 | enum CSFML_VERSION_PATCH = 0; 20 | }else static if(sfmlSupport == SFMLSupport.sfml240){ 21 | enum CSFML_VERSION_MINOR = 4; 22 | enum CSFML_VERSION_PATCH = 0; 23 | }else static if(sfmlSupport == SFMLSupport.sfml230){ 24 | enum CSFML_VERSION_MINOR = 3; 25 | enum CSFML_VERSION_PATCH = 0; 26 | }else static if(sfmlSupport == SFMLSupport.sfml220){ 27 | enum CSFML_VERSION_MINOR = 2; 28 | enum CSFML_VERSION_PATCH = 0; 29 | }else static if(sfmlSupport == SFMLSupport.sfml210){ 30 | enum CSFML_VERSION_MINOR = 1; 31 | enum CSFML_VERSION_PATCH = 0; 32 | }else{ 33 | enum CSFML_VERSION_MINOR = 0; 34 | enum CSFML_VERSION_PATCH = 0; 35 | } 36 | 37 | alias sfBool = int; 38 | enum sfFalse = 0; 39 | enum sfTrue = 1; 40 | 41 | alias sfInt8 = byte; 42 | alias sfUint8 = ubyte; 43 | alias sfInt16 = short; 44 | alias sfUint16 = ushort; 45 | alias sfInt32 = int; 46 | alias sfUint32 = uint; 47 | alias sfInt64 = long; 48 | alias sfUint64 = ulong; 49 | 50 | //System/Types.h 51 | struct sfClock; 52 | struct sfMutex; 53 | struct sfThread; 54 | 55 | //System/InputStream.h 56 | extern(C) nothrow{ 57 | alias sfInputStreamReadFunc = sfInt64 function(void*, sfInt64, void*); 58 | alias sfInputStreamSeekFunc = sfInt64 function(sfInt64, void*); 59 | alias sfInputStreamTellFunc = sfInt64 function(void*); 60 | alias sfInputStreamGetSizeFunc = sfInt64 function(void*); 61 | } 62 | 63 | struct sfInputStream{ 64 | sfInputStreamReadFunc read; 65 | sfInputStreamSeekFunc seek; 66 | sfInputStreamTellFunc tell; 67 | sfInputStreamGetSizeFunc getSize; 68 | void* userData; 69 | } 70 | 71 | //System/Thread.h 72 | /* This is not declared in the C header. It's solely for simplifying 73 | the declaration of sfThread_Create in the binding */ 74 | extern(C) alias sfThreadFunc = void function(void*) nothrow; 75 | 76 | //System/Time.h 77 | struct sfTime{ 78 | sfInt64 microseconds; 79 | } 80 | 81 | immutable(sfTime) sfTime_Zero; 82 | 83 | //System/Vector2.h 84 | struct sfVector2i{ 85 | int x, y; 86 | } 87 | 88 | struct sfVector2u{ 89 | uint x, y; 90 | } 91 | 92 | struct sfVector2f{ 93 | float x, y; 94 | } 95 | 96 | //System/Vector3.h 97 | struct sfVector3f{ 98 | float x, y, z; 99 | } 100 | 101 | static if(staticSFML){ 102 | extern(C) @nogc nothrow{ 103 | //System/Clock.h 104 | sfClock* sfClock_create(); 105 | sfClock* sfClock_copy(const(sfClock)* clock); 106 | void sfClock_destroy(sfClock* clock); 107 | sfTime sfClock_getElapsedTime(const(sfClock)* clock); 108 | sfTime sfClock_restart(sfClock* clock); 109 | 110 | //System/Mutex.h 111 | sfMutex* sfMutex_create(); 112 | void sfMutex_destroy(sfMutex* mutex); 113 | void sfMutex_lock(sfMutex* mutex); 114 | void sfMutex_unlock(sfMutex* mutex); 115 | 116 | //System/Sleep.h 117 | void sfSleep(sfTime duration); 118 | 119 | //System/Thread.h 120 | sfThread* sfThread_create(sfThreadFunc _function,void* userData); 121 | void sfThread_destroy(sfThread* thread); 122 | void sfThread_launch(sfThread* thread); 123 | void sfThread_wait(sfThread* thread); 124 | void sfThread_terminate(sfThread* thread); 125 | 126 | //System/Time.h 127 | float sfTime_asSeconds(sfTime time); 128 | sfInt32 sfTime_asMilliseconds(sfTime time); 129 | sfInt64 sfTime_asMicroseconds(sfTime time); 130 | sfTime sfSeconds(float amount); 131 | sfTime sfMilliseconds(sfInt32 amount); 132 | sfTime sfMicroseconds(sfInt64 amount); 133 | } 134 | }else{ 135 | import bindbc.loader; 136 | 137 | extern(C) @nogc nothrow{ 138 | //System/Clock.h 139 | alias psfClock_create = sfClock* function(); 140 | alias psfClock_copy = sfClock* function(const(sfClock)* clock); 141 | alias psfClock_destroy = void function(sfClock* clock); 142 | alias psfClock_getElapsedTime = sfTime function(const(sfClock*) clock); 143 | alias psfClock_restart = sfTime function(sfClock* clock); 144 | 145 | //System/Mutex.h 146 | alias psfMutex_create = sfMutex* function(); 147 | alias psfMutex_destroy = void function(sfMutex* mutex); 148 | alias psfMutex_lock = void function(sfMutex* mutex); 149 | alias psfMutex_unlock = void function(sfMutex* mutex); 150 | 151 | //System/Sleep.h 152 | alias psfSleep = void function(sfTime duration); 153 | 154 | //System/Thread.h 155 | alias psfThread_create = sfThread* function(sfThreadFunc _function,void* userData); 156 | alias psfThread_destroy = void function(sfThread* thread); 157 | alias psfThread_launch = void function(sfThread* thread); 158 | alias psfThread_wait = void function(sfThread* thread); 159 | alias psfThread_terminate = void function(sfThread* thread); 160 | 161 | //System/Time.h 162 | alias psfTime_asSeconds = float function(sfTime time); 163 | alias psfTime_asMilliseconds = sfInt32 function(sfTime time); 164 | alias psfTime_asMicroseconds = sfInt64 function(sfTime time); 165 | alias psfSeconds = sfTime function(float); 166 | alias psfMilliseconds = sfTime function(sfInt32); 167 | alias psfMicroseconds = sfTime function(sfInt64); 168 | } 169 | 170 | __gshared{ 171 | psfClock_create sfClock_create; 172 | psfClock_copy sfClock_copy; 173 | psfClock_destroy sfClock_destroy; 174 | psfClock_getElapsedTime sfClock_getElapsedTime; 175 | psfClock_restart sfClock_restart; 176 | psfMutex_create sfMutex_create; 177 | psfMutex_destroy sfMutex_destroy; 178 | psfMutex_lock sfMutex_lock; 179 | psfMutex_unlock sfMutex_unlock; 180 | psfSleep sfSleep; 181 | psfThread_create sfThread_create; 182 | psfThread_destroy sfThread_destroy; 183 | psfThread_launch sfThread_launch; 184 | psfThread_wait sfThread_wait; 185 | psfThread_terminate sfThread_terminate; 186 | psfTime_asSeconds sfTime_asSeconds; 187 | psfTime_asMilliseconds sfTime_asMilliseconds; 188 | psfTime_asMicroseconds sfTime_asMicroseconds; 189 | psfSeconds sfSeconds; 190 | psfMilliseconds sfMilliseconds; 191 | psfMicroseconds sfMicroseconds; 192 | } 193 | 194 | private{ 195 | SharedLib lib; 196 | SFMLSupport loadedVersion; 197 | } 198 | 199 | @nogc nothrow: 200 | SFMLSupport loadedSFMLSystemVersion(){ return loadedVersion; } 201 | 202 | bool isSFMLSystemLoaded(){ 203 | return lib != invalidHandle; 204 | } 205 | 206 | SFMLSupport loadSFMLSystem(){ 207 | version(Windows){ 208 | const(char)[][3] libNames = [ 209 | "csfml-system.dll", 210 | "csfml-system-2.dll", 211 | "csfml-system-2.0.dll" 212 | ]; 213 | }else version(OSX){ 214 | const(char)[][3] libNames = [ 215 | "libcsfml-system.dylib", 216 | "libcsfml-system.2.dylib", 217 | "libcsfml-system.2.0.dylib" 218 | ]; 219 | }else version(Posix){ 220 | const(char)[][3] libNames = [ 221 | "libcsfml-system.so", 222 | "libcsfml-system.so.2", 223 | "libcsfml-system.so.2.0" 224 | ]; 225 | } 226 | 227 | SFMLSupport ret; 228 | foreach(name; libNames){ 229 | ret = loadSFMLSystem(name.ptr); 230 | if(ret != SFMLSupport.noLibrary) break; 231 | } 232 | return ret; 233 | } 234 | 235 | SFMLSupport loadSFMLSystem(const(char)* libName){ 236 | lib = load(libName); 237 | if(lib == invalidHandle){ 238 | return SFMLSupport.noLibrary; 239 | } 240 | 241 | auto errCount = errorCount(); 242 | loadedVersion = SFMLSupport.badLibrary; 243 | 244 | lib.bindSymbol(cast(void**)&sfClock_create,"sfClock_create"); 245 | lib.bindSymbol(cast(void**)&sfClock_copy,"sfClock_copy"); 246 | lib.bindSymbol(cast(void**)&sfClock_destroy,"sfClock_destroy"); 247 | lib.bindSymbol(cast(void**)&sfClock_getElapsedTime,"sfClock_getElapsedTime"); 248 | lib.bindSymbol(cast(void**)&sfClock_restart,"sfClock_restart"); 249 | lib.bindSymbol(cast(void**)&sfMutex_create,"sfMutex_create"); 250 | lib.bindSymbol(cast(void**)&sfMutex_destroy,"sfMutex_destroy"); 251 | lib.bindSymbol(cast(void**)&sfMutex_lock,"sfMutex_lock"); 252 | lib.bindSymbol(cast(void**)&sfMutex_unlock,"sfMutex_unlock"); 253 | lib.bindSymbol(cast(void**)&sfSleep,"sfSleep"); 254 | lib.bindSymbol(cast(void**)&sfThread_create,"sfThread_create"); 255 | lib.bindSymbol(cast(void**)&sfThread_destroy,"sfThread_destroy"); 256 | lib.bindSymbol(cast(void**)&sfThread_launch,"sfThread_launch"); 257 | lib.bindSymbol(cast(void**)&sfThread_wait,"sfThread_wait"); 258 | lib.bindSymbol(cast(void**)&sfThread_terminate,"sfThread_terminate"); 259 | lib.bindSymbol(cast(void**)&sfTime_asSeconds,"sfTime_asSeconds"); 260 | lib.bindSymbol(cast(void**)&sfTime_asMilliseconds,"sfTime_asMilliseconds"); 261 | lib.bindSymbol(cast(void**)&sfTime_asMicroseconds,"sfTime_asMicroseconds"); 262 | lib.bindSymbol(cast(void**)&sfSeconds,"sfSeconds"); 263 | lib.bindSymbol(cast(void**)&sfMilliseconds,"sfMilliseconds"); 264 | lib.bindSymbol(cast(void**)&sfMicroseconds,"sfMicroseconds"); 265 | 266 | loadedVersion = sfmlSupport; 267 | return loadedVersion; 268 | } 269 | } 270 | 271 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecation Warning 2 | These bindings are no longer going to be actively maintained by me in the future. You may submit issues, and I will still review pull requests, but I may not respond to issues in a timely fashion. 3 | 4 | ### Why? 5 | - SFML has a similar feature-set to SDL, which you can already use via [BindBC-SDL](https://github.com/BindBC/bindbc-sdl) if you need a multimedia library. SDL is generally more feature-rich than SFML. 6 | - SFML frequently has breaking changes in patch releases. SDL has breaking changes in major releases only. 7 | - These bindings have been used by very few people, meaning that they may well be a minefield of undiscovered bugs. 8 | - The bindings haven't been updated to use BindBC-Common, so any non-trivial maintenance would require a large pre-requisite amount of work. 9 | 10 | # BindBC-SFML 11 | 12 | This project provides both static and dynamic D bindings to versions 2.0 – 2.5 of the CSFML libraries, which in turn are [the official C bindings](https://www.sfml-dev.org/download/csfml/) to [the SFML game and multimedia libraries](https://www.sfml-dev.org/index.php) written in C++. This package is intended as a replacement of [DerelictSFML2](https://github.com/DerelictOrg/DerelictSFML2). 13 | 14 | ## About CSFML 15 | This documentation describes how to use BindBC-SFML. As the maintainer of this library, I do not provide instructions on using CSFML. However, since these are direct bindings to the CSFML API, then the following quote from the CSFML download page applies (documentation link added by me for convenience): 16 | 17 | > Since the CSFML API is similar to SFML, there's no tutorial for it; but you can follow the C++ tutorials available [on this website](https://www.sfml-dev.org/learn.php), and adapt them to the C API very easily. 18 | 19 | [The CSFML download packages](https://www.sfml-dev.org/download/csfml/) include the C API documentation so that you can easily see how to translate the C++ examples to C, which in turn will be an almost direct translation to D. (In the future, I intend to create a D tutorial series that will use BindBC-SFML.) 20 | 21 | ## Usage 22 | By default, BindBC-SFML is configured to compile as dynamic bindings that are not `-betterC` compatible. The dynamic bindings have no link-time dependency on the CSFML libraries, so the CSFML shared libraries must be manually loaded at runtime. When configured as static bindings, there is a link-time dependency on the CSFML libraries—either the static libraries or the appropriate files for linking with shared libraries on your system (see below). 23 | 24 | When using DUB to manage your project, the static bindings can be enabled via a DUB `subConfiguration` statement in your project's package file. `-betterC` compatibility is also enabled via subconfigurations. 25 | 26 | To use any of the supported CSFML libraries, add BindBC-SFML as a dependency to your project's package file and include the appropriate version for any of the CSFML libraries you want to use. Note that the CSFML System library is always loaded, and when the CSFML Graphics library is configured, the CSFML Window library will be loaded automatically. 27 | 28 | As an example, the following is configured to use the Audio, Graphics, System, and Window libraries via dynamic bindings that are not `-betterC` compatible: 29 | 30 | __dub.json__ 31 | ``` 32 | "dependencies": { 33 | "bindbc-sfml": "~>1.1.0", 34 | }, 35 | "versions": [ 36 | "SFML_Audio", 37 | "SFML_Graphics" 38 | ], 39 | ``` 40 | 41 | __dub.sdl__ 42 | ``` 43 | dependency "bindbc-sfml" version="~>1.1.0" 44 | versions "SFML_Audio" "SFML_Graphics" 45 | ``` 46 | 47 | ### The dynamic bindings 48 | The dynamic bindings require no special configuration when using DUB to manage your project. There is no link-time dependency. At runtime, the CSFML shared libraries are required to be on the shared library search path of the user's system. On Windows, this is typically handled by distributing the CSFML DLLs with your program. On other systems, it usually means installing the SFML runtime libraries through a package manager. 49 | 50 | To load the shared libraries, you need to call the appropriate load function. Each CSFML library binding provides load functions that return a binding-specific value indicating either that the library failed to load (it couldn't be found) or that one or more symbols failed to load, or that a version number that matches a global constant based on the compile-time configuration. 51 | 52 | There is also a global `loadSFML` function that will load all configured CSFML libraries, and which returns `true` on success or `false` on failure. This is possible due to the fact that all of the CSFML libraries are part of the same versioned release package. In other words, all of the CSFML libraries you distribute with your application should be from the same release, e.g. CSFML 2.2 or CSFML 2.5. Never mix different CSFML library versions in the same program. 53 | 54 | Note that it is not necessary to load the CSFML System library unless you intend to call any functions from the System API. When using the CSFML Graphics library, the same holds true for the CSFML Window library; the Graphics library is dependent on the Window library, and both shared libraries need to be in the same directory (along with the System shared library, upon which all the CSFML libraries depend), but it is not necessary to load the Window library if you do not need to call any of its functions. 55 | 56 | ```d 57 | /* 58 | The package modules for any CSFML libraries you have configured will be imported 59 | with this single import statement. In the case of the configuration example 60 | above, the Audio, Graphics, System, and Window package modules will be imported. 61 | */ 62 | import bindbc.sfml; 63 | 64 | /* 65 | This version attempts to load the CSFML System library and all configured CSFML libraries using well-known variations of the library names for the host system. Note that when the Graphics library is configured, the Window library is also 66 | automatically configured, so `loadSFML` will attempt to load it as well. 67 | */ 68 | if(!loadSFML()) { 69 | /* 70 | A CSFML library failed to load. The error handling API in bindbc-loader 71 | can be used to fetch the error messages. 72 | */ 73 | } 74 | 75 | /* 76 | This version attempts to load a specific CSFML library individually. This allows for more nuanced error handling, and avoids the loading of the System and, in this case, Window libraries when you don't need to use them. 77 | */ 78 | SFMLSupport ret = loadSFMLGraphics(); 79 | if(ret != sfmlSupport) { 80 | /* 81 | sfmlSupport is the compile-time constant representing the CSFML version that was configured, e.g., `SFMLSupport.sfml200`, `SFMLSupport.sfml220`, etc. If the load was successful, then the returned value should match the `sfmlSupport` value. If the load failed, the returned value will be one of `SFMLSupport.noLibrary` or `SFMLSupport.badLibrary`. 82 | */ 83 | if(ret == SFMLSupport.noLibrary) { 84 | /* 85 | The system failed to load the library. Usually this means that either the library or one of its dependencies could not be found. 86 | */ 87 | } 88 | else if(ret == SFMLSupport.badLibrary) { 89 | /* 90 | This indicates that the system was able to find and successfully load the library, but one or more symbols the binding expected to find was missing. This usually indicates that the loaded library is of a lower API version than the binding was configured to load, e.g., a CSFML 2.0 library loaded by a CSFML 2.5 configuration. 91 | 92 | For many C libraries, this is perfectly fine and the application can continue as long as none of the missing functions are called. Unfortunately, for CSFML, this can be problematic, as the maintainer sometimes changes the signature of functions from one minor version to the next. (This is addressed later in this documentation.) 93 | */ 94 | } 95 | } 96 | 97 | /* 98 | This version attempts to load a specific CSFML library using a user-supplied file name. 99 | Usually, the name and/or path will be platform specific, as in this example 100 | which attempts to load `csfml-graphics.dll` from the `libs` subdirectory, relative 101 | to the executable, only on Windows. It has the same return values as the version above. 102 | */ 103 | version(Windows) { 104 | auto ret = loadSFMLGraphics("libs/csfml-graphics.dll"); 105 | if(ret != sfmlSupport) { 106 | // Error handling as above. 107 | } 108 | } 109 | ``` 110 | By default, each CSFML library binding is configured to compile bindings for version 2.0.0 the C library. This ensures the widest level of compatibility at runtime. This behavior can be overridden by using via specific identifiers. It is recommended that you always select the minimum version you require _and no higher_. In this example, the CSFML dynamic bindings (for each CSFML library you intend to use) is compiled to support CSFML version 2.5.0: 111 | 112 | __dub.json__ 113 | ``` 114 | "dependencies": { 115 | "bindbc-sfmll": "~>1.1.0" 116 | }, 117 | "versions": [ 118 | "SFML_Audio", 119 | "SFML_Graphics", 120 | "SFML_250", 121 | ], 122 | ``` 123 | 124 | __dub.sdl__ 125 | ``` 126 | dependency "bindbc-sfml" version="~>1.1.0" 127 | versions "SFML_Audio" "SFML_Graphics" "SFML_250" 128 | ``` 129 | 130 | Following are the supported CSFML library versions and the corresponding version identifiers to pass to the compiler. 131 | 132 | | Library Version |Version Identifier| 133 | |--------------------|------------------| 134 | | SFML 2.0.0 | Default | 135 | | SFML 2.1.0 | SFML_210 | 136 | | SFML 2.2.0 | SFML_220 | 137 | | SFML 2.3.0 | SFML_230 | 138 | | SFML 2.4.0 | SFML_240 | 139 | | SFML 2.5.0 | SFML_250 | 140 | | SFML 2.5.2 | SFML_252 | 141 | 142 | > [!NOTE]\ 143 | > There is no difference in the public API between CSFML 2.0 and CSFML 2.1. 144 | 145 | ### Version mismatch 146 | Many C libraries have versioning schemes such that minor version releases, e.g. 2.0 vs 2.1, are still compatible. In that case, a dynamic binding can load e.g. a 2.0 library with a 2.1 binding and, as long as no 2.1 functions are called, run as normal. With SFML, this is actually only true with versions 2.0 and 2.1. 147 | 148 | Beginning in CSFML 2.2 and continuing in later versions, some function signatures were changed from the previous versions. Due to the nature of dynamic loading, this *will not break library loading* when, say, a 2.0 library is loaded by a 2.5 binding. However, it will cause undefined behavior (most likely a crash) if an affected function is called. 149 | 150 | For that reason, it is recommended that if you configure BindBC-SFML with version `SFML_230` or higher, you always treat a load function return value of `SFMLSupport.badLibrary` as an irrecoverable failure and do not attempt to continue with the lower library version. 151 | 152 | If you insist on supporting older CSFML versions than the one you've configured, you'll need to be aware of the changes. In some cases, the type of one or more parameters, or of the return value, was changed, In other cases, parameters were added. Some of the changes might be harmless (like changing a return type from `int` to `float`), or harmless 64-bit builds (like changing a parameter or return type from `uint` to `size_t`), but the rest can cause issues. 153 | 154 | These are the functions you need to watch out for, the version in which the change was made, and the nature of the change: 155 | 156 | | Version | Function Name | Change | 157 | |----------|--------------------------------------|--------------------------------------| 158 | | SFML_220 | `sfFont_getKerning` | Return type (void to sfBool) | 159 | | SFML_220 | `sfFont_getLineSpacing` | Return type (void to sfBool) | 160 | | SFML_220 | `sfSoundRecorder_start` | Return type (void to sfBool) | 161 | | SFML_230 | `sfCircleShape_getPoint` | Parameter type (uint to size_t) | 162 | | SFML_230 | `sfCircleShape_getPointCount` | Return type (uint to size_t) | 163 | | SFML_230 | `sfCircleShape_setPointCount` | Parameter type (uint to size_t) | 164 | | SFML_230 | `sfConvexShape_getPoint` | Parameter type (uint to size_t) | 165 | | SFML_230 | `sfConvexShape_getPointCount` | Return type (uint to size_t) | 166 | | SFML_230 | `sfConvexShape_setPointCount` | Parameter type (uint to size_t) | 167 | | SFML_230 | `sfRectangleShape_getPoint` | Parameter type (uint to size_t) | 168 | | SFML_230 | `sfRectangleShape_getPointCount` | Return type (uint to size_t) | 169 | | SFML_230 | `sfRenderTexture_drawPrimitives` | Parameter type (uint to size_t) | 170 | | SFML_230 | `sfRenderWindow_drawPrimitives` | Parameter type (uint to size_t) | 171 | | SFML_230 | `sfShader_createFromStream` | Additional parameter | 172 | | SFML_230 | `sfShape_getPoint` | Parameter type (uint to size_t) | 173 | | SFML_230 | `sfShape_getPointCount` | Return type (uint to size_t) | 174 | | SFML_230 | `sfSoundBuffer_createFromSamples` | Parameter type (size_t to sfUint64) | 175 | | SFML_230 | `sfSoundBuffer_getSampleCount` | Return type (size_t to sfUint64) | 176 | | SFML_230 | `sfVertexArray_getVertexCount` | Return type (uint to size_t) | 177 | | SFML_230 | `sfVertexArray_getVertex` | Parameter type (uint to size_t) | 178 | | SFML_230 | `sfVertexArray_resize` | Parameter type (uint to size_t) | 179 | | SFML_240 | `sfContext_setActive` | Return type (void to sfBool) | 180 | | SFML_240 | `sfTcpListener_listen` | Additional parameter | 181 | | SFML_240 | `sfUdpSocket_bind` | Additional parameter | 182 | | SFML_240 | `sfSoundBufferRecorder_start` | Return type (void to sfBool) | 183 | | SFML_250 | `sfFtp_upload` | Additional parameter | 184 | | SFML_252 | `sfTexture_setSrgb` | Removed entirely :( | 185 | 186 | ## The static bindings 187 | The static bindings have a link-time dependency on either the shared or static CSFML libraries. On Windows, you can link with the static libraries or, to use the DLLs, the import libraries. On other systems, you can link with either the static libraries or directly with the shared libraries. 188 | 189 | This requires the CSFML development packages be installed on your system at compile time. When linking with the static libraries, there is no runtime dependency on CSFML. When linking with the shared libraries, the runtime dependency is the same as the dynamic bindings, the difference being that the shared libraries are no longer loaded manually—loading is handled automatically by the system when the program is launched. 190 | 191 | > [!NOTE]\ 192 | > The CSFML binary distributions on [the CSFML download page](https://www.sfml-dev.org/download/csfml/) do not include static libraries. The Windows packages contain import libraries, meaning the DLLs will still be required at runtime. To obtain the static libraries, you will either have to build them yourself or find prebuilt libraries somewhere else. I am unaware of anywhere that provides the CSFML static libraries for download, so if you do find them somewhere, please let me know. 193 | 194 | Enabling the static bindings can be done in two ways. 195 | 196 | ### Via the compiler's `-version` switch or DUB's `versions` directive 197 | Pass the `BindSFML_Static` version to the compiler and link with the appropriate libraries. Note that `BindSFML_Static` will also enable the static binding for all configured CSFML libraries. 198 | 199 | When using the compiler command line or a build system that doesn't support DUB, this is the only option. The `-version=BindSFML_Static` option should be passed to the compiler when building your program. All of the required C libraries, as well as the BindBC-SFML and `bindbc-loader` static libraries, must also be passed to the compiler on the command line or via your build system's configuration. 200 | 201 | > [!TIP]\ 202 | > The version identifierentifier `BindBC_Static` can be used to configure all of the _official_ BindBC packages used in your program. (i.e. those maintained in [the BindBC GitHub organisation](https://github.com/BindBC)) Some third-party BindBC packages may support it as well. 203 | 204 | For example, when using the static bindings for the SFML Audio and Graphics packages with DUB: 205 | 206 | __dub.json__ 207 | ``` 208 | "dependencies": { 209 | "bindbc-sfml": "~>1.1.0" 210 | }, 211 | "versions": ["BindSFML_Static", "SFML_Audio", "SFML_Graphics"], 212 | "libs": ["csfml-audio", "csfml-graphics"] 213 | ``` 214 | 215 | __dub.sdl__ 216 | ``` 217 | dependency "bindbc-sfml" version="~>1.1.0" 218 | versions "BindSFML_Static" "SFML_Audio" "SFML_Graphics" 219 | libs "csfml-audio" "csfml-graphics" 220 | ``` 221 | 222 | Note that if you wished to call any CSFML System or Window functions, the `csdml-system` and `csfml-window` libraries would need to be linked as well. 223 | 224 | ### Via DUB subconfigurations 225 | Instead of using DUB's `versions` directive, a `subConfiguration` can be used. Enable the `static` subconfiguration for the BindBC-SFML dependency: 226 | 227 | __dub.json__ 228 | ``` 229 | "dependencies": { 230 | "bindbc-sfml": "~>1.1.0" 231 | }, 232 | "subConfigurations": { 233 | "bindbc-sfml": "static" 234 | }, 235 | "versions": [ 236 | "SFML_Audio", 237 | "SFML_Graphics", 238 | ], 239 | "libs": ["csfml-audio", "csfml-graphics"] 240 | ``` 241 | 242 | __dub.sdl__ 243 | ``` 244 | dependency "bindbc-sfml" version="~>1.1.0" 245 | subConfiguration "bindbc-sfml" "static" 246 | versions "SFML_Audio" "SFML_Graphics" 247 | libs "csfml-audio" "csfml-graphics" 248 | ``` 249 | 250 | Note that if you wished to call any CSFML System or Window functions, the `csdml-system` and `csfml-window` libraries would need to be linked as well. 251 | 252 | ## `-betterC` support 253 | `-betterC` support is enabled via the `dynamicBC` and `staticBC` subconfigurations, for dynamic and static bindings respectively. To enable the static bindings with `-betterC` support: 254 | 255 | __dub.json__ 256 | ``` 257 | "dependencies": { 258 | "bindbc-sfml": "~>1.1.0" 259 | }, 260 | "subConfigurations": { 261 | "bindbc-sfml": "staticBC" 262 | }, 263 | "versions": [ 264 | "SFML_Audio", 265 | "SFML_Graphics", 266 | ], 267 | "libs": ["csfml-audio", "csfml-graphics"] 268 | ``` 269 | 270 | __dub.sdl__ 271 | ``` 272 | dependency "bindbc-sfml" version="~>1.1.0" 273 | subConfiguration "bindbc-sfml" "staticBC" 274 | versions "SFML_Audio" "SFML_Graphics" 275 | libs "csfml-audio" "csfml-graphics" 276 | ``` 277 | 278 | Note that if you wished to call any CSFML System or Window functions, the `csdml-system` and `csfml-window` libraries would need to be linked as well. 279 | 280 | When not using DUB to manage your project, first use DUB to compile the BindBC libraries with the `dynamicBC` or `staticBC` configuration, then pass `-betterC` to the compiler when building your project. 281 | -------------------------------------------------------------------------------- /source/bindbc/sfml/window.d: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2020 - 2021 Michael D. Parker 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | module bindbc.sfml.window; 8 | 9 | import bindbc.sfml.config; 10 | static if(bindSFMLWindow): 11 | 12 | import bindbc.sfml.system; 13 | 14 | //Window/Types.h 15 | struct sfContext; 16 | struct sfWindow; 17 | 18 | static if(sfmlSupport >= SFMLSupport.sfml250){ 19 | struct sfCursor; 20 | 21 | //Window/Cursor.h 22 | enum sfCursorType{ 23 | sfCursorArrow, 24 | sfCursorArrowWait, 25 | sfCursorWait, 26 | sfCursorText, 27 | sfCursorHand, 28 | sfCursorSizeHorizontal, 29 | sfCursorSizeVertical, 30 | sfCursorSizeTopLeftBottomRight, 31 | sfCursorSizeBottomLeftTopRight, 32 | sfCursorSizeAll, 33 | sfCursorCross, 34 | sfCursorHelp, 35 | sfCursorNotAllowed, 36 | } 37 | } 38 | 39 | 40 | //Window/Sensor.h 41 | // Had to put this above sfSensorEvent declaration, else there was 42 | // a compile failure due to the static if. 43 | static if(sfmlSupport >= SFMLSupport.sfml220){ 44 | enum sfSensorType{ 45 | sfSensorAccelerometer, 46 | sfSensorGyroscope, 47 | sfSensorMagnetometer, 48 | sfSensorGravity, 49 | sfSensorUserAcceleration, 50 | sfSensorOrientation, 51 | 52 | sfSensorCount, 53 | } 54 | mixin(expandEnum!sfSensorType); 55 | } 56 | 57 | //Window/Mouse.h 58 | // Had to put this above sfMouseWheelScrollEvent declaration, else there was 59 | // a compile failure due to the static if. 60 | enum sfMouseButton{ 61 | sfMouseLeft, 62 | sfMouseRight, 63 | sfMouseMiddle, 64 | sfMouseXButton1, 65 | sfMouseXButton2, 66 | sfMouseButtonCount, 67 | } 68 | mixin(expandEnum!sfMouseButton); 69 | 70 | static if(sfmlSupport >= SFMLSupport.sfml230){ 71 | enum sfMouseWheel{ 72 | sfMouseVerticalWheel, 73 | sfMouseHorizontalWheel, 74 | } 75 | mixin(expandEnum!sfMouseWheel); 76 | } 77 | 78 | //Window/Event.h 79 | static if(sfmlSupport >= SFMLSupport.sfml230){ 80 | enum sfEventType{ 81 | sfEvtClosed, 82 | sfEvtResized, 83 | sfEvtLostFocus, 84 | sfEvtGainedFocus, 85 | sfEvtTextEntered, 86 | sfEvtKeyPressed, 87 | sfEvtKeyReleased, 88 | sfEvtMouseWheelMoved, 89 | sfEvtMouseWheelScrolled, 90 | sfEvtMouseButtonPressed, 91 | sfEvtMouseButtonReleased, 92 | sfEvtMouseMoved, 93 | sfEvtMouseEntered, 94 | sfEvtMouseLeft, 95 | sfEvtJoystickButtonPressed, 96 | sfEvtJoystickButtonReleased, 97 | sfEvtJoystickMoved, 98 | sfEvtJoystickConnected, 99 | sfEvtJoystickDisconnected, 100 | sfEvtTouchBegan, 101 | sfEvtTouchMoved, 102 | sfEvtTouchEnded, 103 | sfEvtSensorChanged, 104 | } 105 | }else static if(sfmlSupport == SFMLSupport.sfml220){ 106 | enum sfEventType{ 107 | sfEvtClosed, 108 | sfEvtResized, 109 | sfEvtLostFocus, 110 | sfEvtGainedFocus, 111 | sfEvtTextEntered, 112 | sfEvtKeyPressed, 113 | sfEvtKeyReleased, 114 | sfEvtMouseWheelMoved, 115 | sfEvtMouseButtonPressed, 116 | sfEvtMouseButtonReleased, 117 | sfEvtMouseMoved, 118 | sfEvtMouseEntered, 119 | sfEvtMouseLeft, 120 | sfEvtJoystickButtonPressed, 121 | sfEvtJoystickButtonReleased, 122 | sfEvtJoystickMoved, 123 | sfEvtJoystickConnected, 124 | sfEvtJoystickDisconnected, 125 | sfEvtTouchBegan, 126 | sfEvtTouchMoved, 127 | sfEvtTouchEnded, 128 | sfEvtSensorChanged, 129 | } 130 | }else{ 131 | enum sfEventType{ 132 | sfEvtClosed, 133 | sfEvtResized, 134 | sfEvtLostFocus, 135 | sfEvtGainedFocus, 136 | sfEvtTextEntered, 137 | sfEvtKeyPressed, 138 | sfEvtKeyReleased, 139 | sfEvtMouseWheelMoved, 140 | sfEvtMouseButtonPressed, 141 | sfEvtMouseButtonReleased, 142 | sfEvtMouseMoved, 143 | sfEvtMouseEntered, 144 | sfEvtMouseLeft, 145 | sfEvtJoystickButtonPressed, 146 | sfEvtJoystickButtonReleased, 147 | sfEvtJoystickMoved, 148 | sfEvtJoystickConnected, 149 | sfEvtJoystickDisconnected, 150 | } 151 | } 152 | mixin(expandEnum!sfEventType); 153 | 154 | struct sfKeyEvent{ 155 | sfEventType type; 156 | sfKeyCode code; 157 | sfBool alt, control, shift, system; 158 | } 159 | 160 | struct sfTextEvent{ 161 | sfEventType type; 162 | sfUint32 unicode; 163 | } 164 | 165 | struct sfMouseMoveEvent{ 166 | sfEventType type; 167 | int x, y; 168 | } 169 | 170 | struct sfMouseButtonEvent{ 171 | sfEventType type; 172 | sfMouseButton button; 173 | int x, y; 174 | } 175 | 176 | struct sfMouseWheelEvent{ 177 | sfEventType type; 178 | int delta; 179 | int x, y; 180 | } 181 | 182 | static if(sfmlSupport >= SFMLSupport.sfml230){ 183 | struct sfMouseWheelScrollEvent{ 184 | sfEventType type; 185 | sfMouseWheel wheel; 186 | float delta; 187 | int x, y; 188 | } 189 | } 190 | 191 | struct sfJoystickMoveEvent{ 192 | sfEventType type; 193 | uint joystickId; 194 | sfJoystickAxis axis; 195 | float position; 196 | } 197 | 198 | struct sfJoystickButtonEvent{ 199 | sfEventType type; 200 | uint joystickId; 201 | uint button; 202 | } 203 | 204 | struct sfJoystickConnectEvent{ 205 | sfEventType type; 206 | uint joystickId; 207 | } 208 | 209 | struct sfSizeEvent{ 210 | sfEventType type; 211 | uint width, height; 212 | } 213 | 214 | static if(sfmlSupport >= SFMLSupport.sfml220){ 215 | struct sfTouchEvent{ 216 | sfEventType type; 217 | uint finger; 218 | int x, y; 219 | } 220 | 221 | struct sfSensorEvent{ 222 | sfEventType type; 223 | sfSensorType sensorType; 224 | float x, y, z; 225 | } 226 | } 227 | 228 | union sfEvent{ 229 | sfEventType type; 230 | sfSizeEvent size; 231 | sfKeyEvent key; 232 | sfTextEvent text; 233 | sfMouseMoveEvent mouseMove; 234 | sfMouseButtonEvent mouseButton; 235 | sfMouseWheelEvent mouseWheel; 236 | static if(sfmlSupport >= SFMLSupport.sfml230){ 237 | sfMouseWheelScrollEvent mouseWheelScroll; 238 | } 239 | sfJoystickMoveEvent joystickMove; 240 | sfJoystickButtonEvent joystickButton; 241 | sfJoystickConnectEvent joystickConnect; 242 | 243 | static if(sfmlSupport >= SFMLSupport.sfml220){ 244 | sfTouchEvent touch; 245 | sfSensorEvent sensor; 246 | } 247 | } 248 | 249 | //Window/Joystick.h 250 | enum sfJoystickCount = 8; 251 | enum sfJoystickButtonCount = 32; 252 | enum sfJoystickAxisCount = 8; 253 | 254 | enum sfJoystickAxis{ 255 | sfJoystickX, 256 | sfJoystickY, 257 | sfJoystickZ, 258 | sfJoystickR, 259 | sfJoystickU, 260 | sfJoystickV, 261 | sfJoystickPovX, 262 | sfJoystickPovY, 263 | } 264 | mixin(expandEnum!sfJoystickAxis); 265 | 266 | //Window/JoystickIndentification.h 267 | static if(sfmlSupport >= SFMLSupport.sfml220){ 268 | struct sfJoystickIdentification{ 269 | const(char)* name; 270 | uint vendorId; 271 | uint productId; 272 | } 273 | } 274 | 275 | //Window/Keyboard.h 276 | enum sfKeyCode{ 277 | sfKeyUnknown = -1, 278 | sfKeyA, 279 | sfKeyB, 280 | sfKeyC, 281 | sfKeyD, 282 | sfKeyE, 283 | sfKeyF, 284 | sfKeyG, 285 | sfKeyH, 286 | sfKeyI, 287 | sfKeyJ, 288 | sfKeyK, 289 | sfKeyL, 290 | sfKeyM, 291 | sfKeyN, 292 | sfKeyO, 293 | sfKeyP, 294 | sfKeyQ, 295 | sfKeyR, 296 | sfKeyS, 297 | sfKeyT, 298 | sfKeyU, 299 | sfKeyV, 300 | sfKeyW, 301 | sfKeyX, 302 | sfKeyY, 303 | sfKeyZ, 304 | sfKeyNum0, 305 | sfKeyNum1, 306 | sfKeyNum2, 307 | sfKeyNum3, 308 | sfKeyNum4, 309 | sfKeyNum5, 310 | sfKeyNum6, 311 | sfKeyNum7, 312 | sfKeyNum8, 313 | sfKeyNum9, 314 | sfKeyEscape, 315 | sfKeyLControl, 316 | sfKeyLShift, 317 | sfKeyLAlt, 318 | sfKeyLSystem, 319 | sfKeyRControl, 320 | sfKeyRShift, 321 | sfKeyRAlt, 322 | sfKeyRSystem, 323 | sfKeyMenu, 324 | sfKeyLBracket, 325 | sfKeyRBracket, 326 | sfKeySemicolon, 327 | sfKeyComma, 328 | sfKeyPeriod, 329 | sfKeyQuote, 330 | sfKeySlash, 331 | sfKeyBackslash, 332 | sfKeyTilde, 333 | sfKeyEqual, 334 | sfKeyHyphen, 335 | sfKeySpace, 336 | sfKeyEnter, 337 | sfKeyBackspace, 338 | sfKeyTab, 339 | sfKeyPageUp, 340 | sfKeyPageDown, 341 | sfKeyEnd, 342 | sfKeyHome, 343 | sfKeyInsert, 344 | sfKeyDelete, 345 | sfKeyAdd, 346 | sfKeySubtract, 347 | sfKeyMultiply, 348 | sfKeyDivide, 349 | sfKeyLeft, 350 | sfKeyRight, 351 | sfKeyUp, 352 | sfKeyDown, 353 | sfKeyNumpad0, 354 | sfKeyNumpad1, 355 | sfKeyNumpad2, 356 | sfKeyNumpad3, 357 | sfKeyNumpad4, 358 | sfKeyNumpad5, 359 | sfKeyNumpad6, 360 | sfKeyNumpad7, 361 | sfKeyNumpad8, 362 | sfKeyNumpad9, 363 | sfKeyF1, 364 | sfKeyF2, 365 | sfKeyF3, 366 | sfKeyF4, 367 | sfKeyF5, 368 | sfKeyF6, 369 | sfKeyF7, 370 | sfKeyF8, 371 | sfKeyF9, 372 | sfKeyF10, 373 | sfKeyF11, 374 | sfKeyF12, 375 | sfKeyF13, 376 | sfKeyF14, 377 | sfKeyF15, 378 | sfKeyPause, 379 | sfKeyCount, 380 | 381 | //Changed in 2.5 382 | sfKeySemiColon = sfKeySemicolon, 383 | sfKeyBackSlash = sfKeyBackslash, 384 | sfKeyDash = sfKeyHyphen, 385 | sfKeyReturn = sfKeyEnter, 386 | sfKeyBack = sfKeyBackspace, 387 | } 388 | mixin(expandEnum!sfKeyCode); 389 | 390 | //Window/VideoMode.h 391 | struct sfVideoMode{ 392 | uint width, height; 393 | uint bitsPerPixel; 394 | } 395 | 396 | //Window/Window.h 397 | enum sfWindowStyle{ 398 | sfNone = 0, 399 | sfTitlebar = 1 << 0, 400 | sfResize = 1 << 1, 401 | sfClose = 1 << 2, 402 | sfFullscreen = 1 << 3, 403 | sfDefaultStyle = sfTitlebar | sfResize | sfClose, 404 | } 405 | mixin(expandEnum!sfWindowStyle); 406 | 407 | static if(sfmlSupport >= SFMLSupport.sfml230){ 408 | enum sfContextAttribute{ 409 | sfContextDefault = 0, 410 | sfContextCore = 1 << 0, 411 | sfContextDebug = 1 << 2, 412 | } 413 | mixin(expandEnum!sfContextAttribute); 414 | } 415 | 416 | struct sfContextSettings{ 417 | uint depthBits; 418 | uint stencilBits; 419 | uint antialiasingLevel; 420 | uint majorVersion; 421 | uint minorVersion; 422 | static if(sfmlSupport >= SFMLSupport.sfml230){ 423 | sfUint32 attributeFlags; 424 | } 425 | static if(sfmlSupport >= SFMLSupport.sfml240){ 426 | sfBool sRgbCapable; 427 | } 428 | } 429 | 430 | //Window/WindowHandle.h 431 | version(Windows) alias sfWindowHandle = void*; 432 | else version(OSX) alias sfWindowHandle = void*; 433 | else version(Posix){ 434 | import core.stdc.config : c_ulong; 435 | alias sfWindowHandle = c_ulong; 436 | } 437 | 438 | static if(staticSFML){ 439 | extern(C) @nogc nothrow{ 440 | //Window/Context.h 441 | sfContext* sfContext_create(); 442 | void sfContext_destroy(sfContext* context); 443 | 444 | static if(sfmlSupport >= sfmlSupport.sfml240){ 445 | sfBool sfContext_setActive(sfContext* context, sfBool active); 446 | }else{ 447 | void sfContext_setActive(sfContext* context, sfBool active); 448 | } 449 | //Window/Joystick.h 450 | sfBool sfJoystick_isConnected(uint joystick); 451 | uint sfJoystick_getButtonCount(uint joystick); 452 | sfBool sfJoystick_hasAxis(uint joystick, sfJoystickAxis axis); 453 | sfBool sfJoystick_isButtonPressed(uint joystick, uint button); 454 | float sfJoystick_getAxisPosition(uint joystick, sfJoystickAxis axis); 455 | void sfJoystick_update(); 456 | 457 | //Window/Keyboard.h 458 | sfBool sfKeyboard_isKeyPressed(sfKeyCode key); 459 | 460 | //Window/Mouse.h 461 | sfBool sfMouse_isButtonPressed(sfMouseButton button); 462 | sfVector2i sfMouse_getPosition(const(sfWindow)* relativeTo); 463 | void sfMouse_setPosition(sfVector2i position, const(sfWindow)* relativeTo); 464 | 465 | //Window/VideoMode.h 466 | sfVideoMode sfVideoMode_getDesktopMode(); 467 | const(sfVideoMode)* sfVideoMode_getFullscreenModes(size_t* count); 468 | sfBool sfVideoMode_isValid(sfVideoMode mode); 469 | 470 | //Window/Window.h 471 | sfWindow* sfWindow_create(sfVideoMode mode, const(char)* title, sfUint32 style, const(sfContextSettings)* settings); 472 | sfWindow* sfWindow_createUnicode(sfVideoMode mode, const(sfUint32)* title, sfUint32 style, const(sfContextSettings)* settings); 473 | sfWindow* sfWindow_createFromHandle(sfWindowHandle handle, const(sfContextSettings)* settings); 474 | void sfWindow_destroy(sfWindow* window); 475 | void sfWindow_close(sfWindow* window); 476 | sfBool sfWindow_isOpen(const(sfWindow)* window); 477 | sfContextSettings sfWindow_getSettings(const(sfWindow)* window); 478 | sfBool sfWindow_pollEvent(sfWindow* window, sfEvent* event); 479 | sfBool sfWindow_waitEvent(sfWindow* window, sfEvent* event); 480 | sfVector2i sfWindow_getPosition(const(sfWindow)* window); 481 | void sfWindow_setPosition(sfWindow* window, sfVector2i position); 482 | sfVector2u sfWindow_getSize(const(sfWindow)* window); 483 | void sfWindow_setSize(sfWindow* window, sfVector2u size); 484 | void sfWindow_setTitle(sfWindow* window, const(char)* title); 485 | void sfWindow_setUnicodeTitle(sfWindow* window, const(sfUint32)* title); 486 | void sfWindow_setIcon(sfWindow* window, uint width, uint height, const(sfUint8)* pixels); 487 | void sfWindow_setVisible(sfWindow* window, sfBool visible); 488 | void sfWindow_setMouseCursorVisible(sfWindow* window, sfBool visible); 489 | void sfWindow_setVerticalSyncEnabled(sfWindow* window, sfBool enabled); 490 | void sfWindow_setKeyRepeatEnabled(sfWindow* window, sfBool enabled); 491 | sfBool sfWindow_setActive(sfWindow* window, sfBool active); 492 | void sfWindow_display(sfWindow* window); 493 | void sfWindow_setFramerateLimit(sfWindow* window, uint limit); 494 | void sfWindow_setJoystickThreshold(sfWindow* window, float threshold); 495 | sfWindowHandle sfWindow_getSystemHandle(const(sfWindow)* window); 496 | 497 | static if(sfmlSupport >= SFMLSupport.sfml220){ 498 | //Window/Joystick.h 499 | sfJoystickIdentification sfJoystick_getIdentification(uint joystick); 500 | 501 | //Window/Sensor.h 502 | sfBool sfSensor_isAvailable(sfSensorType sensor); 503 | void sfSensor_setEnabled(sfSensorType sensor, sfBool enabled); 504 | sfVector3f sfSensor_getValue(sfSensorType sensor); 505 | 506 | //Window/Touch.h 507 | sfBool sfTouch_isDown(uint finger); 508 | sfVector2i sfTouch_getPosition(uint finger, const(sfWindow)* relativeTo); 509 | 510 | //Window/Window.h 511 | void sfWindow_requestFocus(sfWindow* window); 512 | sfBool sfWindow_hasFocus(const(sfWindow)* window); 513 | } 514 | static if(sfmlSupport >= SFMLSupport.sfml240){ 515 | //Window/Context.h 516 | sfContextSettings sfContext_getSettings(const(sfContext)* context); 517 | 518 | //Window/Keyboard.h 519 | void sfKeyboard_setVirtualKeyboardVisible(sfBool visible); 520 | 521 | //Window/Window.h 522 | void sfWindow_setMouseCursorGrabbed(sfWindow* window, sfBool grabbed); 523 | } 524 | static if(sfmlSupport >= SFMLSupport.sfml250){ 525 | //Window/Clipboard.h 526 | const(char)* sfClipboard_getString(); 527 | const(sfUint32)* sfClipboard_getUnicodeString(); 528 | void sfClipboard_setString(const(char)* text); 529 | void sfClipboard_setUnicodeString(const(sfUint32)* text); 530 | 531 | //Window/Context.h 532 | sfUint64 sfContext_getActiveContextId(); 533 | 534 | //Window/Cursor.h 535 | sfCursor* sfCursor_createFromPixels(const(sfUint8)* pixels, sfVector2u size, sfVector2u hotspot); 536 | sfCursor* sfCursor_createFromSystem(sfCursorType type); 537 | void sfCursor_destroy(sfCursor* cursor); 538 | 539 | //Window/Window.h 540 | void sfWindow_setMouseCursor(sfWindow* window, const(sfCursor)* cursor); 541 | } 542 | } 543 | }else{ 544 | import bindbc.loader; 545 | 546 | extern(C) @nogc nothrow{ 547 | //Window/Context.h 548 | alias psfContext_create = sfContext* function(); 549 | alias psfContext_destroy = void function(sfContext* context); 550 | 551 | static if(sfmlSupport >= SFMLSupport.sfml240){ 552 | alias psfContext_setActive = sfBool function(sfContext* context, sfBool active); 553 | }else{ 554 | alias psfContext_setActive = void function(sfContext* context, sfBool active); 555 | } 556 | 557 | //Window/Joystick.h 558 | alias psfJoystick_isConnected = sfBool function(uint joystick); 559 | alias psfJoystick_getButtonCount = uint function(uint joystick); 560 | alias psfJoystick_hasAxis = sfBool function(uint joystick, sfJoystickAxis axis); 561 | alias psfJoystick_isButtonPressed = sfBool function(uint joystick, uint button); 562 | alias psfJoystick_getAxisPosition = float function(uint joystick, sfJoystickAxis axis); 563 | alias psfJoystick_update = void function(); 564 | 565 | //Window/Keyboard.h 566 | alias psfKeyboard_isKeyPressed = sfBool function(sfKeyCode key); 567 | 568 | //Window/Mouse.h 569 | alias psfMouse_isButtonPressed = sfBool function(sfMouseButton button); 570 | alias psfMouse_getPosition = sfVector2i function(const(sfWindow)* relativeTo); 571 | alias psfMouse_setPosition = void function(sfVector2i position, const(sfWindow)* relativeTo); 572 | 573 | //Window/VideoMode.h 574 | alias psfVideoMode_getDesktopMode = sfVideoMode function(); 575 | alias psfVideoMode_getFullscreenModes = const(sfVideoMode)* function(size_t* count); 576 | alias psfVideoMode_isValid = sfBool function(sfVideoMode mode); 577 | 578 | //Window/Window.h 579 | alias psfWindow_create = sfWindow* function(sfVideoMode mode, const(char)* title, sfUint32 style, const(sfContextSettings)* settings); 580 | alias psfWindow_createUnicode = sfWindow* function(sfVideoMode mode, const(sfUint32)* title, sfUint32 style, const(sfContextSettings)* settings); 581 | alias psfWindow_createFromHandle = sfWindow* function(sfWindowHandle handle, const(sfContextSettings)* settings); 582 | alias psfWindow_destroy = void function(sfWindow* window); 583 | alias psfWindow_close = void function(sfWindow* window); 584 | alias psfWindow_isOpen = sfBool function(const(sfWindow)* window); 585 | alias psfWindow_getSettings = sfContextSettings function(const(sfWindow)* window); 586 | alias psfWindow_pollEvent = sfBool function(sfWindow* window, sfEvent* event); 587 | alias psfWindow_waitEvent = sfBool function(sfWindow* window, sfEvent* event); 588 | alias psfWindow_getPosition = sfVector2i function(const(sfWindow)* window); 589 | alias psfWindow_setPosition = void function(sfWindow* window, sfVector2i position); 590 | alias psfWindow_getSize = sfVector2u function(const(sfWindow)* window); 591 | alias psfWindow_setSize = void function(sfWindow* window, sfVector2u size); 592 | alias psfWindow_setTitle = void function(sfWindow* window, const(char)* title); 593 | alias psfWindow_setUnicodeTitle = void function(sfWindow* window, const(sfUint32)* title); 594 | alias psfWindow_setIcon = void function(sfWindow* window, uint width, uint height, const(sfUint8)* pixels); 595 | alias psfWindow_setVisible = void function(sfWindow* window, sfBool visible); 596 | alias psfWindow_setMouseCursorVisible = void function(sfWindow* window, sfBool visible); 597 | alias psfWindow_setVerticalSyncEnabled = void function(sfWindow* window, sfBool enabled); 598 | alias psfWindow_setKeyRepeatEnabled = void function(sfWindow* window, sfBool enabled); 599 | alias psfWindow_setActive = sfBool function(sfWindow* window, sfBool active); 600 | alias psfWindow_display = void function(sfWindow* window); 601 | alias psfWindow_setFramerateLimit = void function(sfWindow* window, uint limit); 602 | alias psfWindow_setJoystickThreshold = void function(sfWindow* window, float threshold); 603 | alias psfWindow_getSystemHandle = sfWindowHandle function(const(sfWindow)* window); 604 | 605 | static if(sfmlSupport >= SFMLSupport.sfml220){ 606 | //Window/Joystick.h 607 | alias psfJoystick_getIdentification = sfJoystickIdentification function(uint joystick); 608 | 609 | //Window/Sensor.h 610 | alias psfSensor_isAvailable = sfBool function(sfSensorType sensor); 611 | alias psfSensor_setEnabled = void function(sfSensorType sensor, sfBool enabled); 612 | alias psfSensor_getValue = sfVector3f function(sfSensorType sensor); 613 | 614 | //Window/Touch.h 615 | alias psfTouch_isDown = sfBool function(uint finger); 616 | alias psfTouch_getPosition = sfVector2i function(uint finger, const(sfWindow)* relativeTo); 617 | 618 | //Window/Window.h 619 | alias psfWindow_requestFocus = void function(sfWindow* window); 620 | alias psfWindow_hasFocus = sfBool function(const(sfWindow)* window); 621 | } 622 | static if(sfmlSupport >= SFMLSupport.sfml240){ 623 | //Window/Context.h 624 | alias psfContext_getSettings = sfContextSettings function(const(sfContext)* context); 625 | 626 | //Window/Keyboard.h 627 | alias psfKeyboard_setVirtualKeyboardVisible = void function(sfBool visible); 628 | 629 | //Window/Window.h 630 | alias psfWindow_setMouseCursorGrabbed = void function(sfWindow* window, sfBool grabbed); 631 | } 632 | static if(sfmlSupport >= SFMLSupport.sfml250){ 633 | //Window/Clipboard.h 634 | alias psfClipboard_getString = const(char)* function(); 635 | alias psfClipboard_getUnicodeString = const(sfUint32)* function(); 636 | alias psfClipboard_setString = void function(const(char)* text); 637 | alias psfClipboard_setUnicodeString = void function(const(sfUint32)* text); 638 | 639 | //Window/Context.h 640 | alias psfContext_getActiveContextId = sfUint64 function(); 641 | 642 | //Window/Cursor.h 643 | alias psfCursor_createFromPixels = sfCursor* function(const(sfUint8)* pixels, sfVector2u size, sfVector2u hotspot); 644 | alias psfCursor_createFromSystem = sfCursor* function(sfCursorType type); 645 | alias psfCursor_destroy = void function(sfCursor* cursor); 646 | 647 | //Window/Window.h 648 | alias psfWindow_setMouseCursor = void function(sfWindow* window, const(sfCursor)* cursor); 649 | } 650 | } 651 | 652 | __gshared{ 653 | psfContext_create sfContext_create; 654 | psfContext_destroy sfContext_destroy; 655 | psfContext_setActive sfContext_setActive; 656 | psfJoystick_isConnected sfJoystick_isConnected; 657 | psfJoystick_getButtonCount sfJoystick_getButtonCount; 658 | psfJoystick_hasAxis sfJoystick_hasAxis; 659 | psfJoystick_isButtonPressed sfJoystick_isButtonPressed; 660 | psfJoystick_getAxisPosition sfJoystick_getAxisPosition; 661 | psfJoystick_update sfJoystick_update; 662 | psfKeyboard_isKeyPressed sfKeyboard_isKeyPressed; 663 | psfMouse_isButtonPressed sfMouse_isButtonPressed; 664 | psfMouse_getPosition sfMouse_getPosition; 665 | psfMouse_setPosition sfMouse_setPosition; 666 | psfVideoMode_getDesktopMode sfVideoMode_getDesktopMode; 667 | psfVideoMode_getFullscreenModes sfVideoMode_getFullscreenModes; 668 | psfVideoMode_isValid sfVideoMode_isValid; 669 | psfWindow_create sfWindow_create; 670 | psfWindow_createUnicode sfWindow_createUnicode; 671 | psfWindow_createFromHandle sfWindow_createFromHandle; 672 | psfWindow_destroy sfWindow_destroy; 673 | psfWindow_close sfWindow_close; 674 | psfWindow_isOpen sfWindow_isOpen; 675 | psfWindow_getSettings sfWindow_getSettings; 676 | psfWindow_pollEvent sfWindow_pollEvent; 677 | psfWindow_waitEvent sfWindow_waitEvent; 678 | psfWindow_getPosition sfWindow_getPosition; 679 | psfWindow_setPosition sfWindow_setPosition; 680 | psfWindow_getSize sfWindow_getSize; 681 | psfWindow_setSize sfWindow_setSize; 682 | psfWindow_setTitle sfWindow_setTitle; 683 | psfWindow_setUnicodeTitle sfWindow_setUnicodeTitle; 684 | psfWindow_setIcon sfWindow_setIcon; 685 | psfWindow_setVisible sfWindow_setVisible; 686 | psfWindow_setMouseCursorVisible sfWindow_setMouseCursorVisible; 687 | psfWindow_setVerticalSyncEnabled sfWindow_setVerticalSyncEnabled; 688 | psfWindow_setKeyRepeatEnabled sfWindow_setKeyRepeatEnabled; 689 | psfWindow_setActive sfWindow_setActive; 690 | psfWindow_display sfWindow_display; 691 | psfWindow_setFramerateLimit sfWindow_setFramerateLimit; 692 | psfWindow_setJoystickThreshold sfWindow_setJoystickThreshold; 693 | psfWindow_getSystemHandle sfWindow_getSystemHandle; 694 | 695 | static if(sfmlSupport >= SFMLSupport.sfml220){ 696 | psfJoystick_getIdentification sfJoystick_getIdentification; 697 | psfSensor_isAvailable sfSensor_isAvailable; 698 | psfSensor_setEnabled sfSensor_setEnabled; 699 | psfSensor_getValue sfSensor_getValue; 700 | psfTouch_isDown sfTouch_isDown; 701 | psfTouch_getPosition sfTouch_getPosition; 702 | psfWindow_requestFocus sfWindow_requestFocus; 703 | psfWindow_hasFocus sfWindow_hasFocus; 704 | } 705 | static if(sfmlSupport >= SFMLSupport.sfml240){ 706 | psfContext_getSettings sfContext_getSettings; 707 | psfKeyboard_setVirtualKeyboardVisible sfKeyboard_setVirtualKeyboardVisible; 708 | psfWindow_setMouseCursorGrabbed sfWindow_setMouseCursorGrabbed; 709 | } 710 | static if(sfmlSupport >= SFMLSupport.sfml250){ 711 | psfClipboard_getString sfClipboard_getString; 712 | psfClipboard_getUnicodeString sfClipboard_getUnicodeString; 713 | psfClipboard_setString sfClipboard_setString; 714 | psfClipboard_setUnicodeString sfClipboard_setUnicodeString; 715 | psfContext_getActiveContextId sfContext_getActiveContextId; 716 | psfCursor_createFromPixels sfCursor_createFromPixels; 717 | psfCursor_createFromSystem sfCursor_createFromSystem; 718 | psfCursor_destroy sfCursor_destroy; 719 | psfWindow_setMouseCursor sfWindow_setMouseCursor; 720 | } 721 | } 722 | private{ 723 | SharedLib lib; 724 | SFMLSupport loadedVersion; 725 | } 726 | 727 | @nogc nothrow: 728 | SFMLSupport loadedSFMLWindowVersion(){ return loadedVersion; } 729 | 730 | bool isSFMLWindowLoaded(){ 731 | return lib != invalidHandle; 732 | } 733 | 734 | SFMLSupport loadSFMLWindow(){ 735 | version(Windows){ 736 | const(char)[][3] libNames = [ 737 | "csfml-window.dll", 738 | "csfml-window-2.dll", 739 | "csfml-window-2.0.dll" 740 | ]; 741 | }else version(OSX){ 742 | const(char)[][3] libNames = [ 743 | "libcsfml-window.dylib", 744 | "libcsfml-window.2.dylib", 745 | "libcsfml-window.2.0.dylib" 746 | ]; 747 | }else version(Posix){ 748 | const(char)[][3] libNames = [ 749 | "libcsfml-window.so", 750 | "libcsfml-window.so.2", 751 | "libcsfml-window.so.2.0" 752 | ]; 753 | } 754 | 755 | SFMLSupport ret; 756 | foreach(name; libNames){ 757 | ret = loadSFMLWindow(name.ptr); 758 | if(ret != SFMLSupport.noLibrary) break; 759 | } 760 | return ret; 761 | } 762 | 763 | SFMLSupport loadSFMLWindow(const(char)* libName){ 764 | lib = load(libName); 765 | if(lib == invalidHandle){ 766 | return SFMLSupport.noLibrary; 767 | } 768 | 769 | auto errCount = errorCount(); 770 | loadedVersion = SFMLSupport.badLibrary; 771 | 772 | // Now load the functions 773 | lib.bindSymbol(cast(void**)&sfContext_create,"sfContext_create"); 774 | lib.bindSymbol(cast(void**)&sfContext_destroy,"sfContext_destroy"); 775 | lib.bindSymbol(cast(void**)&sfContext_setActive,"sfContext_setActive"); 776 | lib.bindSymbol(cast(void**)&sfJoystick_isConnected,"sfJoystick_isConnected"); 777 | lib.bindSymbol(cast(void**)&sfJoystick_getButtonCount,"sfJoystick_getButtonCount"); 778 | lib.bindSymbol(cast(void**)&sfJoystick_hasAxis,"sfJoystick_hasAxis"); 779 | lib.bindSymbol(cast(void**)&sfJoystick_isButtonPressed,"sfJoystick_isButtonPressed"); 780 | lib.bindSymbol(cast(void**)&sfJoystick_getAxisPosition,"sfJoystick_getAxisPosition"); 781 | lib.bindSymbol(cast(void**)&sfJoystick_update,"sfJoystick_update"); 782 | lib.bindSymbol(cast(void**)&sfKeyboard_isKeyPressed,"sfKeyboard_isKeyPressed"); 783 | lib.bindSymbol(cast(void**)&sfMouse_isButtonPressed,"sfMouse_isButtonPressed"); 784 | lib.bindSymbol(cast(void**)&sfMouse_getPosition,"sfMouse_getPosition"); 785 | lib.bindSymbol(cast(void**)&sfMouse_setPosition,"sfMouse_setPosition"); 786 | lib.bindSymbol(cast(void**)&sfVideoMode_getDesktopMode,"sfVideoMode_getDesktopMode"); 787 | lib.bindSymbol(cast(void**)&sfVideoMode_getFullscreenModes,"sfVideoMode_getFullscreenModes"); 788 | lib.bindSymbol(cast(void**)&sfVideoMode_isValid,"sfVideoMode_isValid"); 789 | lib.bindSymbol(cast(void**)&sfWindow_create,"sfWindow_create"); 790 | lib.bindSymbol(cast(void**)&sfWindow_createUnicode,"sfWindow_createUnicode"); 791 | lib.bindSymbol(cast(void**)&sfWindow_createFromHandle,"sfWindow_createFromHandle"); 792 | lib.bindSymbol(cast(void**)&sfWindow_destroy,"sfWindow_destroy"); 793 | lib.bindSymbol(cast(void**)&sfWindow_close,"sfWindow_close"); 794 | lib.bindSymbol(cast(void**)&sfWindow_isOpen,"sfWindow_isOpen"); 795 | lib.bindSymbol(cast(void**)&sfWindow_getSettings,"sfWindow_getSettings"); 796 | lib.bindSymbol(cast(void**)&sfWindow_pollEvent,"sfWindow_pollEvent"); 797 | lib.bindSymbol(cast(void**)&sfWindow_waitEvent,"sfWindow_waitEvent"); 798 | lib.bindSymbol(cast(void**)&sfWindow_getPosition,"sfWindow_getPosition"); 799 | lib.bindSymbol(cast(void**)&sfWindow_setPosition,"sfWindow_setPosition"); 800 | lib.bindSymbol(cast(void**)&sfWindow_getSize,"sfWindow_getSize"); 801 | lib.bindSymbol(cast(void**)&sfWindow_setSize,"sfWindow_setSize"); 802 | lib.bindSymbol(cast(void**)&sfWindow_setTitle,"sfWindow_setTitle"); 803 | lib.bindSymbol(cast(void**)&sfWindow_setUnicodeTitle,"sfWindow_setUnicodeTitle"); 804 | lib.bindSymbol(cast(void**)&sfWindow_setIcon,"sfWindow_setIcon"); 805 | lib.bindSymbol(cast(void**)&sfWindow_setVisible,"sfWindow_setVisible"); 806 | lib.bindSymbol(cast(void**)&sfWindow_setMouseCursorVisible,"sfWindow_setMouseCursorVisible"); 807 | lib.bindSymbol(cast(void**)&sfWindow_setVerticalSyncEnabled,"sfWindow_setVerticalSyncEnabled"); 808 | lib.bindSymbol(cast(void**)&sfWindow_setKeyRepeatEnabled,"sfWindow_setKeyRepeatEnabled"); 809 | lib.bindSymbol(cast(void**)&sfWindow_setActive,"sfWindow_setActive"); 810 | lib.bindSymbol(cast(void**)&sfWindow_display,"sfWindow_display"); 811 | lib.bindSymbol(cast(void**)&sfWindow_setFramerateLimit,"sfWindow_setFramerateLimit"); 812 | lib.bindSymbol(cast(void**)&sfWindow_setJoystickThreshold,"sfWindow_setJoystickThreshold"); 813 | lib.bindSymbol(cast(void**)&sfWindow_getSystemHandle,"sfWindow_getSystemHandle"); 814 | 815 | if(errorCount() != errCount) return SFMLSupport.badLibrary; 816 | else loadedVersion = sfmlSupport.sfml200; 817 | 818 | static if(sfmlSupport >= SFMLSupport.sfml220){ 819 | lib.bindSymbol(cast(void**)&sfJoystick_getIdentification,"sfJoystick_getIdentification"); 820 | lib.bindSymbol(cast(void**)&sfSensor_isAvailable,"sfSensor_isAvailable"); 821 | lib.bindSymbol(cast(void**)&sfSensor_setEnabled,"sfSensor_setEnabled"); 822 | lib.bindSymbol(cast(void**)&sfSensor_getValue,"sfSensor_getValue"); 823 | lib.bindSymbol(cast(void**)&sfTouch_isDown,"sfTouch_isDown"); 824 | lib.bindSymbol(cast(void**)&sfTouch_getPosition,"sfTouch_getPosition"); 825 | lib.bindSymbol(cast(void**)&sfWindow_requestFocus,"sfWindow_requestFocus"); 826 | lib.bindSymbol(cast(void**)&sfWindow_hasFocus,"sfWindow_hasFocus"); 827 | 828 | if(errorCount() != errCount) return SFMLSupport.badLibrary; 829 | else{ 830 | static if(sfmlSupport >= SFMLSupport.sfml230){ 831 | loadedVersion = sfmlSupport.sfml230; 832 | }else{ 833 | loadedVersion = sfmlSupport.sfml220; 834 | } 835 | } 836 | } 837 | static if(sfmlSupport >= SFMLSupport.sfml240){ 838 | lib.bindSymbol(cast(void**)&sfContext_getSettings,"sfContext_getSettings"); 839 | lib.bindSymbol(cast(void**)&sfKeyboard_setVirtualKeyboardVisible,"sfKeyboard_setVirtualKeyboardVisible"); 840 | lib.bindSymbol(cast(void**)&sfWindow_setMouseCursorGrabbed,"sfWindow_setMouseCursorGrabbed"); 841 | 842 | if(errorCount() != errCount) return SFMLSupport.badLibrary; 843 | else loadedVersion = sfmlSupport.sfml240; 844 | } 845 | static if(sfmlSupport >= SFMLSupport.sfml250){ 846 | lib.bindSymbol(cast(void**)&sfClipboard_getString,"sfClipboard_getString"); 847 | lib.bindSymbol(cast(void**)&sfClipboard_getUnicodeString,"sfClipboard_getUnicodeString"); 848 | lib.bindSymbol(cast(void**)&sfClipboard_setString,"sfClipboard_setString"); 849 | lib.bindSymbol(cast(void**)&sfClipboard_setUnicodeString,"sfClipboard_setUnicodeString"); 850 | lib.bindSymbol(cast(void**)&sfContext_getActiveContextId,"sfContext_getActiveContextId"); 851 | lib.bindSymbol(cast(void**)&sfCursor_createFromPixels,"sfCursor_createFromPixels"); 852 | lib.bindSymbol(cast(void**)&sfCursor_createFromSystem,"sfCursor_createFromSystem"); 853 | lib.bindSymbol(cast(void**)&sfCursor_destroy,"sfCursor_destroy"); 854 | lib.bindSymbol(cast(void**)&sfWindow_setMouseCursor,"sfWindow_setMouseCursor"); 855 | 856 | if(errorCount() != errCount) return SFMLSupport.badLibrary; 857 | else loadedVersion = sfmlSupport.sfml250; 858 | } 859 | 860 | return loadedVersion; 861 | } 862 | } 863 | 864 | -------------------------------------------------------------------------------- /source/bindbc/sfml/audio.d: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2020 - 2021 Michael D. Parker 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | module bindbc.sfml.audio; 8 | 9 | import bindbc.sfml.config; 10 | static if(bindSFMLAudio): 11 | 12 | import bindbc.sfml.system; 13 | 14 | //Audio/Types.h 15 | struct sfMusic; 16 | struct sfSound; 17 | struct sfSoundBuffer; 18 | struct sfSoundBufferRecorder; 19 | struct sfSoundRecorder; 20 | struct sfSoundStream; 21 | 22 | static if(sfmlSupport >= SFMLSupport.sfml250){ 23 | struct sfTimeSpan{ 24 | sfTime offset; 25 | sfTime length; 26 | } 27 | } 28 | 29 | //Audio/SoundRecorder.h 30 | extern(C) nothrow{ 31 | alias sfSoundRecorderStartCallback = sfBool function(void*); 32 | alias sfSoundRecorderProcessCallback = sfBool function(const(sfInt16)*,size_t,void*); 33 | alias sfSoundRecorderStopCallback = void function(void*); 34 | } 35 | 36 | //Audio/SoundStatus.h 37 | enum sfSoundStatus{ 38 | sfStopped, 39 | sfPaused, 40 | sfPlaying, 41 | } 42 | mixin(expandEnum!sfSoundStatus); 43 | 44 | //Audio/SoundStream.h 45 | struct sfSoundStreamChunk{ 46 | sfInt16* samples; 47 | uint sampleCount; 48 | } 49 | 50 | extern(C) nothrow{ 51 | alias sfSoundStreamGetDataCallback = sfBool function(sfSoundStreamChunk*,void*); 52 | alias sfSoundStreamSeekCallback = void function(sfTime,void*); 53 | } 54 | 55 | static if(staticSFML){ 56 | extern(C) @nogc nothrow{ 57 | //Audio/Listener.h 58 | void sfListener_setGlobalVolume(float volume); 59 | float sfListener_getGlobalVolume(); 60 | void sfListener_setPosition(sfVector3f position); 61 | sfVector3f sfListener_getPosition(); 62 | void sfListener_setDirection(sfVector3f orientation); 63 | sfVector3f sfListener_getDirection(); 64 | 65 | //Audio/Music.h 66 | sfMusic* sfMusic_createFromFile(const(char)* filename); 67 | sfMusic* sfMusic_createFromMemory(const(void)* data, size_t sizeInBytes); 68 | sfMusic* sfMusic_createFromStream(sfInputStream* stream); 69 | void sfMusic_destroy(sfMusic* music); 70 | void sfMusic_setLoop(sfMusic* music, sfBool loop); 71 | sfBool sfMusic_getLoop(const(sfMusic)* music); 72 | sfTime sfMusic_getDuration(const(sfMusic)* music); 73 | void sfMusic_play(sfMusic* music); 74 | void sfMusic_pause(sfMusic* music); 75 | void sfMusic_stop(sfMusic* music); 76 | uint sfMusic_getChannelCount(const(sfMusic)* music); 77 | uint sfMusic_getSampleRate(const(sfMusic)* music); 78 | sfSoundStatus sfMusic_getStatus(const(sfMusic)* music); 79 | sfTime sfMusic_getPlayingOffset(const(sfMusic)* music); 80 | void sfMusic_setPitch(sfMusic* music, float pitch); 81 | void sfMusic_setVolume(sfMusic* music, float volume); 82 | void sfMusic_setPosition(sfMusic* music, sfVector3f position); 83 | void sfMusic_setRelativeToListener(sfMusic* music, sfBool relative); 84 | void sfMusic_setMinDistance(sfMusic* music, float distance); 85 | void sfMusic_setAttenuation(sfMusic* music, float attenuation); 86 | void sfMusic_setPlayingOffset(sfMusic* music, sfTime timeOffset); 87 | float sfMusic_getPitch(const(sfMusic)* music); 88 | float sfMusic_getVolume(const(sfMusic)* music); 89 | sfVector3f sfMusic_getPosition(const(sfMusic)* music); 90 | sfBool sfMusic_isRelativeToListener(const(sfMusic)* music); 91 | float sfMusic_getMinDistance(const(sfMusic)* music); 92 | float sfMusic_getAttenuation(const(sfMusic)* music); 93 | 94 | //Audio/Sound.h 95 | sfSound* sfSound_create(); 96 | sfSound* sfSound_copy(const(sfSound)* sound); 97 | void sfSound_destroy(sfSound* sound); 98 | void sfSound_play(sfSound* sound); 99 | void sfSound_pause(sfSound* sound); 100 | void sfSound_stop(sfSound* sound); 101 | void sfSound_setBuffer(sfSound* sound, const(sfSoundBuffer)* buffer); 102 | const(sfSoundBuffer)* sfSound_getBuffer(const(sfSound)* sound); 103 | void sfSound_setLoop(sfSound* sound, sfBool loop); 104 | sfBool sfSound_getLoop(const(sfSound)* sound); 105 | sfSoundStatus sfSound_getStatus(const(sfSound)* sound); 106 | void sfSound_setPitch(sfSound* sound, float pitch); 107 | void sfSound_setVolume(sfSound* sound, float volume); 108 | void sfSound_setPosition(sfSound* sound, sfVector3f position); 109 | void sfSound_setRelativeToListener(sfSound* sound, sfBool relative); 110 | void sfSound_setMinDistance(sfSound* sound, float distance); 111 | void sfSound_setAttenuation(sfSound* sound, float attenuation); 112 | void sfSound_setPlayingOffset(sfSound* sound, sfTime timeOffset); 113 | float sfSound_getPitch(const(sfSound)* sound); 114 | float sfSound_getVolume(const(sfSound)* sound); 115 | sfVector3f sfSound_getPosition(const(sfSound)* sound); 116 | sfBool sfSound_isRelativeToListener(const(sfSound)* sound); 117 | float sfSound_getMinDistance(const(sfSound)* sound); 118 | float sfSound_getAttenuation(const(sfSound)* sound); 119 | sfTime sfSound_getPlayingOffset(const(sfSound)* sound); 120 | 121 | //Audio/SoundBuffer.h 122 | sfSoundBuffer* sfSoundBuffer_createFromFile(const(char)* filename); 123 | sfSoundBuffer* sfSoundBuffer_createFromMemory(const(void)* data, size_t sizeInBytes); 124 | sfSoundBuffer* sfSoundBuffer_createFromStream(sfInputStream* stream); 125 | sfSoundBuffer* sfSoundBuffer_copy(const(sfSoundBuffer)* soundBuffer); 126 | void sfSoundBuffer_destroy(sfSoundBuffer* soundBuffer); 127 | sfBool sfSoundBuffer_saveToFile(const(sfSoundBuffer)* soundBuffer, const(char)* filename); 128 | const(sfInt16)* sfSoundBuffer_getSamples(const(sfSoundBuffer)* soundBuffer); 129 | uint sfSoundBuffer_getSampleRate(const(sfSoundBuffer)* soundBuffer); 130 | uint sfSoundBuffer_getChannelCount(const(sfSoundBuffer)* soundBuffer); 131 | sfTime sfSoundBuffer_getDuration(const(sfSoundBuffer)* soundBuffer); 132 | 133 | static if(sfmlSupport >= SFMLSupport.sfml230){ 134 | sfSoundBuffer* sfSoundBuffer_createFromSamples(const(sfInt16)* samples, sfUint64 sampleCount, uint channelCount, uint sampleRate); 135 | sfUint64 sfSoundBuffer_getSampleCount(const(sfSoundBuffer)* soundBuffer); 136 | }else{ 137 | sfSoundBuffer* sfSoundBuffer_createFromSamples(const(sfInt16)* samples, size_t sampleCount, uint channelCount, uint sampleRate); 138 | size_t sfSoundBuffer_getSampleCount(const(sfSoundBuffer)* soundBuffer); 139 | } 140 | 141 | //Audio/SoundBufferRecorder.h 142 | sfSoundBufferRecorder* sfSoundBufferRecorder_create(); 143 | void sfSoundBufferRecorder_destroy(sfSoundBufferRecorder* soundBufferRecorder); 144 | void sfSoundBufferRecorder_stop(sfSoundBufferRecorder* soundBufferRecorder); 145 | uint sfSoundBufferRecorder_getSampleRate(const(sfSoundBufferRecorder)* soundBufferRecorder); 146 | const(sfSoundBuffer)* sfSoundBufferRecorder_getBuffer(const(sfSoundBufferRecorder)* soundBufferRecorder); 147 | 148 | static if(sfmlSupport >= SFMLSupport.sfml240){ 149 | sfBool sfSoundBufferRecorder_start(sfSoundBufferRecorder* soundBufferRecorder, uint sampleRate); 150 | }else{ 151 | void sfSoundBufferRecorder_start(sfSoundBufferRecorder* soundBufferRecorder, uint sampleRate); 152 | } 153 | 154 | //Audio/SoundRecorder.h 155 | sfSoundRecorder* sfSoundRecorder_create(sfSoundRecorderStartCallback onStart, sfSoundRecorderProcessCallback onProcess, sfSoundRecorderStopCallback onStop, void* userData); 156 | void sfSoundRecorder_destroy(sfSoundRecorder* soundRecorder); 157 | void sfSoundRecorder_stop(sfSoundRecorder* soundRecorder); 158 | uint sfSoundRecorder_getSampleRate(const(sfSoundRecorder)* soundRecorder); 159 | sfBool sfSoundRecorder_isAvailable(); 160 | 161 | static if(sfmlSupport >= SFMLSupport.sfml220){ 162 | sfBool sfSoundRecorder_start(sfSoundRecorder* soundRecorder, uint sampleRate); 163 | }else{ 164 | void sfSoundRecorder_start(sfSoundRecorder* soundRecorder, uint sampleRate); 165 | } 166 | 167 | //Audio/SoundStream.h 168 | sfSoundStream* sfSoundStream_create(sfSoundStreamGetDataCallback onGetData, sfSoundStreamSeekCallback onSeek, uint channelCount, uint sampleRate, void* userData); 169 | void sfSoundStream_destroy(sfSoundStream* soundStream); 170 | void sfSoundStream_play(sfSoundStream* soundStream); 171 | void sfSoundStream_pause(sfSoundStream* soundStream); 172 | void sfSoundStream_stop(sfSoundStream* soundStream); 173 | sfSoundStatus sfSoundStream_getStatus(const(sfSoundStream)* soundStream); 174 | uint sfSoundStream_getChannelCount(const(sfSoundStream)* soundStream); 175 | uint sfSoundStream_getSampleRate(const(sfSoundStream)* soundStream); 176 | void sfSoundStream_setPitch(sfSoundStream* soundStream, float pitch); 177 | void sfSoundStream_setVolume(sfSoundStream* soundStream, float volume); 178 | void sfSoundStream_setPosition(sfSoundStream* soundStream, sfVector3f position); 179 | void sfSoundStream_setRelativeToListener(sfSoundStream* soundStream, sfBool relative); 180 | void sfSoundStream_setMinDistance(sfSoundStream* soundStream, float distance); 181 | void sfSoundStream_setAttenuation(sfSoundStream* soundStream, float attenuation); 182 | void sfSoundStream_setPlayingOffset(sfSoundStream* soundStream, sfTime timeOffset); 183 | void sfSoundStream_setLoop(sfSoundStream* soundStream, sfBool loop); 184 | float sfSoundStream_getPitch(const(sfSoundStream)* soundStream); 185 | float sfSoundStream_getVolume(const(sfSoundStream)* soundStream); 186 | sfVector3f sfSoundStream_getPosition(const(sfSoundStream)* soundStream); 187 | sfBool sfSoundStream_isRelativeToListener(const(sfSoundStream)* soundStream); 188 | float sfSoundStream_getMinDistance(const(sfSoundStream)* soundStream); 189 | float sfSoundStream_getAttenuation(const(sfSoundStream)* soundStream); 190 | sfBool sfSoundStream_getLoop(const(sfSoundStream)* soundStream); 191 | sfTime sfSoundStream_getPlayingOffset(const(sfSoundStream)* soundStream); 192 | 193 | static if(sfmlSupport >= SFMLSupport.sfml220){ 194 | //Audio/Listener.h 195 | void sfListener_setUpVector(sfVector3f upVector); 196 | sfVector3f sfListener_getUpVector(); 197 | 198 | //Audio/SoundRecorder.h 199 | void sfSoundRecorder_setProcessingInterval(sfSoundRecorder* soundRecorder, sfTime interval); 200 | const(char*)* sfSoundRecorder_getAvailableDevices(size_t* count); 201 | const(char)* sfSoundRecorder_getDefaultDevice(); 202 | sfBool sfSoundRecorder_setDevice(sfSoundRecorder* soundRecorder, const(char)* name); 203 | const(char)* sfSoundRecorder_getDevice(sfSoundRecorder* soundRecorder); 204 | } 205 | static if(sfmlSupport >= sfmlSupport.sfml240){ 206 | //Audio/SoundBufferRecorder.h 207 | sfBool sfSoundBufferRecorder_setDevice(sfSoundBufferRecorder* soundBufferRecorder, const(char)* name); 208 | const(char)* sfSoundBufferRecorder_getDevice(sfSoundBufferRecorder* soundBufferRecorder); 209 | 210 | //Audio/SoundRecorder.h 211 | void sfSoundRecorder_setChannelCount(sfSoundRecorder* soundRecorder, uint channelCount); 212 | uint sfSoundRecorder_getChannelCount(const(sfSoundRecorder)* soundRecorder); 213 | } 214 | static if(sfmlSupport >= sfmlSupport.sfml250){ 215 | //Audio/Music.h 216 | sfTimeSpan sfMusic_getLoopPoints(const(sfMusic)* music); 217 | void sfMusic_setLoopPoints(sfMusic* music, sfTimeSpan timePoints); 218 | } 219 | } 220 | }else{ 221 | import bindbc.loader; 222 | 223 | extern(C) @nogc nothrow{ 224 | //Audio/Listener.h 225 | alias psfListener_setGlobalVolume = void function(float volume); 226 | alias psfListener_getGlobalVolume = float function(); 227 | alias psfListener_setPosition = void function(sfVector3f position); 228 | alias psfListener_getPosition = sfVector3f function(); 229 | alias psfListener_setDirection = void function(sfVector3f orientation); 230 | alias psfListener_getDirection = sfVector3f function(); 231 | 232 | //Audio/Music.h 233 | alias psfMusic_createFromFile = sfMusic* function(const(char)* filename); 234 | alias psfMusic_createFromMemory = sfMusic* function(const(void)* data, size_t sizeInBytes); 235 | alias psfMusic_createFromStream = sfMusic* function(sfInputStream* stream); 236 | alias psfMusic_destroy = void function(sfMusic* music); 237 | alias psfMusic_setLoop = void function(sfMusic* music, sfBool loop); 238 | alias psfMusic_getLoop = sfBool function(const(sfMusic)* music); 239 | alias psfMusic_getDuration = sfTime function(const(sfMusic)* music); 240 | alias psfMusic_play = void function(sfMusic* music); 241 | alias psfMusic_pause = void function(sfMusic* music); 242 | alias psfMusic_stop = void function(sfMusic* music); 243 | alias psfMusic_getChannelCount = uint function(const(sfMusic)* music); 244 | alias psfMusic_getSampleRate = uint function(const(sfMusic)* music); 245 | alias psfMusic_getStatus = sfSoundStatus function(const(sfMusic)* music); 246 | alias psfMusic_getPlayingOffset = sfTime function(const(sfMusic)* music); 247 | alias psfMusic_setPitch = void function(sfMusic* music, float pitch); 248 | alias psfMusic_setVolume = void function(sfMusic* music, float volume); 249 | alias psfMusic_setPosition = void function(sfMusic* music, sfVector3f position); 250 | alias psfMusic_setRelativeToListener = void function(sfMusic* music, sfBool relative); 251 | alias psfMusic_setMinDistance = void function(sfMusic* music, float distance); 252 | alias psfMusic_setAttenuation = void function(sfMusic* music, float attenuation); 253 | alias psfMusic_setPlayingOffset = void function(sfMusic* music, sfTime timeOffset); 254 | alias psfMusic_getPitch = float function(const(sfMusic)* music); 255 | alias psfMusic_getVolume = float function(const(sfMusic)* music); 256 | alias psfMusic_getPosition = sfVector3f function(const(sfMusic)* music); 257 | alias psfMusic_isRelativeToListener = sfBool function(const(sfMusic)* music); 258 | alias psfMusic_getMinDistance = float function(const(sfMusic)* music); 259 | alias psfMusic_getAttenuation = float function(const(sfMusic)* music); 260 | 261 | //Audio/Sound.h 262 | alias psfSound_create = sfSound* function(); 263 | alias psfSound_copy = sfSound* function(const(sfSound)* sound); 264 | alias psfSound_destroy = void function(sfSound* sound); 265 | alias psfSound_play = void function(sfSound* sound); 266 | alias psfSound_pause = void function(sfSound* sound); 267 | alias psfSound_stop = void function(sfSound* sound); 268 | alias psfSound_setBuffer = void function(sfSound* sound, const(sfSoundBuffer)* buffer); 269 | alias psfSound_getBuffer = const(sfSoundBuffer)* function(const(sfSound)* sound); 270 | alias psfSound_setLoop = void function(sfSound* sound, sfBool loop); 271 | alias psfSound_getLoop = sfBool function(const(sfSound)* sound); 272 | alias psfSound_getStatus = sfSoundStatus function(const(sfSound)* sound); 273 | alias psfSound_setPitch = void function(sfSound* sound, float pitch); 274 | alias psfSound_setVolume = void function(sfSound* sound, float volume); 275 | alias psfSound_setPosition = void function(sfSound* sound, sfVector3f position); 276 | alias psfSound_setRelativeToListener = void function(sfSound* sound, sfBool relative); 277 | alias psfSound_setMinDistance = void function(sfSound* sound, float distance); 278 | alias psfSound_setAttenuation = void function(sfSound* sound, float attenuation); 279 | alias psfSound_setPlayingOffset = void function(sfSound* sound, sfTime timeOffset); 280 | alias psfSound_getPitch = float function(const(sfSound)* sound); 281 | alias psfSound_getVolume = float function(const(sfSound)* sound); 282 | alias psfSound_getPosition = sfVector3f function(const(sfSound)* sound); 283 | alias psfSound_isRelativeToListener = sfBool function(const(sfSound)* sound); 284 | alias psfSound_getMinDistance = float function(const(sfSound)* sound); 285 | alias psfSound_getAttenuation = float function(const(sfSound)* sound); 286 | alias psfSound_getPlayingOffset = sfTime function(const(sfSound)* sound); 287 | 288 | //Audio/SoundBuffer.h 289 | alias psfSoundBuffer_createFromFile = sfSoundBuffer* function(const(char)* filename); 290 | alias psfSoundBuffer_createFromMemory = sfSoundBuffer* function(const(void)* data, size_t sizeInBytes); 291 | alias psfSoundBuffer_createFromStream = sfSoundBuffer* function(sfInputStream* stream); 292 | alias psfSoundBuffer_copy = sfSoundBuffer* function(const(sfSoundBuffer)* soundBuffer); 293 | alias psfSoundBuffer_destroy = void function(sfSoundBuffer* soundBuffer); 294 | alias psfSoundBuffer_saveToFile = sfBool function(const(sfSoundBuffer)* soundBuffer, const(char)* filename); 295 | alias psfSoundBuffer_getSamples = const(sfInt16)* function(const(sfSoundBuffer)* soundBuffer); 296 | alias psfSoundBuffer_getSampleRate = uint function(const(sfSoundBuffer)* soundBuffer); 297 | alias psfSoundBuffer_getChannelCount = uint function(const(sfSoundBuffer)* soundBuffer); 298 | alias psfSoundBuffer_getDuration = sfTime function(const(sfSoundBuffer)* soundBuffer); 299 | 300 | static if(sfmlSupport >= SFMLSupport.sfml230){ 301 | alias psfSoundBuffer_createFromSamples = sfSoundBuffer* function(const(sfInt16)* samples, sfUint64 sampleCount, uint channelCount, uint sampleRate); 302 | alias psfSoundBuffer_getSampleCount = sfUint64 function(const(sfSoundBuffer)* soundBuffer); 303 | }else{ 304 | alias psfSoundBuffer_createFromSamples = sfSoundBuffer* function(const(sfInt16)* samples, size_t sampleCount, uint channelCount, uint sampleRate); 305 | alias psfSoundBuffer_getSampleCount = size_t function(const(sfSoundBuffer)* soundBuffer); 306 | } 307 | 308 | //Audio/SoundBufferRecorder.h 309 | alias psfSoundBufferRecorder_create = sfSoundBufferRecorder* function(); 310 | alias psfSoundBufferRecorder_destroy = void function(sfSoundBufferRecorder* soundBufferRecorder); 311 | alias psfSoundBufferRecorder_stop = void function(sfSoundBufferRecorder* soundBufferRecorder); 312 | alias psfSoundBufferRecorder_getSampleRate = uint function(const(sfSoundBufferRecorder)* soundBufferRecorder); 313 | alias psfSoundBufferRecorder_getBuffer = const(sfSoundBuffer)* function(const(sfSoundBufferRecorder)* soundBufferRecorder); 314 | 315 | static if(sfmlSupport >= SFMLSupport.sfml240){ 316 | alias psfSoundBufferRecorder_start = sfBool function(sfSoundBufferRecorder* soundBufferRecorder, uint sampleRate); 317 | }else{ 318 | alias psfSoundBufferRecorder_start = void function(sfSoundBufferRecorder* soundBufferRecorder, uint sampleRate); 319 | } 320 | 321 | //Audio/SoundRecorder.h 322 | alias psfSoundRecorder_create = sfSoundRecorder* function(sfSoundRecorderStartCallback onStart, sfSoundRecorderProcessCallback onProcess, sfSoundRecorderStopCallback onStop, void* userData); 323 | alias psfSoundRecorder_destroy = void function(sfSoundRecorder* soundRecorder); 324 | alias psfSoundRecorder_stop = void function(sfSoundRecorder* soundRecorder); 325 | alias psfSoundRecorder_getSampleRate = uint function(const(sfSoundRecorder)* soundRecorder); 326 | alias psfSoundRecorder_isAvailable = sfBool function(); 327 | 328 | static if(sfmlSupport >= SFMLSupport.sfml220){ 329 | alias psfSoundRecorder_start = sfBool function(sfSoundRecorder* soundRecorder, uint sampleRate); 330 | }else{ 331 | alias psfSoundRecorder_start = void function(sfSoundRecorder* soundRecorder, uint sampleRate); 332 | } 333 | 334 | //Audio/SoundStream.h 335 | alias psfSoundStream_create = sfSoundStream* function(sfSoundStreamGetDataCallback onGetData, sfSoundStreamSeekCallback onSeek, uint channelCount, uint sampleRate, void* userData); 336 | alias psfSoundStream_destroy = void function(sfSoundStream* soundStream); 337 | alias psfSoundStream_play = void function(sfSoundStream* soundStream); 338 | alias psfSoundStream_pause = void function(sfSoundStream* soundStream); 339 | alias psfSoundStream_stop = void function(sfSoundStream* soundStream); 340 | alias psfSoundStream_getStatus = sfSoundStatus function(const(sfSoundStream)* soundStream); 341 | alias psfSoundStream_getChannelCount = uint function(const(sfSoundStream)* soundStream); 342 | alias psfSoundStream_getSampleRate = uint function(const(sfSoundStream)* soundStream); 343 | alias psfSoundStream_setPitch = void function(sfSoundStream* soundStream, float pitch); 344 | alias psfSoundStream_setVolume = void function(sfSoundStream* soundStream, float volume); 345 | alias psfSoundStream_setPosition = void function(sfSoundStream* soundStream, sfVector3f position); 346 | alias psfSoundStream_setRelativeToListener = void function(sfSoundStream* soundStream, sfBool relative); 347 | alias psfSoundStream_setMinDistance = void function(sfSoundStream* soundStream, float distance); 348 | alias psfSoundStream_setAttenuation = void function(sfSoundStream* soundStream, float attenuation); 349 | alias psfSoundStream_setPlayingOffset = void function(sfSoundStream* soundStream, sfTime timeOffset); 350 | alias psfSoundStream_setLoop = void function(sfSoundStream* soundStream, sfBool loop); 351 | alias psfSoundStream_getPitch = float function(const(sfSoundStream)* soundStream); 352 | alias psfSoundStream_getVolume = float function(const(sfSoundStream)* soundStream); 353 | alias psfSoundStream_getPosition = sfVector3f function(const(sfSoundStream)* soundStream); 354 | alias psfSoundStream_isRelativeToListener = sfBool function(const(sfSoundStream)* soundStream); 355 | alias psfSoundStream_getMinDistance = float function(const(sfSoundStream)* soundStream); 356 | alias psfSoundStream_getAttenuation = float function(const(sfSoundStream)* soundStream); 357 | alias psfSoundStream_getLoop = sfBool function(const(sfSoundStream)* soundStream); 358 | alias psfSoundStream_getPlayingOffset = sfTime function(const(sfSoundStream)* soundStream); 359 | 360 | static if(sfmlSupport >= SFMLSupport.sfml220){ 361 | //Audio/Listener.h 362 | alias psfListener_setUpVector = void function(sfVector3f upVector); 363 | alias psfListener_getUpVector = sfVector3f function(); 364 | 365 | //Audio/SoundRecorder.h 366 | alias psfSoundRecorder_setProcessingInterval = void function(sfSoundRecorder* soundRecorder, sfTime interval); 367 | alias psfSoundRecorder_getAvailableDevices = const(char*)* function(size_t* count); 368 | alias psfSoundRecorder_getDefaultDevice = const(char)* function(); 369 | alias psfSoundRecorder_setDevice = sfBool function(sfSoundRecorder* soundRecorder, const(char)* name); 370 | alias psfSoundRecorder_getDevice = const(char)* function(sfSoundRecorder* soundRecorder); 371 | } 372 | static if(sfmlSupport >= sfmlSupport.sfml240){ 373 | //Audio/SoundBufferRecorder.h 374 | alias psfSoundBufferRecorder_setDevice = sfBool function(sfSoundBufferRecorder* soundBufferRecorder, const(char)* name); 375 | alias psfSoundBufferRecorder_getDevice = const(char)* function(sfSoundBufferRecorder* soundBufferRecorder); 376 | 377 | //Audio/SoundRecorder.h 378 | alias psfSoundRecorder_setChannelCount = void function(sfSoundRecorder* soundRecorder, uint channelCount); 379 | alias psfSoundRecorder_getChannelCount = uint function(const(sfSoundRecorder)* soundRecorder); 380 | } 381 | static if(sfmlSupport >= sfmlSupport.sfml250){ 382 | //Audio/Music.h 383 | alias psfMusic_getLoopPoints = sfTimeSpan function(const(sfMusic)* music); 384 | alias psfMusic_setLoopPoints = void function(sfMusic* music, sfTimeSpan timePoints); 385 | } 386 | } 387 | 388 | __gshared{ 389 | psfListener_setGlobalVolume sfListener_setGlobalVolume; 390 | psfListener_getGlobalVolume sfListener_getGlobalVolume; 391 | psfListener_setPosition sfListener_setPosition; 392 | psfListener_getPosition sfListener_getPosition; 393 | psfListener_setDirection sfListener_setDirection; 394 | psfListener_getDirection sfListener_getDirection; 395 | psfMusic_createFromFile sfMusic_createFromFile; 396 | psfMusic_createFromMemory sfMusic_createFromMemory; 397 | psfMusic_createFromStream sfMusic_createFromStream; 398 | psfMusic_destroy sfMusic_destroy; 399 | psfMusic_setLoop sfMusic_setLoop; 400 | psfMusic_getLoop sfMusic_getLoop; 401 | psfMusic_getDuration sfMusic_getDuration; 402 | psfMusic_play sfMusic_play; 403 | psfMusic_pause sfMusic_pause; 404 | psfMusic_stop sfMusic_stop; 405 | psfMusic_getChannelCount sfMusic_getChannelCount; 406 | psfMusic_getSampleRate sfMusic_getSampleRate; 407 | psfMusic_getStatus sfMusic_getStatus; 408 | psfMusic_getPlayingOffset sfMusic_getPlayingOffset; 409 | psfMusic_setPitch sfMusic_setPitch; 410 | psfMusic_setVolume sfMusic_setVolume; 411 | psfMusic_setPosition sfMusic_setPosition; 412 | psfMusic_setRelativeToListener sfMusic_setRelativeToListener; 413 | psfMusic_setMinDistance sfMusic_setMinDistance; 414 | psfMusic_setAttenuation sfMusic_setAttenuation; 415 | psfMusic_setPlayingOffset sfMusic_setPlayingOffset; 416 | psfMusic_getPitch sfMusic_getPitch; 417 | psfMusic_getVolume sfMusic_getVolume; 418 | psfMusic_getPosition sfMusic_getPosition; 419 | psfMusic_isRelativeToListener sfMusic_isRelativeToListener; 420 | psfMusic_getMinDistance sfMusic_getMinDistance; 421 | psfMusic_getAttenuation sfMusic_getAttenuation; 422 | psfSound_create sfSound_create; 423 | psfSound_copy sfSound_copy; 424 | psfSound_destroy sfSound_destroy; 425 | psfSound_play sfSound_play; 426 | psfSound_pause sfSound_pause; 427 | psfSound_stop sfSound_stop; 428 | psfSound_setBuffer sfSound_setBuffer; 429 | psfSound_getBuffer sfSound_getBuffer; 430 | psfSound_setLoop sfSound_setLoop; 431 | psfSound_getLoop sfSound_getLoop; 432 | psfSound_getStatus sfSound_getStatus; 433 | psfSound_setPitch sfSound_setPitch; 434 | psfSound_setVolume sfSound_setVolume; 435 | psfSound_setPosition sfSound_setPosition; 436 | psfSound_setRelativeToListener sfSound_setRelativeToListener; 437 | psfSound_setMinDistance sfSound_setMinDistance; 438 | psfSound_setAttenuation sfSound_setAttenuation; 439 | psfSound_setPlayingOffset sfSound_setPlayingOffset; 440 | psfSound_getPitch sfSound_getPitch; 441 | psfSound_getVolume sfSound_getVolume; 442 | psfSound_getPosition sfSound_getPosition; 443 | psfSound_isRelativeToListener sfSound_isRelativeToListener; 444 | psfSound_getMinDistance sfSound_getMinDistance; 445 | psfSound_getAttenuation sfSound_getAttenuation; 446 | psfSound_getPlayingOffset sfSound_getPlayingOffset; 447 | psfSoundBuffer_createFromFile sfSoundBuffer_createFromFile; 448 | psfSoundBuffer_createFromMemory sfSoundBuffer_createFromMemory; 449 | psfSoundBuffer_createFromStream sfSoundBuffer_createFromStream; 450 | psfSoundBuffer_createFromSamples sfSoundBuffer_createFromSamples; 451 | psfSoundBuffer_copy sfSoundBuffer_copy; 452 | psfSoundBuffer_destroy sfSoundBuffer_destroy; 453 | psfSoundBuffer_saveToFile sfSoundBuffer_saveToFile; 454 | psfSoundBuffer_getSamples sfSoundBuffer_getSamples; 455 | psfSoundBuffer_getSampleCount sfSoundBuffer_getSampleCount; 456 | psfSoundBuffer_getSampleRate sfSoundBuffer_getSampleRate; 457 | psfSoundBuffer_getChannelCount sfSoundBuffer_getChannelCount; 458 | psfSoundBuffer_getDuration sfSoundBuffer_getDuration; 459 | psfSoundBufferRecorder_create sfSoundBufferRecorder_create; 460 | psfSoundBufferRecorder_destroy sfSoundBufferRecorder_destroy; 461 | psfSoundBufferRecorder_start sfSoundBufferRecorder_start; 462 | psfSoundBufferRecorder_stop sfSoundBufferRecorder_stop; 463 | psfSoundBufferRecorder_getSampleRate sfSoundBufferRecorder_getSampleRate; 464 | psfSoundBufferRecorder_getBuffer sfSoundBufferRecorder_getBuffer; 465 | psfSoundRecorder_create sfSoundRecorder_create; 466 | psfSoundRecorder_destroy sfSoundRecorder_destroy; 467 | psfSoundRecorder_start sfSoundRecorder_start; 468 | psfSoundRecorder_stop sfSoundRecorder_stop; 469 | psfSoundRecorder_getSampleRate sfSoundRecorder_getSampleRate; 470 | psfSoundRecorder_isAvailable sfSoundRecorder_isAvailable; 471 | psfSoundStream_create sfSoundStream_create; 472 | psfSoundStream_destroy sfSoundStream_destroy; 473 | psfSoundStream_play sfSoundStream_play; 474 | psfSoundStream_pause sfSoundStream_pause; 475 | psfSoundStream_stop sfSoundStream_stop; 476 | psfSoundStream_getStatus sfSoundStream_getStatus; 477 | psfSoundStream_getChannelCount sfSoundStream_getChannelCount; 478 | psfSoundStream_getSampleRate sfSoundStream_getSampleRate; 479 | psfSoundStream_setPitch sfSoundStream_setPitch; 480 | psfSoundStream_setVolume sfSoundStream_setVolume; 481 | psfSoundStream_setPosition sfSoundStream_setPosition; 482 | psfSoundStream_setRelativeToListener sfSoundStream_setRelativeToListener; 483 | psfSoundStream_setMinDistance sfSoundStream_setMinDistance; 484 | psfSoundStream_setAttenuation sfSoundStream_setAttenuation; 485 | psfSoundStream_setPlayingOffset sfSoundStream_setPlayingOffset; 486 | psfSoundStream_setLoop sfSoundStream_setLoop; 487 | psfSoundStream_getPitch sfSoundStream_getPitch; 488 | psfSoundStream_getVolume sfSoundStream_getVolume; 489 | psfSoundStream_getPosition sfSoundStream_getPosition; 490 | psfSoundStream_isRelativeToListener sfSoundStream_isRelativeToListener; 491 | psfSoundStream_getMinDistance sfSoundStream_getMinDistance; 492 | psfSoundStream_getAttenuation sfSoundStream_getAttenuation; 493 | psfSoundStream_getLoop sfSoundStream_getLoop; 494 | psfSoundStream_getPlayingOffset sfSoundStream_getPlayingOffset; 495 | 496 | static if(sfmlSupport >= SFMLSupport.sfml220){ 497 | psfListener_setUpVector sfListener_setUpVector; 498 | psfListener_getUpVector sfListener_getUpVector; 499 | psfSoundRecorder_setProcessingInterval sfSoundRecorder_setProcessingInterval; 500 | psfSoundRecorder_getAvailableDevices sfSoundRecorder_getAvailableDevices; 501 | psfSoundRecorder_getDefaultDevice sfSoundRecorder_getDefaultDevice; 502 | psfSoundRecorder_setDevice sfSoundRecorder_setDevice; 503 | psfSoundRecorder_getDevice sfSoundRecorder_getDevice; 504 | } 505 | static if(sfmlSupport >= SFMLSupport.sfml240){ 506 | psfSoundBufferRecorder_setDevice sfSoundBufferRecorder_setDevice; 507 | psfSoundBufferRecorder_getDevice sfSoundBufferRecorder_getDevice; 508 | psfSoundRecorder_setChannelCount sfSoundRecorder_setChannelCount; 509 | psfSoundRecorder_getChannelCount sfSoundRecorder_getChannelCount; 510 | } 511 | static if(sfmlSupport >= sfmlSupport.sfml250){ 512 | psfMusic_getLoopPoints sfMusic_getLoopPoints; 513 | psfMusic_setLoopPoints sfMusic_setLoopPoints; 514 | } 515 | } 516 | private{ 517 | SharedLib lib; 518 | SFMLSupport loadedVersion; 519 | } 520 | 521 | @nogc nothrow: 522 | SFMLSupport loadedSFMLAudioVersion(){ return loadedVersion; } 523 | 524 | bool isSFMLAudioLoaded(){ 525 | return lib != invalidHandle; 526 | } 527 | 528 | SFMLSupport loadSFMLAudio(){ 529 | version(Windows){ 530 | const(char)[][3] libNames = [ 531 | "csfml-audio.dll", 532 | "csfml-audio-2.dll", 533 | "csfml-audio-2.0.dll" 534 | ]; 535 | }else version(OSX){ 536 | const(char)[][3] libNames = [ 537 | "libcsfml-audio.dylib", 538 | "libcsfml-audio.2.dylib", 539 | "libcsfml-audio.2.0.dylib" 540 | ]; 541 | }else version(Posix){ 542 | const(char)[][3] libNames = [ 543 | "libcsfml-audio.so", 544 | "libcsfml-audio.so.2", 545 | "libcsfml-audio.so.2.0" 546 | ]; 547 | } 548 | 549 | SFMLSupport ret; 550 | foreach(name; libNames){ 551 | ret = loadSFMLAudio(name.ptr); 552 | if(ret != SFMLSupport.noLibrary) break; 553 | } 554 | return ret; 555 | } 556 | 557 | SFMLSupport loadSFMLAudio(const(char)* libName){ 558 | lib = load(libName); 559 | if(lib == invalidHandle){ 560 | return SFMLSupport.noLibrary; 561 | } 562 | 563 | auto errCount = errorCount(); 564 | loadedVersion = SFMLSupport.badLibrary; 565 | 566 | lib.bindSymbol(cast(void**)&sfListener_setGlobalVolume,"sfListener_setGlobalVolume"); 567 | lib.bindSymbol(cast(void**)&sfListener_getGlobalVolume,"sfListener_getGlobalVolume"); 568 | lib.bindSymbol(cast(void**)&sfListener_setPosition,"sfListener_setPosition"); 569 | lib.bindSymbol(cast(void**)&sfListener_getPosition,"sfListener_getPosition"); 570 | lib.bindSymbol(cast(void**)&sfListener_setDirection,"sfListener_setDirection"); 571 | lib.bindSymbol(cast(void**)&sfListener_getDirection,"sfListener_getDirection"); 572 | lib.bindSymbol(cast(void**)&sfMusic_createFromFile,"sfMusic_createFromFile"); 573 | lib.bindSymbol(cast(void**)&sfMusic_createFromMemory,"sfMusic_createFromMemory"); 574 | lib.bindSymbol(cast(void**)&sfMusic_createFromStream,"sfMusic_createFromStream"); 575 | lib.bindSymbol(cast(void**)&sfMusic_destroy,"sfMusic_destroy"); 576 | lib.bindSymbol(cast(void**)&sfMusic_setLoop,"sfMusic_setLoop"); 577 | lib.bindSymbol(cast(void**)&sfMusic_getLoop,"sfMusic_getLoop"); 578 | lib.bindSymbol(cast(void**)&sfMusic_getDuration,"sfMusic_getDuration"); 579 | lib.bindSymbol(cast(void**)&sfMusic_play,"sfMusic_play"); 580 | lib.bindSymbol(cast(void**)&sfMusic_pause,"sfMusic_pause"); 581 | lib.bindSymbol(cast(void**)&sfMusic_stop,"sfMusic_stop"); 582 | lib.bindSymbol(cast(void**)&sfMusic_getChannelCount,"sfMusic_getChannelCount"); 583 | lib.bindSymbol(cast(void**)&sfMusic_getSampleRate,"sfMusic_getSampleRate"); 584 | lib.bindSymbol(cast(void**)&sfMusic_getStatus,"sfMusic_getStatus"); 585 | lib.bindSymbol(cast(void**)&sfMusic_getPlayingOffset,"sfMusic_getPlayingOffset"); 586 | lib.bindSymbol(cast(void**)&sfMusic_setPitch,"sfMusic_setPitch"); 587 | lib.bindSymbol(cast(void**)&sfMusic_setVolume,"sfMusic_setVolume"); 588 | lib.bindSymbol(cast(void**)&sfMusic_setPosition,"sfMusic_setPosition"); 589 | lib.bindSymbol(cast(void**)&sfMusic_setRelativeToListener,"sfMusic_setRelativeToListener"); 590 | lib.bindSymbol(cast(void**)&sfMusic_setMinDistance,"sfMusic_setMinDistance"); 591 | lib.bindSymbol(cast(void**)&sfMusic_setAttenuation,"sfMusic_setAttenuation"); 592 | lib.bindSymbol(cast(void**)&sfMusic_setPlayingOffset,"sfMusic_setPlayingOffset"); 593 | lib.bindSymbol(cast(void**)&sfMusic_getPitch,"sfMusic_getPitch"); 594 | lib.bindSymbol(cast(void**)&sfMusic_getVolume,"sfMusic_getVolume"); 595 | lib.bindSymbol(cast(void**)&sfMusic_getPosition,"sfMusic_getPosition"); 596 | lib.bindSymbol(cast(void**)&sfMusic_isRelativeToListener,"sfMusic_isRelativeToListener"); 597 | lib.bindSymbol(cast(void**)&sfMusic_getMinDistance,"sfMusic_getMinDistance"); 598 | lib.bindSymbol(cast(void**)&sfMusic_getAttenuation,"sfMusic_getAttenuation"); 599 | lib.bindSymbol(cast(void**)&sfSound_create,"sfSound_create"); 600 | lib.bindSymbol(cast(void**)&sfSound_copy,"sfSound_copy"); 601 | lib.bindSymbol(cast(void**)&sfSound_destroy,"sfSound_destroy"); 602 | lib.bindSymbol(cast(void**)&sfSound_play,"sfSound_play"); 603 | lib.bindSymbol(cast(void**)&sfSound_pause,"sfSound_pause"); 604 | lib.bindSymbol(cast(void**)&sfSound_stop,"sfSound_stop"); 605 | lib.bindSymbol(cast(void**)&sfSound_setBuffer,"sfSound_setBuffer"); 606 | lib.bindSymbol(cast(void**)&sfSound_getBuffer,"sfSound_getBuffer"); 607 | lib.bindSymbol(cast(void**)&sfSound_setLoop,"sfSound_setLoop"); 608 | lib.bindSymbol(cast(void**)&sfSound_getLoop,"sfSound_getLoop"); 609 | lib.bindSymbol(cast(void**)&sfSound_getStatus,"sfSound_getStatus"); 610 | lib.bindSymbol(cast(void**)&sfSound_setPitch,"sfSound_setPitch"); 611 | lib.bindSymbol(cast(void**)&sfSound_setVolume,"sfSound_setVolume"); 612 | lib.bindSymbol(cast(void**)&sfSound_setPosition,"sfSound_setPosition"); 613 | lib.bindSymbol(cast(void**)&sfSound_setRelativeToListener,"sfSound_setRelativeToListener"); 614 | lib.bindSymbol(cast(void**)&sfSound_setMinDistance,"sfSound_setMinDistance"); 615 | lib.bindSymbol(cast(void**)&sfSound_setAttenuation,"sfSound_setAttenuation"); 616 | lib.bindSymbol(cast(void**)&sfSound_setPlayingOffset,"sfSound_setPlayingOffset"); 617 | lib.bindSymbol(cast(void**)&sfSound_getPitch,"sfSound_getPitch"); 618 | lib.bindSymbol(cast(void**)&sfSound_getVolume,"sfSound_getVolume"); 619 | lib.bindSymbol(cast(void**)&sfSound_getPosition,"sfSound_getPosition"); 620 | lib.bindSymbol(cast(void**)&sfSound_isRelativeToListener,"sfSound_isRelativeToListener"); 621 | lib.bindSymbol(cast(void**)&sfSound_getMinDistance,"sfSound_getMinDistance"); 622 | lib.bindSymbol(cast(void**)&sfSound_getAttenuation,"sfSound_getAttenuation"); 623 | lib.bindSymbol(cast(void**)&sfSound_getPlayingOffset,"sfSound_getPlayingOffset"); 624 | lib.bindSymbol(cast(void**)&sfSoundBuffer_createFromFile,"sfSoundBuffer_createFromFile"); 625 | lib.bindSymbol(cast(void**)&sfSoundBuffer_createFromMemory,"sfSoundBuffer_createFromMemory"); 626 | lib.bindSymbol(cast(void**)&sfSoundBuffer_createFromStream,"sfSoundBuffer_createFromStream"); 627 | lib.bindSymbol(cast(void**)&sfSoundBuffer_createFromSamples,"sfSoundBuffer_createFromSamples"); 628 | lib.bindSymbol(cast(void**)&sfSoundBuffer_copy,"sfSoundBuffer_copy"); 629 | lib.bindSymbol(cast(void**)&sfSoundBuffer_destroy,"sfSoundBuffer_destroy"); 630 | lib.bindSymbol(cast(void**)&sfSoundBuffer_saveToFile,"sfSoundBuffer_saveToFile"); 631 | lib.bindSymbol(cast(void**)&sfSoundBuffer_getSamples,"sfSoundBuffer_getSamples"); 632 | lib.bindSymbol(cast(void**)&sfSoundBuffer_getSampleCount,"sfSoundBuffer_getSampleCount"); 633 | lib.bindSymbol(cast(void**)&sfSoundBuffer_getSampleRate,"sfSoundBuffer_getSampleRate"); 634 | lib.bindSymbol(cast(void**)&sfSoundBuffer_getChannelCount,"sfSoundBuffer_getChannelCount"); 635 | lib.bindSymbol(cast(void**)&sfSoundBuffer_getDuration,"sfSoundBuffer_getDuration"); 636 | lib.bindSymbol(cast(void**)&sfSoundBufferRecorder_create,"sfSoundBufferRecorder_create"); 637 | lib.bindSymbol(cast(void**)&sfSoundBufferRecorder_destroy,"sfSoundBufferRecorder_destroy"); 638 | lib.bindSymbol(cast(void**)&sfSoundBufferRecorder_start,"sfSoundBufferRecorder_start"); 639 | lib.bindSymbol(cast(void**)&sfSoundBufferRecorder_stop,"sfSoundBufferRecorder_stop"); 640 | lib.bindSymbol(cast(void**)&sfSoundBufferRecorder_getSampleRate,"sfSoundBufferRecorder_getSampleRate"); 641 | lib.bindSymbol(cast(void**)&sfSoundBufferRecorder_getBuffer,"sfSoundBufferRecorder_getBuffer"); 642 | lib.bindSymbol(cast(void**)&sfSoundRecorder_create,"sfSoundRecorder_create"); 643 | lib.bindSymbol(cast(void**)&sfSoundRecorder_destroy,"sfSoundRecorder_destroy"); 644 | lib.bindSymbol(cast(void**)&sfSoundRecorder_start,"sfSoundRecorder_start"); 645 | lib.bindSymbol(cast(void**)&sfSoundRecorder_stop,"sfSoundRecorder_stop"); 646 | lib.bindSymbol(cast(void**)&sfSoundRecorder_getSampleRate,"sfSoundRecorder_getSampleRate"); 647 | lib.bindSymbol(cast(void**)&sfSoundRecorder_isAvailable,"sfSoundRecorder_isAvailable"); 648 | lib.bindSymbol(cast(void**)&sfSoundStream_create,"sfSoundStream_create"); 649 | lib.bindSymbol(cast(void**)&sfSoundStream_destroy,"sfSoundStream_destroy"); 650 | lib.bindSymbol(cast(void**)&sfSoundStream_play,"sfSoundStream_play"); 651 | lib.bindSymbol(cast(void**)&sfSoundStream_pause,"sfSoundStream_pause"); 652 | lib.bindSymbol(cast(void**)&sfSoundStream_stop,"sfSoundStream_stop"); 653 | lib.bindSymbol(cast(void**)&sfSoundStream_getStatus,"sfSoundStream_getStatus"); 654 | lib.bindSymbol(cast(void**)&sfSoundStream_getChannelCount,"sfSoundStream_getChannelCount"); 655 | lib.bindSymbol(cast(void**)&sfSoundStream_getSampleRate,"sfSoundStream_getSampleRate"); 656 | lib.bindSymbol(cast(void**)&sfSoundStream_setPitch,"sfSoundStream_setPitch"); 657 | lib.bindSymbol(cast(void**)&sfSoundStream_setVolume,"sfSoundStream_setVolume"); 658 | lib.bindSymbol(cast(void**)&sfSoundStream_setPosition,"sfSoundStream_setPosition"); 659 | lib.bindSymbol(cast(void**)&sfSoundStream_setRelativeToListener,"sfSoundStream_setRelativeToListener"); 660 | lib.bindSymbol(cast(void**)&sfSoundStream_setMinDistance,"sfSoundStream_setMinDistance"); 661 | lib.bindSymbol(cast(void**)&sfSoundStream_setAttenuation,"sfSoundStream_setAttenuation"); 662 | lib.bindSymbol(cast(void**)&sfSoundStream_setPlayingOffset,"sfSoundStream_setPlayingOffset"); 663 | lib.bindSymbol(cast(void**)&sfSoundStream_setLoop,"sfSoundStream_setLoop"); 664 | lib.bindSymbol(cast(void**)&sfSoundStream_getPitch,"sfSoundStream_getPitch"); 665 | lib.bindSymbol(cast(void**)&sfSoundStream_getVolume,"sfSoundStream_getVolume"); 666 | lib.bindSymbol(cast(void**)&sfSoundStream_getPosition,"sfSoundStream_getPosition"); 667 | lib.bindSymbol(cast(void**)&sfSoundStream_isRelativeToListener,"sfSoundStream_isRelativeToListener"); 668 | lib.bindSymbol(cast(void**)&sfSoundStream_getMinDistance,"sfSoundStream_getMinDistance"); 669 | lib.bindSymbol(cast(void**)&sfSoundStream_getAttenuation,"sfSoundStream_getAttenuation"); 670 | lib.bindSymbol(cast(void**)&sfSoundStream_getLoop,"sfSoundStream_getLoop"); 671 | lib.bindSymbol(cast(void**)&sfSoundStream_getPlayingOffset,"sfSoundStream_getPlayingOffset"); 672 | 673 | if(errorCount() != errCount) return SFMLSupport.badLibrary; 674 | else loadedVersion = sfmlSupport.sfml200; 675 | 676 | static if(sfmlSupport >= SFMLSupport.sfml220){ 677 | lib.bindSymbol(cast(void**)&sfListener_setUpVector,"sfListener_setUpVector"); 678 | lib.bindSymbol(cast(void**)&sfListener_getUpVector,"sfListener_getUpVector"); 679 | lib.bindSymbol(cast(void**)&sfSoundRecorder_setProcessingInterval,"sfSoundRecorder_setProcessingInterval"); 680 | lib.bindSymbol(cast(void**)&sfSoundRecorder_getAvailableDevices,"sfSoundRecorder_getAvailableDevices"); 681 | lib.bindSymbol(cast(void**)&sfSoundRecorder_getDefaultDevice,"sfSoundRecorder_getDefaultDevice"); 682 | lib.bindSymbol(cast(void**)&sfSoundRecorder_setDevice,"sfSoundRecorder_setDevice"); 683 | lib.bindSymbol(cast(void**)&sfSoundRecorder_getDevice,"sfSoundRecorder_getDevice"); 684 | 685 | if(errorCount() != errCount) return SFMLSupport.badLibrary; 686 | else{ 687 | static if(sfmlSupport >= SFMLSupport.sfml230){ 688 | loadedVersion = SFMLSupport.sfml230; 689 | }else{ 690 | loadedVersion = SFMLSupport.sfml220; 691 | } 692 | } 693 | } 694 | static if(sfmlSupport >= SFMLSupport.sfml240){ 695 | lib.bindSymbol(cast(void**)&sfSoundBufferRecorder_setDevice,"sfSoundBufferRecorder_setDevice"); 696 | lib.bindSymbol(cast(void**)&sfSoundBufferRecorder_getDevice,"sfSoundBufferRecorder_getDevice"); 697 | lib.bindSymbol(cast(void**)&sfSoundRecorder_setChannelCount,"sfSoundRecorder_setChannelCount"); 698 | lib.bindSymbol(cast(void**)&sfSoundRecorder_getChannelCount,"sfSoundRecorder_getChannelCount"); 699 | 700 | if(errorCount() != errCount) return SFMLSupport.badLibrary; 701 | else loadedVersion = SFMLSupport.sfml240; 702 | } 703 | static if(sfmlSupport >= SFMLSupport.sfml250){ 704 | lib.bindSymbol(cast(void**)&sfMusic_getLoopPoints,"sfMusic_getLoopPoints"); 705 | lib.bindSymbol(cast(void**)&sfMusic_setLoopPoints,"sfMusic_setLoopPoints"); 706 | 707 | if(errorCount() != errCount) return SFMLSupport.badLibrary; 708 | else loadedVersion = SFMLSupport.sfml250; 709 | } 710 | 711 | return loadedVersion; 712 | } 713 | } 714 | -------------------------------------------------------------------------------- /source/bindbc/sfml/network.d: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2020 - 2021 Michael D. Parker 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | module bindbc.sfml.network; 8 | 9 | import bindbc.sfml.config; 10 | static if(bindSFMLNetwork): 11 | 12 | import core.stdc.stddef : wchar_t; 13 | import bindbc.sfml.system; 14 | 15 | //Network/Types.h 16 | struct sfFtpDirectoryResponse; 17 | struct sfFtpListingResponse; 18 | struct sfFtpResponse; 19 | struct sfFtp; 20 | struct sfHttpRequest; 21 | struct sfHttpResponse; 22 | struct sfHttp; 23 | struct sfPacket; 24 | struct sfSocketSelector; 25 | struct sfTcpListener; 26 | struct sfTcpSocket; 27 | struct sfUdpSocket; 28 | 29 | //Network/Ftp.h 30 | enum sfFtpTransferMode{ 31 | sfFtpBinary, 32 | sfFtpAscii, 33 | sfFtpEbcdic, 34 | } 35 | mixin(expandEnum!sfFtpTransferMode); 36 | 37 | enum sfFtpStatus{ 38 | sfFtpRestartMarkerReply = 110, 39 | sfFtpServiceReadySoon = 120, 40 | sfFtpDataConnectionAlreadyOpened = 125, 41 | sfFtpOpeningDataConnection = 150, 42 | sfFtpOk = 200, 43 | sfFtpPointlessCommand = 202, 44 | sfFtpSystemStatus = 211, 45 | sfFtpDirectoryStatus = 212, 46 | sfFtpFileStatus = 213, 47 | sfFtpHelpMessage = 214, 48 | sfFtpSystemType = 215, 49 | sfFtpServiceReady = 220, 50 | sfFtpClosingConnection = 221, 51 | sfFtpDataConnectionOpened = 225, 52 | sfFtpClosingDataConnection = 226, 53 | sfFtpEnteringPassiveMode = 227, 54 | sfFtpLoggedIn = 230, 55 | sfFtpFileActionOk = 250, 56 | sfFtpDirectoryOk = 257, 57 | sfFtpNeedPassword = 331, 58 | sfFtpNeedAccountToLogIn = 332, 59 | sfFtpNeedInformation = 350, 60 | sfFtpServiceUnavailable = 421, 61 | sfFtpDataConnectionUnavailable = 425, 62 | sfFtpTransferAborted = 426, 63 | sfFtpFileActionAborted = 450, 64 | sfFtpLocalError = 451, 65 | sfFtpInsufficientStorageSpace = 452, 66 | sfFtpCommandUnknown = 500, 67 | sfFtpParametersUnknown = 501, 68 | sfFtpCommandNotImplemented = 502, 69 | sfFtpBadCommandSequence = 503, 70 | sfFtpParameterNotImplemented = 504, 71 | sfFtpNotLoggedIn = 530, 72 | sfFtpNeedAccountToStore = 532, 73 | sfFtpFileUnavailable = 550, 74 | sfFtpPageTypeUnknown = 551, 75 | sfFtpNotEnoughMemory = 552, 76 | sfFtpFilenameNotAllowed = 553, 77 | sfFtpInvalidResponse = 1000, 78 | sfFtpConnectionFailed = 1001, 79 | sfFtpConnectionClosed = 1002, 80 | sfFtpInvalidFile = 1003, 81 | } 82 | mixin(expandEnum!sfFtpStatus); 83 | 84 | //Network/Http.h 85 | static if(sfmlSupport >= SFMLSupport.sfml200){ 86 | enum sfHttpMethod{ 87 | sfHttpGet, 88 | sfHttpPost, 89 | sfHttpHead, 90 | sfHttpPut, 91 | sfHttpDelete, 92 | } 93 | }else{ 94 | enum sfHttpMethod{ 95 | sfHttpGet, 96 | sfHttpPost, 97 | sfHttpHead, 98 | } 99 | } 100 | mixin(expandEnum!sfHttpMethod); 101 | 102 | enum sfHttpStatus{ 103 | sfHttpOk = 200, 104 | sfHttpCreated = 201, 105 | sfHttpAccepted = 202, 106 | sfHttpNoContent = 204, 107 | sfHttpResetContent = 205, 108 | sfHttpPartialContent = 206, 109 | sfHttpMultipleChoices = 300, 110 | sfHttpMovedPermanently = 301, 111 | sfHttpMovedTemporarily = 302, 112 | sfHttpNotModified = 303, 113 | sfHttpBadRequest = 400, 114 | sfHttpUnauthorized = 401, 115 | sfHttpForbidden = 403, 116 | sfHttpNotFound = 404, 117 | sfHttpRangeNotSatisfiable = 407, 118 | sfHttpInternalServerError = 500, 119 | sfHttpNotImplemented = 501, 120 | sfHttpBadGateway = 502, 121 | sfHttpServiceNotAvailable = 503, 122 | sfHttpGatewayTimeout = 504, 123 | sfHttpVersionNotSupported = 505, 124 | sfHttpInvalidResponse = 1000, 125 | sfHttpConnectionFailed = 1001, 126 | } 127 | mixin(expandEnum!sfHttpStatus); 128 | 129 | // Netork/IpAddress.h 130 | struct sfIpAddress{ 131 | char[16] address; 132 | } 133 | 134 | // Helper functions to replace the C constants 135 | const(sfIpAddress) sfIpAddress_Any(){ 136 | return sfIpAddress_fromBytes(0, 0, 0, 0); 137 | } 138 | 139 | const(sfIpAddress) sfIpAddress_LocalHost(){ 140 | return sfIpAddress_fromBytes(127, 0, 0, 1); 141 | } 142 | 143 | const(sfIpAddress) sfIpAddress_Broadcast(){ 144 | return sfIpAddress_fromBytes(255, 255, 255, 255); 145 | } 146 | 147 | //Network/SocketStatus.h 148 | static if(sfmlSupport >= SFMLSupport.sfml230){ 149 | enum sfSocketStatus{ 150 | sfSocketDone, 151 | sfSocketNotReady, 152 | sfSocketPartial, 153 | sfSocketDisconnected, 154 | sfSocketError, 155 | } 156 | }else{ 157 | enum sfSocketStatus{ 158 | sfSocketDone, 159 | sfSocketNotReady, 160 | sfSocketDisconnected, 161 | sfSocketError, 162 | } 163 | } 164 | mixin(expandEnum!sfSocketStatus); 165 | 166 | static if(staticSFML){ 167 | extern(C) @nogc nothrow{ 168 | //Network/Ftp.h 169 | void sfFtpListingResponse_destroy(sfFtpListingResponse* ftpListingResponse); 170 | sfBool sfFtpListingResponse_isOk(const(sfFtpListingResponse)* ftpListingResponse); 171 | sfFtpStatus sfFtpListingResponse_getStatus(const(sfFtpListingResponse)* ftpListingResponse); 172 | const(char)* sfFtpListingResponse_getMessage(const(sfFtpListingResponse)* ftpListingResponse); 173 | size_t sfFtpListingResponse_getCount(const(sfFtpListingResponse)* ftpListingResponse); 174 | const(char)* sfFtpListingResponse_getName(const(sfFtpListingResponse)* ftpListingResponse, size_t index); 175 | void sfFtpDirectoryResponse_destroy(sfFtpDirectoryResponse* ftpDirectoryResponse); 176 | sfBool sfFtpDirectoryResponse_isOk(const(sfFtpDirectoryResponse)* ftpDirectoryResponse); 177 | sfFtpStatus sfFtpDirectoryResponse_getStatus(const(sfFtpDirectoryResponse)* ftpDirectoryResponse); 178 | const(char)* sfFtpDirectoryResponse_getMessage(const(sfFtpDirectoryResponse)* ftpDirectoryResponse); 179 | const(char)* sfFtpDirectoryResponse_getDirectory(const(sfFtpDirectoryResponse)* ftpDirectoryResponse); 180 | void sfFtpResponse_destroy(sfFtpResponse* ftpResponse); 181 | sfBool sfFtpResponse_isOk(const(sfFtpResponse)* ftpResponse); 182 | sfFtpStatus sfFtpResponse_getStatus(const(sfFtpResponse)* ftpResponse); 183 | const(char)* sfFtpResponse_getMessage(const(sfFtpResponse)* ftpResponse); 184 | sfFtp* sfFtp_create(); 185 | void sfFtp_destroy(sfFtp* ftp); 186 | sfFtpResponse* sfFtp_connect(sfFtp* ftp, sfIpAddress server, ushort port, sfTime timeout); 187 | sfFtpResponse* sfFtp_loginAnonymous(sfFtp* ftp); 188 | sfFtpResponse* sfFtp_login(sfFtp* ftp, const(char)* name, const(char)* password); 189 | sfFtpResponse* sfFtp_disconnect(sfFtp* ftp); 190 | sfFtpResponse* sfFtp_keepAlive(sfFtp* ftp); 191 | sfFtpDirectoryResponse* sfFtp_getWorkingDirectory(sfFtp* ftp); 192 | sfFtpListingResponse* sfFtp_getDirectoryListing(sfFtp* ftp, const(char)* directory); 193 | sfFtpResponse* sfFtp_changeDirectory(sfFtp* ftp, const(char)* directory); 194 | sfFtpResponse* sfFtp_parentDirectory(sfFtp* ftp); 195 | sfFtpResponse* sfFtp_createDirectory(sfFtp* ftp, const(char)* name); 196 | sfFtpResponse* sfFtp_deleteDirectory(sfFtp* ftp, const(char)* name); 197 | sfFtpResponse* sfFtp_renameFile(sfFtp* ftp, const(char)* file, const(char)* newName); 198 | sfFtpResponse* sfFtp_deleteFile(sfFtp* ftp, const(char)* name); 199 | sfFtpResponse* sfFtp_download(sfFtp* ftp, const(char)* remoteFile, const(char)* destPath, sfFtpTransferMode mode); 200 | 201 | static if(sfmlSupport >= SFMLSupport.sfml250){ 202 | sfFtpResponse* sfFtp_upload(sfFtp* ftp, const(char)* localFile, const(char)* destPath, sfFtpTransferMode mode, sfBool append); 203 | }else{ 204 | sfFtpResponse* sfFtp_upload(sfFtp* ftp, const(char)* localFile, const(char)* destPath, sfFtpTransferMode mode); 205 | } 206 | 207 | //Network/Http.h 208 | sfHttpRequest* sfHttpRequest_create(); 209 | void sfHttpRequest_destroy(sfHttpRequest* httpRequest); 210 | void sfHttpRequest_setField(sfHttpRequest* httpRequest, const(char)* field, const(char)* value); 211 | void sfHttpRequest_setMethod(sfHttpRequest* httpRequest, sfHttpMethod method); 212 | void sfHttpRequest_setUri(sfHttpRequest* httpRequest, const(char)* uri); 213 | void sfHttpRequest_setHttpVersion(sfHttpRequest* httpRequest, uint major, uint minor); 214 | void sfHttpRequest_setBody(sfHttpRequest* httpRequest, const(char)* body); 215 | void sfHttpResponse_destroy(sfHttpResponse* httpResponse); 216 | const(char)* sfHttpResponse_getField(const(sfHttpResponse)* httpResponse, const(char)* field); 217 | sfHttpStatus sfHttpResponse_getStatus(const(sfHttpResponse)* httpResponse); 218 | uint sfHttpResponse_getMajorVersion(const(sfHttpResponse)* httpResponse); 219 | uint sfHttpResponse_getMinorVersion(const(sfHttpResponse)* httpResponse); 220 | const(char)* sfHttpResponse_getBody(const(sfHttpResponse)* httpResponse); 221 | sfHttp* sfHttp_create(); 222 | void sfHttp_destroy(sfHttp* http); 223 | void sfHttp_setHost(sfHttp* http, const(char)* host, ushort port); 224 | sfHttpResponse* sfHttp_sendRequest(sfHttp* http, const(sfHttpRequest)* request, sfTime timeout); 225 | 226 | //Network/IpAddress.h 227 | sfIpAddress sfIpAddress_fromString(const(char)* address); 228 | sfIpAddress sfIpAddress_fromBytes(sfUint8 byte0, sfUint8 byte1, sfUint8 byte2, sfUint8 byte3); 229 | sfIpAddress sfIpAddress_fromInteger(sfUint32 address); 230 | void sfIpAddress_toString(sfIpAddress address, char* string); 231 | sfUint32 sfIpAddress_toInteger(sfIpAddress address); 232 | sfIpAddress sfIpAddress_getLocalAddress(); 233 | sfIpAddress sfIpAddress_getPublicAddress(sfTime timeout); 234 | 235 | //Network/Packet.h 236 | sfPacket* sfPacket_create(); 237 | sfPacket* sfPacket_copy(const(sfPacket)* packet); 238 | void sfPacket_destroy(sfPacket* packet); 239 | void sfPacket_append(sfPacket* packet, const(void)* data, size_t sizeInBytes); 240 | void sfPacket_clear(sfPacket* packet); 241 | const(void)* sfPacket_getData(const(sfPacket)* packet); 242 | size_t sfPacket_getDataSize(const(sfPacket)* packet); 243 | sfBool sfPacket_endOfPacket(const(sfPacket)* packet); 244 | sfBool sfPacket_canRead(const(sfPacket)* packet); 245 | sfBool sfPacket_readBool(sfPacket* packet); 246 | sfInt8 sfPacket_readInt8(sfPacket* packet); 247 | sfUint8 sfPacket_readUint8(sfPacket* packet); 248 | sfInt16 sfPacket_readInt16(sfPacket* packet); 249 | sfUint16 sfPacket_readUint16(sfPacket* packet); 250 | sfInt32 sfPacket_readInt32(sfPacket* packet); 251 | sfUint32 sfPacket_readUint32(sfPacket* packet); 252 | float sfPacket_readFloat(sfPacket* packet); 253 | double sfPacket_readDouble(sfPacket* packet); 254 | void sfPacket_readString(sfPacket* packet, char* string_); 255 | void sfPacket_readWideString(sfPacket* packet, wchar_t* string_); 256 | void sfPacket_writeBool(sfPacket* packet, sfBool); 257 | void sfPacket_writeInt8(sfPacket* packet, sfInt8); 258 | void sfPacket_writeUint8(sfPacket* packet, sfUint8); 259 | void sfPacket_writeInt16(sfPacket* packet, sfInt16); 260 | void sfPacket_writeUint16(sfPacket* packet, sfUint16); 261 | void sfPacket_writeInt32(sfPacket* packet, sfInt32); 262 | void sfPacket_writeUint32(sfPacket* packet, sfUint32); 263 | void sfPacket_writeFloat(sfPacket* packet, float); 264 | void sfPacket_writeDouble(sfPacket* packet, double); 265 | void sfPacket_writeString(sfPacket* packet, const(char)* string_); 266 | void sfPacket_writeWideString(sfPacket* packet, const(wchar_t)* string_); 267 | 268 | //Network/SocketSelector.h 269 | sfSocketSelector* sfSocketSelector_create(); 270 | sfSocketSelector* sfSocketSelector_copy(const(sfSocketSelector)* selector); 271 | void sfSocketSelector_destroy(sfSocketSelector* selector); 272 | void sfSocketSelector_addTcpListener(sfSocketSelector* selector, sfTcpListener* socket); 273 | void sfSocketSelector_addTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket); 274 | void sfSocketSelector_addUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket); 275 | void sfSocketSelector_removeTcpListener(sfSocketSelector* selector, sfTcpListener* socket); 276 | void sfSocketSelector_removeTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket); 277 | void sfSocketSelector_removeUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket); 278 | void sfSocketSelector_clear(sfSocketSelector* selector); 279 | sfBool sfSocketSelector_wait(sfSocketSelector* selector, sfTime timeout); 280 | sfBool sfSocketSelector_isTcpListenerReady(const(sfSocketSelector)* selector, sfTcpListener* socket); 281 | sfBool sfSocketSelector_isTcpSocketReady(const(sfSocketSelector)* selector, sfTcpSocket* socket); 282 | sfBool sfSocketSelector_isUdpSocketReady(const(sfSocketSelector)* selector, sfUdpSocket* socket); 283 | 284 | //Network/TcpListener.h 285 | sfTcpListener* sfTcpListener_create(); 286 | void sfTcpListener_destroy(sfTcpListener* listener); 287 | void sfTcpListener_setBlocking(sfTcpListener* listener, sfBool blocking); 288 | sfBool sfTcpListener_isBlocking(const(sfTcpListener)* listener); 289 | ushort sfTcpListener_getLocalPort(const(sfTcpListener)* listener); 290 | sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** connected); 291 | 292 | static if(sfmlSupport >= SFMLSupport.sfml240){ 293 | sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, ushort port, sfIpAddress address); 294 | }else{ 295 | sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, ushort port); 296 | } 297 | 298 | //Network/TcpSocket.h 299 | sfTcpSocket* sfTcpSocket_create(); 300 | void sfTcpSocket_destroy(sfTcpSocket* socket); 301 | void sfTcpSocket_setBlocking(sfTcpSocket* socket, sfBool blocking); 302 | sfBool sfTcpSocket_isBlocking(const(sfTcpSocket)* socket); 303 | ushort sfTcpSocket_getLocalPort(const(sfTcpSocket)* socket); 304 | sfIpAddress sfTcpSocket_getRemoteAddress(const(sfTcpSocket)* socket); 305 | ushort sfTcpSocket_getRemotePort(const(sfTcpSocket)* socket); 306 | sfSocketStatus sfTcpSocket_connect(sfTcpSocket* socket, sfIpAddress remoteAddress, ushort remotePort, sfTime timeout); 307 | void sfTcpSocket_disconnect(sfTcpSocket* socket); 308 | sfSocketStatus sfTcpSocket_send(sfTcpSocket* socket, const(void)* data, size_t size); 309 | sfSocketStatus sfTcpSocket_receive(sfTcpSocket* socket, void* data, size_t size, size_t* received); 310 | sfSocketStatus sfTcpSocket_sendPacket(sfTcpSocket* socket, sfPacket* packet); 311 | sfSocketStatus sfTcpSocket_receivePacket(sfTcpSocket* socket, sfPacket* packet); 312 | 313 | //Network/UdpSocket.h 314 | sfUdpSocket* sfUdpSocket_create(); 315 | void sfUdpSocket_destroy(sfUdpSocket* socket); 316 | void sfUdpSocket_setBlocking(sfUdpSocket* socket, sfBool blocking); 317 | sfBool sfUdpSocket_isBlocking(const(sfUdpSocket)* socket); 318 | ushort sfUdpSocket_getLocalPort(const(sfUdpSocket)* socket); 319 | void sfUdpSocket_unbind(sfUdpSocket* socket); 320 | sfSocketStatus sfUdpSocket_send(sfUdpSocket* socket, const(void)* data, size_t size, sfIpAddress remoteAddress, ushort remotePort); 321 | sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t size, size_t* received, sfIpAddress* remoteAddress, ushort* remotePort); 322 | sfSocketStatus sfUdpSocket_sendPacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress remoteAddress, ushort remotePort); 323 | sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress* remoteAddress, ushort* remotePort); 324 | uint sfUdpSocket_maxDatagramSize(); 325 | 326 | static if(sfmlSupport >= SFMLSupport.sfml240){ 327 | sfSocketStatus sfUdpSocket_bind(sfUdpSocket* socket, ushort port, sfIpAddress address); 328 | }else{ 329 | sfSocketStatus sfUdpSocket_bind(sfUdpSocket* socket, ushort port); 330 | } 331 | 332 | //New functions 333 | static if(sfmlSupport >= SFMLSupport.sfml230){ 334 | //Network/TcpSocket.h 335 | sfSocketStatus sfTcpSocket_sendPartial(sfTcpSocket* socket, const(void)* data, size_t size, size_t* sent); 336 | } 337 | static if(sfmlSupport >= SFMLSupport.sfml240){ 338 | //Network/Ftp.h 339 | sfFtpResponse* sfFtp_sendCommand(sfFtp* ftp, const(char)* command, const(char)* parameter); 340 | } 341 | } 342 | }else{ 343 | import bindbc.loader; 344 | 345 | extern(C) @nogc nothrow{ 346 | //Network/Ftp.h 347 | alias psfFtpListingResponse_destroy = void function(sfFtpListingResponse* ftpListingResponse); 348 | alias psfFtpListingResponse_isOk = sfBool function(const(sfFtpListingResponse)* ftpListingResponse); 349 | alias psfFtpListingResponse_getStatus = sfFtpStatus function(const(sfFtpListingResponse)* ftpListingResponse); 350 | alias psfFtpListingResponse_getMessage = const(char)* function(const(sfFtpListingResponse)* ftpListingResponse); 351 | alias psfFtpListingResponse_getCount = size_t function(const(sfFtpListingResponse)* ftpListingResponse); 352 | alias psfFtpListingResponse_getName = const(char)* function(const(sfFtpListingResponse)* ftpListingResponse, size_t index); 353 | alias psfFtpDirectoryResponse_destroy = void function(sfFtpDirectoryResponse* ftpDirectoryResponse); 354 | alias psfFtpDirectoryResponse_isOk = sfBool function(const(sfFtpDirectoryResponse)* ftpDirectoryResponse); 355 | alias psfFtpDirectoryResponse_getStatus = sfFtpStatus function(const(sfFtpDirectoryResponse)* ftpDirectoryResponse); 356 | alias psfFtpDirectoryResponse_getMessage = const(char)* function(const(sfFtpDirectoryResponse)* ftpDirectoryResponse); 357 | alias psfFtpDirectoryResponse_getDirectory = const(char)* function(const(sfFtpDirectoryResponse)* ftpDirectoryResponse); 358 | alias psfFtpResponse_destroy = void function(sfFtpResponse* ftpResponse); 359 | alias psfFtpResponse_isOk = sfBool function(const(sfFtpResponse)* ftpResponse); 360 | alias psfFtpResponse_getStatus = sfFtpStatus function(const(sfFtpResponse)* ftpResponse); 361 | alias psfFtpResponse_getMessage = const(char)* function(const(sfFtpResponse)* ftpResponse); 362 | alias psfFtp_create = sfFtp* function(); 363 | alias psfFtp_destroy = void function(sfFtp* ftp); 364 | alias psfFtp_connect = sfFtpResponse* function(sfFtp* ftp, sfIpAddress server, ushort port, sfTime timeout); 365 | alias psfFtp_loginAnonymous = sfFtpResponse* function(sfFtp* ftp); 366 | alias psfFtp_login = sfFtpResponse* function(sfFtp* ftp, const(char)* name, const(char)* password); 367 | alias psfFtp_disconnect = sfFtpResponse* function(sfFtp* ftp); 368 | alias psfFtp_keepAlive = sfFtpResponse* function(sfFtp* ftp); 369 | alias psfFtp_getWorkingDirectory = sfFtpDirectoryResponse* function(sfFtp* ftp); 370 | alias psfFtp_getDirectoryListing = sfFtpListingResponse* function(sfFtp* ftp, const(char)* directory); 371 | alias psfFtp_changeDirectory = sfFtpResponse* function(sfFtp* ftp, const(char)* directory); 372 | alias psfFtp_parentDirectory = sfFtpResponse* function(sfFtp* ftp); 373 | alias psfFtp_createDirectory = sfFtpResponse* function(sfFtp* ftp, const(char)* name); 374 | alias psfFtp_deleteDirectory = sfFtpResponse* function(sfFtp* ftp, const(char)* name); 375 | alias psfFtp_renameFile = sfFtpResponse* function(sfFtp* ftp, const(char)* file, const(char)* newName); 376 | alias psfFtp_deleteFile = sfFtpResponse* function(sfFtp* ftp, const(char)* name); 377 | alias psfFtp_download = sfFtpResponse* function(sfFtp* ftp, const(char)* remoteFile, const(char)* destPath, sfFtpTransferMode mode); 378 | 379 | static if(sfmlSupport >= SFMLSupport.sfml250){ 380 | alias psfFtp_upload = sfFtpResponse* function(sfFtp* ftp, const(char)* localFile, const(char)* destPath, sfFtpTransferMode mode, sfBool append); 381 | }else{ 382 | alias psfFtp_upload = sfFtpResponse* function(sfFtp* ftp, const(char)* localFile, const(char)* destPath, sfFtpTransferMode mode); 383 | } 384 | 385 | //Network/Http.h 386 | alias psfHttpRequest_create = sfHttpRequest* function(); 387 | alias psfHttpRequest_destroy = void function(sfHttpRequest* httpRequest); 388 | alias psfHttpRequest_setField = void function(sfHttpRequest* httpRequest, const(char)* field, const(char)* value); 389 | alias psfHttpRequest_setMethod = void function(sfHttpRequest* httpRequest, sfHttpMethod method); 390 | alias psfHttpRequest_setUri = void function(sfHttpRequest* httpRequest, const(char)* uri); 391 | alias psfHttpRequest_setHttpVersion = void function(sfHttpRequest* httpRequest, uint major, uint minor); 392 | alias psfHttpRequest_setBody = void function(sfHttpRequest* httpRequest, const(char)* body); 393 | alias psfHttpResponse_destroy = void function(sfHttpResponse* httpResponse); 394 | alias psfHttpResponse_getField = const(char)* function(const(sfHttpResponse)* httpResponse, const(char)* field); 395 | alias psfHttpResponse_getStatus = sfHttpStatus function(const(sfHttpResponse)* httpResponse); 396 | alias psfHttpResponse_getMajorVersion = uint function(const(sfHttpResponse)* httpResponse); 397 | alias psfHttpResponse_getMinorVersion = uint function(const(sfHttpResponse)* httpResponse); 398 | alias psfHttpResponse_getBody = const(char)* function(const(sfHttpResponse)* httpResponse); 399 | alias psfHttp_create = sfHttp* function(); 400 | alias psfHttp_destroy = void function(sfHttp* http); 401 | alias psfHttp_setHost = void function(sfHttp* http, const(char)* host, ushort port); 402 | alias psfHttp_sendRequest = sfHttpResponse* function(sfHttp* http, const(sfHttpRequest)* request, sfTime timeout); 403 | 404 | //Network/IpAddress.h 405 | alias psfIpAddress_fromString = sfIpAddress function(const(char)* address); 406 | alias psfIpAddress_fromBytes = sfIpAddress function(sfUint8 byte0, sfUint8 byte1, sfUint8 byte2, sfUint8 byte3); 407 | alias psfIpAddress_fromInteger = sfIpAddress function(sfUint32 address); 408 | alias psfIpAddress_toString = void function(sfIpAddress address, char* string); 409 | alias psfIpAddress_toInteger = sfUint32 function(sfIpAddress address); 410 | alias psfIpAddress_getLocalAddress = sfIpAddress function(); 411 | alias psfIpAddress_getPublicAddress = sfIpAddress function(sfTime timeout); 412 | 413 | //Network/Packet.h 414 | alias psfPacket_create = sfPacket* function(); 415 | alias psfPacket_copy = sfPacket* function(const(sfPacket)* packet); 416 | alias psfPacket_destroy = void function(sfPacket* packet); 417 | alias psfPacket_append = void function(sfPacket* packet, const(void)* data, size_t sizeInBytes); 418 | alias psfPacket_clear = void function(sfPacket* packet); 419 | alias psfPacket_getData = const(void)* function(const(sfPacket)* packet); 420 | alias psfPacket_getDataSize = size_t function(const(sfPacket)* packet); 421 | alias psfPacket_endOfPacket = sfBool function(const(sfPacket)* packet); 422 | alias psfPacket_canRead = sfBool function(const(sfPacket)* packet); 423 | alias psfPacket_readBool = sfBool function(sfPacket* packet); 424 | alias psfPacket_readInt8 = sfInt8 function(sfPacket* packet); 425 | alias psfPacket_readUint8 = sfUint8 function(sfPacket* packet); 426 | alias psfPacket_readInt16 = sfInt16 function(sfPacket* packet); 427 | alias psfPacket_readUint16 = sfUint16 function(sfPacket* packet); 428 | alias psfPacket_readInt32 = sfInt32 function(sfPacket* packet); 429 | alias psfPacket_readUint32 = sfUint32 function(sfPacket* packet); 430 | alias psfPacket_readFloat = float function(sfPacket* packet); 431 | alias psfPacket_readDouble = double function(sfPacket* packet); 432 | alias psfPacket_readString = void function(sfPacket* packet, char* string_); 433 | alias psfPacket_readWideString = void function(sfPacket* packet, wchar_t* string_); 434 | alias psfPacket_writeBool = void function(sfPacket* packet, sfBool); 435 | alias psfPacket_writeInt8 = void function(sfPacket* packet, sfInt8); 436 | alias psfPacket_writeUint8 = void function(sfPacket* packet, sfUint8); 437 | alias psfPacket_writeInt16 = void function(sfPacket* packet, sfInt16); 438 | alias psfPacket_writeUint16 = void function(sfPacket* packet, sfUint16); 439 | alias psfPacket_writeInt32 = void function(sfPacket* packet, sfInt32); 440 | alias psfPacket_writeUint32 = void function(sfPacket* packet, sfUint32); 441 | alias psfPacket_writeFloat = void function(sfPacket* packet, float); 442 | alias psfPacket_writeDouble = void function(sfPacket* packet, double); 443 | alias psfPacket_writeString = void function(sfPacket* packet, const(char)* string_); 444 | alias psfPacket_writeWideString = void function(sfPacket* packet, const(wchar_t)* string_); 445 | 446 | //Network/SocketSelector.h 447 | alias psfSocketSelector_create = sfSocketSelector* function(); 448 | alias psfSocketSelector_copy = sfSocketSelector* function(const(sfSocketSelector)* selector); 449 | alias psfSocketSelector_destroy = void function(sfSocketSelector* selector); 450 | alias psfSocketSelector_addTcpListener = void function(sfSocketSelector* selector, sfTcpListener* socket); 451 | alias psfSocketSelector_addTcpSocket = void function(sfSocketSelector* selector, sfTcpSocket* socket); 452 | alias psfSocketSelector_addUdpSocket = void function(sfSocketSelector* selector, sfUdpSocket* socket); 453 | alias psfSocketSelector_removeTcpListener = void function(sfSocketSelector* selector, sfTcpListener* socket); 454 | alias psfSocketSelector_removeTcpSocket = void function(sfSocketSelector* selector, sfTcpSocket* socket); 455 | alias psfSocketSelector_removeUdpSocket = void function(sfSocketSelector* selector, sfUdpSocket* socket); 456 | alias psfSocketSelector_clear = void function(sfSocketSelector* selector); 457 | alias psfSocketSelector_wait = sfBool function(sfSocketSelector* selector, sfTime timeout); 458 | alias psfSocketSelector_isTcpListenerReady = sfBool function(const(sfSocketSelector)* selector, sfTcpListener* socket); 459 | alias psfSocketSelector_isTcpSocketReady = sfBool function(const(sfSocketSelector)* selector, sfTcpSocket* socket); 460 | alias psfSocketSelector_isUdpSocketReady = sfBool function(const(sfSocketSelector)* selector, sfUdpSocket* socket); 461 | 462 | //Network/TcpListener.h 463 | alias psfTcpListener_create = sfTcpListener* function(); 464 | alias psfTcpListener_destroy = void function(sfTcpListener* listener); 465 | alias psfTcpListener_setBlocking = void function(sfTcpListener* listener, sfBool blocking); 466 | alias psfTcpListener_isBlocking = sfBool function(const(sfTcpListener)* listener); 467 | alias psfTcpListener_getLocalPort = ushort function(const(sfTcpListener)* listener); 468 | alias psfTcpListener_accept = sfSocketStatus function(sfTcpListener* listener, sfTcpSocket** connected); 469 | 470 | static if(sfmlSupport >= SFMLSupport.sfml240){ 471 | alias psfTcpListener_listen = sfSocketStatus function(sfTcpListener* listener, ushort port, sfIpAddress address); 472 | }else{ 473 | alias psfTcpListener_listen = sfSocketStatus function(sfTcpListener* listener, ushort port); 474 | } 475 | 476 | //Network/TcpSocket.h 477 | alias psfTcpSocket_create = sfTcpSocket* function(); 478 | alias psfTcpSocket_destroy = void function(sfTcpSocket* socket); 479 | alias psfTcpSocket_setBlocking = void function(sfTcpSocket* socket, sfBool blocking); 480 | alias psfTcpSocket_isBlocking = sfBool function(const(sfTcpSocket)* socket); 481 | alias psfTcpSocket_getLocalPort = ushort function(const(sfTcpSocket)* socket); 482 | alias psfTcpSocket_getRemoteAddress = sfIpAddress function(const(sfTcpSocket)* socket); 483 | alias psfTcpSocket_getRemotePort = ushort function(const(sfTcpSocket)* socket); 484 | alias psfTcpSocket_connect = sfSocketStatus function(sfTcpSocket* socket, sfIpAddress remoteAddress, ushort remotePort, sfTime timeout); 485 | alias psfTcpSocket_disconnect = void function(sfTcpSocket* socket); 486 | alias psfTcpSocket_send = sfSocketStatus function(sfTcpSocket* socket, const(void)* data, size_t size); 487 | alias psfTcpSocket_receive = sfSocketStatus function(sfTcpSocket* socket, void* data, size_t maxSize, size_t* sizeReceived); 488 | alias psfTcpSocket_sendPacket = sfSocketStatus function(sfTcpSocket* socket, sfPacket* packet); 489 | alias psfTcpSocket_receivePacket = sfSocketStatus function(sfTcpSocket* socket, sfPacket* packet); 490 | 491 | //Network/UdpSocket.h 492 | alias psfUdpSocket_create = sfUdpSocket* function(); 493 | alias psfUdpSocket_destroy = void function(sfUdpSocket* socket); 494 | alias psfUdpSocket_setBlocking = void function(sfUdpSocket* socket, sfBool blocking); 495 | alias psfUdpSocket_isBlocking = sfBool function(const(sfUdpSocket)* socket); 496 | alias psfUdpSocket_getLocalPort = ushort function(const(sfUdpSocket)* socket); 497 | alias psfUdpSocket_unbind = void function(sfUdpSocket* socket); 498 | alias psfUdpSocket_send = sfSocketStatus function(sfUdpSocket* socket, const(void)* data, size_t size, sfIpAddress remoteAddress, ushort remotePort); 499 | alias psfUdpSocket_receive = sfSocketStatus function(sfUdpSocket* socket, void* data, size_t size, size_t* received, sfIpAddress* remoteAddress, ushort* remotePort); 500 | alias psfUdpSocket_sendPacket = sfSocketStatus function(sfUdpSocket* socket, sfPacket* packet, sfIpAddress remoteAddress, ushort remotePort); 501 | alias psfUdpSocket_receivePacket = sfSocketStatus function(sfUdpSocket* socket, sfPacket* packet, sfIpAddress* remoteAddress, ushort* remotePort); 502 | alias psfUdpSocket_maxDatagramSize = uint function(); 503 | 504 | static if(sfmlSupport >= SFMLSupport.sfml240){ 505 | alias psfUdpSocket_bind = sfSocketStatus function(sfUdpSocket* socket, ushort port, sfIpAddress address); 506 | }else{ 507 | alias psfUdpSocket_bind = sfSocketStatus function(sfUdpSocket* socket, ushort port); 508 | } 509 | 510 | //New functions 511 | static if(sfmlSupport >= SFMLSupport.sfml230){ 512 | //Network/TcpSocket.h 513 | alias psfTcpSocket_sendPartial = sfSocketStatus function(sfTcpSocket* socket, const(void)* data, size_t size, size_t* sent); 514 | } 515 | static if(sfmlSupport >= SFMLSupport.sfml240){ 516 | //Network/Ftp.h 517 | alias psfFtp_sendCommand = sfFtpResponse* function(sfFtp* ftp, const(char)* command, const(char)* parameter); 518 | } 519 | } 520 | 521 | __gshared{ 522 | psfFtpListingResponse_destroy sfFtpListingResponse_destroy; 523 | psfFtpListingResponse_isOk sfFtpListingResponse_isOk; 524 | psfFtpListingResponse_getStatus sfFtpListingResponse_getStatus; 525 | psfFtpListingResponse_getMessage sfFtpListingResponse_getMessage; 526 | psfFtpListingResponse_getCount sfFtpListingResponse_getCount; 527 | psfFtpListingResponse_getName sfFtpListingResponse_getName; 528 | psfFtpDirectoryResponse_destroy sfFtpDirectoryResponse_destroy; 529 | psfFtpDirectoryResponse_isOk sfFtpDirectoryResponse_isOk; 530 | psfFtpDirectoryResponse_getStatus sfFtpDirectoryResponse_getStatus; 531 | psfFtpDirectoryResponse_getMessage sfFtpDirectoryResponse_getMessage; 532 | psfFtpDirectoryResponse_getDirectory sfFtpDirectoryResponse_getDirectory; 533 | psfFtpResponse_destroy sfFtpResponse_destroy; 534 | psfFtpResponse_isOk sfFtpResponse_isOk; 535 | psfFtpResponse_getStatus sfFtpResponse_getStatus; 536 | psfFtpResponse_getMessage sfFtpResponse_getMessage; 537 | psfFtp_create sfFtp_create; 538 | psfFtp_destroy sfFtp_destroy; 539 | psfFtp_connect sfFtp_connect; 540 | psfFtp_loginAnonymous sfFtp_loginAnonymous; 541 | psfFtp_login sfFtp_login; 542 | psfFtp_disconnect sfFtp_disconnect; 543 | psfFtp_keepAlive sfFtp_keepAlive; 544 | psfFtp_getWorkingDirectory sfFtp_getWorkingDirectory; 545 | psfFtp_getDirectoryListing sfFtp_getDirectoryListing; 546 | psfFtp_changeDirectory sfFtp_changeDirectory; 547 | psfFtp_parentDirectory sfFtp_parentDirectory; 548 | psfFtp_createDirectory sfFtp_createDirectory; 549 | psfFtp_deleteDirectory sfFtp_deleteDirectory; 550 | psfFtp_renameFile sfFtp_renameFile; 551 | psfFtp_deleteFile sfFtp_deleteFile; 552 | psfFtp_download sfFtp_download; 553 | psfFtp_upload sfFtp_upload; 554 | psfHttpRequest_create sfHttpRequest_create; 555 | psfHttpRequest_destroy sfHttpRequest_destroy; 556 | psfHttpRequest_setField sfHttpRequest_setField; 557 | psfHttpRequest_setMethod sfHttpRequest_setMethod; 558 | psfHttpRequest_setUri sfHttpRequest_setUri; 559 | psfHttpRequest_setHttpVersion sfHttpRequest_setHttpVersion; 560 | psfHttpRequest_setBody sfHttpRequest_setBody; 561 | psfHttpResponse_destroy sfHttpResponse_destroy; 562 | psfHttpResponse_getField sfHttpResponse_getField; 563 | psfHttpResponse_getStatus sfHttpResponse_getStatus; 564 | psfHttpResponse_getMajorVersion sfHttpResponse_getMajorVersion; 565 | psfHttpResponse_getMinorVersion sfHttpResponse_getMinorVersion; 566 | psfHttpResponse_getBody sfHttpResponse_getBody; 567 | psfHttp_create sfHttp_create; 568 | psfHttp_destroy sfHttp_destroy; 569 | psfHttp_setHost sfHttp_setHost; 570 | psfHttp_sendRequest sfHttp_sendRequest; 571 | psfIpAddress_fromString sfIpAddress_fromString; 572 | psfIpAddress_fromBytes sfIpAddress_fromBytes; 573 | psfIpAddress_fromInteger sfIpAddress_fromInteger; 574 | psfIpAddress_toString sfIpAddress_toString; 575 | psfIpAddress_toInteger sfIpAddress_toInteger; 576 | psfIpAddress_getLocalAddress sfIpAddress_getLocalAddress; 577 | psfIpAddress_getPublicAddress sfIpAddress_getPublicAddress; 578 | psfPacket_create sfPacket_create; 579 | psfPacket_copy sfPacket_copy; 580 | psfPacket_destroy sfPacket_destroy; 581 | psfPacket_append sfPacket_append; 582 | psfPacket_clear sfPacket_clear; 583 | psfPacket_getData sfPacket_getData; 584 | psfPacket_getDataSize sfPacket_getDataSize; 585 | psfPacket_endOfPacket sfPacket_endOfPacket; 586 | psfPacket_canRead sfPacket_canRead; 587 | psfPacket_readBool sfPacket_readBool; 588 | psfPacket_readInt8 sfPacket_readInt8; 589 | psfPacket_readUint8 sfPacket_readUint8; 590 | psfPacket_readInt16 sfPacket_readInt16; 591 | psfPacket_readUint16 sfPacket_readUint16; 592 | psfPacket_readInt32 sfPacket_readInt32; 593 | psfPacket_readUint32 sfPacket_readUint32; 594 | psfPacket_readFloat sfPacket_readFloat; 595 | psfPacket_readDouble sfPacket_readDouble; 596 | psfPacket_readString sfPacket_readString; 597 | psfPacket_readWideString sfPacket_readWideString; 598 | psfPacket_writeBool sfPacket_writeBool; 599 | psfPacket_writeInt8 sfPacket_writeInt8; 600 | psfPacket_writeUint8 sfPacket_writeUint8; 601 | psfPacket_writeInt16 sfPacket_writeInt16; 602 | psfPacket_writeUint16 sfPacket_writeUint16; 603 | psfPacket_writeInt32 sfPacket_writeInt32; 604 | psfPacket_writeUint32 sfPacket_writeUint32; 605 | psfPacket_writeFloat sfPacket_writeFloat; 606 | psfPacket_writeDouble sfPacket_writeDouble; 607 | psfPacket_writeString sfPacket_writeString; 608 | psfPacket_writeWideString sfPacket_writeWideString; 609 | psfSocketSelector_create sfSocketSelector_create; 610 | psfSocketSelector_copy sfSocketSelector_copy; 611 | psfSocketSelector_destroy sfSocketSelector_destroy; 612 | psfSocketSelector_addTcpListener sfSocketSelector_addTcpListener; 613 | psfSocketSelector_addTcpSocket sfSocketSelector_addTcpSocket; 614 | psfSocketSelector_addUdpSocket sfSocketSelector_addUdpSocket; 615 | psfSocketSelector_removeTcpListener sfSocketSelector_removeTcpListener; 616 | psfSocketSelector_removeTcpSocket sfSocketSelector_removeTcpSocket; 617 | psfSocketSelector_removeUdpSocket sfSocketSelector_removeUdpSocket; 618 | psfSocketSelector_clear sfSocketSelector_clear; 619 | psfSocketSelector_wait sfSocketSelector_wait; 620 | psfSocketSelector_isTcpListenerReady sfSocketSelector_isTcpListenerReady; 621 | psfSocketSelector_isTcpSocketReady sfSocketSelector_isTcpSocketReady; 622 | psfSocketSelector_isUdpSocketReady sfSocketSelector_isUdpSocketReady; 623 | psfTcpListener_create sfTcpListener_create; 624 | psfTcpListener_destroy sfTcpListener_destroy; 625 | psfTcpListener_setBlocking sfTcpListener_setBlocking; 626 | psfTcpListener_isBlocking sfTcpListener_isBlocking; 627 | psfTcpListener_getLocalPort sfTcpListener_getLocalPort; 628 | psfTcpListener_listen sfTcpListener_listen; 629 | psfTcpListener_accept sfTcpListener_accept; 630 | psfTcpSocket_create sfTcpSocket_create; 631 | psfTcpSocket_destroy sfTcpSocket_destroy; 632 | psfTcpSocket_setBlocking sfTcpSocket_setBlocking; 633 | psfTcpSocket_isBlocking sfTcpSocket_isBlocking; 634 | psfTcpSocket_getLocalPort sfTcpSocket_getLocalPort; 635 | psfTcpSocket_getRemoteAddress sfTcpSocket_getRemoteAddress; 636 | psfTcpSocket_getRemotePort sfTcpSocket_getRemotePort; 637 | psfTcpSocket_connect sfTcpSocket_connect; 638 | psfTcpSocket_disconnect sfTcpSocket_disconnect; 639 | psfTcpSocket_send sfTcpSocket_send; 640 | psfTcpSocket_receive sfTcpSocket_receive; 641 | psfTcpSocket_sendPacket sfTcpSocket_sendPacket; 642 | psfTcpSocket_receivePacket sfTcpSocket_receivePacket; 643 | psfUdpSocket_create sfUdpSocket_create; 644 | psfUdpSocket_destroy sfUdpSocket_destroy; 645 | psfUdpSocket_setBlocking sfUdpSocket_setBlocking; 646 | psfUdpSocket_isBlocking sfUdpSocket_isBlocking; 647 | psfUdpSocket_getLocalPort sfUdpSocket_getLocalPort; 648 | psfUdpSocket_bind sfUdpSocket_bind; 649 | psfUdpSocket_unbind sfUdpSocket_unbind; 650 | psfUdpSocket_send sfUdpSocket_send; 651 | psfUdpSocket_receive sfUdpSocket_receive; 652 | psfUdpSocket_sendPacket sfUdpSocket_sendPacket; 653 | psfUdpSocket_receivePacket sfUdpSocket_receivePacket; 654 | psfUdpSocket_maxDatagramSize sfUdpSocket_maxDatagramSize; 655 | 656 | static if(sfmlSupport >= SFMLSupport.sfml230){ 657 | psfTcpSocket_sendPartial sfTcpSocket_sendPartial; 658 | } 659 | static if(sfmlSupport >= SFMLSupport.sfml240){ 660 | psfFtp_sendCommand sfFtp_sendCommand; 661 | } 662 | } 663 | private{ 664 | SharedLib lib; 665 | SFMLSupport loadedVersion; 666 | } 667 | 668 | @nogc nothrow: 669 | SFMLSupport loadedSFMLNetworkVersion(){ return loadedVersion; } 670 | 671 | bool isSFMLNetworkLoaded(){ 672 | return lib != invalidHandle; 673 | } 674 | 675 | SFMLSupport loadSFMLNetwork(){ 676 | version(Windows){ 677 | const(char)[][3] libNames = [ 678 | "csfml-network.dll", 679 | "csfml-network-2.dll", 680 | "csfml-network-2.0.dll" 681 | ]; 682 | }else version(OSX){ 683 | const(char)[][3] libNames = [ 684 | "libcsfml-network.dylib", 685 | "libcsfml-network.2.dylib", 686 | "libcsfml-network.2.0.dylib" 687 | ]; 688 | }else version(Posix){ 689 | const(char)[][3] libNames = [ 690 | "libcsfml-network.so", 691 | "libcsfml-network.so.2", 692 | "libcsfml-network.so.2.0" 693 | ]; 694 | } 695 | 696 | SFMLSupport ret; 697 | foreach(name; libNames){ 698 | ret = loadSFMLNetwork(name.ptr); 699 | if(ret != SFMLSupport.noLibrary) break; 700 | } 701 | return ret; 702 | } 703 | 704 | SFMLSupport loadSFMLNetwork(const(char)* libName){ 705 | lib = load(libName); 706 | if(lib == invalidHandle){ 707 | return SFMLSupport.noLibrary; 708 | } 709 | 710 | auto errCount = errorCount(); 711 | loadedVersion = SFMLSupport.badLibrary; 712 | 713 | //Now load the functions 714 | lib.bindSymbol(cast(void**)&sfFtpListingResponse_destroy,"sfFtpListingResponse_destroy"); 715 | lib.bindSymbol(cast(void**)&sfFtpListingResponse_isOk,"sfFtpListingResponse_isOk"); 716 | lib.bindSymbol(cast(void**)&sfFtpListingResponse_getStatus,"sfFtpListingResponse_getStatus"); 717 | lib.bindSymbol(cast(void**)&sfFtpListingResponse_getMessage,"sfFtpListingResponse_getMessage"); 718 | lib.bindSymbol(cast(void**)&sfFtpListingResponse_getCount,"sfFtpListingResponse_getCount"); 719 | lib.bindSymbol(cast(void**)&sfFtpListingResponse_getName,"sfFtpListingResponse_getName"); 720 | lib.bindSymbol(cast(void**)&sfFtpDirectoryResponse_destroy,"sfFtpDirectoryResponse_destroy"); 721 | lib.bindSymbol(cast(void**)&sfFtpDirectoryResponse_isOk,"sfFtpDirectoryResponse_isOk"); 722 | lib.bindSymbol(cast(void**)&sfFtpDirectoryResponse_getStatus,"sfFtpDirectoryResponse_getStatus"); 723 | lib.bindSymbol(cast(void**)&sfFtpDirectoryResponse_getMessage,"sfFtpDirectoryResponse_getMessage"); 724 | lib.bindSymbol(cast(void**)&sfFtpDirectoryResponse_getDirectory,"sfFtpDirectoryResponse_getDirectory"); 725 | lib.bindSymbol(cast(void**)&sfFtpResponse_destroy,"sfFtpResponse_destroy"); 726 | lib.bindSymbol(cast(void**)&sfFtpResponse_isOk,"sfFtpResponse_isOk"); 727 | lib.bindSymbol(cast(void**)&sfFtpResponse_getStatus,"sfFtpResponse_getStatus"); 728 | lib.bindSymbol(cast(void**)&sfFtpResponse_getMessage,"sfFtpResponse_getMessage"); 729 | lib.bindSymbol(cast(void**)&sfFtp_create,"sfFtp_create"); 730 | lib.bindSymbol(cast(void**)&sfFtp_destroy,"sfFtp_destroy"); 731 | lib.bindSymbol(cast(void**)&sfFtp_connect,"sfFtp_connect"); 732 | lib.bindSymbol(cast(void**)&sfFtp_loginAnonymous,"sfFtp_loginAnonymous"); 733 | lib.bindSymbol(cast(void**)&sfFtp_login,"sfFtp_login"); 734 | lib.bindSymbol(cast(void**)&sfFtp_disconnect,"sfFtp_disconnect"); 735 | lib.bindSymbol(cast(void**)&sfFtp_keepAlive,"sfFtp_keepAlive"); 736 | lib.bindSymbol(cast(void**)&sfFtp_getWorkingDirectory,"sfFtp_getWorkingDirectory"); 737 | lib.bindSymbol(cast(void**)&sfFtp_getDirectoryListing,"sfFtp_getDirectoryListing"); 738 | lib.bindSymbol(cast(void**)&sfFtp_changeDirectory,"sfFtp_changeDirectory"); 739 | lib.bindSymbol(cast(void**)&sfFtp_parentDirectory,"sfFtp_parentDirectory"); 740 | lib.bindSymbol(cast(void**)&sfFtp_createDirectory,"sfFtp_createDirectory"); 741 | lib.bindSymbol(cast(void**)&sfFtp_deleteDirectory,"sfFtp_deleteDirectory"); 742 | lib.bindSymbol(cast(void**)&sfFtp_renameFile,"sfFtp_renameFile"); 743 | lib.bindSymbol(cast(void**)&sfFtp_deleteFile,"sfFtp_deleteFile"); 744 | lib.bindSymbol(cast(void**)&sfFtp_download,"sfFtp_download"); 745 | lib.bindSymbol(cast(void**)&sfFtp_upload,"sfFtp_upload"); 746 | lib.bindSymbol(cast(void**)&sfHttpRequest_create,"sfHttpRequest_create"); 747 | lib.bindSymbol(cast(void**)&sfHttpRequest_destroy,"sfHttpRequest_destroy"); 748 | lib.bindSymbol(cast(void**)&sfHttpRequest_setField,"sfHttpRequest_setField"); 749 | lib.bindSymbol(cast(void**)&sfHttpRequest_setMethod,"sfHttpRequest_setMethod"); 750 | lib.bindSymbol(cast(void**)&sfHttpRequest_setUri,"sfHttpRequest_setUri"); 751 | lib.bindSymbol(cast(void**)&sfHttpRequest_setHttpVersion,"sfHttpRequest_setHttpVersion"); 752 | lib.bindSymbol(cast(void**)&sfHttpRequest_setBody,"sfHttpRequest_setBody"); 753 | lib.bindSymbol(cast(void**)&sfHttpResponse_destroy,"sfHttpResponse_destroy"); 754 | lib.bindSymbol(cast(void**)&sfHttpResponse_getField,"sfHttpResponse_getField"); 755 | lib.bindSymbol(cast(void**)&sfHttpResponse_getStatus,"sfHttpResponse_getStatus"); 756 | lib.bindSymbol(cast(void**)&sfHttpResponse_getMajorVersion,"sfHttpResponse_getMajorVersion"); 757 | lib.bindSymbol(cast(void**)&sfHttpResponse_getMinorVersion,"sfHttpResponse_getMinorVersion"); 758 | lib.bindSymbol(cast(void**)&sfHttpResponse_getBody,"sfHttpResponse_getBody"); 759 | lib.bindSymbol(cast(void**)&sfHttp_create,"sfHttp_create"); 760 | lib.bindSymbol(cast(void**)&sfHttp_destroy,"sfHttp_destroy"); 761 | lib.bindSymbol(cast(void**)&sfHttp_setHost,"sfHttp_setHost"); 762 | lib.bindSymbol(cast(void**)&sfHttp_sendRequest,"sfHttp_sendRequest"); 763 | lib.bindSymbol(cast(void**)&sfIpAddress_fromString,"sfIpAddress_fromString"); 764 | lib.bindSymbol(cast(void**)&sfIpAddress_fromBytes,"sfIpAddress_fromBytes"); 765 | lib.bindSymbol(cast(void**)&sfIpAddress_fromInteger,"sfIpAddress_fromInteger"); 766 | lib.bindSymbol(cast(void**)&sfIpAddress_toString,"sfIpAddress_toString"); 767 | lib.bindSymbol(cast(void**)&sfIpAddress_toInteger,"sfIpAddress_toInteger"); 768 | lib.bindSymbol(cast(void**)&sfIpAddress_getLocalAddress,"sfIpAddress_getLocalAddress"); 769 | lib.bindSymbol(cast(void**)&sfIpAddress_getPublicAddress,"sfIpAddress_getPublicAddress"); 770 | lib.bindSymbol(cast(void**)&sfPacket_create,"sfPacket_create"); 771 | lib.bindSymbol(cast(void**)&sfPacket_copy,"sfPacket_copy"); 772 | lib.bindSymbol(cast(void**)&sfPacket_destroy,"sfPacket_destroy"); 773 | lib.bindSymbol(cast(void**)&sfPacket_append,"sfPacket_append"); 774 | lib.bindSymbol(cast(void**)&sfPacket_clear,"sfPacket_clear"); 775 | lib.bindSymbol(cast(void**)&sfPacket_getData,"sfPacket_getData"); 776 | lib.bindSymbol(cast(void**)&sfPacket_getDataSize,"sfPacket_getDataSize"); 777 | lib.bindSymbol(cast(void**)&sfPacket_endOfPacket,"sfPacket_endOfPacket"); 778 | lib.bindSymbol(cast(void**)&sfPacket_canRead,"sfPacket_canRead"); 779 | lib.bindSymbol(cast(void**)&sfPacket_readBool,"sfPacket_readBool"); 780 | lib.bindSymbol(cast(void**)&sfPacket_readInt8,"sfPacket_readInt8"); 781 | lib.bindSymbol(cast(void**)&sfPacket_readUint8,"sfPacket_readUint8"); 782 | lib.bindSymbol(cast(void**)&sfPacket_readInt16,"sfPacket_readInt16"); 783 | lib.bindSymbol(cast(void**)&sfPacket_readUint16,"sfPacket_readUint16"); 784 | lib.bindSymbol(cast(void**)&sfPacket_readInt32,"sfPacket_readInt32"); 785 | lib.bindSymbol(cast(void**)&sfPacket_readUint32,"sfPacket_readUint32"); 786 | lib.bindSymbol(cast(void**)&sfPacket_readFloat,"sfPacket_readFloat"); 787 | lib.bindSymbol(cast(void**)&sfPacket_readDouble,"sfPacket_readDouble"); 788 | lib.bindSymbol(cast(void**)&sfPacket_readString,"sfPacket_readString"); 789 | lib.bindSymbol(cast(void**)&sfPacket_readWideString,"sfPacket_readWideString"); 790 | lib.bindSymbol(cast(void**)&sfPacket_writeBool,"sfPacket_writeBool"); 791 | lib.bindSymbol(cast(void**)&sfPacket_writeInt8,"sfPacket_writeInt8"); 792 | lib.bindSymbol(cast(void**)&sfPacket_writeUint8,"sfPacket_writeUint8"); 793 | lib.bindSymbol(cast(void**)&sfPacket_writeInt16,"sfPacket_writeInt16"); 794 | lib.bindSymbol(cast(void**)&sfPacket_writeUint16,"sfPacket_writeUint16"); 795 | lib.bindSymbol(cast(void**)&sfPacket_writeInt32,"sfPacket_writeInt32"); 796 | lib.bindSymbol(cast(void**)&sfPacket_writeUint32,"sfPacket_writeUint32"); 797 | lib.bindSymbol(cast(void**)&sfPacket_writeFloat,"sfPacket_writeFloat"); 798 | lib.bindSymbol(cast(void**)&sfPacket_writeDouble,"sfPacket_writeDouble"); 799 | lib.bindSymbol(cast(void**)&sfPacket_writeString,"sfPacket_writeString"); 800 | lib.bindSymbol(cast(void**)&sfPacket_writeWideString,"sfPacket_writeWideString"); 801 | lib.bindSymbol(cast(void**)&sfSocketSelector_create,"sfSocketSelector_create"); 802 | lib.bindSymbol(cast(void**)&sfSocketSelector_copy,"sfSocketSelector_copy"); 803 | lib.bindSymbol(cast(void**)&sfSocketSelector_destroy,"sfSocketSelector_destroy"); 804 | lib.bindSymbol(cast(void**)&sfSocketSelector_addTcpListener,"sfSocketSelector_addTcpListener"); 805 | lib.bindSymbol(cast(void**)&sfSocketSelector_addTcpSocket,"sfSocketSelector_addTcpSocket"); 806 | lib.bindSymbol(cast(void**)&sfSocketSelector_addUdpSocket,"sfSocketSelector_addUdpSocket"); 807 | lib.bindSymbol(cast(void**)&sfSocketSelector_removeTcpListener,"sfSocketSelector_removeTcpListener"); 808 | lib.bindSymbol(cast(void**)&sfSocketSelector_removeTcpSocket,"sfSocketSelector_removeTcpSocket"); 809 | lib.bindSymbol(cast(void**)&sfSocketSelector_removeUdpSocket,"sfSocketSelector_removeUdpSocket"); 810 | lib.bindSymbol(cast(void**)&sfSocketSelector_clear,"sfSocketSelector_clear"); 811 | lib.bindSymbol(cast(void**)&sfSocketSelector_wait,"sfSocketSelector_wait"); 812 | lib.bindSymbol(cast(void**)&sfSocketSelector_isTcpListenerReady,"sfSocketSelector_isTcpListenerReady"); 813 | lib.bindSymbol(cast(void**)&sfSocketSelector_isTcpSocketReady,"sfSocketSelector_isTcpSocketReady"); 814 | lib.bindSymbol(cast(void**)&sfSocketSelector_isUdpSocketReady,"sfSocketSelector_isUdpSocketReady"); 815 | lib.bindSymbol(cast(void**)&sfTcpListener_create,"sfTcpListener_create"); 816 | lib.bindSymbol(cast(void**)&sfTcpListener_destroy,"sfTcpListener_destroy"); 817 | lib.bindSymbol(cast(void**)&sfTcpListener_setBlocking,"sfTcpListener_setBlocking"); 818 | lib.bindSymbol(cast(void**)&sfTcpListener_isBlocking,"sfTcpListener_isBlocking"); 819 | lib.bindSymbol(cast(void**)&sfTcpListener_getLocalPort,"sfTcpListener_getLocalPort"); 820 | lib.bindSymbol(cast(void**)&sfTcpListener_listen,"sfTcpListener_listen"); 821 | lib.bindSymbol(cast(void**)&sfTcpListener_accept,"sfTcpListener_accept"); 822 | lib.bindSymbol(cast(void**)&sfTcpSocket_create,"sfTcpSocket_create"); 823 | lib.bindSymbol(cast(void**)&sfTcpSocket_destroy,"sfTcpSocket_destroy"); 824 | lib.bindSymbol(cast(void**)&sfTcpSocket_setBlocking,"sfTcpSocket_setBlocking"); 825 | lib.bindSymbol(cast(void**)&sfTcpSocket_isBlocking,"sfTcpSocket_isBlocking"); 826 | lib.bindSymbol(cast(void**)&sfTcpSocket_getLocalPort,"sfTcpSocket_getLocalPort"); 827 | lib.bindSymbol(cast(void**)&sfTcpSocket_getRemoteAddress,"sfTcpSocket_getRemoteAddress"); 828 | lib.bindSymbol(cast(void**)&sfTcpSocket_getRemotePort,"sfTcpSocket_getRemotePort"); 829 | lib.bindSymbol(cast(void**)&sfTcpSocket_connect,"sfTcpSocket_connect"); 830 | lib.bindSymbol(cast(void**)&sfTcpSocket_disconnect,"sfTcpSocket_disconnect"); 831 | lib.bindSymbol(cast(void**)&sfTcpSocket_send,"sfTcpSocket_send"); 832 | lib.bindSymbol(cast(void**)&sfTcpSocket_receive,"sfTcpSocket_receive"); 833 | lib.bindSymbol(cast(void**)&sfTcpSocket_sendPacket,"sfTcpSocket_sendPacket"); 834 | lib.bindSymbol(cast(void**)&sfTcpSocket_receivePacket,"sfTcpSocket_receivePacket"); 835 | lib.bindSymbol(cast(void**)&sfUdpSocket_destroy,"sfUdpSocket_destroy"); 836 | lib.bindSymbol(cast(void**)&sfUdpSocket_setBlocking,"sfUdpSocket_setBlocking"); 837 | lib.bindSymbol(cast(void**)&sfUdpSocket_isBlocking,"sfUdpSocket_isBlocking"); 838 | lib.bindSymbol(cast(void**)&sfUdpSocket_getLocalPort,"sfUdpSocket_getLocalPort"); 839 | lib.bindSymbol(cast(void**)&sfUdpSocket_bind,"sfUdpSocket_bind"); 840 | lib.bindSymbol(cast(void**)&sfUdpSocket_unbind,"sfUdpSocket_unbind"); 841 | lib.bindSymbol(cast(void**)&sfUdpSocket_send,"sfUdpSocket_send"); 842 | lib.bindSymbol(cast(void**)&sfUdpSocket_receive,"sfUdpSocket_receive"); 843 | lib.bindSymbol(cast(void**)&sfUdpSocket_sendPacket,"sfUdpSocket_sendPacket"); 844 | lib.bindSymbol(cast(void**)&sfUdpSocket_receivePacket,"sfUdpSocket_receivePacket"); 845 | lib.bindSymbol(cast(void**)&sfUdpSocket_maxDatagramSize,"sfUdpSocket_maxDatagramSize"); 846 | 847 | if(errorCount() != errCount) return SFMLSupport.badLibrary; 848 | else{ 849 | static if(sfmlSupport >= SFMLSupport.sfml220){ 850 | loadedVersion = sfmlSupport.sfml220; 851 | }else{ 852 | loadedVersion = sfmlSupport.sfml200; 853 | } 854 | } 855 | 856 | static if(sfmlSupport >= SFMLSupport.sfml230){ 857 | lib.bindSymbol(cast(void**)&sfTcpSocket_sendPartial,"sfTcpSocket_sendPartial"); 858 | 859 | if(errorCount() != errCount) return SFMLSupport.badLibrary; 860 | else loadedVersion = SFMLSupport.sfml230; 861 | } 862 | static if(sfmlSupport >= SFMLSupport.sfml240){ 863 | lib.bindSymbol(cast(void**)&sfFtp_sendCommand,"sfFtp_sendCommand"); 864 | 865 | if(errorCount() != errCount) return SFMLSupport.badLibrary; 866 | static if(sfmlSupport >= SFMLSupport.sfml250){ 867 | loadedVersion = SFMLSupport.sfml250; 868 | }else{ 869 | loadedVersion = SFMLSupport.sfml240; 870 | } 871 | } 872 | 873 | loadedVersion = sfmlSupport; 874 | return loadedVersion; 875 | } 876 | } 877 | --------------------------------------------------------------------------------