├── .editorconfig ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── CONTRIBUTING.md ├── License.txt ├── README.md ├── appveyor.yml ├── build.d ├── changelog.txt ├── doc ├── local_documentation.ddoc └── website_documentation.ddoc ├── dub.json ├── dub.selections.json ├── src ├── DSFMLC │ ├── Audio │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── Export.h │ │ ├── InputSoundFile.cpp │ │ ├── InputSoundFile.h │ │ ├── InputSoundFileStruct.h │ │ ├── InternalSoundRecorder.cpp │ │ ├── InternalSoundRecorder.hpp │ │ ├── Listener.cpp │ │ ├── Listener.h │ │ ├── OutputSoundFile.cpp │ │ ├── OutputSoundFile.h │ │ ├── OutputSoundFileStruct.h │ │ ├── Sound.cpp │ │ ├── Sound.h │ │ ├── SoundBuffer.cpp │ │ ├── SoundBuffer.h │ │ ├── SoundBufferStruct.h │ │ ├── SoundRecorder.cpp │ │ ├── SoundRecorder.h │ │ ├── SoundRecorderStruct.h │ │ ├── SoundSource.cpp │ │ ├── SoundSource.h │ │ ├── SoundStream.cpp │ │ ├── SoundStream.h │ │ ├── SoundStreamStruct.h │ │ ├── SoundStruct.h │ │ └── Types.h │ ├── CMakeLists.txt │ ├── Config.h │ ├── ConvertEvent.h │ ├── Graphics │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── CreateRenderStates.hpp │ │ ├── Export.h │ │ ├── Font.cpp │ │ ├── Font.h │ │ ├── FontStruct.h │ │ ├── Image.cpp │ │ ├── Image.h │ │ ├── ImageStruct.h │ │ ├── RenderTexture.cpp │ │ ├── RenderTexture.h │ │ ├── RenderTextureStruct.h │ │ ├── RenderWindow.cpp │ │ ├── RenderWindow.h │ │ ├── RenderWindowStruct.h │ │ ├── Shader.cpp │ │ ├── Shader.h │ │ ├── ShaderStruct.h │ │ ├── Texture.cpp │ │ ├── Texture.h │ │ ├── TextureStruct.h │ │ ├── Transform.cpp │ │ ├── Transform.h │ │ └── Types.h │ ├── Network │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── Export.h │ │ ├── Ftp.cpp │ │ ├── Ftp.h │ │ ├── FtpStruct.h │ │ ├── Http.cpp │ │ ├── Http.h │ │ ├── HttpStruct.h │ │ ├── IpAddress.cpp │ │ ├── IpAddress.h │ │ ├── Packet.cpp │ │ ├── Packet.h │ │ ├── PacketStruct.h │ │ ├── SocketSelector.cpp │ │ ├── SocketSelector.h │ │ ├── SocketSelectorStruct.h │ │ ├── TcpListener.cpp │ │ ├── TcpListener.h │ │ ├── TcpListenerStruct.h │ │ ├── TcpSocket.cpp │ │ ├── TcpSocket.h │ │ ├── TcpSocketStruct.h │ │ ├── Types.h │ │ ├── UdpSocket.cpp │ │ ├── UdpSocket.h │ │ └── UdpSocketStruct.h │ ├── System │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── DStream.hpp │ │ ├── Err.cpp │ │ ├── Err.h │ │ ├── ErrStream.cpp │ │ ├── ErrStream.hpp │ │ ├── Export.h │ │ ├── String.cpp │ │ ├── String.h │ │ ├── Threads.cpp │ │ └── Threads.h │ └── Window │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── Context.cpp │ │ ├── Context.h │ │ ├── ContextStruct.h │ │ ├── ConvertEvent.h │ │ ├── Event.h │ │ ├── Export.h │ │ ├── Joystick.cpp │ │ ├── Joystick.h │ │ ├── Keyboard.cpp │ │ ├── Keyboard.h │ │ ├── Mouse.cpp │ │ ├── Mouse.h │ │ ├── Sensor.cpp │ │ ├── Sensor.h │ │ ├── Touch.cpp │ │ ├── Touch.h │ │ ├── Types.h │ │ ├── VideoMode.cpp │ │ ├── VideoMode.h │ │ ├── Window.cpp │ │ ├── Window.h │ │ ├── WindowHandle.h │ │ └── WindowStruct.h └── dsfml │ ├── audio │ ├── inputsoundfile.d │ ├── listener.d │ ├── music.d │ ├── outputsoundfile.d │ ├── package.d │ ├── sound.d │ ├── soundbuffer.d │ ├── soundbufferrecorder.d │ ├── soundrecorder.d │ ├── soundsource.d │ └── soundstream.d │ ├── graphics │ ├── blendmode.d │ ├── circleshape.d │ ├── color.d │ ├── convexshape.d │ ├── drawable.d │ ├── font.d │ ├── glsl.d │ ├── glyph.d │ ├── image.d │ ├── package.d │ ├── primitivetype.d │ ├── rect.d │ ├── rectangleshape.d │ ├── renderstates.d │ ├── rendertarget.d │ ├── rendertexture.d │ ├── renderwindow.d │ ├── shader.d │ ├── shape.d │ ├── sprite.d │ ├── text.d │ ├── texture.d │ ├── transform.d │ ├── transformable.d │ ├── vertex.d │ ├── vertexarray.d │ └── view.d │ ├── network │ ├── ftp.d │ ├── http.d │ ├── ipaddress.d │ ├── package.d │ ├── packet.d │ ├── socket.d │ ├── socketselector.d │ ├── tcplistener.d │ ├── tcpsocket.d │ └── udpsocket.d │ ├── system │ ├── clock.d │ ├── config.d │ ├── err.d │ ├── inputstream.d │ ├── lock.d │ ├── mutex.d │ ├── package.d │ ├── sleep.d │ ├── string.d │ ├── thread.d │ ├── time.d │ ├── vector2.d │ └── vector3.d │ └── window │ ├── context.d │ ├── contextsettings.d │ ├── event.d │ ├── joystick.d │ ├── keyboard.d │ ├── mouse.d │ ├── package.d │ ├── sensor.d │ ├── touch.d │ ├── videomode.d │ ├── window.d │ └── windowhandle.d └── unittest └── res ├── TestImage.png ├── TestMusic.ogg ├── TestSound.ogg └── Warenhaus-Standard.ttf /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.yml] 12 | indent_size = 2 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | obj/ 3 | lib/ 4 | import/ 5 | *.exe 6 | CMakeFiles/ 7 | *.cmake 8 | Makefile 9 | CMakeCache.txt 10 | libdsfml.a 11 | .dub/ 12 | build 13 | build.exe 14 | unittest/unittest 15 | unittest/unittest.exe 16 | unittest/Text.png 17 | unittest/log.txt 18 | unittest/*.dll 19 | unittest/*.so 20 | unittest/*.dylib 21 | dub.selections.json 22 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "SFML"] 2 | path = SFML 3 | url = https://github.com/SFML/SFML 4 | ignore = dirty 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: 2 | - linux 3 | - osx 4 | 5 | language: d 6 | 7 | dist: trusty 8 | sudo: false 9 | 10 | addons: 11 | apt: 12 | packages: 13 | #- libfreetype6-dev 14 | #- libgl1-mesa-dev 15 | #- libglew-dev 16 | #- libjpeg8-dev 17 | - libopenal-dev 18 | #- libpthread-stubs0-dev 19 | #- libsndfile1-dev 20 | #- libx11-dev 21 | #- libx11-xcb-dev 22 | #- libxrandr-dev 23 | #- libxcb-image0-dev 24 | #- libxcb-randr0-dev 25 | #- libudev-dev 26 | #- libvorbis-dev 27 | #- libflac-dev 28 | 29 | d: 30 | - dmd-2.075.0 31 | - dmd-2.074.1 32 | - dmd-2.073.2 33 | - dmd-2.072.2 34 | - dmd-2.071.2 35 | - dmd-2.070.2 36 | - dmd-2.069.2 37 | - dmd-2.068.2 38 | # - gdc-6.3.0 39 | # - gdc-5.4.0 40 | - gdc-4.9.4 41 | - gdc-4.8.5 42 | - ldc-1.3.0 43 | - ldc-1.2.0 44 | - ldc-1.1.1 45 | 46 | matrix: 47 | exclude: 48 | # - os: osx 49 | # d: gdc-6.3.0 50 | # - os: osx 51 | # d: gdc-5.4.0 52 | - os: osx 53 | d: gdc-4.9.4 54 | - os: osx 55 | d: gdc-4.8.5 56 | 57 | #Download SFML binaries 58 | install: 59 | - mkdir SFML/lib 60 | - cd SFML/lib 61 | - curl dsfml.com/bins/ci/${TRAVIS_OS_NAME}/sfml.tar.gz -o sfml.tar.gz 62 | - tar xf sfml.tar.gz 63 | - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${TRAVIS_BUILD_DIR}/SFML/lib 64 | - cd $TRAVIS_BUILD_DIR 65 | 66 | script: 67 | - echo ${DMD} build.d 68 | - ${DMD} build.d 69 | # build static libraries 70 | - ./build 71 | #build unit tests 72 | - ./build --unittest 73 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8.3) 2 | 3 | project (DSFMLC) 4 | 5 | option(STATIC_SFML "Build DSFMLC expecting static SFML libs" ON) 6 | 7 | set(CMAKE_BUILD_TYPE Release) 8 | 9 | #we want to make sure we're linking to static crt libs 10 | #Stolen from stack overflow 11 | if(MSVC) 12 | # We statically link to reduce dependencies 13 | foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) 14 | if(${flag_var} MATCHES "/MD") 15 | string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") 16 | endif(${flag_var} MATCHES "/MD") 17 | if(${flag_var} MATCHES "/MDd") 18 | string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}") 19 | endif(${flag_var} MATCHES "/MDd") 20 | endforeach(flag_var) 21 | endif(MSVC) 22 | 23 | 24 | #DSFML should work for all patch versions 25 | set(VERSION_MAJOR 2) 26 | set(VERSION_MINOR 4) 27 | 28 | 29 | #add DSFMLC and SFML header paths 30 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) 31 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) 32 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/SFML/include) 33 | 34 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) 35 | 36 | if(STATIC_SFML) 37 | add_definitions(-DSFML_STATIC) 38 | endif(STATIC_SFML) 39 | 40 | 41 | add_subdirectory(src/DSFMLC/System) 42 | add_subdirectory(src/DSFMLC/Audio) 43 | add_subdirectory(src/DSFMLC/Network) 44 | add_subdirectory(src/DSFMLC/Window) 45 | add_subdirectory(src/DSFMLC/Graphics) 46 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Opening a new Issue 2 | === 3 | 4 | When opening a new issue, please remember that while I want this library to feel very D-like, I also want to keep it as true to SFML as possible. If you have a suggestion, I am always willing to discuss it, but I want it to make sense for the library. Just because it isn't a part of SFML doesn't mean it wouldn't be something that could make the library better either. If we can do something better in D than we could in C++, then we should (See https://github.com/Jebbs/DSFML/pull/109). 5 | 6 | Opening a Pull Request 7 | === 8 | 9 | When opening a pull request, don't forget to check the guidelines for opening a new issue if your pull has a new feature. If you are usure that it fits with the library, you can always open an issue first and then a pull request later. 10 | 11 | Please take a quick look at my notes for source file layouts before you submit the pull request. (https://gist.github.com/Jebbs/8904535) 12 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | 2 | DSFML - The Simple and Fast Multimedia Library for D 3 | 4 | Copyright (c) 2013 - 2015 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | 6 | This software is provided 'as-is', without any express or implied warranty. 7 | In no event will the authors be held liable for any damages arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, including commercial applications, 10 | and to alter it and redistribute it freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 13 | If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 14 | 15 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 16 | 17 | 3. This notice may not be removed or altered from any source distribution 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DSFML 2 | ===== 3 | [![Build Status](https://travis-ci.org/Jebbs/DSFML.svg?branch=master)](https://travis-ci.org/Jebbs/DSFML) 4 | [![Build Status](https://ci.appveyor.com/api/projects/status/github/jebbs/dsfml?branch=master&svg=true)](https://ci.appveyor.com/project/jebbs/dsfml) 5 | 6 | 7 | DSFML is a static binding of SFML, which let's you use SFML in your D programs. DSFML attempts to be as compatible with SFML as possible, but does so in a way that makes sense for the D language. 8 | 9 | See www.dsfml.com for more information and help getting started 10 | 11 | 12 | 13 | 14 | Contributing 15 | === 16 | If you would like to contribute, feel free! Issues, pull requests, and emails are always welcome. 17 | 18 | 19 | Email is 20 | 21 | 22 | -------------------------------------------------------------------------------- /dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dsfml", 3 | "description": "DSFML binding for SFML-The Simple and Fast Multimedia Library", 4 | "authors": ["Jeremy DeHaan"], 5 | "homepage": "https://github.com/Jebbs/DSFML", 6 | "version":"2.4.0", 7 | "license": "Zlib", 8 | "dependencies": { 9 | "dsfml:audio": "~>2.4", 10 | "dsfml:graphics": "~>2.4", 11 | "dsfml:window": "~>2.4", 12 | "dsfml:network": "~>2.4", 13 | "dsfml:system": "~>2.4" 14 | }, 15 | "subPackages": 16 | [ 17 | { 18 | "name": "audio", 19 | "targetType": "library", 20 | "sourcePaths": ["src/dsfml/audio"], 21 | "libs": [ "dsfmlc-audio" ], 22 | "dependencies": 23 | { 24 | "dsfml:system": "~>2.4" 25 | } 26 | }, 27 | { 28 | "name": "graphics", 29 | "targetType": "library", 30 | "sourcePaths": ["src/dsfml/graphics"], 31 | "libs": [ "dsfmlc-graphics" ], 32 | "dependencies": 33 | { 34 | "dsfml:system": "~>2.4", 35 | "dsfml:window": "~>2.4" 36 | } 37 | }, 38 | { 39 | "name": "window", 40 | "sourcePaths": ["src/dsfml/window"], 41 | "libs": [ "dsfmlc-window" ], 42 | "dependencies": 43 | { 44 | "dsfml:system": "~>2.4" 45 | } 46 | }, 47 | { 48 | "name": "network", 49 | "targetType": "library", 50 | "sourcePaths": ["src/dsfml/network"], 51 | "libs": [ "dsfmlc-network" ], 52 | "dependencies": 53 | { 54 | "dsfml:system": "~>2.4" 55 | } 56 | }, 57 | { 58 | "name": "system", 59 | "targetType": "library", 60 | "importPaths": ["src/"], 61 | "sourcePaths": ["src/dsfml/system"], 62 | "libs": [ "dsfmlc-system" ] 63 | } 64 | ] 65 | } 66 | -------------------------------------------------------------------------------- /dub.selections.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileVersion": 1, 3 | "versions": { 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/.gitignore: -------------------------------------------------------------------------------- 1 | #Ignore these things because they are annoying 2 | CMakeFiles/ 3 | *.cmake 4 | Makefile 5 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCROOT ${PROJECT_SOURCE_DIR}/Audio) 2 | 3 | # all source files 4 | set(SRC 5 | ${SRCROOT}/Export.h 6 | ${SRCROOT}/Listener.cpp 7 | ${SRCROOT}/Listener.h 8 | ${SRCROOT}/Sound.cpp 9 | ${SRCROOT}/Sound.h 10 | ${SRCROOT}/SoundBuffer.cpp 11 | ${SRCROOT}/SoundBuffer.h 12 | ${SRCROOT}/InputSoundFile.cpp 13 | ${SRCROOT}/InputSoundFile.h 14 | ${SRCROOT}/InputSoundFileStruct.h 15 | ${SRCROOT}/OutputSoundFile.cpp 16 | ${SRCROOT}/OutputSoundFile.h 17 | ${SRCROOT}/OutputSoundFileStruct.h 18 | ${SRCROOT}/SoundRecorder.cpp 19 | ${SRCROOT}/SoundRecorder.h 20 | ${SRCROOT}/SoundRecorderStruct.h 21 | ${SRCROOT}/SoundStreamStruct.h 22 | ${SRCROOT}/SoundStream.cpp 23 | ${SRCROOT}/SoundStream.h 24 | ) 25 | source_group("" FILES ${SRC}) 26 | 27 | #build only object files that can be linked into a d static library 28 | add_library(dsfmlc-audio OBJECT ${SRC}) 29 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/Export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_AUDIO_EXPORT_H 29 | #define DSFML_AUDIO_EXPORT_H 30 | 31 | #include 32 | 33 | #define DSFML_AUDIO_API extern "C" SFML_API_EXPORT 34 | 35 | #endif // DSFML_AUDIO_EXPORT_H 36 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/InputSoundFile.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include "InputSoundFileStruct.h" 32 | 33 | sfInputSoundFile* sfInputSoundFile_create() 34 | { 35 | return new sfInputSoundFile; 36 | } 37 | 38 | void sfInputSoundFile_destroy(sfInputSoundFile* file) 39 | { 40 | delete file; 41 | } 42 | 43 | DLong sfInputSoundFile_getSampleCount(const sfInputSoundFile* file) 44 | { 45 | return file->This.getSampleCount(); 46 | } 47 | 48 | DUint sfInputSoundFile_getChannelCount( const sfInputSoundFile* file) 49 | { 50 | return file->This.getChannelCount(); 51 | } 52 | 53 | DUint sfInputSoundFile_getSampleRate(const sfInputSoundFile* file) 54 | { 55 | DUint test = file->This.getSampleRate(); 56 | return test; 57 | } 58 | 59 | DBool sfInputSoundFile_openFromFile(sfInputSoundFile* file, const char* filename, size_t length) 60 | { 61 | if(file->This.openFromFile(std::string(filename, length))) 62 | { 63 | return DTrue; 64 | } 65 | return DFalse; 66 | } 67 | 68 | DBool sfInputSoundFile_openFromMemory(sfInputSoundFile* file,void* data, DLong sizeInBytes) 69 | { 70 | bool toReturn = file->This.openFromMemory(data,(size_t)sizeInBytes); 71 | 72 | return toReturn?DTrue:DFalse; 73 | } 74 | 75 | DBool sfInputSoundFile_openFromStream(sfInputSoundFile* file, DStream* stream) 76 | { 77 | file->stream = sfmlStream(stream); 78 | 79 | bool toReturn = file->This.openFromStream(file->stream); 80 | 81 | return toReturn?DTrue:DFalse; 82 | } 83 | 84 | DLong sfInputSoundFile_read(sfInputSoundFile* file, DShort* data, DLong sampleCount) 85 | { 86 | return file->This.read(data, (size_t)sampleCount); 87 | } 88 | 89 | void sfInputSoundFile_seek(sfInputSoundFile* file, DLong timeOffset) 90 | { 91 | 92 | sf::Time temp = sf::microseconds(timeOffset); 93 | file->This.seek(temp); 94 | } 95 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/InputSoundFile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_INPUTSOUNDFILE_H 29 | #define DSFML_INPUTSOUNDFILE_H 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | //Creates the sound file 37 | DSFML_AUDIO_API sfInputSoundFile* sfInputSoundFile_create(); 38 | 39 | //Destroys the sound file 40 | DSFML_AUDIO_API void sfInputSoundFile_destroy(sfInputSoundFile* file); 41 | 42 | //Get the sample count of the sound file 43 | DSFML_AUDIO_API DLong sfInputSoundFile_getSampleCount(const sfInputSoundFile* file); 44 | 45 | //Get the channel count of the sound file 46 | DSFML_AUDIO_API DUint sfInputSoundFile_getChannelCount(const sfInputSoundFile* file); 47 | 48 | //Get the sample rate of the sound file 49 | DSFML_AUDIO_API DUint sfInputSoundFile_getSampleRate(const sfInputSoundFile* file); 50 | 51 | //Open a sound file for reading 52 | DSFML_AUDIO_API DBool sfInputSoundFile_openFromFile(sfInputSoundFile* file, 53 | const char* filename, 54 | size_t length); 55 | 56 | //Open a sound file in memory for reading 57 | DSFML_AUDIO_API DBool sfInputSoundFile_openFromMemory(sfInputSoundFile* file, 58 | void* data, 59 | DLong sizeInBytes); 60 | 61 | //Open a sound file from a custom stream for reading 62 | DSFML_AUDIO_API DBool sfInputSoundFile_openFromStream(sfInputSoundFile* file, 63 | DStream* stream); 64 | 65 | //Read samples from a sound file 66 | DSFML_AUDIO_API DLong sfInputSoundFile_read(sfInputSoundFile* file, DShort* data, 67 | DLong sampleCount); 68 | 69 | //Change the current read position in the sound file 70 | DSFML_AUDIO_API void sfInputSoundFile_seek(sfInputSoundFile* file, 71 | DLong timeOffset); 72 | 73 | #endif // DSFML_INPUTSOUNDFILE_H 74 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/InputSoundFileStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_INPUTSOUNDFILESTRUCT_H 29 | #define DSFML_INPUTSOUNDFILESTRUCT_H 30 | 31 | 32 | #include 33 | #include 34 | 35 | //Create a wrapper around a sf::priv::SoundFile 36 | struct sfInputSoundFile 37 | { 38 | sf::InputSoundFile This; 39 | sfmlStream stream; 40 | }; 41 | 42 | #endif // DSFML_INPUTSOUNDFILESTRUCT_H 43 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/InternalSoundRecorder.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_INTERNALSOUNDRECORDER_HPP 29 | #define DSFML_INTERNALSOUNDRECORDER_HPP 30 | 31 | #include 32 | #include 33 | 34 | //Class for recording sound data to be passed to sfSoundRecorder 35 | class InternalSoundRecorder 36 | { 37 | public: 38 | //Initialize the system for recording 39 | DBool initialize(DUint sampleRate); 40 | 41 | //Start the capturing of sound data 42 | void startCapture(); 43 | 44 | //Get the number of samples that have been recorded so far 45 | DInt getSampleNumber(); 46 | 47 | //Get a pointer to the samples that have been captured 48 | DShort* getSamplePointer(DInt numSamples); 49 | 50 | //Stop the capturing of sound data 51 | void stopCapture(); 52 | 53 | //Close the device so that another sound recorder may use it 54 | void closeDevice(); 55 | 56 | //Check to see if sound recording is allowed on the system 57 | static DBool isAvailable(); 58 | 59 | private: 60 | //Vector that stores recorded samples 61 | std::vector m_samples; 62 | }; 63 | 64 | #endif // DSFML_INTERNALSOUNDRECORDER_HPP 65 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/Listener.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | void sfListener_setGlobalVolume(float volume) 33 | { 34 | sf::Listener::setGlobalVolume(volume); 35 | } 36 | 37 | float sfListener_getGlobalVolume(void) 38 | { 39 | return sf::Listener::getGlobalVolume(); 40 | } 41 | 42 | void sfListener_setPosition(float x, float y, float z) 43 | { 44 | 45 | sf::Listener::setPosition(x,y,z); 46 | } 47 | 48 | void sfListener_getPosition(float* x, float* y, float* z) 49 | { 50 | sf::Vector3f temp; 51 | 52 | temp = sf::Listener::getPosition(); 53 | 54 | *x = temp.x; 55 | *y = temp.y; 56 | *z = temp.z; 57 | } 58 | 59 | void sfListener_setDirection(float x, float y, float z) 60 | { 61 | sf::Listener::setDirection(x,y,z); 62 | } 63 | 64 | void sfListener_getDirection(float* x, float* y, float* z) 65 | { 66 | sf::Vector3f temp; 67 | 68 | temp = sf::Listener::getDirection(); 69 | 70 | *x = temp.x; 71 | *y = temp.y; 72 | *z = temp.z; 73 | } 74 | 75 | void sfListener_setUpVector(float x, float y, float z) 76 | { 77 | sf::Listener::setUpVector(x,y,z); 78 | } 79 | 80 | void sfListener_getUpVector(float* x, float* y, float* z) 81 | { 82 | sf::Vector3f temp; 83 | 84 | temp = sf::Listener::getUpVector(); 85 | 86 | *x = temp.x; 87 | *y = temp.y; 88 | *z = temp.z; 89 | } 90 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/Listener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_AUDIO_LISTENER_H 29 | #define DSFML_AUDIO_LISTENER_H 30 | 31 | #include 32 | 33 | //Set the global volume 34 | DSFML_AUDIO_API void sfListener_setGlobalVolume(float volume); 35 | 36 | //Get the global volume 37 | DSFML_AUDIO_API float sfListener_getGlobalVolume(void); 38 | 39 | //Set the position of the Listener 40 | DSFML_AUDIO_API void sfListener_setPosition(float x, float y, float z); 41 | 42 | //Get the position of the Listener 43 | DSFML_AUDIO_API void sfListener_getPosition(float* x, float* y, float* z); 44 | 45 | //Set the direction of the Listener 46 | DSFML_AUDIO_API void sfListener_setDirection(float x, float y, float z); 47 | 48 | //Get the direction of the Listener 49 | DSFML_AUDIO_API void sfListener_getDirection(float* x, float* y, float* z); 50 | 51 | //Set the upward vector of the Listener 52 | DSFML_AUDIO_API void sfListener_setUpVector(float x, float y, float z); 53 | 54 | //Get the upward vector of the Listener 55 | DSFML_AUDIO_API void sfListener_getUpVector(float* x, float* y, float* z); 56 | 57 | #endif // DSFML_AUDIO_LISTENER_H 58 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/OutputSoundFile.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include "OutputSoundFileStruct.h" 30 | 31 | sfOutputSoundFile* sfOutputSoundFile_create() 32 | { 33 | return new sfOutputSoundFile; 34 | } 35 | 36 | void sfOutputSoundFile_destroy(sfOutputSoundFile* file) 37 | { 38 | delete file; 39 | } 40 | 41 | DBool sfOutputSoundFile_openFromFile(sfOutputSoundFile* file, const char* filename, size_t length, DUint channelCount, DUint sampleRate) 42 | { 43 | bool toReturn = file->This.openFromFile(std::string(filename, length), channelCount, sampleRate); 44 | 45 | return toReturn?DTrue:DFalse; 46 | } 47 | 48 | void sfOutputSoundFile_write(sfOutputSoundFile* file, const DShort* data, DLong sampleCount) 49 | { 50 | file->This.write(data,(size_t)sampleCount); 51 | } 52 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/OutputSoundFile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_OUTPUTSOUNDFILE_H 29 | #define DSFML_OUTPUTSOUNDFILE_H 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | //Creates the sound file 36 | DSFML_AUDIO_API sfOutputSoundFile* sfOutputSoundFile_create(); 37 | 38 | //Destroys the sound file 39 | DSFML_AUDIO_API void sfOutputSoundFile_destroy(sfOutputSoundFile* file); 40 | 41 | //Open a sound file for writting 42 | DSFML_AUDIO_API DBool sfOutputSoundFile_openFromFile(sfOutputSoundFile* file, const char* filename, size_t length, DUint channelCount, DUint sampleRate); 43 | 44 | //Write samples to a sound file 45 | DSFML_AUDIO_API void sfOutputSoundFile_write(sfOutputSoundFile* file, const DShort* data, DLong sampleCount); 46 | 47 | #endif // DSFML_OUTPUTSOUNDFILE_H 48 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/OutputSoundFileStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_OUTPUTSOUNDFILESTRUCT_H 29 | #define DSFML_OUTPUTSOUNDFILESTRUCT_H 30 | 31 | #include 32 | 33 | //Create a wrapper around a sf::OutputSoundFile 34 | struct sfOutputSoundFile 35 | { 36 | sf::OutputSoundFile This; 37 | }; 38 | 39 | #endif // DSFML_INPUTSOUNDFILESTRUCT_H 40 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/Sound.h: -------------------------------------------------------------------------------- 1 | /* 2 | DSFML - The Simple and Fast Multimedia Library for D 3 | 4 | Copyright (c) <2018> 5 | 6 | This software is provided 'as-is', without any express or implied warranty. 7 | In no event will the authors be held liable for any damages arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, including commercial applications, 10 | and to alter it and redistribute it freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 13 | If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 14 | 15 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 16 | 17 | 3. This notice may not be removed or altered from any source distribution 18 | 19 | 20 | ***All code is based on code written by Laurent Gomila*** 21 | 22 | 23 | External Libraries Used: 24 | 25 | SFML - The Simple and Fast Multimedia Library 26 | Copyright (C) 2007-2018 Laurent Gomila (laurent.gom@gmail.com) 27 | 28 | All Libraries used by SFML - For a full list see http://www.sfml-dev.org/license.php 29 | */ 30 | 31 | #ifndef DSFML_SOUND_H 32 | #define DSFML_SOUND_H 33 | 34 | //Header 35 | #include 36 | #include 37 | 38 | 39 | DSFML_AUDIO_API sfSound* sfSound_construct(void); 40 | 41 | DSFML_AUDIO_API sfSound* sfSound_copy(const sfSound* sound); 42 | 43 | DSFML_AUDIO_API void sfSound_destroy(sfSound* sound); 44 | 45 | DSFML_AUDIO_API void sfSound_play(sfSound* sound); 46 | 47 | DSFML_AUDIO_API void sfSound_pause(sfSound* sound); 48 | 49 | DSFML_AUDIO_API void sfSound_stop(sfSound* sound); 50 | 51 | DSFML_AUDIO_API void sfSound_setBuffer(sfSound* sound, const sfSoundBuffer* buffer); 52 | 53 | //DSFML_AUDIO_API sfSoundBuffer* sfSound_getBuffer(const sfSound* sound); 54 | 55 | DSFML_AUDIO_API void sfSound_setLoop(sfSound* sound, DBool loop); 56 | 57 | DSFML_AUDIO_API DBool sfSound_getLoop(const sfSound* sound); 58 | 59 | DSFML_AUDIO_API int sfSound_getStatus(const sfSound* sound); 60 | 61 | DSFML_AUDIO_API void sfSound_setPitch(sfSound* sound, float pitch); 62 | 63 | DSFML_AUDIO_API void sfSound_setVolume(sfSound* sound, float volume); 64 | 65 | DSFML_AUDIO_API void sfSound_setPosition(sfSound* sound, float positionX, float positionY, float positionZ); 66 | 67 | DSFML_AUDIO_API void sfSound_setRelativeToListener(sfSound* sound, DBool relative); 68 | 69 | DSFML_AUDIO_API void sfSound_setMinDistance(sfSound* sound, float distance); 70 | 71 | DSFML_AUDIO_API void sfSound_setAttenuation(sfSound* sound, float attenuation); 72 | 73 | DSFML_AUDIO_API void sfSound_setPlayingOffset(sfSound* sound, DLong timeOffset); 74 | 75 | DSFML_AUDIO_API float sfSound_getPitch(const sfSound* sound); 76 | 77 | DSFML_AUDIO_API float sfSound_getVolume(const sfSound* sound); 78 | 79 | DSFML_AUDIO_API void sfSound_getPosition(const sfSound* sound, float* positionX, float* positionY, float* positionZ); 80 | 81 | DSFML_AUDIO_API DBool sfSound_isRelativeToListener(const sfSound* sound); 82 | 83 | DSFML_AUDIO_API float sfSound_getMinDistance(const sfSound* sound); 84 | 85 | DSFML_AUDIO_API float sfSound_getAttenuation(const sfSound* sound); 86 | 87 | DSFML_AUDIO_API DLong sfSound_getPlayingOffset(const sfSound* sound); 88 | 89 | #endif // DSFML_SOUND_H 90 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/SoundBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include "SoundBufferStruct.h" 30 | 31 | sfSoundBuffer* sfSoundBuffer_construct() 32 | { 33 | return new sfSoundBuffer; 34 | } 35 | 36 | DBool sfSoundBuffer_loadFromFile(sfSoundBuffer* soundBuffer, const char* filename, size_t length) 37 | { 38 | return (soundBuffer->This.loadFromFile(std::string(filename, length)))?DTrue:DFalse; 39 | } 40 | 41 | DBool sfSoundBuffer_loadFromMemory(sfSoundBuffer* soundBuffer, const void* data, size_t sizeInBytes) 42 | { 43 | return (soundBuffer->This.loadFromMemory(data, sizeInBytes))?DTrue:DFalse; 44 | } 45 | 46 | DBool sfSoundBuffer_loadFromStream(sfSoundBuffer* soundBuffer, DStream* stream) 47 | { 48 | sfmlStream Stream = sfmlStream(stream); 49 | return (soundBuffer->This.loadFromStream(Stream))?DTrue:DFalse; 50 | } 51 | 52 | DBool sfSoundBuffer_loadFromSamples(sfSoundBuffer* soundBuffer, const DShort* samples, size_t sampleCount, DUint channelCount, DUint sampleRate) 53 | { 54 | return (soundBuffer->This.loadFromSamples(samples, sampleCount, channelCount, sampleRate))?DTrue:DFalse; 55 | } 56 | 57 | sfSoundBuffer* sfSoundBuffer_copy(const sfSoundBuffer* soundBuffer) 58 | { 59 | return new sfSoundBuffer(*soundBuffer); 60 | } 61 | 62 | void sfSoundBuffer_destroy(sfSoundBuffer* soundBuffer) 63 | { 64 | delete soundBuffer; 65 | } 66 | 67 | DBool sfSoundBuffer_saveToFile(const sfSoundBuffer* soundBuffer, const char* filename, size_t length) 68 | { 69 | return (soundBuffer->This.saveToFile(std::string(filename, length)))? DTrue: DFalse; 70 | } 71 | 72 | const DShort* sfSoundBuffer_getSamples(const sfSoundBuffer* soundBuffer) 73 | { 74 | return soundBuffer->This.getSamples(); 75 | } 76 | 77 | size_t sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer) 78 | { 79 | return soundBuffer->This.getSampleCount(); 80 | } 81 | 82 | DUint sfSoundBuffer_getSampleRate(const sfSoundBuffer* soundBuffer) 83 | { 84 | return soundBuffer->This.getSampleRate(); 85 | } 86 | 87 | DUint sfSoundBuffer_getChannelCount(const sfSoundBuffer* soundBuffer) 88 | { 89 | return soundBuffer->This.getChannelCount(); 90 | } 91 | 92 | DLong sfSoundBuffer_getDuration(const sfSoundBuffer* soundBuffer) 93 | { 94 | return soundBuffer->This.getDuration().asMicroseconds(); 95 | } 96 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/SoundBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | DSFML - The Simple and Fast Multimedia Library for D 3 | 4 | Copyright (c) <2018> 5 | 6 | This software is provided 'as-is', without any express or implied warranty. 7 | In no event will the authors be held liable for any damages arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, including commercial applications, 10 | and to alter it and redistribute it freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 13 | If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 14 | 15 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 16 | 17 | 3. This notice may not be removed or altered from any source distribution 18 | 19 | 20 | ***All code is based on code written by Laurent Gomila*** 21 | 22 | 23 | External Libraries Used: 24 | 25 | SFML - The Simple and Fast Multimedia Library 26 | Copyright (C) 2007-2018 Laurent Gomila (laurent.gom@gmail.com) 27 | 28 | All Libraries used by SFML - For a full list see http://www.sfml-dev.org/license.php 29 | */ 30 | 31 | #ifndef DSFML_SOUNDBUFFER_H 32 | #define DSFML_SOUNDBUFFER_H 33 | 34 | //Headers 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | DSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_construct(); 41 | 42 | DSFML_AUDIO_API DBool sfSoundBuffer_loadFromFile(sfSoundBuffer* soundBuffer, const char* filename, size_t length); 43 | 44 | DSFML_AUDIO_API DBool sfSoundBuffer_loadFromMemory(sfSoundBuffer* soundBuffer, const void* data, size_t sizeInBytes); 45 | 46 | DSFML_AUDIO_API DBool sfSoundBuffer_loadFromStream(sfSoundBuffer* soundBuffer, DStream* stream); 47 | 48 | DSFML_AUDIO_API DBool sfSoundBuffer_loadFromSamples(sfSoundBuffer* soundBuffer, const DShort* samples, size_t sampleCount, DUint channelCount, DUint sampleRate); 49 | 50 | DSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_copy(const sfSoundBuffer* soundBuffer); 51 | 52 | DSFML_AUDIO_API void sfSoundBuffer_destroy(sfSoundBuffer* soundBuffer); 53 | 54 | DSFML_AUDIO_API DBool sfSoundBuffer_saveToFile(const sfSoundBuffer* soundBuffer, const char* filename, size_t length); 55 | 56 | DSFML_AUDIO_API const DShort* sfSoundBuffer_getSamples(const sfSoundBuffer* soundBuffer); 57 | 58 | DSFML_AUDIO_API size_t sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer); 59 | 60 | DSFML_AUDIO_API DUint sfSoundBuffer_getSampleRate(const sfSoundBuffer* soundBuffer); 61 | 62 | DSFML_AUDIO_API DUint sfSoundBuffer_getChannelCount(const sfSoundBuffer* soundBuffer); 63 | 64 | DSFML_AUDIO_API DLong sfSoundBuffer_getDuration(const sfSoundBuffer* soundBuffer); 65 | 66 | #endif // DSFML_SOUNDBUFFER_H 67 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/SoundBufferStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_SOUNDBUFFERSTRUCT_H 29 | #define DSFML_SOUNDBUFFERSTRUCT_H 30 | 31 | #include 32 | 33 | struct sfSoundBuffer 34 | { 35 | sf::SoundBuffer This; 36 | }; 37 | 38 | #endif //DSFML_SOUNDSTRUCT_H 39 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/SoundRecorder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include "SoundRecorderStruct.h" 30 | 31 | sfSoundRecorder* sfSoundRecorder_construct(SoundRecorderCallBacks* newCallBacks) 32 | { 33 | return new sfSoundRecorder(newCallBacks); 34 | } 35 | 36 | void sfSoundRecorder_destroy(sfSoundRecorder* soundRecorder) 37 | { 38 | delete soundRecorder; 39 | } 40 | 41 | void sfSoundRecorder_start(sfSoundRecorder* soundRecorder, DUint sampleRate) 42 | { 43 | soundRecorder->This.start(sampleRate); 44 | } 45 | 46 | void sfSoundRecorder_stop(sfSoundRecorder* soundRecorder) 47 | { 48 | soundRecorder->This.stop(); 49 | } 50 | 51 | DUint sfSoundRecorder_getSampleRate(const sfSoundRecorder* soundRecorder) 52 | { 53 | return soundRecorder->This.getSampleRate(); 54 | } 55 | 56 | DBool sfSoundRecorder_setDevice(sfSoundRecorder* soundRecorder, const char* name, size_t length) 57 | { 58 | return soundRecorder->This.setDevice(std::string(name, length)); 59 | } 60 | 61 | const char * sfSoundRecorder_getDevice(const sfSoundRecorder* soundRecorder) 62 | { 63 | return soundRecorder->This.getDevice().c_str(); 64 | } 65 | 66 | const char ** sfSoundRecorder_getAvailableDevices (size_t* count) 67 | { 68 | static std::vector devices; 69 | 70 | // Populate the array on first call 71 | if (devices.empty()) 72 | { 73 | const std::vector& SFMLDevices = sf::SoundRecorder::getAvailableDevices(); 74 | for (std::vector::const_iterator it = SFMLDevices.begin(); it != SFMLDevices.end(); ++it) 75 | { 76 | 77 | devices.push_back(it->c_str()); 78 | } 79 | } 80 | 81 | if (count) 82 | *count = devices.size(); 83 | 84 | return !devices.empty() ? &devices[0] : NULL; 85 | } 86 | 87 | const char * sfSoundRecorder_getDefaultDevice (void) 88 | { 89 | return sf::SoundRecorder::getDefaultDevice().c_str(); 90 | } 91 | 92 | DBool sfSoundRecorder_isAvailable(void) 93 | { 94 | return sf::SoundRecorder::isAvailable() ? DTrue : DFalse; 95 | } 96 | 97 | void sfSoundRecorder_setProcessingInterval(sfSoundRecorder* soundRecorder, DUlong time) 98 | { 99 | soundRecorder->This.setProcessingIntervalD(time); 100 | } 101 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/SoundRecorder.h: -------------------------------------------------------------------------------- 1 | /* 2 | DSFML - The Simple and Fast Multimedia Library for D 3 | 4 | Copyright (c) <2018> 5 | 6 | This software is provided 'as-is', without any express or implied warranty. 7 | In no event will the authors be held liable for any damages arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, including commercial applications, 10 | and to alter it and redistribute it freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 13 | If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 14 | 15 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 16 | 17 | 3. This notice may not be removed or altered from any source distribution 18 | 19 | 20 | ***All code is based on code written by Laurent Gomila*** 21 | 22 | 23 | External Libraries Used: 24 | 25 | SFML - The Simple and Fast Multimedia Library 26 | Copyright (C) 2007-2018 Laurent Gomila (laurent.gom@gmail.com) 27 | 28 | All Libraries used by SFML - For a full list see http://www.sfml-dev.org/license.php 29 | */ 30 | 31 | #ifndef DSFML_SOUNDRECORDER_H 32 | #define DSFML_SOUNDRECORDER_H 33 | 34 | //Headers 35 | #include 36 | #include 37 | #include 38 | 39 | DSFML_AUDIO_API sfSoundRecorder* sfSoundRecorder_construct(SoundRecorderCallBacks* newCallBacks); 40 | 41 | DSFML_AUDIO_API void sfSoundRecorder_destroy(sfSoundRecorder* soundRecorder); 42 | 43 | DSFML_AUDIO_API void sfSoundRecorder_start(sfSoundRecorder* soundRecorder, DUint sampleRate); 44 | 45 | DSFML_AUDIO_API void sfSoundRecorder_stop(sfSoundRecorder* soundRecorder); 46 | 47 | DSFML_AUDIO_API DUint sfSoundRecorder_getSampleRate(const sfSoundRecorder* soundRecorder); 48 | 49 | DSFML_AUDIO_API DBool sfSoundRecorder_setDevice (sfSoundRecorder* soundRecorder, const char * name, size_t length); 50 | 51 | DSFML_AUDIO_API const char * sfSoundRecorder_getDevice(const sfSoundRecorder* soundRecorder); 52 | 53 | DSFML_AUDIO_API DBool sfSoundRecorder_isAvailable(void); 54 | 55 | DSFML_AUDIO_API const char * sfSoundRecorder_getDefaultDevice (void); 56 | 57 | DSFML_AUDIO_API const char ** sfSoundRecorder_getAvailableDevices (size_t* count); 58 | 59 | DSFML_AUDIO_API void sfSoundRecorder_setProcessingInterval(sfSoundRecorder* soundRecorder, DUlong time); 60 | 61 | #endif // DSFML_SOUNDRECORDER_H 62 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/SoundRecorderStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_SOUNDRECORDER_STRUCT_H 29 | #define DSFML_SOUNDRECORDER_STRUCT_H 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | //class to use in D 36 | class SoundRecorderCallBacks 37 | { 38 | public: 39 | virtual DBool onStart(); 40 | 41 | virtual DBool onProcessSamples(const DShort* samples, std::size_t sampleCount); 42 | 43 | virtual void onStop(); 44 | }; 45 | 46 | 47 | class SoundRecorderImp: public sf::SoundRecorder 48 | { 49 | private: 50 | SoundRecorderCallBacks* callBacks; 51 | 52 | public: 53 | SoundRecorderImp(SoundRecorderCallBacks* newCallBacks): 54 | callBacks(newCallBacks) 55 | { 56 | //callBacks = newCallBacks; 57 | } 58 | 59 | // Using a public method here to gain access to a C++ Protected method from D. Not sure if this is the best way. 60 | void setProcessingIntervalD (DUlong time) 61 | { 62 | sf::SoundRecorder::setProcessingInterval(sf::microseconds(time)); 63 | } 64 | 65 | protected: 66 | virtual bool onStart() 67 | { 68 | return (callBacks->onStart() == DTrue); 69 | } 70 | 71 | virtual bool onProcessSamples(const sf::Int16* samples, std::size_t sampleCount) 72 | { 73 | return (callBacks->onProcessSamples(samples, sampleCount) == DTrue); 74 | } 75 | 76 | virtual void onStop() 77 | { 78 | callBacks->onStop(); 79 | } 80 | 81 | }; 82 | 83 | //Wrapper around an InternalSoundRecorder 84 | struct sfSoundRecorder 85 | { 86 | sfSoundRecorder(SoundRecorderCallBacks* newCallBacks): 87 | This(newCallBacks) 88 | { 89 | 90 | } 91 | 92 | SoundRecorderImp This; 93 | }; 94 | #endif // DSFML_SOUNDRECORDER_STRUCT_H 95 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/SoundSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_SOUNDSOURCE_H 29 | #define DSFML_SOUNDSOURCE_H 30 | 31 | #include 32 | #include 33 | 34 | //Define the audio methods used within sf::SoundSource 35 | 36 | DSFML_AUDIO_API void sfSoundSource_ensureALInit(); 37 | 38 | DSFML_AUDIO_API void sfSoundSource_initialize(DUint* sourceID); 39 | 40 | DSFML_AUDIO_API void sfSoundSource_setPitch(DUint sourceID, float pitch); 41 | 42 | DSFML_AUDIO_API void sfSoundSource_setVolume(DUint sourceID, float volume); 43 | 44 | DSFML_AUDIO_API void sfSoundSource_setPosition(DUint sourceID, float x, float y, float z); 45 | 46 | DSFML_AUDIO_API void sfSoundSource_setRelativeToListener(DUint sourceID,DBool relative); 47 | 48 | DSFML_AUDIO_API void sfSoundSource_setMinDistance(DUint sourceID, float distance); 49 | 50 | DSFML_AUDIO_API void sfSoundSource_setAttenuation(DUint sourceID, float attenuation); 51 | 52 | DSFML_AUDIO_API float sfSoundSource_getPitch(DUint sourceID); 53 | 54 | DSFML_AUDIO_API float sfSoundSource_getVolume(DUint sourceID); 55 | 56 | DSFML_AUDIO_API void sfSoundSource_getPosition(DUint sourceID, float* x, float* y, float* z); 57 | 58 | DSFML_AUDIO_API DBool sfSoundSource_isRelativeToListener(DUint sourceID); 59 | 60 | DSFML_AUDIO_API float sfSoundSource_getMinDistance(DUint sourceID); 61 | 62 | DSFML_AUDIO_API float sfSoundSource_getAttenuation(DUint sourceID); 63 | 64 | DSFML_AUDIO_API DInt sfSoundSource_getStatus(DUint sourceID); 65 | 66 | DSFML_AUDIO_API void sfSoundSource_destroy(DUint* sourceID); 67 | 68 | #endif // DSFML_SOUNDSOURCE_H 69 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/SoundStreamStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_SOUNDSTREAMSTRUCT_H 29 | #define DSFML_SOUNDSTREAMSTRUCT_H 30 | 31 | #include 32 | #include 33 | 34 | struct sfChunk 35 | { 36 | const DShort* samples; 37 | DUint sampleCount; 38 | }; 39 | 40 | typedef struct sfChunk sfChunk; 41 | 42 | //class to use in D 43 | class SoundStreamCallBacks 44 | { 45 | public: 46 | virtual DBool onGetData(sfChunk* chunk); 47 | virtual void onSeek(DLong time); 48 | }; 49 | 50 | class sfSoundStreamImp : public sf::SoundStream 51 | { 52 | 53 | private: 54 | SoundStreamCallBacks* callBacks; 55 | 56 | public: 57 | 58 | sfSoundStreamImp(SoundStreamCallBacks* newCallBacks) 59 | { 60 | callBacks = newCallBacks; 61 | 62 | } 63 | 64 | void SoundStreamInitialize(DUint channelCount, DUint sampleRate) 65 | { 66 | initialize(channelCount, sampleRate); 67 | } 68 | 69 | protected: 70 | virtual bool onGetData(Chunk& data) 71 | { 72 | sfChunk chunk; 73 | DBool ret = callBacks->onGetData(&chunk); 74 | 75 | data.samples = chunk.samples; 76 | data.sampleCount = chunk.sampleCount; 77 | 78 | return (ret == DTrue); 79 | } 80 | 81 | virtual void onSeek(sf::Time timeOffset) 82 | { 83 | callBacks->onSeek(timeOffset.asMicroseconds()); 84 | } 85 | }; 86 | 87 | struct sfSoundStream 88 | { 89 | sfSoundStream(SoundStreamCallBacks* newCallBacks): 90 | This(newCallBacks) 91 | { 92 | } 93 | 94 | sfSoundStreamImp This; 95 | }; 96 | 97 | #endif // DSFML_SOUNDSTREAMSTRUCT_H 98 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/SoundStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_SOUNDSTRUCT_H 29 | #define DSFML_SOUNDSTRUCT_H 30 | 31 | #include 32 | #include "SoundBufferStruct.h" 33 | 34 | 35 | struct sfSound 36 | { 37 | sf::Sound This; 38 | const sfSoundBuffer* Buffer; 39 | }; 40 | 41 | #endif //DSFML_SOUNDSTRUCT_H 42 | -------------------------------------------------------------------------------- /src/DSFMLC/Audio/Types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_AUDIO_TYPES_H 29 | #define DSFML_AUDIO_TYPES_H 30 | 31 | typedef struct sfSoundBuffer sfSoundBuffer; 32 | typedef struct sfSound sfSound; 33 | typedef struct sfInputSoundFile sfInputSoundFile; 34 | typedef struct sfOutputSoundFile sfOutputSoundFile; 35 | typedef struct sfSoundRecorder sfSoundRecorder; 36 | typedef struct sfSoundBufferRecorder sfSoundBufferRecorder; 37 | 38 | 39 | #endif // DSFML_AUDIO_TYPES_H 40 | 41 | -------------------------------------------------------------------------------- /src/DSFMLC/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8.3) 2 | 3 | project (DSFMLC) 4 | 5 | option(STATIC_SFML "Build DSFMLC expecting static SFML libs" ON) 6 | 7 | set(CMAKE_BUILD_TYPE Release) 8 | 9 | #we want to make sure we're linking to static crt libs 10 | #Stolen from stack overflow 11 | if(MSVC) 12 | # We statically link to reduce dependencies 13 | foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) 14 | if(${flag_var} MATCHES "/MD") 15 | string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") 16 | endif(${flag_var} MATCHES "/MD") 17 | if(${flag_var} MATCHES "/MDd") 18 | string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}") 19 | endif(${flag_var} MATCHES "/MDd") 20 | endforeach(flag_var) 21 | endif(MSVC) 22 | 23 | 24 | #DSFML should work for all patch versions 25 | set(VERSION_MAJOR 2) 26 | set(VERSION_MINOR 4) 27 | 28 | 29 | #add DSFMLC and SFML header paths 30 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../SFML/include) 31 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../) 32 | 33 | 34 | add_subdirectory(System) 35 | add_subdirectory(Audio) 36 | add_subdirectory(Network) 37 | add_subdirectory(Window) 38 | add_subdirectory(Graphics) 39 | -------------------------------------------------------------------------------- /src/DSFMLC/Config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_CONFIG_H 29 | #define DSFML_CONFIG_H 30 | 31 | #include 32 | 33 | /// Define portable fixed-size types for D 34 | 35 | // 8 bits integer types 36 | typedef signed char DByte; 37 | typedef unsigned char DUbyte; 38 | 39 | // 16 bits integer types 40 | typedef signed short DShort; 41 | typedef unsigned short DUshort; 42 | 43 | // 32 bits integer types 44 | typedef signed int DInt; 45 | typedef unsigned int DUint; 46 | 47 | // 64 bits integer types 48 | #if defined(_MSC_VER) 49 | typedef signed __int64 DLong; 50 | typedef unsigned __int64 DUlong; 51 | #else 52 | typedef signed long long DLong; 53 | typedef unsigned long long DUlong; 54 | #endif 55 | 56 | // 32 Bit wide character(dchar) 57 | typedef DUint DChar; 58 | 59 | //Define a boolean that is compatible with D 60 | typedef DUbyte DBool; 61 | #define DFalse 0 62 | #define DTrue 1 63 | 64 | #endif // SFML_CONFIG_H 65 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/.gitignore: -------------------------------------------------------------------------------- 1 | #Ignore these things because they are annoying 2 | CMakeFiles/ 3 | *.cmake 4 | Makefile -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCROOT ${PROJECT_SOURCE_DIR}/Graphics) 2 | 3 | # all source files 4 | set(SRC 5 | ${SRCROOT}/Export.h 6 | ${SRCROOT}/CreateRenderStates.hpp 7 | ${SRCROOT}/Font.cpp 8 | ${SRCROOT}/FontStruct.h 9 | ${SRCROOT}/Font.h 10 | ${SRCROOT}/Image.cpp 11 | ${SRCROOT}/ImageStruct.h 12 | ${SRCROOT}/Image.h 13 | ${SRCROOT}/RenderTexture.cpp 14 | ${SRCROOT}/RenderTextureStruct.h 15 | ${SRCROOT}/RenderTexture.h 16 | ${SRCROOT}/RenderWindow.cpp 17 | ${SRCROOT}/RenderWindowStruct.h 18 | ${SRCROOT}/RenderWindow.h 19 | ${SRCROOT}/Shader.cpp 20 | ${SRCROOT}/ShaderStruct.h 21 | ${SRCROOT}/Shader.h 22 | ${SRCROOT}/Texture.cpp 23 | ${SRCROOT}/TextureStruct.h 24 | ${SRCROOT}/Texture.h 25 | ${SRCROOT}/Transform.cpp 26 | ${SRCROOT}/Transform.h 27 | ${SRCROOT}/Types.h 28 | ) 29 | 30 | source_group("" FILES ${SRC}) 31 | 32 | 33 | #build only object files that can be linked into a d static library 34 | add_library(dsfmlc-graphics OBJECT ${SRC}) 35 | 36 | #if(MSVC) 37 | #target_link_libraries(dsfmlc-graphics STATIC opengl32.lib) 38 | #endif(MSVC) 39 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/CreateRenderStates.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_CONVERTRENDERSTATES_H 29 | #define DSFML_CONVERTRENDERSTATES_H 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | 37 | // Convert sfRenderStates* to sf::RenderStates 38 | inline sf::RenderStates createRenderStates(DInt colorSrcFactor, DInt colorDstFactor, DInt colorEquation, 39 | DInt alphaSrcFactor, DInt alphaDstFactor, DInt alphaEquation, 40 | const float* transform, const sfTexture* texture, const sfShader* shader) 41 | { 42 | sf::RenderStates sfmlStates; 43 | sf::BlendMode blendMode; 44 | 45 | blendMode.colorSrcFactor = static_cast(colorSrcFactor); 46 | blendMode.colorDstFactor = static_cast(colorDstFactor); 47 | blendMode.colorEquation = static_cast(colorEquation); 48 | blendMode.alphaSrcFactor = static_cast(alphaSrcFactor); 49 | blendMode.alphaDstFactor = static_cast(alphaDstFactor); 50 | blendMode.alphaEquation = static_cast(alphaEquation); 51 | 52 | sfmlStates.blendMode = blendMode; 53 | sfmlStates.transform = *reinterpret_cast(transform); 54 | sfmlStates.texture = texture ? texture->This : NULL; 55 | sfmlStates.shader = shader ? &shader->This : NULL; 56 | 57 | return sfmlStates; 58 | } 59 | 60 | #endif // DSFML_CONVERTRENDERSTATES_H 61 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/Export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_GRAPHICS_EXPORT_H 29 | #define SFML_GRAPHICS_EXPORT_H 30 | 31 | #include 32 | 33 | #define DSFML_GRAPHICS_API extern "C" SFML_API_EXPORT 34 | 35 | #endif // SFML_GRAPHICS_EXPORT_H 36 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/Font.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_FONT_H 29 | #define SFML_FONT_H 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | //Construct a new font 37 | DSFML_GRAPHICS_API sfFont* sfFont_construct(void); 38 | 39 | //Load a new font from a file 40 | DSFML_GRAPHICS_API DBool sfFont_loadFromFile(sfFont* font, const char* filename, size_t length); 41 | 42 | //Load a new image font a file in memory 43 | DSFML_GRAPHICS_API DBool sfFont_loadFromMemory(sfFont* font, const void* data, size_t sizeInBytes); 44 | 45 | //Load a new image font a custom stream 46 | DSFML_GRAPHICS_API DBool sfFont_loadFromStream(sfFont* font, DStream* stream); 47 | 48 | // Copy an existing font 49 | DSFML_GRAPHICS_API sfFont* sfFont_copy(const sfFont* font); 50 | 51 | //Destroy an existing font 52 | DSFML_GRAPHICS_API void sfFont_destroy(sfFont* font); 53 | 54 | //Get a glyph in a font 55 | DSFML_GRAPHICS_API void sfFont_getGlyph(const sfFont* font, DUint codePoint, DInt characterSize, DBool bold, float outlineThickness, float* glyphAdvance, float* glyphBoundsLeft, float* glyphBoundsTop, float* glyphBoundsWidth, float* glyphBoundsHeight, DInt* glyphTextRectLeft, DInt* glyphTextRectTop, DInt* glyphTextRectWidth, DInt* glyphTextRectHeight); 56 | 57 | //Get the kerning value corresponding to a given pair of characters in a font 58 | DSFML_GRAPHICS_API float sfFont_getKerning(const sfFont* font, DUint first, DUint second, DUint characterSize); 59 | 60 | //Get the line spacing value 61 | DSFML_GRAPHICS_API float sfFont_getLineSpacing(const sfFont* font, DUint characterSize); 62 | 63 | //Get the position of the underline 64 | DSFML_GRAPHICS_API float sfFont_getUnderlinePosition (const sfFont * font, DUint characterSize); 65 | 66 | //Get the thickness of the underline 67 | DSFML_GRAPHICS_API float sfFont_getUnderlineThickness (const sfFont * font, DUint charactersize); 68 | 69 | //Get the font texture for a given character size 70 | DSFML_GRAPHICS_API sfTexture* sfFont_getTexture(const sfFont* font, DUint characterSize); 71 | 72 | #endif // SFML_IMAGE_H 73 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/FontStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_FONTSTRUCT_H 29 | #define DSFML_FONTSTRUCT_H 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | //Internal structure of sfFont 36 | struct sfFont 37 | { 38 | sf::Font This; 39 | sfmlStream Stream; 40 | }; 41 | 42 | #endif // DSFML_FONTSTRUCT_H 43 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/ImageStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_IMAGESTRUCT_H 29 | #define DSFML_IMAGESTRUCT_H 30 | 31 | #include 32 | 33 | //Internal structure of sfImage 34 | struct sfImage 35 | { 36 | sf::Image This; 37 | }; 38 | 39 | #endif // SFML_IMAGESTRUCT_H 40 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/RenderTextureStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_RENDERTEXTURESTRUCT_H 29 | #define SFML_RENDERTEXTURESTRUCT_H 30 | 31 | #include 32 | #include 33 | 34 | //Internal structure of sfRenderTexture 35 | struct sfRenderTexture 36 | { 37 | sf::RenderTexture This; 38 | const sfTexture* Target; 39 | }; 40 | 41 | #endif // SFML_RENDERTEXTURESTRUCT_H 42 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/RenderWindowStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_RENDERWINDOWSTRUCT_H 29 | #define SFML_RENDERWINDOWSTRUCT_H 30 | 31 | #include 32 | 33 | //Internal structure of sfRenderWindow 34 | struct sfRenderWindow 35 | { 36 | sf::RenderWindow This; 37 | }; 38 | 39 | #endif // SFML_RENDERWINDOWSTRUCT_H 40 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/ShaderStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_SHADERSTRUCT_H 29 | #define DSFML_SHADERSTRUCT_H 30 | 31 | #include 32 | 33 | //Internal structure of sfShader 34 | struct sfShader 35 | { 36 | sf::Shader This; 37 | }; 38 | 39 | #endif // SFML_SHADERSTRUCT_H 40 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/TextureStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_TEXTURESTRUCT_H 29 | #define SFML_TEXTURESTRUCT_H 30 | 31 | #include 32 | 33 | //Internal structure of sfTexture 34 | struct sfTexture 35 | { 36 | sfTexture() 37 | { 38 | This = new sf::Texture; 39 | OwnInstance = true; 40 | } 41 | 42 | sfTexture(sf::Texture* texture) 43 | { 44 | This = texture; 45 | OwnInstance = false; 46 | } 47 | 48 | sfTexture(const sfTexture& texture) 49 | { 50 | This = texture.This ? new sf::Texture(*texture.This) : NULL; 51 | OwnInstance = true; 52 | } 53 | 54 | ~sfTexture() 55 | { 56 | if (OwnInstance) 57 | delete This; 58 | } 59 | 60 | sf::Texture* This; 61 | bool OwnInstance; 62 | }; 63 | 64 | #endif // SFML_TEXTURESTRUCT_H 65 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/Transform.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | void sfTransform_getInverse(const float* transform, float* inverse) 33 | { 34 | *reinterpret_cast(inverse) = 35 | reinterpret_cast(transform)->getInverse(); 36 | } 37 | 38 | void sfTransform_transformPoint(const float* transform, float xIn, float yIn, float* xOut, float* yOut) 39 | { 40 | sf::Vector2f sfmlPoint = 41 | (reinterpret_cast(transform))->transformPoint(xIn, yIn); 42 | 43 | *xOut = sfmlPoint.x; 44 | *yOut = sfmlPoint.y; 45 | } 46 | 47 | void sfTransform_transformRect(const float* transform, float leftIn, float topIn, float widthIn, float heightIn, float* leftOut, float* topOut, float* widthOut, float* heightOut) 48 | { 49 | sf::FloatRect sfmlRect = 50 | reinterpret_cast(transform)->transformRect(sf::FloatRect(leftIn, topIn, widthIn, heightIn)); 51 | 52 | *leftOut = sfmlRect.left; 53 | *topOut = sfmlRect.top; 54 | *widthOut = sfmlRect.width; 55 | *heightOut = sfmlRect.height; 56 | } 57 | 58 | void sfTransform_combine(float* transform, const float* other) 59 | { 60 | reinterpret_cast(transform)->combine(*reinterpret_cast(other)); 61 | } 62 | 63 | void sfTransform_translate(float* transform, float x, float y) 64 | { 65 | reinterpret_cast(transform)->translate(x, y); 66 | } 67 | 68 | void sfTransform_rotate(float* transform, float angle) 69 | { 70 | reinterpret_cast(transform)->rotate(angle); 71 | } 72 | 73 | void sfTransform_rotateWithCenter(float* transform, float angle, float centerX, float centerY) 74 | { 75 | reinterpret_cast(transform)->rotate(angle, centerX, centerY); 76 | } 77 | 78 | void sfTransform_scale(float* transform, float scaleX, float scaleY) 79 | { 80 | reinterpret_cast(transform)->scale(scaleX, scaleY); 81 | } 82 | 83 | void sfTransform_scaleWithCenter(float* transform, float scaleX, float scaleY, float centerX, float centerY) 84 | { 85 | reinterpret_cast(transform)->scale(scaleX, scaleY, centerX, centerY); 86 | } 87 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/Transform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_TRANSFORM_H 29 | #define DSFML_TRANSFORM_H 30 | 31 | #include 32 | #include 33 | 34 | //Return the inverse of a transform 35 | DSFML_GRAPHICS_API void sfTransform_getInverse(const float* transform, float* inverse); 36 | 37 | //Apply a transform to a 2D point 38 | DSFML_GRAPHICS_API void sfTransform_transformPoint(const float* transform, float xIn, float yIn, float* xOut, float* yOut); 39 | 40 | //Apply a transform to a rectangle 41 | DSFML_GRAPHICS_API void sfTransform_transformRect(const float* transform, float leftIn, float topIn, float widthIn, float heightIn, float* leftOut, float* topOut, float* widthOut, float* heightOut); 42 | 43 | //Combine two transforms 44 | DSFML_GRAPHICS_API void sfTransform_combine(float* transform, const float* other); 45 | 46 | //Combine a transform with a translation 47 | DSFML_GRAPHICS_API void sfTransform_translate(float* transform, float x, float y); 48 | 49 | //Combine the current transform with a rotation 50 | DSFML_GRAPHICS_API void sfTransform_rotate(float* transform, float angle); 51 | 52 | //Combine the current transform with a rotation 53 | DSFML_GRAPHICS_API void sfTransform_rotateWithCenter(float* transform, float angle, float centerX, float centerY); 54 | 55 | //Combine the current transform with a scaling 56 | DSFML_GRAPHICS_API void sfTransform_scale(float* transform, float scaleX, float scaleY); 57 | 58 | //Combine the current transform with a scaling 59 | DSFML_GRAPHICS_API void sfTransform_scaleWithCenter(float* transform, float scaleX, float scaleY, float centerX, float centerY); 60 | 61 | 62 | #endif // SFML_TRANSFORM_H 63 | -------------------------------------------------------------------------------- /src/DSFMLC/Graphics/Types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_GRAPHICS_TYPES_H 29 | #define DSFML_GRAPHICS_TYPES_H 30 | 31 | typedef struct sfFont sfFont; 32 | typedef struct sfImage sfImage; 33 | typedef struct sfShader sfShader; 34 | typedef struct sfRenderTexture sfRenderTexture; 35 | typedef struct sfRenderWindow sfRenderWindow; 36 | typedef struct sfSprite sfSprite; 37 | typedef struct sfText sfText; 38 | typedef struct sfTexture sfTexture; 39 | 40 | #endif // SFML_GRAPHICS_TYPES_H 41 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/.gitignore: -------------------------------------------------------------------------------- 1 | #Ignore these things because they are annoying 2 | CMakeFiles/ 3 | *.cmake 4 | Makefile -------------------------------------------------------------------------------- /src/DSFMLC/Network/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCROOT ${PROJECT_SOURCE_DIR}/Network) 2 | 3 | # all source files 4 | set(SRC 5 | ${SRCROOT}/Export.h 6 | ${SRCROOT}/Ftp.cpp 7 | ${SRCROOT}/FtpStruct.h 8 | ${SRCROOT}/Ftp.h 9 | ${SRCROOT}/Http.cpp 10 | ${SRCROOT}/HttpStruct.h 11 | ${SRCROOT}/Http.h 12 | ${SRCROOT}/IpAddress.cpp 13 | ${SRCROOT}/IpAddress.h 14 | ${SRCROOT}/Packet.cpp 15 | ${SRCROOT}/PacketStruct.h 16 | ${SRCROOT}/Packet.h 17 | ${SRCROOT}/SocketSelector.cpp 18 | ${SRCROOT}/SocketSelectorStruct.h 19 | ${SRCROOT}/SocketSelector.h 20 | ${SRCROOT}/TcpListener.cpp 21 | ${SRCROOT}/TcpListenerStruct.h 22 | ${SRCROOT}/TcpListener.h 23 | ${SRCROOT}/TcpSocket.cpp 24 | ${SRCROOT}/TcpSocketStruct.h 25 | ${SRCROOT}/TcpSocket.h 26 | ${SRCROOT}/Types.h 27 | ${SRCROOT}/UdpSocket.cpp 28 | ${SRCROOT}/UdpSocketStruct.h 29 | ${SRCROOT}/UdpSocket.h 30 | ) 31 | 32 | source_group("" FILES ${SRC}) 33 | 34 | #build only object files that can be linked into a d static library 35 | add_library(dsfmlc-network OBJECT ${SRC}) 36 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/Export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DFML_NETWORK_EXPORT_H 29 | #define DFML_NETWORK_EXPORT_H 30 | 31 | #include 32 | 33 | #define DSFML_NETWORK_API extern "C" SFML_API_EXPORT 34 | 35 | #endif // DFML_NETWORK_EXPORT_H 36 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/FtpStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_FTPSTRUCT_H 29 | #define DSFML_FTPSTRUCT_H 30 | 31 | #include 32 | #include 33 | 34 | //Internal structure of sfFtp 35 | struct sfFtp 36 | { 37 | sf::Ftp This; 38 | }; 39 | 40 | //Internal structure of sfFtpResponse 41 | struct sfFtpResponse 42 | { 43 | sfFtpResponse(const sf::Ftp::Response& Response) 44 | : This(Response) 45 | { 46 | } 47 | 48 | sf::Ftp::Response This; 49 | }; 50 | 51 | //Internal structure of sfFtpDirectoryResponse 52 | struct sfFtpDirectoryResponse 53 | { 54 | sfFtpDirectoryResponse(const sf::Ftp::DirectoryResponse& Response) 55 | : This(Response) 56 | { 57 | } 58 | 59 | sf::Ftp::DirectoryResponse This; 60 | }; 61 | 62 | //Internal structure of sfFtpListingResponse 63 | struct sfFtpListingResponse 64 | { 65 | sfFtpListingResponse(const sf::Ftp::ListingResponse& Response) 66 | : This(Response) 67 | { 68 | } 69 | 70 | ~sfFtpListingResponse() 71 | { 72 | for (std::vector::iterator it = Filenames.begin(); it != Filenames.end(); ++it) 73 | delete[] *it; 74 | } 75 | 76 | sf::Ftp::ListingResponse This; 77 | std::vector Filenames; 78 | }; 79 | 80 | #endif // DSFML_FTPSTRUCT_H 81 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/HttpStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_HTTPSTRUCT_H 29 | #define SFML_HTTPSTRUCT_H 30 | 31 | #include 32 | 33 | //Internal structure of sfHttp 34 | struct sfHttp 35 | { 36 | sf::Http This; 37 | }; 38 | 39 | //Internal structure of sfHttpRequest 40 | struct sfHttpRequest 41 | { 42 | sf::Http::Request This; 43 | }; 44 | 45 | //Internal structure of sfHttpResponse 46 | struct sfHttpResponse 47 | { 48 | sf::Http::Response This; 49 | }; 50 | 51 | #endif // SFML_HTTPSTRUCT_H 52 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/IpAddress.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | // Headers 29 | #include 30 | #include 31 | 32 | DUint sfIpAddress_integerFromString(const char* address, size_t addressLength) 33 | { 34 | return sf::IpAddress(std::string(address, addressLength)).toInteger(); 35 | } 36 | 37 | void sfIpAddress_getLocalAddress(sf::IpAddress* ipAddress) 38 | { 39 | *ipAddress = sf::IpAddress::getLocalAddress(); 40 | } 41 | 42 | void sfIpAddress_getPublicAddress(sf::IpAddress* ipAddress, DLong timeout) 43 | { 44 | *ipAddress = sf::IpAddress::getPublicAddress(sf::microseconds(timeout)); 45 | } 46 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/IpAddress.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_IPADDRESS_H 29 | #define DSFML_IPADDRESS_H 30 | 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | 37 | //Get the host integer representation from a string 38 | DSFML_NETWORK_API DUint sfIpAddress_integerFromString(const char* address, size_t addressLength); 39 | 40 | //Get the computer's local address 41 | DSFML_NETWORK_API void sfIpAddress_getLocalAddress(sf::IpAddress* ipAddress); 42 | 43 | //Get the computer's public address 44 | DSFML_NETWORK_API void sfIpAddress_getPublicAddress(sf::IpAddress* ipAddress, DLong timeout); 45 | 46 | #endif // DSFML_IPADDRESS_H 47 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/PacketStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_PACKETSTRUCT_H 29 | #define DSFML_PACKETSTRUCT_H 30 | 31 | #include 32 | 33 | //Internal structure of sfPacket 34 | struct sfPacket 35 | { 36 | sf::Packet This; 37 | }; 38 | 39 | #endif // DSFML_PACKETSTRUCT_H 40 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/SocketSelector.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | sfSocketSelector* sfSocketSelector_create(void) 35 | { 36 | return new sfSocketSelector; 37 | } 38 | 39 | sfSocketSelector* sfSocketSelector_copy(const sfSocketSelector* selector) 40 | { 41 | return new sfSocketSelector(*selector); 42 | } 43 | 44 | void sfSocketSelector_destroy(sfSocketSelector* selector) 45 | { 46 | delete selector; 47 | } 48 | 49 | void sfSocketSelector_addTcpListener(sfSocketSelector* selector, sfTcpListener* socket) 50 | { 51 | selector->This.add(socket->This); 52 | } 53 | 54 | void sfSocketSelector_addTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket) 55 | { 56 | selector->This.add(socket->This); 57 | } 58 | 59 | void sfSocketSelector_addUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket) 60 | { 61 | selector->This.add(socket->This); 62 | } 63 | 64 | void sfSocketSelector_removeTcpListener(sfSocketSelector* selector, sfTcpListener* socket) 65 | { 66 | selector->This.remove(socket->This); 67 | } 68 | 69 | void sfSocketSelector_removeTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket) 70 | { 71 | selector->This.remove(socket->This); 72 | } 73 | 74 | void sfSocketSelector_removeUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket) 75 | { 76 | selector->This.remove(socket->This); 77 | } 78 | 79 | void sfSocketSelector_clear(sfSocketSelector* selector) 80 | { 81 | selector->This.clear(); 82 | } 83 | 84 | DBool sfSocketSelector_wait(sfSocketSelector* selector, DLong timeout) 85 | { 86 | return selector->This.wait(sf::microseconds(timeout))?DTrue: DFalse; 87 | } 88 | 89 | DBool sfSocketSelector_isTcpListenerReady(const sfSocketSelector* selector, sfTcpListener* socket) 90 | { 91 | return selector->This.isReady(socket->This)?DTrue: DFalse; 92 | } 93 | 94 | DBool sfSocketSelector_isTcpSocketReady(const sfSocketSelector* selector, sfTcpSocket* socket) 95 | { 96 | return selector->This.isReady(socket->This)?DTrue: DFalse; 97 | } 98 | 99 | DBool sfSocketSelector_isUdpSocketReady(const sfSocketSelector* selector, sfUdpSocket* socket) 100 | { 101 | return selector->This.isReady(socket->This)?DTrue: DFalse; 102 | } 103 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/SocketSelector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_SOCKETSELECTOR_H 29 | #define DSFML_SOCKETSELECTOR_H 30 | 31 | #include 32 | #include 33 | 34 | //Create a new selector 35 | DSFML_NETWORK_API sfSocketSelector* sfSocketSelector_create(void); 36 | 37 | //Create a new socket selector by copying an existing one 38 | DSFML_NETWORK_API sfSocketSelector* sfSocketSelector_copy(const sfSocketSelector* selector); 39 | 40 | //Destroy a socket selector 41 | DSFML_NETWORK_API void sfSocketSelector_destroy(sfSocketSelector* selector); 42 | 43 | //Add a new socket to a socket selector 44 | DSFML_NETWORK_API void sfSocketSelector_addTcpListener(sfSocketSelector* selector, sfTcpListener* socket); 45 | DSFML_NETWORK_API void sfSocketSelector_addTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket); 46 | DSFML_NETWORK_API void sfSocketSelector_addUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket); 47 | 48 | //Remove a socket from a socket selector 49 | DSFML_NETWORK_API void sfSocketSelector_removeTcpListener(sfSocketSelector* selector, sfTcpListener* socket); 50 | DSFML_NETWORK_API void sfSocketSelector_removeTcpSocket(sfSocketSelector* selector, sfTcpSocket* socket); 51 | DSFML_NETWORK_API void sfSocketSelector_removeUdpSocket(sfSocketSelector* selector, sfUdpSocket* socket); 52 | 53 | //Remove all the sockets stored in a selector 54 | DSFML_NETWORK_API void sfSocketSelector_clear(sfSocketSelector* selector); 55 | 56 | //Wait until one or more sockets are ready to receive 57 | DSFML_NETWORK_API DBool sfSocketSelector_wait(sfSocketSelector* selector, DLong timeout); 58 | 59 | //Test a socket to know if it is ready to receive data 60 | DSFML_NETWORK_API DBool sfSocketSelector_isTcpListenerReady(const sfSocketSelector* selector, sfTcpListener* socket); 61 | DSFML_NETWORK_API DBool sfSocketSelector_isTcpSocketReady(const sfSocketSelector* selector, sfTcpSocket* socket); 62 | DSFML_NETWORK_API DBool sfSocketSelector_isUdpSocketReady(const sfSocketSelector* selector, sfUdpSocket* socket); 63 | 64 | #endif // DSFML_SOCKETSELECTOR_H 65 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/SocketSelectorStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_SOCKETSELECTORSTRUCT_H 29 | #define SFML_SOCKETSELECTORSTRUCT_H 30 | 31 | #include 32 | 33 | //Internal structure of sfSocketSelector 34 | struct sfSocketSelector 35 | { 36 | sf::SocketSelector This; 37 | }; 38 | 39 | #endif // SFML_SOCKETSELECTORSTRUCT_H 40 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/TcpListener.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | sfTcpListener* sfTcpListener_create(void) 33 | { 34 | return new sfTcpListener; 35 | } 36 | 37 | void sfTcpListener_destroy(sfTcpListener* listener) 38 | { 39 | delete listener; 40 | } 41 | 42 | void sfTcpListener_setBlocking(sfTcpListener* listener, DBool blocking) 43 | { 44 | listener->This.setBlocking(blocking == DTrue); 45 | } 46 | 47 | DBool sfTcpListener_isBlocking(const sfTcpListener* listener) 48 | { 49 | return listener->This.isBlocking()?DTrue: DFalse; 50 | } 51 | 52 | DUshort sfTcpListener_getLocalPort(const sfTcpListener* listener) 53 | { 54 | return listener->This.getLocalPort(); 55 | } 56 | 57 | DInt sfTcpListener_listen(sfTcpListener* listener,DUshort port, const sf::IpAddress* address) 58 | { 59 | return listener->This.listen(port, *address); 60 | } 61 | 62 | DInt sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket* connected) 63 | { 64 | sf::Socket::Status status = listener->This.accept(connected->This); 65 | 66 | return status; 67 | } 68 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/TcpListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_TCPLISTENER_H 29 | #define DSFML_TCPLISTENER_H 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | //Create a new TCP listener 36 | DSFML_NETWORK_API sfTcpListener* sfTcpListener_create(void); 37 | 38 | //Destroy a TCP listener 39 | DSFML_NETWORK_API void sfTcpListener_destroy(sfTcpListener* listener); 40 | 41 | //Set the blocking state of a TCP listener 42 | DSFML_NETWORK_API void sfTcpListener_setBlocking(sfTcpListener* listener, DBool blocking); 43 | 44 | //Tell whether a TCP listener is in blocking or non-blocking mode 45 | DSFML_NETWORK_API DBool sfTcpListener_isBlocking(const sfTcpListener* listener); 46 | 47 | //Get the port to which a TCP listener is bound locally 48 | DSFML_NETWORK_API DUshort sfTcpListener_getLocalPort(const sfTcpListener* listener); 49 | 50 | //Start listening for connections 51 | DSFML_NETWORK_API DInt sfTcpListener_listen(sfTcpListener* listener, DUshort port, const sf::IpAddress* address); 52 | 53 | //Accept a new connection 54 | DSFML_NETWORK_API DInt sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket* connected); 55 | 56 | #endif // DSFML_TCPLISTENER_H 57 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/TcpListenerStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_TCPLISTENERSTRUCT_H 29 | #define SFML_TCPLISTENERSTRUCT_H 30 | 31 | #include 32 | 33 | //Internal structure of sfTcpListener 34 | struct sfTcpListener 35 | { 36 | sf::TcpListener This; 37 | }; 38 | 39 | #endif // SFML_TCPLISTENERSTRUCT_H 40 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/TcpSocket.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | sfTcpSocket* sfTcpSocket_create(void) 35 | { 36 | return new sfTcpSocket; 37 | } 38 | 39 | void sfTcpSocket_destroy(sfTcpSocket* socket) 40 | { 41 | delete socket; 42 | } 43 | 44 | void sfTcpSocket_setBlocking(sfTcpSocket* socket, DBool blocking) 45 | { 46 | socket->This.setBlocking(blocking == DTrue); 47 | } 48 | 49 | DBool sfTcpSocket_isBlocking(const sfTcpSocket* socket) 50 | { 51 | return socket->This.isBlocking()?DTrue: DFalse; 52 | } 53 | 54 | DUshort sfTcpSocket_getLocalPort(const sfTcpSocket* socket) 55 | { 56 | return socket->This.getLocalPort(); 57 | } 58 | 59 | void sfTcpSocket_getRemoteAddress(const sfTcpSocket* socket, sf::IpAddress* ipAddress) 60 | { 61 | *ipAddress = socket->This.getRemoteAddress(); 62 | } 63 | 64 | DUshort sfTcpSocket_getRemotePort(const sfTcpSocket* socket) 65 | { 66 | return socket->This.getRemotePort(); 67 | } 68 | 69 | DInt sfTcpSocket_connect(sfTcpSocket* socket, const sf::IpAddress* ipAddress, DUshort port, DLong timeout) 70 | { 71 | return socket->This.connect(*ipAddress, port, sf::microseconds(timeout)); 72 | } 73 | 74 | void sfTcpSocket_disconnect(sfTcpSocket* socket) 75 | { 76 | socket->This.disconnect(); 77 | } 78 | 79 | DInt sfTcpSocket_send(sfTcpSocket* socket, const void* data, size_t size) 80 | { 81 | 82 | return socket->This.send(data, size); 83 | } 84 | 85 | DInt sfTcpSocket_receive(sfTcpSocket* socket, void* data, size_t maxSize, size_t* sizeReceived) 86 | { 87 | return socket->This.receive(data, maxSize, *sizeReceived); 88 | } 89 | 90 | DInt sfTcpSocket_sendPacket(sfTcpSocket* socket, sfPacket* packet) 91 | { 92 | return socket->This.send(packet->This); 93 | } 94 | 95 | DInt sfTcpSocket_receivePacket(sfTcpSocket* socket, sfPacket* packet) 96 | { 97 | return socket->This.receive(packet->This); 98 | } 99 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/TcpSocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_TCPSOCKET_H 29 | #define DSFML_TCPSOCKET_H 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | //Destroy internal stored data for receiving 37 | DSFML_NETWORK_API void sfTcpSocket_destroyInternalData(void); 38 | 39 | //Create a new TCP socket 40 | DSFML_NETWORK_API sfTcpSocket* sfTcpSocket_create(void); 41 | 42 | //Destroy a TCP socket 43 | DSFML_NETWORK_API void sfTcpSocket_destroy(sfTcpSocket* socket); 44 | 45 | //Set the blocking state of a TCP listener 46 | DSFML_NETWORK_API void sfTcpSocket_setBlocking(sfTcpSocket* socket, DBool blocking); 47 | 48 | //Tell whether a TCP socket is in blocking or non-blocking mode 49 | DSFML_NETWORK_API DBool sfTcpSocket_isBlocking(const sfTcpSocket* socket); 50 | 51 | //Get the port to which a TCP socket is bound locally 52 | DSFML_NETWORK_API DUshort sfTcpSocket_getLocalPort(const sfTcpSocket* socket); 53 | 54 | //Get the address of the connected peer of a TCP socket 55 | DSFML_NETWORK_API void sfTcpSocket_getRemoteAddress(const sfTcpSocket* socket, sf::IpAddress* ipAddress); 56 | 57 | //Get the port of the connected peer to which a TCP socket is connected 58 | DSFML_NETWORK_API DUshort sfTcpSocket_getRemotePort(const sfTcpSocket* socket); 59 | 60 | //Connect a TCP socket to a remote peer 61 | DSFML_NETWORK_API DInt sfTcpSocket_connect(sfTcpSocket* socket, const sf::IpAddress* ipAddress, DUshort port, DLong timeout); 62 | 63 | //Disconnect a TCP socket from its remote peer 64 | DSFML_NETWORK_API void sfTcpSocket_disconnect(sfTcpSocket* socket); 65 | 66 | //Send raw data to the remote peer of a TCP socket 67 | DSFML_NETWORK_API DInt sfTcpSocket_send(sfTcpSocket* socket, const void* data, size_t size); 68 | 69 | //Receive raw data from the remote peer of a TCP socket 70 | DSFML_NETWORK_API DInt sfTcpSocket_receive(sfTcpSocket* socket, void* data, size_t maxSize, size_t* sizeReceived); 71 | 72 | //Send a formatted packet of data to the remote peer of a TCP socket 73 | DSFML_NETWORK_API DInt sfTcpSocket_sendPacket(sfTcpSocket* socket, sfPacket* packet); 74 | 75 | //Receive a formatted packet of data from the remote peer 76 | DSFML_NETWORK_API DInt sfTcpSocket_receivePacket(sfTcpSocket* socket, sfPacket* packet); 77 | 78 | #endif // DSFML_TCPSOCKET_H 79 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/TcpSocketStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_TCPSOCKETSTRUCT_H 29 | #define SFML_TCPSOCKETSTRUCT_H 30 | 31 | #include 32 | 33 | //Internal structure of sfTcpSocket 34 | struct sfTcpSocket 35 | { 36 | sf::TcpSocket This; 37 | }; 38 | 39 | #endif // SFML_TCPSOCKETSTRUCT_H 40 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/Types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_NETWORK_TYPES_H 29 | #define SFML_NETWORK_TYPES_H 30 | 31 | typedef struct sfFtpDirectoryResponse sfFtpDirectoryResponse; 32 | typedef struct sfFtpListingResponse sfFtpListingResponse; 33 | typedef struct sfFtpResponse sfFtpResponse; 34 | typedef struct sfFtp sfFtp; 35 | typedef struct sfHttpRequest sfHttpRequest; 36 | typedef struct sfHttpResponse sfHttpResponse; 37 | typedef struct sfHttp sfHttp; 38 | typedef struct sfPacket sfPacket; 39 | typedef struct sfSocketSelector sfSocketSelector; 40 | typedef struct sfTcpListener sfTcpListener; 41 | typedef struct sfTcpSocket sfTcpSocket; 42 | typedef struct sfUdpSocket sfUdpSocket; 43 | 44 | 45 | #endif // SFML_NETWORK_TYPES_H 46 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/UdpSocket.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | sfUdpSocket* sfUdpSocket_create(void) 35 | { 36 | return new sfUdpSocket; 37 | } 38 | 39 | void sfUdpSocket_destroy(sfUdpSocket* socket) 40 | { 41 | delete socket; 42 | } 43 | 44 | void sfUdpSocket_setBlocking(sfUdpSocket* socket, DBool blocking) 45 | { 46 | socket->This.setBlocking(blocking == DTrue); 47 | } 48 | 49 | DBool sfUdpSocket_isBlocking(const sfUdpSocket* socket) 50 | { 51 | return socket->This.isBlocking()?DTrue: DFalse; 52 | } 53 | 54 | DUshort sfUdpSocket_getLocalPort(const sfUdpSocket* socket) 55 | { 56 | return socket->This.getLocalPort(); 57 | } 58 | 59 | DInt sfUdpSocket_bind(sfUdpSocket* socket, DUshort port, sf::IpAddress* ipAddress) 60 | { 61 | return static_cast(socket->This.bind(port, *ipAddress)); 62 | } 63 | 64 | void sfUdpSocket_unbind(sfUdpSocket* socket) 65 | { 66 | socket->This.unbind(); 67 | } 68 | 69 | DInt sfUdpSocket_send(sfUdpSocket* socket, const void* data, size_t size, sf::IpAddress* receiver, DUshort port) 70 | { 71 | return static_cast(socket->This.send(data, size, *receiver, port)); 72 | } 73 | 74 | DInt sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t maxSize, size_t* sizeReceived, sf::IpAddress* sender, DUshort* port) 75 | { 76 | return static_cast(socket->This.receive(data, maxSize, *sizeReceived, 77 | *sender, *port)); 78 | } 79 | 80 | DInt sfUdpSocket_sendPacket(sfUdpSocket* socket, sfPacket* packet, sf::IpAddress* receiver, DUshort port) 81 | { 82 | return static_cast(socket->This.send(packet->This, *receiver, port)); 83 | } 84 | 85 | DInt sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet, sf::IpAddress* sender, DUshort* port) 86 | { 87 | DInt status = static_cast(socket->This.receive(packet->This, *sender, *port)); 88 | 89 | return status; 90 | } 91 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/UdpSocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_UDPSOCKET_H 29 | #define DSFML_UDPSOCKET_H 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | //Destroy internal stored data for receiving 37 | DSFML_NETWORK_API void sfUdpSocket_destroyInternalData(void); 38 | 39 | //Create a new UDP socket 40 | DSFML_NETWORK_API sfUdpSocket* sfUdpSocket_create(void); 41 | 42 | //Destroy a UDP socket 43 | DSFML_NETWORK_API void sfUdpSocket_destroy(sfUdpSocket* socket); 44 | 45 | //Set the blocking state of a UDP listener 46 | DSFML_NETWORK_API void sfUdpSocket_setBlocking(sfUdpSocket* socket, DBool blocking); 47 | 48 | //Tell whether a UDP socket is in blocking or non-blocking mode 49 | DSFML_NETWORK_API DBool sfUdpSocket_isBlocking(const sfUdpSocket* socket); 50 | 51 | //Get the port to which a UDP socket is bound locally 52 | DSFML_NETWORK_API DUshort sfUdpSocket_getLocalPort(const sfUdpSocket* socket); 53 | 54 | //Bind a UDP socket to a specific port 55 | DSFML_NETWORK_API DInt sfUdpSocket_bind(sfUdpSocket* socket, DUshort port, sf::IpAddress* ipAddress); 56 | 57 | //Unbind a UDP socket from the local port to which it is bound 58 | DSFML_NETWORK_API void sfUdpSocket_unbind(sfUdpSocket* socket); 59 | 60 | //Send raw data to a remote peer with a UDP socket 61 | DSFML_NETWORK_API DInt sfUdpSocket_send(sfUdpSocket* socket, const void* data, size_t size, sf::IpAddress* receiver, DUshort port); 62 | 63 | //Receive raw data from a remote peer with a UDP socket 64 | DSFML_NETWORK_API DInt sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t maxSize, size_t* sizeReceived, sf::IpAddress* sender, DUshort* port); 65 | 66 | //Send a formatted packet of data to a remote peer with a UDP socket 67 | DSFML_NETWORK_API DInt sfUdpSocket_sendPacket(sfUdpSocket* socket, sfPacket* packet, sf::IpAddress* receiver, DUshort port); 68 | 69 | //Receive a formatted packet of data from a remote peer with a UDP socket 70 | DSFML_NETWORK_API DInt sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet, sf::IpAddress* sender, DUshort* port); 71 | 72 | #endif // SFML_UDPSOCKET_H 73 | -------------------------------------------------------------------------------- /src/DSFMLC/Network/UdpSocketStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_UDPSOCKETSTRUCT_H 29 | #define SFML_UDPSOCKETSTRUCT_H 30 | 31 | #include 32 | 33 | //Internal structure of sfUdpSocket 34 | struct sfUdpSocket 35 | { 36 | sf::UdpSocket This; 37 | }; 38 | 39 | #endif // SFML_UDPSOCKETSTRUCT_H 40 | -------------------------------------------------------------------------------- /src/DSFMLC/System/.gitignore: -------------------------------------------------------------------------------- 1 | #Ignore these things because they are annoying 2 | CMakeFiles/ 3 | *.cmake 4 | Makefile -------------------------------------------------------------------------------- /src/DSFMLC/System/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCROOT ${PROJECT_SOURCE_DIR}/System) 2 | 3 | set(SRC 4 | ${SRCROOT}/DStream.hpp 5 | ${SRCROOT}/Err.cpp 6 | ${SRCROOT}/Err.h 7 | ${SRCROOT}/ErrStream.cpp 8 | ${SRCROOT}/ErrStream.hpp 9 | ${SRCROOT}/String.cpp 10 | ${SRCROOT}/String.h 11 | ${SRCROOT}/Export.h 12 | ) 13 | 14 | #build only object files that can be linked into a d static library 15 | add_library(dsfmlc-system OBJECT ${SRC}) 16 | -------------------------------------------------------------------------------- /src/DSFMLC/System/DStream.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | 29 | #ifndef DSFML_DSTREAM_H 30 | #define DSFML_DSTREAM_H 31 | 32 | #include 33 | #include 34 | 35 | //Define an interface usable with D's C++ interop 36 | class DStream 37 | { 38 | public: 39 | virtual DLong read(void* data, DLong size); 40 | 41 | virtual DLong seek(DLong position); 42 | 43 | virtual DLong tell(); 44 | 45 | virtual DLong getSize(); 46 | 47 | }; 48 | 49 | //Define a class based off sf::InputStream that encoumpasses a DStream 50 | class sfmlStream:public sf::InputStream 51 | { 52 | 53 | private: 54 | DStream* myStream; 55 | 56 | public: 57 | 58 | sfmlStream() 59 | { 60 | 61 | } 62 | 63 | sfmlStream(DStream* stream) 64 | { 65 | myStream = stream; 66 | } 67 | 68 | virtual sf::Int64 read(void* data, sf::Int64 size) 69 | { 70 | return myStream->read(data, size); 71 | } 72 | 73 | virtual sf::Int64 seek(sf::Int64 position) 74 | { 75 | return myStream->seek(position); 76 | } 77 | 78 | virtual sf::Int64 tell() 79 | { 80 | return myStream->tell(); 81 | } 82 | 83 | virtual sf::Int64 getSize() 84 | { 85 | return myStream->getSize(); 86 | } 87 | 88 | }; 89 | 90 | #endif // DSFML_DSTREAM_H 91 | -------------------------------------------------------------------------------- /src/DSFMLC/System/Err.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | namespace 33 | { 34 | //Custom stream buffer that write's to our D-side err File. 35 | ErrStream errStream; 36 | } 37 | 38 | void sfErr_redirect(void (*writeFunc)(const char* str, int size)) 39 | { 40 | errStream.setWriteFunc(writeFunc); 41 | sf::err().rdbuf(&errStream); 42 | } 43 | -------------------------------------------------------------------------------- /src/DSFMLC/System/Err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_ERR_H 29 | #define DSFML_ERR_H 30 | 31 | #include 32 | 33 | //Redirect sf::err() to our custom stream buffer 34 | //This takes a function poiter to the write function because mscv complains about missing symbols 35 | DSFML_SYSTEM_API void sfErr_redirect(void (*writeFunc)(const char* str, int size)); 36 | 37 | #endif // DSFML_ERR_H 38 | -------------------------------------------------------------------------------- /src/DSFMLC/System/ErrStream.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | ErrStream::ErrStream() 4 | { 5 | //set the size to be BUFFER_SIZE-1 to more easily handle overflow character 6 | setp(m_buffer, m_buffer+BUFFER_SIZE-1); 7 | } 8 | 9 | void ErrStream::setWriteFunc(void (*writeFunc)(const char* str, int size)) 10 | { 11 | m_writeFunc = writeFunc; 12 | } 13 | 14 | ErrStream::int_type ErrStream::overflow(int_type ch) 15 | { 16 | *pptr() = ch; 17 | pbump(1); 18 | write(); 19 | return ch; 20 | } 21 | 22 | int ErrStream::sync() 23 | { 24 | write(); 25 | return 0; 26 | } 27 | 28 | void ErrStream:: write() 29 | { 30 | std::ptrdiff_t size = pptr() - pbase(); 31 | pbump(-size); 32 | m_writeFunc(m_buffer, size); 33 | } -------------------------------------------------------------------------------- /src/DSFMLC/System/ErrStream.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_ERRSRTEAM_HPP 29 | #define DSFML_ERRSRTEAM_HPP 30 | 31 | #include 32 | 33 | class ErrStream: public std:: streambuf 34 | { 35 | public: 36 | enum {BUFFER_SIZE=128}; 37 | ErrStream(); 38 | void setWriteFunc(void (*writeFunc)(const char* str, int size)); 39 | 40 | private: 41 | int_type overflow(int_type ch) override; 42 | int sync() override; 43 | void write(); 44 | void (*m_writeFunc)(const char* str, int size); 45 | char m_buffer[BUFFER_SIZE]; 46 | }; 47 | 48 | #endif //DSFML_ERRSRTEAM_HPP -------------------------------------------------------------------------------- /src/DSFMLC/System/Export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_SYSTEM_EXPORT_H 29 | #define DSFML_SYSTEM_EXPORT_H 30 | 31 | #include 32 | 33 | #define DSFML_SYSTEM_API extern "C" SFML_API_EXPORT 34 | 35 | #endif // DSFML_SYSTEM_EXPORT_H 36 | -------------------------------------------------------------------------------- /src/DSFMLC/System/String.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | namespace 32 | { 33 | std::basic_string utf8Out; 34 | std::basic_string utf16Out; 35 | std::basic_string utf32Out; 36 | } 37 | 38 | //Convert to utf8 39 | void utf16to8(const DUshort* inStr, size_t inLen, const DUbyte* outStr, size_t* outLen) 40 | { 41 | std::basic_string in; 42 | in.insert(0,inStr, inLen); 43 | 44 | utf8Out.clear(); 45 | 46 | sf::Utf16::toUtf8(in.begin(), in.end(), utf8Out.begin()); 47 | 48 | outStr = utf8Out.data(); 49 | *outLen = utf8Out.length(); 50 | } 51 | 52 | void utf32to8(const DUint* inStr, size_t inLen, const DUbyte* outStr, size_t* outLen) 53 | { 54 | std::basic_string in; 55 | in.insert(0,inStr, inLen); 56 | 57 | utf8Out.clear(); 58 | 59 | sf::Utf32::toUtf8(in.begin(), in.end(), utf8Out.begin()); 60 | 61 | outStr = utf8Out.data(); 62 | *outLen = utf8Out.length(); 63 | } 64 | 65 | //Convert to utf16 66 | void utf8to16(const DUbyte* inStr, size_t inLen, const DUshort* outStr, size_t* outLen) 67 | { 68 | std::basic_string in; 69 | in.insert(0,inStr, inLen); 70 | 71 | utf16Out.clear(); 72 | 73 | sf::Utf8::toUtf16(in.begin(), in.end(), utf16Out.begin()); 74 | 75 | outStr = utf16Out.data(); 76 | *outLen = utf16Out.length(); 77 | } 78 | 79 | void utf32to16(const DUint* inStr, size_t inLen, const DUshort* outStr, size_t* outLen) 80 | { 81 | std::basic_string in; 82 | in.insert(0,inStr, inLen); 83 | 84 | utf8Out.clear(); 85 | 86 | sf::Utf32::toUtf16(in.begin(), in.end(), utf16Out.begin()); 87 | 88 | outStr = utf16Out.data(); 89 | *outLen = utf16Out.length(); 90 | } 91 | 92 | //Convert to utf32 93 | void utf8to32(const DUbyte* inStr, size_t inLen, const DUint* outStr, size_t* outLen) 94 | { 95 | std::basic_string in; 96 | in.insert(0,inStr, inLen); 97 | 98 | utf32Out.clear(); 99 | 100 | sf::Utf8::toUtf32(in.begin(), in.end(), utf32Out.begin()); 101 | 102 | outStr = utf32Out.data(); 103 | *outLen = utf32Out.length(); 104 | } 105 | 106 | void utf16to32(const DUshort* inStr, size_t inLen, const DUint* outStr, size_t* outLen) 107 | { 108 | std::basic_string in; 109 | in.insert(0,inStr, inLen); 110 | 111 | utf32Out.clear(); 112 | 113 | sf::Utf16::toUtf32(in.begin(), in.end(), utf32Out.begin()); 114 | 115 | outStr = utf32Out.data(); 116 | *outLen = utf32Out.length(); 117 | } 118 | -------------------------------------------------------------------------------- /src/DSFMLC/System/String.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_STRING_H 29 | #define DSFML_STRING_H 30 | 31 | #include 32 | #include 33 | 34 | //Convert to utf8 35 | DSFML_SYSTEM_API void utf16to8(const DUshort* inStr, size_t inLen, const DUbyte* outStr, size_t* outLen); 36 | DSFML_SYSTEM_API void utf32to8(const DUint* inStr, size_t inLen, const DUbyte* outStr, size_t* outLen); 37 | 38 | //Convert to utf16 39 | DSFML_SYSTEM_API void utf8to16(const DUbyte* inStr, size_t inLen, const DUshort* outStr, size_t* outLen); 40 | DSFML_SYSTEM_API void utf32to16(const DUint* inStr, size_t inLen, const DUshort* outStr, size_t* outLen); 41 | 42 | //Convert to utf32 43 | DSFML_SYSTEM_API void utf8to32(const DUbyte* inStr, size_t inLen, const DUint* outStr, size_t* outLen); 44 | DSFML_SYSTEM_API void utf16to32(const DUshort* inStr, size_t inLen, const DUint* outStr, size_t* outLen); 45 | 46 | #endif//DSFML_STRING_H 47 | -------------------------------------------------------------------------------- /src/DSFMLC/System/Threads.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | void linux_XInitThreads(void) 32 | { 33 | XInitThreads(); 34 | } 35 | -------------------------------------------------------------------------------- /src/DSFMLC/System/Threads.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_THREADS_H 29 | #define DSFML_THREADS_H 30 | 31 | #include 32 | 33 | //call XInitThreads 34 | DSFML_SYSTEM_API void linux_XInitThreads(void); 35 | 36 | #endif // DSFML_THREADS_H 37 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/.gitignore: -------------------------------------------------------------------------------- 1 | #Ignore these things because they are annoying 2 | CMakeFiles/ 3 | *.cmake 4 | Makefile -------------------------------------------------------------------------------- /src/DSFMLC/Window/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCROOT ${PROJECT_SOURCE_DIR}/Window) 2 | 3 | # all source files 4 | set(SRC 5 | ${SRCROOT}/Export.h 6 | ${SRCROOT}/Context.cpp 7 | ${SRCROOT}/ContextStruct.h 8 | ${SRCROOT}/Context.h 9 | ${SRCROOT}/Event.h 10 | ${SRCROOT}/Joystick.cpp 11 | ${SRCROOT}/Joystick.h 12 | ${SRCROOT}/Keyboard.cpp 13 | ${SRCROOT}/Keyboard.h 14 | ${SRCROOT}/Mouse.cpp 15 | ${SRCROOT}/Mouse.h 16 | ${SRCROOT}/Sensor.cpp 17 | ${SRCROOT}/Sensor.h 18 | ${SRCROOT}/Touch.cpp 19 | ${SRCROOT}/Touch.h 20 | ${SRCROOT}/Types.h 21 | ${SRCROOT}/VideoMode.cpp 22 | ${SRCROOT}/VideoMode.h 23 | ${SRCROOT}/Window.cpp 24 | ${SRCROOT}/WindowStruct.h 25 | ${SRCROOT}/Window.h 26 | ${SRCROOT}/WindowHandle.h 27 | ) 28 | 29 | source_group("" FILES ${SRC}) 30 | 31 | #build only object files that can be linked into a d static library 32 | add_library(dsfmlc-window OBJECT ${SRC}) 33 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Context.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | sfContext* sfContext_create(void) 32 | { 33 | return new sfContext; 34 | } 35 | 36 | void sfContext_destroy(sfContext* context) 37 | { 38 | delete context; 39 | } 40 | 41 | void sfContext_setActive(sfContext* context, DBool active) 42 | { 43 | context->This.setActive(active == DTrue); 44 | } 45 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_CONTEXT_H 29 | #define DSFML_CONTEXT_H 30 | 31 | #include 32 | #include 33 | 34 | //Create a new context 35 | DSFML_WINDOW_API sfContext* sfContext_create(void); 36 | 37 | //Destroy a context 38 | DSFML_WINDOW_API void sfContext_destroy(sfContext* context); 39 | 40 | //Activate or deactivate explicitely a context 41 | DSFML_WINDOW_API void sfContext_setActive(sfContext* context, DBool active); 42 | 43 | #endif // DSFML_CONTEXT_H 44 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/ContextStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_CONTEXTSTRUCT_H 29 | #define DSFML_CONTEXTSTRUCT_H 30 | 31 | #include 32 | 33 | // Internal structure of sfContext 34 | struct sfContext 35 | { 36 | sf::Context This; 37 | }; 38 | 39 | #endif // DSFML_CONTEXTSTRUCT_H 40 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_WINDOW_EXPORT_H 29 | #define SFML_WINDOW_EXPORT_H 30 | 31 | #include 32 | 33 | #define DSFML_WINDOW_API extern "C" SFML_API_EXPORT 34 | 35 | #endif // SFML_WINDOW_EXPORT_H 36 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Joystick.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | DBool sfJoystick_isConnected(DUint joystick) 32 | { 33 | return sf::Joystick::isConnected(joystick) ? DTrue : DFalse; 34 | } 35 | 36 | DUint sfJoystick_getButtonCount(DUint joystick) 37 | { 38 | return sf::Joystick::getButtonCount(joystick); 39 | } 40 | 41 | DBool sfJoystick_hasAxis(DUint joystick, DInt axis) 42 | { 43 | return sf::Joystick::hasAxis(joystick, static_cast(axis)) ? DTrue : DFalse; 44 | } 45 | 46 | DBool sfJoystick_isButtonPressed(DUint joystick, DUint button) 47 | { 48 | return sf::Joystick::isButtonPressed(joystick, button) ? DTrue : DFalse; 49 | } 50 | 51 | float sfJoystick_getAxisPosition(DUint joystick, DInt axis) 52 | { 53 | return sf::Joystick::getAxisPosition(joystick, static_cast(axis)); 54 | } 55 | 56 | size_t sfJoystick_getIdentificationNameLength (DUint joystick) 57 | { 58 | return sf::Joystick::getIdentification(joystick).name.getSize(); 59 | } 60 | 61 | void sfJoystick_getIdentificationName (DUint joystick, DUint * nameBuffer) 62 | { 63 | //On Linux, just returning the pointer to the name string works fine, but on windows it corrupts during passing. 64 | sf::Joystick::Identification sfmlIdentification = sf::Joystick::getIdentification(joystick); 65 | 66 | for (unsigned int i = 0; i < sfmlIdentification.name.getSize(); i++) 67 | { 68 | nameBuffer[i] = sfmlIdentification.name[i]; 69 | } 70 | 71 | } 72 | 73 | void sfJoystick_getIdentification(DUint joystick, DUint * vendorId, DUint* productId) 74 | { 75 | sf::Joystick::Identification sfmlIdentification = sf::Joystick::getIdentification(joystick); 76 | 77 | *vendorId = sfmlIdentification.vendorId; 78 | *productId = sfmlIdentification.productId; 79 | } 80 | 81 | void sfJoystick_update(void) 82 | { 83 | sf::Joystick::update(); 84 | } 85 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Joystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_JOYSTICK_H 29 | #define DSFML_JOYSTICK_H 30 | 31 | #include 32 | #include 33 | 34 | //Global joysticks capabilities 35 | enum 36 | { 37 | sfJoystickCount = 8, /// Maximum number of supported joysticks 38 | sfJoystickButtonCount = 32, /// Maximum number of supported buttons 39 | sfJoystickAxisCount = 8 /// Maximum number of supported axes 40 | }; 41 | 42 | //Axes supported by SFML joysticks 43 | typedef enum 44 | { 45 | sfJoystickX, /// The X axis 46 | sfJoystickY, /// The Y axis 47 | sfJoystickZ, /// The Z axis 48 | sfJoystickR, /// The R axis 49 | sfJoystickU, /// The U axis 50 | sfJoystickV, /// The V axis 51 | sfJoystickPovX, /// The X axis of the point-of-view hat 52 | sfJoystickPovY /// The Y axis of the point-of-view hat 53 | } sfJoystickAxis; 54 | 55 | //Check if a joystick is connected 56 | DSFML_WINDOW_API DBool sfJoystick_isConnected(DUint joystick); 57 | 58 | //Return the number of buttons supported by a joystick 59 | DSFML_WINDOW_API DUint sfJoystick_getButtonCount(DUint joystick); 60 | 61 | //Check if a joystick supports a given axis 62 | DSFML_WINDOW_API DBool sfJoystick_hasAxis(DUint joystick, DInt axis); 63 | 64 | //Check if a joystick button is pressed 65 | DSFML_WINDOW_API DBool sfJoystick_isButtonPressed(DUint joystick, DUint button); 66 | 67 | //Get the current position of a joystick axis 68 | DSFML_WINDOW_API float sfJoystick_getAxisPosition(DUint joystick, DInt axis); 69 | 70 | //Get the length of a joystick name for buffer generation 71 | DSFML_WINDOW_API size_t sfJoystick_getIdentificationNameLength (DUint joystick); 72 | 73 | //Write the name of the joystick name to a D-side buffer 74 | DSFML_WINDOW_API void sfJoystick_getIdentificationName(DUint joystick, DUint * nameBuffer); 75 | 76 | //Get the joystick information 77 | DSFML_WINDOW_API void sfJoystick_getIdentification(DUint joystick, DUint * vendorID, DUint* productId); 78 | 79 | //Update the states of all joysticks 80 | DSFML_WINDOW_API void sfJoystick_update(void); 81 | 82 | #endif // SFML_JOYSTICK_H 83 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Keyboard.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | DBool sfKeyboard_isKeyPressed(DInt key) 32 | { 33 | return sf::Keyboard::isKeyPressed(static_cast(key)); 34 | } 35 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_KEYBOARD_H 29 | #define DSFML_KEYBOARD_H 30 | 31 | #include 32 | 33 | //Check if a key is pressed 34 | DSFML_WINDOW_API DBool sfKeyboard_isKeyPressed(DInt key); 35 | 36 | #endif // DSFML_KEYBOARD_H 37 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Mouse.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | // Headers 29 | #include 30 | #include 31 | #include 32 | 33 | DBool sfMouse_isButtonPressed(DInt button) 34 | { 35 | return sf::Mouse::isButtonPressed(static_cast(button)) ? DTrue : DFalse; 36 | } 37 | 38 | void sfMouse_getPosition(const sfWindow* relativeTo, DInt* x, DInt* y) 39 | { 40 | sf::Vector2i sfmlPos; 41 | if (relativeTo) 42 | sfmlPos = sf::Mouse::getPosition(relativeTo->This); 43 | else 44 | sfmlPos = sf::Mouse::getPosition(); 45 | 46 | *x = sfmlPos.x; 47 | *y = sfmlPos.y; 48 | } 49 | 50 | void sfMouse_setPosition(DInt x, DInt y, const sfWindow* relativeTo) 51 | { 52 | if (relativeTo) 53 | sf::Mouse::setPosition(sf::Vector2i(x, y), relativeTo->This); 54 | else 55 | sf::Mouse::setPosition(sf::Vector2i(x, y)); 56 | } 57 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Mouse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_MOUSE_H 29 | #define SFML_MOUSE_H 30 | 31 | 32 | #include 33 | #include 34 | 35 | //Check if a mouse button is pressed 36 | DSFML_WINDOW_API DBool sfMouse_isButtonPressed(DInt button); 37 | 38 | //Get the current position of the mouse 39 | DSFML_WINDOW_API void sfMouse_getPosition(const sfWindow* relativeTo, DInt* x, DInt* y); 40 | 41 | //Set the current position of the mouse 42 | DSFML_WINDOW_API void sfMouse_setPosition(DInt x, DInt y, const sfWindow* relativeTo); 43 | 44 | #endif // DSFML_MOUSE_H 45 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Sensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | DBool sfSensor_isAvailable (DInt sensor) 33 | { 34 | return sf::Sensor::isAvailable(static_cast(sensor)) ? DTrue : DFalse; 35 | } 36 | 37 | void sfSensor_setEnabled (DInt sensor, DBool enabled) 38 | { 39 | sf::Sensor::setEnabled(static_cast(sensor), (enabled == DTrue)); 40 | } 41 | 42 | void sfSensor_getValue (DInt sensor, float* x, float* y, float* z) 43 | { 44 | sf::Vector3f getValue = sf::Sensor::getValue(static_cast(sensor)); 45 | 46 | *x = getValue.x; 47 | *y = getValue.y; 48 | *z = getValue.z; 49 | } 50 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Sensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_SENSOR_H 29 | #define SFML_SENSOR_H 30 | 31 | #include 32 | #include 33 | 34 | //Check if a sensor is available on the underlying platform 35 | DSFML_WINDOW_API DBool sfSensor_isAvailable(DInt sensor); 36 | 37 | //Enable or disable a sensor 38 | DSFML_WINDOW_API void sfSensor_setEnabled(DInt sensor, DBool enabled); 39 | 40 | //Get the current sensor value 41 | DSFML_WINDOW_API void sfSensor_getValue(DInt sensor, float* x, float* y, float* z); 42 | 43 | #endif /* SFML_SENSOR_H */ 44 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Touch.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | DBool sfTouch_isDown (DUint finger) 34 | { 35 | return sf::Touch::isDown(finger) ? DTrue : DFalse; 36 | } 37 | 38 | void sfTouch_getPosition (DUint finger, const sfWindow* relativeTo, DInt* x, DInt* y) 39 | { 40 | sf::Vector2i getPosition; 41 | if (relativeTo) 42 | getPosition = sf::Touch::getPosition(finger, relativeTo->This); 43 | else 44 | getPosition = sf::Touch::getPosition(finger); 45 | 46 | *x = getPosition.x; 47 | *y = getPosition.y; 48 | } 49 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef SFML_TOUCH_H 29 | #define SFML_TOUCH_H 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | //Check if a touch event is currently down 36 | DSFML_WINDOW_API DBool sfTouch_isDown (DUint finger); 37 | 38 | //Get the current position of a touch in desktop coordinates 39 | DSFML_WINDOW_API void sfTouch_getPosition (DUint finger, const sfWindow* relativeTo, DInt* x, DInt* y); 40 | 41 | #endif /* SFML_TOUCH_H */ 42 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/Types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_WINDOW_TYPES_H 29 | #define DSFML_WINDOW_TYPES_H 30 | 31 | typedef struct sfContext sfContext; 32 | typedef struct sfWindow sfWindow; 33 | 34 | #endif // DSFML_WINDOW_TYPES_H 35 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/VideoMode.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | void sfVideoMode_getDesktopMode(DUint* width, DUint* height, DUint* bitsPerPixel) 32 | { 33 | sf::VideoMode desktop = sf::VideoMode::getDesktopMode(); 34 | 35 | *width = desktop.width; 36 | *height = desktop.height; 37 | *bitsPerPixel = desktop.bitsPerPixel; 38 | 39 | 40 | } 41 | 42 | const DUint* sfVideoMode_getFullscreenModes(size_t* count) 43 | { 44 | static std::vector modes; 45 | 46 | // Populate the array on first call 47 | if (modes.empty()) 48 | { 49 | const std::vector& SFMLModes = sf::VideoMode::getFullscreenModes(); 50 | for (std::vector::const_iterator it = SFMLModes.begin(); it != SFMLModes.end(); ++it) 51 | { 52 | 53 | modes.push_back(it->width); 54 | modes.push_back(it->height); 55 | modes.push_back(it->bitsPerPixel); 56 | } 57 | } 58 | 59 | if (count) 60 | *count = modes.size(); 61 | 62 | return !modes.empty() ? &modes[0] : NULL; 63 | } 64 | 65 | DBool sfVideoMode_isValid(DUint width, DUint height, DUint bitsPerPixel) 66 | { 67 | sf::VideoMode videoMode(width, height, bitsPerPixel); 68 | return videoMode.isValid() ? DTrue : DFalse; 69 | } 70 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/VideoMode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_VIDEOMODE_H 29 | #define DSFML_VIDEOMODE_H 30 | 31 | #include 32 | #include 33 | 34 | //Get the current desktop video mode 35 | DSFML_WINDOW_API void sfVideoMode_getDesktopMode(DUint* width, DUint* height, DUint* bitsPerPixel); 36 | 37 | //Retrieve all the video modes supported in fullscreen mode 38 | DSFML_WINDOW_API const DUint* sfVideoMode_getFullscreenModes(size_t* Count); 39 | 40 | //Tell whether or not a video mode is valid 41 | DSFML_WINDOW_API DBool sfVideoMode_isValid(DUint width, DUint height, DUint bitsPerPixel); 42 | 43 | #endif // DSFML_VIDEOMODE_H 44 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/WindowHandle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_WINDOWHANDLE_H 29 | #define DSFML_WINDOWHANDLE_H 30 | 31 | #include 32 | 33 | 34 | //////////////////////////////////////////////////////////// 35 | /// Define a low-level window handle type, specific to 36 | /// each platform 37 | //////////////////////////////////////////////////////////// 38 | #if defined(SFML_SYSTEM_WINDOWS) 39 | 40 | // Window handle is HWND (HWND__*) on Windows 41 | struct HWND__; 42 | typedef struct HWND__* sfWindowHandle; 43 | 44 | #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) 45 | 46 | // Window handle is Window (unsigned long) on Unix - X11 47 | typedef unsigned long sfWindowHandle; 48 | 49 | #elif defined(SFML_SYSTEM_MACOS) 50 | 51 | // Window handle is NSWindow (void*) on Mac OS X - Cocoa 52 | typedef void* sfWindowHandle; 53 | 54 | #endif 55 | 56 | #endif // DSFML_WINDOWHANDLE_H 57 | -------------------------------------------------------------------------------- /src/DSFMLC/Window/WindowStruct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | #ifndef DSFML_WINDOWSTRUCT_H 29 | #define DSFML_WINDOWSTRUCT_H 30 | 31 | #include 32 | 33 | // Internal structure of sfWindow 34 | struct sfWindow 35 | { 36 | sf::Window This; 37 | }; 38 | 39 | #endif // DSFML_WINDOWSTRUCT_H 40 | -------------------------------------------------------------------------------- /src/dsfml/audio/package.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /// Sounds, streaming (musics or custom sources), recording, spatialization. 29 | module dsfml.audio; 30 | 31 | public 32 | { 33 | import dsfml.audio.inputsoundfile; 34 | import dsfml.audio.listener; 35 | import dsfml.audio.music; 36 | import dsfml.audio.outputsoundfile; 37 | import dsfml.audio.sound; 38 | import dsfml.audio.soundbuffer; 39 | import dsfml.audio.soundbufferrecorder; 40 | import dsfml.audio.soundrecorder; 41 | import dsfml.audio.soundsource; 42 | import dsfml.audio.soundstream; 43 | 44 | import dsfml.system; 45 | } 46 | -------------------------------------------------------------------------------- /src/dsfml/graphics/drawable.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /** 29 | * $(U Drawable) is a very simple base interface that allows objects of derived 30 | * classes to be drawn to a RenderTarget. 31 | * 32 | * All you have to do in your derived class is to override the draw virtual 33 | * function. 34 | * 35 | * Note that inheriting from $(DRAWABLE_LINK) is not mandatory, but it allows 36 | * this nice syntax `window.draw(object)` rather than `object.draw(window)`, 37 | * which is more consistent with other DSFML classes. 38 | * 39 | * Example: 40 | * --- 41 | * class MyDrawable : Drawable 42 | * { 43 | * public: 44 | * 45 | * this() 46 | * { 47 | * m_sprite = Sprite(); 48 | * m_texture = Texture(); 49 | * m_vertices = VertexArray(); 50 | * 51 | * // additional setup 52 | * } 53 | * ... 54 | * 55 | * void draw(RenderTarget target, RenderStates states) const 56 | * { 57 | * // You can draw other high-level objects 58 | * target.draw(m_sprite, states); 59 | * 60 | * // ... or use the low-level API 61 | * states.texture = m_texture; 62 | * target.draw(m_vertices, states); 63 | * 64 | * // ... or draw with OpenGL directly 65 | * glBegin(GL_QUADS); 66 | * ... 67 | * glEnd(); 68 | * } 69 | * 70 | * private: 71 | * Sprite m_sprite; 72 | * Texture m_texture; 73 | * VertexArray m_vertices; 74 | * } 75 | * --- 76 | * 77 | * See_Also: 78 | * $(RENDERTARGET_LINK) 79 | */ 80 | module dsfml.graphics.drawable; 81 | 82 | import dsfml.graphics.rendertarget; 83 | import dsfml.graphics.renderstates; 84 | 85 | /** 86 | * Interface for objects that can be drawn to a render target. 87 | */ 88 | interface Drawable 89 | { 90 | /** 91 | * Draw the object to a render target. 92 | * 93 | * Params: 94 | * renderTarget = Render target to draw to 95 | * renderStates = Current render states 96 | */ 97 | void draw(RenderTarget renderTarget, RenderStates renderStates); 98 | } -------------------------------------------------------------------------------- /src/dsfml/graphics/glyph.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /** 29 | * A glyph is the visual representation of a character. 30 | * 31 | * The $(U Glyph) structure provides the information needed to handle the glyph: 32 | * $(UL 33 | * $(LI its coordinates in the font's texture) 34 | * $(LI its bounding rectangle) 35 | * $(LI the offset to apply to get the starting position of the next glyph)) 36 | * 37 | * See_Also: 38 | * $(FONT_LINK) 39 | */ 40 | module dsfml.graphics.glyph; 41 | 42 | public import dsfml.graphics.rect; 43 | 44 | /** 45 | * Structure describing a glyph. 46 | */ 47 | struct Glyph 48 | { 49 | /// Offset to move horizontally to the next character. 50 | float advance; 51 | /// Bounding rectangle of the glyph, in coordinates relative to the baseline. 52 | FloatRect bounds; 53 | /// Texture coordinates of the glyph inside the font's texture. 54 | IntRect textureRect; 55 | } 56 | -------------------------------------------------------------------------------- /src/dsfml/graphics/package.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /// 2D graphics module: sprites, text, shapes, etc. 29 | module dsfml.graphics; 30 | 31 | public 32 | { 33 | import dsfml.window; 34 | 35 | import dsfml.graphics.blendmode; 36 | import dsfml.graphics.circleshape; 37 | import dsfml.graphics.color; 38 | import dsfml.graphics.convexshape; 39 | import dsfml.graphics.drawable; 40 | import dsfml.graphics.font; 41 | import dsfml.graphics.glyph; 42 | import dsfml.graphics.image; 43 | import dsfml.graphics.primitivetype; 44 | import dsfml.graphics.rect; 45 | import dsfml.graphics.rectangleshape; 46 | import dsfml.graphics.renderstates; 47 | import dsfml.graphics.rendertarget; 48 | import dsfml.graphics.rendertexture; 49 | import dsfml.graphics.renderwindow; 50 | import dsfml.graphics.shader; 51 | import dsfml.graphics.shape; 52 | import dsfml.graphics.sprite; 53 | import dsfml.graphics.text; 54 | import dsfml.graphics.texture; 55 | import dsfml.graphics.transform; 56 | import dsfml.graphics.transformable; 57 | import dsfml.graphics.vertex; 58 | import dsfml.graphics.vertexarray; 59 | import dsfml.graphics.view; 60 | } 61 | -------------------------------------------------------------------------------- /src/dsfml/graphics/primitivetype.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /// The module containing the list of usable primitives for drawing. 29 | module dsfml.graphics.primitivetype; 30 | 31 | /** 32 | * Types of primitives that a $(VERTEXARRAY_LINK VertexArray) can render. 33 | * 34 | * Points and lines have no area, therefore their thickness will always be 1 35 | * pixel, regarldess the current transform and view. 36 | */ 37 | enum PrimitiveType 38 | { 39 | /// List of individual points. 40 | Points, 41 | /// List of individual lines. 42 | Lines, 43 | /// List of connected lines; a point uses the previous point to form a line. 44 | LineStrip, 45 | /// List of individual triangles. 46 | Triangles, 47 | /** 48 | * List of connected triangles; a point uses the two previous points to form 49 | * a triangle. 50 | */ 51 | TriangleStrip, 52 | /** 53 | * List of connected triangles; a point uses the common center and the 54 | * previous point to form a triangle. 55 | */ 56 | TriangleFan, 57 | /// List of individual quads. 58 | Quads, 59 | 60 | /// Deprecated: List of individual triangles. 61 | LinesStrip = LineStrip, 62 | /// Deprecated: List of connected triangles. 63 | TrianglesStrip = TriangleStrip, 64 | /// Deprecated: List of connected triangles. 65 | TrianglesFan = TriangleFan 66 | } 67 | -------------------------------------------------------------------------------- /src/dsfml/network/package.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /** 29 | * Socket-based communication, utilities and higher-level network protocols 30 | * (HTTP, FTP). 31 | */ 32 | module dsfml.network; 33 | 34 | public 35 | { 36 | import dsfml.system; 37 | 38 | import dsfml.network.ftp; 39 | import dsfml.network.http; 40 | import dsfml.network.ipaddress; 41 | import dsfml.network.packet; 42 | import dsfml.network.socket; 43 | import dsfml.network.socketselector; 44 | import dsfml.network.tcplistener; 45 | import dsfml.network.tcpsocket; 46 | import dsfml.network.udpsocket; 47 | } 48 | -------------------------------------------------------------------------------- /src/dsfml/system/config.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /// A module containing configuration settings. 29 | module dsfml.system.config; 30 | 31 | //Check to confirm compiler is at least v2.067 32 | static if (__VERSION__ < 2067L) 33 | { 34 | static assert(0, "Please upgrade your compiler to v2.067 or later"); 35 | } 36 | 37 | /// DSFML version enum 38 | enum 39 | { 40 | /// DSFML's major version number. 41 | DSFML_VERSION_MAJOR = 2, 42 | /// DSFML's minor version number. 43 | DSFML_VERSION_MINOR = 4 44 | } 45 | 46 | //destructor output for mixing in. 47 | enum destructorOutput =` 48 | version (DSFML_Noisy_Destructors) 49 | { 50 | import dsfml.system.err; 51 | err.writeln("Destroying ", typeof(this).stringof); 52 | }`; 53 | 54 | -------------------------------------------------------------------------------- /src/dsfml/system/package.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /// Base module of SFML, defining various utilities. 29 | module dsfml.system; 30 | 31 | public 32 | { 33 | import dsfml.system.clock; 34 | import dsfml.system.config; 35 | import dsfml.system.err; 36 | import dsfml.system.inputstream; 37 | import dsfml.system.lock; 38 | import dsfml.system.mutex; 39 | import dsfml.system.sleep; 40 | import dsfml.system.thread; 41 | import dsfml.system.vector2; 42 | import dsfml.system.vector3; 43 | } 44 | -------------------------------------------------------------------------------- /src/dsfml/system/sleep.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /// A module containing the sleep function. 29 | module dsfml.system.sleep; 30 | 31 | public import dsfml.system.time; 32 | 33 | /** 34 | * Make the current thread sleep for a given duration. 35 | * 36 | * sleep is the best way to block a program or one of its threads, as it doesn't 37 | * consume any CPU power. 38 | * 39 | * Params: 40 | * duration = The length of time to sleep for 41 | */ 42 | void sleep(Time duration) 43 | { 44 | import core.thread: Thread; 45 | import core.time: usecs; 46 | Thread.sleep(usecs(duration.asMicroseconds())); 47 | } 48 | 49 | unittest 50 | { 51 | version(DSFML_Unittest_System) 52 | { 53 | import std.stdio; 54 | 55 | writeln("Unit test for sleep function"); 56 | 57 | writeln("Start!(sleeping for 1 second)"); 58 | sleep(seconds(1)); 59 | writeln("Done! Now sleeping for 2 seconds."); 60 | sleep(seconds(2)); 61 | writeln("Done! I think you get the idea."); 62 | writeln(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/dsfml/system/string.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /** 29 | * A module containing functions for interacting with strings going to and from 30 | * a C/C++ library as well as converting between D's string types. This module 31 | * has no dependencies except for std.utf. 32 | * 33 | * Deprecated: This module is expected to be removed in DSFML 2.5. 34 | */ 35 | deprecated("This module is expected to be removed in DSFML 2.5.") 36 | module dsfml.system.string; 37 | 38 | /** 39 | * Returns a D string copy of a zero terminated C style string 40 | * 41 | * Params: 42 | * str = The C style string to convert 43 | * 44 | * Returns: The D style string copy. 45 | * 46 | * Deprecated: This method is expected to be removed in DSFML 2.5. 47 | */ 48 | deprecated("This method is expected to be removed in DSFML 2.5.") 49 | immutable(T)[] toString(T)(in const(T)* str) pure 50 | if (is(T == dchar)||is(T == wchar)||is(T == char)) 51 | { 52 | if(str is null) 53 | return ""; 54 | 55 | return str[0..strlen(str)].idup; 56 | } 57 | 58 | /** 59 | * Returns the same string in a different utf encoding 60 | * 61 | * Params: 62 | * str = The string to convert 63 | * 64 | * Returns: the C style string pointer. 65 | * 66 | * Deprecated: Use conversion methonds in std.utf instead. 67 | */ 68 | deprecated("Use conversion methonds in std.utf instead.") 69 | immutable(U)[] stringConvert(T, U)(in T[] str) pure 70 | if ((is(T == dchar)||is(T == wchar)||is(T == char)) && 71 | (is(U == dchar)||is(U == wchar)||is(U == char))) 72 | { 73 | import std.utf; 74 | 75 | static if(is(U == char)) 76 | return toUTF8(str); 77 | else static if(is(U == wchar)) 78 | return toUTF16(str); 79 | else 80 | return toUTF32(str); 81 | } 82 | 83 | /** 84 | * Get the length of a C style string. 85 | * 86 | * Params: 87 | * str = The C style string 88 | * 89 | * Returns: The C string's length. 90 | */ 91 | private size_t strlen(T)(in const(T)* str) pure nothrow 92 | if (is(T == dchar)||is(T == wchar)||is(T == char)) 93 | { 94 | size_t n = 0; 95 | for (; str[n] != 0; ++n) {} 96 | return n; 97 | } 98 | 99 | unittest 100 | { 101 | version(DSFML_Unittest_System) 102 | { 103 | import std.stdio; 104 | 105 | writeln("Unit test for string functions"); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/dsfml/window/context.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /** 29 | * If you need to make OpenGL calls without having an active window (like in a 30 | * thread), you can use an instance of this class to get a valid context. 31 | * 32 | * Having a valid context is necessary for $(I every) OpenGL call. 33 | * 34 | * Note that a context is only active in its current thread, if you create a new 35 | * thread it will have no valid context by default. 36 | * 37 | * To use a $(U Context) instance, just construct it and let it live as long as you 38 | * need a valid context. No explicit activation is needed, all it has to do is 39 | * to exist. Its destructor will take care of deactivating and freeing all the 40 | * attached resources. 41 | * 42 | * Example: 43 | * --- 44 | * void threadFunction() 45 | * { 46 | * Context context = new Context(); 47 | * // from now on, you have a valid context 48 | * 49 | * // you can make OpenGL calls 50 | * glClear(GL_DEPTH_BUFFER_BIT); 51 | * } 52 | * // the context is automatically deactivated and destroyed by the 53 | * // Context destructor when the class is collected by the GC 54 | * --- 55 | */ 56 | module dsfml.window.context; 57 | 58 | alias GlFunctionPointer = void*; 59 | 60 | /** 61 | * Class holding a valid drawing context. 62 | */ 63 | class Context 64 | { 65 | package sfContext* sfPtr; 66 | 67 | /** 68 | * Default constructor. 69 | * 70 | * The constructor creates and activates the context. 71 | */ 72 | this() 73 | { 74 | sfPtr = sfContext_create(); 75 | } 76 | 77 | /// Destructor. 78 | ~this() 79 | { 80 | import dsfml.system.config; 81 | mixin(destructorOutput); 82 | sfContext_destroy(sfPtr); 83 | } 84 | 85 | /** 86 | * Activate or deactivate explicitely the context. 87 | * 88 | * Params: 89 | * active = true to activate, false to deactivate 90 | * 91 | * Returns: true on success, false on failure. 92 | */ 93 | void setActive(bool active) 94 | { 95 | sfContext_setActive(sfPtr,active); 96 | } 97 | } 98 | 99 | package extern(C) 100 | { 101 | struct sfContext; 102 | } 103 | private extern(C) 104 | { 105 | sfContext* sfContext_create(); 106 | void sfContext_destroy(sfContext* context); 107 | void sfContext_setActive(sfContext* context, bool active); 108 | } 109 | -------------------------------------------------------------------------------- /src/dsfml/window/package.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | 29 | /// Provides OpenGL-based windows, and abstractions for events and input handling. 30 | module dsfml.window; 31 | 32 | public 33 | { 34 | import dsfml.system; 35 | 36 | import dsfml.window.context; 37 | import dsfml.window.contextsettings; 38 | import dsfml.window.event; 39 | import dsfml.window.joystick; 40 | import dsfml.window.keyboard; 41 | import dsfml.window.mouse; 42 | import dsfml.window.touch; 43 | import dsfml.window.sensor; 44 | import dsfml.window.videomode; 45 | import dsfml.window.window; 46 | import dsfml.window.windowhandle; 47 | } 48 | -------------------------------------------------------------------------------- /src/dsfml/window/windowhandle.d: -------------------------------------------------------------------------------- 1 | /* 2 | * DSFML - The Simple and Fast Multimedia Library for D 3 | * 4 | * Copyright (c) 2013 - 2018 Jeremy DeHaan (dehaan.jeremiah@gmail.com) 5 | * 6 | * This software is provided 'as-is', without any express or implied warranty. 7 | * In no event will the authors be held liable for any damages arising from the 8 | * use of this software. 9 | * 10 | * Permission is granted to anyone to use this software for any purpose, 11 | * including commercial applications, and to alter it and redistribute it 12 | * freely, subject to the following restrictions: 13 | * 14 | * 1. The origin of this software must not be misrepresented; you must not claim 15 | * that you wrote the original software. If you use this software in a product, 16 | * an acknowledgment in the product documentation would be appreciated but is 17 | * not required. 18 | * 19 | * 2. Altered source versions must be plainly marked as such, and must not be 20 | * misrepresented as being the original software. 21 | * 22 | * 3. This notice may not be removed or altered from any source distribution 23 | * 24 | * 25 | * DSFML is based on SFML (Copyright Laurent Gomila) 26 | */ 27 | 28 | /** 29 | * Define a low-level window handle type, specific to each platform. 30 | * 31 | * $(TABLE 32 | * $(TR $(TH Platform) $(TH Type)) 33 | * $(TR $(TD Windows) $(TD `HWND`)) 34 | * $(TR $(TD Linux/FreeBSD) $(TD `Window`)) 35 | * $(TR $(TD Mac OS X) 36 | * $(TD either `NSWindow*` or `NSView*`, disguised as `void*`))) 37 | * $(LF) 38 | * 39 | * $(PARA $(B Mac OS X Specification) 40 | * 41 | * On Mac OS X, a $(WINDOW_LINK) can be created either from an existing 42 | * `NSWindow*` or an `NSView*`. When the window is created from a window, DSFML 43 | * will use its content view as the OpenGL area. `Window.getSystemHandle()` will 44 | * return the handle that was used to create the window, 45 | * which is a `NSWindow*` by default.) 46 | */ 47 | module dsfml.window.windowhandle; 48 | 49 | 50 | //TODO: Make the Windows Window Handle the right type? 51 | //(ie, a HWND from std.c.windows.windows? 52 | version(Windows) 53 | { 54 | //import std.c.windows.windows; 55 | struct HWND__; 56 | alias HWND__* WindowHandle; 57 | } 58 | version(OSX) 59 | { 60 | import core.stdc.config; 61 | alias c_ulong WindowHandle; 62 | } 63 | version(linux) 64 | { 65 | alias void* WindowHandle; 66 | } 67 | -------------------------------------------------------------------------------- /unittest/res/TestImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jebbs/DSFML/d6a43117aa273284bf0d2074869caed010d41548/unittest/res/TestImage.png -------------------------------------------------------------------------------- /unittest/res/TestMusic.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jebbs/DSFML/d6a43117aa273284bf0d2074869caed010d41548/unittest/res/TestMusic.ogg -------------------------------------------------------------------------------- /unittest/res/TestSound.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jebbs/DSFML/d6a43117aa273284bf0d2074869caed010d41548/unittest/res/TestSound.ogg -------------------------------------------------------------------------------- /unittest/res/Warenhaus-Standard.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jebbs/DSFML/d6a43117aa273284bf0d2074869caed010d41548/unittest/res/Warenhaus-Standard.ttf --------------------------------------------------------------------------------