sfml.js 0.0.1-preview.42 → 0.0.1-preview.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -13
- package/binding.gyp +21 -19
- package/lib/poll_event.d.ts +2 -2
- package/lib/render_window.d.ts +36 -10
- package/lib/render_window.js +76 -0
- package/package.json +9 -17
- package/src/render_window.cc +177 -0
- package/src/render_window.h +45 -0
- package/src/render_window_async_display.cc +49 -0
- package/src/render_window_async_draw.cc +56 -0
- package/tools/copier/linux.js +21 -0
- package/tools/copier/macos.js +34 -0
- package/tools/copier/windows.js +33 -0
- package/tools/lib_downloader.js +102 -0
- package/tools/lib_downloader_urls.js +58 -0
- package/third_party/sfml/platform/linux/lib/libsfml-audio.so.2.5.1 +0 -0
- package/third_party/sfml/platform/linux/lib/libsfml-graphics.so.2.5.1 +0 -0
- package/third_party/sfml/platform/linux/lib/libsfml-network.so.2.5.1 +0 -0
- package/third_party/sfml/platform/linux/lib/libsfml-system.so.2.5.1 +0 -0
- package/third_party/sfml/platform/linux/lib/libsfml-window.so.2.5.1 +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/FLAC.framework/Versions/A/FLAC +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/FLAC.framework/Versions/A/Resources/Info.plist +0 -22
- package/third_party/sfml/platform/macOS/Frameworks/OpenAL.framework/Versions/A/OpenAL +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/OpenAL.framework/Versions/A/Resources/Info.plist +0 -22
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/AlResource.hpp +0 -70
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/Export.hpp +0 -48
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/InputSoundFile.hpp +0 -263
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/Listener.hpp +0 -234
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/Music.hpp +0 -337
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/OutputSoundFile.hpp +0 -133
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/Sound.hpp +0 -264
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundBuffer.hpp +0 -352
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundBufferRecorder.hpp +0 -144
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundFileFactory.hpp +0 -197
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundFileFactory.inl +0 -100
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundFileReader.hpp +0 -165
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundFileWriter.hpp +0 -125
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundRecorder.hpp +0 -408
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundSource.hpp +0 -332
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio/SoundStream.hpp +0 -405
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Audio.hpp +0 -56
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Config.hpp +0 -236
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/GpuPreference.hpp +0 -74
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/BlendMode.hpp +0 -215
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/CircleShape.hpp +0 -154
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Color.hpp +0 -275
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/ConvexShape.hpp +0 -153
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Drawable.hpp +0 -126
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Export.hpp +0 -48
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Font.hpp +0 -439
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Glsl.hpp +0 -227
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Glsl.inl +0 -155
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Glyph.hpp +0 -79
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Image.hpp +0 -324
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/PrimitiveType.hpp +0 -58
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Rect.hpp +0 -254
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Rect.inl +0 -159
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/RectangleShape.hpp +0 -132
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/RenderStates.hpp +0 -174
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/RenderTarget.hpp +0 -510
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/RenderTexture.hpp +0 -314
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/RenderWindow.hpp +0 -284
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Shader.hpp +0 -875
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Shape.hpp +0 -355
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Sprite.hpp +0 -279
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Text.hpp +0 -513
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Texture.hpp +0 -733
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Transform.hpp +0 -479
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Transformable.hpp +0 -429
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/Vertex.hpp +0 -148
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/VertexArray.hpp +0 -223
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/VertexBuffer.hpp +0 -408
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics/View.hpp +0 -343
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Graphics.hpp +0 -68
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Main.hpp +0 -43
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/Export.hpp +0 -48
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/Ftp.hpp +0 -616
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/Http.hpp +0 -482
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/IpAddress.hpp +0 -328
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/Packet.hpp +0 -532
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/Socket.hpp +0 -219
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/SocketHandle.hpp +0 -57
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/SocketSelector.hpp +0 -263
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/TcpListener.hpp +0 -166
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/TcpSocket.hpp +0 -316
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network/UdpSocket.hpp +0 -291
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Network.hpp +0 -53
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/OpenGL.hpp +0 -78
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Clock.hpp +0 -117
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Err.hpp +0 -80
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Export.hpp +0 -48
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/FileInputStream.hpp +0 -169
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/InputStream.hpp +0 -152
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Lock.hpp +0 -139
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/MemoryInputStream.hpp +0 -148
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Mutex.hpp +0 -148
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/NativeActivity.hpp +0 -62
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/NonCopyable.hpp +0 -129
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Sleep.hpp +0 -52
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/String.hpp +0 -669
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/String.inl +0 -53
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Thread.hpp +0 -282
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Thread.inl +0 -90
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/ThreadLocal.hpp +0 -103
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/ThreadLocalPtr.hpp +0 -158
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/ThreadLocalPtr.inl +0 -77
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Time.hpp +0 -488
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Utf.hpp +0 -763
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Utf.inl +0 -752
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Vector2.hpp +0 -301
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Vector2.inl +0 -161
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Vector3.hpp +0 -302
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System/Vector3.inl +0 -168
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/System.hpp +0 -60
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Clipboard.hpp +0 -119
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Context.hpp +0 -195
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/ContextSettings.hpp +0 -149
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Cursor.hpp +0 -222
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Event.hpp +0 -284
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Export.hpp +0 -48
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/GlResource.hpp +0 -109
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Joystick.hpp +0 -227
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Keyboard.hpp +0 -232
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Mouse.hpp +0 -177
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Sensor.hpp +0 -150
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Touch.hpp +0 -137
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/VideoMode.hpp +0 -228
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/Window.hpp +0 -622
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/WindowHandle.hpp +0 -101
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window/WindowStyle.hpp +0 -53
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Headers/Window.hpp +0 -58
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/CMake/SFMLConfig.cmake +0 -148
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/CMake/SFMLConfigDependencies.cmake +0 -86
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/CMake/SFMLConfigVersion.cmake +0 -46
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/CMake/SFMLSharedTargets-release.cmake +0 -59
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/CMake/SFMLSharedTargets.cmake +0 -158
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/Resources/Info.plist +0 -26
- package/third_party/sfml/platform/macOS/Frameworks/SFML.framework/Versions/2.5.1/SFML +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/freetype.framework/Versions/A/Resources/Info.plist +0 -22
- package/third_party/sfml/platform/macOS/Frameworks/freetype.framework/Versions/A/freetype +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/ogg.framework/Versions/A/Resources/Info.plist +0 -22
- package/third_party/sfml/platform/macOS/Frameworks/ogg.framework/Versions/A/ogg +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/sfml-audio.framework/Versions/2.5.1/Resources/Info.plist +0 -26
- package/third_party/sfml/platform/macOS/Frameworks/sfml-audio.framework/Versions/2.5.1/sfml-audio +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/sfml-graphics.framework/Versions/2.5.1/Resources/Info.plist +0 -26
- package/third_party/sfml/platform/macOS/Frameworks/sfml-graphics.framework/Versions/2.5.1/sfml-graphics +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/sfml-network.framework/Versions/2.5.1/Resources/Info.plist +0 -26
- package/third_party/sfml/platform/macOS/Frameworks/sfml-network.framework/Versions/2.5.1/sfml-network +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/sfml-system.framework/Versions/2.5.1/Resources/Info.plist +0 -26
- package/third_party/sfml/platform/macOS/Frameworks/sfml-system.framework/Versions/2.5.1/sfml-system +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/sfml-window.framework/Versions/2.5.1/Resources/Info.plist +0 -26
- package/third_party/sfml/platform/macOS/Frameworks/sfml-window.framework/Versions/2.5.1/sfml-window +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/vorbis.framework/Versions/A/Resources/Info.plist +0 -22
- package/third_party/sfml/platform/macOS/Frameworks/vorbis.framework/Versions/A/vorbis +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/vorbisenc.framework/Versions/A/Resources/Info.plist +0 -22
- package/third_party/sfml/platform/macOS/Frameworks/vorbisenc.framework/Versions/A/vorbisenc +0 -0
- package/third_party/sfml/platform/macOS/Frameworks/vorbisfile.framework/Versions/A/Resources/Info.plist +0 -22
- package/third_party/sfml/platform/macOS/Frameworks/vorbisfile.framework/Versions/A/vorbisfile +0 -0
- package/third_party/sfml/platform/macOS/lib/libsfml-audio.2.5.1.dylib +0 -0
- package/third_party/sfml/platform/macOS/lib/libsfml-graphics.2.5.1.dylib +0 -0
- package/third_party/sfml/platform/macOS/lib/libsfml-network.2.5.1.dylib +0 -0
- package/third_party/sfml/platform/macOS/lib/libsfml-system.2.5.1.dylib +0 -0
- package/third_party/sfml/platform/macOS/lib/libsfml-window.2.5.1.dylib +0 -0
- package/third_party/sfml/platform/win64/bin/openal32.dll +0 -0
- package/third_party/sfml/platform/win64/bin/sfml-audio-2.dll +0 -0
- package/third_party/sfml/platform/win64/bin/sfml-graphics-2.dll +0 -0
- package/third_party/sfml/platform/win64/bin/sfml-network-2.dll +0 -0
- package/third_party/sfml/platform/win64/bin/sfml-system-2.dll +0 -0
- package/third_party/sfml/platform/win64/bin/sfml-window-2.dll +0 -0
- package/third_party/sfml/platform/win64/lib/flac.lib +0 -0
- package/third_party/sfml/platform/win64/lib/freetype.lib +0 -0
- package/third_party/sfml/platform/win64/lib/ogg.lib +0 -0
- package/third_party/sfml/platform/win64/lib/openal32.lib +0 -0
- package/third_party/sfml/platform/win64/lib/sfml-audio.lib +0 -0
- package/third_party/sfml/platform/win64/lib/sfml-graphics.lib +0 -0
- package/third_party/sfml/platform/win64/lib/sfml-main.lib +0 -0
- package/third_party/sfml/platform/win64/lib/sfml-network.lib +0 -0
- package/third_party/sfml/platform/win64/lib/sfml-system.lib +0 -0
- package/third_party/sfml/platform/win64/lib/sfml-window.lib +0 -0
- package/third_party/sfml/platform/win64/lib/vorbis.lib +0 -0
- package/third_party/sfml/platform/win64/lib/vorbisenc.lib +0 -0
- package/third_party/sfml/platform/win64/lib/vorbisfile.lib +0 -0
- package/tools/symlinks.js +0 -122
package/README.md
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://github.com/XadillaX/node-sfml/blob/main/assets/sfml.js.png?raw=true" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
Node.js binding for <a href="https://www.sfml-dev.org/">SFML</a> - a Simple and Fast cross-platform Multimedia Library.
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.org/package/sfml.js">
|
|
11
|
+
<img src="http://img.shields.io/npm/v/sfml.js.svg?style=for-the-badge&colorA=FF7800&colorB=CC5600&label=NPM" />
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://www.npmjs.org/package/sfml.js">
|
|
14
|
+
<img src="http://img.shields.io/npm/dm/sfml.js.svg?style=for-the-badge&colorA=5DDB61&colorB=4BC74F&label=DOWNLOADS" />
|
|
15
|
+
</a>
|
|
16
|
+
<!-- [](https://www.npmjs.org/package/sfml.js) -->
|
|
2
17
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
3
|
-
|
|
18
|
+
<a href="#contributors-"><img src="https://img.shields.io/badge/2-ALL%20CONTRIBUTORS?style=for-the-badge&colorA=FF69b4&colorB=cc47a4&label=ALL%20CONTRIBUTORS" />
|
|
4
19
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-

|
|
11
|
-
|
|
12
|
-
A cross-platform SFML's Node.js binding.
|
|
20
|
+
<a href="https://github.com/XadillaX/node-sfml">
|
|
21
|
+
<img src="https://img.shields.io/github/stars/XadillaX/node-sfml.svg?style=for-the-badge&colorA=FBBD30&colorB=F2AA08&label=STAR" />
|
|
22
|
+
</a>
|
|
23
|
+
</p>
|
|
13
24
|
|
|
14
25
|
## Installation
|
|
15
26
|
|
|
@@ -19,9 +30,9 @@ $ npm install --save sfml.js
|
|
|
19
30
|
|
|
20
31
|
## Usage
|
|
21
32
|
|
|
22
|
-
Refer to
|
|
23
|
-
|
|
24
|
-
And SFML's official documentation: [https://www.sfml-dev.org/documentation/2.5.1/](https://www.sfml-dev.org/documentation/2.5.1/).
|
|
33
|
+
- Refer to TypeDoc: [https://sfml.js.org/](https://sfml.js.org/);
|
|
34
|
+
- Refer to Typing Definitions: [https://github.com/XadillaX/node-sfml/blob/main/index.d.ts](https://github.com/XadillaX/node-sfml/blob/main/index.d.ts);
|
|
35
|
+
- And SFML's official documentation: [https://www.sfml-dev.org/documentation/2.5.1/](https://www.sfml-dev.org/documentation/2.5.1/).
|
|
25
36
|
|
|
26
37
|
## Examples
|
|
27
38
|
|
package/binding.gyp
CHANGED
|
@@ -109,28 +109,28 @@
|
|
|
109
109
|
"copies": [{
|
|
110
110
|
"destination": "<(module_root_dir)/build/Release/",
|
|
111
111
|
"files": [
|
|
112
|
-
"<(module_root_dir)/third_party/sfml/platform/
|
|
113
|
-
"<(module_root_dir)/third_party/sfml/platform/
|
|
114
|
-
"<(module_root_dir)/third_party/sfml/platform/
|
|
115
|
-
"<(module_root_dir)/third_party/sfml/platform/
|
|
116
|
-
"<(module_root_dir)/third_party/sfml/platform/
|
|
117
|
-
"<(module_root_dir)/third_party/sfml/platform/
|
|
112
|
+
"<(module_root_dir)/third_party/sfml/platform/win/bin/openal32.dll",
|
|
113
|
+
"<(module_root_dir)/third_party/sfml/platform/win/bin/sfml-audio-2.dll",
|
|
114
|
+
"<(module_root_dir)/third_party/sfml/platform/win/bin/sfml-graphics-2.dll",
|
|
115
|
+
"<(module_root_dir)/third_party/sfml/platform/win/bin/sfml-network-2.dll",
|
|
116
|
+
"<(module_root_dir)/third_party/sfml/platform/win/bin/sfml-system-2.dll",
|
|
117
|
+
"<(module_root_dir)/third_party/sfml/platform/win/bin/sfml-window-2.dll"
|
|
118
118
|
]
|
|
119
119
|
}],
|
|
120
120
|
"libraries": [
|
|
121
|
-
"../third_party/sfml/platform/
|
|
122
|
-
"../third_party/sfml/platform/
|
|
123
|
-
"../third_party/sfml/platform/
|
|
124
|
-
"../third_party/sfml/platform/
|
|
125
|
-
"../third_party/sfml/platform/
|
|
126
|
-
"../third_party/sfml/platform/
|
|
127
|
-
"../third_party/sfml/platform/
|
|
128
|
-
"../third_party/sfml/platform/
|
|
129
|
-
"../third_party/sfml/platform/
|
|
130
|
-
"../third_party/sfml/platform/
|
|
131
|
-
"../third_party/sfml/platform/
|
|
132
|
-
"../third_party/sfml/platform/
|
|
133
|
-
"../third_party/sfml/platform/
|
|
121
|
+
"../third_party/sfml/platform/win/lib/flac.lib",
|
|
122
|
+
"../third_party/sfml/platform/win/lib/freetype.lib",
|
|
123
|
+
"../third_party/sfml/platform/win/lib/ogg.lib",
|
|
124
|
+
"../third_party/sfml/platform/win/lib/openal32.lib",
|
|
125
|
+
"../third_party/sfml/platform/win/lib/sfml-audio.lib",
|
|
126
|
+
"../third_party/sfml/platform/win/lib/sfml-graphics.lib",
|
|
127
|
+
"../third_party/sfml/platform/win/lib/sfml-main.lib",
|
|
128
|
+
"../third_party/sfml/platform/win/lib/sfml-network.lib",
|
|
129
|
+
"../third_party/sfml/platform/win/lib/sfml-system.lib",
|
|
130
|
+
"../third_party/sfml/platform/win/lib/sfml-window.lib",
|
|
131
|
+
"../third_party/sfml/platform/win/lib/vorbis.lib",
|
|
132
|
+
"../third_party/sfml/platform/win/lib/vorbisenc.lib",
|
|
133
|
+
"../third_party/sfml/platform/win/lib/vorbisfile.lib",
|
|
134
134
|
],
|
|
135
135
|
}],
|
|
136
136
|
["OS==\"mac\"", {
|
|
@@ -163,6 +163,8 @@
|
|
|
163
163
|
"./src/poll_event.cc",
|
|
164
164
|
"./src/rect.cc",
|
|
165
165
|
"./src/render_window.cc",
|
|
166
|
+
"./src/render_window_async_display.cc",
|
|
167
|
+
"./src/render_window_async_draw.cc",
|
|
166
168
|
"./src/sensor.cc",
|
|
167
169
|
"./src/touch.cc",
|
|
168
170
|
"./src/texture.cc",
|
package/lib/poll_event.d.ts
CHANGED
package/lib/render_window.d.ts
CHANGED
|
@@ -4,30 +4,56 @@ import { Event } from './poll_event';
|
|
|
4
4
|
import { Image } from './image';
|
|
5
5
|
import { VideoMode } from './video_mode';
|
|
6
6
|
import { Vector2U } from './vector2';
|
|
7
|
+
import { Vector2I } from '..';
|
|
8
|
+
|
|
9
|
+
type ContextSettings = {
|
|
10
|
+
depthBits: number;
|
|
11
|
+
stencilBits: number;
|
|
12
|
+
antialiasingLevel: number;
|
|
13
|
+
majorVersion: number;
|
|
14
|
+
minorVersion: number;
|
|
15
|
+
attributeFlags: number;
|
|
16
|
+
sRgbCapable: boolean;
|
|
17
|
+
};
|
|
7
18
|
|
|
8
19
|
export class RenderWindow {
|
|
9
|
-
constructor(
|
|
20
|
+
constructor(
|
|
21
|
+
videoMode?: VideoMode,
|
|
22
|
+
title?: string,
|
|
23
|
+
style?: RenderWindow.Style
|
|
24
|
+
);
|
|
10
25
|
|
|
26
|
+
create(windowHandle: number): void;
|
|
27
|
+
create(videoMode: VideoMode, title: string, style?: RenderWindow.Style): void;
|
|
11
28
|
capture(): Image;
|
|
12
29
|
clear(color: number | Color): void;
|
|
13
30
|
close(): void;
|
|
14
31
|
draw(content: Drawable): void;
|
|
32
|
+
drawAsync(content: Drawable): Promise<void>;
|
|
15
33
|
display(): void;
|
|
34
|
+
displayAsync(): Promise<void>;
|
|
35
|
+
|
|
36
|
+
getPosition(): Vector2I;
|
|
37
|
+
getSettings(): ContextSettings;
|
|
38
|
+
getSize(): Vector2U;
|
|
39
|
+
|
|
40
|
+
hasFocus(): boolean;
|
|
16
41
|
isOpen(): boolean;
|
|
17
42
|
|
|
18
43
|
pollEvent(): Event;
|
|
44
|
+
requestFocus(): void;
|
|
19
45
|
|
|
20
|
-
|
|
21
|
-
|
|
46
|
+
setActive(active?: boolean): void;
|
|
47
|
+
setFramerateLimit(limit: number): void;
|
|
48
|
+
setIcon(width: number, height: number, icon: Buffer): void;
|
|
49
|
+
setJoystickThreshold(threshold: number): void;
|
|
50
|
+
setKeyRepeatEnabled(enabled: boolean): void;
|
|
22
51
|
setMouseCursorVisible(visible: boolean): void;
|
|
23
52
|
setMouseCursorGrabbed(grabbed: boolean): void;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
getSize(): Vector2U;
|
|
29
|
-
|
|
30
|
-
hasFocus(): boolean;
|
|
53
|
+
setPosition(position: Vector2I): void;
|
|
54
|
+
setTitle(title: string): void;
|
|
55
|
+
setVisible(visible: boolean): void;
|
|
56
|
+
setVerticalSyncEnabled(enabled: boolean): void;
|
|
31
57
|
}
|
|
32
58
|
export namespace RenderWindow {
|
|
33
59
|
enum Style {
|
package/lib/render_window.js
CHANGED
|
@@ -7,6 +7,7 @@ const {
|
|
|
7
7
|
} = require('../build/Release/binding.node');
|
|
8
8
|
const { validateTypeOf } = require('./common');
|
|
9
9
|
const { VideoMode } = require('./video_mode');
|
|
10
|
+
const { Vector2I } = require('./vector2');
|
|
10
11
|
|
|
11
12
|
const DRAW_DRAWABLE = Symbol('RenderWindow::drawDrawable');
|
|
12
13
|
const RAW_RENDER_WINDOW = Symbol('RenderWindow::rawRenderWindow');
|
|
@@ -28,6 +29,23 @@ class RenderWindow {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
create(videoMode, title, style) {
|
|
33
|
+
if (Number.isInteger(videoMode) && videoMode >= 0) {
|
|
34
|
+
this[RAW_RENDER_WINDOW].create(videoMode);
|
|
35
|
+
} else {
|
|
36
|
+
validateTypeOf(videoMode, 'videoMode', VideoMode, false);
|
|
37
|
+
validateTypeOf(title, 'title', 'string', false);
|
|
38
|
+
validateTypeOf(style, 'style', 'number', true);
|
|
39
|
+
|
|
40
|
+
videoMode = videoMode[VideoMode.RAW_VIDEO_MODE];
|
|
41
|
+
if (style === undefined) {
|
|
42
|
+
this[RAW_RENDER_WINDOW].create(videoMode, title);
|
|
43
|
+
} else {
|
|
44
|
+
this[RAW_RENDER_WINDOW].create(videoMode, title, style);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
31
49
|
capture() {
|
|
32
50
|
return this[RAW_RENDER_WINDOW].capture();
|
|
33
51
|
}
|
|
@@ -54,10 +72,37 @@ class RenderWindow {
|
|
|
54
72
|
this[RAW_RENDER_WINDOW].drawDrawable(content._raw());
|
|
55
73
|
}
|
|
56
74
|
|
|
75
|
+
drawAsync(content) {
|
|
76
|
+
if (content instanceof Drawable) {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
this[RAW_RENDER_WINDOW].drawDrawableAsync((err, res) => {
|
|
79
|
+
err ? reject(new Error(err)) : resolve(res);
|
|
80
|
+
}, content._raw());
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return Promise.reject(new Error('Expected Drawable Instance'));
|
|
84
|
+
}
|
|
85
|
+
|
|
57
86
|
display() {
|
|
58
87
|
this[RAW_RENDER_WINDOW].display();
|
|
59
88
|
}
|
|
60
89
|
|
|
90
|
+
displayAsync() {
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
this[RAW_RENDER_WINDOW].displayAsync((err, res) => {
|
|
93
|
+
err ? reject(new Error(err)) : resolve(res);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
getPosition() {
|
|
99
|
+
return this[RAW_RENDER_WINDOW].getPosition();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
getSettings() {
|
|
103
|
+
return this[RAW_RENDER_WINDOW].getSettings();
|
|
104
|
+
}
|
|
105
|
+
|
|
61
106
|
isOpen() {
|
|
62
107
|
return this[RAW_RENDER_WINDOW].isOpen();
|
|
63
108
|
}
|
|
@@ -66,6 +111,10 @@ class RenderWindow {
|
|
|
66
111
|
return this[RAW_RENDER_WINDOW].pollEvent();
|
|
67
112
|
}
|
|
68
113
|
|
|
114
|
+
requestFocus() {
|
|
115
|
+
this[RAW_RENDER_WINDOW].requestFocus();
|
|
116
|
+
}
|
|
117
|
+
|
|
69
118
|
setVisible(visible) {
|
|
70
119
|
validateTypeOf(visible, 'visible', 'boolean');
|
|
71
120
|
this[RAW_RENDER_WINDOW].setVisible(visible);
|
|
@@ -106,6 +155,33 @@ class RenderWindow {
|
|
|
106
155
|
this[RAW_RENDER_WINDOW].setActive(active);
|
|
107
156
|
}
|
|
108
157
|
|
|
158
|
+
setIcon(width, height, icon) {
|
|
159
|
+
validateTypeOf(width, 'width', 'number', false);
|
|
160
|
+
validateTypeOf(height, 'height', 'number', false);
|
|
161
|
+
validateTypeOf(icon, 'icon', Buffer, false);
|
|
162
|
+
|
|
163
|
+
if (icon.byteLength !== 4 * width * height) {
|
|
164
|
+
throw new Error('Invalid icon size, must be 4 * width * height');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
this[RAW_RENDER_WINDOW].setIcon(width, height, icon);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
setJoystickThreshold(threshold) {
|
|
171
|
+
validateTypeOf(threshold, 'threshold', 'number', false);
|
|
172
|
+
this[RAW_RENDER_WINDOW].setJoystickThreshold(threshold);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
setPosition(position) {
|
|
176
|
+
validateTypeOf(position, 'position', Vector2I, false);
|
|
177
|
+
this[RAW_RENDER_WINDOW].setPosition(position);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
setTitle(title) {
|
|
181
|
+
validateTypeOf(title, 'title', 'string', false);
|
|
182
|
+
this[RAW_RENDER_WINDOW].setTitle(title);
|
|
183
|
+
}
|
|
184
|
+
|
|
109
185
|
getSize() {
|
|
110
186
|
return this[RAW_RENDER_WINDOW].getSize();
|
|
111
187
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sfml.js",
|
|
3
|
-
"version": "0.0.1-preview.
|
|
3
|
+
"version": "0.0.1-preview.45",
|
|
4
4
|
"description": "SFML's Node.js binding.",
|
|
5
5
|
"main": "lib/sfml.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build-dummy-debug": "node-gyp rebuild --debug && mv build/Debug build/Release",
|
|
8
8
|
"generate_compile_commands": "node-gyp -- configure -f=gyp.generator.compile_commands_json.py && mv Release/compile_commands.json compile_commands.json && rm -rf Release && rm -rf Debug",
|
|
9
9
|
"clang-format": "./tools/clang_format.js --style=file -i ./src/*.cc ./src/*.h ./src/drawable/*.cc ./src/drawable/*.h ./src/sound/*.cc ./src/sound/*.h ./src/workers/*.h",
|
|
10
|
-
"preinstall": "node tools/symlinks.js",
|
|
11
10
|
"cpplint": "./third_party/cpplint/cpplint.py src/*.* src/**/*",
|
|
12
11
|
"jslint": "./node_modules/.bin/eslint ./**/*.js",
|
|
13
|
-
"install": "node-gyp rebuild"
|
|
12
|
+
"install": "node tools/lib_downloader.js && node-gyp rebuild"
|
|
14
13
|
},
|
|
15
14
|
"repository": {
|
|
16
15
|
"type": "git",
|
|
@@ -24,8 +23,11 @@
|
|
|
24
23
|
"homepage": "https://github.com/XadillaX/node-sfml#readme",
|
|
25
24
|
"dependencies": {
|
|
26
25
|
"clang-format": "^1.4.0",
|
|
26
|
+
"download": "^8.0.0",
|
|
27
27
|
"nan": "^2.15.0",
|
|
28
|
-
"node-gyp": "^8.2.0"
|
|
28
|
+
"node-gyp": "^8.2.0",
|
|
29
|
+
"spidex": "^2.2.1",
|
|
30
|
+
"tiny-spinner": "^1.1.0"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
33
|
"@types/node": "^16.11.6",
|
|
@@ -36,6 +38,8 @@
|
|
|
36
38
|
"eslint-plugin-import": "^2.25.2",
|
|
37
39
|
"eslint-plugin-jsdoc": "^37.0.3",
|
|
38
40
|
"eslint-plugin-node": "^11.1.0",
|
|
41
|
+
"typedoc": "^0.20.14",
|
|
42
|
+
"typedoc-deno-theme": "^1.3.3",
|
|
39
43
|
"typescript": "~4.0.0"
|
|
40
44
|
},
|
|
41
45
|
"files": [
|
|
@@ -44,19 +48,7 @@
|
|
|
44
48
|
"lib/**/*",
|
|
45
49
|
"src/**/*",
|
|
46
50
|
"third_party/sfml/include/**/*",
|
|
47
|
-
"third_party/
|
|
48
|
-
"third_party/sfml/platform/linux/lib/libsfml-system.so.2.5.1",
|
|
49
|
-
"third_party/sfml/platform/linux/lib/libsfml-window.so.2.5.1",
|
|
50
|
-
"third_party/sfml/platform/linux/lib/libsfml-network.so.2.5.1",
|
|
51
|
-
"third_party/sfml/platform/linux/lib/libsfml-graphics.so.2.5.1",
|
|
52
|
-
"third_party/sfml/platform/macOS/lib/libsfml-audio.2.5.1.dylib",
|
|
53
|
-
"third_party/sfml/platform/macOS/lib/libsfml-system.2.5.1.dylib",
|
|
54
|
-
"third_party/sfml/platform/macOS/lib/libsfml-window.2.5.1.dylib",
|
|
55
|
-
"third_party/sfml/platform/macOS/lib/libsfml-network.2.5.1.dylib",
|
|
56
|
-
"third_party/sfml/platform/macOS/lib/libsfml-graphics.2.5.1.dylib",
|
|
57
|
-
"third_party/sfml/platform/macOS/Frameworks/**/*",
|
|
58
|
-
"third_party/sfml/platform/win64/lib/*.lib",
|
|
59
|
-
"third_party/sfml/platform/win64/bin/*.dll",
|
|
51
|
+
"third_party/sfm/platform/.gitkeep",
|
|
60
52
|
"tools/*",
|
|
61
53
|
"tsconfig.json"
|
|
62
54
|
]
|
package/src/render_window.cc
CHANGED
|
@@ -25,15 +25,25 @@ NAN_MODULE_INIT(RenderWindow::Init) {
|
|
|
25
25
|
|
|
26
26
|
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
|
27
27
|
|
|
28
|
+
Nan::SetPrototypeMethod(tpl, "create", Create);
|
|
28
29
|
Nan::SetPrototypeMethod(tpl, "capture", Capture);
|
|
29
30
|
Nan::SetPrototypeMethod(tpl, "clear", Clear);
|
|
30
31
|
Nan::SetPrototypeMethod(tpl, "close", Close);
|
|
31
32
|
Nan::SetPrototypeMethod(tpl, "display", Display);
|
|
33
|
+
Nan::SetPrototypeMethod(tpl, "displayAsync", DisplayAsync);
|
|
32
34
|
Nan::SetPrototypeMethod(tpl, "drawDrawable", DrawDrawable);
|
|
35
|
+
Nan::SetPrototypeMethod(tpl, "drawDrawableAsync", DrawDrawableAsync);
|
|
33
36
|
Nan::SetPrototypeMethod(tpl, "isOpen", IsOpen);
|
|
34
37
|
Nan::SetPrototypeMethod(tpl, "pollEvent", PollEvent);
|
|
35
38
|
Nan::SetPrototypeMethod(tpl, "getSize", GetSize);
|
|
36
39
|
Nan::SetPrototypeMethod(tpl, "hasFocus", HasFocus);
|
|
40
|
+
Nan::SetPrototypeMethod(tpl, "setJoystickThreshold", SetJoystickThreshold);
|
|
41
|
+
Nan::SetPrototypeMethod(tpl, "getPosition", GetPosition);
|
|
42
|
+
Nan::SetPrototypeMethod(tpl, "setPosition", SetPosition);
|
|
43
|
+
Nan::SetPrototypeMethod(tpl, "setTitle", SetTitle);
|
|
44
|
+
Nan::SetPrototypeMethod(tpl, "setIcon", SetIcon);
|
|
45
|
+
Nan::SetPrototypeMethod(tpl, "getSettings", GetSettings);
|
|
46
|
+
Nan::SetPrototypeMethod(tpl, "requestFocus", RequestFocus);
|
|
37
47
|
|
|
38
48
|
#define PRIMITIVE_VALUE_PROTOTYPE_METHOD(name, _) \
|
|
39
49
|
Nan::SetPrototypeMethod(tpl, "set" #name, Set##name);
|
|
@@ -118,10 +128,54 @@ NAN_METHOD(RenderWindow::New) {
|
|
|
118
128
|
}
|
|
119
129
|
}
|
|
120
130
|
|
|
131
|
+
window->_display_draw_mutex = new sf::Mutex();
|
|
121
132
|
window->Wrap(info.This());
|
|
122
133
|
info.GetReturnValue().Set(info.This());
|
|
123
134
|
}
|
|
124
135
|
|
|
136
|
+
NAN_METHOD(RenderWindow::Create) {
|
|
137
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
138
|
+
VideoMode* mode = nullptr;
|
|
139
|
+
Local<v8::Uint32> style;
|
|
140
|
+
Local<v8::Uint32> handle;
|
|
141
|
+
Local<String> title;
|
|
142
|
+
|
|
143
|
+
switch (info.Length()) {
|
|
144
|
+
case 1:
|
|
145
|
+
handle = info[0].As<v8::Uint32>();
|
|
146
|
+
|
|
147
|
+
window->_window->create(
|
|
148
|
+
(sf::WindowHandle)(Nan::To<sf::Uint32>(handle).FromJust()));
|
|
149
|
+
break;
|
|
150
|
+
|
|
151
|
+
case 3: {
|
|
152
|
+
style = info[2].As<v8::Uint32>();
|
|
153
|
+
// fallthrough
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
case 2: {
|
|
157
|
+
mode = Nan::ObjectWrap::Unwrap<VideoMode>(info[0].As<Object>());
|
|
158
|
+
title = info[1].As<String>();
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
default: {
|
|
163
|
+
Nan::ThrowError("Invalid arguments count.");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
Nan::Utf8String utf8_title(title);
|
|
169
|
+
std::string std_title(*utf8_title, utf8_title.length());
|
|
170
|
+
if (style.IsEmpty()) {
|
|
171
|
+
window->_window->create(mode->mode(), sf::String(std_title));
|
|
172
|
+
} else {
|
|
173
|
+
window->_window->create(mode->mode(),
|
|
174
|
+
sf::String(std_title),
|
|
175
|
+
Nan::To<sf::Uint32>(style).FromJust());
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
125
179
|
NAN_METHOD(RenderWindow::Capture) {
|
|
126
180
|
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
127
181
|
sf::Image img = window->_window->capture();
|
|
@@ -155,14 +209,52 @@ NAN_METHOD(RenderWindow::Close) {
|
|
|
155
209
|
|
|
156
210
|
NAN_METHOD(RenderWindow::Display) {
|
|
157
211
|
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
212
|
+
window->_display_draw_mutex->lock();
|
|
158
213
|
window->_window->display();
|
|
214
|
+
window->_display_draw_mutex->unlock();
|
|
159
215
|
}
|
|
160
216
|
|
|
161
217
|
NAN_METHOD(RenderWindow::DrawDrawable) {
|
|
162
218
|
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
163
219
|
drawable::Drawable* drawable =
|
|
164
220
|
Nan::ObjectWrap::Unwrap<drawable::Drawable>(info[0].As<Object>());
|
|
221
|
+
|
|
222
|
+
window->_display_draw_mutex->lock();
|
|
165
223
|
window->_window->draw(drawable->raw<sf::Drawable>());
|
|
224
|
+
window->_display_draw_mutex->unlock();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
NAN_METHOD(RenderWindow::DisplayAsync) {
|
|
228
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
229
|
+
if (!info[0]->IsFunction()) {
|
|
230
|
+
return Nan::ThrowError(
|
|
231
|
+
Nan::New("expected function callback").ToLocalChecked());
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
window->_window->setActive(false);
|
|
235
|
+
Nan::AsyncQueueWorker(new AsyncRenderWindowDisplay(
|
|
236
|
+
window->_window,
|
|
237
|
+
window->_display_draw_mutex,
|
|
238
|
+
new Nan::Callback(info[0].As<v8::Function>())));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
NAN_METHOD(RenderWindow::DrawDrawableAsync) {
|
|
242
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
243
|
+
if (!info[0]->IsFunction()) {
|
|
244
|
+
return Nan::ThrowError(
|
|
245
|
+
Nan::New("expected function callback").ToLocalChecked());
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
drawable::Drawable* drawable =
|
|
249
|
+
Nan::ObjectWrap::Unwrap<drawable::Drawable>(info[1].As<Object>());
|
|
250
|
+
|
|
251
|
+
window->_window->setActive(false);
|
|
252
|
+
Nan::AsyncQueueWorker(
|
|
253
|
+
new AsyncRenderWindowDraw(window->_window,
|
|
254
|
+
window->_display_draw_mutex,
|
|
255
|
+
&drawable->raw<sf::Drawable>(),
|
|
256
|
+
nullptr,
|
|
257
|
+
new Nan::Callback(info[0].As<v8::Function>())));
|
|
166
258
|
}
|
|
167
259
|
|
|
168
260
|
NAN_METHOD(RenderWindow::IsOpen) {
|
|
@@ -201,11 +293,96 @@ NAN_METHOD(RenderWindow::GetSize) {
|
|
|
201
293
|
info.GetReturnValue().Set(maybe_vec.ToLocalChecked());
|
|
202
294
|
}
|
|
203
295
|
|
|
296
|
+
NAN_METHOD(RenderWindow::GetPosition) {
|
|
297
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
298
|
+
sf::Vector2i vec = window->_window->getPosition();
|
|
299
|
+
|
|
300
|
+
Nan::TryCatch try_catch;
|
|
301
|
+
MaybeLocal<Value> maybe_vec =
|
|
302
|
+
vector2::Vector2I::NewRealInstance(info.GetIsolate(), vec);
|
|
303
|
+
if (maybe_vec.IsEmpty()) {
|
|
304
|
+
try_catch.ReThrow();
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
info.GetReturnValue().Set(maybe_vec.ToLocalChecked());
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
NAN_METHOD(RenderWindow::SetPosition) {
|
|
312
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
313
|
+
vector2::Vector2I* position =
|
|
314
|
+
Nan::ObjectWrap::Unwrap<vector2::Vector2I>(info[0].As<v8::Object>());
|
|
315
|
+
|
|
316
|
+
window->_window->setPosition(position->vector2());
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
NAN_METHOD(RenderWindow::SetTitle) {
|
|
320
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
321
|
+
Local<String> title = info[0].As<String>();
|
|
322
|
+
Nan::Utf8String utf8_title(title);
|
|
323
|
+
std::string std_title(*utf8_title, utf8_title.length());
|
|
324
|
+
|
|
325
|
+
window->_window->setTitle(sf::String(std_title));
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
NAN_METHOD(RenderWindow::SetIcon) {
|
|
329
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
330
|
+
sf::Uint32 width = Nan::To<sf::Uint32>(info[0]).FromJust();
|
|
331
|
+
sf::Uint32 height = Nan::To<sf::Uint32>(info[1]).FromJust();
|
|
332
|
+
v8::Local<v8::Object> pixels = info[2].As<Object>();
|
|
333
|
+
|
|
334
|
+
if (node::Buffer::HasInstance(pixels)) {
|
|
335
|
+
const sf::Uint8* buf =
|
|
336
|
+
reinterpret_cast<sf::Uint8*>(node::Buffer::Data(pixels));
|
|
337
|
+
return window->_window->setIcon(width, height, buf);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
204
341
|
NAN_METHOD(RenderWindow::HasFocus) {
|
|
205
342
|
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
206
343
|
info.GetReturnValue().Set(window->_window->hasFocus());
|
|
207
344
|
}
|
|
208
345
|
|
|
346
|
+
NAN_METHOD(RenderWindow::RequestFocus) {
|
|
347
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
348
|
+
window->_window->requestFocus();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
NAN_METHOD(RenderWindow::GetSettings) {
|
|
352
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
353
|
+
const sf::ContextSettings settings = window->_window->getSettings();
|
|
354
|
+
|
|
355
|
+
Local<Object> ret = Nan::New<Object>();
|
|
356
|
+
Nan::Set(ret,
|
|
357
|
+
Nan::New<String>("depthBits").ToLocalChecked(),
|
|
358
|
+
Nan::New(settings.depthBits));
|
|
359
|
+
Nan::Set(ret,
|
|
360
|
+
Nan::New<String>("stencilBits").ToLocalChecked(),
|
|
361
|
+
Nan::New(settings.stencilBits));
|
|
362
|
+
Nan::Set(ret,
|
|
363
|
+
Nan::New<String>("antialiasingLevel").ToLocalChecked(),
|
|
364
|
+
Nan::New(settings.antialiasingLevel));
|
|
365
|
+
Nan::Set(ret,
|
|
366
|
+
Nan::New<String>("majorVersion").ToLocalChecked(),
|
|
367
|
+
Nan::New(settings.majorVersion));
|
|
368
|
+
Nan::Set(ret,
|
|
369
|
+
Nan::New<String>("minorVersion").ToLocalChecked(),
|
|
370
|
+
Nan::New(settings.minorVersion));
|
|
371
|
+
Nan::Set(ret,
|
|
372
|
+
Nan::New<String>("attributeFlags").ToLocalChecked(),
|
|
373
|
+
Nan::New(settings.attributeFlags));
|
|
374
|
+
Nan::Set(ret,
|
|
375
|
+
Nan::New<String>("sRgbCapable").ToLocalChecked(),
|
|
376
|
+
Nan::New(settings.sRgbCapable));
|
|
377
|
+
info.GetReturnValue().Set(ret);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
NAN_METHOD(RenderWindow::SetJoystickThreshold) {
|
|
381
|
+
RenderWindow* window = Nan::ObjectWrap::Unwrap<RenderWindow>(info.Holder());
|
|
382
|
+
float threshold = static_cast<float>(Nan::To<double>(info[0]).FromJust());
|
|
383
|
+
window->_window->setJoystickThreshold(threshold);
|
|
384
|
+
}
|
|
385
|
+
|
|
209
386
|
#define SET_PRIMITIVE_VALUE(name, type) \
|
|
210
387
|
NAN_METHOD(RenderWindow::Set##name) { \
|
|
211
388
|
RenderWindow* window = \
|
package/src/render_window.h
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include <nan.h>
|
|
5
5
|
|
|
6
6
|
#include <SFML/Graphics/RenderWindow.hpp>
|
|
7
|
+
#include <SFML/System/Mutex.hpp>
|
|
7
8
|
#include <SFML/Window/Event.hpp>
|
|
8
9
|
|
|
9
10
|
namespace node_sfml {
|
|
@@ -14,19 +15,30 @@ class RenderWindow : public Nan::ObjectWrap {
|
|
|
14
15
|
static NAN_MODULE_INIT(Init);
|
|
15
16
|
|
|
16
17
|
inline sf::RenderWindow* window() { return _window; }
|
|
18
|
+
inline sf::Mutex* displayDrawMutex() { return _display_draw_mutex; }
|
|
17
19
|
|
|
18
20
|
private:
|
|
19
21
|
static NAN_METHOD(New);
|
|
20
22
|
|
|
23
|
+
static NAN_METHOD(Create);
|
|
21
24
|
static NAN_METHOD(Capture);
|
|
22
25
|
static NAN_METHOD(Clear);
|
|
23
26
|
static NAN_METHOD(Close);
|
|
24
27
|
static NAN_METHOD(Display);
|
|
28
|
+
static NAN_METHOD(DisplayAsync);
|
|
25
29
|
static NAN_METHOD(DrawDrawable);
|
|
30
|
+
static NAN_METHOD(DrawDrawableAsync);
|
|
26
31
|
static NAN_METHOD(IsOpen);
|
|
27
32
|
static NAN_METHOD(PollEvent);
|
|
28
33
|
static NAN_METHOD(GetSize);
|
|
29
34
|
static NAN_METHOD(HasFocus);
|
|
35
|
+
static NAN_METHOD(GetPosition);
|
|
36
|
+
static NAN_METHOD(SetPosition);
|
|
37
|
+
static NAN_METHOD(SetTitle);
|
|
38
|
+
static NAN_METHOD(SetJoystickThreshold);
|
|
39
|
+
static NAN_METHOD(SetIcon);
|
|
40
|
+
static NAN_METHOD(GetSettings);
|
|
41
|
+
static NAN_METHOD(RequestFocus);
|
|
30
42
|
|
|
31
43
|
#define PRIMITIVE_VALUES(V) \
|
|
32
44
|
V(Visible, bool) \
|
|
@@ -57,9 +69,42 @@ class RenderWindow : public Nan::ObjectWrap {
|
|
|
57
69
|
|
|
58
70
|
private:
|
|
59
71
|
sf::RenderWindow* _window;
|
|
72
|
+
sf::Mutex* _display_draw_mutex;
|
|
60
73
|
sf::Event _event;
|
|
61
74
|
};
|
|
62
75
|
|
|
76
|
+
class AsyncRenderWindowDisplay : public Nan::AsyncWorker {
|
|
77
|
+
public:
|
|
78
|
+
AsyncRenderWindowDisplay(sf::RenderWindow* window,
|
|
79
|
+
sf::Mutex* display_draw_mutex,
|
|
80
|
+
Nan::Callback* callback);
|
|
81
|
+
void Execute();
|
|
82
|
+
void HandleOKCallback();
|
|
83
|
+
void HandleErrorCallback();
|
|
84
|
+
|
|
85
|
+
private:
|
|
86
|
+
sf::RenderWindow* _window;
|
|
87
|
+
sf::Mutex* _display_draw_mutex;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
class AsyncRenderWindowDraw : public Nan::AsyncWorker {
|
|
91
|
+
public:
|
|
92
|
+
AsyncRenderWindowDraw(sf::RenderWindow* window,
|
|
93
|
+
sf::Mutex* display_draw_mutex,
|
|
94
|
+
sf::Drawable* drawable,
|
|
95
|
+
sf::RenderStates* render_states,
|
|
96
|
+
Nan::Callback* callback);
|
|
97
|
+
void Execute();
|
|
98
|
+
void HandleOKCallback();
|
|
99
|
+
void HandleErrorCallback();
|
|
100
|
+
|
|
101
|
+
private:
|
|
102
|
+
sf::RenderWindow* _window;
|
|
103
|
+
sf::Mutex* _display_draw_mutex;
|
|
104
|
+
sf::Drawable* _drawable;
|
|
105
|
+
sf::RenderStates* _render_states;
|
|
106
|
+
};
|
|
107
|
+
|
|
63
108
|
} // namespace render_window
|
|
64
109
|
} // namespace node_sfml
|
|
65
110
|
|