commit 89074ca417ec00732264307a6c4758a4a0f31890 Author: Sean McArdle Date: Fri Jun 15 07:30:16 2018 -0700 Initial commit with FNA-Template project. diff --git a/FNA/.gitignore b/FNA/.gitignore new file mode 100644 index 0000000..59bee9d --- /dev/null +++ b/FNA/.gitignore @@ -0,0 +1,8 @@ +bin/ +obj/ +obj_core/ +*.pidb +*.user +*.userprefs +*.suo +*.vs diff --git a/FNA/.gitmodules b/FNA/.gitmodules new file mode 100644 index 0000000..f8ac735 --- /dev/null +++ b/FNA/.gitmodules @@ -0,0 +1,15 @@ +[submodule "lib/SDL2-CS"] + path = lib/SDL2-CS + url = git://github.com/flibitijibibo/SDL2-CS.git +[submodule "lib/OpenAL-CS"] + path = lib/OpenAL-CS + url = git://github.com/flibitijibibo/OpenAL-CS.git +[submodule "lib/MojoShader-CS"] + path = lib/MojoShader-CS + url = git://github.com/flibitijibibo/MojoShader-CS.git +[submodule "lib/Vorbisfile-CS"] + path = lib/Vorbisfile-CS + url = git://github.com/flibitijibibo/Vorbisfile-CS.git +[submodule "lib/Theorafile"] + path = lib/Theorafile + url = git://github.com/FNA-XNA/Theorafile.git diff --git a/FNA/Directory.Build.props b/FNA/Directory.Build.props new file mode 100644 index 0000000..813d4bf --- /dev/null +++ b/FNA/Directory.Build.props @@ -0,0 +1,5 @@ + + + obj_core\ + + diff --git a/FNA/FNA.Core.csproj b/FNA/FNA.Core.csproj new file mode 100644 index 0000000..3b2dbdf --- /dev/null +++ b/FNA/FNA.Core.csproj @@ -0,0 +1,376 @@ + + + netstandard2.0 + x64 + + + false + FNA + Microsoft.Xna.Framework + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Always + + + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.AlphaTestEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.BasicEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.DualTextureEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.EnvironmentMapEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.SkinnedEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.SpriteEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.YUVToRGBAEffect.fxb + + + diff --git a/FNA/FNA.csproj b/FNA/FNA.csproj new file mode 100644 index 0000000..e2bc64f --- /dev/null +++ b/FNA/FNA.csproj @@ -0,0 +1,444 @@ + + + + Debug + x86 + 9.0.21022 + 2.0 + {35253CE1-C864-4CD3-8249-4D1319748E8F} + Library + Microsoft.Xna.Framework + FNA + + + True + full + False + bin\Debug + DEBUG; + prompt + 4 + x86 + False + True + + + none + True + bin\Release + prompt + 4 + x86 + False + True + + + True + full + False + bin\Debug + DEBUG; + prompt + 4 + x64 + False + True + + + none + True + bin\Release + prompt + 4 + x64 + False + True + + + True + full + False + bin\Debug + DEBUG; + prompt + 4 + False + True + + + none + True + bin\Release + prompt + 4 + False + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Always + + + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.AlphaTestEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.BasicEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.DualTextureEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.EnvironmentMapEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.SkinnedEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.SpriteEffect.fxb + + + Microsoft.Xna.Framework.Graphics.Effect.Resources.YUVToRGBAEffect.fxb + + + diff --git a/FNA/FNA.dll.config b/FNA/FNA.dll.config new file mode 100644 index 0000000..2f6d821 --- /dev/null +++ b/FNA/FNA.dll.config @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FNA/FNA.sln b/FNA/FNA.sln new file mode 100644 index 0000000..1f77149 --- /dev/null +++ b/FNA/FNA.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FNA", "FNA.csproj", "{35253CE1-C864-4CD3-8249-4D1319748E8F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + Debug|AnyCPU = Debug|AnyCPU + Release|AnyCPU = Release|AnyCPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Debug|x86.ActiveCfg = Debug|x86 + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Debug|x86.Build.0 = Debug|x86 + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|x86.ActiveCfg = Release|x86 + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|x86.Build.0 = Release|x86 + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Debug|x64.ActiveCfg = Debug|x64 + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Debug|x64.Build.0 = Debug|x64 + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|x64.ActiveCfg = Release|x64 + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|x64.Build.0 = Release|x64 + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Debug|AnyCPU.Build.0 = Debug|AnyCPU + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|AnyCPU.ActiveCfg = Release|AnyCPU + {35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|AnyCPU.Build.0 = Release|AnyCPU + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = FNA.csproj + EndGlobalSection +EndGlobal diff --git a/FNA/Makefile b/FNA/Makefile new file mode 100644 index 0000000..9f650ca --- /dev/null +++ b/FNA/Makefile @@ -0,0 +1,372 @@ +# Makefile for FNA +# Written by Ethan "flibitijibibo" Lee + +# Source Lists +SRC = \ + src/Audio/AudioCategory.cs \ + src/Audio/AudioChannels.cs \ + src/Audio/AudioDevice.cs \ + src/Audio/AudioEmitter.cs \ + src/Audio/AudioEngine.cs \ + src/Audio/AudioListener.cs \ + src/Audio/AudioStopOptions.cs \ + src/Audio/Cue.cs \ + src/Audio/CueData.cs \ + src/Audio/DynamicSoundEffectInstance.cs \ + src/Audio/InstancePlayLimitException.cs \ + src/Audio/Microphone.cs \ + src/Audio/MicrophoneState.cs \ + src/Audio/NoAudioHardwareException.cs \ + src/Audio/NoMicrophoneConnectedException.cs \ + src/Audio/RendererDetail.cs \ + src/Audio/SoundBank.cs \ + src/Audio/SoundEffect.cs \ + src/Audio/SoundEffectInstance.cs \ + src/Audio/SoundState.cs \ + src/Audio/WaveBank.cs \ + src/Audio/XACTInternal.cs \ + src/BoundingBox.cs \ + src/BoundingFrustum.cs \ + src/BoundingSphere.cs \ + src/Color.cs \ + src/ContainmentType.cs \ + src/Content/ContentExtensions.cs \ + src/Content/ContentLoadException.cs \ + src/Content/ContentManager.cs \ + src/Content/ContentReader.cs \ + src/Content/ContentReaders/AlphaTestEffectReader.cs \ + src/Content/ContentReaders/ArrayReader.cs \ + src/Content/ContentReaders/BasicEffectReader.cs \ + src/Content/ContentReaders/BooleanReader.cs \ + src/Content/ContentReaders/BoundingBoxReader.cs \ + src/Content/ContentReaders/BoundingFrustumReader.cs \ + src/Content/ContentReaders/BoundingSphereReader.cs \ + src/Content/ContentReaders/ByteReader.cs \ + src/Content/ContentReaders/CharReader.cs \ + src/Content/ContentReaders/ColorReader.cs \ + src/Content/ContentReaders/CurveReader.cs \ + src/Content/ContentReaders/DateTimeReader.cs \ + src/Content/ContentReaders/DecimalReader.cs \ + src/Content/ContentReaders/DictionaryReader.cs \ + src/Content/ContentReaders/DoubleReader.cs \ + src/Content/ContentReaders/DualTextureEffectReader.cs \ + src/Content/ContentReaders/EffectMaterialReader.cs \ + src/Content/ContentReaders/EffectReader.cs \ + src/Content/ContentReaders/EnumReader.cs \ + src/Content/ContentReaders/EnvironmentMapEffectReader.cs \ + src/Content/ContentReaders/ExternalReferenceReader.cs \ + src/Content/ContentReaders/IndexBufferReader.cs \ + src/Content/ContentReaders/Int16Reader.cs \ + src/Content/ContentReaders/Int32Reader.cs \ + src/Content/ContentReaders/Int64Reader.cs \ + src/Content/ContentReaders/ListReader.cs \ + src/Content/ContentReaders/MatrixReader.cs \ + src/Content/ContentReaders/ModelReader.cs \ + src/Content/ContentReaders/NullableReader.cs \ + src/Content/ContentReaders/PlaneReader.cs \ + src/Content/ContentReaders/PointReader.cs \ + src/Content/ContentReaders/QuaternionReader.cs \ + src/Content/ContentReaders/RayReader.cs \ + src/Content/ContentReaders/RectangleReader.cs \ + src/Content/ContentReaders/ReflectiveReader.cs \ + src/Content/ContentReaders/SByteReader.cs \ + src/Content/ContentReaders/SingleReader.cs \ + src/Content/ContentReaders/SkinnedEffectReader.cs \ + src/Content/ContentReaders/SongReader.cs \ + src/Content/ContentReaders/SoundEffectReader.cs \ + src/Content/ContentReaders/SpriteFontReader.cs \ + src/Content/ContentReaders/StringReader.cs \ + src/Content/ContentReaders/Texture2DReader.cs \ + src/Content/ContentReaders/Texture3DReader.cs \ + src/Content/ContentReaders/TextureCubeReader.cs \ + src/Content/ContentReaders/TextureReader.cs \ + src/Content/ContentReaders/TimeSpanReader.cs \ + src/Content/ContentReaders/UInt16Reader.cs \ + src/Content/ContentReaders/UInt32Reader.cs \ + src/Content/ContentReaders/UInt64Reader.cs \ + src/Content/ContentReaders/Vector2Reader.cs \ + src/Content/ContentReaders/Vector3Reader.cs \ + src/Content/ContentReaders/Vector4Reader.cs \ + src/Content/ContentReaders/VertexBufferReader.cs \ + src/Content/ContentReaders/VertexDeclarationReader.cs \ + src/Content/ContentReaders/VideoReader.cs \ + src/Content/ContentSerializerAttribute.cs \ + src/Content/ContentSerializerCollectionItemNameAttribute.cs \ + src/Content/ContentSerializerIgnoreAttribute.cs \ + src/Content/ContentSerializerRuntimeTypeAttribute.cs \ + src/Content/ContentSerializerTypeVersionAttribute.cs \ + src/Content/ContentTypeReader.cs \ + src/Content/ContentTypeReaderManager.cs \ + src/Content/LzxDecoder.cs \ + src/Content/ResourceContentManager.cs \ + src/Curve.cs \ + src/CurveContinuity.cs \ + src/CurveKey.cs \ + src/CurveKeyCollection.cs \ + src/CurveLoopType.cs \ + src/CurveTangent.cs \ + src/Design/BoundingBoxConverter.cs \ + src/Design/BoundingSphereConverter.cs \ + src/Design/ColorConverter.cs \ + src/Design/MathTypeConverter.cs \ + src/Design/MatrixConverter.cs \ + src/Design/PlaneConverter.cs \ + src/Design/PointConverter.cs \ + src/Design/QuaternionConverter.cs \ + src/Design/RayConverter.cs \ + src/Design/RectangleConverter.cs \ + src/Design/Vector2Converter.cs \ + src/Design/Vector3Converter.cs \ + src/Design/Vector4Converter.cs \ + src/DisplayOrientation.cs \ + src/DrawableGameComponent.cs \ + src/FNALoggerEXT.cs \ + src/FNAPlatform/FNAPlatform.cs \ + src/FNAPlatform/FNAWindow.cs \ + src/FNAPlatform/IALDevice.cs \ + src/FNAPlatform/IGLDevice.cs \ + src/FNAPlatform/ModernGLDevice.cs \ + src/FNAPlatform/ModernGLDevice_GL.cs \ + src/FNAPlatform/NullALDevice.cs \ + src/FNAPlatform/OpenALDevice.cs \ + src/FNAPlatform/OpenGLDevice.cs \ + src/FNAPlatform/OpenGLDevice_GL.cs \ + src/FNAPlatform/SDL2_FNAPlatform.cs \ + src/FrameworkDispatcher.cs \ + src/Game.cs \ + src/GameComponent.cs \ + src/GameComponentCollection.cs \ + src/GameComponentCollectionEventArgs.cs \ + src/GameServiceContainer.cs \ + src/GameTime.cs \ + src/GameWindow.cs \ + src/Graphics/ClearOptions.cs \ + src/Graphics/ColorWriteChannels.cs \ + src/Graphics/CubeMapFace.cs \ + src/Graphics/DepthFormat.cs \ + src/Graphics/DeviceLostException.cs \ + src/Graphics/DeviceNotResetException.cs \ + src/Graphics/DirectionalLight.cs \ + src/Graphics/DisplayMode.cs \ + src/Graphics/DisplayModeCollection.cs \ + src/Graphics/DxtUtil.cs \ + src/Graphics/Effect/Effect.cs \ + src/Graphics/Effect/EffectAnnotation.cs \ + src/Graphics/Effect/EffectAnnotationCollection.cs \ + src/Graphics/Effect/EffectMaterial.cs \ + src/Graphics/Effect/EffectParameter.cs \ + src/Graphics/Effect/EffectParameterClass.cs \ + src/Graphics/Effect/EffectParameterCollection.cs \ + src/Graphics/Effect/EffectParameterType.cs \ + src/Graphics/Effect/EffectPass.cs \ + src/Graphics/Effect/EffectPassCollection.cs \ + src/Graphics/Effect/EffectTechnique.cs \ + src/Graphics/Effect/EffectTechniqueCollection.cs \ + src/Graphics/Effect/IEffectFog.cs \ + src/Graphics/Effect/IEffectLights.cs \ + src/Graphics/Effect/IEffectMatrices.cs \ + src/Graphics/Effect/Resources.cs \ + src/Graphics/Effect/StockEffects/AlphaTestEffect.cs \ + src/Graphics/Effect/StockEffects/BasicEffect.cs \ + src/Graphics/Effect/StockEffects/DualTextureEffect.cs \ + src/Graphics/Effect/StockEffects/EffectHelpers.cs \ + src/Graphics/Effect/StockEffects/EnvironmentMapEffect.cs \ + src/Graphics/Effect/StockEffects/SkinnedEffect.cs \ + src/Graphics/Effect/StockEffects/SpriteEffect.cs \ + src/Graphics/GraphicsAdapter.cs \ + src/Graphics/GraphicsDevice.cs \ + src/Graphics/GraphicsDeviceStatus.cs \ + src/Graphics/GraphicsProfile.cs \ + src/Graphics/GraphicsResource.cs \ + src/Graphics/IGraphicsDeviceService.cs \ + src/Graphics/IRenderTarget.cs \ + src/Graphics/Model.cs \ + src/Graphics/ModelBone.cs \ + src/Graphics/ModelBoneCollection.cs \ + src/Graphics/ModelEffectCollection.cs \ + src/Graphics/ModelMesh.cs \ + src/Graphics/ModelMeshCollection.cs \ + src/Graphics/ModelMeshPart.cs \ + src/Graphics/ModelMeshPartCollection.cs \ + src/Graphics/NoSuitableGraphicsDeviceException.cs \ + src/Graphics/OcclusionQuery.cs \ + src/Graphics/PackedVector/Alpha8.cs \ + src/Graphics/PackedVector/Bgr565.cs \ + src/Graphics/PackedVector/Bgra4444.cs \ + src/Graphics/PackedVector/Bgra5551.cs \ + src/Graphics/PackedVector/Byte4.cs \ + src/Graphics/PackedVector/HalfSingle.cs \ + src/Graphics/PackedVector/HalfTypeHelper.cs \ + src/Graphics/PackedVector/HalfVector2.cs \ + src/Graphics/PackedVector/HalfVector4.cs \ + src/Graphics/PackedVector/IPackedVector.cs \ + src/Graphics/PackedVector/NormalizedByte2.cs \ + src/Graphics/PackedVector/NormalizedByte4.cs \ + src/Graphics/PackedVector/NormalizedShort2.cs \ + src/Graphics/PackedVector/NormalizedShort4.cs \ + src/Graphics/PackedVector/Rg32.cs \ + src/Graphics/PackedVector/Rgba64.cs \ + src/Graphics/PackedVector/Rgba1010102.cs \ + src/Graphics/PackedVector/Short2.cs \ + src/Graphics/PackedVector/Short4.cs \ + src/Graphics/PresentationParameters.cs \ + src/Graphics/PresentInterval.cs \ + src/Graphics/PrimitiveType.cs \ + src/Graphics/RenderTarget2D.cs \ + src/Graphics/RenderTargetBinding.cs \ + src/Graphics/RenderTargetCube.cs \ + src/Graphics/RenderTargetUsage.cs \ + src/Graphics/ResourceCreatedEventArgs.cs \ + src/Graphics/ResourceDestroyedEventArgs.cs \ + src/Graphics/SamplerStateCollection.cs \ + src/Graphics/SetDataOptions.cs \ + src/Graphics/SpriteBatch.cs \ + src/Graphics/SpriteEffects.cs \ + src/Graphics/SpriteFont.cs \ + src/Graphics/SpriteSortMode.cs \ + src/Graphics/States/Blend.cs \ + src/Graphics/States/BlendFunction.cs \ + src/Graphics/States/BlendState.cs \ + src/Graphics/States/CompareFunction.cs \ + src/Graphics/States/CullMode.cs \ + src/Graphics/States/DepthStencilState.cs \ + src/Graphics/States/FillMode.cs \ + src/Graphics/States/RasterizerState.cs \ + src/Graphics/States/SamplerState.cs \ + src/Graphics/States/StencilOperation.cs \ + src/Graphics/States/TextureAddressMode.cs \ + src/Graphics/States/TextureFilter.cs \ + src/Graphics/SurfaceFormat.cs \ + src/Graphics/Texture.cs \ + src/Graphics/Texture2D.cs \ + src/Graphics/Texture3D.cs \ + src/Graphics/TextureCollection.cs \ + src/Graphics/TextureCube.cs \ + src/Graphics/Vertices/BufferUsage.cs \ + src/Graphics/Vertices/DynamicIndexBuffer.cs \ + src/Graphics/Vertices/DynamicVertexBuffer.cs \ + src/Graphics/Vertices/IndexBuffer.cs \ + src/Graphics/Vertices/IndexElementSize.cs \ + src/Graphics/Vertices/IVertexType.cs \ + src/Graphics/Vertices/VertexBuffer.cs \ + src/Graphics/Vertices/VertexBufferBinding.cs \ + src/Graphics/Vertices/VertexDeclaration.cs \ + src/Graphics/Vertices/VertexDeclarationCache.cs \ + src/Graphics/Vertices/VertexElement.cs \ + src/Graphics/Vertices/VertexElementFormat.cs \ + src/Graphics/Vertices/VertexElementUsage.cs \ + src/Graphics/Vertices/VertexPositionColor.cs \ + src/Graphics/Vertices/VertexPositionColorTexture.cs \ + src/Graphics/Vertices/VertexPositionNormalTexture.cs \ + src/Graphics/Vertices/VertexPositionTexture.cs \ + src/Graphics/Viewport.cs \ + src/Graphics/X360TexUtil.cs \ + src/GraphicsDeviceInformation.cs \ + src/GraphicsDeviceManager.cs \ + src/IDrawable.cs \ + src/IGameComponent.cs \ + src/IGraphicsDeviceManager.cs \ + src/Input/Buttons.cs \ + src/Input/ButtonState.cs \ + src/Input/GamePad.cs \ + src/Input/GamePadButtons.cs \ + src/Input/GamePadCapabilities.cs \ + src/Input/GamePadDeadZone.cs \ + src/Input/GamePadDPad.cs \ + src/Input/GamePadState.cs \ + src/Input/GamePadThumbSticks.cs \ + src/Input/GamePadTriggers.cs \ + src/Input/GamePadType.cs \ + src/Input/Keyboard.cs \ + src/Input/KeyboardState.cs \ + src/Input/Keys.cs \ + src/Input/KeyState.cs \ + src/Input/Mouse.cs \ + src/Input/MouseState.cs \ + src/Input/TextInputEXT.cs \ + src/Input/Touch/GestureSample.cs \ + src/Input/Touch/GestureType.cs \ + src/Input/Touch/TouchCollection.cs \ + src/Input/Touch/TouchLocation.cs \ + src/Input/Touch/TouchLocationState.cs \ + src/Input/Touch/TouchPanel.cs \ + src/Input/Touch/TouchPanelCapabilities.cs \ + src/IUpdateable.cs \ + src/LaunchParameters.cs \ + src/MathHelper.cs \ + src/Matrix.cs \ + src/Media/MediaPlayer.cs \ + src/Media/MediaQueue.cs \ + src/Media/MediaState.cs \ + src/Media/SongCollection.cs \ + src/Media/VideoSoundtrackType.cs \ + src/Media/VisualizationData.cs \ + src/Media/Xiph/Song.cs \ + src/Media/Xiph/Video.cs \ + src/Media/Xiph/VideoPlayer.cs \ + src/NamespaceDocs.cs \ + src/Plane.cs \ + src/PlaneIntersectionType.cs \ + src/PlayerIndex.cs \ + src/Point.cs \ + src/PreparingDeviceSettingsEventArgs.cs \ + src/Properties/AssemblyInfo.cs \ + src/Quaternion.cs \ + src/Ray.cs \ + src/Rectangle.cs \ + src/Storage/StorageContainer.cs \ + src/Storage/StorageDevice.cs \ + src/Storage/StorageDeviceNotConnectedException.cs \ + src/TitleContainer.cs \ + src/TitleLocation.cs \ + src/Utilities/AssemblyHelper.cs \ + src/Utilities/FileHelpers.cs \ + src/Utilities/FNAInternalExtensions.cs \ + src/Vector2.cs \ + src/Vector3.cs \ + src/Vector4.cs \ + lib/SDL2-CS/src/SDL2.cs \ + lib/SDL2-CS/src/SDL2_image.cs \ + lib/OpenAL-CS/src/ALC10.cs \ + lib/OpenAL-CS/src/ALC11.cs \ + lib/OpenAL-CS/src/AL10.cs \ + lib/OpenAL-CS/src/AL11.cs \ + lib/OpenAL-CS/src/ALEXT.cs \ + lib/OpenAL-CS/src/EFX.cs \ + lib/MojoShader-CS/MojoShader.cs \ + lib/Vorbisfile-CS/Vorbisfile.cs \ + lib/Theorafile/csharp/Theorafile.cs + +RESDIR = src/Graphics/Effect/StockEffects/FXB +RESNAME = Microsoft.Xna.Framework.Graphics.Effect.Resources +RES = \ + -resource:$(RESDIR)/AlphaTestEffect.fxb,$(RESNAME).AlphaTestEffect.fxb \ + -resource:$(RESDIR)/BasicEffect.fxb,$(RESNAME).BasicEffect.fxb \ + -resource:$(RESDIR)/DualTextureEffect.fxb,$(RESNAME).DualTextureEffect.fxb \ + -resource:$(RESDIR)/EnvironmentMapEffect.fxb,$(RESNAME).EnvironmentMapEffect.fxb \ + -resource:$(RESDIR)/SkinnedEffect.fxb,$(RESNAME).SkinnedEffect.fxb \ + -resource:$(RESDIR)/SpriteEffect.fxb,$(RESNAME).SpriteEffect.fxb \ + -resource:src/Graphics/Effect/YUVToRGBA/YUVToRGBAEffect.fxb,$(RESNAME).YUVToRGBAEffect.fxb + +# Targets + +debug: clean-debug + mkdir -p bin/Debug + cp FNA.dll.config bin/Debug + dmcs /unsafe -debug -define:DEBUG -out:bin/Debug/FNA.dll -target:library $(SRC) $(RES) + +clean-debug: + rm -rf bin/Debug + +release: clean-release + mkdir -p bin/Release + cp FNA.dll.config bin/Release + dmcs /unsafe -optimize -out:bin/Release/FNA.dll -target:library $(SRC) $(RES) + +clean-release: + rm -rf bin/Release + +clean: clean-debug clean-release + rm -rf bin + +all: debug release diff --git a/FNA/README b/FNA/README new file mode 100644 index 0000000..108403c --- /dev/null +++ b/FNA/README @@ -0,0 +1,29 @@ +This is FNA, an XNA4 reimplementation that focuses solely on developing a fully +accurate XNA4 runtime for the desktop. + +Project Website: http://fna-xna.github.io/ + +License +------- +FNA is released under the Microsoft Public License. See LICENSE for details. + +FNA uses LzxDecoder.cs, released under a dual MSPL/LGPL license. +See lzxdecoder.LICENSE for details. + +FNA uses code from the unxwb project, specially released under the MonoGame +project license. See unxwb.LICENSE for details. + +FNA uses code from the Mono.Xna project, released under the MIT license. +See monoxna.LICENSE for details. + +Documentation +------------- +Documentation for FNA can be found on the FNA wiki: + +https://github.com/FNA-XNA/FNA/wiki + +Found an issue? +--------------- +Issues and patches can be reported via GitHub: + +https://github.com/FNA-XNA/FNA/issues diff --git a/FNA/gendarme/fna.ignore b/FNA/gendarme/fna.ignore new file mode 100644 index 0000000..4f81672 --- /dev/null +++ b/FNA/gendarme/fna.ignore @@ -0,0 +1,12 @@ +R: Gendarme.Rules.Design.AvoidRefAndOutParametersRule +A: FNA + +R: Gendarme.Rules.Naming.AvoidDeepNamespaceHierarchyRule +A: FNA + +# Ignore everything from the lib folder +@ sdl2.ignore +@ openal.ignore +@ mojoshader.ignore +@ vorbisfile.ignore +@ theorafile.ignore diff --git a/FNA/gendarme/mojoshader.ignore b/FNA/gendarme/mojoshader.ignore new file mode 100644 index 0000000..bd4db1a --- /dev/null +++ b/FNA/gendarme/mojoshader.ignore @@ -0,0 +1,344 @@ +R: Gendarme.Rules.Performance.AvoidConcatenatingCharsRule +M: System.Byte[] MojoShader::UTF8_ToNative(System.String) + +R: Gendarme.Rules.Design.Generic.AvoidDeclaringCustomDelegatesRule +T: MojoShader/MOJOSHADER_malloc +T: MojoShader/MOJOSHADER_free +T: MojoShader/MOJOSHADER_glGetProcAddress + +R: Gendarme.Rules.Performance.AvoidLargeStructureRule +T: MojoShader/MOJOSHADER_symbol +T: MojoShader/MOJOSHADER_preshaderInstruction +T: MojoShader/MOJOSHADER_preshader +T: MojoShader/MOJOSHADER_parseData +T: MojoShader/MOJOSHADER_effectValue +T: MojoShader/MOJOSHADER_effectState +T: MojoShader/MOJOSHADER_effectSamplerState +T: MojoShader/MOJOSHADER_effectAnnotation +T: MojoShader/MOJOSHADER_effectParam +T: MojoShader/MOJOSHADER_effectShader +T: MojoShader/MOJOSHADER_effectObject +T: MojoShader/MOJOSHADER_effect + +R: Gendarme.Rules.Naming.AvoidNonAlphanumericIdentifierRule +T: MojoShader +M: System.Int32 MojoShader::MOJOSHADER_version() +M: System.IntPtr MojoShader::MOJOSHADER_changeset() +M: System.Int32 MojoShader::MOJOSHADER_maxShaderModel(System.String) +M: System.IntPtr MojoShader::MOJOSHADER_parse(System.String,System.String,System.Byte[],System.UInt32,MojoShader/MOJOSHADER_swizzle[],System.UInt32,MojoShader/MOJOSHADER_samplerMap[],System.UInt32,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_freeParseData(System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_parsePreshader(System.Byte[],System.UInt32,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_freePreshader(System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_parseEffect(System.String,System.Byte[],System.UInt32,MojoShader/MOJOSHADER_swizzle[],System.UInt32,MojoShader/MOJOSHADER_samplerMap[],System.UInt32,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_freeEffect(System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_cloneEffect(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_effectSetRawValueHandle(System.IntPtr,System.IntPtr,System.UInt32,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_effectSetRawValueName(System.IntPtr,System.String,System.IntPtr,System.UInt32,System.UInt32) +M: System.IntPtr MojoShader::MOJOSHADER_effectGetCurrentTechnique(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_effectSetTechnique(System.IntPtr,System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_effectFindNextValidTechnique(System.IntPtr,System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_glCompileEffect(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glDeleteEffect(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glEffectBegin(System.IntPtr,System.UInt32&,System.Int32,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glEffectBeginPass(System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glEffectCommitChanges(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glEffectEndPass(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glEffectEnd(System.IntPtr) +M: System.Int32 MojoShader::MOJOSHADER_glAvailableProfiles(MojoShader/MOJOSHADER_glGetProcAddress,System.IntPtr,System.IntPtr[],System.Int32,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.String MojoShader::MOJOSHADER_glBestProfile(MojoShader/MOJOSHADER_glGetProcAddress,System.IntPtr,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_glCreateContext(System.String,MojoShader/MOJOSHADER_glGetProcAddress,System.IntPtr,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glMakeContextCurrent(System.IntPtr) +M: System.String MojoShader::MOJOSHADER_glGetError() +M: System.Int32 MojoShader::MOJOSHADER_glMaxUniforms(MojoShader/MOJOSHADER_shaderType) +M: System.IntPtr MojoShader::MOJOSHADER_glCompileShader(System.Byte[],System.UInt32,MojoShader/MOJOSHADER_swizzle[],System.UInt32,MojoShader/MOJOSHADER_samplerMap[],System.UInt32) +M: System.IntPtr MojoShader::MOJOSHADER_glGetShaderParseData(System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_glLinkProgram(System.IntPtr,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glBindProgram(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glBindShaders(System.IntPtr,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glSetVertexShaderUniformF(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetVertexShaderUniformF(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetVertexShaderUniformI(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetVertexShaderUniformI(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetVertexShaderUniformB(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetVertexShaderUniformB(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetPixelShaderUniformF(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetPixelShaderUniformF(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetPixelShaderUniformI(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetPixelShaderUniformI(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetPixelShaderUniformB(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetPixelShaderUniformB(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetLegacyBumpMapEnv(System.UInt32,System.Single,System.Single,System.Single,System.Single,System.Single,System.Single) +M: System.Int32 MojoShader::MOJOSHADER_glGetVertexAttribLocation(MojoShader/MOJOSHADER_usage,System.Int32) +M: System.Void MojoShader::MOJOSHADER_glSetVertexAttribute(MojoShader/MOJOSHADER_usage,System.Int32,System.UInt32,MojoShader/MOJOSHADER_attributeType,System.Int32,System.UInt32,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glSetVertexAttribDivisor(MojoShader/MOJOSHADER_usage,System.Int32,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glProgramReady() +M: System.Void MojoShader::MOJOSHADER_glProgramViewportFlip(System.Int32) +M: System.Void MojoShader::MOJOSHADER_glDeleteProgram(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glDeleteShader(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glDestroyContext(System.IntPtr) +T: MojoShader/MOJOSHADER_malloc +T: MojoShader/MOJOSHADER_free +T: MojoShader/MOJOSHADER_shaderType +T: MojoShader/MOJOSHADER_attributeType +T: MojoShader/MOJOSHADER_uniformType +T: MojoShader/MOJOSHADER_uniform +T: MojoShader/MOJOSHADER_constant +T: MojoShader/MOJOSHADER_samplerType +T: MojoShader/MOJOSHADER_sampler +T: MojoShader/MOJOSHADER_samplerMap +T: MojoShader/MOJOSHADER_usage +T: MojoShader/MOJOSHADER_attribute +T: MojoShader/MOJOSHADER_swizzle +T: MojoShader/MOJOSHADER_symbolRegisterSet +T: MojoShader/MOJOSHADER_symbolClass +T: MojoShader/MOJOSHADER_symbolType +T: MojoShader/MOJOSHADER_symbolTypeInfo +T: MojoShader/MOJOSHADER_symbolStructMember +T: MojoShader/MOJOSHADER_symbol +T: MojoShader/MOJOSHADER_error +T: MojoShader/MOJOSHADER_preshaderOpcode +T: MojoShader/MOJOSHADER_preshaderOperandType +T: MojoShader/MOJOSHADER_preshaderOperand +T: MojoShader/MOJOSHADER_preshaderInstruction +T: MojoShader/MOJOSHADER_preshader +T: MojoShader/MOJOSHADER_parseData +T: MojoShader/MOJOSHADER_renderStateType +T: MojoShader/MOJOSHADER_zBufferType +T: MojoShader/MOJOSHADER_fillMode +T: MojoShader/MOJOSHADER_shadeMode +T: MojoShader/MOJOSHADER_blendMode +T: MojoShader/MOJOSHADER_cullMode +T: MojoShader/MOJOSHADER_compareFunc +T: MojoShader/MOJOSHADER_fogMode +T: MojoShader/MOJOSHADER_stencilOp +T: MojoShader/MOJOSHADER_materialColorSource +T: MojoShader/MOJOSHADER_vertexBlendFlags +T: MojoShader/MOJOSHADER_patchedEdgeStyle +T: MojoShader/MOJOSHADER_debugMonitorTokens +T: MojoShader/MOJOSHADER_blendOp +T: MojoShader/MOJOSHADER_degreeType +T: MojoShader/MOJOSHADER_samplerStateType +T: MojoShader/MOJOSHADER_textureAddress +T: MojoShader/MOJOSHADER_textureFilterType +T: MojoShader/MOJOSHADER_effectValue +T: MojoShader/MOJOSHADER_effectState +T: MojoShader/MOJOSHADER_effectSamplerState +T: MojoShader/MOJOSHADER_effectAnnotation +T: MojoShader/MOJOSHADER_effectParam +T: MojoShader/MOJOSHADER_effectPass +T: MojoShader/MOJOSHADER_effectTechnique +T: MojoShader/MOJOSHADER_effectShader +T: MojoShader/MOJOSHADER_effectSamplerMap +T: MojoShader/MOJOSHADER_effectString +T: MojoShader/MOJOSHADER_effectTexture +T: MojoShader/MOJOSHADER_effectObject +T: MojoShader/MOJOSHADER_samplerStateRegister +T: MojoShader/MOJOSHADER_effectStateChanges +T: MojoShader/MOJOSHADER_effect +T: MojoShader/MOJOSHADER_glGetProcAddress + +R: Gendarme.Rules.BadPractice.AvoidVisibleConstantFieldRule +T: MojoShader + +R: Gendarme.Rules.Design.AvoidVisibleFieldsRule +T: MojoShader/MOJOSHADER_uniform +T: MojoShader/MOJOSHADER_constant +T: MojoShader/MOJOSHADER_sampler +T: MojoShader/MOJOSHADER_samplerMap +T: MojoShader/MOJOSHADER_attribute +T: MojoShader/MOJOSHADER_swizzle +T: MojoShader/MOJOSHADER_symbolTypeInfo +T: MojoShader/MOJOSHADER_symbolStructMember +T: MojoShader/MOJOSHADER_symbol +T: MojoShader/MOJOSHADER_error +T: MojoShader/MOJOSHADER_preshaderOperand +T: MojoShader/MOJOSHADER_preshaderInstruction +T: MojoShader/MOJOSHADER_preshader +T: MojoShader/MOJOSHADER_parseData +T: MojoShader/MOJOSHADER_effectValue +T: MojoShader/MOJOSHADER_effectState +T: MojoShader/MOJOSHADER_effectSamplerState +T: MojoShader/MOJOSHADER_effectAnnotation +T: MojoShader/MOJOSHADER_effectParam +T: MojoShader/MOJOSHADER_effectPass +T: MojoShader/MOJOSHADER_effectTechnique +T: MojoShader/MOJOSHADER_effectShader +T: MojoShader/MOJOSHADER_effectSamplerMap +T: MojoShader/MOJOSHADER_effectString +T: MojoShader/MOJOSHADER_effectTexture +T: MojoShader/MOJOSHADER_effectObject +T: MojoShader/MOJOSHADER_samplerStateRegister +T: MojoShader/MOJOSHADER_effectStateChanges +T: MojoShader/MOJOSHADER_effect + +R: Gendarme.Rules.Design.AvoidVisibleNestedTypesRule +T: MojoShader/MOJOSHADER_malloc +T: MojoShader/MOJOSHADER_free +T: MojoShader/MOJOSHADER_shaderType +T: MojoShader/MOJOSHADER_attributeType +T: MojoShader/MOJOSHADER_uniformType +T: MojoShader/MOJOSHADER_uniform +T: MojoShader/MOJOSHADER_constant +T: MojoShader/MOJOSHADER_constant/__FixedBuffer0 +T: MojoShader/MOJOSHADER_constant/__FixedBuffer1 +T: MojoShader/MOJOSHADER_samplerType +T: MojoShader/MOJOSHADER_sampler +T: MojoShader/MOJOSHADER_samplerMap +T: MojoShader/MOJOSHADER_usage +T: MojoShader/MOJOSHADER_attribute +T: MojoShader/MOJOSHADER_swizzle +T: MojoShader/MOJOSHADER_swizzle/__FixedBuffer2 +T: MojoShader/MOJOSHADER_symbolRegisterSet +T: MojoShader/MOJOSHADER_symbolClass +T: MojoShader/MOJOSHADER_symbolType +T: MojoShader/MOJOSHADER_symbolTypeInfo +T: MojoShader/MOJOSHADER_symbolStructMember +T: MojoShader/MOJOSHADER_symbol +T: MojoShader/MOJOSHADER_error +T: MojoShader/MOJOSHADER_preshaderOpcode +T: MojoShader/MOJOSHADER_preshaderOperandType +T: MojoShader/MOJOSHADER_preshaderOperand +T: MojoShader/MOJOSHADER_preshaderInstruction +T: MojoShader/MOJOSHADER_preshader +T: MojoShader/MOJOSHADER_parseData +T: MojoShader/MOJOSHADER_renderStateType +T: MojoShader/MOJOSHADER_zBufferType +T: MojoShader/MOJOSHADER_fillMode +T: MojoShader/MOJOSHADER_shadeMode +T: MojoShader/MOJOSHADER_blendMode +T: MojoShader/MOJOSHADER_cullMode +T: MojoShader/MOJOSHADER_compareFunc +T: MojoShader/MOJOSHADER_fogMode +T: MojoShader/MOJOSHADER_stencilOp +T: MojoShader/MOJOSHADER_materialColorSource +T: MojoShader/MOJOSHADER_vertexBlendFlags +T: MojoShader/MOJOSHADER_patchedEdgeStyle +T: MojoShader/MOJOSHADER_debugMonitorTokens +T: MojoShader/MOJOSHADER_blendOp +T: MojoShader/MOJOSHADER_degreeType +T: MojoShader/MOJOSHADER_samplerStateType +T: MojoShader/MOJOSHADER_textureAddress +T: MojoShader/MOJOSHADER_textureFilterType +T: MojoShader/MOJOSHADER_effectValue +T: MojoShader/MOJOSHADER_effectState +T: MojoShader/MOJOSHADER_effectSamplerState +T: MojoShader/MOJOSHADER_effectAnnotation +T: MojoShader/MOJOSHADER_effectParam +T: MojoShader/MOJOSHADER_effectPass +T: MojoShader/MOJOSHADER_effectTechnique +T: MojoShader/MOJOSHADER_effectShader +T: MojoShader/MOJOSHADER_effectSamplerMap +T: MojoShader/MOJOSHADER_effectString +T: MojoShader/MOJOSHADER_effectTexture +T: MojoShader/MOJOSHADER_effectObject +T: MojoShader/MOJOSHADER_samplerStateRegister +T: MojoShader/MOJOSHADER_effectStateChanges +T: MojoShader/MOJOSHADER_effect +T: MojoShader/MOJOSHADER_glGetProcAddress + +R: Gendarme.Rules.Interoperability.CentralizePInvokesIntoNativeMethodsTypeRule +M: System.Int32 MojoShader::MOJOSHADER_version() +M: System.IntPtr MojoShader::MOJOSHADER_changeset() +M: System.Int32 MojoShader::MOJOSHADER_maxShaderModel(System.Byte[]) +M: System.IntPtr MojoShader::MOJOSHADER_parse(System.Byte[],System.Byte[],System.Byte[],System.UInt32,MojoShader/MOJOSHADER_swizzle[],System.UInt32,MojoShader/MOJOSHADER_samplerMap[],System.UInt32,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_freeParseData(System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_parsePreshader(System.Byte[],System.UInt32,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_freePreshader(System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_parseEffect(System.Byte[],System.Byte[],System.UInt32,MojoShader/MOJOSHADER_swizzle[],System.UInt32,MojoShader/MOJOSHADER_samplerMap[],System.UInt32,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_freeEffect(System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_cloneEffect(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_effectSetRawValueHandle(System.IntPtr,System.IntPtr,System.UInt32,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_effectSetRawValueName(System.IntPtr,System.Byte[],System.IntPtr,System.UInt32,System.UInt32) +M: System.IntPtr MojoShader::MOJOSHADER_effectGetCurrentTechnique(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_effectSetTechnique(System.IntPtr,System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_effectFindNextValidTechnique(System.IntPtr,System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_glCompileEffect(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glDeleteEffect(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glEffectBegin(System.IntPtr,System.UInt32&,System.Int32,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glEffectBeginPass(System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glEffectCommitChanges(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glEffectEndPass(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glEffectEnd(System.IntPtr) +M: System.Int32 MojoShader::MOJOSHADER_glAvailableProfiles(MojoShader/MOJOSHADER_glGetProcAddress,System.IntPtr,System.IntPtr[],System.Int32,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.IntPtr MojoShader::INTERNAL_glBestProfile(MojoShader/MOJOSHADER_glGetProcAddress,System.IntPtr,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_glCreateContext(System.Byte[],MojoShader/MOJOSHADER_glGetProcAddress,System.IntPtr,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glMakeContextCurrent(System.IntPtr) +M: System.IntPtr MojoShader::INTERNAL_glGetError() +M: System.Int32 MojoShader::MOJOSHADER_glMaxUniforms(MojoShader/MOJOSHADER_shaderType) +M: System.IntPtr MojoShader::MOJOSHADER_glCompileShader(System.Byte[],System.UInt32,MojoShader/MOJOSHADER_swizzle[],System.UInt32,MojoShader/MOJOSHADER_samplerMap[],System.UInt32) +M: System.IntPtr MojoShader::MOJOSHADER_glGetShaderParseData(System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_glLinkProgram(System.IntPtr,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glBindProgram(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glBindShaders(System.IntPtr,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glSetVertexShaderUniformF(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetVertexShaderUniformF(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetVertexShaderUniformI(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetVertexShaderUniformI(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetVertexShaderUniformB(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetVertexShaderUniformB(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetPixelShaderUniformF(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetPixelShaderUniformF(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetPixelShaderUniformI(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetPixelShaderUniformI(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetPixelShaderUniformB(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glGetPixelShaderUniformB(System.UInt32,System.IntPtr,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glSetLegacyBumpMapEnv(System.UInt32,System.Single,System.Single,System.Single,System.Single,System.Single,System.Single) +M: System.Int32 MojoShader::MOJOSHADER_glGetVertexAttribLocation(MojoShader/MOJOSHADER_usage,System.Int32) +M: System.Void MojoShader::MOJOSHADER_glSetVertexAttribute(MojoShader/MOJOSHADER_usage,System.Int32,System.UInt32,MojoShader/MOJOSHADER_attributeType,System.Int32,System.UInt32,System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glSetVertexAttribDivisor(MojoShader/MOJOSHADER_usage,System.Int32,System.UInt32) +M: System.Void MojoShader::MOJOSHADER_glProgramReady() +M: System.Void MojoShader::MOJOSHADER_glProgramViewportFlip(System.Int32) +M: System.Void MojoShader::MOJOSHADER_glDeleteProgram(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glDeleteShader(System.IntPtr) +M: System.Void MojoShader::MOJOSHADER_glDestroyContext(System.IntPtr) + +R: Gendarme.Rules.Naming.DoNotPrefixValuesWithEnumNameRule +T: MojoShader/MOJOSHADER_usage +T: MojoShader/MOJOSHADER_stencilOp +T: MojoShader/MOJOSHADER_blendOp + +R: Gendarme.Rules.Design.MarkAssemblyWithAssemblyVersionRule +A: MojoShader-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Design.MarkAssemblyWithCLSCompliantRule +A: MojoShader-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Design.MarkAssemblyWithComVisibleRule +A: MojoShader-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Security.NativeFieldsShouldNotBeVisibleRule +T: MojoShader/MOJOSHADER_uniform +T: MojoShader/MOJOSHADER_sampler +T: MojoShader/MOJOSHADER_attribute +T: MojoShader/MOJOSHADER_symbolTypeInfo +T: MojoShader/MOJOSHADER_symbolStructMember +T: MojoShader/MOJOSHADER_symbol +T: MojoShader/MOJOSHADER_error +T: MojoShader/MOJOSHADER_preshader +T: MojoShader/MOJOSHADER_parseData +T: MojoShader/MOJOSHADER_effectValue +T: MojoShader/MOJOSHADER_effectAnnotation +T: MojoShader/MOJOSHADER_effectParam +T: MojoShader/MOJOSHADER_effectPass +T: MojoShader/MOJOSHADER_effectTechnique +T: MojoShader/MOJOSHADER_effectShader +T: MojoShader/MOJOSHADER_effectSamplerMap +T: MojoShader/MOJOSHADER_effectString +T: MojoShader/MOJOSHADER_samplerStateRegister +T: MojoShader/MOJOSHADER_effectStateChanges +T: MojoShader/MOJOSHADER_effect + +R: Gendarme.Rules.Naming.UseCorrectCasingRule +M: System.IntPtr MojoShader::MOJOSHADER_parseEffect(System.Byte[],System.Byte[],System.UInt32,MojoShader/MOJOSHADER_swizzle[],System.UInt32,MojoShader/MOJOSHADER_samplerMap[],System.UInt32,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) +M: System.IntPtr MojoShader::MOJOSHADER_parseEffect(System.String,System.Byte[],System.UInt32,MojoShader/MOJOSHADER_swizzle[],System.UInt32,MojoShader/MOJOSHADER_samplerMap[],System.UInt32,MojoShader/MOJOSHADER_malloc,MojoShader/MOJOSHADER_free,System.IntPtr) + +R: Gendarme.Rules.Naming.UseCorrectSuffixRule +T: MojoShader/MOJOSHADER_attribute +T: MojoShader/MOJOSHADER_vertexBlendFlags + +R: Gendarme.Rules.Naming.UseSingularNameInEnumsUnlessAreFlagsRule +T: MojoShader/MOJOSHADER_symbolClass +T: MojoShader/MOJOSHADER_vertexBlendFlags +T: MojoShader/MOJOSHADER_debugMonitorTokens +T: MojoShader/MOJOSHADER_textureAddress + diff --git a/FNA/gendarme/openal.ignore b/FNA/gendarme/openal.ignore new file mode 100644 index 0000000..16846eb --- /dev/null +++ b/FNA/gendarme/openal.ignore @@ -0,0 +1,326 @@ +R: Gendarme.Rules.Naming.AvoidNonAlphanumericIdentifierRule +T: OpenAL.ALC10 +T: OpenAL.ALC11 +T: OpenAL.AL10 +T: OpenAL.AL11 +T: OpenAL.ALEXT +T: OpenAL.EFX + +R: Gendarme.Rules.BadPractice.AvoidVisibleConstantFieldRule +T: OpenAL.ALC10 +T: OpenAL.ALC11 +T: OpenAL.AL10 +T: OpenAL.AL11 +T: OpenAL.ALEXT +T: OpenAL.EFX + +R: Gendarme.Rules.Interoperability.CentralizePInvokesIntoNativeMethodsTypeRule +M: System.IntPtr OpenAL.ALC10::alcCreateContext(System.IntPtr,System.Int32[]) +M: System.Boolean OpenAL.ALC10::alcMakeContextCurrent(System.IntPtr) +M: System.Void OpenAL.ALC10::alcDestroyContext(System.IntPtr) +M: System.IntPtr OpenAL.ALC10::alcGetCurrentContext() +M: System.IntPtr OpenAL.ALC10::alcGetContextsDevice(System.IntPtr) +M: System.IntPtr OpenAL.ALC10::alcOpenDevice(System.String) +M: System.Boolean OpenAL.ALC10::alcCloseDevice(System.IntPtr) +M: System.Int32 OpenAL.ALC10::alcGetError(System.IntPtr) +M: System.IntPtr OpenAL.ALC10::alcGetProcAddress(System.IntPtr,System.String) +M: System.Int32 OpenAL.ALC10::alcGetEnumValue(System.IntPtr,System.String) +M: System.IntPtr OpenAL.ALC10::alcGetString(System.IntPtr,System.Int32) +M: System.Void OpenAL.ALC10::alcGetIntegerv(System.IntPtr,System.Int32,System.Int32,System.Int32[]) +M: System.Void OpenAL.ALC11::alcProcessContext(System.IntPtr) +M: System.Void OpenAL.ALC11::alcSuspendContext(System.IntPtr) +M: System.Boolean OpenAL.ALC11::alcIsExtensionPresent(System.IntPtr,System.String) +M: System.IntPtr OpenAL.ALC11::alcCaptureOpenDevice(System.String,System.UInt32,System.Int32,System.Int32) +M: System.Boolean OpenAL.ALC11::alcCaptureCloseDevice(System.IntPtr) +M: System.Void OpenAL.ALC11::alcCaptureStart(System.IntPtr) +M: System.Void OpenAL.ALC11::alcCaptureStop(System.IntPtr) +M: System.Void OpenAL.ALC11::alcCaptureSamples(System.IntPtr,System.IntPtr,System.Int32) +M: System.Void OpenAL.AL10::alDopplerFactor(System.Single) +M: System.Void OpenAL.AL10::alDistanceModel(System.Int32) +M: System.Void OpenAL.AL10::alEnable(System.Int32) +M: System.Void OpenAL.AL10::alDisable(System.Int32) +M: System.Boolean OpenAL.AL10::alIsEnabled(System.Int32) +M: System.IntPtr OpenAL.AL10::INTERNAL_alGetString(System.Int32) +M: System.Void OpenAL.AL10::alGetBooleanv(System.Int32,System.Boolean[]) +M: System.Void OpenAL.AL10::alGetIntegerv(System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alGetFloatv(System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alGetDoublev(System.Int32,System.Double[]) +M: System.Boolean OpenAL.AL10::alGetBoolean(System.Int32) +M: System.Int32 OpenAL.AL10::alGetInteger(System.Int32) +M: System.Single OpenAL.AL10::alGetFloat(System.Int32) +M: System.Double OpenAL.AL10::alGetDouble(System.Int32) +M: System.Int32 OpenAL.AL10::alGetError() +M: System.Boolean OpenAL.AL10::alIsExtensionPresent(System.String) +M: System.IntPtr OpenAL.AL10::alGetProcAddress(System.String) +M: System.Int32 OpenAL.AL10::alGetEnumValue(System.String) +M: System.Void OpenAL.AL10::alListenerf(System.Int32,System.Single) +M: System.Void OpenAL.AL10::alListener3f(System.Int32,System.Single,System.Single,System.Single) +M: System.Void OpenAL.AL10::alListenerfv(System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alListeneri(System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alListener3i(System.Int32,System.Int32,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alListeneriv(System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alGetListenerf(System.Int32,System.Single&) +M: System.Void OpenAL.AL10::alGetListener3f(System.Int32,System.Single&,System.Single&,System.Single&) +M: System.Void OpenAL.AL10::alGetListenerfv(System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alGetListeneri(System.Int32,System.Int32&) +M: System.Void OpenAL.AL10::alGetListener3i(System.Int32,System.Int32&,System.Int32&,System.Int32&) +M: System.Void OpenAL.AL10::alGetListeneriv(System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alGenSources(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alGenSources(System.Int32,System.UInt32&) +M: System.Void OpenAL.AL10::alDeleteSources(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alDeleteSources(System.Int32,System.UInt32&) +M: System.Boolean OpenAL.AL10::alIsSource(System.UInt32) +M: System.Void OpenAL.AL10::alSourcef(System.UInt32,System.Int32,System.Single) +M: System.Void OpenAL.AL10::alSource3f(System.UInt32,System.Int32,System.Single,System.Single,System.Single) +M: System.Void OpenAL.AL10::alSourcefv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alSourcei(System.UInt32,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alSource3i(System.UInt32,System.Int32,System.Int32,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alSourceiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alGetSourcef(System.UInt32,System.Int32,System.Single&) +M: System.Void OpenAL.AL10::alGetSource3f(System.UInt32,System.Int32,System.Single&,System.Single&,System.Single&) +M: System.Void OpenAL.AL10::alGetSourcefv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alGetSourcei(System.UInt32,System.Int32,System.Int32&) +M: System.Void OpenAL.AL10::alGetSource3i(System.UInt32,System.Int32,System.Int32&,System.Int32&,System.Int32&) +M: System.Void OpenAL.AL10::alGetSourceiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alSourcePlayv(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourceStopv(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourceRewindv(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourcePausev(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourcePlay(System.UInt32) +M: System.Void OpenAL.AL10::alSourceStop(System.UInt32) +M: System.Void OpenAL.AL10::alSourceRewind(System.UInt32) +M: System.Void OpenAL.AL10::alSourcePause(System.UInt32) +M: System.Void OpenAL.AL10::alSourceQueueBuffers(System.UInt32,System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourceQueueBuffers(System.UInt32,System.Int32,System.UInt32&) +M: System.Void OpenAL.AL10::alSourceUnqueueBuffers(System.UInt32,System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourceUnqueueBuffers(System.UInt32,System.Int32,System.UInt32&) +M: System.Void OpenAL.AL10::alGenBuffers(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alGenBuffers(System.Int32,System.UInt32&) +M: System.Void OpenAL.AL10::alDeleteBuffers(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alDeleteBuffers(System.Int32,System.UInt32&) +M: System.Boolean OpenAL.AL10::alIsBuffer(System.UInt32) +M: System.Void OpenAL.AL10::alBufferData(System.UInt32,System.Int32,System.IntPtr,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBufferData(System.UInt32,System.Int32,System.Byte[],System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBufferData(System.UInt32,System.Int32,System.Int16[],System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBufferData(System.UInt32,System.Int32,System.Single[],System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBufferf(System.UInt32,System.Int32,System.Single) +M: System.Void OpenAL.AL10::alBuffer3f(System.UInt32,System.Int32,System.Single,System.Single,System.Single) +M: System.Void OpenAL.AL10::alBufferfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alBufferi(System.UInt32,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBuffer3i(System.UInt32,System.Int32,System.Int32,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBufferiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alGetBufferf(System.UInt32,System.Int32,System.Single&) +M: System.Void OpenAL.AL10::alGetBuffer3f(System.UInt32,System.Int32,System.Single&,System.Single&,System.Single&) +M: System.Void OpenAL.AL10::alGetBufferfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alGetBufferi(System.UInt32,System.Int32,System.Int32&) +M: System.Void OpenAL.AL10::alGetBuffer3i(System.UInt32,System.Int32,System.Int32&,System.Int32&,System.Int32&) +M: System.Void OpenAL.AL10::alGetBufferiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.AL11::alSpeedOfSound(System.Single) +M: System.Void OpenAL.ALEXT::alGetBufferSamplesSOFT(System.UInt32,System.Int32,System.Int32,System.Int32,System.Int32,System.IntPtr) +M: System.Void OpenAL.EFX::alGenEffects(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alGenEffects(System.Int32,System.UInt32&) +M: System.Void OpenAL.EFX::alDeleteEffects(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alDeleteEffects(System.Int32,System.UInt32&) +M: System.Boolean OpenAL.EFX::alIsEffect(System.UInt32) +M: System.Void OpenAL.EFX::alEffecti(System.UInt32,System.Int32,System.Int32) +M: System.Void OpenAL.EFX::alEffectiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alEffectf(System.UInt32,System.Int32,System.Single) +M: System.Void OpenAL.EFX::alEffectfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.EFX::alGetEffecti(System.UInt32,System.Int32,System.Int32&) +M: System.Void OpenAL.EFX::alGetEffectiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alGetEffectf(System.UInt32,System.Int32,System.Single&) +M: System.Void OpenAL.EFX::alGetEffectfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.EFX::alGenFilters(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alGenFilters(System.Int32,System.UInt32&) +M: System.Void OpenAL.EFX::alDeleteFilters(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alDeleteFilters(System.Int32,System.UInt32&) +M: System.Boolean OpenAL.EFX::alIsFilter(System.UInt32) +M: System.Void OpenAL.EFX::alFilteri(System.UInt32,System.Int32,System.Int32) +M: System.Void OpenAL.EFX::alFilteriv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alFilterf(System.UInt32,System.Int32,System.Single) +M: System.Void OpenAL.EFX::alFilterfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.EFX::alGetFilteri(System.UInt32,System.Int32,System.Int32&) +M: System.Void OpenAL.EFX::alGetFilteriv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alGetFilterf(System.UInt32,System.Int32,System.Single&) +M: System.Void OpenAL.EFX::alGetFilterfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.EFX::alGenAuxiliaryEffectSlots(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alGenAuxiliaryEffectSlots(System.Int32,System.UInt32&) +M: System.Void OpenAL.EFX::alDeleteAuxiliaryEffectSlots(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alDeleteAuxiliaryEffectSlots(System.Int32,System.UInt32&) +M: System.Boolean OpenAL.EFX::alIsAuxiliaryEffectSlot(System.UInt32) +M: System.Void OpenAL.EFX::alAuxiliaryEffectSloti(System.UInt32,System.Int32,System.Int32) +M: System.Void OpenAL.EFX::alAuxiliaryEffectSlotiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alAuxiliaryEffectSlotf(System.UInt32,System.Int32,System.Single) +M: System.Void OpenAL.EFX::alAuxiliaryEffectSlotfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.EFX::alGetAuxiliaryEffectSloti(System.UInt32,System.Int32,System.Int32&) +M: System.Void OpenAL.EFX::alGetAuxiliaryEffectSlotiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alGetAuxiliaryEffectSlotf(System.UInt32,System.Int32,System.Single&) +M: System.Void OpenAL.EFX::alGetAuxiliaryEffectSlotfv(System.UInt32,System.Int32,System.Single[]) + +R: Gendarme.Rules.Design.MarkAssemblyWithAssemblyVersionRule +A: OpenAL-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Design.MarkAssemblyWithCLSCompliantRule +A: OpenAL-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Design.MarkAssemblyWithComVisibleRule +A: OpenAL-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Interoperability.MarshalBooleansInPInvokeDeclarationsRule +M: System.Boolean OpenAL.ALC10::alcMakeContextCurrent(System.IntPtr) +M: System.Boolean OpenAL.ALC10::alcCloseDevice(System.IntPtr) +M: System.Boolean OpenAL.ALC11::alcIsExtensionPresent(System.IntPtr,System.String) +M: System.Boolean OpenAL.ALC11::alcCaptureCloseDevice(System.IntPtr) +M: System.Boolean OpenAL.AL10::alIsEnabled(System.Int32) +M: System.Void OpenAL.AL10::alGetBooleanv(System.Int32,System.Boolean[]) +M: System.Boolean OpenAL.AL10::alGetBoolean(System.Int32) +M: System.Boolean OpenAL.AL10::alIsExtensionPresent(System.String) +M: System.Boolean OpenAL.AL10::alIsSource(System.UInt32) +M: System.Boolean OpenAL.AL10::alIsBuffer(System.UInt32) +M: System.Boolean OpenAL.EFX::alIsEffect(System.UInt32) +M: System.Boolean OpenAL.EFX::alIsFilter(System.UInt32) +M: System.Boolean OpenAL.EFX::alIsAuxiliaryEffectSlot(System.UInt32) + +R: Gendarme.Rules.Naming.UseCorrectCasingRule +M: System.IntPtr OpenAL.ALC10::alcCreateContext(System.IntPtr,System.Int32[]) +M: System.Boolean OpenAL.ALC10::alcMakeContextCurrent(System.IntPtr) +M: System.Void OpenAL.ALC10::alcDestroyContext(System.IntPtr) +M: System.IntPtr OpenAL.ALC10::alcGetCurrentContext() +M: System.IntPtr OpenAL.ALC10::alcGetContextsDevice(System.IntPtr) +M: System.IntPtr OpenAL.ALC10::alcOpenDevice(System.String) +M: System.Boolean OpenAL.ALC10::alcCloseDevice(System.IntPtr) +M: System.Int32 OpenAL.ALC10::alcGetError(System.IntPtr) +M: System.IntPtr OpenAL.ALC10::alcGetProcAddress(System.IntPtr,System.String) +M: System.Int32 OpenAL.ALC10::alcGetEnumValue(System.IntPtr,System.String) +M: System.IntPtr OpenAL.ALC10::alcGetString(System.IntPtr,System.Int32) +M: System.Void OpenAL.ALC10::alcGetIntegerv(System.IntPtr,System.Int32,System.Int32,System.Int32[]) +M: System.Void OpenAL.ALC11::alcProcessContext(System.IntPtr) +M: System.Void OpenAL.ALC11::alcSuspendContext(System.IntPtr) +M: System.Boolean OpenAL.ALC11::alcIsExtensionPresent(System.IntPtr,System.String) +M: System.IntPtr OpenAL.ALC11::alcCaptureOpenDevice(System.String,System.UInt32,System.Int32,System.Int32) +M: System.Boolean OpenAL.ALC11::alcCaptureCloseDevice(System.IntPtr) +M: System.Void OpenAL.ALC11::alcCaptureStart(System.IntPtr) +M: System.Void OpenAL.ALC11::alcCaptureStop(System.IntPtr) +M: System.Void OpenAL.ALC11::alcCaptureSamples(System.IntPtr,System.IntPtr,System.Int32) +M: System.Void OpenAL.AL10::alDopplerFactor(System.Single) +M: System.Void OpenAL.AL10::alDistanceModel(System.Int32) +M: System.Void OpenAL.AL10::alEnable(System.Int32) +M: System.Void OpenAL.AL10::alDisable(System.Int32) +M: System.Boolean OpenAL.AL10::alIsEnabled(System.Int32) +M: System.String OpenAL.AL10::alGetString(System.Int32) +M: System.Void OpenAL.AL10::alGetBooleanv(System.Int32,System.Boolean[]) +M: System.Void OpenAL.AL10::alGetIntegerv(System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alGetFloatv(System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alGetDoublev(System.Int32,System.Double[]) +M: System.Boolean OpenAL.AL10::alGetBoolean(System.Int32) +M: System.Int32 OpenAL.AL10::alGetInteger(System.Int32) +M: System.Single OpenAL.AL10::alGetFloat(System.Int32) +M: System.Double OpenAL.AL10::alGetDouble(System.Int32) +M: System.Int32 OpenAL.AL10::alGetError() +M: System.Boolean OpenAL.AL10::alIsExtensionPresent(System.String) +M: System.IntPtr OpenAL.AL10::alGetProcAddress(System.String) +M: System.Int32 OpenAL.AL10::alGetEnumValue(System.String) +M: System.Void OpenAL.AL10::alListenerf(System.Int32,System.Single) +M: System.Void OpenAL.AL10::alListener3f(System.Int32,System.Single,System.Single,System.Single) +M: System.Void OpenAL.AL10::alListenerfv(System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alListeneri(System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alListener3i(System.Int32,System.Int32,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alListeneriv(System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alGetListenerf(System.Int32,System.Single&) +M: System.Void OpenAL.AL10::alGetListener3f(System.Int32,System.Single&,System.Single&,System.Single&) +M: System.Void OpenAL.AL10::alGetListenerfv(System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alGetListeneri(System.Int32,System.Int32&) +M: System.Void OpenAL.AL10::alGetListener3i(System.Int32,System.Int32&,System.Int32&,System.Int32&) +M: System.Void OpenAL.AL10::alGetListeneriv(System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alGenSources(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alGenSources(System.Int32,System.UInt32&) +M: System.Void OpenAL.AL10::alDeleteSources(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alDeleteSources(System.Int32,System.UInt32&) +M: System.Boolean OpenAL.AL10::alIsSource(System.UInt32) +M: System.Void OpenAL.AL10::alSourcef(System.UInt32,System.Int32,System.Single) +M: System.Void OpenAL.AL10::alSource3f(System.UInt32,System.Int32,System.Single,System.Single,System.Single) +M: System.Void OpenAL.AL10::alSourcefv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alSourcei(System.UInt32,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alSource3i(System.UInt32,System.Int32,System.Int32,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alSourceiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alGetSourcef(System.UInt32,System.Int32,System.Single&) +M: System.Void OpenAL.AL10::alGetSource3f(System.UInt32,System.Int32,System.Single&,System.Single&,System.Single&) +M: System.Void OpenAL.AL10::alGetSourcefv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alGetSourcei(System.UInt32,System.Int32,System.Int32&) +M: System.Void OpenAL.AL10::alGetSource3i(System.UInt32,System.Int32,System.Int32&,System.Int32&,System.Int32&) +M: System.Void OpenAL.AL10::alGetSourceiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alSourcePlayv(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourceStopv(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourceRewindv(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourcePausev(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourcePlay(System.UInt32) +M: System.Void OpenAL.AL10::alSourceStop(System.UInt32) +M: System.Void OpenAL.AL10::alSourceRewind(System.UInt32) +M: System.Void OpenAL.AL10::alSourcePause(System.UInt32) +M: System.Void OpenAL.AL10::alSourceQueueBuffers(System.UInt32,System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourceQueueBuffers(System.UInt32,System.Int32,System.UInt32&) +M: System.Void OpenAL.AL10::alSourceUnqueueBuffers(System.UInt32,System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alSourceUnqueueBuffers(System.UInt32,System.Int32,System.UInt32&) +M: System.Void OpenAL.AL10::alGenBuffers(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alGenBuffers(System.Int32,System.UInt32&) +M: System.Void OpenAL.AL10::alDeleteBuffers(System.Int32,System.UInt32[]) +M: System.Void OpenAL.AL10::alDeleteBuffers(System.Int32,System.UInt32&) +M: System.Boolean OpenAL.AL10::alIsBuffer(System.UInt32) +M: System.Void OpenAL.AL10::alBufferData(System.UInt32,System.Int32,System.IntPtr,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBufferData(System.UInt32,System.Int32,System.Byte[],System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBufferData(System.UInt32,System.Int32,System.Int16[],System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBufferData(System.UInt32,System.Int32,System.Single[],System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBufferf(System.UInt32,System.Int32,System.Single) +M: System.Void OpenAL.AL10::alBuffer3f(System.UInt32,System.Int32,System.Single,System.Single,System.Single) +M: System.Void OpenAL.AL10::alBufferfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alBufferi(System.UInt32,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBuffer3i(System.UInt32,System.Int32,System.Int32,System.Int32,System.Int32) +M: System.Void OpenAL.AL10::alBufferiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.AL10::alGetBufferf(System.UInt32,System.Int32,System.Single&) +M: System.Void OpenAL.AL10::alGetBuffer3f(System.UInt32,System.Int32,System.Single&,System.Single&,System.Single&) +M: System.Void OpenAL.AL10::alGetBufferfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.AL10::alGetBufferi(System.UInt32,System.Int32,System.Int32&) +M: System.Void OpenAL.AL10::alGetBuffer3i(System.UInt32,System.Int32,System.Int32&,System.Int32&,System.Int32&) +M: System.Void OpenAL.AL10::alGetBufferiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.AL11::alSpeedOfSound(System.Single) +M: System.Void OpenAL.ALEXT::alGetBufferSamplesSOFT(System.UInt32,System.Int32,System.Int32,System.Int32,System.Int32,System.IntPtr) +M: System.Void OpenAL.EFX::alGenEffects(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alGenEffects(System.Int32,System.UInt32&) +M: System.Void OpenAL.EFX::alDeleteEffects(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alDeleteEffects(System.Int32,System.UInt32&) +M: System.Boolean OpenAL.EFX::alIsEffect(System.UInt32) +M: System.Void OpenAL.EFX::alEffecti(System.UInt32,System.Int32,System.Int32) +M: System.Void OpenAL.EFX::alEffectiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alEffectf(System.UInt32,System.Int32,System.Single) +M: System.Void OpenAL.EFX::alEffectfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.EFX::alGetEffecti(System.UInt32,System.Int32,System.Int32&) +M: System.Void OpenAL.EFX::alGetEffectiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alGetEffectf(System.UInt32,System.Int32,System.Single&) +M: System.Void OpenAL.EFX::alGetEffectfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.EFX::alGenFilters(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alGenFilters(System.Int32,System.UInt32&) +M: System.Void OpenAL.EFX::alDeleteFilters(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alDeleteFilters(System.Int32,System.UInt32&) +M: System.Boolean OpenAL.EFX::alIsFilter(System.UInt32) +M: System.Void OpenAL.EFX::alFilteri(System.UInt32,System.Int32,System.Int32) +M: System.Void OpenAL.EFX::alFilteriv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alFilterf(System.UInt32,System.Int32,System.Single) +M: System.Void OpenAL.EFX::alFilterfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.EFX::alGetFilteri(System.UInt32,System.Int32,System.Int32&) +M: System.Void OpenAL.EFX::alGetFilteriv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alGetFilterf(System.UInt32,System.Int32,System.Single&) +M: System.Void OpenAL.EFX::alGetFilterfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.EFX::alGenAuxiliaryEffectSlots(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alGenAuxiliaryEffectSlots(System.Int32,System.UInt32&) +M: System.Void OpenAL.EFX::alDeleteAuxiliaryEffectSlots(System.Int32,System.UInt32[]) +M: System.Void OpenAL.EFX::alDeleteAuxiliaryEffectSlots(System.Int32,System.UInt32&) +M: System.Boolean OpenAL.EFX::alIsAuxiliaryEffectSlot(System.UInt32) +M: System.Void OpenAL.EFX::alAuxiliaryEffectSloti(System.UInt32,System.Int32,System.Int32) +M: System.Void OpenAL.EFX::alAuxiliaryEffectSlotiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alAuxiliaryEffectSlotf(System.UInt32,System.Int32,System.Single) +M: System.Void OpenAL.EFX::alAuxiliaryEffectSlotfv(System.UInt32,System.Int32,System.Single[]) +M: System.Void OpenAL.EFX::alGetAuxiliaryEffectSloti(System.UInt32,System.Int32,System.Int32&) +M: System.Void OpenAL.EFX::alGetAuxiliaryEffectSlotiv(System.UInt32,System.Int32,System.Int32[]) +M: System.Void OpenAL.EFX::alGetAuxiliaryEffectSlotf(System.UInt32,System.Int32,System.Single&) +M: System.Void OpenAL.EFX::alGetAuxiliaryEffectSlotfv(System.UInt32,System.Int32,System.Single[]) + diff --git a/FNA/gendarme/runGendarme.sh b/FNA/gendarme/runGendarme.sh new file mode 100755 index 0000000..9019789 --- /dev/null +++ b/FNA/gendarme/runGendarme.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Filename of the FNA assembly output +ASSEMBLYNAME="../bin/Debug/FNA.dll" + +# Move to script's directory +cd "`dirname "$0"`" + +# Run Gendarme using the FNA ruleset +gendarme --ignore fna.ignore --html gendarme.html $ASSEMBLYNAME diff --git a/FNA/gendarme/sdl2.ignore b/FNA/gendarme/sdl2.ignore new file mode 100644 index 0000000..ccce59f --- /dev/null +++ b/FNA/gendarme/sdl2.ignore @@ -0,0 +1,1722 @@ +R: Gendarme.Rules.Performance.AvoidConcatenatingCharsRule +M: System.Byte[] SDL2.SDL::UTF8_ToNative(System.String) +M: System.IntPtr SDL2.SDL::INTERNAL_AllocUTF8(System.String) + +R: Gendarme.Rules.Design.Generic.AvoidDeclaringCustomDelegatesRule +T: SDL2.SDL/SDL_WinRT_mainFunction +T: SDL2.SDL/SDL_LogOutputFunction +T: SDL2.SDL/SDL_HitTest +T: SDL2.SDL/SDL_EventFilter +T: SDL2.SDL/SDL_AudioCallback +T: SDL2.SDL/SDL_TimerCallback +T: SDL2.SDL_mixer/MixFuncDelegate +T: SDL2.SDL_mixer/Mix_EffectFunc_t +T: SDL2.SDL_mixer/Mix_EffectDone_t +T: SDL2.SDL_mixer/MusicFinishedDelegate +T: SDL2.SDL_mixer/ChannelFinishedDelegate +T: SDL2.SDL_mixer/SoundFontDelegate + +R: Gendarme.Rules.Performance.AvoidLargeStructureRule +T: SDL2.SDL/SDL_PixelFormat +T: SDL2.SDL/SDL_Surface +T: SDL2.SDL/SDL_MouseMotionEvent +T: SDL2.SDL/SDL_TouchFingerEvent +T: SDL2.SDL/SDL_MultiGestureEvent +T: SDL2.SDL/SDL_DollarGestureEvent +T: SDL2.SDL/SDL_Event +T: SDL2.SDL/SDL_HapticPeriodic +T: SDL2.SDL/SDL_HapticCondition +T: SDL2.SDL/SDL_HapticRamp +T: SDL2.SDL/SDL_HapticCustom +T: SDL2.SDL/SDL_HapticEffect +T: SDL2.SDL/INTERNAL_SysWMDriverUnion +T: SDL2.SDL/SDL_SysWMinfo + +R: Gendarme.Rules.Naming.AvoidNonAlphanumericIdentifierRule +T: SDL2.SDL +M: System.UInt32 SDL2.SDL::SDL_FOURCC(System.Byte,System.Byte,System.Byte,System.Byte) +M: System.IntPtr SDL2.SDL::SDL_RWFromMem(System.IntPtr,System.Int32) +M: System.Void SDL2.SDL::SDL_SetMainReady() +M: System.Int32 SDL2.SDL::SDL_WinRTRunApp(SDL2.SDL/SDL_WinRT_mainFunction,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_Init(System.UInt32) +M: System.Int32 SDL2.SDL::SDL_InitSubSystem(System.UInt32) +M: System.Void SDL2.SDL::SDL_Quit() +M: System.Void SDL2.SDL::SDL_QuitSubSystem(System.UInt32) +M: System.UInt32 SDL2.SDL::SDL_WasInit(System.UInt32) +M: System.String SDL2.SDL::SDL_GetPlatform() +M: System.Void SDL2.SDL::SDL_ClearHints() +M: System.String SDL2.SDL::SDL_GetHint(System.String) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_SetHint(System.String,System.String) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_SetHintWithPriority(System.String,System.String,SDL2.SDL/SDL_HintPriority) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GetHintBoolean(System.String,SDL2.SDL/SDL_bool) +M: System.Void SDL2.SDL::SDL_ClearError() +M: System.String SDL2.SDL::SDL_GetError() +M: System.Void SDL2.SDL::SDL_SetError(System.String) +M: System.Void SDL2.SDL::SDL_Log(System.String) +M: System.Void SDL2.SDL::SDL_LogVerbose(System.Int32,System.String) +M: System.Void SDL2.SDL::SDL_LogDebug(System.Int32,System.String) +M: System.Void SDL2.SDL::SDL_LogInfo(System.Int32,System.String) +M: System.Void SDL2.SDL::SDL_LogWarn(System.Int32,System.String) +M: System.Void SDL2.SDL::SDL_LogError(System.Int32,System.String) +M: System.Void SDL2.SDL::SDL_LogCritical(System.Int32,System.String) +M: System.Void SDL2.SDL::SDL_LogMessage(System.Int32,SDL2.SDL/SDL_LogPriority,System.String) +M: System.Void SDL2.SDL::SDL_LogMessageV(System.Int32,SDL2.SDL/SDL_LogPriority,System.String) +M: SDL2.SDL/SDL_LogPriority SDL2.SDL::SDL_LogGetPriority(System.Int32) +M: System.Void SDL2.SDL::SDL_LogSetPriority(System.Int32,SDL2.SDL/SDL_LogPriority) +M: System.Void SDL2.SDL::SDL_LogSetAllPriority(SDL2.SDL/SDL_LogPriority) +M: System.Void SDL2.SDL::SDL_LogResetPriorities() +M: System.Void SDL2.SDL::SDL_LogGetOutputFunction(SDL2.SDL/SDL_LogOutputFunction&,System.IntPtr&) +M: System.Void SDL2.SDL::SDL_LogSetOutputFunction(SDL2.SDL/SDL_LogOutputFunction,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_ShowMessageBox(SDL2.SDL/SDL_MessageBoxData&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_ShowSimpleMessageBox(SDL2.SDL/SDL_MessageBoxFlags,System.String,System.String,System.IntPtr) +M: System.Void SDL2.SDL::SDL_VERSION(SDL2.SDL/SDL_version&) +M: System.Int32 SDL2.SDL::SDL_VERSIONNUM(System.Int32,System.Int32,System.Int32) +M: System.Boolean SDL2.SDL::SDL_VERSION_ATLEAST(System.Int32,System.Int32,System.Int32) +M: System.Void SDL2.SDL::SDL_GetVersion(SDL2.SDL/SDL_version&) +M: System.String SDL2.SDL::SDL_GetRevision() +M: System.Int32 SDL2.SDL::SDL_GetRevisionNumber() +M: System.Int32 SDL2.SDL::SDL_WINDOWPOS_UNDEFINED_DISPLAY(System.Int32) +M: System.Boolean SDL2.SDL::SDL_WINDOWPOS_ISUNDEFINED(System.Int32) +M: System.Int32 SDL2.SDL::SDL_WINDOWPOS_CENTERED_DISPLAY(System.Int32) +M: System.Boolean SDL2.SDL::SDL_WINDOWPOS_ISCENTERED(System.Int32) +M: System.IntPtr SDL2.SDL::SDL_CreateWindow(System.String,System.Int32,System.Int32,System.Int32,System.Int32,SDL2.SDL/SDL_WindowFlags) +M: System.Int32 SDL2.SDL::SDL_CreateWindowAndRenderer(System.Int32,System.Int32,SDL2.SDL/SDL_WindowFlags,System.IntPtr&,System.IntPtr&) +M: System.IntPtr SDL2.SDL::SDL_CreateWindowFrom(System.IntPtr) +M: System.Void SDL2.SDL::SDL_DestroyWindow(System.IntPtr) +M: System.Void SDL2.SDL::SDL_DisableScreenSaver() +M: System.Void SDL2.SDL::SDL_EnableScreenSaver() +M: System.IntPtr SDL2.SDL::SDL_GetClosestDisplayMode(System.Int32,SDL2.SDL/SDL_DisplayMode&,SDL2.SDL/SDL_DisplayMode&) +M: System.Int32 SDL2.SDL::SDL_GetCurrentDisplayMode(System.Int32,SDL2.SDL/SDL_DisplayMode&) +M: System.String SDL2.SDL::SDL_GetCurrentVideoDriver() +M: System.Int32 SDL2.SDL::SDL_GetDesktopDisplayMode(System.Int32,SDL2.SDL/SDL_DisplayMode&) +M: System.String SDL2.SDL::SDL_GetDisplayName(System.Int32) +M: System.Int32 SDL2.SDL::SDL_GetDisplayBounds(System.Int32,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_GetDisplayDPI(System.Int32,System.Single&,System.Single&,System.Single&) +M: System.Int32 SDL2.SDL::SDL_GetDisplayMode(System.Int32,System.Int32,SDL2.SDL/SDL_DisplayMode&) +M: System.Int32 SDL2.SDL::SDL_GetDisplayUsableBounds(System.Int32,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_GetNumDisplayModes(System.Int32) +M: System.Int32 SDL2.SDL::SDL_GetNumVideoDisplays() +M: System.Int32 SDL2.SDL::SDL_GetNumVideoDrivers() +M: System.String SDL2.SDL::SDL_GetVideoDriver(System.Int32) +M: System.Single SDL2.SDL::SDL_GetWindowBrightness(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetWindowOpacity(System.IntPtr,System.Single) +M: System.Int32 SDL2.SDL::SDL_GetWindowOpacity(System.IntPtr,System.Single&) +M: System.Int32 SDL2.SDL::SDL_SetWindowModalFor(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetWindowInputFocus(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GetWindowData(System.IntPtr,System.String) +M: System.Int32 SDL2.SDL::SDL_GetWindowDisplayIndex(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GetWindowDisplayMode(System.IntPtr,SDL2.SDL/SDL_DisplayMode&) +M: System.UInt32 SDL2.SDL::SDL_GetWindowFlags(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GetWindowFromID(System.UInt32) +M: System.Int32 SDL2.SDL::SDL_GetWindowGammaRamp(System.IntPtr,System.UInt16[],System.UInt16[],System.UInt16[]) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GetWindowGrab(System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetWindowID(System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetWindowPixelFormat(System.IntPtr) +M: System.Void SDL2.SDL::SDL_GetWindowMaximumSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_GetWindowMinimumSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_GetWindowPosition(System.IntPtr,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_GetWindowSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.IntPtr SDL2.SDL::SDL_GetWindowSurface(System.IntPtr) +M: System.String SDL2.SDL::SDL_GetWindowTitle(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GL_BindTexture(System.IntPtr,System.Single&,System.Single&) +M: System.IntPtr SDL2.SDL::SDL_GL_CreateContext(System.IntPtr) +M: System.Void SDL2.SDL::SDL_GL_DeleteContext(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GL_GetProcAddress(System.String) +M: System.IntPtr SDL2.SDL::SDL_GL_GetProcAddress(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GL_ExtensionSupported(System.String) +M: System.Void SDL2.SDL::SDL_GL_ResetAttributes() +M: System.Int32 SDL2.SDL::SDL_GL_GetAttribute(SDL2.SDL/SDL_GLattr,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_GL_GetSwapInterval() +M: System.Int32 SDL2.SDL::SDL_GL_MakeCurrent(System.IntPtr,System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GL_GetCurrentWindow() +M: System.IntPtr SDL2.SDL::SDL_GL_GetCurrentContext() +M: System.Void SDL2.SDL::SDL_GL_GetDrawableSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_GL_SetAttribute(SDL2.SDL/SDL_GLattr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_GL_SetSwapInterval(System.Int32) +M: System.Void SDL2.SDL::SDL_GL_SwapWindow(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GL_UnbindTexture(System.IntPtr) +M: System.Void SDL2.SDL::SDL_HideWindow(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IsScreenSaverEnabled() +M: System.Void SDL2.SDL::SDL_MaximizeWindow(System.IntPtr) +M: System.Void SDL2.SDL::SDL_MinimizeWindow(System.IntPtr) +M: System.Void SDL2.SDL::SDL_RaiseWindow(System.IntPtr) +M: System.Void SDL2.SDL::SDL_RestoreWindow(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetWindowBrightness(System.IntPtr,System.Single) +M: System.IntPtr SDL2.SDL::SDL_SetWindowData(System.IntPtr,System.String,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetWindowDisplayMode(System.IntPtr,SDL2.SDL/SDL_DisplayMode&) +M: System.Int32 SDL2.SDL::SDL_SetWindowFullscreen(System.IntPtr,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_SetWindowGammaRamp(System.IntPtr,System.UInt16[],System.UInt16[],System.UInt16[]) +M: System.Void SDL2.SDL::SDL_SetWindowGrab(System.IntPtr,SDL2.SDL/SDL_bool) +M: System.Void SDL2.SDL::SDL_SetWindowIcon(System.IntPtr,System.IntPtr) +M: System.Void SDL2.SDL::SDL_SetWindowMaximumSize(System.IntPtr,System.Int32,System.Int32) +M: System.Void SDL2.SDL::SDL_SetWindowMinimumSize(System.IntPtr,System.Int32,System.Int32) +M: System.Void SDL2.SDL::SDL_SetWindowPosition(System.IntPtr,System.Int32,System.Int32) +M: System.Void SDL2.SDL::SDL_SetWindowSize(System.IntPtr,System.Int32,System.Int32) +M: System.Void SDL2.SDL::SDL_SetWindowBordered(System.IntPtr,SDL2.SDL/SDL_bool) +M: System.Int32 SDL2.SDL::SDL_GetWindowBordersSize(System.IntPtr,System.Int32&,System.Int32&,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_SetWindowResizable(System.IntPtr,SDL2.SDL/SDL_bool) +M: System.Void SDL2.SDL::SDL_SetWindowTitle(System.IntPtr,System.String) +M: System.Void SDL2.SDL::SDL_ShowWindow(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_UpdateWindowSurface(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_UpdateWindowSurfaceRects(System.IntPtr,SDL2.SDL/SDL_Rect[],System.Int32) +M: System.Int32 SDL2.SDL::SDL_VideoInit(System.String) +M: System.Void SDL2.SDL::SDL_VideoQuit() +M: System.Int32 SDL2.SDL::SDL_SetWindowHitTest(System.IntPtr,SDL2.SDL/SDL_HitTest,System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GetGrabbedWindow() +M: SDL2.SDL/SDL_BlendMode SDL2.SDL::SDL_ComposeCustomBlendMode(SDL2.SDL/SDL_BlendFactor,SDL2.SDL/SDL_BlendFactor,SDL2.SDL/SDL_BlendOperation,SDL2.SDL/SDL_BlendFactor,SDL2.SDL/SDL_BlendFactor,SDL2.SDL/SDL_BlendOperation) +M: System.Int32 SDL2.SDL::SDL_Vulkan_LoadLibrary(System.String) +M: System.IntPtr SDL2.SDL::SDL_Vulkan_GetVkGetInstanceProcAddr() +M: System.Void SDL2.SDL::SDL_Vulkan_UnloadLibrary() +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_Vulkan_GetInstanceExtensions(System.IntPtr,System.UInt32&,System.IntPtr[]) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_Vulkan_CreateSurface(System.IntPtr,System.IntPtr,System.IntPtr&) +M: System.Void SDL2.SDL::SDL_Vulkan_GetDrawableSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.IntPtr SDL2.SDL::SDL_CreateRenderer(System.IntPtr,System.Int32,SDL2.SDL/SDL_RendererFlags) +M: System.IntPtr SDL2.SDL::SDL_CreateSoftwareRenderer(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_CreateTexture(System.IntPtr,System.UInt32,System.Int32,System.Int32,System.Int32) +M: System.IntPtr SDL2.SDL::SDL_CreateTextureFromSurface(System.IntPtr,System.IntPtr) +M: System.Void SDL2.SDL::SDL_DestroyRenderer(System.IntPtr) +M: System.Void SDL2.SDL::SDL_DestroyTexture(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GetNumRenderDrivers() +M: System.Int32 SDL2.SDL::SDL_GetRenderDrawBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode&) +M: System.Int32 SDL2.SDL::SDL_GetRenderDrawColor(System.IntPtr,System.Byte&,System.Byte&,System.Byte&,System.Byte&) +M: System.Int32 SDL2.SDL::SDL_GetRenderDriverInfo(System.Int32,SDL2.SDL/SDL_RendererInfo&) +M: System.IntPtr SDL2.SDL::SDL_GetRenderer(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GetRendererInfo(System.IntPtr,SDL2.SDL/SDL_RendererInfo&) +M: System.Int32 SDL2.SDL::SDL_GetRendererOutputSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_GetTextureAlphaMod(System.IntPtr,System.Byte&) +M: System.Int32 SDL2.SDL::SDL_GetTextureBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode&) +M: System.Int32 SDL2.SDL::SDL_GetTextureColorMod(System.IntPtr,System.Byte&,System.Byte&,System.Byte&) +M: System.Int32 SDL2.SDL::SDL_LockTexture(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_LockTexture(System.IntPtr,System.IntPtr,System.IntPtr&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_QueryTexture(System.IntPtr,System.UInt32&,System.Int32&,System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_RenderClear(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderCopy(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_RenderCopy(System.IntPtr,System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_RenderCopy(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderCopy(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&,System.Double,SDL2.SDL/SDL_Point&,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,System.Double,SDL2.SDL/SDL_Point&,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,System.Double,SDL2.SDL/SDL_Point&,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&,System.Double,System.IntPtr,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.Double,SDL2.SDL/SDL_Point&,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,System.Double,System.IntPtr,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,System.Double,System.IntPtr,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.Double,System.IntPtr,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderDrawLine(System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderDrawLines(System.IntPtr,SDL2.SDL/SDL_Point[],System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderDrawPoint(System.IntPtr,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderDrawPoints(System.IntPtr,SDL2.SDL/SDL_Point[],System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderDrawRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_RenderDrawRect(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderDrawRects(System.IntPtr,SDL2.SDL/SDL_Rect[],System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderFillRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_RenderFillRect(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderFillRects(System.IntPtr,SDL2.SDL/SDL_Rect[],System.Int32) +M: System.Void SDL2.SDL::SDL_RenderGetClipRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Void SDL2.SDL::SDL_RenderGetLogicalSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_RenderGetScale(System.IntPtr,System.Single&,System.Single&) +M: System.Int32 SDL2.SDL::SDL_RenderGetViewport(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Void SDL2.SDL::SDL_RenderPresent(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderReadPixels(System.IntPtr,SDL2.SDL/SDL_Rect&,System.UInt32,System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderSetClipRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_RenderSetClipRect(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderSetLogicalSize(System.IntPtr,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderSetScale(System.IntPtr,System.Single,System.Single) +M: System.Int32 SDL2.SDL::SDL_RenderSetIntegerScale(System.IntPtr,SDL2.SDL/SDL_bool) +M: System.Int32 SDL2.SDL::SDL_RenderSetViewport(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_SetRenderDrawBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode) +M: System.Int32 SDL2.SDL::SDL_SetRenderDrawColor(System.IntPtr,System.Byte,System.Byte,System.Byte,System.Byte) +M: System.Int32 SDL2.SDL::SDL_SetRenderTarget(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetTextureAlphaMod(System.IntPtr,System.Byte) +M: System.Int32 SDL2.SDL::SDL_SetTextureBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode) +M: System.Int32 SDL2.SDL::SDL_SetTextureColorMod(System.IntPtr,System.Byte,System.Byte,System.Byte) +M: System.Void SDL2.SDL::SDL_UnlockTexture(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_UpdateTexture(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_UpdateTexture(System.IntPtr,System.IntPtr,System.IntPtr,System.Int32) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_RenderTargetSupported(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GetRenderTarget(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_RenderIsClipEnabled(System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_DEFINE_PIXELFOURCC(System.Byte,System.Byte,System.Byte,System.Byte) +M: System.UInt32 SDL2.SDL::SDL_DEFINE_PIXELFORMAT(SDL2.SDL/SDL_PIXELTYPE_ENUM,SDL2.SDL/SDL_PIXELORDER_ENUM,SDL2.SDL/SDL_PACKEDLAYOUT_ENUM,System.Byte,System.Byte) +M: System.Byte SDL2.SDL::SDL_PIXELFLAG(System.UInt32) +M: System.Byte SDL2.SDL::SDL_PIXELTYPE(System.UInt32) +M: System.Byte SDL2.SDL::SDL_PIXELORDER(System.UInt32) +M: System.Byte SDL2.SDL::SDL_PIXELLAYOUT(System.UInt32) +M: System.Byte SDL2.SDL::SDL_BITSPERPIXEL(System.UInt32) +M: System.Byte SDL2.SDL::SDL_BYTESPERPIXEL(System.UInt32) +M: System.Boolean SDL2.SDL::SDL_ISPIXELFORMAT_INDEXED(System.UInt32) +M: System.Boolean SDL2.SDL::SDL_ISPIXELFORMAT_ALPHA(System.UInt32) +M: System.Boolean SDL2.SDL::SDL_ISPIXELFORMAT_FOURCC(System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_AllocFormat(System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_AllocPalette(System.Int32) +M: System.Void SDL2.SDL::SDL_CalculateGammaRamp(System.Single,System.UInt16[]) +M: System.Void SDL2.SDL::SDL_FreeFormat(System.IntPtr) +M: System.Void SDL2.SDL::SDL_FreePalette(System.IntPtr) +M: System.String SDL2.SDL::SDL_GetPixelFormatName(System.UInt32) +M: System.Void SDL2.SDL::SDL_GetRGB(System.UInt32,System.IntPtr,System.Byte&,System.Byte&,System.Byte&) +M: System.Void SDL2.SDL::SDL_GetRGBA(System.UInt32,System.IntPtr,System.Byte&,System.Byte&,System.Byte&,System.Byte&) +M: System.UInt32 SDL2.SDL::SDL_MapRGB(System.IntPtr,System.Byte,System.Byte,System.Byte) +M: System.UInt32 SDL2.SDL::SDL_MapRGBA(System.IntPtr,System.Byte,System.Byte,System.Byte,System.Byte) +M: System.UInt32 SDL2.SDL::SDL_MasksToPixelFormatEnum(System.Int32,System.UInt32,System.UInt32,System.UInt32,System.UInt32) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_PixelFormatEnumToMasks(System.UInt32,System.Int32&,System.UInt32&,System.UInt32&,System.UInt32&,System.UInt32&) +M: System.Int32 SDL2.SDL::SDL_SetPaletteColors(System.IntPtr,SDL2.SDL/SDL_Color[],System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_SetPixelFormatPalette(System.IntPtr,System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_PointInRect(SDL2.SDL/SDL_Point&,SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_EnclosePoints(SDL2.SDL/SDL_Point[],System.Int32,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_HasIntersection(SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IntersectRect(SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IntersectRectAndLine(SDL2.SDL/SDL_Rect&,System.Int32&,System.Int32&,System.Int32&,System.Int32&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_RectEmpty(SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_RectEquals(SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: System.Void SDL2.SDL::SDL_UnionRect(SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: System.Boolean SDL2.SDL::SDL_MUSTLOCK(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_BlitSurface(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_BlitSurface(System.IntPtr,System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_BlitSurface(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_BlitSurface(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_BlitScaled(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_BlitScaled(System.IntPtr,System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_BlitScaled(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_BlitScaled(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_ConvertPixels(System.Int32,System.Int32,System.UInt32,System.IntPtr,System.Int32,System.UInt32,System.IntPtr,System.Int32) +M: System.IntPtr SDL2.SDL::SDL_ConvertSurface(System.IntPtr,System.IntPtr,System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_ConvertSurfaceFormat(System.IntPtr,System.UInt32,System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_CreateRGBSurface(System.UInt32,System.Int32,System.Int32,System.Int32,System.UInt32,System.UInt32,System.UInt32,System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_CreateRGBSurfaceFrom(System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32,System.UInt32,System.UInt32,System.UInt32,System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_CreateRGBSurfaceWithFormat(System.UInt32,System.Int32,System.Int32,System.Int32,System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_CreateRGBSurfaceWithFormatFrom(System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_FillRect(System.IntPtr,SDL2.SDL/SDL_Rect&,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_FillRect(System.IntPtr,System.IntPtr,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_FillRects(System.IntPtr,SDL2.SDL/SDL_Rect[],System.Int32,System.UInt32) +M: System.Void SDL2.SDL::SDL_FreeSurface(System.IntPtr) +M: System.Void SDL2.SDL::SDL_GetClipRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_GetColorKey(System.IntPtr,System.UInt32&) +M: System.Int32 SDL2.SDL::SDL_GetSurfaceAlphaMod(System.IntPtr,System.Byte&) +M: System.Int32 SDL2.SDL::SDL_GetSurfaceBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode&) +M: System.Int32 SDL2.SDL::SDL_GetSurfaceColorMod(System.IntPtr,System.Byte&,System.Byte&,System.Byte&) +M: System.IntPtr SDL2.SDL::SDL_LoadBMP(System.String) +M: System.Int32 SDL2.SDL::SDL_LockSurface(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_LowerBlit(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_LowerBlitScaled(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_SaveBMP(System.IntPtr,System.String) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_SetClipRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_SetColorKey(System.IntPtr,System.Int32,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_SetSurfaceAlphaMod(System.IntPtr,System.Byte) +M: System.Int32 SDL2.SDL::SDL_SetSurfaceBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode) +M: System.Int32 SDL2.SDL::SDL_SetSurfaceColorMod(System.IntPtr,System.Byte,System.Byte,System.Byte) +M: System.Int32 SDL2.SDL::SDL_SetSurfacePalette(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetSurfaceRLE(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_SoftStretch(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Void SDL2.SDL::SDL_UnlockSurface(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_UpperBlit(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_UpperBlitScaled(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.IntPtr SDL2.SDL::SDL_DuplicateSurface(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_HasClipboardText() +M: System.String SDL2.SDL::SDL_GetClipboardText() +M: System.Int32 SDL2.SDL::SDL_SetClipboardText(System.String) +M: System.Void SDL2.SDL::SDL_PumpEvents() +M: System.Int32 SDL2.SDL::SDL_PeepEvents(SDL2.SDL/SDL_Event[],System.Int32,SDL2.SDL/SDL_eventaction,SDL2.SDL/SDL_EventType,SDL2.SDL/SDL_EventType) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_HasEvent(SDL2.SDL/SDL_EventType) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_HasEvents(SDL2.SDL/SDL_EventType,SDL2.SDL/SDL_EventType) +M: System.Void SDL2.SDL::SDL_FlushEvent(SDL2.SDL/SDL_EventType) +M: System.Void SDL2.SDL::SDL_FlushEvents(SDL2.SDL/SDL_EventType,SDL2.SDL/SDL_EventType) +M: System.Int32 SDL2.SDL::SDL_PollEvent(SDL2.SDL/SDL_Event&) +M: System.Int32 SDL2.SDL::SDL_WaitEvent(SDL2.SDL/SDL_Event&) +M: System.Int32 SDL2.SDL::SDL_WaitEventTimeout(SDL2.SDL/SDL_Event&,System.Int32) +M: System.Int32 SDL2.SDL::SDL_PushEvent(SDL2.SDL/SDL_Event&) +M: System.Void SDL2.SDL::SDL_SetEventFilter(SDL2.SDL/SDL_EventFilter,System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GetEventFilter(SDL2.SDL/SDL_EventFilter&,System.IntPtr&) +M: System.Void SDL2.SDL::SDL_AddEventWatch(SDL2.SDL/SDL_EventFilter,System.IntPtr) +M: System.Void SDL2.SDL::SDL_DelEventWatch(SDL2.SDL/SDL_EventFilter,System.IntPtr) +M: System.Void SDL2.SDL::SDL_FilterEvents(SDL2.SDL/SDL_EventFilter,System.IntPtr) +M: System.Byte SDL2.SDL::SDL_EventState(SDL2.SDL/SDL_EventType,System.Int32) +M: System.Byte SDL2.SDL::SDL_GetEventState(SDL2.SDL/SDL_EventType) +M: System.UInt32 SDL2.SDL::SDL_RegisterEvents(System.Int32) +M: SDL2.SDL/SDL_Keycode SDL2.SDL::SDL_SCANCODE_TO_KEYCODE(SDL2.SDL/SDL_Scancode) +M: System.IntPtr SDL2.SDL::SDL_GetKeyboardFocus() +M: System.IntPtr SDL2.SDL::SDL_GetKeyboardState(System.Int32&) +M: SDL2.SDL/SDL_Keymod SDL2.SDL::SDL_GetModState() +M: System.Void SDL2.SDL::SDL_SetModState(SDL2.SDL/SDL_Keymod) +M: SDL2.SDL/SDL_Keycode SDL2.SDL::SDL_GetKeyFromScancode(SDL2.SDL/SDL_Scancode) +M: SDL2.SDL/SDL_Scancode SDL2.SDL::SDL_GetScancodeFromKey(SDL2.SDL/SDL_Keycode) +M: System.String SDL2.SDL::SDL_GetScancodeName(SDL2.SDL/SDL_Scancode) +M: SDL2.SDL/SDL_Scancode SDL2.SDL::SDL_GetScancodeFromName(System.String) +M: System.String SDL2.SDL::SDL_GetKeyName(SDL2.SDL/SDL_Keycode) +M: SDL2.SDL/SDL_Keycode SDL2.SDL::SDL_GetKeyFromName(System.String) +M: System.Void SDL2.SDL::SDL_StartTextInput() +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IsTextInputActive() +M: System.Void SDL2.SDL::SDL_StopTextInput() +M: System.Void SDL2.SDL::SDL_SetTextInputRect(SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_HasScreenKeyboardSupport() +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IsScreenKeyboardShown(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GetMouseFocus() +M: System.UInt32 SDL2.SDL::SDL_GetMouseState(System.Int32&,System.Int32&) +M: System.UInt32 SDL2.SDL::SDL_GetMouseState(System.IntPtr,System.Int32&) +M: System.UInt32 SDL2.SDL::SDL_GetMouseState(System.Int32&,System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetMouseState(System.IntPtr,System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetGlobalMouseState(System.Int32&,System.Int32&) +M: System.UInt32 SDL2.SDL::SDL_GetGlobalMouseState(System.IntPtr,System.Int32&) +M: System.UInt32 SDL2.SDL::SDL_GetGlobalMouseState(System.Int32&,System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetGlobalMouseState(System.IntPtr,System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetRelativeMouseState(System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_WarpMouseInWindow(System.IntPtr,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_WarpMouseGlobal(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_SetRelativeMouseMode(SDL2.SDL/SDL_bool) +M: System.Int32 SDL2.SDL::SDL_CaptureMouse(SDL2.SDL/SDL_bool) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GetRelativeMouseMode() +M: System.IntPtr SDL2.SDL::SDL_CreateCursor(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32) +M: System.IntPtr SDL2.SDL::SDL_CreateColorCursor(System.IntPtr,System.Int32,System.Int32) +M: System.IntPtr SDL2.SDL::SDL_CreateSystemCursor(SDL2.SDL/SDL_SystemCursor) +M: System.Void SDL2.SDL::SDL_SetCursor(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GetCursor() +M: System.Void SDL2.SDL::SDL_FreeCursor(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_ShowCursor(System.Int32) +M: System.UInt32 SDL2.SDL::SDL_BUTTON(System.UInt32) +M: System.Int32 SDL2.SDL::SDL_GetNumTouchDevices() +M: System.Int64 SDL2.SDL::SDL_GetTouchDevice(System.Int32) +M: System.Int32 SDL2.SDL::SDL_GetNumTouchFingers(System.Int64) +M: System.IntPtr SDL2.SDL::SDL_GetTouchFinger(System.Int64,System.Int32) +M: System.Void SDL2.SDL::SDL_JoystickClose(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_JoystickEventState(System.Int32) +M: System.Int16 SDL2.SDL::SDL_JoystickGetAxis(System.IntPtr,System.Int32) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_JoystickGetAxisInitialState(System.IntPtr,System.Int32,System.UInt16&) +M: System.Int32 SDL2.SDL::SDL_JoystickGetBall(System.IntPtr,System.Int32,System.Int32&,System.Int32&) +M: System.Byte SDL2.SDL::SDL_JoystickGetButton(System.IntPtr,System.Int32) +M: System.Byte SDL2.SDL::SDL_JoystickGetHat(System.IntPtr,System.Int32) +M: System.String SDL2.SDL::SDL_JoystickName(System.IntPtr) +M: System.String SDL2.SDL::SDL_JoystickNameForIndex(System.Int32) +M: System.Int32 SDL2.SDL::SDL_JoystickNumAxes(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_JoystickNumBalls(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_JoystickNumButtons(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_JoystickNumHats(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_JoystickOpen(System.Int32) +M: System.Void SDL2.SDL::SDL_JoystickUpdate() +M: System.Int32 SDL2.SDL::SDL_NumJoysticks() +M: System.Guid SDL2.SDL::SDL_JoystickGetDeviceGUID(System.Int32) +M: System.Guid SDL2.SDL::SDL_JoystickGetGUID(System.IntPtr) +M: System.Void SDL2.SDL::SDL_JoystickGetGUIDString(System.Guid,System.Byte[],System.Int32) +M: System.Guid SDL2.SDL::SDL_JoystickGetGUIDFromString(System.String) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetDeviceVendor(System.Int32) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetDeviceProduct(System.Int32) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetDeviceProductVersion(System.Int32) +M: SDL2.SDL/SDL_JoystickType SDL2.SDL::SDL_JoystickGetDeviceType(System.Int32) +M: System.Int32 SDL2.SDL::SDL_JoystickGetDeviceInstanceID(System.Int32) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetVendor(System.IntPtr) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetProduct(System.IntPtr) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetProductVersion(System.IntPtr) +M: SDL2.SDL/SDL_JoystickType SDL2.SDL::SDL_JoystickGetType(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_JoystickGetAttached(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_JoystickInstanceID(System.IntPtr) +M: SDL2.SDL/SDL_JoystickPowerLevel SDL2.SDL::SDL_JoystickCurrentPowerLevel(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_JoystickFromInstanceID(System.Int32) +M: System.Void SDL2.SDL::SDL_LockJoysticks() +M: System.Void SDL2.SDL::SDL_UnlockJoysticks() +M: System.Int32 SDL2.SDL::SDL_GameControllerAddMapping(System.String) +M: System.Int32 SDL2.SDL::SDL_GameControllerNumMappings() +M: System.String SDL2.SDL::SDL_GameControllerMappingForIndex(System.Int32) +M: System.Int32 SDL2.SDL::SDL_GameControllerAddMappingsFromFile(System.String) +M: System.String SDL2.SDL::SDL_GameControllerMappingForGUID(System.Guid) +M: System.String SDL2.SDL::SDL_GameControllerMapping(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IsGameController(System.Int32) +M: System.String SDL2.SDL::SDL_GameControllerNameForIndex(System.Int32) +M: System.IntPtr SDL2.SDL::SDL_GameControllerOpen(System.Int32) +M: System.String SDL2.SDL::SDL_GameControllerName(System.IntPtr) +M: System.UInt16 SDL2.SDL::SDL_GameControllerGetVendor(System.IntPtr) +M: System.UInt16 SDL2.SDL::SDL_GameControllerGetProduct(System.IntPtr) +M: System.UInt16 SDL2.SDL::SDL_GameControllerGetProductVersion(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GameControllerGetAttached(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GameControllerGetJoystick(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GameControllerEventState(System.Int32) +M: System.Void SDL2.SDL::SDL_GameControllerUpdate() +M: SDL2.SDL/SDL_GameControllerAxis SDL2.SDL::SDL_GameControllerGetAxisFromString(System.String) +M: System.String SDL2.SDL::SDL_GameControllerGetStringForAxis(SDL2.SDL/SDL_GameControllerAxis) +M: SDL2.SDL/SDL_GameControllerButtonBind SDL2.SDL::SDL_GameControllerGetBindForAxis(System.IntPtr,SDL2.SDL/SDL_GameControllerAxis) +M: System.Int16 SDL2.SDL::SDL_GameControllerGetAxis(System.IntPtr,SDL2.SDL/SDL_GameControllerAxis) +M: SDL2.SDL/SDL_GameControllerButton SDL2.SDL::SDL_GameControllerGetButtonFromString(System.String) +M: System.String SDL2.SDL::SDL_GameControllerGetStringForButton(SDL2.SDL/SDL_GameControllerButton) +M: SDL2.SDL/SDL_GameControllerButtonBind SDL2.SDL::SDL_GameControllerGetBindForButton(System.IntPtr,SDL2.SDL/SDL_GameControllerButton) +M: System.Byte SDL2.SDL::SDL_GameControllerGetButton(System.IntPtr,SDL2.SDL/SDL_GameControllerButton) +M: System.Void SDL2.SDL::SDL_GameControllerClose(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GameControllerFromInstanceID(System.Int32) +M: System.Void SDL2.SDL::SDL_HapticClose(System.IntPtr) +M: System.Void SDL2.SDL::SDL_HapticDestroyEffect(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticEffectSupported(System.IntPtr,SDL2.SDL/SDL_HapticEffect&) +M: System.Int32 SDL2.SDL::SDL_HapticGetEffectStatus(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticIndex(System.IntPtr) +M: System.String SDL2.SDL::SDL_HapticName(System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticNewEffect(System.IntPtr,SDL2.SDL/SDL_HapticEffect&) +M: System.Int32 SDL2.SDL::SDL_HapticNumAxes(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticNumEffects(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticNumEffectsPlaying(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_HapticOpen(System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticOpened(System.Int32) +M: System.IntPtr SDL2.SDL::SDL_HapticOpenFromJoystick(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_HapticOpenFromMouse() +M: System.Int32 SDL2.SDL::SDL_HapticPause(System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_HapticQuery(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticRumbleInit(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticRumblePlay(System.IntPtr,System.Single,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_HapticRumbleStop(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticRumbleSupported(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticRunEffect(System.IntPtr,System.Int32,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_HapticSetAutocenter(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticSetGain(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticStopAll(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticStopEffect(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticUnpause(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticUpdateEffect(System.IntPtr,System.Int32,SDL2.SDL/SDL_HapticEffect&) +M: System.Int32 SDL2.SDL::SDL_JoystickIsHaptic(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_MouseIsHaptic() +M: System.Int32 SDL2.SDL::SDL_NumHaptics() +M: System.UInt16 SDL2.SDL::SDL_AUDIO_BITSIZE(System.UInt16) +M: System.Boolean SDL2.SDL::SDL_AUDIO_ISFLOAT(System.UInt16) +M: System.Boolean SDL2.SDL::SDL_AUDIO_ISBIGENDIAN(System.UInt16) +M: System.Boolean SDL2.SDL::SDL_AUDIO_ISSIGNED(System.UInt16) +M: System.Boolean SDL2.SDL::SDL_AUDIO_ISINT(System.UInt16) +M: System.Boolean SDL2.SDL::SDL_AUDIO_ISLITTLEENDIAN(System.UInt16) +M: System.Boolean SDL2.SDL::SDL_AUDIO_ISUNSIGNED(System.UInt16) +M: System.Int32 SDL2.SDL::SDL_AudioInit(System.String) +M: System.Void SDL2.SDL::SDL_AudioQuit() +M: System.Void SDL2.SDL::SDL_CloseAudio() +M: System.Void SDL2.SDL::SDL_CloseAudioDevice(System.UInt32) +M: System.Void SDL2.SDL::SDL_FreeWAV(System.IntPtr) +M: System.String SDL2.SDL::SDL_GetAudioDeviceName(System.Int32,System.Int32) +M: SDL2.SDL/SDL_AudioStatus SDL2.SDL::SDL_GetAudioDeviceStatus(System.UInt32) +M: System.String SDL2.SDL::SDL_GetAudioDriver(System.Int32) +M: SDL2.SDL/SDL_AudioStatus SDL2.SDL::SDL_GetAudioStatus() +M: System.String SDL2.SDL::SDL_GetCurrentAudioDriver() +M: System.Int32 SDL2.SDL::SDL_GetNumAudioDevices(System.Int32) +M: System.Int32 SDL2.SDL::SDL_GetNumAudioDrivers() +M: SDL2.SDL/SDL_AudioSpec SDL2.SDL::SDL_LoadWAV(System.String,SDL2.SDL/SDL_AudioSpec&,System.IntPtr&,System.UInt32&) +M: System.Void SDL2.SDL::SDL_LockAudio() +M: System.Void SDL2.SDL::SDL_LockAudioDevice(System.UInt32) +M: System.Void SDL2.SDL::SDL_MixAudio(System.Byte[],System.Byte[],System.UInt32,System.Int32) +M: System.Void SDL2.SDL::SDL_MixAudioFormat(System.Byte[],System.Byte[],System.UInt16,System.UInt32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_OpenAudio(SDL2.SDL/SDL_AudioSpec&,SDL2.SDL/SDL_AudioSpec&) +M: System.Int32 SDL2.SDL::SDL_OpenAudio(SDL2.SDL/SDL_AudioSpec&,System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_OpenAudioDevice(System.String,System.Int32,SDL2.SDL/SDL_AudioSpec&,SDL2.SDL/SDL_AudioSpec&,System.Int32) +M: System.Void SDL2.SDL::SDL_PauseAudio(System.Int32) +M: System.Void SDL2.SDL::SDL_PauseAudioDevice(System.UInt32,System.Int32) +M: System.Void SDL2.SDL::SDL_UnlockAudio() +M: System.Void SDL2.SDL::SDL_UnlockAudioDevice(System.UInt32) +M: System.Int32 SDL2.SDL::SDL_QueueAudio(System.UInt32,System.IntPtr,System.UInt32) +M: System.UInt32 SDL2.SDL::SDL_DequeueAudio(System.UInt32,System.IntPtr,System.UInt32) +M: System.UInt32 SDL2.SDL::SDL_GetQueuedAudioSize(System.UInt32) +M: System.Void SDL2.SDL::SDL_ClearQueuedAudio(System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_NewAudioStream(System.UInt16,System.Byte,System.Int32,System.UInt16,System.Byte,System.Int32) +M: System.Int32 SDL2.SDL::SDL_AudioStreamPut(System.IntPtr,System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_AudioStreamGet(System.IntPtr,System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_AudioStreamAvailable(System.IntPtr) +M: System.Void SDL2.SDL::SDL_AudioStreamClear(System.IntPtr) +M: System.Void SDL2.SDL::SDL_FreeAudioStream(System.IntPtr) +M: System.Boolean SDL2.SDL::SDL_TICKS_PASSED(System.UInt32,System.UInt32) +M: System.Void SDL2.SDL::SDL_Delay(System.UInt32) +M: System.UInt32 SDL2.SDL::SDL_GetTicks() +M: System.UInt64 SDL2.SDL::SDL_GetPerformanceCounter() +M: System.UInt64 SDL2.SDL::SDL_GetPerformanceFrequency() +M: System.Int32 SDL2.SDL::SDL_AddTimer(System.UInt32,SDL2.SDL/SDL_TimerCallback,System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_RemoveTimer(System.Int32) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GetWindowWMInfo(System.IntPtr,SDL2.SDL/SDL_SysWMinfo&) +M: System.String SDL2.SDL::SDL_GetBasePath() +M: System.String SDL2.SDL::SDL_GetPrefPath(System.String,System.String) +M: SDL2.SDL/SDL_PowerState SDL2.SDL::SDL_GetPowerInfo(System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_GetCPUCount() +M: System.Int32 SDL2.SDL::SDL_GetSystemRAM() +T: SDL2.SDL/SDL_bool +T: SDL2.SDL/SDL_WinRT_mainFunction +T: SDL2.SDL/SDL_HintPriority +T: SDL2.SDL/SDL_LogPriority +T: SDL2.SDL/SDL_LogOutputFunction +T: SDL2.SDL/SDL_MessageBoxFlags +T: SDL2.SDL/SDL_MessageBoxButtonFlags +T: SDL2.SDL/SDL_MessageBoxButtonData +T: SDL2.SDL/SDL_MessageBoxColor +T: SDL2.SDL/SDL_MessageBoxColorType +T: SDL2.SDL/SDL_MessageBoxColorScheme +T: SDL2.SDL/SDL_MessageBoxData +T: SDL2.SDL/SDL_version +T: SDL2.SDL/SDL_GLattr +T: SDL2.SDL/SDL_GLprofile +T: SDL2.SDL/SDL_GLcontext +T: SDL2.SDL/SDL_WindowEventID +T: SDL2.SDL/SDL_WindowFlags +T: SDL2.SDL/SDL_HitTestResult +T: SDL2.SDL/SDL_DisplayMode +T: SDL2.SDL/SDL_HitTest +T: SDL2.SDL/SDL_BlendMode +T: SDL2.SDL/SDL_BlendOperation +T: SDL2.SDL/SDL_BlendFactor +T: SDL2.SDL/SDL_RendererFlags +T: SDL2.SDL/SDL_RendererFlip +T: SDL2.SDL/SDL_TextureAccess +T: SDL2.SDL/SDL_TextureModulate +T: SDL2.SDL/SDL_RendererInfo +T: SDL2.SDL/SDL_PIXELTYPE_ENUM +T: SDL2.SDL/SDL_PIXELORDER_ENUM +T: SDL2.SDL/SDL_PACKEDLAYOUT_ENUM +T: SDL2.SDL/SDL_Color +T: SDL2.SDL/SDL_Palette +T: SDL2.SDL/SDL_PixelFormat +T: SDL2.SDL/SDL_Point +T: SDL2.SDL/SDL_Rect +T: SDL2.SDL/SDL_Surface +T: SDL2.SDL/SDL_EventType +T: SDL2.SDL/SDL_MouseWheelDirection +T: SDL2.SDL/SDL_GenericEvent +T: SDL2.SDL/SDL_WindowEvent +T: SDL2.SDL/SDL_KeyboardEvent +T: SDL2.SDL/SDL_TextEditingEvent +T: SDL2.SDL/SDL_TextInputEvent +T: SDL2.SDL/SDL_MouseMotionEvent +T: SDL2.SDL/SDL_MouseButtonEvent +T: SDL2.SDL/SDL_MouseWheelEvent +T: SDL2.SDL/SDL_JoyAxisEvent +T: SDL2.SDL/SDL_JoyBallEvent +T: SDL2.SDL/SDL_JoyHatEvent +T: SDL2.SDL/SDL_JoyButtonEvent +T: SDL2.SDL/SDL_JoyDeviceEvent +T: SDL2.SDL/SDL_ControllerAxisEvent +T: SDL2.SDL/SDL_ControllerButtonEvent +T: SDL2.SDL/SDL_ControllerDeviceEvent +T: SDL2.SDL/SDL_AudioDeviceEvent +T: SDL2.SDL/SDL_TouchFingerEvent +T: SDL2.SDL/SDL_MultiGestureEvent +T: SDL2.SDL/SDL_DollarGestureEvent +T: SDL2.SDL/SDL_DropEvent +T: SDL2.SDL/SDL_QuitEvent +T: SDL2.SDL/SDL_UserEvent +T: SDL2.SDL/SDL_SysWMEvent +T: SDL2.SDL/SDL_Event +T: SDL2.SDL/SDL_EventFilter +T: SDL2.SDL/SDL_eventaction +T: SDL2.SDL/SDL_Scancode +T: SDL2.SDL/SDL_Keycode +T: SDL2.SDL/SDL_Keymod +T: SDL2.SDL/SDL_Keysym +T: SDL2.SDL/SDL_SystemCursor +T: SDL2.SDL/SDL_Finger +T: SDL2.SDL/SDL_JoystickPowerLevel +T: SDL2.SDL/SDL_JoystickType +T: SDL2.SDL/SDL_GameControllerBindType +T: SDL2.SDL/SDL_GameControllerAxis +T: SDL2.SDL/SDL_GameControllerButton +T: SDL2.SDL/INTERNAL_GameControllerButtonBind_hat +T: SDL2.SDL/INTERNAL_GameControllerButtonBind_union +T: SDL2.SDL/SDL_GameControllerButtonBind +T: SDL2.SDL/SDL_HapticDirection +T: SDL2.SDL/SDL_HapticConstant +T: SDL2.SDL/SDL_HapticPeriodic +T: SDL2.SDL/SDL_HapticCondition +T: SDL2.SDL/SDL_HapticRamp +T: SDL2.SDL/SDL_HapticLeftRight +T: SDL2.SDL/SDL_HapticCustom +T: SDL2.SDL/SDL_HapticEffect +T: SDL2.SDL/SDL_AudioStatus +T: SDL2.SDL/SDL_AudioSpec +T: SDL2.SDL/SDL_AudioCallback +T: SDL2.SDL/SDL_TimerCallback +T: SDL2.SDL/SDL_SYSWM_TYPE +T: SDL2.SDL/INTERNAL_windows_wminfo +T: SDL2.SDL/INTERNAL_winrt_wminfo +T: SDL2.SDL/INTERNAL_x11_wminfo +T: SDL2.SDL/INTERNAL_directfb_wminfo +T: SDL2.SDL/INTERNAL_cocoa_wminfo +T: SDL2.SDL/INTERNAL_uikit_wminfo +T: SDL2.SDL/INTERNAL_wayland_wminfo +T: SDL2.SDL/INTERNAL_mir_wminfo +T: SDL2.SDL/INTERNAL_android_wminfo +T: SDL2.SDL/INTERNAL_SysWMDriverUnion +T: SDL2.SDL/SDL_SysWMinfo +T: SDL2.SDL/SDL_PowerState +T: SDL2.SDL_image +M: System.Void SDL2.SDL_image::SDL_IMAGE_VERSION(SDL2.SDL/SDL_version&) +M: SDL2.SDL/SDL_version SDL2.SDL_image::IMG_Linked_Version() +M: System.Int32 SDL2.SDL_image::IMG_Init(SDL2.SDL_image/IMG_InitFlags) +M: System.Void SDL2.SDL_image::IMG_Quit() +M: System.IntPtr SDL2.SDL_image::IMG_Load(System.String) +M: System.IntPtr SDL2.SDL_image::IMG_Load_RW(System.IntPtr,System.Int32) +M: System.IntPtr SDL2.SDL_image::IMG_LoadTyped_RW(System.IntPtr,System.Int32,System.String) +M: System.IntPtr SDL2.SDL_image::IMG_LoadTexture(System.IntPtr,System.String) +M: System.IntPtr SDL2.SDL_image::IMG_LoadTexture_RW(System.IntPtr,System.IntPtr,System.Int32) +M: System.IntPtr SDL2.SDL_image::IMG_LoadTextureTyped_RW(System.IntPtr,System.IntPtr,System.Int32,System.String) +M: System.IntPtr SDL2.SDL_image::IMG_ReadXPMFromArray(System.String[]) +M: System.Int32 SDL2.SDL_image::IMG_SavePNG(System.IntPtr,System.String) +M: System.Int32 SDL2.SDL_image::IMG_SavePNG_RW(System.IntPtr,System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_image::IMG_SaveJPG(System.IntPtr,System.String,System.Int32) +M: System.Int32 SDL2.SDL_image::IMG_SaveJPG_RW(System.IntPtr,System.IntPtr,System.Int32,System.Int32) +T: SDL2.SDL_image/IMG_InitFlags +T: SDL2.SDL_mixer +M: System.Void SDL2.SDL_mixer::SDL_MIXER_VERSION(SDL2.SDL/SDL_version&) +M: SDL2.SDL/SDL_version SDL2.SDL_mixer::MIX_Linked_Version() +M: System.Int32 SDL2.SDL_mixer::Mix_Init(SDL2.SDL_mixer/MIX_InitFlags) +M: System.Void SDL2.SDL_mixer::Mix_Quit() +M: System.Int32 SDL2.SDL_mixer::Mix_OpenAudio(System.Int32,System.UInt16,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_AllocateChannels(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_QuerySpec(System.Int32&,System.UInt16&,System.Int32&) +M: System.IntPtr SDL2.SDL_mixer::Mix_LoadWAV_RW(System.IntPtr,System.Int32) +M: System.IntPtr SDL2.SDL_mixer::Mix_LoadWAV(System.String) +M: System.IntPtr SDL2.SDL_mixer::Mix_LoadMUS(System.String) +M: System.IntPtr SDL2.SDL_mixer::Mix_QuickLoad_WAV(System.Byte[]) +M: System.IntPtr SDL2.SDL_mixer::Mix_QuickLoad_RAW(System.Byte[],System.UInt32) +M: System.Void SDL2.SDL_mixer::Mix_FreeChunk(System.IntPtr) +M: System.Void SDL2.SDL_mixer::Mix_FreeMusic(System.IntPtr) +M: System.Int32 SDL2.SDL_mixer::Mix_GetNumChunkDecoders() +M: System.String SDL2.SDL_mixer::Mix_GetChunkDecoder(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GetNumMusicDecoders() +M: System.String SDL2.SDL_mixer::Mix_GetMusicDecoder(System.Int32) +M: SDL2.SDL_mixer/Mix_MusicType SDL2.SDL_mixer::Mix_GetMusicType(System.IntPtr) +M: System.Void SDL2.SDL_mixer::Mix_SetPostMix(SDL2.SDL_mixer/MixFuncDelegate,System.IntPtr) +M: System.Void SDL2.SDL_mixer::Mix_HookMusic(SDL2.SDL_mixer/MixFuncDelegate,System.IntPtr) +M: System.Void SDL2.SDL_mixer::Mix_HookMusicFinished(SDL2.SDL_mixer/MusicFinishedDelegate) +M: System.IntPtr SDL2.SDL_mixer::Mix_GetMusicHookData() +M: System.Void SDL2.SDL_mixer::Mix_ChannelFinished(SDL2.SDL_mixer/ChannelFinishedDelegate) +M: System.Int32 SDL2.SDL_mixer::Mix_RegisterEffect(System.Int32,SDL2.SDL_mixer/Mix_EffectFunc_t,SDL2.SDL_mixer/Mix_EffectDone_t,System.IntPtr) +M: System.Int32 SDL2.SDL_mixer::Mix_UnregisterEffect(System.Int32,SDL2.SDL_mixer/Mix_EffectFunc_t) +M: System.Int32 SDL2.SDL_mixer::Mix_UnregisterAllEffects(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_SetPanning(System.Int32,System.Byte,System.Byte) +M: System.Int32 SDL2.SDL_mixer::Mix_SetPosition(System.Int32,System.Int16,System.Byte) +M: System.Int32 SDL2.SDL_mixer::Mix_SetDistance(System.Int32,System.Byte) +M: System.Int32 SDL2.SDL_mixer::Mix_SetReverseStereo(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_ReserveChannels(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupChannel(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupChannels(System.Int32,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupAvailable(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupCount(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupOldest(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupNewer(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_PlayChannel(System.Int32,System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_PlayChannelTimed(System.Int32,System.IntPtr,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_PlayMusic(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeInMusic(System.IntPtr,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeInMusicPos(System.IntPtr,System.Int32,System.Int32,System.Double) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeInChannel(System.Int32,System.IntPtr,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeInChannelTimed(System.Int32,System.IntPtr,System.Int32,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_Volume(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_VolumeChunk(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_VolumeMusic(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_HaltChannel(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_HaltGroup(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_HaltMusic() +M: System.Int32 SDL2.SDL_mixer::Mix_ExpireChannel(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeOutChannel(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeOutGroup(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeOutMusic(System.Int32) +M: SDL2.SDL_mixer/Mix_Fading SDL2.SDL_mixer::Mix_FadingMusic() +M: SDL2.SDL_mixer/Mix_Fading SDL2.SDL_mixer::Mix_FadingChannel(System.Int32) +M: System.Void SDL2.SDL_mixer::Mix_Pause(System.Int32) +M: System.Void SDL2.SDL_mixer::Mix_Resume(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_Paused(System.Int32) +M: System.Void SDL2.SDL_mixer::Mix_PauseMusic() +M: System.Void SDL2.SDL_mixer::Mix_ResumeMusic() +M: System.Void SDL2.SDL_mixer::Mix_RewindMusic() +M: System.Int32 SDL2.SDL_mixer::Mix_PausedMusic() +M: System.Int32 SDL2.SDL_mixer::Mix_SetMusicPosition(System.Double) +M: System.Int32 SDL2.SDL_mixer::Mix_Playing(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_PlayingMusic() +M: System.Int32 SDL2.SDL_mixer::Mix_SetMusicCMD(System.String) +M: System.Int32 SDL2.SDL_mixer::Mix_SetSynchroValue(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GetSynchroValue() +M: System.Int32 SDL2.SDL_mixer::Mix_SetSoundFonts(System.String) +M: System.String SDL2.SDL_mixer::Mix_GetSoundFonts() +M: System.Int32 SDL2.SDL_mixer::Mix_EachSoundFont(SDL2.SDL_mixer/SoundFontDelegate,System.IntPtr) +M: System.IntPtr SDL2.SDL_mixer::Mix_GetChunk(System.Int32) +M: System.Void SDL2.SDL_mixer::Mix_CloseAudio() +T: SDL2.SDL_mixer/MIX_InitFlags +T: SDL2.SDL_mixer/Mix_Fading +T: SDL2.SDL_mixer/Mix_MusicType +T: SDL2.SDL_mixer/Mix_EffectFunc_t +T: SDL2.SDL_mixer/Mix_EffectDone_t +T: SDL2.SDL_ttf +M: System.Void SDL2.SDL_ttf::SDL_TTF_VERSION(SDL2.SDL/SDL_version&) +M: SDL2.SDL/SDL_version SDL2.SDL_ttf::TTF_LinkedVersion() +M: System.Void SDL2.SDL_ttf::TTF_ByteSwappedUNICODE(System.Int32) +M: System.Int32 SDL2.SDL_ttf::TTF_Init() +M: System.IntPtr SDL2.SDL_ttf::TTF_OpenFont(System.String,System.Int32) +M: System.IntPtr SDL2.SDL_ttf::TTF_OpenFontRW(System.IntPtr,System.Int32,System.Int32) +M: System.IntPtr SDL2.SDL_ttf::TTF_OpenFontIndex(System.String,System.Int32,System.Int64) +M: System.IntPtr SDL2.SDL_ttf::TTF_OpenFontIndexRW(System.IntPtr,System.Int32,System.Int32,System.Int64) +M: System.Int32 SDL2.SDL_ttf::TTF_GetFontStyle(System.IntPtr) +M: System.Void SDL2.SDL_ttf::TTF_SetFontStyle(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_ttf::TTF_GetFontOutline(System.IntPtr) +M: System.Void SDL2.SDL_ttf::TTF_SetFontOutline(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_ttf::TTF_GetFontHinting(System.IntPtr) +M: System.Void SDL2.SDL_ttf::TTF_SetFontHinting(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_ttf::TTF_FontHeight(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_FontAscent(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_FontDescent(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_FontLineSkip(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_GetFontKerning(System.IntPtr) +M: System.Void SDL2.SDL_ttf::TTF_SetFontKerning(System.IntPtr,System.Int32) +M: System.Int64 SDL2.SDL_ttf::TTF_FontFaces(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_FontFaceIsFixedWidth(System.IntPtr) +M: System.String SDL2.SDL_ttf::TTF_FontFaceFamilyName(System.IntPtr) +M: System.String SDL2.SDL_ttf::TTF_FontFaceStyleName(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_GlyphIsProvided(System.IntPtr,System.UInt16) +M: System.Int32 SDL2.SDL_ttf::TTF_GlyphMetrics(System.IntPtr,System.UInt16,System.Int32&,System.Int32&,System.Int32&,System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL_ttf::TTF_SizeText(System.IntPtr,System.String,System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL_ttf::INTERNAL_TTF_SizeUTF8(System.IntPtr,System.Byte[],System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL_ttf::TTF_SizeUTF8(System.IntPtr,System.String,System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL_ttf::TTF_SizeUNICODE(System.IntPtr,System.String,System.Int32&,System.Int32&) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderText_Solid(System.IntPtr,System.String,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUTF8_Solid(System.IntPtr,System.String,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUNICODE_Solid(System.IntPtr,System.String,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderGlyph_Solid(System.IntPtr,System.UInt16,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderText_Shaded(System.IntPtr,System.String,SDL2.SDL/SDL_Color,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUTF8_Shaded(System.IntPtr,System.String,SDL2.SDL/SDL_Color,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUNICODE_Shaded(System.IntPtr,System.String,SDL2.SDL/SDL_Color,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderGlyph_Shaded(System.IntPtr,System.UInt16,SDL2.SDL/SDL_Color,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderText_Blended(System.IntPtr,System.String,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUTF8_Blended(System.IntPtr,System.String,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUNICODE_Blended(System.IntPtr,System.String,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderText_Blended_Wrapped(System.IntPtr,System.String,SDL2.SDL/SDL_Color,System.UInt32) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUTF8_Blended_Wrapped(System.IntPtr,System.String,SDL2.SDL/SDL_Color,System.UInt32) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUNICODE_Blended_Wrapped(System.IntPtr,System.String,SDL2.SDL/SDL_Color,System.UInt32) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderGlyph_Blended(System.IntPtr,System.UInt16,SDL2.SDL/SDL_Color) +M: System.Void SDL2.SDL_ttf::TTF_CloseFont(System.IntPtr) +M: System.Void SDL2.SDL_ttf::TTF_Quit() +M: System.Int32 SDL2.SDL_ttf::TTF_WasInit() +M: System.Int32 SDL2.SDL_ttf::SDL_GetFontKerningSize(System.IntPtr,System.Int32,System.Int32) + +R: Gendarme.Rules.Design.AvoidRefAndOutParametersRule +M: System.Void SDL2.SDL::SDL_LogGetOutputFunction(SDL2.SDL/SDL_LogOutputFunction&,System.IntPtr&) +M: System.Int32 SDL2.SDL::SDL_ShowMessageBox(SDL2.SDL/SDL_MessageBoxData&,System.Int32&) +M: System.Void SDL2.SDL::SDL_VERSION(SDL2.SDL/SDL_version&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_PointInRect(SDL2.SDL/SDL_Point&,SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_RectEmpty(SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_RectEquals(SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GetEventFilter(SDL2.SDL/SDL_EventFilter&,System.IntPtr&) +M: SDL2.SDL/SDL_AudioSpec SDL2.SDL::SDL_LoadWAV(System.String,SDL2.SDL/SDL_AudioSpec&,System.IntPtr&,System.UInt32&) +M: System.UInt32 SDL2.SDL::SDL_OpenAudioDevice(System.String,System.Int32,SDL2.SDL/SDL_AudioSpec&,SDL2.SDL/SDL_AudioSpec&,System.Int32) +M: System.Void SDL2.SDL_image::SDL_IMAGE_VERSION(SDL2.SDL/SDL_version&) +M: System.Void SDL2.SDL_mixer::SDL_MIXER_VERSION(SDL2.SDL/SDL_version&) +M: System.Void SDL2.SDL_ttf::SDL_TTF_VERSION(SDL2.SDL/SDL_version&) +M: System.Int32 SDL2.SDL_ttf::TTF_SizeUTF8(System.IntPtr,System.String,System.Int32&,System.Int32&) + +R: Gendarme.Rules.Performance.AvoidUnneededFieldInitializationRule +M: System.Void SDL2.SDL::.cctor() + +R: Gendarme.Rules.Performance.AvoidUnusedPrivateFieldsRule +T: SDL2.SDL/SDL_WindowEvent +T: SDL2.SDL/SDL_KeyboardEvent +T: SDL2.SDL/SDL_MouseMotionEvent +T: SDL2.SDL/SDL_MouseButtonEvent +T: SDL2.SDL/SDL_JoyAxisEvent +T: SDL2.SDL/SDL_JoyBallEvent +T: SDL2.SDL/SDL_JoyHatEvent +T: SDL2.SDL/SDL_JoyButtonEvent +T: SDL2.SDL/SDL_ControllerAxisEvent +T: SDL2.SDL/SDL_ControllerButtonEvent +T: SDL2.SDL/SDL_AudioDeviceEvent + +R: Gendarme.Rules.BadPractice.AvoidVisibleConstantFieldRule +T: SDL2.SDL +T: SDL2.SDL_image +T: SDL2.SDL_mixer +T: SDL2.SDL_ttf + +R: Gendarme.Rules.Design.AvoidVisibleFieldsRule +T: SDL2.SDL/SDL_MessageBoxButtonData +T: SDL2.SDL/SDL_MessageBoxColor +T: SDL2.SDL/SDL_MessageBoxColorScheme +T: SDL2.SDL/SDL_MessageBoxData +T: SDL2.SDL/SDL_version +T: SDL2.SDL/SDL_DisplayMode +T: SDL2.SDL/SDL_RendererInfo +T: SDL2.SDL/SDL_Color +T: SDL2.SDL/SDL_Palette +T: SDL2.SDL/SDL_PixelFormat +T: SDL2.SDL/SDL_Point +T: SDL2.SDL/SDL_Rect +T: SDL2.SDL/SDL_Surface +T: SDL2.SDL/SDL_GenericEvent +T: SDL2.SDL/SDL_WindowEvent +T: SDL2.SDL/SDL_KeyboardEvent +T: SDL2.SDL/SDL_TextEditingEvent +T: SDL2.SDL/SDL_TextInputEvent +T: SDL2.SDL/SDL_MouseMotionEvent +T: SDL2.SDL/SDL_MouseButtonEvent +T: SDL2.SDL/SDL_MouseWheelEvent +T: SDL2.SDL/SDL_JoyAxisEvent +T: SDL2.SDL/SDL_JoyBallEvent +T: SDL2.SDL/SDL_JoyHatEvent +T: SDL2.SDL/SDL_JoyButtonEvent +T: SDL2.SDL/SDL_JoyDeviceEvent +T: SDL2.SDL/SDL_ControllerAxisEvent +T: SDL2.SDL/SDL_ControllerButtonEvent +T: SDL2.SDL/SDL_ControllerDeviceEvent +T: SDL2.SDL/SDL_AudioDeviceEvent +T: SDL2.SDL/SDL_TouchFingerEvent +T: SDL2.SDL/SDL_MultiGestureEvent +T: SDL2.SDL/SDL_DollarGestureEvent +T: SDL2.SDL/SDL_DropEvent +T: SDL2.SDL/SDL_QuitEvent +T: SDL2.SDL/SDL_UserEvent +T: SDL2.SDL/SDL_SysWMEvent +T: SDL2.SDL/SDL_Event +T: SDL2.SDL/SDL_Keysym +T: SDL2.SDL/SDL_Finger +T: SDL2.SDL/INTERNAL_GameControllerButtonBind_hat +T: SDL2.SDL/INTERNAL_GameControllerButtonBind_union +T: SDL2.SDL/SDL_GameControllerButtonBind +T: SDL2.SDL/SDL_HapticDirection +T: SDL2.SDL/SDL_HapticConstant +T: SDL2.SDL/SDL_HapticPeriodic +T: SDL2.SDL/SDL_HapticCondition +T: SDL2.SDL/SDL_HapticRamp +T: SDL2.SDL/SDL_HapticLeftRight +T: SDL2.SDL/SDL_HapticCustom +T: SDL2.SDL/SDL_HapticEffect +T: SDL2.SDL/SDL_AudioSpec +T: SDL2.SDL/INTERNAL_windows_wminfo +T: SDL2.SDL/INTERNAL_winrt_wminfo +T: SDL2.SDL/INTERNAL_x11_wminfo +T: SDL2.SDL/INTERNAL_directfb_wminfo +T: SDL2.SDL/INTERNAL_cocoa_wminfo +T: SDL2.SDL/INTERNAL_uikit_wminfo +T: SDL2.SDL/INTERNAL_wayland_wminfo +T: SDL2.SDL/INTERNAL_mir_wminfo +T: SDL2.SDL/INTERNAL_android_wminfo +T: SDL2.SDL/INTERNAL_SysWMDriverUnion +T: SDL2.SDL/SDL_SysWMinfo + +R: Gendarme.Rules.Design.AvoidVisibleNestedTypesRule +T: SDL2.SDL/SDL_bool +T: SDL2.SDL/SDL_WinRT_mainFunction +T: SDL2.SDL/SDL_HintPriority +T: SDL2.SDL/SDL_LogPriority +T: SDL2.SDL/SDL_LogOutputFunction +T: SDL2.SDL/SDL_MessageBoxFlags +T: SDL2.SDL/SDL_MessageBoxButtonFlags +T: SDL2.SDL/SDL_MessageBoxButtonData +T: SDL2.SDL/SDL_MessageBoxColor +T: SDL2.SDL/SDL_MessageBoxColorType +T: SDL2.SDL/SDL_MessageBoxColorScheme +T: SDL2.SDL/SDL_MessageBoxData +T: SDL2.SDL/SDL_version +T: SDL2.SDL/SDL_GLattr +T: SDL2.SDL/SDL_GLprofile +T: SDL2.SDL/SDL_GLcontext +T: SDL2.SDL/SDL_WindowEventID +T: SDL2.SDL/SDL_WindowFlags +T: SDL2.SDL/SDL_HitTestResult +T: SDL2.SDL/SDL_DisplayMode +T: SDL2.SDL/SDL_HitTest +T: SDL2.SDL/SDL_BlendMode +T: SDL2.SDL/SDL_BlendOperation +T: SDL2.SDL/SDL_BlendFactor +T: SDL2.SDL/SDL_RendererFlags +T: SDL2.SDL/SDL_RendererFlip +T: SDL2.SDL/SDL_TextureAccess +T: SDL2.SDL/SDL_TextureModulate +T: SDL2.SDL/SDL_RendererInfo +T: SDL2.SDL/SDL_RendererInfo/__FixedBuffer0 +T: SDL2.SDL/SDL_PIXELTYPE_ENUM +T: SDL2.SDL/SDL_PIXELORDER_ENUM +T: SDL2.SDL/SDL_PACKEDLAYOUT_ENUM +T: SDL2.SDL/SDL_Color +T: SDL2.SDL/SDL_Palette +T: SDL2.SDL/SDL_PixelFormat +T: SDL2.SDL/SDL_Point +T: SDL2.SDL/SDL_Rect +T: SDL2.SDL/SDL_Surface +T: SDL2.SDL/SDL_EventType +T: SDL2.SDL/SDL_MouseWheelDirection +T: SDL2.SDL/SDL_GenericEvent +T: SDL2.SDL/SDL_WindowEvent +T: SDL2.SDL/SDL_KeyboardEvent +T: SDL2.SDL/SDL_TextEditingEvent +T: SDL2.SDL/SDL_TextEditingEvent/__FixedBuffer1 +T: SDL2.SDL/SDL_TextInputEvent +T: SDL2.SDL/SDL_TextInputEvent/__FixedBuffer2 +T: SDL2.SDL/SDL_MouseMotionEvent +T: SDL2.SDL/SDL_MouseButtonEvent +T: SDL2.SDL/SDL_MouseWheelEvent +T: SDL2.SDL/SDL_JoyAxisEvent +T: SDL2.SDL/SDL_JoyBallEvent +T: SDL2.SDL/SDL_JoyHatEvent +T: SDL2.SDL/SDL_JoyButtonEvent +T: SDL2.SDL/SDL_JoyDeviceEvent +T: SDL2.SDL/SDL_ControllerAxisEvent +T: SDL2.SDL/SDL_ControllerButtonEvent +T: SDL2.SDL/SDL_ControllerDeviceEvent +T: SDL2.SDL/SDL_AudioDeviceEvent +T: SDL2.SDL/SDL_TouchFingerEvent +T: SDL2.SDL/SDL_MultiGestureEvent +T: SDL2.SDL/SDL_DollarGestureEvent +T: SDL2.SDL/SDL_DropEvent +T: SDL2.SDL/SDL_QuitEvent +T: SDL2.SDL/SDL_UserEvent +T: SDL2.SDL/SDL_SysWMEvent +T: SDL2.SDL/SDL_Event +T: SDL2.SDL/SDL_EventFilter +T: SDL2.SDL/SDL_eventaction +T: SDL2.SDL/SDL_Scancode +T: SDL2.SDL/SDL_Keycode +T: SDL2.SDL/SDL_Keymod +T: SDL2.SDL/SDL_Keysym +T: SDL2.SDL/SDL_SystemCursor +T: SDL2.SDL/SDL_Finger +T: SDL2.SDL/SDL_JoystickPowerLevel +T: SDL2.SDL/SDL_JoystickType +T: SDL2.SDL/SDL_GameControllerBindType +T: SDL2.SDL/SDL_GameControllerAxis +T: SDL2.SDL/SDL_GameControllerButton +T: SDL2.SDL/INTERNAL_GameControllerButtonBind_hat +T: SDL2.SDL/INTERNAL_GameControllerButtonBind_union +T: SDL2.SDL/SDL_GameControllerButtonBind +T: SDL2.SDL/SDL_HapticDirection +T: SDL2.SDL/SDL_HapticDirection/__FixedBuffer3 +T: SDL2.SDL/SDL_HapticConstant +T: SDL2.SDL/SDL_HapticPeriodic +T: SDL2.SDL/SDL_HapticCondition +T: SDL2.SDL/SDL_HapticCondition/__FixedBuffer4 +T: SDL2.SDL/SDL_HapticCondition/__FixedBuffer5 +T: SDL2.SDL/SDL_HapticCondition/__FixedBuffer6 +T: SDL2.SDL/SDL_HapticCondition/__FixedBuffer7 +T: SDL2.SDL/SDL_HapticCondition/__FixedBuffer8 +T: SDL2.SDL/SDL_HapticCondition/
__FixedBuffer9 +T: SDL2.SDL/SDL_HapticRamp +T: SDL2.SDL/SDL_HapticLeftRight +T: SDL2.SDL/SDL_HapticCustom +T: SDL2.SDL/SDL_HapticEffect +T: SDL2.SDL/SDL_AudioStatus +T: SDL2.SDL/SDL_AudioSpec +T: SDL2.SDL/SDL_AudioCallback +T: SDL2.SDL/SDL_TimerCallback +T: SDL2.SDL/SDL_SYSWM_TYPE +T: SDL2.SDL/INTERNAL_windows_wminfo +T: SDL2.SDL/INTERNAL_winrt_wminfo +T: SDL2.SDL/INTERNAL_x11_wminfo +T: SDL2.SDL/INTERNAL_directfb_wminfo +T: SDL2.SDL/INTERNAL_cocoa_wminfo +T: SDL2.SDL/INTERNAL_uikit_wminfo +T: SDL2.SDL/INTERNAL_wayland_wminfo +T: SDL2.SDL/INTERNAL_mir_wminfo +T: SDL2.SDL/INTERNAL_android_wminfo +T: SDL2.SDL/INTERNAL_SysWMDriverUnion +T: SDL2.SDL/SDL_SysWMinfo +T: SDL2.SDL/SDL_PowerState +T: SDL2.SDL_image/IMG_InitFlags +T: SDL2.SDL_mixer/MIX_InitFlags +T: SDL2.SDL_mixer/Mix_Fading +T: SDL2.SDL_mixer/Mix_MusicType +T: SDL2.SDL_mixer/MixFuncDelegate +T: SDL2.SDL_mixer/Mix_EffectFunc_t +T: SDL2.SDL_mixer/Mix_EffectDone_t +T: SDL2.SDL_mixer/MusicFinishedDelegate +T: SDL2.SDL_mixer/ChannelFinishedDelegate +T: SDL2.SDL_mixer/SoundFontDelegate + +R: Gendarme.Rules.Interoperability.CentralizePInvokesIntoNativeMethodsTypeRule +M: System.IntPtr SDL2.SDL::SDL_malloc(System.IntPtr) +M: System.Void SDL2.SDL::SDL_free(System.IntPtr) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_RWFromFile(System.Byte[],System.Byte[]) +M: System.IntPtr SDL2.SDL::SDL_RWFromMem(System.IntPtr,System.Int32) +M: System.Void SDL2.SDL::SDL_SetMainReady() +M: System.Int32 SDL2.SDL::SDL_WinRTRunApp(SDL2.SDL/SDL_WinRT_mainFunction,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_Init(System.UInt32) +M: System.Int32 SDL2.SDL::SDL_InitSubSystem(System.UInt32) +M: System.Void SDL2.SDL::SDL_Quit() +M: System.Void SDL2.SDL::SDL_QuitSubSystem(System.UInt32) +M: System.UInt32 SDL2.SDL::SDL_WasInit(System.UInt32) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetPlatform() +M: System.Void SDL2.SDL::SDL_ClearHints() +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetHint(System.Byte[]) +M: SDL2.SDL/SDL_bool SDL2.SDL::INTERNAL_SDL_SetHint(System.Byte[],System.Byte[]) +M: SDL2.SDL/SDL_bool SDL2.SDL::INTERNAL_SDL_SetHintWithPriority(System.Byte[],System.Byte[],SDL2.SDL/SDL_HintPriority) +M: SDL2.SDL/SDL_bool SDL2.SDL::INTERNAL_SDL_GetHintBoolean(System.Byte[],SDL2.SDL/SDL_bool) +M: System.Void SDL2.SDL::SDL_ClearError() +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetError() +M: System.Void SDL2.SDL::INTERNAL_SDL_SetError(System.Byte[]) +M: System.Void SDL2.SDL::INTERNAL_SDL_Log(System.Byte[]) +M: System.Void SDL2.SDL::INTERNAL_SDL_LogVerbose(System.Int32,System.Byte[]) +M: System.Void SDL2.SDL::INTERNAL_SDL_LogDebug(System.Int32,System.Byte[]) +M: System.Void SDL2.SDL::INTERNAL_SDL_LogInfo(System.Int32,System.Byte[]) +M: System.Void SDL2.SDL::INTERNAL_SDL_LogWarn(System.Int32,System.Byte[]) +M: System.Void SDL2.SDL::INTERNAL_SDL_LogError(System.Int32,System.Byte[]) +M: System.Void SDL2.SDL::INTERNAL_SDL_LogCritical(System.Int32,System.Byte[]) +M: System.Void SDL2.SDL::INTERNAL_SDL_LogMessage(System.Int32,SDL2.SDL/SDL_LogPriority,System.Byte[]) +M: System.Void SDL2.SDL::INTERNAL_SDL_LogMessageV(System.Int32,SDL2.SDL/SDL_LogPriority,System.Byte[]) +M: SDL2.SDL/SDL_LogPriority SDL2.SDL::SDL_LogGetPriority(System.Int32) +M: System.Void SDL2.SDL::SDL_LogSetPriority(System.Int32,SDL2.SDL/SDL_LogPriority) +M: System.Void SDL2.SDL::SDL_LogSetAllPriority(SDL2.SDL/SDL_LogPriority) +M: System.Void SDL2.SDL::SDL_LogResetPriorities() +M: System.Void SDL2.SDL::SDL_LogGetOutputFunction(System.IntPtr&,System.IntPtr&) +M: System.Void SDL2.SDL::SDL_LogSetOutputFunction(SDL2.SDL/SDL_LogOutputFunction,System.IntPtr) +M: System.Int32 SDL2.SDL::INTERNAL_SDL_ShowMessageBox(SDL2.SDL/INTERNAL_SDL_MessageBoxData&,System.Int32&) +M: System.Int32 SDL2.SDL::INTERNAL_SDL_ShowSimpleMessageBox(SDL2.SDL/SDL_MessageBoxFlags,System.Byte[],System.Byte[],System.IntPtr) +M: System.Void SDL2.SDL::SDL_GetVersion(SDL2.SDL/SDL_version&) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetRevision() +M: System.Int32 SDL2.SDL::SDL_GetRevisionNumber() +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_CreateWindow(System.Byte[],System.Int32,System.Int32,System.Int32,System.Int32,SDL2.SDL/SDL_WindowFlags) +M: System.Int32 SDL2.SDL::SDL_CreateWindowAndRenderer(System.Int32,System.Int32,SDL2.SDL/SDL_WindowFlags,System.IntPtr&,System.IntPtr&) +M: System.IntPtr SDL2.SDL::SDL_CreateWindowFrom(System.IntPtr) +M: System.Void SDL2.SDL::SDL_DestroyWindow(System.IntPtr) +M: System.Void SDL2.SDL::SDL_DisableScreenSaver() +M: System.Void SDL2.SDL::SDL_EnableScreenSaver() +M: System.IntPtr SDL2.SDL::SDL_GetClosestDisplayMode(System.Int32,SDL2.SDL/SDL_DisplayMode&,SDL2.SDL/SDL_DisplayMode&) +M: System.Int32 SDL2.SDL::SDL_GetCurrentDisplayMode(System.Int32,SDL2.SDL/SDL_DisplayMode&) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetCurrentVideoDriver() +M: System.Int32 SDL2.SDL::SDL_GetDesktopDisplayMode(System.Int32,SDL2.SDL/SDL_DisplayMode&) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetDisplayName(System.Int32) +M: System.Int32 SDL2.SDL::SDL_GetDisplayBounds(System.Int32,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_GetDisplayDPI(System.Int32,System.Single&,System.Single&,System.Single&) +M: System.Int32 SDL2.SDL::SDL_GetDisplayMode(System.Int32,System.Int32,SDL2.SDL/SDL_DisplayMode&) +M: System.Int32 SDL2.SDL::SDL_GetDisplayUsableBounds(System.Int32,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_GetNumDisplayModes(System.Int32) +M: System.Int32 SDL2.SDL::SDL_GetNumVideoDisplays() +M: System.Int32 SDL2.SDL::SDL_GetNumVideoDrivers() +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetVideoDriver(System.Int32) +M: System.Single SDL2.SDL::SDL_GetWindowBrightness(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetWindowOpacity(System.IntPtr,System.Single) +M: System.Int32 SDL2.SDL::SDL_GetWindowOpacity(System.IntPtr,System.Single&) +M: System.Int32 SDL2.SDL::SDL_SetWindowModalFor(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetWindowInputFocus(System.IntPtr) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetWindowData(System.IntPtr,System.Byte[]) +M: System.Int32 SDL2.SDL::SDL_GetWindowDisplayIndex(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GetWindowDisplayMode(System.IntPtr,SDL2.SDL/SDL_DisplayMode&) +M: System.UInt32 SDL2.SDL::SDL_GetWindowFlags(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GetWindowFromID(System.UInt32) +M: System.Int32 SDL2.SDL::SDL_GetWindowGammaRamp(System.IntPtr,System.UInt16[],System.UInt16[],System.UInt16[]) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GetWindowGrab(System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetWindowID(System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetWindowPixelFormat(System.IntPtr) +M: System.Void SDL2.SDL::SDL_GetWindowMaximumSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_GetWindowMinimumSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_GetWindowPosition(System.IntPtr,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_GetWindowSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.IntPtr SDL2.SDL::SDL_GetWindowSurface(System.IntPtr) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetWindowTitle(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GL_BindTexture(System.IntPtr,System.Single&,System.Single&) +M: System.IntPtr SDL2.SDL::SDL_GL_CreateContext(System.IntPtr) +M: System.Void SDL2.SDL::SDL_GL_DeleteContext(System.IntPtr) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GL_GetProcAddress(System.Byte[]) +M: System.IntPtr SDL2.SDL::SDL_GL_GetProcAddress(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::INTERNAL_SDL_GL_ExtensionSupported(System.Byte[]) +M: System.Void SDL2.SDL::SDL_GL_ResetAttributes() +M: System.Int32 SDL2.SDL::SDL_GL_GetAttribute(SDL2.SDL/SDL_GLattr,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_GL_GetSwapInterval() +M: System.Int32 SDL2.SDL::SDL_GL_MakeCurrent(System.IntPtr,System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GL_GetCurrentWindow() +M: System.IntPtr SDL2.SDL::SDL_GL_GetCurrentContext() +M: System.Void SDL2.SDL::SDL_GL_GetDrawableSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_GL_SetAttribute(SDL2.SDL/SDL_GLattr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_GL_SetSwapInterval(System.Int32) +M: System.Void SDL2.SDL::SDL_GL_SwapWindow(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GL_UnbindTexture(System.IntPtr) +M: System.Void SDL2.SDL::SDL_HideWindow(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IsScreenSaverEnabled() +M: System.Void SDL2.SDL::SDL_MaximizeWindow(System.IntPtr) +M: System.Void SDL2.SDL::SDL_MinimizeWindow(System.IntPtr) +M: System.Void SDL2.SDL::SDL_RaiseWindow(System.IntPtr) +M: System.Void SDL2.SDL::SDL_RestoreWindow(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetWindowBrightness(System.IntPtr,System.Single) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_SetWindowData(System.IntPtr,System.Byte[],System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetWindowDisplayMode(System.IntPtr,SDL2.SDL/SDL_DisplayMode&) +M: System.Int32 SDL2.SDL::SDL_SetWindowFullscreen(System.IntPtr,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_SetWindowGammaRamp(System.IntPtr,System.UInt16[],System.UInt16[],System.UInt16[]) +M: System.Void SDL2.SDL::SDL_SetWindowGrab(System.IntPtr,SDL2.SDL/SDL_bool) +M: System.Void SDL2.SDL::SDL_SetWindowIcon(System.IntPtr,System.IntPtr) +M: System.Void SDL2.SDL::SDL_SetWindowMaximumSize(System.IntPtr,System.Int32,System.Int32) +M: System.Void SDL2.SDL::SDL_SetWindowMinimumSize(System.IntPtr,System.Int32,System.Int32) +M: System.Void SDL2.SDL::SDL_SetWindowPosition(System.IntPtr,System.Int32,System.Int32) +M: System.Void SDL2.SDL::SDL_SetWindowSize(System.IntPtr,System.Int32,System.Int32) +M: System.Void SDL2.SDL::SDL_SetWindowBordered(System.IntPtr,SDL2.SDL/SDL_bool) +M: System.Int32 SDL2.SDL::SDL_GetWindowBordersSize(System.IntPtr,System.Int32&,System.Int32&,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_SetWindowResizable(System.IntPtr,SDL2.SDL/SDL_bool) +M: System.Void SDL2.SDL::INTERNAL_SDL_SetWindowTitle(System.IntPtr,System.Byte[]) +M: System.Void SDL2.SDL::SDL_ShowWindow(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_UpdateWindowSurface(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_UpdateWindowSurfaceRects(System.IntPtr,SDL2.SDL/SDL_Rect[],System.Int32) +M: System.Int32 SDL2.SDL::INTERNAL_SDL_VideoInit(System.Byte[]) +M: System.Void SDL2.SDL::SDL_VideoQuit() +M: System.Int32 SDL2.SDL::SDL_SetWindowHitTest(System.IntPtr,SDL2.SDL/SDL_HitTest,System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GetGrabbedWindow() +M: SDL2.SDL/SDL_BlendMode SDL2.SDL::SDL_ComposeCustomBlendMode(SDL2.SDL/SDL_BlendFactor,SDL2.SDL/SDL_BlendFactor,SDL2.SDL/SDL_BlendOperation,SDL2.SDL/SDL_BlendFactor,SDL2.SDL/SDL_BlendFactor,SDL2.SDL/SDL_BlendOperation) +M: System.Int32 SDL2.SDL::INTERNAL_SDL_Vulkan_LoadLibrary(System.Byte[]) +M: System.IntPtr SDL2.SDL::SDL_Vulkan_GetVkGetInstanceProcAddr() +M: System.Void SDL2.SDL::SDL_Vulkan_UnloadLibrary() +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_Vulkan_GetInstanceExtensions(System.IntPtr,System.UInt32&,System.IntPtr[]) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_Vulkan_CreateSurface(System.IntPtr,System.IntPtr,System.IntPtr&) +M: System.Void SDL2.SDL::SDL_Vulkan_GetDrawableSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.IntPtr SDL2.SDL::SDL_CreateRenderer(System.IntPtr,System.Int32,SDL2.SDL/SDL_RendererFlags) +M: System.IntPtr SDL2.SDL::SDL_CreateSoftwareRenderer(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_CreateTexture(System.IntPtr,System.UInt32,System.Int32,System.Int32,System.Int32) +M: System.IntPtr SDL2.SDL::SDL_CreateTextureFromSurface(System.IntPtr,System.IntPtr) +M: System.Void SDL2.SDL::SDL_DestroyRenderer(System.IntPtr) +M: System.Void SDL2.SDL::SDL_DestroyTexture(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GetNumRenderDrivers() +M: System.Int32 SDL2.SDL::SDL_GetRenderDrawBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode&) +M: System.Int32 SDL2.SDL::SDL_GetRenderDrawColor(System.IntPtr,System.Byte&,System.Byte&,System.Byte&,System.Byte&) +M: System.Int32 SDL2.SDL::SDL_GetRenderDriverInfo(System.Int32,SDL2.SDL/SDL_RendererInfo&) +M: System.IntPtr SDL2.SDL::SDL_GetRenderer(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GetRendererInfo(System.IntPtr,SDL2.SDL/SDL_RendererInfo&) +M: System.Int32 SDL2.SDL::SDL_GetRendererOutputSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_GetTextureAlphaMod(System.IntPtr,System.Byte&) +M: System.Int32 SDL2.SDL::SDL_GetTextureBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode&) +M: System.Int32 SDL2.SDL::SDL_GetTextureColorMod(System.IntPtr,System.Byte&,System.Byte&,System.Byte&) +M: System.Int32 SDL2.SDL::SDL_LockTexture(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_LockTexture(System.IntPtr,System.IntPtr,System.IntPtr&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_QueryTexture(System.IntPtr,System.UInt32&,System.Int32&,System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_RenderClear(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderCopy(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_RenderCopy(System.IntPtr,System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_RenderCopy(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderCopy(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&,System.Double,SDL2.SDL/SDL_Point&,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,System.Double,SDL2.SDL/SDL_Point&,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,System.Double,SDL2.SDL/SDL_Point&,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&,System.Double,System.IntPtr,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.Double,SDL2.SDL/SDL_Point&,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,System.Double,System.IntPtr,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,System.Double,System.IntPtr,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderCopyEx(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.Double,System.IntPtr,SDL2.SDL/SDL_RendererFlip) +M: System.Int32 SDL2.SDL::SDL_RenderDrawLine(System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderDrawLines(System.IntPtr,SDL2.SDL/SDL_Point[],System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderDrawPoint(System.IntPtr,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderDrawPoints(System.IntPtr,SDL2.SDL/SDL_Point[],System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderDrawRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_RenderDrawRect(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderDrawRects(System.IntPtr,SDL2.SDL/SDL_Rect[],System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderFillRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_RenderFillRect(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderFillRects(System.IntPtr,SDL2.SDL/SDL_Rect[],System.Int32) +M: System.Void SDL2.SDL::SDL_RenderGetClipRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Void SDL2.SDL::SDL_RenderGetLogicalSize(System.IntPtr,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_RenderGetScale(System.IntPtr,System.Single&,System.Single&) +M: System.Int32 SDL2.SDL::SDL_RenderGetViewport(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Void SDL2.SDL::SDL_RenderPresent(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderReadPixels(System.IntPtr,SDL2.SDL/SDL_Rect&,System.UInt32,System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderSetClipRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_RenderSetClipRect(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_RenderSetLogicalSize(System.IntPtr,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_RenderSetScale(System.IntPtr,System.Single,System.Single) +M: System.Int32 SDL2.SDL::SDL_RenderSetIntegerScale(System.IntPtr,SDL2.SDL/SDL_bool) +M: System.Int32 SDL2.SDL::SDL_RenderSetViewport(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_SetRenderDrawBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode) +M: System.Int32 SDL2.SDL::SDL_SetRenderDrawColor(System.IntPtr,System.Byte,System.Byte,System.Byte,System.Byte) +M: System.Int32 SDL2.SDL::SDL_SetRenderTarget(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetTextureAlphaMod(System.IntPtr,System.Byte) +M: System.Int32 SDL2.SDL::SDL_SetTextureBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode) +M: System.Int32 SDL2.SDL::SDL_SetTextureColorMod(System.IntPtr,System.Byte,System.Byte,System.Byte) +M: System.Void SDL2.SDL::SDL_UnlockTexture(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_UpdateTexture(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_UpdateTexture(System.IntPtr,System.IntPtr,System.IntPtr,System.Int32) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_RenderTargetSupported(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GetRenderTarget(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_RenderIsClipEnabled(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_AllocFormat(System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_AllocPalette(System.Int32) +M: System.Void SDL2.SDL::SDL_CalculateGammaRamp(System.Single,System.UInt16[]) +M: System.Void SDL2.SDL::SDL_FreeFormat(System.IntPtr) +M: System.Void SDL2.SDL::SDL_FreePalette(System.IntPtr) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetPixelFormatName(System.UInt32) +M: System.Void SDL2.SDL::SDL_GetRGB(System.UInt32,System.IntPtr,System.Byte&,System.Byte&,System.Byte&) +M: System.Void SDL2.SDL::SDL_GetRGBA(System.UInt32,System.IntPtr,System.Byte&,System.Byte&,System.Byte&,System.Byte&) +M: System.UInt32 SDL2.SDL::SDL_MapRGB(System.IntPtr,System.Byte,System.Byte,System.Byte) +M: System.UInt32 SDL2.SDL::SDL_MapRGBA(System.IntPtr,System.Byte,System.Byte,System.Byte,System.Byte) +M: System.UInt32 SDL2.SDL::SDL_MasksToPixelFormatEnum(System.Int32,System.UInt32,System.UInt32,System.UInt32,System.UInt32) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_PixelFormatEnumToMasks(System.UInt32,System.Int32&,System.UInt32&,System.UInt32&,System.UInt32&,System.UInt32&) +M: System.Int32 SDL2.SDL::SDL_SetPaletteColors(System.IntPtr,SDL2.SDL/SDL_Color[],System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_SetPixelFormatPalette(System.IntPtr,System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_EnclosePoints(SDL2.SDL/SDL_Point[],System.Int32,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_HasIntersection(SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IntersectRect(SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IntersectRectAndLine(SDL2.SDL/SDL_Rect&,System.Int32&,System.Int32&,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_UnionRect(SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_BlitSurface(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_BlitSurface(System.IntPtr,System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_BlitSurface(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_BlitSurface(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_BlitScaled(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_BlitScaled(System.IntPtr,System.IntPtr,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_BlitScaled(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_BlitScaled(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_ConvertPixels(System.Int32,System.Int32,System.UInt32,System.IntPtr,System.Int32,System.UInt32,System.IntPtr,System.Int32) +M: System.IntPtr SDL2.SDL::SDL_ConvertSurface(System.IntPtr,System.IntPtr,System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_ConvertSurfaceFormat(System.IntPtr,System.UInt32,System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_CreateRGBSurface(System.UInt32,System.Int32,System.Int32,System.Int32,System.UInt32,System.UInt32,System.UInt32,System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_CreateRGBSurfaceFrom(System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32,System.UInt32,System.UInt32,System.UInt32,System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_CreateRGBSurfaceWithFormat(System.UInt32,System.Int32,System.Int32,System.Int32,System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_CreateRGBSurfaceWithFormatFrom(System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_FillRect(System.IntPtr,SDL2.SDL/SDL_Rect&,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_FillRect(System.IntPtr,System.IntPtr,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_FillRects(System.IntPtr,SDL2.SDL/SDL_Rect[],System.Int32,System.UInt32) +M: System.Void SDL2.SDL::SDL_FreeSurface(System.IntPtr) +M: System.Void SDL2.SDL::SDL_GetClipRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_GetColorKey(System.IntPtr,System.UInt32&) +M: System.Int32 SDL2.SDL::SDL_GetSurfaceAlphaMod(System.IntPtr,System.Byte&) +M: System.Int32 SDL2.SDL::SDL_GetSurfaceBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode&) +M: System.Int32 SDL2.SDL::SDL_GetSurfaceColorMod(System.IntPtr,System.Byte&,System.Byte&,System.Byte&) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_LoadBMP_RW(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_LockSurface(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_LowerBlit(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_LowerBlitScaled(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::INTERNAL_SDL_SaveBMP_RW(System.IntPtr,System.IntPtr,System.Int32) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_SetClipRect(System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_SetColorKey(System.IntPtr,System.Int32,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_SetSurfaceAlphaMod(System.IntPtr,System.Byte) +M: System.Int32 SDL2.SDL::SDL_SetSurfaceBlendMode(System.IntPtr,SDL2.SDL/SDL_BlendMode) +M: System.Int32 SDL2.SDL::SDL_SetSurfaceColorMod(System.IntPtr,System.Byte,System.Byte,System.Byte) +M: System.Int32 SDL2.SDL::SDL_SetSurfacePalette(System.IntPtr,System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_SetSurfaceRLE(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_SoftStretch(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Void SDL2.SDL::SDL_UnlockSurface(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_UpperBlit(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.Int32 SDL2.SDL::SDL_UpperBlitScaled(System.IntPtr,SDL2.SDL/SDL_Rect&,System.IntPtr,SDL2.SDL/SDL_Rect&) +M: System.IntPtr SDL2.SDL::SDL_DuplicateSurface(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_HasClipboardText() +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetClipboardText() +M: System.Int32 SDL2.SDL::INTERNAL_SDL_SetClipboardText(System.Byte[]) +M: System.Void SDL2.SDL::SDL_PumpEvents() +M: System.Int32 SDL2.SDL::SDL_PeepEvents(SDL2.SDL/SDL_Event[],System.Int32,SDL2.SDL/SDL_eventaction,SDL2.SDL/SDL_EventType,SDL2.SDL/SDL_EventType) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_HasEvent(SDL2.SDL/SDL_EventType) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_HasEvents(SDL2.SDL/SDL_EventType,SDL2.SDL/SDL_EventType) +M: System.Void SDL2.SDL::SDL_FlushEvent(SDL2.SDL/SDL_EventType) +M: System.Void SDL2.SDL::SDL_FlushEvents(SDL2.SDL/SDL_EventType,SDL2.SDL/SDL_EventType) +M: System.Int32 SDL2.SDL::SDL_PollEvent(SDL2.SDL/SDL_Event&) +M: System.Int32 SDL2.SDL::SDL_WaitEvent(SDL2.SDL/SDL_Event&) +M: System.Int32 SDL2.SDL::SDL_WaitEventTimeout(SDL2.SDL/SDL_Event&,System.Int32) +M: System.Int32 SDL2.SDL::SDL_PushEvent(SDL2.SDL/SDL_Event&) +M: System.Void SDL2.SDL::SDL_SetEventFilter(SDL2.SDL/SDL_EventFilter,System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GetEventFilter(System.IntPtr&,System.IntPtr&) +M: System.Void SDL2.SDL::SDL_AddEventWatch(SDL2.SDL/SDL_EventFilter,System.IntPtr) +M: System.Void SDL2.SDL::SDL_DelEventWatch(SDL2.SDL/SDL_EventFilter,System.IntPtr) +M: System.Void SDL2.SDL::SDL_FilterEvents(SDL2.SDL/SDL_EventFilter,System.IntPtr) +M: System.Byte SDL2.SDL::SDL_EventState(SDL2.SDL/SDL_EventType,System.Int32) +M: System.UInt32 SDL2.SDL::SDL_RegisterEvents(System.Int32) +M: System.IntPtr SDL2.SDL::SDL_GetKeyboardFocus() +M: System.IntPtr SDL2.SDL::SDL_GetKeyboardState(System.Int32&) +M: SDL2.SDL/SDL_Keymod SDL2.SDL::SDL_GetModState() +M: System.Void SDL2.SDL::SDL_SetModState(SDL2.SDL/SDL_Keymod) +M: SDL2.SDL/SDL_Keycode SDL2.SDL::SDL_GetKeyFromScancode(SDL2.SDL/SDL_Scancode) +M: SDL2.SDL/SDL_Scancode SDL2.SDL::SDL_GetScancodeFromKey(SDL2.SDL/SDL_Keycode) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetScancodeName(SDL2.SDL/SDL_Scancode) +M: SDL2.SDL/SDL_Scancode SDL2.SDL::INTERNAL_SDL_GetScancodeFromName(System.Byte[]) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetKeyName(SDL2.SDL/SDL_Keycode) +M: SDL2.SDL/SDL_Keycode SDL2.SDL::INTERNAL_SDL_GetKeyFromName(System.Byte[]) +M: System.Void SDL2.SDL::SDL_StartTextInput() +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IsTextInputActive() +M: System.Void SDL2.SDL::SDL_StopTextInput() +M: System.Void SDL2.SDL::SDL_SetTextInputRect(SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_HasScreenKeyboardSupport() +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IsScreenKeyboardShown(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GetMouseFocus() +M: System.UInt32 SDL2.SDL::SDL_GetMouseState(System.Int32&,System.Int32&) +M: System.UInt32 SDL2.SDL::SDL_GetMouseState(System.IntPtr,System.Int32&) +M: System.UInt32 SDL2.SDL::SDL_GetMouseState(System.Int32&,System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetMouseState(System.IntPtr,System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetGlobalMouseState(System.Int32&,System.Int32&) +M: System.UInt32 SDL2.SDL::SDL_GetGlobalMouseState(System.IntPtr,System.Int32&) +M: System.UInt32 SDL2.SDL::SDL_GetGlobalMouseState(System.Int32&,System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetGlobalMouseState(System.IntPtr,System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_GetRelativeMouseState(System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_WarpMouseInWindow(System.IntPtr,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_WarpMouseGlobal(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_SetRelativeMouseMode(SDL2.SDL/SDL_bool) +M: System.Int32 SDL2.SDL::SDL_CaptureMouse(SDL2.SDL/SDL_bool) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GetRelativeMouseMode() +M: System.IntPtr SDL2.SDL::SDL_CreateCursor(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32) +M: System.IntPtr SDL2.SDL::SDL_CreateColorCursor(System.IntPtr,System.Int32,System.Int32) +M: System.IntPtr SDL2.SDL::SDL_CreateSystemCursor(SDL2.SDL/SDL_SystemCursor) +M: System.Void SDL2.SDL::SDL_SetCursor(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GetCursor() +M: System.Void SDL2.SDL::SDL_FreeCursor(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_ShowCursor(System.Int32) +M: System.Int32 SDL2.SDL::SDL_GetNumTouchDevices() +M: System.Int64 SDL2.SDL::SDL_GetTouchDevice(System.Int32) +M: System.Int32 SDL2.SDL::SDL_GetNumTouchFingers(System.Int64) +M: System.IntPtr SDL2.SDL::SDL_GetTouchFinger(System.Int64,System.Int32) +M: System.Void SDL2.SDL::SDL_JoystickClose(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_JoystickEventState(System.Int32) +M: System.Int16 SDL2.SDL::SDL_JoystickGetAxis(System.IntPtr,System.Int32) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_JoystickGetAxisInitialState(System.IntPtr,System.Int32,System.UInt16&) +M: System.Int32 SDL2.SDL::SDL_JoystickGetBall(System.IntPtr,System.Int32,System.Int32&,System.Int32&) +M: System.Byte SDL2.SDL::SDL_JoystickGetButton(System.IntPtr,System.Int32) +M: System.Byte SDL2.SDL::SDL_JoystickGetHat(System.IntPtr,System.Int32) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_JoystickName(System.IntPtr) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_JoystickNameForIndex(System.Int32) +M: System.Int32 SDL2.SDL::SDL_JoystickNumAxes(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_JoystickNumBalls(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_JoystickNumButtons(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_JoystickNumHats(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_JoystickOpen(System.Int32) +M: System.Void SDL2.SDL::SDL_JoystickUpdate() +M: System.Int32 SDL2.SDL::SDL_NumJoysticks() +M: System.Guid SDL2.SDL::SDL_JoystickGetDeviceGUID(System.Int32) +M: System.Guid SDL2.SDL::SDL_JoystickGetGUID(System.IntPtr) +M: System.Void SDL2.SDL::SDL_JoystickGetGUIDString(System.Guid,System.Byte[],System.Int32) +M: System.Guid SDL2.SDL::INTERNAL_SDL_JoystickGetGUIDFromString(System.Byte[]) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetDeviceVendor(System.Int32) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetDeviceProduct(System.Int32) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetDeviceProductVersion(System.Int32) +M: SDL2.SDL/SDL_JoystickType SDL2.SDL::SDL_JoystickGetDeviceType(System.Int32) +M: System.Int32 SDL2.SDL::SDL_JoystickGetDeviceInstanceID(System.Int32) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetVendor(System.IntPtr) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetProduct(System.IntPtr) +M: System.UInt16 SDL2.SDL::SDL_JoystickGetProductVersion(System.IntPtr) +M: SDL2.SDL/SDL_JoystickType SDL2.SDL::SDL_JoystickGetType(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_JoystickGetAttached(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_JoystickInstanceID(System.IntPtr) +M: SDL2.SDL/SDL_JoystickPowerLevel SDL2.SDL::SDL_JoystickCurrentPowerLevel(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_JoystickFromInstanceID(System.Int32) +M: System.Void SDL2.SDL::SDL_LockJoysticks() +M: System.Void SDL2.SDL::SDL_UnlockJoysticks() +M: System.Int32 SDL2.SDL::INTERNAL_SDL_GameControllerAddMapping(System.Byte[]) +M: System.Int32 SDL2.SDL::SDL_GameControllerNumMappings() +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GameControllerMappingForIndex(System.Int32) +M: System.Int32 SDL2.SDL::INTERNAL_SDL_GameControllerAddMappingsFromRW(System.IntPtr,System.Int32) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GameControllerMappingForGUID(System.Guid) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GameControllerMapping(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IsGameController(System.Int32) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GameControllerNameForIndex(System.Int32) +M: System.IntPtr SDL2.SDL::SDL_GameControllerOpen(System.Int32) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GameControllerName(System.IntPtr) +M: System.UInt16 SDL2.SDL::SDL_GameControllerGetVendor(System.IntPtr) +M: System.UInt16 SDL2.SDL::SDL_GameControllerGetProduct(System.IntPtr) +M: System.UInt16 SDL2.SDL::SDL_GameControllerGetProductVersion(System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GameControllerGetAttached(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GameControllerGetJoystick(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_GameControllerEventState(System.Int32) +M: System.Void SDL2.SDL::SDL_GameControllerUpdate() +M: SDL2.SDL/SDL_GameControllerAxis SDL2.SDL::INTERNAL_SDL_GameControllerGetAxisFromString(System.Byte[]) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GameControllerGetStringForAxis(SDL2.SDL/SDL_GameControllerAxis) +M: SDL2.SDL/INTERNAL_SDL_GameControllerButtonBind SDL2.SDL::INTERNAL_SDL_GameControllerGetBindForAxis(System.IntPtr,SDL2.SDL/SDL_GameControllerAxis) +M: System.Int16 SDL2.SDL::SDL_GameControllerGetAxis(System.IntPtr,SDL2.SDL/SDL_GameControllerAxis) +M: SDL2.SDL/SDL_GameControllerButton SDL2.SDL::INTERNAL_SDL_GameControllerGetButtonFromString(System.Byte[]) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GameControllerGetStringForButton(SDL2.SDL/SDL_GameControllerButton) +M: SDL2.SDL/INTERNAL_SDL_GameControllerButtonBind SDL2.SDL::INTERNAL_SDL_GameControllerGetBindForButton(System.IntPtr,SDL2.SDL/SDL_GameControllerButton) +M: System.Byte SDL2.SDL::SDL_GameControllerGetButton(System.IntPtr,SDL2.SDL/SDL_GameControllerButton) +M: System.Void SDL2.SDL::SDL_GameControllerClose(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_GameControllerFromInstanceID(System.Int32) +M: System.Void SDL2.SDL::SDL_HapticClose(System.IntPtr) +M: System.Void SDL2.SDL::SDL_HapticDestroyEffect(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticEffectSupported(System.IntPtr,SDL2.SDL/SDL_HapticEffect&) +M: System.Int32 SDL2.SDL::SDL_HapticGetEffectStatus(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticIndex(System.IntPtr) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_HapticName(System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticNewEffect(System.IntPtr,SDL2.SDL/SDL_HapticEffect&) +M: System.Int32 SDL2.SDL::SDL_HapticNumAxes(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticNumEffects(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticNumEffectsPlaying(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_HapticOpen(System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticOpened(System.Int32) +M: System.IntPtr SDL2.SDL::SDL_HapticOpenFromJoystick(System.IntPtr) +M: System.IntPtr SDL2.SDL::SDL_HapticOpenFromMouse() +M: System.Int32 SDL2.SDL::SDL_HapticPause(System.IntPtr) +M: System.UInt32 SDL2.SDL::SDL_HapticQuery(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticRumbleInit(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticRumblePlay(System.IntPtr,System.Single,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_HapticRumbleStop(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticRumbleSupported(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticRunEffect(System.IntPtr,System.Int32,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_HapticSetAutocenter(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticSetGain(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticStopAll(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticStopEffect(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_HapticUnpause(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_HapticUpdateEffect(System.IntPtr,System.Int32,SDL2.SDL/SDL_HapticEffect&) +M: System.Int32 SDL2.SDL::SDL_JoystickIsHaptic(System.IntPtr) +M: System.Int32 SDL2.SDL::SDL_MouseIsHaptic() +M: System.Int32 SDL2.SDL::SDL_NumHaptics() +M: System.Int32 SDL2.SDL::INTERNAL_SDL_AudioInit(System.Byte[]) +M: System.Void SDL2.SDL::SDL_AudioQuit() +M: System.Void SDL2.SDL::SDL_CloseAudio() +M: System.Void SDL2.SDL::SDL_CloseAudioDevice(System.UInt32) +M: System.Void SDL2.SDL::SDL_FreeWAV(System.IntPtr) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetAudioDeviceName(System.Int32,System.Int32) +M: SDL2.SDL/SDL_AudioStatus SDL2.SDL::SDL_GetAudioDeviceStatus(System.UInt32) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetAudioDriver(System.Int32) +M: SDL2.SDL/SDL_AudioStatus SDL2.SDL::SDL_GetAudioStatus() +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetCurrentAudioDriver() +M: System.Int32 SDL2.SDL::SDL_GetNumAudioDevices(System.Int32) +M: System.Int32 SDL2.SDL::SDL_GetNumAudioDrivers() +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_LoadWAV_RW(System.IntPtr,System.Int32,SDL2.SDL/SDL_AudioSpec&,System.IntPtr&,System.UInt32&) +M: System.Void SDL2.SDL::SDL_LockAudio() +M: System.Void SDL2.SDL::SDL_LockAudioDevice(System.UInt32) +M: System.Void SDL2.SDL::SDL_MixAudio(System.Byte[],System.Byte[],System.UInt32,System.Int32) +M: System.Void SDL2.SDL::SDL_MixAudioFormat(System.Byte[],System.Byte[],System.UInt16,System.UInt32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_OpenAudio(SDL2.SDL/SDL_AudioSpec&,SDL2.SDL/SDL_AudioSpec&) +M: System.Int32 SDL2.SDL::SDL_OpenAudio(SDL2.SDL/SDL_AudioSpec&,System.IntPtr) +M: System.UInt32 SDL2.SDL::INTERNAL_SDL_OpenAudioDevice(System.Byte[],System.Int32,SDL2.SDL/SDL_AudioSpec&,SDL2.SDL/SDL_AudioSpec&,System.Int32) +M: System.Void SDL2.SDL::SDL_PauseAudio(System.Int32) +M: System.Void SDL2.SDL::SDL_PauseAudioDevice(System.UInt32,System.Int32) +M: System.Void SDL2.SDL::SDL_UnlockAudio() +M: System.Void SDL2.SDL::SDL_UnlockAudioDevice(System.UInt32) +M: System.Int32 SDL2.SDL::SDL_QueueAudio(System.UInt32,System.IntPtr,System.UInt32) +M: System.UInt32 SDL2.SDL::SDL_DequeueAudio(System.UInt32,System.IntPtr,System.UInt32) +M: System.UInt32 SDL2.SDL::SDL_GetQueuedAudioSize(System.UInt32) +M: System.Void SDL2.SDL::SDL_ClearQueuedAudio(System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_NewAudioStream(System.UInt16,System.Byte,System.Int32,System.UInt16,System.Byte,System.Int32) +M: System.Int32 SDL2.SDL::SDL_AudioStreamPut(System.IntPtr,System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_AudioStreamGet(System.IntPtr,System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL::SDL_AudioStreamAvailable(System.IntPtr) +M: System.Void SDL2.SDL::SDL_AudioStreamClear(System.IntPtr) +M: System.Void SDL2.SDL::SDL_FreeAudioStream(System.IntPtr) +M: System.Void SDL2.SDL::SDL_Delay(System.UInt32) +M: System.UInt32 SDL2.SDL::SDL_GetTicks() +M: System.UInt64 SDL2.SDL::SDL_GetPerformanceCounter() +M: System.UInt64 SDL2.SDL::SDL_GetPerformanceFrequency() +M: System.Int32 SDL2.SDL::SDL_AddTimer(System.UInt32,SDL2.SDL/SDL_TimerCallback,System.IntPtr) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_RemoveTimer(System.Int32) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_GetWindowWMInfo(System.IntPtr,SDL2.SDL/SDL_SysWMinfo&) +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetBasePath() +M: System.IntPtr SDL2.SDL::INTERNAL_SDL_GetPrefPath(System.Byte[],System.Byte[]) +M: SDL2.SDL/SDL_PowerState SDL2.SDL::SDL_GetPowerInfo(System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL::SDL_GetCPUCount() +M: System.Int32 SDL2.SDL::SDL_GetSystemRAM() +M: System.IntPtr SDL2.SDL_image::INTERNAL_IMG_Linked_Version() +M: System.Int32 SDL2.SDL_image::IMG_Init(SDL2.SDL_image/IMG_InitFlags) +M: System.Void SDL2.SDL_image::IMG_Quit() +M: System.IntPtr SDL2.SDL_image::INTERNAL_IMG_Load(System.Byte[]) +M: System.IntPtr SDL2.SDL_image::IMG_Load_RW(System.IntPtr,System.Int32) +M: System.IntPtr SDL2.SDL_image::INTERNAL_IMG_LoadTyped_RW(System.IntPtr,System.Int32,System.Byte[]) +M: System.IntPtr SDL2.SDL_image::INTERNAL_IMG_LoadTexture(System.IntPtr,System.Byte[]) +M: System.IntPtr SDL2.SDL_image::IMG_LoadTexture_RW(System.IntPtr,System.IntPtr,System.Int32) +M: System.IntPtr SDL2.SDL_image::INTERNAL_IMG_LoadTextureTyped_RW(System.IntPtr,System.IntPtr,System.Int32,System.Byte[]) +M: System.IntPtr SDL2.SDL_image::IMG_ReadXPMFromArray(System.String[]) +M: System.Int32 SDL2.SDL_image::INTERNAL_IMG_SavePNG(System.IntPtr,System.Byte[]) +M: System.Int32 SDL2.SDL_image::IMG_SavePNG_RW(System.IntPtr,System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_image::INTERNAL_IMG_SaveJPG(System.IntPtr,System.Byte[],System.Int32) +M: System.Int32 SDL2.SDL_image::IMG_SaveJPG_RW(System.IntPtr,System.IntPtr,System.Int32,System.Int32) +M: System.IntPtr SDL2.SDL_mixer::INTERNAL_MIX_Linked_Version() +M: System.Int32 SDL2.SDL_mixer::Mix_Init(SDL2.SDL_mixer/MIX_InitFlags) +M: System.Void SDL2.SDL_mixer::Mix_Quit() +M: System.Int32 SDL2.SDL_mixer::Mix_OpenAudio(System.Int32,System.UInt16,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_AllocateChannels(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_QuerySpec(System.Int32&,System.UInt16&,System.Int32&) +M: System.IntPtr SDL2.SDL_mixer::Mix_LoadWAV_RW(System.IntPtr,System.Int32) +M: System.IntPtr SDL2.SDL_mixer::INTERNAL_Mix_LoadMUS(System.Byte[]) +M: System.IntPtr SDL2.SDL_mixer::Mix_QuickLoad_WAV(System.Byte[]) +M: System.IntPtr SDL2.SDL_mixer::Mix_QuickLoad_RAW(System.Byte[],System.UInt32) +M: System.Void SDL2.SDL_mixer::Mix_FreeChunk(System.IntPtr) +M: System.Void SDL2.SDL_mixer::Mix_FreeMusic(System.IntPtr) +M: System.Int32 SDL2.SDL_mixer::Mix_GetNumChunkDecoders() +M: System.IntPtr SDL2.SDL_mixer::INTERNAL_Mix_GetChunkDecoder(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GetNumMusicDecoders() +M: System.IntPtr SDL2.SDL_mixer::INTERNAL_Mix_GetMusicDecoder(System.Int32) +M: SDL2.SDL_mixer/Mix_MusicType SDL2.SDL_mixer::Mix_GetMusicType(System.IntPtr) +M: System.Void SDL2.SDL_mixer::Mix_SetPostMix(SDL2.SDL_mixer/MixFuncDelegate,System.IntPtr) +M: System.Void SDL2.SDL_mixer::Mix_HookMusic(SDL2.SDL_mixer/MixFuncDelegate,System.IntPtr) +M: System.Void SDL2.SDL_mixer::Mix_HookMusicFinished(SDL2.SDL_mixer/MusicFinishedDelegate) +M: System.IntPtr SDL2.SDL_mixer::Mix_GetMusicHookData() +M: System.Void SDL2.SDL_mixer::Mix_ChannelFinished(SDL2.SDL_mixer/ChannelFinishedDelegate) +M: System.Int32 SDL2.SDL_mixer::Mix_RegisterEffect(System.Int32,SDL2.SDL_mixer/Mix_EffectFunc_t,SDL2.SDL_mixer/Mix_EffectDone_t,System.IntPtr) +M: System.Int32 SDL2.SDL_mixer::Mix_UnregisterEffect(System.Int32,SDL2.SDL_mixer/Mix_EffectFunc_t) +M: System.Int32 SDL2.SDL_mixer::Mix_UnregisterAllEffects(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_SetPanning(System.Int32,System.Byte,System.Byte) +M: System.Int32 SDL2.SDL_mixer::Mix_SetPosition(System.Int32,System.Int16,System.Byte) +M: System.Int32 SDL2.SDL_mixer::Mix_SetDistance(System.Int32,System.Byte) +M: System.Int32 SDL2.SDL_mixer::Mix_SetReverseStereo(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_ReserveChannels(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupChannel(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupChannels(System.Int32,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupAvailable(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupCount(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupOldest(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GroupNewer(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_PlayChannelTimed(System.Int32,System.IntPtr,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_PlayMusic(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeInMusic(System.IntPtr,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeInMusicPos(System.IntPtr,System.Int32,System.Int32,System.Double) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeInChannelTimed(System.Int32,System.IntPtr,System.Int32,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_Volume(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_VolumeChunk(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_VolumeMusic(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_HaltChannel(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_HaltGroup(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_HaltMusic() +M: System.Int32 SDL2.SDL_mixer::Mix_ExpireChannel(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeOutChannel(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeOutGroup(System.Int32,System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_FadeOutMusic(System.Int32) +M: SDL2.SDL_mixer/Mix_Fading SDL2.SDL_mixer::Mix_FadingMusic() +M: SDL2.SDL_mixer/Mix_Fading SDL2.SDL_mixer::Mix_FadingChannel(System.Int32) +M: System.Void SDL2.SDL_mixer::Mix_Pause(System.Int32) +M: System.Void SDL2.SDL_mixer::Mix_Resume(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_Paused(System.Int32) +M: System.Void SDL2.SDL_mixer::Mix_PauseMusic() +M: System.Void SDL2.SDL_mixer::Mix_ResumeMusic() +M: System.Void SDL2.SDL_mixer::Mix_RewindMusic() +M: System.Int32 SDL2.SDL_mixer::Mix_PausedMusic() +M: System.Int32 SDL2.SDL_mixer::Mix_SetMusicPosition(System.Double) +M: System.Int32 SDL2.SDL_mixer::Mix_Playing(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_PlayingMusic() +M: System.Int32 SDL2.SDL_mixer::INTERNAL_Mix_SetMusicCMD(System.Byte[]) +M: System.Int32 SDL2.SDL_mixer::Mix_SetSynchroValue(System.Int32) +M: System.Int32 SDL2.SDL_mixer::Mix_GetSynchroValue() +M: System.Int32 SDL2.SDL_mixer::INTERNAL_Mix_SetSoundFonts(System.Byte[]) +M: System.IntPtr SDL2.SDL_mixer::INTERNAL_Mix_GetSoundFonts() +M: System.Int32 SDL2.SDL_mixer::Mix_EachSoundFont(SDL2.SDL_mixer/SoundFontDelegate,System.IntPtr) +M: System.IntPtr SDL2.SDL_mixer::Mix_GetChunk(System.Int32) +M: System.Void SDL2.SDL_mixer::Mix_CloseAudio() +M: System.IntPtr SDL2.SDL_ttf::INTERNAL_TTF_LinkedVersion() +M: System.Void SDL2.SDL_ttf::TTF_ByteSwappedUNICODE(System.Int32) +M: System.Int32 SDL2.SDL_ttf::TTF_Init() +M: System.IntPtr SDL2.SDL_ttf::INTERNAL_TTF_OpenFont(System.Byte[],System.Int32) +M: System.IntPtr SDL2.SDL_ttf::TTF_OpenFontRW(System.IntPtr,System.Int32,System.Int32) +M: System.IntPtr SDL2.SDL_ttf::INTERNAL_TTF_OpenFontIndex(System.Byte[],System.Int32,System.Int64) +M: System.IntPtr SDL2.SDL_ttf::TTF_OpenFontIndexRW(System.IntPtr,System.Int32,System.Int32,System.Int64) +M: System.Int32 SDL2.SDL_ttf::TTF_GetFontStyle(System.IntPtr) +M: System.Void SDL2.SDL_ttf::TTF_SetFontStyle(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_ttf::TTF_GetFontOutline(System.IntPtr) +M: System.Void SDL2.SDL_ttf::TTF_SetFontOutline(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_ttf::TTF_GetFontHinting(System.IntPtr) +M: System.Void SDL2.SDL_ttf::TTF_SetFontHinting(System.IntPtr,System.Int32) +M: System.Int32 SDL2.SDL_ttf::TTF_FontHeight(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_FontAscent(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_FontDescent(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_FontLineSkip(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_GetFontKerning(System.IntPtr) +M: System.Void SDL2.SDL_ttf::TTF_SetFontKerning(System.IntPtr,System.Int32) +M: System.Int64 SDL2.SDL_ttf::TTF_FontFaces(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_FontFaceIsFixedWidth(System.IntPtr) +M: System.IntPtr SDL2.SDL_ttf::INTERNAL_TTF_FontFaceFamilyName(System.IntPtr) +M: System.IntPtr SDL2.SDL_ttf::INTERNAL_TTF_FontFaceStyleName(System.IntPtr) +M: System.Int32 SDL2.SDL_ttf::TTF_GlyphIsProvided(System.IntPtr,System.UInt16) +M: System.Int32 SDL2.SDL_ttf::TTF_GlyphMetrics(System.IntPtr,System.UInt16,System.Int32&,System.Int32&,System.Int32&,System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL_ttf::TTF_SizeText(System.IntPtr,System.String,System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL_ttf::INTERNAL_TTF_SizeUTF8(System.IntPtr,System.Byte[],System.Int32&,System.Int32&) +M: System.Int32 SDL2.SDL_ttf::TTF_SizeUNICODE(System.IntPtr,System.String,System.Int32&,System.Int32&) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderText_Solid(System.IntPtr,System.String,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::INTERNAL_TTF_RenderUTF8_Solid(System.IntPtr,System.Byte[],SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUNICODE_Solid(System.IntPtr,System.String,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderGlyph_Solid(System.IntPtr,System.UInt16,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderText_Shaded(System.IntPtr,System.String,SDL2.SDL/SDL_Color,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::INTERNAL_TTF_RenderUTF8_Shaded(System.IntPtr,System.Byte[],SDL2.SDL/SDL_Color,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUNICODE_Shaded(System.IntPtr,System.String,SDL2.SDL/SDL_Color,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderGlyph_Shaded(System.IntPtr,System.UInt16,SDL2.SDL/SDL_Color,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderText_Blended(System.IntPtr,System.String,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::INTERNAL_TTF_RenderUTF8_Blended(System.IntPtr,System.Byte[],SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUNICODE_Blended(System.IntPtr,System.String,SDL2.SDL/SDL_Color) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderText_Blended_Wrapped(System.IntPtr,System.String,SDL2.SDL/SDL_Color,System.UInt32) +M: System.IntPtr SDL2.SDL_ttf::INTERNAL_TTF_RenderUTF8_Blended_Wrapped(System.IntPtr,System.Byte[],SDL2.SDL/SDL_Color,System.UInt32) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderUNICODE_Blended_Wrapped(System.IntPtr,System.String,SDL2.SDL/SDL_Color,System.UInt32) +M: System.IntPtr SDL2.SDL_ttf::TTF_RenderGlyph_Blended(System.IntPtr,System.UInt16,SDL2.SDL/SDL_Color) +M: System.Void SDL2.SDL_ttf::TTF_CloseFont(System.IntPtr) +M: System.Void SDL2.SDL_ttf::TTF_Quit() +M: System.Int32 SDL2.SDL_ttf::TTF_WasInit() +M: System.Int32 SDL2.SDL_ttf::SDL_GetFontKerningSize(System.IntPtr,System.Int32,System.Int32) + +R: Gendarme.Rules.Naming.DoNotPrefixValuesWithEnumNameRule +T: SDL2.SDL/SDL_BlendMode +T: SDL2.SDL/SDL_BlendOperation +T: SDL2.SDL/SDL_BlendFactor +T: SDL2.SDL/SDL_TextureAccess +T: SDL2.SDL/SDL_TextureModulate +T: SDL2.SDL/SDL_Scancode +T: SDL2.SDL/SDL_PowerState +T: SDL2.SDL_mixer/Mix_Fading + +R: Gendarme.Rules.Naming.DoNotUseReservedInEnumValueNamesRule +T: SDL2.SDL/SDL_Keymod + +R: Gendarme.Rules.Design.EnumsShouldUseInt32Rule +T: SDL2.SDL/SDL_MessageBoxFlags +T: SDL2.SDL/SDL_MessageBoxButtonFlags +T: SDL2.SDL/SDL_WindowEventID +T: SDL2.SDL/SDL_WindowFlags +T: SDL2.SDL/SDL_RendererFlags +T: SDL2.SDL/SDL_EventType +T: SDL2.SDL/SDL_MouseWheelDirection +T: SDL2.SDL/SDL_Keymod + +R: Gendarme.Rules.Design.FlagsShouldNotDefineAZeroValueRule +T: SDL2.SDL/SDL_BlendMode +T: SDL2.SDL/SDL_RendererFlip +T: SDL2.SDL/SDL_TextureModulate + +R: Gendarme.Rules.Design.MarkAssemblyWithAssemblyVersionRule +A: SDL2-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Design.MarkAssemblyWithCLSCompliantRule +A: SDL2-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Design.MarkAssemblyWithComVisibleRule +A: SDL2-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Security.NativeFieldsShouldNotBeVisibleRule +T: SDL2.SDL/SDL_MessageBoxData +T: SDL2.SDL/SDL_DisplayMode +T: SDL2.SDL/SDL_RendererInfo +T: SDL2.SDL/SDL_Palette +T: SDL2.SDL/SDL_PixelFormat +T: SDL2.SDL/SDL_Surface +T: SDL2.SDL/SDL_DropEvent +T: SDL2.SDL/SDL_UserEvent +T: SDL2.SDL/SDL_SysWMEvent +T: SDL2.SDL/SDL_HapticCustom +T: SDL2.SDL/SDL_AudioSpec +T: SDL2.SDL/INTERNAL_windows_wminfo +T: SDL2.SDL/INTERNAL_winrt_wminfo +T: SDL2.SDL/INTERNAL_x11_wminfo +T: SDL2.SDL/INTERNAL_directfb_wminfo +T: SDL2.SDL/INTERNAL_cocoa_wminfo +T: SDL2.SDL/INTERNAL_uikit_wminfo +T: SDL2.SDL/INTERNAL_wayland_wminfo +T: SDL2.SDL/INTERNAL_mir_wminfo +T: SDL2.SDL/INTERNAL_android_wminfo + +R: Gendarme.Rules.Performance.PreferLiteralOverInitOnlyFieldsRule +T: SDL2.SDL +T: SDL2.SDL_mixer + +R: Gendarme.Rules.Naming.UseCorrectCasingRule +M: System.UInt32 SDL2.SDL::SDL_FOURCC(System.Byte,System.Byte,System.Byte,System.Byte) +M: System.Int32 SDL2.SDL::SDL_VERSIONNUM(System.Int32,System.Int32,System.Int32) +M: System.Boolean SDL2.SDL::SDL_VERSION_ATLEAST(System.Int32,System.Int32,System.Int32) +M: System.Int32 SDL2.SDL::SDL_WINDOWPOS_UNDEFINED_DISPLAY(System.Int32) +M: System.Boolean SDL2.SDL::SDL_WINDOWPOS_ISUNDEFINED(System.Int32) +M: System.Int32 SDL2.SDL::SDL_WINDOWPOS_CENTERED_DISPLAY(System.Int32) +M: System.Boolean SDL2.SDL::SDL_WINDOWPOS_ISCENTERED(System.Int32) +M: System.UInt32 SDL2.SDL::SDL_DEFINE_PIXELFOURCC(System.Byte,System.Byte,System.Byte,System.Byte) +M: System.Byte SDL2.SDL::SDL_PIXELFLAG(System.UInt32) +M: System.Byte SDL2.SDL::SDL_PIXELTYPE(System.UInt32) +M: System.Byte SDL2.SDL::SDL_PIXELORDER(System.UInt32) +M: System.Byte SDL2.SDL::SDL_PIXELLAYOUT(System.UInt32) +M: System.Byte SDL2.SDL::SDL_BITSPERPIXEL(System.UInt32) +M: System.Byte SDL2.SDL::SDL_BYTESPERPIXEL(System.UInt32) +M: System.UInt32 SDL2.SDL::SDL_MasksToPixelFormatEnum(System.Int32,System.UInt32,System.UInt32,System.UInt32,System.UInt32) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_PixelFormatEnumToMasks(System.UInt32,System.Int32&,System.UInt32&,System.UInt32&,System.UInt32&,System.UInt32&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_HasIntersection(SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IntersectRect(SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: SDL2.SDL/SDL_bool SDL2.SDL::SDL_IntersectRectAndLine(SDL2.SDL/SDL_Rect&,System.Int32&,System.Int32&,System.Int32&,System.Int32&) +M: System.Void SDL2.SDL::SDL_UnionRect(SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&,SDL2.SDL/SDL_Rect&) +M: System.IntPtr SDL2.SDL::SDL_CreateRGBSurface(System.UInt32,System.Int32,System.Int32,System.Int32,System.UInt32,System.UInt32,System.UInt32,System.UInt32) +M: System.IntPtr SDL2.SDL::SDL_CreateRGBSurfaceFrom(System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32,System.UInt32,System.UInt32,System.UInt32,System.UInt32) +M: System.Int32 SDL2.SDL::SDL_PollEvent(SDL2.SDL/SDL_Event&) +M: System.Int32 SDL2.SDL::SDL_WaitEvent(SDL2.SDL/SDL_Event&) +M: System.Int32 SDL2.SDL::SDL_WaitEventTimeout(SDL2.SDL/SDL_Event&,System.Int32) +M: System.Int32 SDL2.SDL::SDL_PushEvent(SDL2.SDL/SDL_Event&) +M: SDL2.SDL/SDL_Keycode SDL2.SDL::SDL_SCANCODE_TO_KEYCODE(SDL2.SDL/SDL_Scancode) +M: System.UInt32 SDL2.SDL::SDL_BUTTON(System.UInt32) +M: System.Boolean SDL2.SDL::SDL_TICKS_PASSED(System.UInt32,System.UInt32) +M: System.Void SDL2.SDL_image::SDL_IMAGE_VERSION(SDL2.SDL/SDL_version&) +M: System.Void SDL2.SDL_mixer::SDL_MIXER_VERSION(SDL2.SDL/SDL_version&) +M: System.Void SDL2.SDL_ttf::SDL_TTF_VERSION(SDL2.SDL/SDL_version&) + +R: Gendarme.Rules.Naming.UseCorrectSuffixRule +T: SDL2.SDL/SDL_MessageBoxFlags +T: SDL2.SDL/SDL_MessageBoxButtonFlags +T: SDL2.SDL/SDL_WindowFlags +T: SDL2.SDL/SDL_RendererFlags +T: SDL2.SDL/SDL_PIXELTYPE_ENUM +T: SDL2.SDL/SDL_PIXELORDER_ENUM +T: SDL2.SDL/SDL_PACKEDLAYOUT_ENUM +T: SDL2.SDL/SDL_HapticCondition +T: SDL2.SDL_image/IMG_InitFlags +T: SDL2.SDL_mixer/MIX_InitFlags +T: SDL2.SDL_mixer/MixFuncDelegate +T: SDL2.SDL_mixer/MusicFinishedDelegate +T: SDL2.SDL_mixer/ChannelFinishedDelegate +T: SDL2.SDL_mixer/SoundFontDelegate + +R: Gendarme.Rules.Naming.UsePreferredTermsRule +M: System.Void SDL2.SDL::SDL_LogInfo(System.Int32,System.String) +T: SDL2.SDL/SDL_LogOutputFunction + +R: Gendarme.Rules.Naming.UseSingularNameInEnumsUnlessAreFlagsRule +T: SDL2.SDL/SDL_TextureAccess +T: SDL2.SDL/SDL_GameControllerAxis +T: SDL2.SDL/SDL_AudioStatus + diff --git a/FNA/gendarme/theorafile.ignore b/FNA/gendarme/theorafile.ignore new file mode 100644 index 0000000..bf1afca --- /dev/null +++ b/FNA/gendarme/theorafile.ignore @@ -0,0 +1,84 @@ +R: Gendarme.Rules.Performance.AvoidConcatenatingCharsRule +M: System.Byte[] Theorafile::UTF8_ToNative(System.String) + +R: Gendarme.Rules.Design.Generic.AvoidDeclaringCustomDelegatesRule +T: Theorafile/read_func +T: Theorafile/seek_func +T: Theorafile/close_func + +R: Gendarme.Rules.Naming.AvoidNonAlphanumericIdentifierRule +M: System.Int32 Theorafile::tf_open_callbacks(System.IntPtr,System.IntPtr&,Theorafile/tf_callbacks) +M: System.Int32 Theorafile::tf_fopen(System.String,System.IntPtr&) +M: System.Int32 Theorafile::tf_close(System.IntPtr&) +M: System.Int32 Theorafile::tf_hasaudio(System.IntPtr) +M: System.Int32 Theorafile::tf_hasvideo(System.IntPtr) +M: System.Void Theorafile::tf_videoinfo(System.IntPtr,System.Int32&,System.Int32&,System.Double&) +M: System.Void Theorafile::tf_audioinfo(System.IntPtr,System.Int32&,System.Int32&) +M: System.Int32 Theorafile::tf_eos(System.IntPtr) +M: System.Void Theorafile::tf_reset(System.IntPtr) +M: System.Int32 Theorafile::tf_readvideo(System.IntPtr,System.IntPtr,System.Int32) +M: System.Int32 Theorafile::tf_readaudio(System.IntPtr,System.IntPtr,System.Int32) +T: Theorafile/SeekWhence +T: Theorafile/read_func +T: Theorafile/seek_func +T: Theorafile/close_func +T: Theorafile/tf_callbacks + +R: Gendarme.Rules.Design.AvoidRefAndOutParametersRule +M: System.Int32 Theorafile::tf_open_callbacks(System.IntPtr,System.IntPtr&,Theorafile/tf_callbacks) +M: System.Int32 Theorafile::tf_fopen(System.String,System.IntPtr&) +M: System.Int32 Theorafile::tf_close(System.IntPtr&) + +R: Gendarme.Rules.Design.AvoidVisibleFieldsRule +T: Theorafile/tf_callbacks + +R: Gendarme.Rules.Design.AvoidVisibleNestedTypesRule +T: Theorafile/SeekWhence +T: Theorafile/read_func +T: Theorafile/seek_func +T: Theorafile/close_func +T: Theorafile/tf_callbacks + +R: Gendarme.Rules.Interoperability.CentralizePInvokesIntoNativeMethodsTypeRule +M: System.IntPtr Theorafile::malloc(System.IntPtr) +M: System.Void Theorafile::free(System.IntPtr) +M: System.Int32 Theorafile::INTERNAL_tf_open_callbacks(System.IntPtr,System.IntPtr,Theorafile/tf_callbacks) +M: System.Int32 Theorafile::INTERNAL_tf_fopen(System.Byte[],System.IntPtr) +M: System.Int32 Theorafile::INTERNAL_tf_close(System.IntPtr) +M: System.Int32 Theorafile::tf_hasaudio(System.IntPtr) +M: System.Int32 Theorafile::tf_hasvideo(System.IntPtr) +M: System.Void Theorafile::tf_videoinfo(System.IntPtr,System.Int32&,System.Int32&,System.Double&) +M: System.Void Theorafile::tf_audioinfo(System.IntPtr,System.Int32&,System.Int32&) +M: System.Int32 Theorafile::tf_eos(System.IntPtr) +M: System.Void Theorafile::tf_reset(System.IntPtr) +M: System.Int32 Theorafile::tf_readvideo(System.IntPtr,System.IntPtr,System.Int32) +M: System.Int32 Theorafile::tf_readaudio(System.IntPtr,System.IntPtr,System.Int32) + +R: Gendarme.Rules.Design.MarkAssemblyWithAssemblyVersionRule +A: Theorafile-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Design.MarkAssemblyWithCLSCompliantRule +A: Theorafile-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Design.MarkAssemblyWithComVisibleRule +A: Theorafile-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Naming.UseCorrectCasingRule +M: System.IntPtr Theorafile::malloc(System.IntPtr) +M: System.Void Theorafile::free(System.IntPtr) +M: System.Int32 Theorafile::tf_open_callbacks(System.IntPtr,System.IntPtr&,Theorafile/tf_callbacks) +M: System.Int32 Theorafile::tf_fopen(System.String,System.IntPtr&) +M: System.Int32 Theorafile::tf_close(System.IntPtr&) +M: System.Int32 Theorafile::tf_hasaudio(System.IntPtr) +M: System.Int32 Theorafile::tf_hasvideo(System.IntPtr) +M: System.Void Theorafile::tf_videoinfo(System.IntPtr,System.Int32&,System.Int32&,System.Double&) +M: System.Void Theorafile::tf_audioinfo(System.IntPtr,System.Int32&,System.Int32&) +M: System.Int32 Theorafile::tf_eos(System.IntPtr) +M: System.Void Theorafile::tf_reset(System.IntPtr) +M: System.Int32 Theorafile::tf_readvideo(System.IntPtr,System.IntPtr,System.Int32) +M: System.Int32 Theorafile::tf_readaudio(System.IntPtr,System.IntPtr,System.Int32) +T: Theorafile/read_func +T: Theorafile/seek_func +T: Theorafile/close_func +T: Theorafile/tf_callbacks + diff --git a/FNA/gendarme/vorbisfile.ignore b/FNA/gendarme/vorbisfile.ignore new file mode 100644 index 0000000..a6501d6 --- /dev/null +++ b/FNA/gendarme/vorbisfile.ignore @@ -0,0 +1,91 @@ +R: Gendarme.Rules.Design.Generic.AvoidDeclaringCustomDelegatesRule +T: Vorbisfile/read_func +T: Vorbisfile/seek_func +T: Vorbisfile/close_func +T: Vorbisfile/tell_func + +R: Gendarme.Rules.Naming.AvoidNonAlphanumericIdentifierRule +M: System.Int32 Vorbisfile::ov_fopen(System.String,System.IntPtr&) +M: System.Int32 Vorbisfile::ov_open_callbacks(System.IntPtr,System.IntPtr&,System.IntPtr,System.IntPtr,Vorbisfile/ov_callbacks) +M: Vorbisfile/vorbis_info Vorbisfile::ov_info(System.IntPtr,System.Int32) +M: Vorbisfile/vorbis_comment Vorbisfile::ov_comment(System.IntPtr,System.Int32) +M: System.Double Vorbisfile::ov_time_total(System.IntPtr,System.Int32) +M: System.IntPtr Vorbisfile::ov_read(System.IntPtr,System.Byte[],System.Int32,System.Int32,System.Int32,System.Int32,System.Int32&) +M: System.IntPtr Vorbisfile::ov_read(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32&) +M: System.Int32 Vorbisfile::ov_time_seek(System.IntPtr,System.Double) +M: System.Int32 Vorbisfile::ov_clear(System.IntPtr&) +T: Vorbisfile/SeekWhence +T: Vorbisfile/read_func +T: Vorbisfile/seek_func +T: Vorbisfile/close_func +T: Vorbisfile/tell_func +T: Vorbisfile/vorbis_info +T: Vorbisfile/vorbis_comment +T: Vorbisfile/ov_callbacks + +R: Gendarme.Rules.Design.AvoidRefAndOutParametersRule +M: System.Int32 Vorbisfile::ov_fopen(System.String,System.IntPtr&) +M: System.Int32 Vorbisfile::ov_open_callbacks(System.IntPtr,System.IntPtr&,System.IntPtr,System.IntPtr,Vorbisfile/ov_callbacks) +M: System.Int32 Vorbisfile::ov_clear(System.IntPtr&) + +R: Gendarme.Rules.Design.AvoidVisibleFieldsRule +T: Vorbisfile/vorbis_info +T: Vorbisfile/vorbis_comment +T: Vorbisfile/ov_callbacks + +R: Gendarme.Rules.Design.AvoidVisibleNestedTypesRule +T: Vorbisfile/SeekWhence +T: Vorbisfile/read_func +T: Vorbisfile/seek_func +T: Vorbisfile/close_func +T: Vorbisfile/tell_func +T: Vorbisfile/vorbis_info +T: Vorbisfile/vorbis_comment +T: Vorbisfile/ov_callbacks + +R: Gendarme.Rules.Interoperability.CentralizePInvokesIntoNativeMethodsTypeRule +M: System.IntPtr Vorbisfile::malloc(System.IntPtr) +M: System.Void Vorbisfile::free(System.IntPtr) +M: System.Int32 Vorbisfile::INTERNAL_ov_fopen(System.String,System.IntPtr) +M: System.Int32 Vorbisfile::INTERNAL_ov_open_callbacks(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,Vorbisfile/ov_callbacks) +M: System.IntPtr Vorbisfile::INTERNAL_ov_info(System.IntPtr,System.Int32) +M: System.IntPtr Vorbisfile::INTERNAL_ov_comment(System.IntPtr,System.Int32) +M: System.Double Vorbisfile::ov_time_total(System.IntPtr,System.Int32) +M: System.IntPtr Vorbisfile::ov_read(System.IntPtr,System.Byte[],System.Int32,System.Int32,System.Int32,System.Int32,System.Int32&) +M: System.IntPtr Vorbisfile::ov_read(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32&) +M: System.Int32 Vorbisfile::ov_time_seek(System.IntPtr,System.Double) +M: System.Int32 Vorbisfile::INTERNAL_ov_clear(System.IntPtr) + +R: Gendarme.Rules.Design.MarkAssemblyWithAssemblyVersionRule +A: Vorbisfile-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Design.MarkAssemblyWithCLSCompliantRule +A: Vorbisfile-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Design.MarkAssemblyWithComVisibleRule +A: Vorbisfile-CS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + +R: Gendarme.Rules.Security.NativeFieldsShouldNotBeVisibleRule +T: Vorbisfile/vorbis_info +T: Vorbisfile/vorbis_comment + +R: Gendarme.Rules.Naming.UseCorrectCasingRule +M: System.IntPtr Vorbisfile::malloc(System.IntPtr) +M: System.Void Vorbisfile::free(System.IntPtr) +M: System.Int32 Vorbisfile::ov_fopen(System.String,System.IntPtr&) +M: System.Int32 Vorbisfile::ov_open_callbacks(System.IntPtr,System.IntPtr&,System.IntPtr,System.IntPtr,Vorbisfile/ov_callbacks) +M: Vorbisfile/vorbis_info Vorbisfile::ov_info(System.IntPtr,System.Int32) +M: Vorbisfile/vorbis_comment Vorbisfile::ov_comment(System.IntPtr,System.Int32) +M: System.Double Vorbisfile::ov_time_total(System.IntPtr,System.Int32) +M: System.IntPtr Vorbisfile::ov_read(System.IntPtr,System.Byte[],System.Int32,System.Int32,System.Int32,System.Int32,System.Int32&) +M: System.IntPtr Vorbisfile::ov_read(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32&) +M: System.Int32 Vorbisfile::ov_time_seek(System.IntPtr,System.Double) +M: System.Int32 Vorbisfile::ov_clear(System.IntPtr&) +T: Vorbisfile/read_func +T: Vorbisfile/seek_func +T: Vorbisfile/close_func +T: Vorbisfile/tell_func +T: Vorbisfile/vorbis_info +T: Vorbisfile/vorbis_comment +T: Vorbisfile/ov_callbacks + diff --git a/FNA/lib/MojoShader-CS/.gitignore b/FNA/lib/MojoShader-CS/.gitignore new file mode 100644 index 0000000..ddb8b56 --- /dev/null +++ b/FNA/lib/MojoShader-CS/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +*.pidb +*.userprefs +*.suo diff --git a/FNA/lib/MojoShader-CS/LICENSE b/FNA/lib/MojoShader-CS/LICENSE new file mode 100644 index 0000000..deda405 --- /dev/null +++ b/FNA/lib/MojoShader-CS/LICENSE @@ -0,0 +1,25 @@ +/* MojoShader# - C# Wrapper for MojoShader + * + * Copyright (c) 2014-2017 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ diff --git a/FNA/lib/MojoShader-CS/Makefile b/FNA/lib/MojoShader-CS/Makefile new file mode 100644 index 0000000..9e13877 --- /dev/null +++ b/FNA/lib/MojoShader-CS/Makefile @@ -0,0 +1,10 @@ +# Makefile for MojoShader# +# Written by Ethan "flibitijibibo" Lee + +build: clean + mkdir bin + cp MojoShader-CS.dll.config bin + dmcs /unsafe -debug -out:bin/MojoShader-CS.dll -target:library MojoShader.cs + +clean: + rm -rf bin diff --git a/FNA/lib/MojoShader-CS/MojoShader-CS.csproj b/FNA/lib/MojoShader-CS/MojoShader-CS.csproj new file mode 100644 index 0000000..f0f19f7 --- /dev/null +++ b/FNA/lib/MojoShader-CS/MojoShader-CS.csproj @@ -0,0 +1,39 @@ + + + + Debug + x86 + 9.0.21022 + 2.0 + {19767B10-6A26-42B4-9413-5738E49DF437} + Library + MojoShader + MojoShader-CS + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + x86 + false + true + + + none + false + bin\Release + prompt + 4 + x86 + false + true + + + + + + \ No newline at end of file diff --git a/FNA/lib/MojoShader-CS/MojoShader-CS.dll.config b/FNA/lib/MojoShader-CS/MojoShader-CS.dll.config new file mode 100644 index 0000000..2d91faa --- /dev/null +++ b/FNA/lib/MojoShader-CS/MojoShader-CS.dll.config @@ -0,0 +1,5 @@ + + + + + diff --git a/FNA/lib/MojoShader-CS/MojoShader-CS.sln b/FNA/lib/MojoShader-CS/MojoShader-CS.sln new file mode 100644 index 0000000..5231009 --- /dev/null +++ b/FNA/lib/MojoShader-CS/MojoShader-CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MojoShader-CS", "MojoShader-CS.csproj", "{19767B10-6A26-42B4-9413-5738E49DF437}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {19767B10-6A26-42B4-9413-5738E49DF437}.Debug|x86.ActiveCfg = Debug|x86 + {19767B10-6A26-42B4-9413-5738E49DF437}.Debug|x86.Build.0 = Debug|x86 + {19767B10-6A26-42B4-9413-5738E49DF437}.Release|x86.ActiveCfg = Release|x86 + {19767B10-6A26-42B4-9413-5738E49DF437}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = MojoShader-CS.csproj + EndGlobalSection +EndGlobal diff --git a/FNA/lib/MojoShader-CS/MojoShader.cs b/FNA/lib/MojoShader-CS/MojoShader.cs new file mode 100644 index 0000000..9151eee --- /dev/null +++ b/FNA/lib/MojoShader-CS/MojoShader.cs @@ -0,0 +1,1446 @@ +#region License +/* MojoShader# - C# Wrapper for MojoShader + * + * Copyright (c) 2014-2017 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +public static class MojoShader +{ + #region Native Library Name + + private const string nativeLibName = "MojoShader.dll"; + + #endregion + + #region UTF8 Marshaling + + private static byte[] UTF8_ToNative(string s) + { + if (s == null) + { + return null; + } + + // Add a null terminator. That's kind of it... :/ + return System.Text.Encoding.UTF8.GetBytes(s + '\0'); + } + + private static unsafe string UTF8_ToManaged(IntPtr s) + { + if (s == IntPtr.Zero) + { + return null; + } + + /* We get to do strlen ourselves! */ + byte* ptr = (byte*) s; + while (*ptr != 0) + { + ptr++; + } + + /* TODO: This #ifdef is only here because the equivalent + * .NET 2.0 constructor appears to be less efficient? + * Here's the pretty version, maybe steal this instead: + * + string result = new string( + (sbyte*) s, // Also, why sbyte??? + 0, + (int) (ptr - (byte*) s), + System.Text.Encoding.UTF8 + ); + * See the CoreCLR source for more info. + * -flibit + */ +#if NETSTANDARD2_0 + /* Modern C# lets you just send the byte*, nice! */ + string result = System.Text.Encoding.UTF8.GetString( + (byte*) s, + (int) (ptr - (byte*) s) + ); +#else + /* Old C# requires an extra memcpy, bleh! */ + byte[] bytes = new byte[ptr - (byte*) s]; + Marshal.Copy(s, bytes, 0, bytes.Length); + string result = System.Text.Encoding.UTF8.GetString(bytes); +#endif + return result; + } + + #endregion + + #region Version Interface + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int MOJOSHADER_version(); + + /* IntPtr refers to a statically allocated const char* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr MOJOSHADER_changeset(); + + #endregion + + #region Custom malloc/free Function Types + + /* data refers to a void* */ + public delegate IntPtr MOJOSHADER_malloc(int bytes, IntPtr data); + + /* ptr refers to a void, data to a void* */ + public delegate IntPtr MOJOSHADER_free(IntPtr ptr, IntPtr data); + + #endregion + + #region Parse Interface + + public enum MOJOSHADER_shaderType + { + MOJOSHADER_TYPE_UNKNOWN = 0, + MOJOSHADER_TYPE_PIXEL = (1 << 0), + MOJOSHADER_TYPE_VERTEX = (1 << 1), + MOJOSHADER_TYPE_GEOMETRY = (1 << 2), + MOJOSHADER_TYPE_ANY = -1 // 0xFFFFFFFF, ugh + } + + public enum MOJOSHADER_attributeType + { + MOJOSHADER_ATTRIBUTE_UNKNOWN = -1, + MOJOSHADER_ATTRIBUTE_BYTE, + MOJOSHADER_ATTRIBUTE_UBYTE, + MOJOSHADER_ATTRIBUTE_SHORT, + MOJOSHADER_ATTRIBUTE_USHORT, + MOJOSHADER_ATTRIBUTE_INT, + MOJOSHADER_ATTRIBUTE_UINT, + MOJOSHADER_ATTRIBUTE_FLOAT, + MOJOSHADER_ATTRIBUTE_DOUBLE, + MOJOSHADER_ATTRIBUTE_HALF_FLOAT + } + + public enum MOJOSHADER_uniformType + { + MOJOSHADER_UNIFORM_UNKNOWN = -1, + MOJOSHADER_UNIFORM_FLOAT, + MOJOSHADER_UNIFORM_INT, + MOJOSHADER_UNIFORM_BOOL + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_uniform + { + public MOJOSHADER_uniformType type; + public int index; + public int array_count; + public int constant; + public IntPtr name; // const char* + } + + [StructLayout(LayoutKind.Explicit)] + public unsafe struct MOJOSHADER_constant + { + [FieldOffset(0)] + public MOJOSHADER_uniformType type; + [FieldOffset(4)] + public int index; + [FieldOffset(8)] + public fixed float f[4]; + [FieldOffset(8)] + public fixed int i[4]; + [FieldOffset(8)] + public int b; + } + + public enum MOJOSHADER_samplerType + { + MOJOSHADER_SAMPLER_UNKNOWN = -1, + MOJOSHADER_SAMPLER_2D, + MOJOSHADER_SAMPLER_CUBE, + MOJOSHADER_SAMPLER_VOLUME + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_sampler + { + public MOJOSHADER_samplerType type; + public int index; + public IntPtr name; // const char* + public int texbem; + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_samplerMap + { + public int index; + public MOJOSHADER_samplerType type; + } + + public enum MOJOSHADER_usage + { + MOJOSHADER_USAGE_UNKNOWN = -1, + MOJOSHADER_USAGE_POSITION, + MOJOSHADER_USAGE_BLENDWEIGHT, + MOJOSHADER_USAGE_BLENDINDICES, + MOJOSHADER_USAGE_NORMAL, + MOJOSHADER_USAGE_POINTSIZE, + MOJOSHADER_USAGE_TEXCOORD, + MOJOSHADER_USAGE_TANGENT, + MOJOSHADER_USAGE_BINORMAL, + MOJOSHADER_USAGE_TESSFACTOR, + MOJOSHADER_USAGE_POSITIONT, + MOJOSHADER_USAGE_COLOR, + MOJOSHADER_USAGE_FOG, + MOJOSHADER_USAGE_DEPTH, + MOJOSHADER_USAGE_SAMPLE, + MOJOSHADER_USAGE_TOTAL + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_attribute + { + public MOJOSHADER_usage usage; + public int index; + public IntPtr name; // const char* + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct MOJOSHADER_swizzle + { + public MOJOSHADER_usage usage; + public uint index; + public fixed byte swizzles[4]; + } + + public enum MOJOSHADER_symbolRegisterSet + { + MOJOSHADER_SYMREGSET_BOOL = 0, + MOJOSHADER_SYMREGSET_INT4, + MOJOSHADER_SYMREGSET_FLOAT4, + MOJOSHADER_SYMREGSET_SAMPLER, + MOJOSHADER_SYMREGSET_TOTAL + } + + public enum MOJOSHADER_symbolClass + { + MOJOSHADER_SYMCLASS_SCALAR = 0, + MOJOSHADER_SYMCLASS_VECTOR, + MOJOSHADER_SYMCLASS_MATRIX_ROWS, + MOJOSHADER_SYMCLASS_MATRIX_COLUMNS, + MOJOSHADER_SYMCLASS_OBJECT, + MOJOSHADER_SYMCLASS_STRUCT, + MOJOSHADER_SYMCLASS_TOTAL + } + + public enum MOJOSHADER_symbolType + { + MOJOSHADER_SYMTYPE_VOID = 0, + MOJOSHADER_SYMTYPE_BOOL, + MOJOSHADER_SYMTYPE_INT, + MOJOSHADER_SYMTYPE_FLOAT, + MOJOSHADER_SYMTYPE_STRING, + MOJOSHADER_SYMTYPE_TEXTURE, + MOJOSHADER_SYMTYPE_TEXTURE1D, + MOJOSHADER_SYMTYPE_TEXTURE2D, + MOJOSHADER_SYMTYPE_TEXTURE3D, + MOJOSHADER_SYMTYPE_TEXTURECUBE, + MOJOSHADER_SYMTYPE_SAMPLER, + MOJOSHADER_SYMTYPE_SAMPLER1D, + MOJOSHADER_SYMTYPE_SAMPLER2D, + MOJOSHADER_SYMTYPE_SAMPLER3D, + MOJOSHADER_SYMTYPE_SAMPLERCUBE, + MOJOSHADER_SYMTYPE_PIXELSHADER, + MOJOSHADER_SYMTYPE_VERTEXSHADER, + MOJOSHADER_SYMTYPE_PIXELFRAGMENT, + MOJOSHADER_SYMTYPE_VERTEXFRAGMENT, + MOJOSHADER_SYMTYPE_UNSUPPORTED, + MOJOSHADER_SYMTYPE_TOTAL + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_symbolTypeInfo + { + public MOJOSHADER_symbolClass parameter_class; + public MOJOSHADER_symbolType parameter_type; + public uint rows; + public uint columns; + public uint elements; + public uint member_count; + public IntPtr members; // MOJOSHADER_symbolStructMember* + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_symbolStructMember + { + public IntPtr name; //const char* + public MOJOSHADER_symbolTypeInfo info; + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_symbol + { + public IntPtr name; // const char* + public MOJOSHADER_symbolRegisterSet register_set; + public uint register_index; + public uint register_count; + public MOJOSHADER_symbolTypeInfo info; + } + + public const int MOJOSHADER_POSITION_NONE = -3; + public const int MOJOSHADER_POSITION_BEFORE = -2; + public const int MOJOSHADER_POSITION_AFTER = -1; + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_error + { + public IntPtr error; // const char* + public IntPtr filename; // const char* + public int error_position; + } + + public enum MOJOSHADER_preshaderOpcode + { + MOJOSHADER_PRESHADEROP_NOP, + MOJOSHADER_PRESHADEROP_MOV, + MOJOSHADER_PRESHADEROP_NEG, + MOJOSHADER_PRESHADEROP_RCP, + MOJOSHADER_PRESHADEROP_FRC, + MOJOSHADER_PRESHADEROP_EXP, + MOJOSHADER_PRESHADEROP_LOG, + MOJOSHADER_PRESHADEROP_RSQ, + MOJOSHADER_PRESHADEROP_SIN, + MOJOSHADER_PRESHADEROP_COS, + MOJOSHADER_PRESHADEROP_ASIN, + MOJOSHADER_PRESHADEROP_ACOS, + MOJOSHADER_PRESHADEROP_ATAN, + MOJOSHADER_PRESHADEROP_MIN, + MOJOSHADER_PRESHADEROP_MAX, + MOJOSHADER_PRESHADEROP_LT, + MOJOSHADER_PRESHADEROP_GE, + MOJOSHADER_PRESHADEROP_ADD, + MOJOSHADER_PRESHADEROP_MUL, + MOJOSHADER_PRESHADEROP_ATAN2, + MOJOSHADER_PRESHADEROP_DIV, + MOJOSHADER_PRESHADEROP_CMP, + MOJOSHADER_PRESHADEROP_MOVC, + MOJOSHADER_PRESHADEROP_DOT, + MOJOSHADER_PRESHADEROP_NOISE, + MOJOSHADER_PRESHADEROP_SCALAR_OPS, + MOJOSHADER_PRESHADEROP_MIN_SCALAR = MOJOSHADER_PRESHADEROP_SCALAR_OPS, + MOJOSHADER_PRESHADEROP_MAX_SCALAR, + MOJOSHADER_PRESHADEROP_LT_SCALAR, + MOJOSHADER_PRESHADEROP_GE_SCALAR, + MOJOSHADER_PRESHADEROP_ADD_SCALAR, + MOJOSHADER_PRESHADEROP_MUL_SCALAR, + MOJOSHADER_PRESHADEROP_ATAN2_SCALAR, + MOJOSHADER_PRESHADEROP_DIV_SCALAR, + MOJOSHADER_PRESHADEROP_DOT_SCALAR, + MOJOSHADER_PRESHADEROP_NOISE_SCALAR + } + + public enum MOJOSHADER_preshaderOperandType + { + MOJOSHADER_PRESHADEROPERAND_INPUT, + MOJOSHADER_PRESHADEROPERAND_OUTPUT, + MOJOSHADER_PRESHADEROPERAND_LITERAL, + MOJOSHADER_PRESHADEROPERAND_TEMP + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_preshaderOperand + { + public MOJOSHADER_preshaderOperandType type; + public uint index; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct MOJOSHADER_preshaderInstruction + { + public MOJOSHADER_preshaderOpcode opcode; + public uint element_count; + public uint operand_count; + // FIXME: public fixed MOJOSHADER_preshaderOperand operands[4]; + public MOJOSHADER_preshaderOperand operand1; + public MOJOSHADER_preshaderOperand operand2; + public MOJOSHADER_preshaderOperand operand3; + public MOJOSHADER_preshaderOperand operand4; + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_preshader + { + public uint literal_count; + public IntPtr literals; // double* + public uint temp_count; + public uint symbol_count; + public IntPtr symbols; // MOJOSHADER_symbol* + public uint instruction_count; + public IntPtr instructions; // MOJOSHADER_preshaderInstruction* + public uint register_count; + public IntPtr registers; // float* + public IntPtr malloc; // MOJOSHADER_malloc + public IntPtr free; // MOJOSHADER_free + public IntPtr malloc_data; // void* + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_parseData + { + public int error_count; + public IntPtr errors; // MOJOSHADER_errors* + public IntPtr profile; // const char* + public IntPtr output; // const char* + public int output_len; + public int instruction_count; + public MOJOSHADER_shaderType shader_type; + public int major_ver; + public int minor_ver; + public IntPtr mainfn; // const char* + public int uniform_count; + public IntPtr uniforms; // MOJOSHADER_uniform* + public int constant_count; + public int sampler_count; + public IntPtr samplers; // MOJOSHADER_sampler* + public int attribute_count; + public IntPtr attributes; // MOJOSHADER_attribute* + public int output_count; + public IntPtr outputs; // MOJOSHADER_attributes* + public int swizzle_count; + public IntPtr swizzles; // MOJOSHADER_swizzle* + public int symbol_count; + public IntPtr symbols; // MOJOSHADER_symbols* + public IntPtr preshader; // MOJOSHADER_preshader* + public IntPtr malloc; // MOJOSHADER_malloc + public IntPtr free; // MOJOSHADER_free + public IntPtr malloc_data; // void* + } + + public const string MOJOSHADER_PROFILE_D3D = "d3d"; + public const string MOJOSHADER_PROFILE_BYTECODE = "bytecode"; + public const string MOJOSHADER_PROFILE_GLSL = "glsl"; + public const string MOJOSHADER_PROFILE_GLSL120 = "glsl120"; + public const string MOJOSHADER_PROFILE_GLSLES = "glsles"; + public const string MOJOSHADER_PROFILE_ARB1 = "arb1"; + public const string MOJOSHADER_PROFILE_NV2 = "nv2"; + public const string MOJOSHADER_PROFILE_NV3 = "nv3"; + public const string MOJOSHADER_PROFILE_NV4 = "nv4"; + public const string MOJOSHADER_PROFILE_METAL = "metal"; + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + private static extern int MOJOSHADER_maxShaderModel( + byte[] profile + ); + public static int MOJOSHADER_maxShaderModel(string profile) + { + return MOJOSHADER_maxShaderModel(UTF8_ToNative(profile)); + } + + /* IntPtr refers to a MOJOSHADER_parseData*, d to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr MOJOSHADER_parse( + byte[] profile, + byte[] mainfn, + byte[] tokenbuf, + uint bufsize, + MOJOSHADER_swizzle[] swiz, + uint swizcount, + MOJOSHADER_samplerMap[] smap, + uint smapcount, + MOJOSHADER_malloc m, + MOJOSHADER_free f, + IntPtr d + ); + public static IntPtr MOJOSHADER_parse( + string profile, + string mainfn, + byte[] tokenbuf, + uint bufsize, + MOJOSHADER_swizzle[] swiz, + uint swizcount, + MOJOSHADER_samplerMap[] smap, + uint smapcount, + MOJOSHADER_malloc m, + MOJOSHADER_free f, + IntPtr d + ) { + return MOJOSHADER_parse( + UTF8_ToNative(profile), + UTF8_ToNative(mainfn), + tokenbuf, + bufsize, + swiz, + swizcount, + smap, + smapcount, + m, + f, + d + ); + } + + /* data refers to a MOJOSHADER_parseData* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_freeParseData(IntPtr data); + + /* IntPtr refers to a MOJOSHADER_preshader*, d to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr MOJOSHADER_parsePreshader( + byte[] buf, + uint len, + MOJOSHADER_malloc m, + MOJOSHADER_free f, + IntPtr d + ); + + /* preshader refers to a MOJOSHADER_preshader* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_freePreshader(IntPtr preshader); + + #endregion + + #region Effects Interface + + /* MOJOSHADER_effectState types... */ + + public enum MOJOSHADER_renderStateType + { + MOJOSHADER_RS_ZENABLE, + MOJOSHADER_RS_FILLMODE, + MOJOSHADER_RS_SHADEMODE, + MOJOSHADER_RS_ZWRITEENABLE, + MOJOSHADER_RS_ALPHATESTENABLE, + MOJOSHADER_RS_LASTPIXEL, + MOJOSHADER_RS_SRCBLEND, + MOJOSHADER_RS_DESTBLEND, + MOJOSHADER_RS_CULLMODE, + MOJOSHADER_RS_ZFUNC, + MOJOSHADER_RS_ALPHAREF, + MOJOSHADER_RS_ALPHAFUNC, + MOJOSHADER_RS_DITHERENABLE, + MOJOSHADER_RS_ALPHABLENDENABLE, + MOJOSHADER_RS_FOGENABLE, + MOJOSHADER_RS_SPECULARENABLE, + MOJOSHADER_RS_FOGCOLOR, + MOJOSHADER_RS_FOGTABLEMODE, + MOJOSHADER_RS_FOGSTART, + MOJOSHADER_RS_FOGEND, + MOJOSHADER_RS_FOGDENSITY, + MOJOSHADER_RS_RANGEFOGENABLE, + MOJOSHADER_RS_STENCILENABLE, + MOJOSHADER_RS_STENCILFAIL, + MOJOSHADER_RS_STENCILZFAIL, + MOJOSHADER_RS_STENCILPASS, + MOJOSHADER_RS_STENCILFUNC, + MOJOSHADER_RS_STENCILREF, + MOJOSHADER_RS_STENCILMASK, + MOJOSHADER_RS_STENCILWRITEMASK, + MOJOSHADER_RS_TEXTUREFACTOR, + MOJOSHADER_RS_WRAP0, + MOJOSHADER_RS_WRAP1, + MOJOSHADER_RS_WRAP2, + MOJOSHADER_RS_WRAP3, + MOJOSHADER_RS_WRAP4, + MOJOSHADER_RS_WRAP5, + MOJOSHADER_RS_WRAP6, + MOJOSHADER_RS_WRAP7, + MOJOSHADER_RS_WRAP8, + MOJOSHADER_RS_WRAP9, + MOJOSHADER_RS_WRAP10, + MOJOSHADER_RS_WRAP11, + MOJOSHADER_RS_WRAP12, + MOJOSHADER_RS_WRAP13, + MOJOSHADER_RS_WRAP14, + MOJOSHADER_RS_WRAP15, + MOJOSHADER_RS_CLIPPING, + MOJOSHADER_RS_LIGHTING, + MOJOSHADER_RS_AMBIENT, + MOJOSHADER_RS_FOGVERTEXMODE, + MOJOSHADER_RS_COLORVERTEX, + MOJOSHADER_RS_LOCALVIEWER, + MOJOSHADER_RS_NORMALIZENORMALS, + MOJOSHADER_RS_DIFFUSEMATERIALSOURCE, + MOJOSHADER_RS_SPECULARMATERIALSOURCE, + MOJOSHADER_RS_AMBIENTMATERIALSOURCE, + MOJOSHADER_RS_EMISSIVEMATERIALSOURCE, + MOJOSHADER_RS_VERTEXBLEND, + MOJOSHADER_RS_CLIPPLANEENABLE, + MOJOSHADER_RS_POINTSIZE, + MOJOSHADER_RS_POINTSIZE_MIN, + MOJOSHADER_RS_POINTSPRITEENABLE, + MOJOSHADER_RS_POINTSCALEENABLE, + MOJOSHADER_RS_POINTSCALE_A, + MOJOSHADER_RS_POINTSCALE_B, + MOJOSHADER_RS_POINTSCALE_C, + MOJOSHADER_RS_MULTISAMPLEANTIALIAS, + MOJOSHADER_RS_MULTISAMPLEMASK, + MOJOSHADER_RS_PATCHEDGESTYLE, + MOJOSHADER_RS_DEBUGMONITORTOKEN, + MOJOSHADER_RS_POINTSIZE_MAX, + MOJOSHADER_RS_INDEXEDVERTEXBLENDENABLE, + MOJOSHADER_RS_COLORWRITEENABLE, + MOJOSHADER_RS_TWEENFACTOR, + MOJOSHADER_RS_BLENDOP, + MOJOSHADER_RS_POSITIONDEGREE, + MOJOSHADER_RS_NORMALDEGREE, + MOJOSHADER_RS_SCISSORTESTENABLE, + MOJOSHADER_RS_SLOPESCALEDEPTHBIAS, + MOJOSHADER_RS_ANTIALIASEDLINEENABLE, + MOJOSHADER_RS_MINTESSELLATIONLEVEL, + MOJOSHADER_RS_MAXTESSELLATIONLEVEL, + MOJOSHADER_RS_ADAPTIVETESS_X, + MOJOSHADER_RS_ADAPTIVETESS_Y, + MOJOSHADER_RS_ADAPTIVETESS_Z, + MOJOSHADER_RS_ADAPTIVETESS_W, + MOJOSHADER_RS_ENABLEADAPTIVETESSELLATION, + MOJOSHADER_RS_TWOSIDEDSTENCILMODE, + MOJOSHADER_RS_CCW_STENCILFAIL, + MOJOSHADER_RS_CCW_STENCILZFAIL, + MOJOSHADER_RS_CCW_STENCILPASS, + MOJOSHADER_RS_CCW_STENCILFUNC, + MOJOSHADER_RS_COLORWRITEENABLE1, + MOJOSHADER_RS_COLORWRITEENABLE2, + MOJOSHADER_RS_COLORWRITEENABLE3, + MOJOSHADER_RS_BLENDFACTOR, + MOJOSHADER_RS_SRGBWRITEENABLE, + MOJOSHADER_RS_DEPTHBIAS, + MOJOSHADER_RS_SEPARATEALPHABLENDENABLE, + MOJOSHADER_RS_SRCBLENDALPHA, + MOJOSHADER_RS_DESTBLENDALPHA, + MOJOSHADER_RS_BLENDOPALPHA, + MOJOSHADER_RS_VERTEXSHADER = 146, + MOJOSHADER_RS_PIXELSHADER = 147 + } + + public enum MOJOSHADER_zBufferType + { + MOJOSHADER_ZB_FALSE, + MOJOSHADER_ZB_TRUE, + MOJOSHADER_ZB_USEW + } + + public enum MOJOSHADER_fillMode + { + MOJOSHADER_FILL_POINT = 1, + MOJOSHADER_FILL_WIREFRAME = 2, + MOJOSHADER_FILL_SOLID = 3 + } + + public enum MOJOSHADER_shadeMode + { + MOJOSHADER_SHADE_FLAT = 1, + MOJOSHADER_SHADE_GOURAUD = 2, + MOJOSHADER_SHADE_PHONG = 3, + } + + public enum MOJOSHADER_blendMode + { + MOJOSHADER_BLEND_ZERO = 1, + MOJOSHADER_BLEND_ONE = 2, + MOJOSHADER_BLEND_SRCCOLOR = 3, + MOJOSHADER_BLEND_INVSRCCOLOR = 4, + MOJOSHADER_BLEND_SRCALPHA = 5, + MOJOSHADER_BLEND_INVSRCALPHA = 6, + MOJOSHADER_BLEND_DESTALPHA = 7, + MOJOSHADER_BLEND_INVDESTALPHA = 8, + MOJOSHADER_BLEND_DESTCOLOR = 9, + MOJOSHADER_BLEND_INVDESTCOLOR = 10, + MOJOSHADER_BLEND_SRCALPHASAT = 11, + MOJOSHADER_BLEND_BOTHSRCALPHA = 12, + MOJOSHADER_BLEND_BOTHINVSRCALPHA = 13, + MOJOSHADER_BLEND_BLENDFACTOR = 14, + MOJOSHADER_BLEND_INVBLENDFACTOR = 15, + MOJOSHADER_BLEND_SRCCOLOR2 = 16, + MOJOSHADER_BLEND_INVSRCCOLOR2 = 17 + } + + public enum MOJOSHADER_cullMode + { + MOJOSHADER_CULL_NONE = 1, + MOJOSHADER_CULL_CW = 2, + MOJOSHADER_CULL_CCW = 3 + } + + public enum MOJOSHADER_compareFunc + { + MOJOSHADER_CMP_NEVER = 1, + MOJOSHADER_CMP_LESS = 2, + MOJOSHADER_CMP_EQUAL = 3, + MOJOSHADER_CMP_LESSEQUAL = 4, + MOJOSHADER_CMP_GREATER = 5, + MOJOSHADER_CMP_NOTEQUAL = 6, + MOJOSHADER_CMP_GREATEREQUAL = 7, + MOJOSHADER_CMP_ALWAYS = 8 + } + + public enum MOJOSHADER_fogMode + { + MOJOSHADER_FOG_NONE, + MOJOSHADER_FOG_EXP, + MOJOSHADER_FOG_EXP2, + MOJOSHADER_FOG_LINEAR + } + + public enum MOJOSHADER_stencilOp + { + MOJOSHADER_STENCILOP_KEEP = 1, + MOJOSHADER_STENCILOP_ZERO = 2, + MOJOSHADER_STENCILOP_REPLACE = 3, + MOJOSHADER_STENCILOP_INCRSAT = 4, + MOJOSHADER_STENCILOP_DECRSAT = 5, + MOJOSHADER_STENCILOP_INVERT = 6, + MOJOSHADER_STENCILOP_INCR = 7, + MOJOSHADER_STENCILOP_DECR = 8 + } + + public enum MOJOSHADER_materialColorSource + { + MOJOSHADER_MCS_MATERIAL, + MOJOSHADER_MCS_COLOR1, + MOJOSHADER_MCS_COLOR2 + } + + public enum MOJOSHADER_vertexBlendFlags + { + MOJOSHADER_VBF_DISABLE = 0, + MOJOSHADER_VBF_1WEIGHTS = 1, + MOJOSHADER_VBF_2WEIGHTS = 2, + MOJOSHADER_VBF_3WEIGHTS = 3, + MOJOSHADER_VBF_TWEENING = 255, + MOJOSHADER_VBF_0WEIGHTS = 256, + } + + public enum MOJOSHADER_patchedEdgeStyle + { + MOJOSHADER_PATCHEDGE_DISCRETE, + MOJOSHADER_PATCHEDGE_CONTINUOUS + } + + public enum MOJOSHADER_debugMonitorTokens + { + MOJOSHADER_DMT_ENABLE, + MOJOSHADER_DMT_DISABLE + } + + public enum MOJOSHADER_blendOp + { + MOJOSHADER_BLENDOP_ADD = 1, + MOJOSHADER_BLENDOP_SUBTRACT = 2, + MOJOSHADER_BLENDOP_REVSUBTRACT = 3, + MOJOSHADER_BLENDOP_MIN = 4, + MOJOSHADER_BLENDOP_MAX = 5 + } + + public enum MOJOSHADER_degreeType + { + MOJOSHADER_DEGREE_LINEAR = 1, + MOJOSHADER_DEGREE_QUADRATIC = 2, + MOJOSHADER_DEGREE_CUBIC = 3, + MOJOSHADER_DEGREE_QUINTIC = 5 + } + + /* MOJOSHADER_effectSamplerState types... */ + + public enum MOJOSHADER_samplerStateType + { + MOJOSHADER_SAMP_UNKNOWN0 = 0, + MOJOSHADER_SAMP_UNKNOWN1 = 1, + MOJOSHADER_SAMP_UNKNOWN2 = 2, + MOJOSHADER_SAMP_UNKNOWN3 = 3, + MOJOSHADER_SAMP_TEXTURE = 4, + MOJOSHADER_SAMP_ADDRESSU = 5, + MOJOSHADER_SAMP_ADDRESSV = 6, + MOJOSHADER_SAMP_ADDRESSW = 7, + MOJOSHADER_SAMP_BORDERCOLOR = 8, + MOJOSHADER_SAMP_MAGFILTER = 9, + MOJOSHADER_SAMP_MINFILTER = 10, + MOJOSHADER_SAMP_MIPFILTER = 11, + MOJOSHADER_SAMP_MIPMAPLODBIAS = 12, + MOJOSHADER_SAMP_MAXMIPLEVEL = 13, + MOJOSHADER_SAMP_MAXANISOTROPY = 14, + MOJOSHADER_SAMP_SRGBTEXTURE = 15, + MOJOSHADER_SAMP_ELEMENTINDEX = 16, + MOJOSHADER_SAMP_DMAPOFFSET = 17 + } + + public enum MOJOSHADER_textureAddress + { + MOJOSHADER_TADDRESS_WRAP = 1, + MOJOSHADER_TADDRESS_MIRROR = 2, + MOJOSHADER_TADDRESS_CLAMP = 3, + MOJOSHADER_TADDRESS_BORDER = 4, + MOJOSHADER_TADDRESS_MIRRORONCE = 5 + } + + public enum MOJOSHADER_textureFilterType + { + MOJOSHADER_TEXTUREFILTER_NONE, + MOJOSHADER_TEXTUREFILTER_POINT, + MOJOSHADER_TEXTUREFILTER_LINEAR, + MOJOSHADER_TEXTUREFILTER_ANISOTROPIC, + MOJOSHADER_TEXTUREFILTER_PYRAMIDALQUAD, + MOJOSHADER_TEXTUREFILTER_GAUSSIANQUAD, + MOJOSHADER_TEXTUREFILTER_CONVOLUTIONMONO + } + + /* Effect value types... */ + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectValue + { + public IntPtr name; // const char* + public IntPtr semantic; // const char* + public MOJOSHADER_symbolTypeInfo type; + public uint value_count; + public IntPtr values; // You know what, just look at the C header... + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectState + { + public MOJOSHADER_renderStateType type; + public MOJOSHADER_effectValue value; + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectSamplerState + { + public MOJOSHADER_samplerStateType type; + public MOJOSHADER_effectValue value; + } + + /* typedef MOJOSHADER_effectValue MOJOSHADER_effectAnnotation; */ + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectAnnotation + { + public IntPtr name; // const char* + public IntPtr semantic; // const char* + public MOJOSHADER_symbolTypeInfo type; + public uint value_count; + public IntPtr values; // You know what, just look at the C header... + } + + /* Effect interface structures... */ + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectParam + { + public MOJOSHADER_effectValue value; + public uint annotation_count; + public IntPtr annotations; // MOJOSHADER_effectAnnotations* + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectPass + { + public IntPtr name; // const char* + public uint state_count; + public IntPtr states; // MOJOSHADER_effectState* + public uint annotation_count; + public IntPtr annotations; // MOJOSHADER_effectAnnotations* + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectTechnique + { + public IntPtr name; // const char* + public uint pass_count; + public IntPtr passes; // MOJOSHADER_effectPass* + public uint annotation_count; + public IntPtr annotations; // MOJOSHADER_effectAnnotations* + } + + /* Effect "objects"... */ + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectShader + { + public MOJOSHADER_symbolType type; + public uint technique; + public uint pass; + public uint is_preshader; + public uint preshader_param_count; + public IntPtr preshader_params; // unsigned int* + public uint param_count; + public IntPtr parameters; // unsigned int* + public uint sampler_count; + public IntPtr samplers; // MOJOSHADER_samplerStateRegister* + public IntPtr shader; // *shader/*preshader union + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectSamplerMap + { + public MOJOSHADER_symbolType type; + public IntPtr name; // const char* + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectString + { + public MOJOSHADER_symbolType type; + public IntPtr stringvalue; // const char* + } + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectTexture + { + public MOJOSHADER_symbolType type; + } + + [StructLayout(LayoutKind.Explicit)] + public struct MOJOSHADER_effectObject + { + [FieldOffset(0)] + public MOJOSHADER_symbolType type; + [FieldOffset(0)] + public MOJOSHADER_effectShader shader; + [FieldOffset(0)] + public MOJOSHADER_effectSamplerMap mapping; + [FieldOffset(0)] + public MOJOSHADER_effectString stringvalue; + [FieldOffset(0)] + public MOJOSHADER_effectTexture texture; + } + + /* Effect state change types... */ + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_samplerStateRegister + { + public IntPtr sampler_name; // const char* + public uint sampler_register; + public uint sampler_state_count; + public IntPtr sampler_states; // const MOJOSHADER_effectSamplerState* + } + + /* DO NOT USE STORE THIS STRUCT AS MANAGED MEMORY! + * Instead, call malloc(sizeof(MOJOSHADER_effectStateChanges)) + * and send that to Begin(). + */ + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effectStateChanges + { + public uint render_state_change_count; + public IntPtr render_state_changes; // const MOJOSHADER_effectState* + public uint sampler_state_change_count; + public IntPtr sampler_state_changes; // const MOJOSHADER_samplerStateRegister* + public uint vertex_sampler_state_change_count; + public IntPtr vertex_sampler_state_changes; // const MOJOSHADER_samplerStateRegister* + } + + /* Effect parsing interface... */ + + [StructLayout(LayoutKind.Sequential)] + public struct MOJOSHADER_effect + { + public int error_count; + public IntPtr errors; // MOJOSHADER_error* + public IntPtr profile; // const char* + public int param_count; + public IntPtr parameters; // MOJOSHADER_effectParam* params, lolC# + public int technique_count; + public IntPtr techniques; // MOJOSHADER_effectTechnique* + public IntPtr current_technique; // const MOJOSHADER_effectTechnique* + public int current_pass; + public int object_count; + public IntPtr objects; // MOJOSHADER_effectObject* + public int restore_render_state; + public IntPtr state_changes; // MOJOSHADER_effectStateChanges* + public IntPtr m; // MOJOSHADER_malloc + public IntPtr f; // MOJOSHADER_free + public IntPtr malloc_data; // void* + } + + /* IntPtr refers to a MOJOSHADER_effect*, d to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr MOJOSHADER_parseEffect( + byte[] profile, + byte[] buf, + uint _len, + MOJOSHADER_swizzle[] swiz, + uint swizcount, + MOJOSHADER_samplerMap[] smap, + uint smapcount, + MOJOSHADER_malloc m, + MOJOSHADER_free f, + IntPtr d + ); + public static IntPtr MOJOSHADER_parseEffect( + string profile, + byte[] buf, + uint _len, + MOJOSHADER_swizzle[] swiz, + uint swizcount, + MOJOSHADER_samplerMap[] smap, + uint smapcount, + MOJOSHADER_malloc m, + MOJOSHADER_free f, + IntPtr d + ) { + return MOJOSHADER_parseEffect( + UTF8_ToNative(profile), + buf, + _len, + swiz, + swizcount, + smap, + smapcount, + m, + f, + d + ); + } + + /* effect refers to a MOJOSHADER_effect* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_freeEffect(IntPtr effect); + + /* IntPtr/effect refer to a MOJOSHADER_effect* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr MOJOSHADER_cloneEffect(IntPtr effect); + + /* Effect parameter interface... */ + + /* parameter refers to a MOJOSHADER_effectParam*, data to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_effectSetRawValueHandle( + IntPtr parameter, + IntPtr data, + uint offset, + uint len + ); + + /* effect refers to a MOJOSHADER_effect*, data to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void MOJOSHADER_effectSetRawValueName( + IntPtr effect, + byte[] name, + IntPtr data, + uint offset, + uint len + ); + public static void MOJOSHADER_effectSetRawValueName( + IntPtr effect, + string name, + IntPtr data, + uint offset, + uint len + ) { + MOJOSHADER_effectSetRawValueName( + effect, + UTF8_ToNative(name), + data, + offset, + len + ); + } + + /* Effect technique interface... */ + + /* IntPtr refers to a MOJOSHADER_effectTechnique*, effect to a MOJOSHADER_effect* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr MOJOSHADER_effectGetCurrentTechnique( + IntPtr effect + ); + + /* effect refers to a MOJOSHADER_effect*, technique to a MOJOSHADER_effectTechnique* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_effectSetTechnique( + IntPtr effect, + IntPtr technique + ); + + /* IntPtr/technique refer to a MOJOSHADER_effectTechnique, effect to a MOJOSHADER_effect* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr MOJOSHADER_effectFindNextValidTechnique( + IntPtr effect, + IntPtr technique + ); + + /* OpenGL effect interface... */ + + /* IntPtr refers to a MOJOSHADER_glEffect*, effect to a MOJOSHADER_effect* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr MOJOSHADER_glCompileEffect(IntPtr effect); + + /* glEffect refers to a MOJOSHADER_glEffect* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glDeleteEffect(IntPtr glEffect); + + /* glEffect refers to a MOJOSHADER_glEffect* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glEffectBegin( + IntPtr glEffect, + out uint numPasses, + int saveShaderState, + IntPtr stateChanges + ); + + /* glEffect refers to a MOJOSHADER_glEffect* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glEffectBeginPass( + IntPtr glEffect, + uint pass + ); + + /* glEffect refers to a MOJOSHADER_glEffect* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glEffectCommitChanges( + IntPtr glEffect + ); + + /* glEffect refers to a MOJOSHADER_glEffect* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glEffectEndPass(IntPtr glEffect); + + /* glEffect refers to a MOJOSHADER_glEffect* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glEffectEnd(IntPtr glEffect); + + #endregion + + #region Preprocessor Interface + + // TODO: Needed for MojoShader#? -flibit + + #endregion + + #region Assembler Interface + + // TODO: Needed for MojoShader#? -flibit + + #endregion + + #region HLSL Support + + // TODO: Needed for MojoShader#? -flibit + + #endregion + + #region Abtract Syntax Tree Interface + + // TODO: Needed for MojoShader#? -flibit + + #endregion + + #region Intermediate Representation Interface + + // TODO: Needed for MojoShader#? -flibit + + #endregion + + #region Compiler Interface + + // TODO: Needed for MojoShader#? -flibit + + #endregion + + #region OpenGL Interface + + public delegate IntPtr MOJOSHADER_glGetProcAddress( + IntPtr fnname, + IntPtr data + ); + + /* lookup_d refers to a void*. + * profs refers to a pre-allocated const char**. + * malloc_d to a void*. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int MOJOSHADER_glAvailableProfiles( + MOJOSHADER_glGetProcAddress lookup, + IntPtr lookup_d, + IntPtr[] profs, + int size, + MOJOSHADER_malloc m, + MOJOSHADER_free f, + IntPtr malloc_d + ); + + /* lookup_d refers to a void*, malloc_d to a void* */ + [DllImport(nativeLibName, EntryPoint = "MOJOSHADER_glBestProfile", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_glBestProfile( + MOJOSHADER_glGetProcAddress lookup, + IntPtr lookup_d, + MOJOSHADER_malloc m, + MOJOSHADER_free f, + IntPtr malloc_d + ); + public static string MOJOSHADER_glBestProfile( + MOJOSHADER_glGetProcAddress lookup, + IntPtr lookup_d, + MOJOSHADER_malloc m, + MOJOSHADER_free f, + IntPtr malloc_d + ) { + return UTF8_ToManaged( + INTERNAL_glBestProfile( + lookup, + lookup_d, + m, + f, + malloc_d + ) + ); + } + + /* IntPtr refers to a MOJOSHADER_glContext, + * lookup_d to a void*, malloc_d to a void* + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr MOJOSHADER_glCreateContext( + byte[] profile, + MOJOSHADER_glGetProcAddress lookup, + IntPtr lookup_d, + MOJOSHADER_malloc m, + MOJOSHADER_free f, + IntPtr malloc_d + ); + public static IntPtr MOJOSHADER_glCreateContext( + string profile, + MOJOSHADER_glGetProcAddress lookup, + IntPtr lookup_d, + MOJOSHADER_malloc m, + MOJOSHADER_free f, + IntPtr malloc_d + ) { + return MOJOSHADER_glCreateContext( + UTF8_ToNative(profile), + lookup, + lookup_d, + m, + f, + malloc_d + ); + } + + /* ctx refers to a MOJOSHADER_glContext* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glMakeContextCurrent(IntPtr ctx); + + [DllImport(nativeLibName, EntryPoint = "MOJOSHADER_glGetError", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_glGetError(); + public static string MOJOSHADER_glGetError() + { + return UTF8_ToManaged(INTERNAL_glGetError()); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int MOJOSHADER_glMaxUniforms( + MOJOSHADER_shaderType shader_type + ); + + /* IntPtr refers to a MOJOSHADER_glShader* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr MOJOSHADER_glCompileShader( + byte[] tokenbuf, + uint bufsize, + MOJOSHADER_swizzle[] swiz, + uint swizcount, + MOJOSHADER_samplerMap[] smap, + uint smapcount + ); + + /* IntPtr refers to a const MOJOSHADER_parseData* + * shader refers to a MOJOSHADER_glShader* + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr MOJOSHADER_glGetShaderParseData( + IntPtr shader + ); + + /* IntPtr refers to a MOJOSHADER_glProgram* + * vshader/pshader refer to a MOJOSHADER_glShader* + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr MOJOSHADER_glLinkProgram( + IntPtr vshader, + IntPtr pshader + ); + + /* program refers to a MOJOSHADER_glProgram* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glBindProgram(IntPtr program); + + /* vshader/pshader refer to a MOJOSHADER_glShader* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glBindShaders( + IntPtr vshader, + IntPtr pshader + ); + + /* data refers to a const float* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glSetVertexShaderUniformF( + uint idx, + IntPtr data, + uint vec4count + ); + + /* data refers to a float* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glGetVertexShaderUniformF( + uint idx, + IntPtr data, + uint vec4count + ); + + /* data refers to a const int* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glSetVertexShaderUniformI( + uint idx, + IntPtr data, + uint ivec4count + ); + + /* data refers to an int* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glGetVertexShaderUniformI( + uint idx, + IntPtr data, + uint ivec4count + ); + + /* data refers to a const int* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glSetVertexShaderUniformB( + uint idx, + IntPtr data, + uint bcount + ); + + /* data refers to an int* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glGetVertexShaderUniformB( + uint idx, + IntPtr data, + uint bcount + ); + + /* data refers to a const float* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glSetPixelShaderUniformF( + uint idx, + IntPtr data, + uint vec4count + ); + + /* data refers to a float* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glGetPixelShaderUniformF( + uint idx, + IntPtr data, + uint vec4count + ); + + /* data refers to a const int* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glSetPixelShaderUniformI( + uint idx, + IntPtr data, + uint ivec4count + ); + + /* data refers to an int* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glGetPixelShaderUniformI( + uint idx, + IntPtr data, + uint ivec4count + ); + + /* data refers to a const int* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glSetPixelShaderUniformB( + uint idx, + IntPtr data, + uint bcount + ); + + /* data refers to an int* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glGetPixelShaderUniformB( + uint idx, + IntPtr data, + uint bcount + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glSetLegacyBumpMapEnv( + uint sampler, + float mat00, + float mat01, + float mat10, + float mat11, + float lscale, + float loffset + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int MOJOSHADER_glGetVertexAttribLocation( + MOJOSHADER_usage usage, + int index + ); + + /* ptr refers to a const void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glSetVertexAttribute( + MOJOSHADER_usage usage, + int index, + uint size, + MOJOSHADER_attributeType type, + int normalized, + uint stride, + IntPtr ptr + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glSetVertexAttribDivisor( + MOJOSHADER_usage usage, + int index, + uint divisor + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glProgramReady(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glProgramViewportFlip(int flip); + + /* program refers to a MOJOSHADER_glProgram* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glDeleteProgram(IntPtr program); + + /* shader refers to a MOJOSHADER_glShader* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glDeleteShader(IntPtr shader); + + /* ctx refers to a MOJOSHADER_glContext* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void MOJOSHADER_glDestroyContext(IntPtr ctx); + + #endregion +} diff --git a/FNA/lib/MojoShader-CS/README b/FNA/lib/MojoShader-CS/README new file mode 100644 index 0000000..dd11ec2 --- /dev/null +++ b/FNA/lib/MojoShader-CS/README @@ -0,0 +1,17 @@ +This is MojoShader#, a C# wrapper for MojoShader, a library to work with +Direct3D shaders on alternate 3D APIs and non-Windows platforms. + +License +------- +MojoShader# is released under the zlib license. See LICENSE for details. + +About MojoShader +---------------- +For more information about MojoShader, visit the website: + +http://icculus.org/mojoshader/ + +About the C# Wrapper +-------------------- +MojoShader# was written to be used for FNA's Effect shader support. We wrap this +around MojoShader compiled as a shared library. diff --git a/FNA/lib/OpenAL-CS/.gitignore b/FNA/lib/OpenAL-CS/.gitignore new file mode 100644 index 0000000..ddb8b56 --- /dev/null +++ b/FNA/lib/OpenAL-CS/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +*.pidb +*.userprefs +*.suo diff --git a/FNA/lib/OpenAL-CS/LICENSE b/FNA/lib/OpenAL-CS/LICENSE new file mode 100644 index 0000000..f020269 --- /dev/null +++ b/FNA/lib/OpenAL-CS/LICENSE @@ -0,0 +1,25 @@ +/* OpenAL# - C# Wrapper for OpenAL Soft + * + * Copyright (c) 2014-2015 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ diff --git a/FNA/lib/OpenAL-CS/Makefile b/FNA/lib/OpenAL-CS/Makefile new file mode 100644 index 0000000..cdabaf7 --- /dev/null +++ b/FNA/lib/OpenAL-CS/Makefile @@ -0,0 +1,34 @@ +# Makefile for OpenAL# +# Written by Ethan "flibitijibibo" Lee + +# Source Lists +SRC = \ + src/ALC10.cs \ + src/ALC11.cs \ + src/AL10.cs \ + src/AL11.cs \ + src/ALEXT.cs \ + src/EFX.cs + +# Targets + +debug: clean-debug + mkdir -p bin/Debug + cp OpenAL-CS.dll.config bin/Debug + dmcs /unsafe -debug -out:bin/Debug/OpenAL-CS.dll -target:library $(SRC) + +clean-debug: + rm -rf bin/Debug + +release: clean-release + mkdir -p bin/Release + cp OpenAL-CS.dll.config bin/Release + dmcs /unsafe -optimize -out:bin/Release/OpenAL-CS.dll -target:library $(SRC) + +clean-release: + rm -rf bin/Release + +clean: clean-debug clean-release + rm -rf bin + +all: debug release diff --git a/FNA/lib/OpenAL-CS/OpenAL-CS.csproj b/FNA/lib/OpenAL-CS/OpenAL-CS.csproj new file mode 100644 index 0000000..6476f60 --- /dev/null +++ b/FNA/lib/OpenAL-CS/OpenAL-CS.csproj @@ -0,0 +1,85 @@ + + + + Debug + x86 + 9.0.21022 + 2.0 + {4FF0E874-ADB4-4AE5-B059-DD6116C4A370} + Library + OpenAL + OpenAL-CS + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + x86 + false + + + none + false + bin\Release + prompt + 4 + x86 + false + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + none + false + bin\Release + prompt + 4 + false + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + x64 + false + + + none + false + bin\Release + prompt + 4 + x64 + false + + + + + + + + + + + + + Always + + + diff --git a/FNA/lib/OpenAL-CS/OpenAL-CS.dll.config b/FNA/lib/OpenAL-CS/OpenAL-CS.dll.config new file mode 100644 index 0000000..1bc7bc4 --- /dev/null +++ b/FNA/lib/OpenAL-CS/OpenAL-CS.dll.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/FNA/lib/OpenAL-CS/OpenAL-CS.sln b/FNA/lib/OpenAL-CS/OpenAL-CS.sln new file mode 100644 index 0000000..9ad0527 --- /dev/null +++ b/FNA/lib/OpenAL-CS/OpenAL-CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAL-CS", "OpenAL-CS.csproj", "{4FF0E874-ADB4-4AE5-B059-DD6116C4A370}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4FF0E874-ADB4-4AE5-B059-DD6116C4A370}.Debug|x86.ActiveCfg = Debug|x86 + {4FF0E874-ADB4-4AE5-B059-DD6116C4A370}.Debug|x86.Build.0 = Debug|x86 + {4FF0E874-ADB4-4AE5-B059-DD6116C4A370}.Release|x86.ActiveCfg = Release|x86 + {4FF0E874-ADB4-4AE5-B059-DD6116C4A370}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = OpenAL-CS.csproj + EndGlobalSection +EndGlobal diff --git a/FNA/lib/OpenAL-CS/README b/FNA/lib/OpenAL-CS/README new file mode 100644 index 0000000..370ec6a --- /dev/null +++ b/FNA/lib/OpenAL-CS/README @@ -0,0 +1,31 @@ +This is OpenAL#, a C# wrapper for OpenAL Soft. + +Project Website: https://github.com/flibitijibibo/OpenAL-CS + +License +------- +OpenAL# is released under the zlib license. See LICENSE for details. + +OpenAL Soft, however, is released under the GNU LGPLv2. See below for details. + +About OpenAL Soft +----------------- +For more information about OpenAL Soft and its license, visit the website: + +http://kcat.strangesoft.net/openal.html + +About the C# Wrapper +-------------------- +The C# wrapper was written to be used for FNA's audio support. However, this +is written in a way that can be used for any general C# application. + +OpenAL# is a pure port of the C headers. The naming schemes for this library +will be exactly as they are done in the C library, with little-to-no concern +for "appropriate" C# style. The namespace indicates that this is OpenAL, the +class names will indicate which OpenAL standard version the +function/type/value exists in, and everything else will be as close to the C +version as technically possible. + +Also note that we do not use alGetProcAddress to obtain extension functions. +Since this wrapper specifically supports OpenAL Soft only, we will be +accessing the library's entry points directly. diff --git a/FNA/lib/OpenAL-CS/src/AL10.cs b/FNA/lib/OpenAL-CS/src/AL10.cs new file mode 100644 index 0000000..46ca603 --- /dev/null +++ b/FNA/lib/OpenAL-CS/src/AL10.cs @@ -0,0 +1,593 @@ +#region License +/* OpenAL# - C# Wrapper for OpenAL Soft + * + * Copyright (c) 2014-2015 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace OpenAL +{ + public static class AL10 + { + private const string nativeLibName = "soft_oal.dll"; + + /* typedef int ALenum; */ + public const int AL_NONE = 0x0000; + public const int AL_FALSE = 0x0000; + public const int AL_TRUE = 0x0001; + + public const int AL_SOURCE_RELATIVE = 0x0202; + + public const int AL_CONE_INNER_ANGLE = 0x1001; + public const int AL_CONE_OUTER_ANGLE = 0x1002; + + public const int AL_PITCH = 0x1003; + public const int AL_POSITION = 0x1004; + public const int AL_DIRECTION = 0x1005; + public const int AL_VELOCITY = 0x1006; + public const int AL_LOOPING = 0x1007; + public const int AL_BUFFER = 0x1009; + public const int AL_GAIN = 0x100A; + public const int AL_MIN_GAIN = 0x100D; + public const int AL_MAX_GAIN = 0x100E; + public const int AL_ORIENTATION = 0x100F; + + public const int AL_SOURCE_STATE = 0x1010; + public const int AL_INITIAL = 0x1011; + public const int AL_PLAYING = 0x1012; + public const int AL_PAUSED = 0x1013; + public const int AL_STOPPED = 0x1014; + + public const int AL_BUFFERS_QUEUED = 0x1015; + public const int AL_BUFFERS_PROCESSED = 0x1016; + + public const int AL_REFERENCE_DISTANCE = 0x1020; + public const int AL_ROLLOFF_FACTOR = 0x1021; + public const int AL_CONE_OUTER_GAIN = 0x1022; + + public const int AL_MAX_DISTANCE = 0x1023; + + public const int AL_SOURCE_TYPE = 0x1027; + public const int AL_STATIC = 0x1028; + public const int AL_STREAMING = 0x1029; + public const int AL_UNDETERMINED = 0x1030; + + public const int AL_FORMAT_MONO8 = 0x1100; + public const int AL_FORMAT_MONO16 = 0x1101; + public const int AL_FORMAT_STEREO8 = 0x1102; + public const int AL_FORMAT_STEREO16 = 0x1103; + + public const int AL_FREQUENCY = 0x2001; + public const int AL_BITS = 0x2002; + public const int AL_CHANNELS = 0x2003; + public const int AL_SIZE = 0x2004; + + public const int AL_NO_ERROR = 0x0000; + public const int AL_INVALID_NAME = 0xA001; + public const int AL_INVALID_ENUM = 0xA002; + public const int AL_INVALID_VALUE = 0xA003; + public const int AL_INVALID_OPERATION = 0xA004; + public const int AL_OUT_OF_MEMORY = 0xA005; + + public const int AL_VENDOR = 0xB001; + public const int AL_VERSION = 0xB002; + public const int AL_RENDERER = 0xB003; + public const int AL_EXTENSIONS = 0xB004; + + public const int AL_DOPPLER_FACTOR = 0xC000; + /* Deprecated! */ + public const int AL_DOPPLER_VELOCITY = 0xC001; + + public const int AL_DISTANCE_MODEL = 0xD000; + public const int AL_INVERSE_DISTANCE = 0xD001; + public const int AL_INVERSE_DISTANCE_CLAMPED = 0xD002; + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDopplerFactor(float value); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDistanceModel(int distanceModel); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alEnable(int capability); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDisable(int capability); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alIsEnabled(int capability); + + [DllImport(nativeLibName, EntryPoint = "alGetString", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_alGetString(int param); + public static string alGetString(int param) + { + return Marshal.PtrToStringAnsi(INTERNAL_alGetString(param)); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetBooleanv(int param, bool[] values); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetIntegerv(int param, int[] values); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetFloatv(int param, float[] values); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetDoublev(int param, double[] values); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alGetBoolean(int param); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int alGetInteger(int param); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float alGetFloat(int param); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern double alGetDouble(int param); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int alGetError(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alIsExtensionPresent( + [In()] [MarshalAs(UnmanagedType.LPStr)] + string extname + ); + + /* IntPtr refers to a function pointer */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr alGetProcAddress( + [In()] [MarshalAs(UnmanagedType.LPStr)] + string fname + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int alGetEnumValue( + [In()] [MarshalAs(UnmanagedType.LPStr)] + string ename + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alListenerf( + int param, + float value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alListener3f( + int param, + float value1, + float value2, + float value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alListenerfv( + int param, + float[] values + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alListeneri( + int param, + int value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alListener3i( + int param, + int value1, + int value2, + int value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alListeneriv( + int param, + int[] values + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetListenerf( + int param, + out float value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetListener3f( + int param, + out float value1, + out float value2, + out float value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetListenerfv( + int param, + float[] values + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetListeneri( + int param, + out int value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetListener3i( + int param, + out int value1, + out int value2, + out int value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetListeneriv( + int param, + int[] values + ); + + /* n refers to a ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGenSources(int n, uint[] sources); + + /* n refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGenSources(int n, out uint sources); + + /* n refers to a ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDeleteSources(int n, uint[] sources); + + /* n refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDeleteSources(int n, ref uint sources); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alIsSource(uint source); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourcef( + uint source, + int param, + float value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSource3f( + uint source, + int param, + float value1, + float value2, + float value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourcefv( + uint source, + int param, + float[] values + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourcei( + uint source, + int param, + int value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSource3i( + uint source, + int param, + int value1, + int value2, + int value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourceiv( + uint source, + int param, + int[] values + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetSourcef( + uint source, + int param, + out float value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetSource3f( + uint source, + int param, + out float value1, + out float value2, + out float value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetSourcefv( + uint source, + int param, + float[] values + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetSourcei( + uint source, + int param, + out int value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetSource3i( + uint source, + int param, + out int value1, + out int value2, + out int value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetSourceiv( + uint source, + int param, + int[] values + ); + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourcePlayv( + int n, + uint[] sources + ); + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourceStopv( + int n, + uint[] sources + ); + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourceRewindv( + int n, + uint[] sources + ); + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourcePausev( + int n, + uint[] sources + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourcePlay(uint source); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourceStop(uint source); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourceRewind(uint source); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourcePause(uint source); + + /* nb refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourceQueueBuffers( + uint source, + int nb, + uint[] buffers + ); + + /* nb refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourceQueueBuffers( + uint source, + int nb, + ref uint buffers + ); + + /* nb refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourceUnqueueBuffers( + uint source, + int nb, + uint[] buffers + ); + + /* nb refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSourceUnqueueBuffers( + uint source, + int nb, + ref uint buffers + ); + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGenBuffers(int n, uint[] buffers); + + /* n refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGenBuffers(int n, out uint buffers); + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDeleteBuffers(int n, uint[] buffers); + + /* n refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDeleteBuffers(int n, ref uint buffers); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alIsBuffer(uint buffer); + + /* data refers to a void*, size and freq to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alBufferData( + uint buffer, + int format, + IntPtr data, + int size, + int freq + ); + + /* size and freq refer to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alBufferData( + uint buffer, + int format, + byte[] data, + int size, + int freq + ); + + /* size and freq refer to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alBufferData( + uint buffer, + int format, + short[] data, + int size, + int freq + ); + + /* size and freq refer to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alBufferData( + uint buffer, + int format, + float[] data, + int size, + int freq + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alBufferf( + uint buffer, + int param, + float value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alBuffer3f( + uint buffer, + int param, + float value1, + float value2, + float value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alBufferfv( + uint buffer, + int param, + float[] values + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alBufferi( + uint buffer, + int param, + int value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alBuffer3i( + uint buffer, + int param, + int value1, + int value2, + int value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alBufferiv( + uint buffer, + int param, + int[] values + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetBufferf( + uint buffer, + int param, + out float value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetBuffer3f( + uint buffer, + int param, + out float value1, + out float value2, + out float value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetBufferfv( + uint buffer, + int param, + float[] values + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetBufferi( + uint buffer, + int param, + out int value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetBuffer3i( + uint buffer, + int param, + out int value1, + out int value2, + out int value3 + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetBufferiv( + uint buffer, + int param, + int[] values + ); + } +} diff --git a/FNA/lib/OpenAL-CS/src/AL11.cs b/FNA/lib/OpenAL-CS/src/AL11.cs new file mode 100644 index 0000000..0e389d8 --- /dev/null +++ b/FNA/lib/OpenAL-CS/src/AL11.cs @@ -0,0 +1,55 @@ +#region License +/* OpenAL# - C# Wrapper for OpenAL Soft + * + * Copyright (c) 2014-2015 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace OpenAL +{ + public static class AL11 + { + private const string nativeLibName = "soft_oal.dll"; + + /* typedef int ALenum; */ + public const int AL_SEC_OFFSET = 0x1024; + public const int AL_SAMPLE_OFFSET = 0x1025; + public const int AL_BYTE_OFFSET = 0x1026; + + public const int AL_SPEED_OF_SOUND = 0xC004; + + public const int AL_LINEAR_DISTANCE = 0xD003; + public const int AL_LINEAR_DISTANCE_CLAMPED = 0xD004; + public const int AL_EXPONENT_DISTANCE = 0xD005; + public const int AL_EXPONENT_DISTANCE_CLAMED = 0xD006; + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alSpeedOfSound(float value); + } +} diff --git a/FNA/lib/OpenAL-CS/src/ALC10.cs b/FNA/lib/OpenAL-CS/src/ALC10.cs new file mode 100644 index 0000000..e099d94 --- /dev/null +++ b/FNA/lib/OpenAL-CS/src/ALC10.cs @@ -0,0 +1,127 @@ +#region License +/* OpenAL# - C# Wrapper for OpenAL Soft + * + * Copyright (c) 2014-2015 Ethan Lee + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace OpenAL +{ + public static class ALC10 + { + private const string nativeLibName = "soft_oal.dll"; + + /* typedef int ALenum; */ + public const int ALC_FALSE = 0x0000; + public const int ALC_TRUE = 0x0001; + public const int ALC_FREQUENCY = 0x1007; + public const int ALC_REFRESH = 0x1008; + public const int ALC_SYNC = 0x1009; + + public const int ALC_NO_ERROR = 0x0000; + public const int ALC_INVALID_DEVICE = 0xA001; + public const int ALC_INVALID_CONTEXT = 0xA002; + public const int ALC_INVALID_ENUM = 0xA003; + public const int ALC_INVALID_VALUE = 0xA004; + public const int ALC_OUT_OF_MEMORY = 0xA005; + + public const int ALC_ATTRIBUTES_SIZE = 0x1002; + public const int ALC_ALL_ATTRIBUTES = 0x1003; + public const int ALC_DEFAULT_DEVICE_SPECIFIER = 0x1004; + public const int ALC_DEVICE_SPECIFIER = 0x1005; + public const int ALC_EXTENSIONS = 0x1006; + + /* IntPtr refers to an ALCcontext*, device to an ALCdevice* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr alcCreateContext( + IntPtr device, + int[] attrList + ); + + /* context refers to an ALCcontext* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alcMakeContextCurrent(IntPtr context); + + /* context refers to an ALCcontext* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alcDestroyContext(IntPtr context); + + /* IntPtr refers to an ALCcontext* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr alcGetCurrentContext(); + + /* IntPtr refers to an ALCdevice*, context to an ALCcontext* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr alcGetContextsDevice(IntPtr context); + + /* IntPtr refers to an ALCdevice* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr alcOpenDevice( + [In()] [MarshalAs(UnmanagedType.LPStr)] + string devicename + ); + + /* device refers to an ALCdevice* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alcCloseDevice(IntPtr device); + + /* device refers to an ALCdevice* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int alcGetError(IntPtr device); + + /* IntPtr refers to a function pointer, device to an ALCdevice* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr alcGetProcAddress( + IntPtr device, + [In()] [MarshalAs(UnmanagedType.LPStr)] + string funcname + ); + + /* device refers to an ALCdevice* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int alcGetEnumValue( + IntPtr device, + [In()] [MarshalAs(UnmanagedType.LPStr)] + string enumname + ); + + /* device refers to an ALCdevice* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr alcGetString(IntPtr device, int param); + + /* device refers to an ALCdevice*, size to an ALCsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alcGetIntegerv( + IntPtr device, + int param, + int size, + int[] values + ); + } +} diff --git a/FNA/lib/OpenAL-CS/src/ALC11.cs b/FNA/lib/OpenAL-CS/src/ALC11.cs new file mode 100644 index 0000000..30ad29e --- /dev/null +++ b/FNA/lib/OpenAL-CS/src/ALC11.cs @@ -0,0 +1,96 @@ +#region License +/* OpenAL# - C# Wrapper for OpenAL Soft + * + * Copyright (c) 2014-2015 Ethan Lee + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace OpenAL +{ + public static class ALC11 + { + private const string nativeLibName = "soft_oal.dll"; + + /* typedef int ALenum */ + public const int ALC_MONO_SOURCES = 0x1010; + public const int ALC_STEREO_SOURCES = 0x1011; + + public const int ALC_CAPTURE_DEVICE_SPECIFIER = 0x0310; + public const int ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER = 0x0311; + public const int ALC_CAPTURE_SAMPLES = 0x0312; + public const int ALC_DEFAULT_ALL_DEVICES_SPECIFIER = 0x1012; + public const int ALC_ALL_DEVICES_SPECIFIER = 0x1013; + + /* context refers to an ALCcontext* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alcProcessContext(IntPtr context); + + /* context refers to an ALCcontext* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alcSuspendContext(IntPtr context); + + /* device refers to an ALCdevice* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alcIsExtensionPresent( + IntPtr device, + [In()] [MarshalAs(UnmanagedType.LPStr)] + string extname + ); + + /* IntPtr refers to an ALCdevice*, buffersize to an ALCsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr alcCaptureOpenDevice( + [In()] [MarshalAs(UnmanagedType.LPStr)] + string devicename, + uint frequency, + int format, + int buffersize + ); + + /* device refers to an ALCdevice* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alcCaptureCloseDevice(IntPtr device); + + /* device refers to an ALCdevice* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alcCaptureStart(IntPtr device); + + /* device refers to an ALCdevice* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alcCaptureStop(IntPtr device); + + /* device refers to an ALCdevice*, samples to an ALCsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alcCaptureSamples( + IntPtr device, + IntPtr buffer, + int samples + ); + } +} diff --git a/FNA/lib/OpenAL-CS/src/ALEXT.cs b/FNA/lib/OpenAL-CS/src/ALEXT.cs new file mode 100644 index 0000000..3124968 --- /dev/null +++ b/FNA/lib/OpenAL-CS/src/ALEXT.cs @@ -0,0 +1,73 @@ +#region License +/* OpenAL# - C# Wrapper for OpenAL Soft + * + * Copyright (c) 2014-2015 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace OpenAL +{ + public static class ALEXT + { + private const string nativeLibName = "soft_oal.dll"; + + /* TODO: All OpenAL Soft extensions! Complete as needed. */ + + /* typedef int ALenum */ + public const int AL_FORMAT_MONO_FLOAT32 = 0x10010; + public const int AL_FORMAT_STEREO_FLOAT32 = 0x10011; + + public const int AL_LOOP_POINTS_SOFT = 0x2015; + + public const int AL_UNPACK_BLOCK_ALIGNMENT_SOFT = 0x200C; + public const int AL_PACK_BLOCK_ALIGNMENT_SOFT = 0x200D; + + public const int AL_FORMAT_MONO_MSADPCM_SOFT = 0x1302; + public const int AL_FORMAT_STEREO_MSADPCM_SOFT = 0x1303; + + public const int AL_BYTE_SOFT = 0x1400; + public const int AL_SHORT_SOFT = 0x1402; + public const int AL_FLOAT_SOFT = 0x1406; + + public const int AL_MONO_SOFT = 0x1500; + public const int AL_STEREO_SOFT = 0x1501; + + public const int AL_GAIN_LIMIT_SOFT = 0x200E; + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetBufferSamplesSOFT( + uint buffer, + int offset, + int samples, + int channels, + int type, + IntPtr data + ); + } +} diff --git a/FNA/lib/OpenAL-CS/src/EFX.cs b/FNA/lib/OpenAL-CS/src/EFX.cs new file mode 100644 index 0000000..6a94e2d --- /dev/null +++ b/FNA/lib/OpenAL-CS/src/EFX.cs @@ -0,0 +1,435 @@ +#region License +/* OpenAL# - C# Wrapper for OpenAL Soft + * + * Copyright (c) 2014-2015 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace OpenAL +{ + public static class EFX + { + private const string nativeLibName = "soft_oal.dll"; + + /* typedef int ALenum; */ + public const int AL_METERS_PER_UNIT = 0x20004; + + public const int AL_DIRECT_FILTER = 0x20005; + public const int AL_AUXILIARY_SEND_FILTER = 0x20006; + public const int AL_AIR_ABSORPTION_FACTOR = 0x20007; + public const int AL_ROOM_ROLLOFF_FACTOR = 0x20008; + public const int AL_CONE_OUTER_GAINHF = 0x20009; + public const int AL_DIRECT_FILTER_GAINHF_AUTO = 0x2000A; + public const int AL_AUXILIARY_SEND_FILTER_GAIN_AUTO = 0x2000B; + public const int AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO = 0x2000C; + + public const int AL_REVERB_DENSITY = 0x0001; + public const int AL_REVERB_DIFFUSION = 0x0002; + public const int AL_REVERB_GAIN = 0x0003; + public const int AL_REVERB_GAINHF = 0x0004; + public const int AL_REVERB_DECAY_TIME = 0x0005; + public const int AL_REVERB_DECAY_HFRATIO = 0x0006; + public const int AL_REVERB_REFLECTIONS_GAIN = 0x0007; + public const int AL_REVERB_REFLECTIONS_DELAY = 0x0008; + public const int AL_REVERB_LATE_REVERB_GAIN = 0x0009; + public const int AL_REVERB_LATE_REVERB_DELAY = 0x000A; + public const int AL_REVERB_AIR_ABSORPTION_FACTOR = 0x000B; + public const int AL_REVERB_ROOM_ROLLOFF_FACTOR = 0x000C; + public const int AL_REVERB_DECAY_HFLIMIT = 0x000D; + + public const int AL_EAXREVERB_DENSITY = 0x0001; + public const int AL_EAXREVERB_DIFFUSION = 0x0002; + public const int AL_EAXREVERB_GAIN = 0x0003; + public const int AL_EAXREVERB_GAINHF = 0x0004; + public const int AL_EAXREVERB_GAINLF = 0x0005; + public const int AL_EAXREVERB_DECAY_TIME = 0x0006; + public const int AL_EAXREVERB_DECAY_HFRATIO = 0x0007; + public const int AL_EAXREVERB_DECAY_LFRATIO = 0x0008; + public const int AL_EAXREVERB_REFLECTIONS_GAIN = 0x0009; + public const int AL_EAXREVERB_REFLECTIONS_DELAY = 0x000A; + public const int AL_EAXREVERB_REFLECTIONS_PAN = 0x000B; + public const int AL_EAXREVERB_LATE_REVERB_GAIN = 0x000C; + public const int AL_EAXREVERB_LATE_REVERB_DELAY = 0x000D; + public const int AL_EAXREVERB_LATE_REVERT_PAN = 0x000E; + public const int AL_EAXREVERB_ECHO_TIME = 0x000F; + public const int AL_EAXREVERB_ECHO_DEPTH = 0x0010; + public const int AL_EAXREVERB_MODULATION_TIME = 0x0011; + public const int AL_EAXREVERB_MODULATION_DEPTH = 0x0012; + public const int AL_EAXREVERB_AIR_ABSORPTION_GAINHF = 0x0013; + public const int AL_EAXREVERB_HFREFERENCE = 0x0014; + public const int AL_EAXREVERB_LFREFERENCE = 0x0015; + public const int AL_EAXREVERB_ROOM_ROLLOFF_FACTOR = 0x0016; + public const int AL_EAXREVERB_DECAY_HFLIMIT = 0x0017; + + public const int AL_CHORUS_WAVEFORM = 0x0001; + public const int AL_CHORUS_PHASE = 0x0002; + public const int AL_CHORUS_RATE = 0x0003; + public const int AL_CHORUS_DEPTH = 0x0004; + public const int AL_CHORUS_FEEDBACK = 0x0005; + public const int AL_CHORUS_DELAY = 0x0006; + + public const int AL_DISTORTION_EDGE = 0x0001; + public const int AL_DISTORTION_GAIN = 0x0002; + public const int AL_DISTORTION_LOWPASS_CUTOFF = 0x0003; + public const int AL_DISTORTION_EQCENTER = 0x0004; + public const int AL_DISTORTION_EQBANDWIDTH = 0x0005; + + public const int AL_ECHO_DELAY = 0x0001; + public const int AL_ECHO_LRDELAY = 0x0002; + public const int AL_ECHO_DAMPING = 0x0003; + public const int AL_ECHO_FEEDBACK = 0x0004; + public const int AL_ECHO_SPREAD = 0x0005; + + public const int AL_FLANGER_WAVEFORM = 0x0001; + public const int AL_FLANGER_PHASE = 0x0002; + public const int AL_FLANGER_RATE = 0x0003; + public const int AL_FLANGER_DEPTH = 0x0004; + public const int AL_FLANGER_FEEDBACK = 0x0005; + public const int AL_FLANGER_DELAY = 0x0006; + + public const int AL_FREQUENCY_SHIFTER_FREQUENCY = 0x0001; + public const int AL_FREQUENCY_SHIFTER_LEFT_DIRECTION = 0x0002; + public const int AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION = 0x0003; + + public const int AL_VOCAL_MORPHER_PHONEMEA = 0x0001; + public const int AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING = 0x0002; + public const int AL_VOCAL_MORPHER_PHONEMEB = 0x0003; + public const int AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING = 0x0004; + public const int AL_VOCAL_MORPHER_WAVEFORM = 0x0005; + public const int AL_VOCAL_MORPHER_RATE = 0x0006; + + public const int AL_PITCH_SHIFTER_COARSE_TUNE = 0x0001; + public const int AL_PITCH_SHIFTER_FINE_TUNE = 0x0002; + + public const int AL_RING_MODULATOR_FREQUENCY = 0x0001; + public const int AL_RING_MODULATOR_HIGHPASS_CUTOFF = 0x0002; + public const int AL_RING_MODULATOR_WAVEFORM = 0x0003; + + public const int AL_AUTOWAH_ATTACK_TIME = 0x0001; + public const int AL_AUTOWAH_RELEASE_TIME = 0x0002; + public const int AL_AUTOWAH_RESONANCE = 0x0003; + public const int AL_AUTOWAH_PEAK_GAIN = 0x0004; + + public const int AL_COMPRESSOR_ONOFF = 0x0001; + + public const int AL_EQUALIZER_LOW_GAIN = 0x0001; + public const int AL_EQUALIZER_LOW_CUTOFF = 0x0002; + public const int AL_EQUALIZER_MID1_GAIN = 0x0003; + public const int AL_EQUALIZER_MID1_CENTER = 0x0004; + public const int AL_EQUALIZER_MID1_WIDTH = 0x0005; + public const int AL_EQUALIZER_MID2_GAIN = 0x0006; + public const int AL_EQUALIZER_MID2_CENTER = 0x0007; + public const int AL_EQUALIZER_MID2_WIDTH = 0x0008; + public const int AL_EQUALIZER_HIGH_GAIN = 0x0009; + public const int AL_EQUALIZER_HIGH_CUTOFF = 0x000A; + + public const int AL_EFFECT_FIRST_PARAMETER = 0x0000; + public const int AL_EFFECT_LAST_PARAMETER = 0x8000; + public const int AL_EFFECT_TYPE = 0x8001; + + public const int AL_EFFECT_NULL = 0x0000; + public const int AL_EFFECT_REVERB = 0x0001; + public const int AL_EFFECT_CHORUS = 0x0002; + public const int AL_EFFECT_DISTORTION = 0x0003; + public const int AL_EFFECT_ECHO = 0x0004; + public const int AL_EFFECT_FLANGER = 0x0005; + public const int AL_EFFECT_FREQUENCY_SHIFTER = 0x0006; + public const int AL_EFFECT_VOCAL_MORPHER = 0x0007; + public const int AL_EFFECT_PITCH_SHIFTER = 0x0008; + public const int AL_EFFECT_RING_MODULATOR = 0x0009; + public const int AL_EFFECT_AUTOWAH = 0x000A; + public const int AL_EFFECT_COMPRESSOR = 0x000B; + public const int AL_EFFECT_EQUALIZER = 0x000C; + public const int AL_EFFECT_EAXREVERB = 0x8000; + + public const int AL_EFFECTSLOT_EFFECT = 0x0001; + public const int AL_EFFECTSLOT_GAIN = 0x0002; + public const int AL_EFFECTSLOT_AUXILIARY_SEND_AUTO = 0x0003; + + public const int AL_EFFECTSLOT_NULL = 0x0000; + + public const int AL_LOWPASS_GAIN = 0x0001; + public const int AL_LOWPASS_GAINHF = 0x0002; + + public const int AL_HIGHPASS_GAIN = 0x0001; + public const int AL_HIGHPASS_GAINLF = 0x0002; + + public const int AL_BANDPASS_GAIN = 0x0001; + public const int AL_BANDPASS_GAINLF = 0x0002; + public const int AL_BANDPASS_GAINHF = 0x0003; + + public const int AL_FILTER_FIRST_PARAMETER = 0x0000; + public const int AL_FILTER_LAST_PARAMETER = 0x8000; + public const int AL_FILTER_TYPE = 0x8001; + + public const int AL_FILTER_NULL = 0x0000; + public const int AL_FILTER_LOWPASS = 0x0001; + public const int AL_FILTER_HIGHPASS = 0x0002; + public const int AL_FILTER_BANDPASS = 0x0003; + + /* TODO: EFX Default Value Constants! */ + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGenEffects(int n, uint[] effects); + + /* n refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGenEffects(int n, out uint effects); + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDeleteEffects(int n, uint[] effects); + + /* n refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDeleteEffects(int n, ref uint effects); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alIsEffect(uint effect); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alEffecti( + uint effect, + int param, + int iValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alEffectiv( + uint effect, + int param, + int[] iValues + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alEffectf( + uint effect, + int param, + float flValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alEffectfv( + uint effect, + int param, + float[] flValues + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetEffecti( + uint effect, + int param, + out int piValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetEffectiv( + uint effect, + int param, + int[] piValues + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetEffectf( + uint effect, + int param, + out float pflValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetEffectfv( + uint effect, + int param, + float[] pflValues + ); + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGenFilters(int n, uint[] filters); + + /* n refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGenFilters(int n, out uint filters); + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDeleteFilters(int n, uint[] filters); + + /* n refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDeleteFilters(int n, ref uint filters); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alIsFilter(uint filter); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alFilteri( + uint filter, + int param, + int iValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alFilteriv( + uint filter, + int param, + int[] iValues + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alFilterf( + uint filter, + int param, + float flValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alFilterfv( + uint filter, + int param, + float[] flValues + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetFilteri( + uint filter, + int param, + out int piValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetFilteriv( + uint filter, + int param, + int[] piValues + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetFilterf( + uint filter, + int param, + out float pflValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetFilterfv( + uint filter, + int param, + float[] pflValues + ); + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGenAuxiliaryEffectSlots( + int n, + uint[] effectslots + ); + + /* n refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGenAuxiliaryEffectSlots( + int n, + out uint effectslots + ); + + /* n refers to an ALsizei */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDeleteAuxiliaryEffectSlots( + int n, + uint[] effectslots + ); + + /* n refers to an ALsizei. Overload provided to avoid uint[] alloc. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alDeleteAuxiliaryEffectSlots( + int n, + ref uint effectslots + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool alIsAuxiliaryEffectSlot(uint effectslot); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alAuxiliaryEffectSloti( + uint effectslot, + int param, + int iValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alAuxiliaryEffectSlotiv( + uint effectslot, + int param, + int[] iValues + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alAuxiliaryEffectSlotf( + uint effectslot, + int param, + float flValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alAuxiliaryEffectSlotfv( + uint effectslot, + int param, + float[] flValues + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetAuxiliaryEffectSloti( + uint effectslot, + int param, + out int piValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetAuxiliaryEffectSlotiv( + uint effectslot, + int param, + int[] piValues + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetAuxiliaryEffectSlotf( + uint effectslot, + int param, + out float pflValue + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void alGetAuxiliaryEffectSlotfv( + uint effectslot, + int param, + float[] pflValues + ); + } +} diff --git a/FNA/lib/SDL2-CS/.gitignore b/FNA/lib/SDL2-CS/.gitignore new file mode 100644 index 0000000..ddb8b56 --- /dev/null +++ b/FNA/lib/SDL2-CS/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +*.pidb +*.userprefs +*.suo diff --git a/FNA/lib/SDL2-CS/LICENSE b/FNA/lib/SDL2-CS/LICENSE new file mode 100644 index 0000000..b49c928 --- /dev/null +++ b/FNA/lib/SDL2-CS/LICENSE @@ -0,0 +1,25 @@ +/* SDL2# - C# Wrapper for SDL2 + * + * Copyright (c) 2013-2016 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ diff --git a/FNA/lib/SDL2-CS/Makefile b/FNA/lib/SDL2-CS/Makefile new file mode 100644 index 0000000..6561871 --- /dev/null +++ b/FNA/lib/SDL2-CS/Makefile @@ -0,0 +1,32 @@ +# Makefile for SDL2# +# Written by Ethan "flibitijibibo" Lee + +# Source Lists +SRC = \ + src/SDL2.cs \ + src/SDL2_image.cs \ + src/SDL2_mixer.cs \ + src/SDL2_ttf.cs + +# Targets + +debug: clean-debug + mkdir -p bin/Debug + cp SDL2-CS.dll.config bin/Debug + dmcs /unsafe -debug -out:bin/Debug/SDL2-CS.dll -target:library $(SRC) + +clean-debug: + rm -rf bin/Debug + +release: clean-release + mkdir -p bin/Release + cp SDL2-CS.dll.config bin/Release + dmcs /unsafe -optimize -out:bin/Release/SDL2-CS.dll -target:library $(SRC) + +clean-release: + rm -rf bin/Release + +clean: clean-debug clean-release + rm -rf bin + +all: debug release diff --git a/FNA/lib/SDL2-CS/README b/FNA/lib/SDL2-CS/README new file mode 100644 index 0000000..05e5d75 --- /dev/null +++ b/FNA/lib/SDL2-CS/README @@ -0,0 +1,48 @@ +This is SDL2#, a C# wrapper for SDL2. + +Project Website: https://github.com/flibitijibibo/SDL2-CS + +License +------- +SDL2 and SDL2# are released under the zlib license. See LICENSE for details. + +About SDL2 +---------- +For more information about SDL2, visit the SDL wiki: + +http://wiki.libsdl.org/moin.fcg/FrontPage + +About the C# Wrapper +-------------------- +The C# wrapper was written to be used for FNA's platform support. However, this +is written in a way that can be used for any general C# application. + +The wrapper provides bindings for the following libraries: +- SDL2 +- SDL2_image +- SDL2_mixer +- SDL2_ttf + +Note that SDL2# will not provide every single SDL2 function. This is due to +limitations in the C# language that would cause major conflicts with the native +SDL2 library and its extensions. + +SDL2# is a pure port of the C headers. The naming schemes for this library will +be exactly as they are done in the C library, with little-to-no concern for +"appropriate" C# style. The namespace indicates that this is SDL2, the class +names will indicate which library file the function/type/value exists in, and +everything else will be as close to the C version as technically possible. + +About the Visual Studio Debugger +-------------------------------- +When running C# applications under the Visual Studio debugger, native code that +names threads with the 0x406D1388 exception will silently exit. To prevent this +exception from being thrown by SDL, add this line before your SDL_Init call: + +SDL.SDL_SetHint(SDL.SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1"); + +Roadmap +------- +To see the current roadmap for SDL2#, visit the GitHub issues page: + +https://github.com/flibitijibibo/SDL2-CS/issues diff --git a/FNA/lib/SDL2-CS/SDL2-CS.Core.csproj b/FNA/lib/SDL2-CS/SDL2-CS.Core.csproj new file mode 100644 index 0000000..6d6746a --- /dev/null +++ b/FNA/lib/SDL2-CS/SDL2-CS.Core.csproj @@ -0,0 +1,24 @@ + + + netstandard2.0 + x64 + + + false + SDL2-CS + SDL2 + true + false + + + + + + + + + + Always + + + diff --git a/FNA/lib/SDL2-CS/SDL2-CS.csproj b/FNA/lib/SDL2-CS/SDL2-CS.csproj new file mode 100644 index 0000000..67d5e29 --- /dev/null +++ b/FNA/lib/SDL2-CS/SDL2-CS.csproj @@ -0,0 +1,92 @@ + + + + Debug + x86 + 9.0.21022 + 2.0 + {85480198-8711-4355-830E-72FD794AD3F6} + Library + SDL2 + SDL2-CS + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + x86 + false + true + + + none + false + bin\Release + prompt + 4 + x86 + false + true + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + true + + + none + false + bin\Release + prompt + 4 + true + false + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + x64 + true + false + + + none + false + bin\Release + prompt + 4 + x64 + false + true + + + + + + + + + + + Always + + + + + + diff --git a/FNA/lib/SDL2-CS/SDL2-CS.dll.config b/FNA/lib/SDL2-CS/SDL2-CS.dll.config new file mode 100644 index 0000000..deb8bc6 --- /dev/null +++ b/FNA/lib/SDL2-CS/SDL2-CS.dll.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/FNA/lib/SDL2-CS/SDL2-CS.sln b/FNA/lib/SDL2-CS/SDL2-CS.sln new file mode 100644 index 0000000..7040003 --- /dev/null +++ b/FNA/lib/SDL2-CS/SDL2-CS.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDL2-CS", "SDL2-CS.csproj", "{85480198-8711-4355-830E-72FD794AD3F6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {85480198-8711-4355-830E-72FD794AD3F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85480198-8711-4355-830E-72FD794AD3F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85480198-8711-4355-830E-72FD794AD3F6}.Debug|x64.ActiveCfg = Debug|x64 + {85480198-8711-4355-830E-72FD794AD3F6}.Debug|x64.Build.0 = Debug|x64 + {85480198-8711-4355-830E-72FD794AD3F6}.Debug|x86.ActiveCfg = Debug|x86 + {85480198-8711-4355-830E-72FD794AD3F6}.Debug|x86.Build.0 = Debug|x86 + {85480198-8711-4355-830E-72FD794AD3F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85480198-8711-4355-830E-72FD794AD3F6}.Release|Any CPU.Build.0 = Release|Any CPU + {85480198-8711-4355-830E-72FD794AD3F6}.Release|x64.ActiveCfg = Release|x64 + {85480198-8711-4355-830E-72FD794AD3F6}.Release|x64.Build.0 = Release|x64 + {85480198-8711-4355-830E-72FD794AD3F6}.Release|x86.ActiveCfg = Release|x86 + {85480198-8711-4355-830E-72FD794AD3F6}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = SDL2-CS.csproj + EndGlobalSection +EndGlobal diff --git a/FNA/lib/SDL2-CS/src/SDL2.cs b/FNA/lib/SDL2-CS/src/SDL2.cs new file mode 100644 index 0000000..cde4e27 --- /dev/null +++ b/FNA/lib/SDL2-CS/src/SDL2.cs @@ -0,0 +1,6504 @@ +#region License +/* SDL2# - C# Wrapper for SDL2 + * + * Copyright (c) 2013-2016 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace SDL2 +{ + public static class SDL + { + #region SDL2# Variables + + private const string nativeLibName = "SDL2.dll"; + + #endregion + + #region UTF8 Marshaling + + internal static byte[] UTF8_ToNative(string s) + { + if (s == null) + { + return null; + } + + // Add a null terminator. That's kind of it... :/ + return System.Text.Encoding.UTF8.GetBytes(s + '\0'); + } + + internal static unsafe string UTF8_ToManaged(IntPtr s, bool freePtr = false) + { + if (s == IntPtr.Zero) + { + return null; + } + + /* We get to do strlen ourselves! */ + byte* ptr = (byte*) s; + while (*ptr != 0) + { + ptr++; + } + + /* TODO: This #ifdef is only here because the equivalent + * .NET 2.0 constructor appears to be less efficient? + * Here's the pretty version, maybe steal this instead: + * + string result = new string( + (sbyte*) s, // Also, why sbyte??? + 0, + (int) (ptr - (byte*) s), + System.Text.Encoding.UTF8 + ); + * See the CoreCLR source for more info. + * -flibit + */ +#if NETSTANDARD2_0 + /* Modern C# lets you just send the byte*, nice! */ + string result = System.Text.Encoding.UTF8.GetString( + (byte*) s, + (int) (ptr - (byte*) s) + ); +#else + /* Old C# requires an extra memcpy, bleh! */ + byte[] bytes = new byte[ptr - (byte*) s]; + Marshal.Copy(s, bytes, 0, bytes.Length); + string result = System.Text.Encoding.UTF8.GetString(bytes); +#endif + + /* Some SDL functions will malloc, we have to free! */ + if (freePtr) + { + SDL_free(s); + } + return result; + } + + #endregion + + #region SDL_stdinc.h + + public static uint SDL_FOURCC(byte A, byte B, byte C, byte D) + { + return (uint) (A | (B << 8) | (C << 16) | (D << 24)); + } + + public enum SDL_bool + { + SDL_FALSE = 0, + SDL_TRUE = 1 + } + + /* malloc/free are used by the marshaler! -flibit */ + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr SDL_malloc(IntPtr size); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void SDL_free(IntPtr memblock); + + #endregion + + #region SDL_rwops.h + + /* Note about SDL2# and Internal RWops: + * These functions are currently not supported for public use. + * They are only meant to be used internally in functions marked with + * the phrase "THIS IS AN RWops FUNCTION!" + */ + + /* IntPtr refers to an SDL_RWops* */ + [DllImport(nativeLibName, EntryPoint = "SDL_RWFromFile", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_RWFromFile( + byte[] file, + byte[] mode + ); + internal static IntPtr INTERNAL_SDL_RWFromFile( + string file, + string mode + ) { + return INTERNAL_SDL_RWFromFile( + UTF8_ToNative(file), + UTF8_ToNative(mode) + ); + } + + /* These are the public RWops functions. They should be used by + * functions marked with the phrase "THIS IS A PUBLIC RWops FUNCTION!" + */ + + /* mem refers to a void*, IntPtr to an SDL_RWops* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_RWFromMem(IntPtr mem, int size); + + #endregion + + #region SDL_main.h + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetMainReady(); + + /* This is used as a function pointer to a C main() function for SDL_WinRTRunApp() */ + public delegate int SDL_WinRT_mainFunction(int argc, IntPtr[] argv); + + /* Use this function with UWP to call your C# Main() function! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_WinRTRunApp( + SDL_WinRT_mainFunction mainFunction, + IntPtr reserved + ); + + #endregion + + #region SDL.h + + public const uint SDL_INIT_TIMER = 0x00000001; + public const uint SDL_INIT_AUDIO = 0x00000010; + public const uint SDL_INIT_VIDEO = 0x00000020; + public const uint SDL_INIT_JOYSTICK = 0x00000200; + public const uint SDL_INIT_HAPTIC = 0x00001000; + public const uint SDL_INIT_GAMECONTROLLER = 0x00002000; + public const uint SDL_INIT_NOPARACHUTE = 0x00100000; + public const uint SDL_INIT_EVERYTHING = ( + SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | + SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | + SDL_INIT_GAMECONTROLLER + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_Init(uint flags); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_InitSubSystem(uint flags); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_Quit(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_QuitSubSystem(uint flags); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern uint SDL_WasInit(uint flags); + + #endregion + + #region SDL_platform.h + + [DllImport(nativeLibName, EntryPoint = "SDL_GetPlatform", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetPlatform(); + public static string SDL_GetPlatform() + { + return UTF8_ToManaged(INTERNAL_SDL_GetPlatform()); + } + + #endregion + + #region SDL_hints.h + + public const string SDL_HINT_FRAMEBUFFER_ACCELERATION = + "SDL_FRAMEBUFFER_ACCELERATION"; + public const string SDL_HINT_RENDER_DRIVER = + "SDL_RENDER_DRIVER"; + public const string SDL_HINT_RENDER_OPENGL_SHADERS = + "SDL_RENDER_OPENGL_SHADERS"; + public const string SDL_HINT_RENDER_DIRECT3D_THREADSAFE = + "SDL_RENDER_DIRECT3D_THREADSAFE"; + public const string SDL_HINT_RENDER_VSYNC = + "SDL_RENDER_VSYNC"; + public const string SDL_HINT_VIDEO_X11_XVIDMODE = + "SDL_VIDEO_X11_XVIDMODE"; + public const string SDL_HINT_VIDEO_X11_XINERAMA = + "SDL_VIDEO_X11_XINERAMA"; + public const string SDL_HINT_VIDEO_X11_XRANDR = + "SDL_VIDEO_X11_XRANDR"; + public const string SDL_HINT_GRAB_KEYBOARD = + "SDL_GRAB_KEYBOARD"; + public const string SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS = + "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS"; + public const string SDL_HINT_IDLE_TIMER_DISABLED = + "SDL_IOS_IDLE_TIMER_DISABLED"; + public const string SDL_HINT_ORIENTATIONS = + "SDL_IOS_ORIENTATIONS"; + public const string SDL_HINT_XINPUT_ENABLED = + "SDL_XINPUT_ENABLED"; + public const string SDL_HINT_GAMECONTROLLERCONFIG = + "SDL_GAMECONTROLLERCONFIG"; + public const string SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS = + "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS"; + public const string SDL_HINT_ALLOW_TOPMOST = + "SDL_ALLOW_TOPMOST"; + public const string SDL_HINT_TIMER_RESOLUTION = + "SDL_TIMER_RESOLUTION"; + public const string SDL_HINT_RENDER_SCALE_QUALITY = + "SDL_RENDER_SCALE_QUALITY"; + + /* Only available in SDL 2.0.1 or higher */ + public const string SDL_HINT_VIDEO_HIGHDPI_DISABLED = + "SDL_VIDEO_HIGHDPI_DISABLED"; + + /* Only available in SDL 2.0.2 or higher */ + public const string SDL_HINT_CTRL_CLICK_EMULATE_RIGHT_CLICK = + "SDL_CTRL_CLICK_EMULATE_RIGHT_CLICK"; + public const string SDL_HINT_VIDEO_WIN_D3DCOMPILER = + "SDL_VIDEO_WIN_D3DCOMPILER"; + public const string SDL_HINT_MOUSE_RELATIVE_MODE_WARP = + "SDL_MOUSE_RELATIVE_MODE_WARP"; + public const string SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT = + "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"; + public const string SDL_HINT_VIDEO_ALLOW_SCREENSAVER = + "SDL_VIDEO_ALLOW_SCREENSAVER"; + public const string SDL_HINT_ACCELEROMETER_AS_JOYSTICK = + "SDL_ACCELEROMETER_AS_JOYSTICK"; + public const string SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES = + "SDL_VIDEO_MAC_FULLSCREEN_SPACES"; + + /* Only available in SDL 2.0.3 or higher */ + public const string SDL_HINT_WINRT_PRIVACY_POLICY_URL = + "SDL_WINRT_PRIVACY_POLICY_URL"; + public const string SDL_HINT_WINRT_PRIVACY_POLICY_LABEL = + "SDL_WINRT_PRIVACY_POLICY_LABEL"; + public const string SDL_HINT_WINRT_HANDLE_BACK_BUTTON = + "SDL_WINRT_HANDLE_BACK_BUTTON"; + + /* Only available in SDL 2.0.4 or higher */ + public const string SDL_HINT_NO_SIGNAL_HANDLERS = + "SDL_NO_SIGNAL_HANDLERS"; + public const string SDL_HINT_IME_INTERNAL_EDITING = + "SDL_IME_INTERNAL_EDITING"; + public const string SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH = + "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH"; + public const string SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT = + "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"; + public const string SDL_HINT_THREAD_STACK_SIZE = + "SDL_THREAD_STACK_SIZE"; + public const string SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN = + "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN"; + public const string SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP = + "SDL_WINDOWS_ENABLE_MESSAGELOOP"; + public const string SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 = + "SDL_WINDOWS_NO_CLOSE_ON_ALT_F4"; + public const string SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING = + "SDL_XINPUT_USE_OLD_JOYSTICK_MAPPING"; + public const string SDL_HINT_MAC_BACKGROUND_APP = + "SDL_MAC_BACKGROUND_APP"; + public const string SDL_HINT_VIDEO_X11_NET_WM_PING = + "SDL_VIDEO_X11_NET_WM_PING"; + public const string SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION = + "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"; + public const string SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION = + "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"; + + /* Only available in 2.0.5 or higher */ + public const string SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH = + "SDL_MOUSE_FOCUS_CLICKTHROUGH"; + public const string SDL_HINT_BMP_SAVE_LEGACY_FORMAT = + "SDL_BMP_SAVE_LEGACY_FORMAT"; + public const string SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING = + "SDL_WINDOWS_DISABLE_THREAD_NAMING"; + public const string SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION = + "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION"; + + /* Only available in 2.0.6 or higher */ + public const string SDL_HINT_AUDIO_RESAMPLING_MODE = + "SDL_AUDIO_RESAMPLING_MODE"; + public const string SDL_HINT_RENDER_LOGICAL_SIZE_MODE = + "SDL_RENDER_LOGICAL_SIZE_MODE"; + public const string SDL_HINT_MOUSE_NORMAL_SPEED_SCALE = + "SDL_MOUSE_NORMAL_SPEED_SCALE"; + public const string SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE = + "SDL_MOUSE_RELATIVE_SPEED_SCALE"; + public const string SDL_HINT_TOUCH_MOUSE_EVENTS = + "SDL_TOUCH_MOUSE_EVENTS"; + public const string SDL_HINT_WINDOWS_INTRESOURCE_ICON = + "SDL_WINDOWS_INTRESOURCE_ICON"; + public const string SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL = + "SDL_WINDOWS_INTRESOURCE_ICON_SMALL"; + + public enum SDL_HintPriority + { + SDL_HINT_DEFAULT, + SDL_HINT_NORMAL, + SDL_HINT_OVERRIDE + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_ClearHints(); + + [DllImport(nativeLibName, EntryPoint = "SDL_GetHint", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetHint(byte[] name); + public static string SDL_GetHint(string name) + { + return UTF8_ToManaged( + INTERNAL_SDL_GetHint( + UTF8_ToNative(name) + ) + ); + } + + [DllImport(nativeLibName, EntryPoint = "SDL_SetHint", CallingConvention = CallingConvention.Cdecl)] + private static extern SDL_bool INTERNAL_SDL_SetHint( + byte[] name, + byte[] value + ); + public static SDL_bool SDL_SetHint(string name, string value) + { + return INTERNAL_SDL_SetHint( + UTF8_ToNative(name), + UTF8_ToNative(value) + ); + } + + [DllImport(nativeLibName, EntryPoint = "SDL_SetHintWithPriority", CallingConvention = CallingConvention.Cdecl)] + private static extern SDL_bool INTERNAL_SDL_SetHintWithPriority( + byte[] name, + byte[] value, + SDL_HintPriority priority + ); + public static SDL_bool SDL_SetHintWithPriority( + string name, + string value, + SDL_HintPriority priority + ) { + return INTERNAL_SDL_SetHintWithPriority( + UTF8_ToNative(name), + UTF8_ToNative(value), + priority + ); + } + + /* Available in 2.0.5 or higher */ + [DllImport(nativeLibName, EntryPoint = "SDL_GetHintBoolean", CallingConvention = CallingConvention.Cdecl)] + private static extern SDL_bool INTERNAL_SDL_GetHintBoolean( + byte[] name, + SDL_bool default_value + ); + public static SDL_bool SDL_GetHintBoolean( + string name, + SDL_bool default_value + ) { + return INTERNAL_SDL_GetHintBoolean( + UTF8_ToNative(name), + default_value + ); + } + + #endregion + + #region SDL_error.h + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_ClearError(); + + [DllImport(nativeLibName, EntryPoint = "SDL_GetError", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetError(); + public static string SDL_GetError() + { + return UTF8_ToManaged(INTERNAL_SDL_GetError()); + } + + /* Use string.Format for arglists */ + [DllImport(nativeLibName, EntryPoint = "SDL_SetError", CallingConvention = CallingConvention.Cdecl)] + private static extern void INTERNAL_SDL_SetError(byte[] fmtAndArglist); + public static void SDL_SetError(string fmtAndArglist) + { + INTERNAL_SDL_SetError( + UTF8_ToNative(fmtAndArglist) + ); + } + + #endregion + + #region SDL_log.h + + /* Begin nameless enum SDL_LOG_CATEGORY */ + public const int SDL_LOG_CATEGORY_APPLICATION = 0; + public const int SDL_LOG_CATEGORY_ERROR = 1; + public const int SDL_LOG_CATEGORY_ASSERT = 2; + public const int SDL_LOG_CATEGORY_SYSTEM = 3; + public const int SDL_LOG_CATEGORY_AUDIO = 4; + public const int SDL_LOG_CATEGORY_VIDEO = 5; + public const int SDL_LOG_CATEGORY_RENDER = 6; + public const int SDL_LOG_CATEGORY_INPUT = 7; + public const int SDL_LOG_CATEGORY_TEST = 8; + + /* Reserved for future SDL library use */ + public const int SDL_LOG_CATEGORY_RESERVED1 = 9; + public const int SDL_LOG_CATEGORY_RESERVED2 = 10; + public const int SDL_LOG_CATEGORY_RESERVED3 = 11; + public const int SDL_LOG_CATEGORY_RESERVED4 = 12; + public const int SDL_LOG_CATEGORY_RESERVED5 = 13; + public const int SDL_LOG_CATEGORY_RESERVED6 = 14; + public const int SDL_LOG_CATEGORY_RESERVED7 = 15; + public const int SDL_LOG_CATEGORY_RESERVED8 = 16; + public const int SDL_LOG_CATEGORY_RESERVED9 = 17; + public const int SDL_LOG_CATEGORY_RESERVED10 = 18; + + /* Beyond this point is reserved for application use, e.g. + enum { + LOG_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, + LOG_CATEGORY_AWESOME2, + LOG_CATEGORY_AWESOME3, + ... + }; + */ + public const int SDL_LOG_CATEGORY_CUSTOM = 19; + /* End nameless enum SDL_LOG_CATEGORY */ + + public enum SDL_LogPriority + { + SDL_LOG_PRIORITY_VERBOSE = 1, + SDL_LOG_PRIORITY_DEBUG, + SDL_LOG_PRIORITY_INFO, + SDL_LOG_PRIORITY_WARN, + SDL_LOG_PRIORITY_ERROR, + SDL_LOG_PRIORITY_CRITICAL, + SDL_NUM_LOG_PRIORITIES + } + + /* userdata refers to a void*, message to a const char* */ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void SDL_LogOutputFunction( + IntPtr userdata, + int category, + SDL_LogPriority priority, + IntPtr message + ); + + /* Use string.Format for arglists */ + [DllImport(nativeLibName, EntryPoint = "SDL_Log", CallingConvention = CallingConvention.Cdecl)] + private static extern void INTERNAL_SDL_Log(byte[] fmtAndArglist); + public static void SDL_Log(string fmtAndArglist) + { + INTERNAL_SDL_Log( + UTF8_ToNative(fmtAndArglist) + ); + } + + /* Use string.Format for arglists */ + [DllImport(nativeLibName, EntryPoint = "SDL_LogVerbose", CallingConvention = CallingConvention.Cdecl)] + private static extern void INTERNAL_SDL_LogVerbose( + int category, + byte[] fmtAndArglist + ); + public static void SDL_LogVerbose( + int category, + string fmtAndArglist + ) { + INTERNAL_SDL_LogVerbose( + category, + UTF8_ToNative(fmtAndArglist) + ); + } + + /* Use string.Format for arglists */ + [DllImport(nativeLibName, EntryPoint = "SDL_LogDebug", CallingConvention = CallingConvention.Cdecl)] + private static extern void INTERNAL_SDL_LogDebug( + int category, + byte[] fmtAndArglist + ); + public static void SDL_LogDebug( + int category, + string fmtAndArglist + ) { + INTERNAL_SDL_LogDebug( + category, + UTF8_ToNative(fmtAndArglist) + ); + } + + /* Use string.Format for arglists */ + [DllImport(nativeLibName, EntryPoint = "SDL_LogInfo", CallingConvention = CallingConvention.Cdecl)] + private static extern void INTERNAL_SDL_LogInfo( + int category, + byte[] fmtAndArglist + ); + public static void SDL_LogInfo( + int category, + string fmtAndArglist + ) { + INTERNAL_SDL_LogInfo( + category, + UTF8_ToNative(fmtAndArglist) + ); + } + + /* Use string.Format for arglists */ + [DllImport(nativeLibName, EntryPoint = "SDL_LogWarn", CallingConvention = CallingConvention.Cdecl)] + private static extern void INTERNAL_SDL_LogWarn( + int category, + byte[] fmtAndArglist + ); + public static void SDL_LogWarn( + int category, + string fmtAndArglist + ) { + INTERNAL_SDL_LogWarn( + category, + UTF8_ToNative(fmtAndArglist) + ); + } + + /* Use string.Format for arglists */ + [DllImport(nativeLibName, EntryPoint = "SDL_LogError", CallingConvention = CallingConvention.Cdecl)] + private static extern void INTERNAL_SDL_LogError( + int category, + byte[] fmtAndArglist + ); + public static void SDL_LogError( + int category, + string fmtAndArglist + ) { + INTERNAL_SDL_LogError( + category, + UTF8_ToNative(fmtAndArglist) + ); + } + + /* Use string.Format for arglists */ + [DllImport(nativeLibName, EntryPoint = "SDL_LogCritical", CallingConvention = CallingConvention.Cdecl)] + private static extern void INTERNAL_SDL_LogCritical( + int category, + byte[] fmtAndArglist + ); + public static void SDL_LogCritical( + int category, + string fmtAndArglist + ) { + INTERNAL_SDL_LogCritical( + category, + UTF8_ToNative(fmtAndArglist) + ); + } + + /* Use string.Format for arglists */ + [DllImport(nativeLibName, EntryPoint = "SDL_LogMessage", CallingConvention = CallingConvention.Cdecl)] + private static extern void INTERNAL_SDL_LogMessage( + int category, + SDL_LogPriority priority, + byte[] fmtAndArglist + ); + public static void SDL_LogMessage( + int category, + SDL_LogPriority priority, + string fmtAndArglist + ) { + INTERNAL_SDL_LogMessage( + category, + priority, + UTF8_ToNative(fmtAndArglist) + ); + } + + /* Use string.Format for arglists */ + [DllImport(nativeLibName, EntryPoint = "SDL_LogMessageV", CallingConvention = CallingConvention.Cdecl)] + private static extern void INTERNAL_SDL_LogMessageV( + int category, + SDL_LogPriority priority, + byte[] fmtAndArglist + ); + public static void SDL_LogMessageV( + int category, + SDL_LogPriority priority, + string fmtAndArglist + ) { + INTERNAL_SDL_LogMessageV( + category, + priority, + UTF8_ToNative(fmtAndArglist) + ); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_LogPriority SDL_LogGetPriority( + int category + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_LogSetPriority( + int category, + SDL_LogPriority priority + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_LogSetAllPriority( + SDL_LogPriority priority + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_LogResetPriorities(); + + /* userdata refers to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + private static extern void SDL_LogGetOutputFunction( + out IntPtr callback, + out IntPtr userdata + ); + public static void SDL_LogGetOutputFunction( + out SDL_LogOutputFunction callback, + out IntPtr userdata + ) { + IntPtr result = IntPtr.Zero; + SDL_LogGetOutputFunction( + out result, + out userdata + ); + if (result != IntPtr.Zero) + { + callback = (SDL_LogOutputFunction) Marshal.GetDelegateForFunctionPointer( + result, + typeof(SDL_LogOutputFunction) + ); + } + else + { + callback = null; + } + } + + /* userdata refers to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_LogSetOutputFunction( + SDL_LogOutputFunction callback, + IntPtr userdata + ); + + #endregion + + #region SDL_messagebox.h + + [Flags] + public enum SDL_MessageBoxFlags : uint + { + SDL_MESSAGEBOX_ERROR = 0x00000010, + SDL_MESSAGEBOX_WARNING = 0x00000020, + SDL_MESSAGEBOX_INFORMATION = 0x00000040 + } + + [Flags] + public enum SDL_MessageBoxButtonFlags : uint + { + SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, + SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 + } + + [StructLayout(LayoutKind.Sequential)] + private struct INTERNAL_SDL_MessageBoxButtonData + { + public SDL_MessageBoxButtonFlags flags; + public int buttonid; + public IntPtr text; /* The UTF-8 button text */ + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_MessageBoxButtonData + { + public SDL_MessageBoxButtonFlags flags; + public int buttonid; + public string text; /* The UTF-8 button text */ + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_MessageBoxColor + { + public byte r, g, b; + } + + public enum SDL_MessageBoxColorType + { + SDL_MESSAGEBOX_COLOR_BACKGROUND, + SDL_MESSAGEBOX_COLOR_TEXT, + SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, + SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, + SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, + SDL_MESSAGEBOX_COLOR_MAX + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_MessageBoxColorScheme + { + [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = (int)SDL_MessageBoxColorType.SDL_MESSAGEBOX_COLOR_MAX)] + public SDL_MessageBoxColor[] colors; + } + + [StructLayout(LayoutKind.Sequential)] + private struct INTERNAL_SDL_MessageBoxData + { + public SDL_MessageBoxFlags flags; + public IntPtr window; /* Parent window, can be NULL */ + public IntPtr title; /* UTF-8 title */ + public IntPtr message; /* UTF-8 message text */ + public int numbuttons; + public IntPtr buttons; + public IntPtr colorScheme; /* Can be NULL to use system settings */ + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_MessageBoxData + { + public SDL_MessageBoxFlags flags; + public IntPtr window; /* Parent window, can be NULL */ + public string title; /* UTF-8 title */ + public string message; /* UTF-8 message text */ + public int numbuttons; + public SDL_MessageBoxButtonData[] buttons; + public SDL_MessageBoxColorScheme? colorScheme; /* Can be NULL to use system settings */ + } + + [DllImport(nativeLibName, EntryPoint = "SDL_ShowMessageBox", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_SDL_ShowMessageBox([In()] ref INTERNAL_SDL_MessageBoxData messageboxdata, out int buttonid); + + /* Ripped from Jameson's LpUtf8StrMarshaler */ + private static IntPtr INTERNAL_AllocUTF8(string str) + { + if (string.IsNullOrEmpty(str)) + { + return IntPtr.Zero; + } + byte[] bytes = System.Text.Encoding.UTF8.GetBytes(str + '\0'); + IntPtr mem = SDL.SDL_malloc((IntPtr) bytes.Length); + Marshal.Copy(bytes, 0, mem, bytes.Length); + return mem; + } + + public static unsafe int SDL_ShowMessageBox([In()] ref SDL_MessageBoxData messageboxdata, out int buttonid) + { + var data = new INTERNAL_SDL_MessageBoxData() + { + flags = messageboxdata.flags, + window = messageboxdata.window, + title = INTERNAL_AllocUTF8(messageboxdata.title), + message = INTERNAL_AllocUTF8(messageboxdata.message), + numbuttons = messageboxdata.numbuttons, + }; + + var buttons = new INTERNAL_SDL_MessageBoxButtonData[messageboxdata.numbuttons]; + for (int i = 0; i < messageboxdata.numbuttons; i++) + { + buttons[i] = new INTERNAL_SDL_MessageBoxButtonData() + { + flags = messageboxdata.buttons[i].flags, + buttonid = messageboxdata.buttons[i].buttonid, + text = INTERNAL_AllocUTF8(messageboxdata.buttons[i].text), + }; + } + + if (messageboxdata.colorScheme != null) + { + data.colorScheme = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SDL_MessageBoxColorScheme))); + Marshal.StructureToPtr(messageboxdata.colorScheme.Value, data.colorScheme, false); + } + + int result; + fixed (INTERNAL_SDL_MessageBoxButtonData* buttonsPtr = &buttons[0]) + { + data.buttons = (IntPtr)buttonsPtr; + result = INTERNAL_SDL_ShowMessageBox(ref data, out buttonid); + } + + Marshal.FreeHGlobal(data.colorScheme); + for (int i = 0; i < messageboxdata.numbuttons; i++) + { + SDL_free(buttons[i].text); + } + SDL_free(data.message); + SDL_free(data.title); + + return result; + } + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, EntryPoint = "SDL_ShowSimpleMessageBox", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_SDL_ShowSimpleMessageBox( + SDL_MessageBoxFlags flags, + byte[] title, + byte[] message, + IntPtr window + ); + public static int SDL_ShowSimpleMessageBox( + SDL_MessageBoxFlags flags, + string title, + string message, + IntPtr window + ) { + return INTERNAL_SDL_ShowSimpleMessageBox( + flags, + UTF8_ToNative(title), + UTF8_ToNative(message), + window + ); + } + + #endregion + + #region SDL_version.h, SDL_revision.h + + /* Similar to the headers, this is the version we're expecting to be + * running with. You will likely want to check this somewhere in your + * program! + */ + public const int SDL_MAJOR_VERSION = 2; + public const int SDL_MINOR_VERSION = 0; + public const int SDL_PATCHLEVEL = 8; + + public static readonly int SDL_COMPILEDVERSION = SDL_VERSIONNUM( + SDL_MAJOR_VERSION, + SDL_MINOR_VERSION, + SDL_PATCHLEVEL + ); + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_version + { + public byte major; + public byte minor; + public byte patch; + } + + public static void SDL_VERSION(out SDL_version x) + { + x.major = SDL_MAJOR_VERSION; + x.minor = SDL_MINOR_VERSION; + x.patch = SDL_PATCHLEVEL; + } + + public static int SDL_VERSIONNUM(int X, int Y, int Z) + { + return (X * 1000) + (Y * 100) + Z; + } + + public static bool SDL_VERSION_ATLEAST(int X, int Y, int Z) + { + return (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GetVersion(out SDL_version ver); + + [DllImport(nativeLibName, EntryPoint = "SDL_GetRevision", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetRevision(); + public static string SDL_GetRevision() + { + return UTF8_ToManaged(INTERNAL_SDL_GetRevision()); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetRevisionNumber(); + + #endregion + + #region SDL_video.h + + public enum SDL_GLattr + { + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_RETAINED_BACKING, + SDL_GL_CONTEXT_MAJOR_VERSION, + SDL_GL_CONTEXT_MINOR_VERSION, + SDL_GL_CONTEXT_EGL, + SDL_GL_CONTEXT_FLAGS, + SDL_GL_CONTEXT_PROFILE_MASK, + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, + SDL_GL_CONTEXT_RELEASE_BEHAVIOR, + SDL_GL_CONTEXT_RESET_NOTIFICATION, /* Only available in 2.0.6 */ + SDL_GL_CONTEXT_NO_ERROR, /* Only available in 2.0.6 */ + } + + [Flags] + public enum SDL_GLprofile + { + SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, + SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, + SDL_GL_CONTEXT_PROFILE_ES = 0x0004 + } + + [Flags] + public enum SDL_GLcontext + { + SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001, + SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002, + SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004, + SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008 + } + + public enum SDL_WindowEventID : byte + { + SDL_WINDOWEVENT_NONE, + SDL_WINDOWEVENT_SHOWN, + SDL_WINDOWEVENT_HIDDEN, + SDL_WINDOWEVENT_EXPOSED, + SDL_WINDOWEVENT_MOVED, + SDL_WINDOWEVENT_RESIZED, + SDL_WINDOWEVENT_SIZE_CHANGED, + SDL_WINDOWEVENT_MINIMIZED, + SDL_WINDOWEVENT_MAXIMIZED, + SDL_WINDOWEVENT_RESTORED, + SDL_WINDOWEVENT_ENTER, + SDL_WINDOWEVENT_LEAVE, + SDL_WINDOWEVENT_FOCUS_GAINED, + SDL_WINDOWEVENT_FOCUS_LOST, + SDL_WINDOWEVENT_CLOSE, + /* Available in 2.0.5 or higher */ + SDL_WINDOWEVENT_TAKE_FOCUS, + SDL_WINDOWEVENT_HIT_TEST + } + + [Flags] + public enum SDL_WindowFlags : uint + { + SDL_WINDOW_FULLSCREEN = 0x00000001, + SDL_WINDOW_OPENGL = 0x00000002, + SDL_WINDOW_SHOWN = 0x00000004, + SDL_WINDOW_HIDDEN = 0x00000008, + SDL_WINDOW_BORDERLESS = 0x00000010, + SDL_WINDOW_RESIZABLE = 0x00000020, + SDL_WINDOW_MINIMIZED = 0x00000040, + SDL_WINDOW_MAXIMIZED = 0x00000080, + SDL_WINDOW_INPUT_GRABBED = 0x00000100, + SDL_WINDOW_INPUT_FOCUS = 0x00000200, + SDL_WINDOW_MOUSE_FOCUS = 0x00000400, + SDL_WINDOW_FULLSCREEN_DESKTOP = + (SDL_WINDOW_FULLSCREEN | 0x00001000), + SDL_WINDOW_FOREIGN = 0x00000800, + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /* Only available in 2.0.1 */ + SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /* Only available in 2.0.4 */ + SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /* Only available in 2.0.5 */ + SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /* Only available in 2.0.5 */ + SDL_WINDOW_UTILITY = 0x00020000, /* Only available in 2.0.5 */ + SDL_WINDOW_TOOLTIP = 0x00040000, /* Only available in 2.0.5 */ + SDL_WINDOW_POPUP_MENU = 0x00080000, /* Only available in 2.0.5 */ + SDL_WINDOW_VULKAN = 0x10000000, /* Only available in 2.0.6 */ + } + + /* Only available in 2.0.4 */ + public enum SDL_HitTestResult + { + SDL_HITTEST_NORMAL, /* Region is normal. No special properties. */ + SDL_HITTEST_DRAGGABLE, /* Region can drag entire window. */ + SDL_HITTEST_RESIZE_TOPLEFT, + SDL_HITTEST_RESIZE_TOP, + SDL_HITTEST_RESIZE_TOPRIGHT, + SDL_HITTEST_RESIZE_RIGHT, + SDL_HITTEST_RESIZE_BOTTOMRIGHT, + SDL_HITTEST_RESIZE_BOTTOM, + SDL_HITTEST_RESIZE_BOTTOMLEFT, + SDL_HITTEST_RESIZE_LEFT + } + + public const int SDL_WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000; + public const int SDL_WINDOWPOS_CENTERED_MASK = 0x2FFF0000; + public const int SDL_WINDOWPOS_UNDEFINED = 0x1FFF0000; + public const int SDL_WINDOWPOS_CENTERED = 0x2FFF0000; + + public static int SDL_WINDOWPOS_UNDEFINED_DISPLAY(int X) + { + return (SDL_WINDOWPOS_UNDEFINED_MASK | X); + } + + public static bool SDL_WINDOWPOS_ISUNDEFINED(int X) + { + return (X & 0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK; + } + + public static int SDL_WINDOWPOS_CENTERED_DISPLAY(int X) + { + return (SDL_WINDOWPOS_CENTERED_MASK | X); + } + + public static bool SDL_WINDOWPOS_ISCENTERED(int X) + { + return (X & 0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_DisplayMode + { + public uint format; + public int w; + public int h; + public int refresh_rate; + public IntPtr driverdata; // void* + } + + /* win refers to an SDL_Window*, area to a cosnt SDL_Point*, data to a void* */ + /* Only available in 2.0.4 */ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate SDL_HitTestResult SDL_HitTest(IntPtr win, IntPtr area, IntPtr data); + + /* IntPtr refers to an SDL_Window* */ + [DllImport(nativeLibName, EntryPoint = "SDL_CreateWindow", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_CreateWindow( + byte[] title, + int x, + int y, + int w, + int h, + SDL_WindowFlags flags + ); + public static IntPtr SDL_CreateWindow( + string title, + int x, + int y, + int w, + int h, + SDL_WindowFlags flags + ) { + return INTERNAL_SDL_CreateWindow( + UTF8_ToNative(title), + x, y, w, h, + flags + ); + } + + /* window refers to an SDL_Window*, renderer to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_CreateWindowAndRenderer( + int width, + int height, + SDL_WindowFlags window_flags, + out IntPtr window, + out IntPtr renderer + ); + + /* data refers to some native window type, IntPtr to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateWindowFrom(IntPtr data); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_DestroyWindow(IntPtr window); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_DisableScreenSaver(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_EnableScreenSaver(); + + /* IntPtr refers to an SDL_DisplayMode. Just use closest. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetClosestDisplayMode( + int displayIndex, + ref SDL_DisplayMode mode, + out SDL_DisplayMode closest + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetCurrentDisplayMode( + int displayIndex, + out SDL_DisplayMode mode + ); + + [DllImport(nativeLibName, EntryPoint = "SDL_GetCurrentVideoDriver", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetCurrentVideoDriver(); + public static string SDL_GetCurrentVideoDriver() + { + return UTF8_ToManaged(INTERNAL_SDL_GetCurrentVideoDriver()); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetDesktopDisplayMode( + int displayIndex, + out SDL_DisplayMode mode + ); + + [DllImport(nativeLibName, EntryPoint = "SDL_GetDisplayName", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetDisplayName(int index); + public static string SDL_GetDisplayName(int index) + { + return UTF8_ToManaged(INTERNAL_SDL_GetDisplayName(index)); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetDisplayBounds( + int displayIndex, + out SDL_Rect rect + ); + + /* This function is only available in 2.0.4 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetDisplayDPI( + int displayIndex, + out float ddpi, + out float hdpi, + out float vdpi + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetDisplayMode( + int displayIndex, + int modeIndex, + out SDL_DisplayMode mode + ); + + /* Available in 2.0.5 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetDisplayUsableBounds( + int displayIndex, + out SDL_Rect rect + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetNumDisplayModes( + int displayIndex + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetNumVideoDisplays(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetNumVideoDrivers(); + + [DllImport(nativeLibName, EntryPoint = "SDL_GetVideoDriver", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetVideoDriver( + int index + ); + public static string SDL_GetVideoDriver(int index) + { + return UTF8_ToManaged(INTERNAL_SDL_GetVideoDriver(index)); + } + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern float SDL_GetWindowBrightness( + IntPtr window + ); + + /* window refers to an SDL_Window* */ + /* Available in 2.0.5 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetWindowOpacity( + IntPtr window, + float opacity + ); + + /* window refers to an SDL_Window* */ + /* Available in 2.0.5 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetWindowOpacity( + IntPtr window, + out float out_opacity + ); + + /* modal_window and parent_window refer to an SDL_Window*s */ + /* Available in 2.0.5 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetWindowModalFor( + IntPtr modal_window, + IntPtr parent_window + ); + + /* window refers to an SDL_Window* */ + /* Available in 2.0.5 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetWindowInputFocus(IntPtr window); + + /* window refers to an SDL_Window*, IntPtr to a void* */ + [DllImport(nativeLibName, EntryPoint = "SDL_GetWindowData", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetWindowData( + IntPtr window, + byte[] name + ); + public static IntPtr SDL_GetWindowData( + IntPtr window, + string name + ) { + return INTERNAL_SDL_GetWindowData( + window, + UTF8_ToNative(name) + ); + } + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetWindowDisplayIndex( + IntPtr window + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetWindowDisplayMode( + IntPtr window, + out SDL_DisplayMode mode + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern uint SDL_GetWindowFlags(IntPtr window); + + /* IntPtr refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetWindowFromID(uint id); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetWindowGammaRamp( + IntPtr window, + [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] + ushort[] red, + [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] + ushort[] green, + [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] + ushort[] blue + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_GetWindowGrab(IntPtr window); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern uint SDL_GetWindowID(IntPtr window); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern uint SDL_GetWindowPixelFormat( + IntPtr window + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GetWindowMaximumSize( + IntPtr window, + out int max_w, + out int max_h + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GetWindowMinimumSize( + IntPtr window, + out int min_w, + out int min_h + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GetWindowPosition( + IntPtr window, + out int x, + out int y + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GetWindowSize( + IntPtr window, + out int w, + out int h + ); + + /* IntPtr refers to an SDL_Surface*, window to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetWindowSurface(IntPtr window); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, EntryPoint = "SDL_GetWindowTitle", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetWindowTitle( + IntPtr window + ); + public static string SDL_GetWindowTitle(IntPtr window) + { + return UTF8_ToManaged( + INTERNAL_SDL_GetWindowTitle(window) + ); + } + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GL_BindTexture( + IntPtr texture, + out float texw, + out float texh + ); + + /* IntPtr and window refer to an SDL_GLContext and SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GL_CreateContext(IntPtr window); + + /* context refers to an SDL_GLContext */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GL_DeleteContext(IntPtr context); + + /* IntPtr refers to a function pointer */ + [DllImport(nativeLibName, EntryPoint = "SDL_GL_GetProcAddress", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GL_GetProcAddress( + byte[] proc + ); + public static IntPtr SDL_GL_GetProcAddress(string proc) + { + return INTERNAL_SDL_GL_GetProcAddress( + UTF8_ToNative(proc) + ); + } + + /* IntPtr refers to a function pointer, proc to a const char* */ + [DllImport(nativeLibName, EntryPoint = "SDL_GL_GetProcAddress", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GL_GetProcAddress(IntPtr proc); + + [DllImport(nativeLibName, EntryPoint = "SDL_GL_ExtensionSupported", CallingConvention = CallingConvention.Cdecl)] + private static extern SDL_bool INTERNAL_SDL_GL_ExtensionSupported( + byte[] extension + ); + public static SDL_bool SDL_GL_ExtensionSupported(string extension) + { + return INTERNAL_SDL_GL_ExtensionSupported( + UTF8_ToNative(extension) + ); + } + + /* Only available in SDL 2.0.2 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GL_ResetAttributes(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GL_GetAttribute( + SDL_GLattr attr, + out int value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GL_GetSwapInterval(); + + /* window and context refer to an SDL_Window* and SDL_GLContext */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GL_MakeCurrent( + IntPtr window, + IntPtr context + ); + + /* IntPtr refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GL_GetCurrentWindow(); + + /* IntPtr refers to an SDL_Context */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GL_GetCurrentContext(); + + /* window refers to an SDL_Window*, This function is only available in SDL 2.0.1 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GL_GetDrawableSize( + IntPtr window, + out int w, + out int h + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GL_SetAttribute( + SDL_GLattr attr, + int value + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GL_SetSwapInterval(int interval); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GL_SwapWindow(IntPtr window); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GL_UnbindTexture(IntPtr texture); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_HideWindow(IntPtr window); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_IsScreenSaverEnabled(); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_MaximizeWindow(IntPtr window); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_MinimizeWindow(IntPtr window); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_RaiseWindow(IntPtr window); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_RestoreWindow(IntPtr window); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetWindowBrightness( + IntPtr window, + float brightness + ); + + /* IntPtr and userdata are void*, window is an SDL_Window* */ + [DllImport(nativeLibName, EntryPoint = "SDL_SetWindowData", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_SetWindowData( + IntPtr window, + byte[] name, + IntPtr userdata + ); + public static IntPtr SDL_SetWindowData( + IntPtr window, + string name, + IntPtr userdata + ) { + return INTERNAL_SDL_SetWindowData( + window, + UTF8_ToNative(name), + userdata + ); + } + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetWindowDisplayMode( + IntPtr window, + ref SDL_DisplayMode mode + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetWindowFullscreen( + IntPtr window, + uint flags + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetWindowGammaRamp( + IntPtr window, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] + ushort[] red, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] + ushort[] green, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] + ushort[] blue + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetWindowGrab( + IntPtr window, + SDL_bool grabbed + ); + + /* window refers to an SDL_Window*, icon to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetWindowIcon( + IntPtr window, + IntPtr icon + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetWindowMaximumSize( + IntPtr window, + int max_w, + int max_h + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetWindowMinimumSize( + IntPtr window, + int min_w, + int min_h + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetWindowPosition( + IntPtr window, + int x, + int y + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetWindowSize( + IntPtr window, + int w, + int h + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetWindowBordered( + IntPtr window, + SDL_bool bordered + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetWindowBordersSize( + IntPtr window, + out int top, + out int left, + out int bottom, + out int right + ); + + /* window refers to an SDL_Window* */ + /* Available in 2.0.5 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetWindowResizable( + IntPtr window, + SDL_bool resizable + ); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, EntryPoint = "SDL_SetWindowTitle", CallingConvention = CallingConvention.Cdecl)] + private static extern void INTERNAL_SDL_SetWindowTitle( + IntPtr window, + byte[] title + ); + public static void SDL_SetWindowTitle( + IntPtr window, + string title + ) { + INTERNAL_SDL_SetWindowTitle( + window, + UTF8_ToNative(title) + ); + } + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_ShowWindow(IntPtr window); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_UpdateWindowSurface(IntPtr window); + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_UpdateWindowSurfaceRects( + IntPtr window, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)] + SDL_Rect[] rects, + int numrects + ); + + [DllImport(nativeLibName, EntryPoint = "SDL_VideoInit", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_SDL_VideoInit( + byte[] driver_name + ); + public static int SDL_VideoInit(string driver_name) + { + return INTERNAL_SDL_VideoInit( + UTF8_ToNative(driver_name) + ); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_VideoQuit(); + + /* window refers to an SDL_Window*, callback_data to a void* */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetWindowHitTest( + IntPtr window, + SDL_HitTest callback, + IntPtr callback_data + ); + + /* IntPtr refers to an SDL_Window* */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetGrabbedWindow(); + + #endregion + + #region SDL_blendmode.h + + [Flags] + public enum SDL_BlendMode + { + SDL_BLENDMODE_NONE = 0x00000000, + SDL_BLENDMODE_BLEND = 0x00000001, + SDL_BLENDMODE_ADD = 0x00000002, + SDL_BLENDMODE_MOD = 0x00000004, + SDL_BLENDMODE_INVALID = 0x7FFFFFFF + } + + public enum SDL_BlendOperation + { + SDL_BLENDOPERATION_ADD = 0x1, + SDL_BLENDOPERATION_SUBTRACT = 0x2, + SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, + SDL_BLENDOPERATION_MINIMUM = 0x4, + SDL_BLENDOPERATION_MAXIMUM = 0x5 + } + + public enum SDL_BlendFactor + { + SDL_BLENDFACTOR_ZERO = 0x1, + SDL_BLENDFACTOR_ONE = 0x2, + SDL_BLENDFACTOR_SRC_COLOR = 0x3, + SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, + SDL_BLENDFACTOR_SRC_ALPHA = 0x5, + SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, + SDL_BLENDFACTOR_DST_COLOR = 0x7, + SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, + SDL_BLENDFACTOR_DST_ALPHA = 0x9, + SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA + } + + /* Only available in 2.0.6 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_BlendMode SDL_ComposeCustomBlendMode( + SDL_BlendFactor srcColorFactor, + SDL_BlendFactor dstColorFactor, + SDL_BlendOperation colorOperation, + SDL_BlendFactor srcAlphaFactor, + SDL_BlendFactor dstAlphaFactor, + SDL_BlendOperation alphaOperation + ); + + #endregion + + #region SDL_vulkan.h + + /* Only available in 2.0.6 */ + [DllImport(nativeLibName, EntryPoint = "SDL_Vulkan_LoadLibrary", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_SDL_Vulkan_LoadLibrary( + byte[] path + ); + public static int SDL_Vulkan_LoadLibrary(string path) + { + return INTERNAL_SDL_Vulkan_LoadLibrary( + UTF8_ToNative(path) + ); + } + + /* Only available in 2.0.6 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_Vulkan_GetVkGetInstanceProcAddr(); + + /* Only available in 2.0.6 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_Vulkan_UnloadLibrary(); + + /* window refers to an SDL_Window*, pNames to a const char**. + * Only available in 2.0.6. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_Vulkan_GetInstanceExtensions( + IntPtr window, + out uint pCount, + IntPtr[] pNames + ); + + /* window refers to an SDL_Window. + * instance refers to a VkInstance. + * surface refers to a VkSurfaceKHR. + * Only available in 2.0.6. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_Vulkan_CreateSurface( + IntPtr window, + IntPtr instance, + out IntPtr surface + ); + + /* window refers to an SDL_Window*. + * Only available in 2.0.6. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_Vulkan_GetDrawableSize( + IntPtr window, + out int w, + out int h + ); + + #endregion + + #region SDL_render.h + + [Flags] + public enum SDL_RendererFlags : uint + { + SDL_RENDERER_SOFTWARE = 0x00000001, + SDL_RENDERER_ACCELERATED = 0x00000002, + SDL_RENDERER_PRESENTVSYNC = 0x00000004, + SDL_RENDERER_TARGETTEXTURE = 0x00000008 + } + + [Flags] + public enum SDL_RendererFlip + { + SDL_FLIP_NONE = 0x00000000, + SDL_FLIP_HORIZONTAL = 0x00000001, + SDL_FLIP_VERTICAL = 0x00000002 + } + + public enum SDL_TextureAccess + { + SDL_TEXTUREACCESS_STATIC, + SDL_TEXTUREACCESS_STREAMING, + SDL_TEXTUREACCESS_TARGET + } + + [Flags] + public enum SDL_TextureModulate + { + SDL_TEXTUREMODULATE_NONE = 0x00000000, + SDL_TEXTUREMODULATE_HORIZONTAL = 0x00000001, + SDL_TEXTUREMODULATE_VERTICAL = 0x00000002 + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct SDL_RendererInfo + { + public IntPtr name; // const char* + public uint flags; + public uint num_texture_formats; + public fixed uint texture_formats[16]; + public int max_texture_width; + public int max_texture_height; + } + + /* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateRenderer( + IntPtr window, + int index, + SDL_RendererFlags flags + ); + + /* IntPtr refers to an SDL_Renderer*, surface to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateSoftwareRenderer(IntPtr surface); + + /* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateTexture( + IntPtr renderer, + uint format, + int access, + int w, + int h + ); + + /* IntPtr refers to an SDL_Texture* + * renderer refers to an SDL_Renderer* + * surface refers to an SDL_Surface* + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateTextureFromSurface( + IntPtr renderer, + IntPtr surface + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_DestroyRenderer(IntPtr renderer); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_DestroyTexture(IntPtr texture); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetNumRenderDrivers(); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetRenderDrawBlendMode( + IntPtr renderer, + out SDL_BlendMode blendMode + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetRenderDrawColor( + IntPtr renderer, + out byte r, + out byte g, + out byte b, + out byte a + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetRenderDriverInfo( + int index, + out SDL_RendererInfo info + ); + + /* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetRenderer(IntPtr window); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetRendererInfo( + IntPtr renderer, + out SDL_RendererInfo info + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetRendererOutputSize( + IntPtr renderer, + out int w, + out int h + ); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetTextureAlphaMod( + IntPtr texture, + out byte alpha + ); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetTextureBlendMode( + IntPtr texture, + out SDL_BlendMode blendMode + ); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetTextureColorMod( + IntPtr texture, + out byte r, + out byte g, + out byte b + ); + + /* texture refers to an SDL_Texture*, pixels to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_LockTexture( + IntPtr texture, + ref SDL_Rect rect, + out IntPtr pixels, + out int pitch + ); + + /* texture refers to an SDL_Texture*, pixels to a void*. + * Internally, this function contains logic to use default values when + * the rectangle is passed as NULL. + * This overload allows for IntPtr.Zero to be passed for rect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_LockTexture( + IntPtr texture, + IntPtr rect, + out IntPtr pixels, + out int pitch + ); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_QueryTexture( + IntPtr texture, + out uint format, + out int access, + out int w, + out int h + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderClear(IntPtr renderer); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopy( + IntPtr renderer, + IntPtr texture, + ref SDL_Rect srcrect, + ref SDL_Rect dstrect + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*. + * Internally, this function contains logic to use default values when + * source and destination rectangles are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for srcrect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopy( + IntPtr renderer, + IntPtr texture, + IntPtr srcrect, + ref SDL_Rect dstrect + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*. + * Internally, this function contains logic to use default values when + * source and destination rectangles are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for dstrect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopy( + IntPtr renderer, + IntPtr texture, + ref SDL_Rect srcrect, + IntPtr dstrect + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*. + * Internally, this function contains logic to use default values when + * source and destination rectangles are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for both SDL_Rects. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopy( + IntPtr renderer, + IntPtr texture, + IntPtr srcrect, + IntPtr dstrect + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopyEx( + IntPtr renderer, + IntPtr texture, + ref SDL_Rect srcrect, + ref SDL_Rect dstrect, + double angle, + ref SDL_Point center, + SDL_RendererFlip flip + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*. + * Internally, this function contains logic to use default values when + * source, destination, and/or center are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for srcrect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopyEx( + IntPtr renderer, + IntPtr texture, + IntPtr srcrect, + ref SDL_Rect dstrect, + double angle, + ref SDL_Point center, + SDL_RendererFlip flip + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*. + * Internally, this function contains logic to use default values when + * source, destination, and/or center are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for dstrect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopyEx( + IntPtr renderer, + IntPtr texture, + ref SDL_Rect srcrect, + IntPtr dstrect, + double angle, + ref SDL_Point center, + SDL_RendererFlip flip + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*. + * Internally, this function contains logic to use default values when + * source, destination, and/or center are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for center. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopyEx( + IntPtr renderer, + IntPtr texture, + ref SDL_Rect srcrect, + ref SDL_Rect dstrect, + double angle, + IntPtr center, + SDL_RendererFlip flip + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*. + * Internally, this function contains logic to use default values when + * source, destination, and/or center are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for both + * srcrect and dstrect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopyEx( + IntPtr renderer, + IntPtr texture, + IntPtr srcrect, + IntPtr dstrect, + double angle, + ref SDL_Point center, + SDL_RendererFlip flip + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*. + * Internally, this function contains logic to use default values when + * source, destination, and/or center are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for both + * srcrect and center. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopyEx( + IntPtr renderer, + IntPtr texture, + IntPtr srcrect, + ref SDL_Rect dstrect, + double angle, + IntPtr center, + SDL_RendererFlip flip + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*. + * Internally, this function contains logic to use default values when + * source, destination, and/or center are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for both + * dstrect and center. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopyEx( + IntPtr renderer, + IntPtr texture, + ref SDL_Rect srcrect, + IntPtr dstrect, + double angle, + IntPtr center, + SDL_RendererFlip flip + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*. + * Internally, this function contains logic to use default values when + * source, destination, and/or center are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for all + * three parameters. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopyEx( + IntPtr renderer, + IntPtr texture, + IntPtr srcrect, + IntPtr dstrect, + double angle, + IntPtr center, + SDL_RendererFlip flip + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderDrawLine( + IntPtr renderer, + int x1, + int y1, + int x2, + int y2 + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderDrawLines( + IntPtr renderer, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)] + SDL_Point[] points, + int count + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderDrawPoint( + IntPtr renderer, + int x, + int y + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderDrawPoints( + IntPtr renderer, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)] + SDL_Point[] points, + int count + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderDrawRect( + IntPtr renderer, + ref SDL_Rect rect + ); + + /* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*. + * This overload allows for IntPtr.Zero (null) to be passed for rect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderDrawRect( + IntPtr renderer, + IntPtr rect + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderDrawRects( + IntPtr renderer, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)] + SDL_Rect[] rects, + int count + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderFillRect( + IntPtr renderer, + ref SDL_Rect rect + ); + + /* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*. + * This overload allows for IntPtr.Zero (null) to be passed for rect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderFillRect( + IntPtr renderer, + IntPtr rect + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderFillRects( + IntPtr renderer, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)] + SDL_Rect[] rects, + int count + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_RenderGetClipRect( + IntPtr renderer, + out SDL_Rect rect + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_RenderGetLogicalSize( + IntPtr renderer, + out int w, + out int h + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_RenderGetScale( + IntPtr renderer, + out float scaleX, + out float scaleY + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderGetViewport( + IntPtr renderer, + out SDL_Rect rect + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_RenderPresent(IntPtr renderer); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderReadPixels( + IntPtr renderer, + ref SDL_Rect rect, + uint format, + IntPtr pixels, + int pitch + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderSetClipRect( + IntPtr renderer, + ref SDL_Rect rect + ); + + /* renderer refers to an SDL_Renderer* + * This overload allows for IntPtr.Zero (null) to be passed for rect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderSetClipRect( + IntPtr renderer, + IntPtr rect + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderSetLogicalSize( + IntPtr renderer, + int w, + int h + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderSetScale( + IntPtr renderer, + float scaleX, + float scaleY + ); + + /* renderer refers to an SDL_Renderer* */ + /* Available in 2.0.5 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderSetIntegerScale( + IntPtr renderer, + SDL_bool enable + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderSetViewport( + IntPtr renderer, + ref SDL_Rect rect + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetRenderDrawBlendMode( + IntPtr renderer, + SDL_BlendMode blendMode + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetRenderDrawColor( + IntPtr renderer, + byte r, + byte g, + byte b, + byte a + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetRenderTarget( + IntPtr renderer, + IntPtr texture + ); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetTextureAlphaMod( + IntPtr texture, + byte alpha + ); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetTextureBlendMode( + IntPtr texture, + SDL_BlendMode blendMode + ); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetTextureColorMod( + IntPtr texture, + byte r, + byte g, + byte b + ); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_UnlockTexture(IntPtr texture); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_UpdateTexture( + IntPtr texture, + ref SDL_Rect rect, + IntPtr pixels, + int pitch + ); + + /* texture refers to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_UpdateTexture( + IntPtr texture, + IntPtr rect, + IntPtr pixels, + int pitch + ); + + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_RenderTargetSupported( + IntPtr renderer + ); + + /* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetRenderTarget(IntPtr renderer); + + /* renderer refers to an SDL_Renderer* */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_RenderIsClipEnabled(IntPtr renderer); + + #endregion + + #region SDL_pixels.h + + public static uint SDL_DEFINE_PIXELFOURCC(byte A, byte B, byte C, byte D) + { + return SDL_FOURCC(A, B, C, D); + } + + public static uint SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM type, + SDL_PIXELORDER_ENUM order, + SDL_PACKEDLAYOUT_ENUM layout, + byte bits, + byte bytes + ) { + return (uint) ( + (1 << 28) | + (((byte) type) << 24) | + (((byte) order) << 20) | + (((byte) layout) << 16) | + (bits << 8) | + (bytes) + ); + } + + public static byte SDL_PIXELFLAG(uint X) + { + return (byte) ((X >> 28) & 0x0F); + } + + public static byte SDL_PIXELTYPE(uint X) + { + return (byte) ((X >> 24) & 0x0F); + } + + public static byte SDL_PIXELORDER(uint X) + { + return (byte) ((X >> 20) & 0x0F); + } + + public static byte SDL_PIXELLAYOUT(uint X) + { + return (byte) ((X >> 16) & 0x0F); + } + + public static byte SDL_BITSPERPIXEL(uint X) + { + return (byte) ((X >> 8) & 0xFF); + } + + public static byte SDL_BYTESPERPIXEL(uint X) + { + if (SDL_ISPIXELFORMAT_FOURCC(X)) + { + if ( (X == SDL_PIXELFORMAT_YUY2) || + (X == SDL_PIXELFORMAT_UYVY) || + (X == SDL_PIXELFORMAT_YVYU) ) + { + return 2; + } + return 1; + } + return (byte) (X & 0xFF); + } + + public static bool SDL_ISPIXELFORMAT_INDEXED(uint format) + { + if (SDL_ISPIXELFORMAT_FOURCC(format)) + { + return false; + } + SDL_PIXELTYPE_ENUM pType = + (SDL_PIXELTYPE_ENUM) SDL_PIXELTYPE(format); + return ( + pType == SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX1 || + pType == SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX4 || + pType == SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX8 + ); + } + + public static bool SDL_ISPIXELFORMAT_ALPHA(uint format) + { + if (SDL_ISPIXELFORMAT_FOURCC(format)) + { + return false; + } + SDL_PIXELORDER_ENUM pOrder = + (SDL_PIXELORDER_ENUM) SDL_PIXELORDER(format); + return ( + pOrder == SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_ARGB || + pOrder == SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_RGBA || + pOrder == SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_ABGR || + pOrder == SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_BGRA + ); + } + + public static bool SDL_ISPIXELFORMAT_FOURCC(uint format) + { + return (format == 0) && (SDL_PIXELFLAG(format) != 1); + } + + public enum SDL_PIXELTYPE_ENUM + { + SDL_PIXELTYPE_UNKNOWN, + SDL_PIXELTYPE_INDEX1, + SDL_PIXELTYPE_INDEX4, + SDL_PIXELTYPE_INDEX8, + SDL_PIXELTYPE_PACKED8, + SDL_PIXELTYPE_PACKED16, + SDL_PIXELTYPE_PACKED32, + SDL_PIXELTYPE_ARRAYU8, + SDL_PIXELTYPE_ARRAYU16, + SDL_PIXELTYPE_ARRAYU32, + SDL_PIXELTYPE_ARRAYF16, + SDL_PIXELTYPE_ARRAYF32 + } + + public enum SDL_PIXELORDER_ENUM + { + /* BITMAPORDER */ + SDL_BITMAPORDER_NONE, + SDL_BITMAPORDER_4321, + SDL_BITMAPORDER_1234, + /* PACKEDORDER */ + SDL_PACKEDORDER_NONE = 0, + SDL_PACKEDORDER_XRGB, + SDL_PACKEDORDER_RGBX, + SDL_PACKEDORDER_ARGB, + SDL_PACKEDORDER_RGBA, + SDL_PACKEDORDER_XBGR, + SDL_PACKEDORDER_BGRX, + SDL_PACKEDORDER_ABGR, + SDL_PACKEDORDER_BGRA, + /* ARRAYORDER */ + SDL_ARRAYORDER_NONE = 0, + SDL_ARRAYORDER_RGB, + SDL_ARRAYORDER_RGBA, + SDL_ARRAYORDER_ARGB, + SDL_ARRAYORDER_BGR, + SDL_ARRAYORDER_BGRA, + SDL_ARRAYORDER_ABGR + } + + public enum SDL_PACKEDLAYOUT_ENUM + { + SDL_PACKEDLAYOUT_NONE, + SDL_PACKEDLAYOUT_332, + SDL_PACKEDLAYOUT_4444, + SDL_PACKEDLAYOUT_1555, + SDL_PACKEDLAYOUT_5551, + SDL_PACKEDLAYOUT_565, + SDL_PACKEDLAYOUT_8888, + SDL_PACKEDLAYOUT_2101010, + SDL_PACKEDLAYOUT_1010102 + } + + public static readonly uint SDL_PIXELFORMAT_UNKNOWN = 0; + public static readonly uint SDL_PIXELFORMAT_INDEX1LSB = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX1, + SDL_PIXELORDER_ENUM.SDL_BITMAPORDER_4321, + 0, + 1, 0 + ); + public static readonly uint SDL_PIXELFORMAT_INDEX1MSB = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX1, + SDL_PIXELORDER_ENUM.SDL_BITMAPORDER_1234, + 0, + 1, 0 + ); + public static readonly uint SDL_PIXELFORMAT_INDEX4LSB = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX4, + SDL_PIXELORDER_ENUM.SDL_BITMAPORDER_4321, + 0, + 4, 0 + ); + public static readonly uint SDL_PIXELFORMAT_INDEX4MSB = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX4, + SDL_PIXELORDER_ENUM.SDL_BITMAPORDER_1234, + 0, + 4, 0 + ); + public static readonly uint SDL_PIXELFORMAT_INDEX8 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX8, + 0, + 0, + 8, 1 + ); + public static readonly uint SDL_PIXELFORMAT_RGB332 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED8, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_332, + 8, 1 + ); + public static readonly uint SDL_PIXELFORMAT_RGB444 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_4444, + 12, 2 + ); + public static readonly uint SDL_PIXELFORMAT_RGB555 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_1555, + 15, 2 + ); + public static readonly uint SDL_PIXELFORMAT_BGR555 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX1, + SDL_PIXELORDER_ENUM.SDL_BITMAPORDER_4321, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_1555, + 15, 2 + ); + public static readonly uint SDL_PIXELFORMAT_ARGB4444 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_4444, + 16, 2 + ); + public static readonly uint SDL_PIXELFORMAT_RGBA4444 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_4444, + 16, 2 + ); + public static readonly uint SDL_PIXELFORMAT_ABGR4444 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_4444, + 16, 2 + ); + public static readonly uint SDL_PIXELFORMAT_BGRA4444 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_4444, + 16, 2 + ); + public static readonly uint SDL_PIXELFORMAT_ARGB1555 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_1555, + 16, 2 + ); + public static readonly uint SDL_PIXELFORMAT_RGBA5551 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_5551, + 16, 2 + ); + public static readonly uint SDL_PIXELFORMAT_ABGR1555 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_1555, + 16, 2 + ); + public static readonly uint SDL_PIXELFORMAT_BGRA5551 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_5551, + 16, 2 + ); + public static readonly uint SDL_PIXELFORMAT_RGB565 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_565, + 16, 2 + ); + public static readonly uint SDL_PIXELFORMAT_BGR565 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED16, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_565, + 16, 2 + ); + public static readonly uint SDL_PIXELFORMAT_RGB24 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_ARRAYU8, + SDL_PIXELORDER_ENUM.SDL_ARRAYORDER_RGB, + 0, + 24, 3 + ); + public static readonly uint SDL_PIXELFORMAT_BGR24 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_ARRAYU8, + SDL_PIXELORDER_ENUM.SDL_ARRAYORDER_BGR, + 0, + 24, 3 + ); + public static readonly uint SDL_PIXELFORMAT_RGB888 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED32, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_8888, + 24, 4 + ); + public static readonly uint SDL_PIXELFORMAT_RGBX8888 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED32, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_RGBX, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_8888, + 24, 4 + ); + public static readonly uint SDL_PIXELFORMAT_BGR888 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED32, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_8888, + 24, 4 + ); + public static readonly uint SDL_PIXELFORMAT_BGRX8888 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED32, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_BGRX, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_8888, + 24, 4 + ); + public static readonly uint SDL_PIXELFORMAT_ARGB8888 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED32, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_8888, + 32, 4 + ); + public static readonly uint SDL_PIXELFORMAT_RGBA8888 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED32, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_8888, + 32, 4 + ); + public static readonly uint SDL_PIXELFORMAT_ABGR8888 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED32, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_8888, + 32, 4 + ); + public static readonly uint SDL_PIXELFORMAT_BGRA8888 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED32, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_8888, + 32, 4 + ); + public static readonly uint SDL_PIXELFORMAT_ARGB2101010 = + SDL_DEFINE_PIXELFORMAT( + SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_PACKED32, + SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_ENUM.SDL_PACKEDLAYOUT_2101010, + 32, 4 + ); + public static readonly uint SDL_PIXELFORMAT_YV12 = + SDL_DEFINE_PIXELFOURCC( + (byte) 'Y', (byte) 'V', (byte) '1', (byte) '2' + ); + public static readonly uint SDL_PIXELFORMAT_IYUV = + SDL_DEFINE_PIXELFOURCC( + (byte) 'I', (byte) 'Y', (byte) 'U', (byte) 'V' + ); + public static readonly uint SDL_PIXELFORMAT_YUY2 = + SDL_DEFINE_PIXELFOURCC( + (byte) 'Y', (byte) 'U', (byte) 'Y', (byte) '2' + ); + public static readonly uint SDL_PIXELFORMAT_UYVY = + SDL_DEFINE_PIXELFOURCC( + (byte) 'U', (byte) 'Y', (byte) 'V', (byte) 'Y' + ); + public static readonly uint SDL_PIXELFORMAT_YVYU = + SDL_DEFINE_PIXELFOURCC( + (byte) 'Y', (byte) 'V', (byte) 'Y', (byte) 'U' + ); + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_Color + { + public byte r; + public byte g; + public byte b; + public byte a; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_Palette + { + public int ncolors; + public IntPtr colors; + public int version; + public int refcount; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_PixelFormat + { + public uint format; + public IntPtr palette; // SDL_Palette* + public byte BitsPerPixel; + public byte BytesPerPixel; + public uint Rmask; + public uint Gmask; + public uint Bmask; + public uint Amask; + public byte Rloss; + public byte Gloss; + public byte Bloss; + public byte Aloss; + public byte Rshift; + public byte Gshift; + public byte Bshift; + public byte Ashift; + public int refcount; + public IntPtr next; // SDL_PixelFormat* + } + + /* IntPtr refers to an SDL_PixelFormat* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_AllocFormat(uint pixel_format); + + /* IntPtr refers to an SDL_Palette* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_AllocPalette(int ncolors); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_CalculateGammaRamp( + float gamma, + [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)] + ushort[] ramp + ); + + /* format refers to an SDL_PixelFormat* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_FreeFormat(IntPtr format); + + /* palette refers to an SDL_Palette* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_FreePalette(IntPtr palette); + + [DllImport(nativeLibName, EntryPoint = "SDL_GetPixelFormatName", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetPixelFormatName( + uint format + ); + public static string SDL_GetPixelFormatName(uint format) + { + return UTF8_ToManaged( + INTERNAL_SDL_GetPixelFormatName(format) + ); + } + + /* format refers to an SDL_PixelFormat* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GetRGB( + uint pixel, + IntPtr format, + out byte r, + out byte g, + out byte b + ); + + /* format refers to an SDL_PixelFormat* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GetRGBA( + uint pixel, + IntPtr format, + out byte r, + out byte g, + out byte b, + out byte a + ); + + /* format refers to an SDL_PixelFormat* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern uint SDL_MapRGB( + IntPtr format, + byte r, + byte g, + byte b + ); + + /* format refers to an SDL_PixelFormat* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern uint SDL_MapRGBA( + IntPtr format, + byte r, + byte g, + byte b, + byte a + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern uint SDL_MasksToPixelFormatEnum( + int bpp, + uint Rmask, + uint Gmask, + uint Bmask, + uint Amask + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_PixelFormatEnumToMasks( + uint format, + out int bpp, + out uint Rmask, + out uint Gmask, + out uint Bmask, + out uint Amask + ); + + /* palette refers to an SDL_Palette* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetPaletteColors( + IntPtr palette, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct)] + SDL_Color[] colors, + int firstcolor, + int ncolors + ); + + /* format and palette refer to an SDL_PixelFormat* and SDL_Palette* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetPixelFormatPalette( + IntPtr format, + IntPtr palette + ); + + #endregion + + #region SDL_rect.h + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_Point + { + public int x; + public int y; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_Rect + { + public int x; + public int y; + public int w; + public int h; + } + + /* Only available in 2.0.4 */ + public static SDL_bool SDL_PointInRect(ref SDL_Point p, ref SDL_Rect r) + { + return ( (p.x >= r.x) && + (p.x < (r.x + r.w)) && + (p.y >= r.y) && + (p.y < (r.y + r.h)) ) ? + SDL_bool.SDL_TRUE : + SDL_bool.SDL_FALSE; + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_EnclosePoints( + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 1)] + SDL_Point[] points, + int count, + ref SDL_Rect clip, + out SDL_Rect result + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_HasIntersection( + ref SDL_Rect A, + ref SDL_Rect B + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_IntersectRect( + ref SDL_Rect A, + ref SDL_Rect B, + out SDL_Rect result + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_IntersectRectAndLine( + ref SDL_Rect rect, + ref int X1, + ref int Y1, + ref int X2, + ref int Y2 + ); + + public static SDL_bool SDL_RectEmpty(ref SDL_Rect r) + { + return ((r.w <= 0) || (r.h <= 0)) ? + SDL_bool.SDL_TRUE : + SDL_bool.SDL_FALSE; + } + + public static SDL_bool SDL_RectEquals( + ref SDL_Rect a, + ref SDL_Rect b + ) { + return ( (a.x == b.x) && + (a.y == b.y) && + (a.w == b.w) && + (a.h == b.h) ) ? + SDL_bool.SDL_TRUE : + SDL_bool.SDL_FALSE; + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_UnionRect( + ref SDL_Rect A, + ref SDL_Rect B, + out SDL_Rect result + ); + + #endregion + + #region SDL_surface.h + + public const uint SDL_SWSURFACE = 0x00000000; + public const uint SDL_PREALLOC = 0x00000001; + public const uint SDL_RLEACCEL = 0x00000002; + public const uint SDL_DONTFREE = 0x00000004; + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_Surface + { + public uint flags; + public IntPtr format; // SDL_PixelFormat* + public int w; + public int h; + public int pitch; + public IntPtr pixels; // void* + public IntPtr userdata; // void* + public int locked; + public IntPtr lock_data; // void* + public SDL_Rect clip_rect; + public IntPtr map; // SDL_BlitMap* + public int refcount; + } + + /* surface refers to an SDL_Surface* */ + public static bool SDL_MUSTLOCK(IntPtr surface) + { + SDL_Surface sur; + sur = (SDL_Surface) Marshal.PtrToStructure( + surface, + typeof(SDL_Surface) + ); + return (sur.flags & SDL_RLEACCEL) != 0; + } + + /* src and dst refer to an SDL_Surface* */ + [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_BlitSurface( + IntPtr src, + ref SDL_Rect srcrect, + IntPtr dst, + ref SDL_Rect dstrect + ); + + /* src and dst refer to an SDL_Surface* + * Internally, this function contains logic to use default values when + * source and destination rectangles are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for srcrect. + */ + [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_BlitSurface( + IntPtr src, + IntPtr srcrect, + IntPtr dst, + ref SDL_Rect dstrect + ); + + /* src and dst refer to an SDL_Surface* + * Internally, this function contains logic to use default values when + * source and destination rectangles are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for dstrect. + */ + [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_BlitSurface( + IntPtr src, + ref SDL_Rect srcrect, + IntPtr dst, + IntPtr dstrect + ); + + /* src and dst refer to an SDL_Surface* + * Internally, this function contains logic to use default values when + * source and destination rectangles are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for both SDL_Rects. + */ + [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_BlitSurface( + IntPtr src, + IntPtr srcrect, + IntPtr dst, + IntPtr dstrect + ); + + /* src and dst refer to an SDL_Surface* */ + [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_BlitScaled( + IntPtr src, + ref SDL_Rect srcrect, + IntPtr dst, + ref SDL_Rect dstrect + ); + + /* src and dst refer to an SDL_Surface* + * Internally, this function contains logic to use default values when + * source and destination rectangles are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for srcrect. + */ + [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_BlitScaled( + IntPtr src, + IntPtr srcrect, + IntPtr dst, + ref SDL_Rect dstrect + ); + + /* src and dst refer to an SDL_Surface* + * Internally, this function contains logic to use default values when + * source and destination rectangles are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for dstrect. + */ + [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_BlitScaled( + IntPtr src, + ref SDL_Rect srcrect, + IntPtr dst, + IntPtr dstrect + ); + + /* src and dst refer to an SDL_Surface* + * Internally, this function contains logic to use default values when + * source and destination rectangles are passed as NULL. + * This overload allows for IntPtr.Zero (null) to be passed for both SDL_Rects. + */ + [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_BlitScaled( + IntPtr src, + IntPtr srcrect, + IntPtr dst, + IntPtr dstrect + ); + + /* src and dst are void* pointers */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_ConvertPixels( + int width, + int height, + uint src_format, + IntPtr src, + int src_pitch, + uint dst_format, + IntPtr dst, + int dst_pitch + ); + + /* IntPtr refers to an SDL_Surface* + * src refers to an SDL_Surface* + * fmt refers to an SDL_PixelFormat* + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_ConvertSurface( + IntPtr src, + IntPtr fmt, + uint flags + ); + + /* IntPtr refers to an SDL_Surface*, src to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_ConvertSurfaceFormat( + IntPtr src, + uint pixel_format, + uint flags + ); + + /* IntPtr refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateRGBSurface( + uint flags, + int width, + int height, + int depth, + uint Rmask, + uint Gmask, + uint Bmask, + uint Amask + ); + + /* IntPtr refers to an SDL_Surface*, pixels to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateRGBSurfaceFrom( + IntPtr pixels, + int width, + int height, + int depth, + int pitch, + uint Rmask, + uint Gmask, + uint Bmask, + uint Amask + ); + + /* IntPtr refers to an SDL_Surface* */ + /* Available in 2.0.5 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateRGBSurfaceWithFormat( + uint flags, + int width, + int height, + int depth, + uint format + ); + + /* IntPtr refers to an SDL_Surface*, pixels to a void* */ + /* Available in 2.0.5 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateRGBSurfaceWithFormatFrom( + IntPtr pixels, + int width, + int height, + int depth, + int pitch, + uint format + ); + + /* dst refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_FillRect( + IntPtr dst, + ref SDL_Rect rect, + uint color + ); + + /* dst refers to an SDL_Surface*. + * This overload allows passing NULL to rect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_FillRect( + IntPtr dst, + IntPtr rect, + uint color + ); + + /* dst refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_FillRects( + IntPtr dst, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)] + SDL_Rect[] rects, + int count, + uint color + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_FreeSurface(IntPtr surface); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GetClipRect( + IntPtr surface, + out SDL_Rect rect + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetColorKey( + IntPtr surface, + out uint key + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetSurfaceAlphaMod( + IntPtr surface, + out byte alpha + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetSurfaceBlendMode( + IntPtr surface, + out SDL_BlendMode blendMode + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetSurfaceColorMod( + IntPtr surface, + out byte r, + out byte g, + out byte b + ); + + /* These are for SDL_LoadBMP, which is a macro in the SDL headers. */ + /* IntPtr refers to an SDL_Surface* */ + /* THIS IS AN RWops FUNCTION! */ + [DllImport(nativeLibName, EntryPoint = "SDL_LoadBMP_RW", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_LoadBMP_RW( + IntPtr src, + int freesrc + ); + public static IntPtr SDL_LoadBMP(string file) + { + IntPtr rwops = INTERNAL_SDL_RWFromFile(file, "rb"); + return INTERNAL_SDL_LoadBMP_RW(rwops, 1); + } + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_LockSurface(IntPtr surface); + + /* src and dst refer to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_LowerBlit( + IntPtr src, + ref SDL_Rect srcrect, + IntPtr dst, + ref SDL_Rect dstrect + ); + + /* src and dst refer to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_LowerBlitScaled( + IntPtr src, + ref SDL_Rect srcrect, + IntPtr dst, + ref SDL_Rect dstrect + ); + + /* These are for SDL_SaveBMP, which is a macro in the SDL headers. */ + /* IntPtr refers to an SDL_Surface* */ + /* THIS IS AN RWops FUNCTION! */ + [DllImport(nativeLibName, EntryPoint = "SDL_SaveBMP_RW", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_SDL_SaveBMP_RW( + IntPtr surface, + IntPtr src, + int freesrc + ); + public static int SDL_SaveBMP(IntPtr surface, string file) + { + IntPtr rwops = INTERNAL_SDL_RWFromFile(file, "wb"); + return INTERNAL_SDL_SaveBMP_RW(surface, rwops, 1); + } + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_SetClipRect( + IntPtr surface, + ref SDL_Rect rect + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetColorKey( + IntPtr surface, + int flag, + uint key + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetSurfaceAlphaMod( + IntPtr surface, + byte alpha + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetSurfaceBlendMode( + IntPtr surface, + SDL_BlendMode blendMode + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetSurfaceColorMod( + IntPtr surface, + byte r, + byte g, + byte b + ); + + /* surface refers to an SDL_Surface*, palette to an SDL_Palette* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetSurfacePalette( + IntPtr surface, + IntPtr palette + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetSurfaceRLE( + IntPtr surface, + int flag + ); + + /* src and dst refer to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SoftStretch( + IntPtr src, + ref SDL_Rect srcrect, + IntPtr dst, + ref SDL_Rect dstrect + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_UnlockSurface(IntPtr surface); + + /* src and dst refer to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_UpperBlit( + IntPtr src, + ref SDL_Rect srcrect, + IntPtr dst, + ref SDL_Rect dstrect + ); + + /* src and dst refer to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_UpperBlitScaled( + IntPtr src, + ref SDL_Rect srcrect, + IntPtr dst, + ref SDL_Rect dstrect + ); + + /* surface and IntPtr refer to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_DuplicateSurface(IntPtr surface); + + #endregion + + #region SDL_clipboard.h + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_HasClipboardText(); + + [DllImport(nativeLibName, EntryPoint = "SDL_GetClipboardText", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetClipboardText(); + public static string SDL_GetClipboardText() + { + return UTF8_ToManaged(INTERNAL_SDL_GetClipboardText()); + } + + [DllImport(nativeLibName, EntryPoint = "SDL_SetClipboardText", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_SDL_SetClipboardText( + byte[] text + ); + public static int SDL_SetClipboardText( + string text + ) { + return INTERNAL_SDL_SetClipboardText( + UTF8_ToNative(text) + ); + } + + #endregion + + #region SDL_events.h + + /* General keyboard/mouse state definitions. */ + public const byte SDL_PRESSED = 1; + public const byte SDL_RELEASED = 0; + + /* Default size is according to SDL2 default. */ + public const int SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32; + public const int SDL_TEXTINPUTEVENT_TEXT_SIZE = 32; + + /* The types of events that can be delivered. */ + public enum SDL_EventType : uint + { + SDL_FIRSTEVENT = 0, + + /* Application events */ + SDL_QUIT = 0x100, + + /* Window events */ + SDL_WINDOWEVENT = 0x200, + SDL_SYSWMEVENT, + + /* Keyboard events */ + SDL_KEYDOWN = 0x300, + SDL_KEYUP, + SDL_TEXTEDITING, + SDL_TEXTINPUT, + + /* Mouse events */ + SDL_MOUSEMOTION = 0x400, + SDL_MOUSEBUTTONDOWN, + SDL_MOUSEBUTTONUP, + SDL_MOUSEWHEEL, + + /* Joystick events */ + SDL_JOYAXISMOTION = 0x600, + SDL_JOYBALLMOTION, + SDL_JOYHATMOTION, + SDL_JOYBUTTONDOWN, + SDL_JOYBUTTONUP, + SDL_JOYDEVICEADDED, + SDL_JOYDEVICEREMOVED, + + /* Game controller events */ + SDL_CONTROLLERAXISMOTION = 0x650, + SDL_CONTROLLERBUTTONDOWN, + SDL_CONTROLLERBUTTONUP, + SDL_CONTROLLERDEVICEADDED, + SDL_CONTROLLERDEVICEREMOVED, + SDL_CONTROLLERDEVICEREMAPPED, + + /* Touch events */ + SDL_FINGERDOWN = 0x700, + SDL_FINGERUP, + SDL_FINGERMOTION, + + /* Gesture events */ + SDL_DOLLARGESTURE = 0x800, + SDL_DOLLARRECORD, + SDL_MULTIGESTURE, + + /* Clipboard events */ + SDL_CLIPBOARDUPDATE = 0x900, + + /* Drag and drop events */ + SDL_DROPFILE = 0x1000, + /* Only available in 2.0.4 or higher */ + SDL_DROPTEXT, + SDL_DROPBEGIN, + SDL_DROPCOMPLETE, + + /* Audio hotplug events */ + /* Only available in SDL 2.0.4 or higher */ + SDL_AUDIODEVICEADDED = 0x1100, + SDL_AUDIODEVICEREMOVED, + + /* Render events */ + /* Only available in SDL 2.0.2 or higher */ + SDL_RENDER_TARGETS_RESET = 0x2000, + /* Only available in SDL 2.0.4 or higher */ + SDL_RENDER_DEVICE_RESET, + + /* Events SDL_USEREVENT through SDL_LASTEVENT are for + * your use, and should be allocated with + * SDL_RegisterEvents() + */ + SDL_USEREVENT = 0x8000, + + /* The last event, used for bouding arrays. */ + SDL_LASTEVENT = 0xFFFF + } + + /* Only available in 2.0.4 or higher */ + public enum SDL_MouseWheelDirection : uint + { + SDL_MOUSEWHEEL_NORMAL, + SDL_MOUSEWHEEL_FLIPPED + } + + /* Fields shared by every event */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_GenericEvent + { + public SDL_EventType type; + public UInt32 timestamp; + } + +// Ignore private members used for padding in this struct +#pragma warning disable 0169 + /* Window state change event data (event.window.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_WindowEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public UInt32 windowID; + public SDL_WindowEventID windowEvent; // event, lolC# + private byte padding1; + private byte padding2; + private byte padding3; + public Int32 data1; + public Int32 data2; + } +#pragma warning restore 0169 + +// Ignore private members used for padding in this struct +#pragma warning disable 0169 + /* Keyboard button event structure (event.key.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_KeyboardEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public UInt32 windowID; + public byte state; + public byte repeat; /* non-zero if this is a repeat */ + private byte padding2; + private byte padding3; + public SDL_Keysym keysym; + } +#pragma warning restore 0169 + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct SDL_TextEditingEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public UInt32 windowID; + public fixed byte text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; + public Int32 start; + public Int32 length; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct SDL_TextInputEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public UInt32 windowID; + public fixed byte text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; + } + +// Ignore private members used for padding in this struct +#pragma warning disable 0169 + /* Mouse motion event structure (event.motion.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_MouseMotionEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public UInt32 windowID; + public UInt32 which; + public byte state; /* bitmask of buttons */ + private byte padding1; + private byte padding2; + private byte padding3; + public Int32 x; + public Int32 y; + public Int32 xrel; + public Int32 yrel; + } +#pragma warning restore 0169 + +// Ignore private members used for padding in this struct +#pragma warning disable 0169 + /* Mouse button event structure (event.button.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_MouseButtonEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public UInt32 windowID; + public UInt32 which; + public byte button; /* button id */ + public byte state; /* SDL_PRESSED or SDL_RELEASED */ + public byte clicks; /* 1 for single-click, 2 for double-click, etc. */ + private byte padding1; + public Int32 x; + public Int32 y; + } +#pragma warning restore 0169 + + /* Mouse wheel event structure (event.wheel.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_MouseWheelEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public UInt32 windowID; + public UInt32 which; + public Int32 x; /* amount scrolled horizontally */ + public Int32 y; /* amount scrolled vertically */ + public UInt32 direction; /* Set to one of the SDL_MOUSEWHEEL_* defines */ + } + +// Ignore private members used for padding in this struct +#pragma warning disable 0169 + /* Joystick axis motion event structure (event.jaxis.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_JoyAxisEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public Int32 which; /* SDL_JoystickID */ + public byte axis; + private byte padding1; + private byte padding2; + private byte padding3; + public Int16 axisValue; /* value, lolC# */ + public UInt16 padding4; + } +#pragma warning restore 0169 + +// Ignore private members used for padding in this struct +#pragma warning disable 0169 + /* Joystick trackball motion event structure (event.jball.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_JoyBallEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public Int32 which; /* SDL_JoystickID */ + public byte ball; + private byte padding1; + private byte padding2; + private byte padding3; + public Int16 xrel; + public Int16 yrel; + } +#pragma warning restore 0169 + +// Ignore private members used for padding in this struct +#pragma warning disable 0169 + /* Joystick hat position change event struct (event.jhat.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_JoyHatEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public Int32 which; /* SDL_JoystickID */ + public byte hat; /* index of the hat */ + public byte hatValue; /* value, lolC# */ + private byte padding1; + private byte padding2; + } +#pragma warning restore 0169 + +// Ignore private members used for padding in this struct +#pragma warning disable 0169 + /* Joystick button event structure (event.jbutton.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_JoyButtonEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public Int32 which; /* SDL_JoystickID */ + public byte button; + public byte state; /* SDL_PRESSED or SDL_RELEASED */ + private byte padding1; + private byte padding2; + } +#pragma warning restore 0169 + + /* Joystick device event structure (event.jdevice.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_JoyDeviceEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public Int32 which; /* SDL_JoystickID */ + } + +// Ignore private members used for padding in this struct +#pragma warning disable 0169 + /* Game controller axis motion event (event.caxis.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_ControllerAxisEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public Int32 which; /* SDL_JoystickID */ + public byte axis; + private byte padding1; + private byte padding2; + private byte padding3; + public Int16 axisValue; /* value, lolC# */ + private UInt16 padding4; + } +#pragma warning restore 0169 + +// Ignore private members used for padding in this struct +#pragma warning disable 0169 + /* Game controller button event (event.cbutton.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_ControllerButtonEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public Int32 which; /* SDL_JoystickID */ + public byte button; + public byte state; + private byte padding1; + private byte padding2; + } +#pragma warning restore 0169 + + /* Game controller device event (event.cdevice.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_ControllerDeviceEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public Int32 which; /* joystick id for ADDED, + * else instance id + */ + } + +// Ignore private members used for padding in this struct +#pragma warning disable 0169 + /* Audio device event (event.adevice.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_AudioDeviceEvent + { + public UInt32 type; + public UInt32 timestamp; + public UInt32 which; + public byte iscapture; + private byte padding1; + private byte padding2; + private byte padding3; + } +#pragma warning restore 0169 + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_TouchFingerEvent + { + public UInt32 type; + public UInt32 timestamp; + public Int64 touchId; // SDL_TouchID + public Int64 fingerId; // SDL_GestureID + public float x; + public float y; + public float dx; + public float dy; + public float pressure; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_MultiGestureEvent + { + public UInt32 type; + public UInt32 timestamp; + public Int64 touchId; // SDL_TouchID + public float dTheta; + public float dDist; + public float x; + public float y; + public UInt16 numFingers; + public UInt16 padding; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_DollarGestureEvent + { + public UInt32 type; + public UInt32 timestamp; + public Int64 touchId; // SDL_TouchID + public Int64 gestureId; // SDL_GestureID + public UInt32 numFingers; + public float error; + public float x; + public float y; + } + + /* File open request by system (event.drop.*), disabled by + * default + */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_DropEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public IntPtr file; /* char* filename, to be freed */ + } + + /* The "quit requested" event */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_QuitEvent + { + public SDL_EventType type; + public UInt32 timestamp; + } + + /* A user defined event (event.user.*) */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_UserEvent + { + public UInt32 type; + public UInt32 timestamp; + public UInt32 windowID; + public Int32 code; + public IntPtr data1; /* user-defined */ + public IntPtr data2; /* user-defined */ + } + + /* A video driver dependent event (event.syswm.*), disabled */ + [StructLayout(LayoutKind.Sequential)] + public struct SDL_SysWMEvent + { + public SDL_EventType type; + public UInt32 timestamp; + public IntPtr msg; /* SDL_SysWMmsg*, system-dependent*/ + } + + /* General event structure */ + // C# doesn't do unions, so we do this ugly thing. */ + [StructLayout(LayoutKind.Explicit)] + public struct SDL_Event + { + [FieldOffset(0)] + public SDL_EventType type; + [FieldOffset(0)] + public SDL_WindowEvent window; + [FieldOffset(0)] + public SDL_KeyboardEvent key; + [FieldOffset(0)] + public SDL_TextEditingEvent edit; + [FieldOffset(0)] + public SDL_TextInputEvent text; + [FieldOffset(0)] + public SDL_MouseMotionEvent motion; + [FieldOffset(0)] + public SDL_MouseButtonEvent button; + [FieldOffset(0)] + public SDL_MouseWheelEvent wheel; + [FieldOffset(0)] + public SDL_JoyAxisEvent jaxis; + [FieldOffset(0)] + public SDL_JoyBallEvent jball; + [FieldOffset(0)] + public SDL_JoyHatEvent jhat; + [FieldOffset(0)] + public SDL_JoyButtonEvent jbutton; + [FieldOffset(0)] + public SDL_JoyDeviceEvent jdevice; + [FieldOffset(0)] + public SDL_ControllerAxisEvent caxis; + [FieldOffset(0)] + public SDL_ControllerButtonEvent cbutton; + [FieldOffset(0)] + public SDL_ControllerDeviceEvent cdevice; + [FieldOffset(0)] + public SDL_AudioDeviceEvent adevice; + [FieldOffset(0)] + public SDL_QuitEvent quit; + [FieldOffset(0)] + public SDL_UserEvent user; + [FieldOffset(0)] + public SDL_SysWMEvent syswm; + [FieldOffset(0)] + public SDL_TouchFingerEvent tfinger; + [FieldOffset(0)] + public SDL_MultiGestureEvent mgesture; + [FieldOffset(0)] + public SDL_DollarGestureEvent dgesture; + [FieldOffset(0)] + public SDL_DropEvent drop; + } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int SDL_EventFilter( + IntPtr userdata, // void* + IntPtr sdlevent // SDL_Event* event, lolC# + ); + + /* Pump the event loop, getting events from the input devices*/ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_PumpEvents(); + + public enum SDL_eventaction + { + SDL_ADDEVENT, + SDL_PEEKEVENT, + SDL_GETEVENT + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_PeepEvents( + [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 1)] + SDL_Event[] events, + int numevents, + SDL_eventaction action, + SDL_EventType minType, + SDL_EventType maxType + ); + + /* Checks to see if certain events are in the event queue */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_HasEvent(SDL_EventType type); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_HasEvents( + SDL_EventType minType, + SDL_EventType maxType + ); + + /* Clears events from the event queue */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_FlushEvent(SDL_EventType type); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_FlushEvents( + SDL_EventType min, + SDL_EventType max + ); + + /* Polls for currently pending events */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_PollEvent(out SDL_Event _event); + + /* Waits indefinitely for the next event */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_WaitEvent(out SDL_Event _event); + + /* Waits until the specified timeout (in ms) for the next event + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_WaitEventTimeout(out SDL_Event _event, int timeout); + + /* Add an event to the event queue */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_PushEvent(ref SDL_Event _event); + + /* userdata refers to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetEventFilter( + SDL_EventFilter filter, + IntPtr userdata + ); + + /* userdata refers to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + private static extern SDL_bool SDL_GetEventFilter( + out IntPtr filter, + out IntPtr userdata + ); + public static SDL_bool SDL_GetEventFilter( + out SDL_EventFilter filter, + out IntPtr userdata + ) { + IntPtr result = IntPtr.Zero; + SDL_bool retval = SDL_GetEventFilter(out result, out userdata); + if (result != IntPtr.Zero) + { + filter = (SDL_EventFilter) Marshal.GetDelegateForFunctionPointer( + result, + typeof(SDL_EventFilter) + ); + } + else + { + filter = null; + } + return retval; + } + + /* userdata refers to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_AddEventWatch( + SDL_EventFilter filter, + IntPtr userdata + ); + + /* userdata refers to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_DelEventWatch( + SDL_EventFilter filter, + IntPtr userdata + ); + + /* userdata refers to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_FilterEvents( + SDL_EventFilter filter, + IntPtr userdata + ); + + /* These are for SDL_EventState() */ + public const int SDL_QUERY = -1; + public const int SDL_IGNORE = 0; + public const int SDL_DISABLE = 0; + public const int SDL_ENABLE = 1; + + /* This function allows you to enable/disable certain events */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern byte SDL_EventState(SDL_EventType type, int state); + + /* Get the state of an event */ + public static byte SDL_GetEventState(SDL_EventType type) + { + return SDL_EventState(type, SDL_QUERY); + } + + /* Allocate a set of user-defined events */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_RegisterEvents(int numevents); + #endregion + + #region SDL_scancode.h + + /* Scancodes based off USB keyboard page (0x07) */ + public enum SDL_Scancode + { + SDL_SCANCODE_UNKNOWN = 0, + + SDL_SCANCODE_A = 4, + SDL_SCANCODE_B = 5, + SDL_SCANCODE_C = 6, + SDL_SCANCODE_D = 7, + SDL_SCANCODE_E = 8, + SDL_SCANCODE_F = 9, + SDL_SCANCODE_G = 10, + SDL_SCANCODE_H = 11, + SDL_SCANCODE_I = 12, + SDL_SCANCODE_J = 13, + SDL_SCANCODE_K = 14, + SDL_SCANCODE_L = 15, + SDL_SCANCODE_M = 16, + SDL_SCANCODE_N = 17, + SDL_SCANCODE_O = 18, + SDL_SCANCODE_P = 19, + SDL_SCANCODE_Q = 20, + SDL_SCANCODE_R = 21, + SDL_SCANCODE_S = 22, + SDL_SCANCODE_T = 23, + SDL_SCANCODE_U = 24, + SDL_SCANCODE_V = 25, + SDL_SCANCODE_W = 26, + SDL_SCANCODE_X = 27, + SDL_SCANCODE_Y = 28, + SDL_SCANCODE_Z = 29, + + SDL_SCANCODE_1 = 30, + SDL_SCANCODE_2 = 31, + SDL_SCANCODE_3 = 32, + SDL_SCANCODE_4 = 33, + SDL_SCANCODE_5 = 34, + SDL_SCANCODE_6 = 35, + SDL_SCANCODE_7 = 36, + SDL_SCANCODE_8 = 37, + SDL_SCANCODE_9 = 38, + SDL_SCANCODE_0 = 39, + + SDL_SCANCODE_RETURN = 40, + SDL_SCANCODE_ESCAPE = 41, + SDL_SCANCODE_BACKSPACE = 42, + SDL_SCANCODE_TAB = 43, + SDL_SCANCODE_SPACE = 44, + + SDL_SCANCODE_MINUS = 45, + SDL_SCANCODE_EQUALS = 46, + SDL_SCANCODE_LEFTBRACKET = 47, + SDL_SCANCODE_RIGHTBRACKET = 48, + SDL_SCANCODE_BACKSLASH = 49, + SDL_SCANCODE_NONUSHASH = 50, + SDL_SCANCODE_SEMICOLON = 51, + SDL_SCANCODE_APOSTROPHE = 52, + SDL_SCANCODE_GRAVE = 53, + SDL_SCANCODE_COMMA = 54, + SDL_SCANCODE_PERIOD = 55, + SDL_SCANCODE_SLASH = 56, + + SDL_SCANCODE_CAPSLOCK = 57, + + SDL_SCANCODE_F1 = 58, + SDL_SCANCODE_F2 = 59, + SDL_SCANCODE_F3 = 60, + SDL_SCANCODE_F4 = 61, + SDL_SCANCODE_F5 = 62, + SDL_SCANCODE_F6 = 63, + SDL_SCANCODE_F7 = 64, + SDL_SCANCODE_F8 = 65, + SDL_SCANCODE_F9 = 66, + SDL_SCANCODE_F10 = 67, + SDL_SCANCODE_F11 = 68, + SDL_SCANCODE_F12 = 69, + + SDL_SCANCODE_PRINTSCREEN = 70, + SDL_SCANCODE_SCROLLLOCK = 71, + SDL_SCANCODE_PAUSE = 72, + SDL_SCANCODE_INSERT = 73, + SDL_SCANCODE_HOME = 74, + SDL_SCANCODE_PAGEUP = 75, + SDL_SCANCODE_DELETE = 76, + SDL_SCANCODE_END = 77, + SDL_SCANCODE_PAGEDOWN = 78, + SDL_SCANCODE_RIGHT = 79, + SDL_SCANCODE_LEFT = 80, + SDL_SCANCODE_DOWN = 81, + SDL_SCANCODE_UP = 82, + + SDL_SCANCODE_NUMLOCKCLEAR = 83, + SDL_SCANCODE_KP_DIVIDE = 84, + SDL_SCANCODE_KP_MULTIPLY = 85, + SDL_SCANCODE_KP_MINUS = 86, + SDL_SCANCODE_KP_PLUS = 87, + SDL_SCANCODE_KP_ENTER = 88, + SDL_SCANCODE_KP_1 = 89, + SDL_SCANCODE_KP_2 = 90, + SDL_SCANCODE_KP_3 = 91, + SDL_SCANCODE_KP_4 = 92, + SDL_SCANCODE_KP_5 = 93, + SDL_SCANCODE_KP_6 = 94, + SDL_SCANCODE_KP_7 = 95, + SDL_SCANCODE_KP_8 = 96, + SDL_SCANCODE_KP_9 = 97, + SDL_SCANCODE_KP_0 = 98, + SDL_SCANCODE_KP_PERIOD = 99, + + SDL_SCANCODE_NONUSBACKSLASH = 100, + SDL_SCANCODE_APPLICATION = 101, + SDL_SCANCODE_POWER = 102, + SDL_SCANCODE_KP_EQUALS = 103, + SDL_SCANCODE_F13 = 104, + SDL_SCANCODE_F14 = 105, + SDL_SCANCODE_F15 = 106, + SDL_SCANCODE_F16 = 107, + SDL_SCANCODE_F17 = 108, + SDL_SCANCODE_F18 = 109, + SDL_SCANCODE_F19 = 110, + SDL_SCANCODE_F20 = 111, + SDL_SCANCODE_F21 = 112, + SDL_SCANCODE_F22 = 113, + SDL_SCANCODE_F23 = 114, + SDL_SCANCODE_F24 = 115, + SDL_SCANCODE_EXECUTE = 116, + SDL_SCANCODE_HELP = 117, + SDL_SCANCODE_MENU = 118, + SDL_SCANCODE_SELECT = 119, + SDL_SCANCODE_STOP = 120, + SDL_SCANCODE_AGAIN = 121, + SDL_SCANCODE_UNDO = 122, + SDL_SCANCODE_CUT = 123, + SDL_SCANCODE_COPY = 124, + SDL_SCANCODE_PASTE = 125, + SDL_SCANCODE_FIND = 126, + SDL_SCANCODE_MUTE = 127, + SDL_SCANCODE_VOLUMEUP = 128, + SDL_SCANCODE_VOLUMEDOWN = 129, + /* not sure whether there's a reason to enable these */ + /* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */ + /* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */ + /* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */ + SDL_SCANCODE_KP_COMMA = 133, + SDL_SCANCODE_KP_EQUALSAS400 = 134, + + SDL_SCANCODE_INTERNATIONAL1 = 135, + SDL_SCANCODE_INTERNATIONAL2 = 136, + SDL_SCANCODE_INTERNATIONAL3 = 137, + SDL_SCANCODE_INTERNATIONAL4 = 138, + SDL_SCANCODE_INTERNATIONAL5 = 139, + SDL_SCANCODE_INTERNATIONAL6 = 140, + SDL_SCANCODE_INTERNATIONAL7 = 141, + SDL_SCANCODE_INTERNATIONAL8 = 142, + SDL_SCANCODE_INTERNATIONAL9 = 143, + SDL_SCANCODE_LANG1 = 144, + SDL_SCANCODE_LANG2 = 145, + SDL_SCANCODE_LANG3 = 146, + SDL_SCANCODE_LANG4 = 147, + SDL_SCANCODE_LANG5 = 148, + SDL_SCANCODE_LANG6 = 149, + SDL_SCANCODE_LANG7 = 150, + SDL_SCANCODE_LANG8 = 151, + SDL_SCANCODE_LANG9 = 152, + + SDL_SCANCODE_ALTERASE = 153, + SDL_SCANCODE_SYSREQ = 154, + SDL_SCANCODE_CANCEL = 155, + SDL_SCANCODE_CLEAR = 156, + SDL_SCANCODE_PRIOR = 157, + SDL_SCANCODE_RETURN2 = 158, + SDL_SCANCODE_SEPARATOR = 159, + SDL_SCANCODE_OUT = 160, + SDL_SCANCODE_OPER = 161, + SDL_SCANCODE_CLEARAGAIN = 162, + SDL_SCANCODE_CRSEL = 163, + SDL_SCANCODE_EXSEL = 164, + + SDL_SCANCODE_KP_00 = 176, + SDL_SCANCODE_KP_000 = 177, + SDL_SCANCODE_THOUSANDSSEPARATOR = 178, + SDL_SCANCODE_DECIMALSEPARATOR = 179, + SDL_SCANCODE_CURRENCYUNIT = 180, + SDL_SCANCODE_CURRENCYSUBUNIT = 181, + SDL_SCANCODE_KP_LEFTPAREN = 182, + SDL_SCANCODE_KP_RIGHTPAREN = 183, + SDL_SCANCODE_KP_LEFTBRACE = 184, + SDL_SCANCODE_KP_RIGHTBRACE = 185, + SDL_SCANCODE_KP_TAB = 186, + SDL_SCANCODE_KP_BACKSPACE = 187, + SDL_SCANCODE_KP_A = 188, + SDL_SCANCODE_KP_B = 189, + SDL_SCANCODE_KP_C = 190, + SDL_SCANCODE_KP_D = 191, + SDL_SCANCODE_KP_E = 192, + SDL_SCANCODE_KP_F = 193, + SDL_SCANCODE_KP_XOR = 194, + SDL_SCANCODE_KP_POWER = 195, + SDL_SCANCODE_KP_PERCENT = 196, + SDL_SCANCODE_KP_LESS = 197, + SDL_SCANCODE_KP_GREATER = 198, + SDL_SCANCODE_KP_AMPERSAND = 199, + SDL_SCANCODE_KP_DBLAMPERSAND = 200, + SDL_SCANCODE_KP_VERTICALBAR = 201, + SDL_SCANCODE_KP_DBLVERTICALBAR = 202, + SDL_SCANCODE_KP_COLON = 203, + SDL_SCANCODE_KP_HASH = 204, + SDL_SCANCODE_KP_SPACE = 205, + SDL_SCANCODE_KP_AT = 206, + SDL_SCANCODE_KP_EXCLAM = 207, + SDL_SCANCODE_KP_MEMSTORE = 208, + SDL_SCANCODE_KP_MEMRECALL = 209, + SDL_SCANCODE_KP_MEMCLEAR = 210, + SDL_SCANCODE_KP_MEMADD = 211, + SDL_SCANCODE_KP_MEMSUBTRACT = 212, + SDL_SCANCODE_KP_MEMMULTIPLY = 213, + SDL_SCANCODE_KP_MEMDIVIDE = 214, + SDL_SCANCODE_KP_PLUSMINUS = 215, + SDL_SCANCODE_KP_CLEAR = 216, + SDL_SCANCODE_KP_CLEARENTRY = 217, + SDL_SCANCODE_KP_BINARY = 218, + SDL_SCANCODE_KP_OCTAL = 219, + SDL_SCANCODE_KP_DECIMAL = 220, + SDL_SCANCODE_KP_HEXADECIMAL = 221, + + SDL_SCANCODE_LCTRL = 224, + SDL_SCANCODE_LSHIFT = 225, + SDL_SCANCODE_LALT = 226, + SDL_SCANCODE_LGUI = 227, + SDL_SCANCODE_RCTRL = 228, + SDL_SCANCODE_RSHIFT = 229, + SDL_SCANCODE_RALT = 230, + SDL_SCANCODE_RGUI = 231, + + SDL_SCANCODE_MODE = 257, + + /* These come from the USB consumer page (0x0C) */ + SDL_SCANCODE_AUDIONEXT = 258, + SDL_SCANCODE_AUDIOPREV = 259, + SDL_SCANCODE_AUDIOSTOP = 260, + SDL_SCANCODE_AUDIOPLAY = 261, + SDL_SCANCODE_AUDIOMUTE = 262, + SDL_SCANCODE_MEDIASELECT = 263, + SDL_SCANCODE_WWW = 264, + SDL_SCANCODE_MAIL = 265, + SDL_SCANCODE_CALCULATOR = 266, + SDL_SCANCODE_COMPUTER = 267, + SDL_SCANCODE_AC_SEARCH = 268, + SDL_SCANCODE_AC_HOME = 269, + SDL_SCANCODE_AC_BACK = 270, + SDL_SCANCODE_AC_FORWARD = 271, + SDL_SCANCODE_AC_STOP = 272, + SDL_SCANCODE_AC_REFRESH = 273, + SDL_SCANCODE_AC_BOOKMARKS = 274, + + /* These come from other sources, and are mostly mac related */ + SDL_SCANCODE_BRIGHTNESSDOWN = 275, + SDL_SCANCODE_BRIGHTNESSUP = 276, + SDL_SCANCODE_DISPLAYSWITCH = 277, + SDL_SCANCODE_KBDILLUMTOGGLE = 278, + SDL_SCANCODE_KBDILLUMDOWN = 279, + SDL_SCANCODE_KBDILLUMUP = 280, + SDL_SCANCODE_EJECT = 281, + SDL_SCANCODE_SLEEP = 282, + + SDL_SCANCODE_APP1 = 283, + SDL_SCANCODE_APP2 = 284, + + /* This is not a key, simply marks the number of scancodes + * so that you know how big to make your arrays. */ + SDL_NUM_SCANCODES = 512 + } + + #endregion + + #region SDL_keycode.h + + public const int SDLK_SCANCODE_MASK = (1 << 30); + public static SDL_Keycode SDL_SCANCODE_TO_KEYCODE(SDL_Scancode X) + { + return (SDL_Keycode)((int)X | SDLK_SCANCODE_MASK); + } + + /* So, in the C headers, SDL_Keycode is a typedef of Sint32 + * and all of the names are in an anonymous enum. Yeah... + * that's not going to cut it for C#. We'll just put them in an + * enum for now? */ + public enum SDL_Keycode + { + SDLK_UNKNOWN = 0, + + SDLK_RETURN = '\r', + SDLK_ESCAPE = 27, // '\033' + SDLK_BACKSPACE = '\b', + SDLK_TAB = '\t', + SDLK_SPACE = ' ', + SDLK_EXCLAIM = '!', + SDLK_QUOTEDBL = '"', + SDLK_HASH = '#', + SDLK_PERCENT = '%', + SDLK_DOLLAR = '$', + SDLK_AMPERSAND = '&', + SDLK_QUOTE = '\'', + SDLK_LEFTPAREN = '(', + SDLK_RIGHTPAREN = ')', + SDLK_ASTERISK = '*', + SDLK_PLUS = '+', + SDLK_COMMA = ',', + SDLK_MINUS = '-', + SDLK_PERIOD = '.', + SDLK_SLASH = '/', + SDLK_0 = '0', + SDLK_1 = '1', + SDLK_2 = '2', + SDLK_3 = '3', + SDLK_4 = '4', + SDLK_5 = '5', + SDLK_6 = '6', + SDLK_7 = '7', + SDLK_8 = '8', + SDLK_9 = '9', + SDLK_COLON = ':', + SDLK_SEMICOLON = ';', + SDLK_LESS = '<', + SDLK_EQUALS = '=', + SDLK_GREATER = '>', + SDLK_QUESTION = '?', + SDLK_AT = '@', + /* + Skip uppercase letters + */ + SDLK_LEFTBRACKET = '[', + SDLK_BACKSLASH = '\\', + SDLK_RIGHTBRACKET = ']', + SDLK_CARET = '^', + SDLK_UNDERSCORE = '_', + SDLK_BACKQUOTE = '`', + SDLK_a = 'a', + SDLK_b = 'b', + SDLK_c = 'c', + SDLK_d = 'd', + SDLK_e = 'e', + SDLK_f = 'f', + SDLK_g = 'g', + SDLK_h = 'h', + SDLK_i = 'i', + SDLK_j = 'j', + SDLK_k = 'k', + SDLK_l = 'l', + SDLK_m = 'm', + SDLK_n = 'n', + SDLK_o = 'o', + SDLK_p = 'p', + SDLK_q = 'q', + SDLK_r = 'r', + SDLK_s = 's', + SDLK_t = 't', + SDLK_u = 'u', + SDLK_v = 'v', + SDLK_w = 'w', + SDLK_x = 'x', + SDLK_y = 'y', + SDLK_z = 'z', + + SDLK_CAPSLOCK = (int)SDL_Scancode.SDL_SCANCODE_CAPSLOCK | SDLK_SCANCODE_MASK, + + SDLK_F1 = (int)SDL_Scancode.SDL_SCANCODE_F1 | SDLK_SCANCODE_MASK, + SDLK_F2 = (int)SDL_Scancode.SDL_SCANCODE_F2 | SDLK_SCANCODE_MASK, + SDLK_F3 = (int)SDL_Scancode.SDL_SCANCODE_F3 | SDLK_SCANCODE_MASK, + SDLK_F4 = (int)SDL_Scancode.SDL_SCANCODE_F4 | SDLK_SCANCODE_MASK, + SDLK_F5 = (int)SDL_Scancode.SDL_SCANCODE_F5 | SDLK_SCANCODE_MASK, + SDLK_F6 = (int)SDL_Scancode.SDL_SCANCODE_F6 | SDLK_SCANCODE_MASK, + SDLK_F7 = (int)SDL_Scancode.SDL_SCANCODE_F7 | SDLK_SCANCODE_MASK, + SDLK_F8 = (int)SDL_Scancode.SDL_SCANCODE_F8 | SDLK_SCANCODE_MASK, + SDLK_F9 = (int)SDL_Scancode.SDL_SCANCODE_F9 | SDLK_SCANCODE_MASK, + SDLK_F10 = (int)SDL_Scancode.SDL_SCANCODE_F10 | SDLK_SCANCODE_MASK, + SDLK_F11 = (int)SDL_Scancode.SDL_SCANCODE_F11 | SDLK_SCANCODE_MASK, + SDLK_F12 = (int)SDL_Scancode.SDL_SCANCODE_F12 | SDLK_SCANCODE_MASK, + + SDLK_PRINTSCREEN = (int)SDL_Scancode.SDL_SCANCODE_PRINTSCREEN | SDLK_SCANCODE_MASK, + SDLK_SCROLLLOCK = (int)SDL_Scancode.SDL_SCANCODE_SCROLLLOCK | SDLK_SCANCODE_MASK, + SDLK_PAUSE = (int)SDL_Scancode.SDL_SCANCODE_PAUSE | SDLK_SCANCODE_MASK, + SDLK_INSERT = (int)SDL_Scancode.SDL_SCANCODE_INSERT | SDLK_SCANCODE_MASK, + SDLK_HOME = (int)SDL_Scancode.SDL_SCANCODE_HOME | SDLK_SCANCODE_MASK, + SDLK_PAGEUP = (int)SDL_Scancode.SDL_SCANCODE_PAGEUP | SDLK_SCANCODE_MASK, + SDLK_DELETE = 127, + SDLK_END = (int)SDL_Scancode.SDL_SCANCODE_END | SDLK_SCANCODE_MASK, + SDLK_PAGEDOWN = (int)SDL_Scancode.SDL_SCANCODE_PAGEDOWN | SDLK_SCANCODE_MASK, + SDLK_RIGHT = (int)SDL_Scancode.SDL_SCANCODE_RIGHT | SDLK_SCANCODE_MASK, + SDLK_LEFT = (int)SDL_Scancode.SDL_SCANCODE_LEFT | SDLK_SCANCODE_MASK, + SDLK_DOWN = (int)SDL_Scancode.SDL_SCANCODE_DOWN | SDLK_SCANCODE_MASK, + SDLK_UP = (int)SDL_Scancode.SDL_SCANCODE_UP | SDLK_SCANCODE_MASK, + + SDLK_NUMLOCKCLEAR = (int)SDL_Scancode.SDL_SCANCODE_NUMLOCKCLEAR | SDLK_SCANCODE_MASK, + SDLK_KP_DIVIDE = (int)SDL_Scancode.SDL_SCANCODE_KP_DIVIDE | SDLK_SCANCODE_MASK, + SDLK_KP_MULTIPLY = (int)SDL_Scancode.SDL_SCANCODE_KP_MULTIPLY | SDLK_SCANCODE_MASK, + SDLK_KP_MINUS = (int)SDL_Scancode.SDL_SCANCODE_KP_MINUS | SDLK_SCANCODE_MASK, + SDLK_KP_PLUS = (int)SDL_Scancode.SDL_SCANCODE_KP_PLUS | SDLK_SCANCODE_MASK, + SDLK_KP_ENTER = (int)SDL_Scancode.SDL_SCANCODE_KP_ENTER | SDLK_SCANCODE_MASK, + SDLK_KP_1 = (int)SDL_Scancode.SDL_SCANCODE_KP_1 | SDLK_SCANCODE_MASK, + SDLK_KP_2 = (int)SDL_Scancode.SDL_SCANCODE_KP_2 | SDLK_SCANCODE_MASK, + SDLK_KP_3 = (int)SDL_Scancode.SDL_SCANCODE_KP_3 | SDLK_SCANCODE_MASK, + SDLK_KP_4 = (int)SDL_Scancode.SDL_SCANCODE_KP_4 | SDLK_SCANCODE_MASK, + SDLK_KP_5 = (int)SDL_Scancode.SDL_SCANCODE_KP_5 | SDLK_SCANCODE_MASK, + SDLK_KP_6 = (int)SDL_Scancode.SDL_SCANCODE_KP_6 | SDLK_SCANCODE_MASK, + SDLK_KP_7 = (int)SDL_Scancode.SDL_SCANCODE_KP_7 | SDLK_SCANCODE_MASK, + SDLK_KP_8 = (int)SDL_Scancode.SDL_SCANCODE_KP_8 | SDLK_SCANCODE_MASK, + SDLK_KP_9 = (int)SDL_Scancode.SDL_SCANCODE_KP_9 | SDLK_SCANCODE_MASK, + SDLK_KP_0 = (int)SDL_Scancode.SDL_SCANCODE_KP_0 | SDLK_SCANCODE_MASK, + SDLK_KP_PERIOD = (int)SDL_Scancode.SDL_SCANCODE_KP_PERIOD | SDLK_SCANCODE_MASK, + + SDLK_APPLICATION = (int)SDL_Scancode.SDL_SCANCODE_APPLICATION | SDLK_SCANCODE_MASK, + SDLK_POWER = (int)SDL_Scancode.SDL_SCANCODE_POWER | SDLK_SCANCODE_MASK, + SDLK_KP_EQUALS = (int)SDL_Scancode.SDL_SCANCODE_KP_EQUALS | SDLK_SCANCODE_MASK, + SDLK_F13 = (int)SDL_Scancode.SDL_SCANCODE_F13 | SDLK_SCANCODE_MASK, + SDLK_F14 = (int)SDL_Scancode.SDL_SCANCODE_F14 | SDLK_SCANCODE_MASK, + SDLK_F15 = (int)SDL_Scancode.SDL_SCANCODE_F15 | SDLK_SCANCODE_MASK, + SDLK_F16 = (int)SDL_Scancode.SDL_SCANCODE_F16 | SDLK_SCANCODE_MASK, + SDLK_F17 = (int)SDL_Scancode.SDL_SCANCODE_F17 | SDLK_SCANCODE_MASK, + SDLK_F18 = (int)SDL_Scancode.SDL_SCANCODE_F18 | SDLK_SCANCODE_MASK, + SDLK_F19 = (int)SDL_Scancode.SDL_SCANCODE_F19 | SDLK_SCANCODE_MASK, + SDLK_F20 = (int)SDL_Scancode.SDL_SCANCODE_F20 | SDLK_SCANCODE_MASK, + SDLK_F21 = (int)SDL_Scancode.SDL_SCANCODE_F21 | SDLK_SCANCODE_MASK, + SDLK_F22 = (int)SDL_Scancode.SDL_SCANCODE_F22 | SDLK_SCANCODE_MASK, + SDLK_F23 = (int)SDL_Scancode.SDL_SCANCODE_F23 | SDLK_SCANCODE_MASK, + SDLK_F24 = (int)SDL_Scancode.SDL_SCANCODE_F24 | SDLK_SCANCODE_MASK, + SDLK_EXECUTE = (int)SDL_Scancode.SDL_SCANCODE_EXECUTE | SDLK_SCANCODE_MASK, + SDLK_HELP = (int)SDL_Scancode.SDL_SCANCODE_HELP | SDLK_SCANCODE_MASK, + SDLK_MENU = (int)SDL_Scancode.SDL_SCANCODE_MENU | SDLK_SCANCODE_MASK, + SDLK_SELECT = (int)SDL_Scancode.SDL_SCANCODE_SELECT | SDLK_SCANCODE_MASK, + SDLK_STOP = (int)SDL_Scancode.SDL_SCANCODE_STOP | SDLK_SCANCODE_MASK, + SDLK_AGAIN = (int)SDL_Scancode.SDL_SCANCODE_AGAIN | SDLK_SCANCODE_MASK, + SDLK_UNDO = (int)SDL_Scancode.SDL_SCANCODE_UNDO | SDLK_SCANCODE_MASK, + SDLK_CUT = (int)SDL_Scancode.SDL_SCANCODE_CUT | SDLK_SCANCODE_MASK, + SDLK_COPY = (int)SDL_Scancode.SDL_SCANCODE_COPY | SDLK_SCANCODE_MASK, + SDLK_PASTE = (int)SDL_Scancode.SDL_SCANCODE_PASTE | SDLK_SCANCODE_MASK, + SDLK_FIND = (int)SDL_Scancode.SDL_SCANCODE_FIND | SDLK_SCANCODE_MASK, + SDLK_MUTE = (int)SDL_Scancode.SDL_SCANCODE_MUTE | SDLK_SCANCODE_MASK, + SDLK_VOLUMEUP = (int)SDL_Scancode.SDL_SCANCODE_VOLUMEUP | SDLK_SCANCODE_MASK, + SDLK_VOLUMEDOWN = (int)SDL_Scancode.SDL_SCANCODE_VOLUMEDOWN | SDLK_SCANCODE_MASK, + SDLK_KP_COMMA = (int)SDL_Scancode.SDL_SCANCODE_KP_COMMA | SDLK_SCANCODE_MASK, + SDLK_KP_EQUALSAS400 = + (int)SDL_Scancode.SDL_SCANCODE_KP_EQUALSAS400 | SDLK_SCANCODE_MASK, + + SDLK_ALTERASE = (int)SDL_Scancode.SDL_SCANCODE_ALTERASE | SDLK_SCANCODE_MASK, + SDLK_SYSREQ = (int)SDL_Scancode.SDL_SCANCODE_SYSREQ | SDLK_SCANCODE_MASK, + SDLK_CANCEL = (int)SDL_Scancode.SDL_SCANCODE_CANCEL | SDLK_SCANCODE_MASK, + SDLK_CLEAR = (int)SDL_Scancode.SDL_SCANCODE_CLEAR | SDLK_SCANCODE_MASK, + SDLK_PRIOR = (int)SDL_Scancode.SDL_SCANCODE_PRIOR | SDLK_SCANCODE_MASK, + SDLK_RETURN2 = (int)SDL_Scancode.SDL_SCANCODE_RETURN2 | SDLK_SCANCODE_MASK, + SDLK_SEPARATOR = (int)SDL_Scancode.SDL_SCANCODE_SEPARATOR | SDLK_SCANCODE_MASK, + SDLK_OUT = (int)SDL_Scancode.SDL_SCANCODE_OUT | SDLK_SCANCODE_MASK, + SDLK_OPER = (int)SDL_Scancode.SDL_SCANCODE_OPER | SDLK_SCANCODE_MASK, + SDLK_CLEARAGAIN = (int)SDL_Scancode.SDL_SCANCODE_CLEARAGAIN | SDLK_SCANCODE_MASK, + SDLK_CRSEL = (int)SDL_Scancode.SDL_SCANCODE_CRSEL | SDLK_SCANCODE_MASK, + SDLK_EXSEL = (int)SDL_Scancode.SDL_SCANCODE_EXSEL | SDLK_SCANCODE_MASK, + + SDLK_KP_00 = (int)SDL_Scancode.SDL_SCANCODE_KP_00 | SDLK_SCANCODE_MASK, + SDLK_KP_000 = (int)SDL_Scancode.SDL_SCANCODE_KP_000 | SDLK_SCANCODE_MASK, + SDLK_THOUSANDSSEPARATOR = + (int)SDL_Scancode.SDL_SCANCODE_THOUSANDSSEPARATOR | SDLK_SCANCODE_MASK, + SDLK_DECIMALSEPARATOR = + (int)SDL_Scancode.SDL_SCANCODE_DECIMALSEPARATOR | SDLK_SCANCODE_MASK, + SDLK_CURRENCYUNIT = (int)SDL_Scancode.SDL_SCANCODE_CURRENCYUNIT | SDLK_SCANCODE_MASK, + SDLK_CURRENCYSUBUNIT = + (int)SDL_Scancode.SDL_SCANCODE_CURRENCYSUBUNIT | SDLK_SCANCODE_MASK, + SDLK_KP_LEFTPAREN = (int)SDL_Scancode.SDL_SCANCODE_KP_LEFTPAREN | SDLK_SCANCODE_MASK, + SDLK_KP_RIGHTPAREN = (int)SDL_Scancode.SDL_SCANCODE_KP_RIGHTPAREN | SDLK_SCANCODE_MASK, + SDLK_KP_LEFTBRACE = (int)SDL_Scancode.SDL_SCANCODE_KP_LEFTBRACE | SDLK_SCANCODE_MASK, + SDLK_KP_RIGHTBRACE = (int)SDL_Scancode.SDL_SCANCODE_KP_RIGHTBRACE | SDLK_SCANCODE_MASK, + SDLK_KP_TAB = (int)SDL_Scancode.SDL_SCANCODE_KP_TAB | SDLK_SCANCODE_MASK, + SDLK_KP_BACKSPACE = (int)SDL_Scancode.SDL_SCANCODE_KP_BACKSPACE | SDLK_SCANCODE_MASK, + SDLK_KP_A = (int)SDL_Scancode.SDL_SCANCODE_KP_A | SDLK_SCANCODE_MASK, + SDLK_KP_B = (int)SDL_Scancode.SDL_SCANCODE_KP_B | SDLK_SCANCODE_MASK, + SDLK_KP_C = (int)SDL_Scancode.SDL_SCANCODE_KP_C | SDLK_SCANCODE_MASK, + SDLK_KP_D = (int)SDL_Scancode.SDL_SCANCODE_KP_D | SDLK_SCANCODE_MASK, + SDLK_KP_E = (int)SDL_Scancode.SDL_SCANCODE_KP_E | SDLK_SCANCODE_MASK, + SDLK_KP_F = (int)SDL_Scancode.SDL_SCANCODE_KP_F | SDLK_SCANCODE_MASK, + SDLK_KP_XOR = (int)SDL_Scancode.SDL_SCANCODE_KP_XOR | SDLK_SCANCODE_MASK, + SDLK_KP_POWER = (int)SDL_Scancode.SDL_SCANCODE_KP_POWER | SDLK_SCANCODE_MASK, + SDLK_KP_PERCENT = (int)SDL_Scancode.SDL_SCANCODE_KP_PERCENT | SDLK_SCANCODE_MASK, + SDLK_KP_LESS = (int)SDL_Scancode.SDL_SCANCODE_KP_LESS | SDLK_SCANCODE_MASK, + SDLK_KP_GREATER = (int)SDL_Scancode.SDL_SCANCODE_KP_GREATER | SDLK_SCANCODE_MASK, + SDLK_KP_AMPERSAND = (int)SDL_Scancode.SDL_SCANCODE_KP_AMPERSAND | SDLK_SCANCODE_MASK, + SDLK_KP_DBLAMPERSAND = + (int)SDL_Scancode.SDL_SCANCODE_KP_DBLAMPERSAND | SDLK_SCANCODE_MASK, + SDLK_KP_VERTICALBAR = + (int)SDL_Scancode.SDL_SCANCODE_KP_VERTICALBAR | SDLK_SCANCODE_MASK, + SDLK_KP_DBLVERTICALBAR = + (int)SDL_Scancode.SDL_SCANCODE_KP_DBLVERTICALBAR | SDLK_SCANCODE_MASK, + SDLK_KP_COLON = (int)SDL_Scancode.SDL_SCANCODE_KP_COLON | SDLK_SCANCODE_MASK, + SDLK_KP_HASH = (int)SDL_Scancode.SDL_SCANCODE_KP_HASH | SDLK_SCANCODE_MASK, + SDLK_KP_SPACE = (int)SDL_Scancode.SDL_SCANCODE_KP_SPACE | SDLK_SCANCODE_MASK, + SDLK_KP_AT = (int)SDL_Scancode.SDL_SCANCODE_KP_AT | SDLK_SCANCODE_MASK, + SDLK_KP_EXCLAM = (int)SDL_Scancode.SDL_SCANCODE_KP_EXCLAM | SDLK_SCANCODE_MASK, + SDLK_KP_MEMSTORE = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMSTORE | SDLK_SCANCODE_MASK, + SDLK_KP_MEMRECALL = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMRECALL | SDLK_SCANCODE_MASK, + SDLK_KP_MEMCLEAR = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMCLEAR | SDLK_SCANCODE_MASK, + SDLK_KP_MEMADD = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMADD | SDLK_SCANCODE_MASK, + SDLK_KP_MEMSUBTRACT = + (int)SDL_Scancode.SDL_SCANCODE_KP_MEMSUBTRACT | SDLK_SCANCODE_MASK, + SDLK_KP_MEMMULTIPLY = + (int)SDL_Scancode.SDL_SCANCODE_KP_MEMMULTIPLY | SDLK_SCANCODE_MASK, + SDLK_KP_MEMDIVIDE = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMDIVIDE | SDLK_SCANCODE_MASK, + SDLK_KP_PLUSMINUS = (int)SDL_Scancode.SDL_SCANCODE_KP_PLUSMINUS | SDLK_SCANCODE_MASK, + SDLK_KP_CLEAR = (int)SDL_Scancode.SDL_SCANCODE_KP_CLEAR | SDLK_SCANCODE_MASK, + SDLK_KP_CLEARENTRY = (int)SDL_Scancode.SDL_SCANCODE_KP_CLEARENTRY | SDLK_SCANCODE_MASK, + SDLK_KP_BINARY = (int)SDL_Scancode.SDL_SCANCODE_KP_BINARY | SDLK_SCANCODE_MASK, + SDLK_KP_OCTAL = (int)SDL_Scancode.SDL_SCANCODE_KP_OCTAL | SDLK_SCANCODE_MASK, + SDLK_KP_DECIMAL = (int)SDL_Scancode.SDL_SCANCODE_KP_DECIMAL | SDLK_SCANCODE_MASK, + SDLK_KP_HEXADECIMAL = + (int)SDL_Scancode.SDL_SCANCODE_KP_HEXADECIMAL | SDLK_SCANCODE_MASK, + + SDLK_LCTRL = (int)SDL_Scancode.SDL_SCANCODE_LCTRL | SDLK_SCANCODE_MASK, + SDLK_LSHIFT = (int)SDL_Scancode.SDL_SCANCODE_LSHIFT | SDLK_SCANCODE_MASK, + SDLK_LALT = (int)SDL_Scancode.SDL_SCANCODE_LALT | SDLK_SCANCODE_MASK, + SDLK_LGUI = (int)SDL_Scancode.SDL_SCANCODE_LGUI | SDLK_SCANCODE_MASK, + SDLK_RCTRL = (int)SDL_Scancode.SDL_SCANCODE_RCTRL | SDLK_SCANCODE_MASK, + SDLK_RSHIFT = (int)SDL_Scancode.SDL_SCANCODE_RSHIFT | SDLK_SCANCODE_MASK, + SDLK_RALT = (int)SDL_Scancode.SDL_SCANCODE_RALT | SDLK_SCANCODE_MASK, + SDLK_RGUI = (int)SDL_Scancode.SDL_SCANCODE_RGUI | SDLK_SCANCODE_MASK, + + SDLK_MODE = (int)SDL_Scancode.SDL_SCANCODE_MODE | SDLK_SCANCODE_MASK, + + SDLK_AUDIONEXT = (int)SDL_Scancode.SDL_SCANCODE_AUDIONEXT | SDLK_SCANCODE_MASK, + SDLK_AUDIOPREV = (int)SDL_Scancode.SDL_SCANCODE_AUDIOPREV | SDLK_SCANCODE_MASK, + SDLK_AUDIOSTOP = (int)SDL_Scancode.SDL_SCANCODE_AUDIOSTOP | SDLK_SCANCODE_MASK, + SDLK_AUDIOPLAY = (int)SDL_Scancode.SDL_SCANCODE_AUDIOPLAY | SDLK_SCANCODE_MASK, + SDLK_AUDIOMUTE = (int)SDL_Scancode.SDL_SCANCODE_AUDIOMUTE | SDLK_SCANCODE_MASK, + SDLK_MEDIASELECT = (int)SDL_Scancode.SDL_SCANCODE_MEDIASELECT | SDLK_SCANCODE_MASK, + SDLK_WWW = (int)SDL_Scancode.SDL_SCANCODE_WWW | SDLK_SCANCODE_MASK, + SDLK_MAIL = (int)SDL_Scancode.SDL_SCANCODE_MAIL | SDLK_SCANCODE_MASK, + SDLK_CALCULATOR = (int)SDL_Scancode.SDL_SCANCODE_CALCULATOR | SDLK_SCANCODE_MASK, + SDLK_COMPUTER = (int)SDL_Scancode.SDL_SCANCODE_COMPUTER | SDLK_SCANCODE_MASK, + SDLK_AC_SEARCH = (int)SDL_Scancode.SDL_SCANCODE_AC_SEARCH | SDLK_SCANCODE_MASK, + SDLK_AC_HOME = (int)SDL_Scancode.SDL_SCANCODE_AC_HOME | SDLK_SCANCODE_MASK, + SDLK_AC_BACK = (int)SDL_Scancode.SDL_SCANCODE_AC_BACK | SDLK_SCANCODE_MASK, + SDLK_AC_FORWARD = (int)SDL_Scancode.SDL_SCANCODE_AC_FORWARD | SDLK_SCANCODE_MASK, + SDLK_AC_STOP = (int)SDL_Scancode.SDL_SCANCODE_AC_STOP | SDLK_SCANCODE_MASK, + SDLK_AC_REFRESH = (int)SDL_Scancode.SDL_SCANCODE_AC_REFRESH | SDLK_SCANCODE_MASK, + SDLK_AC_BOOKMARKS = (int)SDL_Scancode.SDL_SCANCODE_AC_BOOKMARKS | SDLK_SCANCODE_MASK, + + SDLK_BRIGHTNESSDOWN = + (int)SDL_Scancode.SDL_SCANCODE_BRIGHTNESSDOWN | SDLK_SCANCODE_MASK, + SDLK_BRIGHTNESSUP = (int)SDL_Scancode.SDL_SCANCODE_BRIGHTNESSUP | SDLK_SCANCODE_MASK, + SDLK_DISPLAYSWITCH = (int)SDL_Scancode.SDL_SCANCODE_DISPLAYSWITCH | SDLK_SCANCODE_MASK, + SDLK_KBDILLUMTOGGLE = + (int)SDL_Scancode.SDL_SCANCODE_KBDILLUMTOGGLE | SDLK_SCANCODE_MASK, + SDLK_KBDILLUMDOWN = (int)SDL_Scancode.SDL_SCANCODE_KBDILLUMDOWN | SDLK_SCANCODE_MASK, + SDLK_KBDILLUMUP = (int)SDL_Scancode.SDL_SCANCODE_KBDILLUMUP | SDLK_SCANCODE_MASK, + SDLK_EJECT = (int)SDL_Scancode.SDL_SCANCODE_EJECT | SDLK_SCANCODE_MASK, + SDLK_SLEEP = (int)SDL_Scancode.SDL_SCANCODE_SLEEP | SDLK_SCANCODE_MASK + } + + /* Key modifiers (bitfield) */ + [Flags] + public enum SDL_Keymod : ushort + { + KMOD_NONE = 0x0000, + KMOD_LSHIFT = 0x0001, + KMOD_RSHIFT = 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LGUI = 0x0400, + KMOD_RGUI = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000, + + /* These are defines in the SDL headers */ + KMOD_CTRL = (KMOD_LCTRL | KMOD_RCTRL), + KMOD_SHIFT = (KMOD_LSHIFT | KMOD_RSHIFT), + KMOD_ALT = (KMOD_LALT | KMOD_RALT), + KMOD_GUI = (KMOD_LGUI | KMOD_RGUI) + } + + #endregion + + #region SDL_keyboard.h + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_Keysym + { + public SDL_Scancode scancode; + public SDL_Keycode sym; + public SDL_Keymod mod; /* UInt16 */ + public UInt32 unicode; /* Deprecated */ + } + + /* Get the window which has kbd focus */ + /* Return type is an SDL_Window pointer */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetKeyboardFocus(); + + /* Get a snapshot of the keyboard state. */ + /* Return value is a pointer to a UInt8 array */ + /* Numkeys returns the size of the array if non-null */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetKeyboardState(out int numkeys); + + /* Get the current key modifier state for the keyboard. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_Keymod SDL_GetModState(); + + /* Set the current key modifier state */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetModState(SDL_Keymod modstate); + + /* Get the key code corresponding to the given scancode + * with the current keyboard layout. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode); + + /* Get the scancode for the given keycode */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key); + + /* Wrapper for SDL_GetScancodeName */ + [DllImport(nativeLibName, EntryPoint = "SDL_GetScancodeName", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetScancodeName(SDL_Scancode scancode); + public static string SDL_GetScancodeName(SDL_Scancode scancode) + { + return UTF8_ToManaged( + INTERNAL_SDL_GetScancodeName(scancode) + ); + } + + /* Get a scancode from a human-readable name */ + [DllImport(nativeLibName, EntryPoint = "SDL_GetScancodeFromName", CallingConvention = CallingConvention.Cdecl)] + private static extern SDL_Scancode INTERNAL_SDL_GetScancodeFromName( + byte[] name + ); + public static SDL_Scancode SDL_GetScancodeFromName(string name) + { + return INTERNAL_SDL_GetScancodeFromName( + UTF8_ToNative(name) + ); + } + + /* Wrapper for SDL_GetKeyName */ + [DllImport(nativeLibName, EntryPoint = "SDL_GetKeyName", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetKeyName(SDL_Keycode key); + public static string SDL_GetKeyName(SDL_Keycode key) + { + return UTF8_ToManaged(INTERNAL_SDL_GetKeyName(key)); + } + + /* Get a key code from a human-readable name */ + [DllImport(nativeLibName, EntryPoint = "SDL_GetKeyFromName", CallingConvention = CallingConvention.Cdecl)] + private static extern SDL_Keycode INTERNAL_SDL_GetKeyFromName( + byte[] name + ); + public static SDL_Keycode SDL_GetKeyFromName(string name) + { + return INTERNAL_SDL_GetKeyFromName(UTF8_ToNative(name)); + } + + /* Start accepting Unicode text input events, show keyboard */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_StartTextInput(); + + /* Check if unicode input events are enabled */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_IsTextInputActive(); + + /* Stop receiving any text input events, hide onscreen kbd */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_StopTextInput(); + + /* Set the rectangle used for text input, hint for IME */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetTextInputRect(ref SDL_Rect rect); + + /* Does the platform support an on-screen keyboard? */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_HasScreenKeyboardSupport(); + + /* Is the on-screen keyboard shown for a given window? */ + /* window is an SDL_Window pointer */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_IsScreenKeyboardShown(IntPtr window); + + #endregion + + #region SDL_mouse.c + + /* Note: SDL_Cursor is a typedef normally. We'll treat it as + * an IntPtr, because C# doesn't do typedefs. Yay! + */ + + /* System cursor types */ + public enum SDL_SystemCursor + { + SDL_SYSTEM_CURSOR_ARROW, // Arrow + SDL_SYSTEM_CURSOR_IBEAM, // I-beam + SDL_SYSTEM_CURSOR_WAIT, // Wait + SDL_SYSTEM_CURSOR_CROSSHAIR, // Crosshair + SDL_SYSTEM_CURSOR_WAITARROW, // Small wait cursor (or Wait if not available) + SDL_SYSTEM_CURSOR_SIZENWSE, // Double arrow pointing northwest and southeast + SDL_SYSTEM_CURSOR_SIZENESW, // Double arrow pointing northeast and southwest + SDL_SYSTEM_CURSOR_SIZEWE, // Double arrow pointing west and east + SDL_SYSTEM_CURSOR_SIZENS, // Double arrow pointing north and south + SDL_SYSTEM_CURSOR_SIZEALL, // Four pointed arrow pointing north, south, east, and west + SDL_SYSTEM_CURSOR_NO, // Slashed circle or crossbones + SDL_SYSTEM_CURSOR_HAND, // Hand + SDL_NUM_SYSTEM_CURSORS + } + + /* Get the window which currently has mouse focus */ + /* Return value is an SDL_Window pointer */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetMouseFocus(); + + /* Get the current state of the mouse */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetMouseState(out int x, out int y); + + /* Get the current state of the mouse */ + /* This overload allows for passing NULL to x */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetMouseState(IntPtr x, out int y); + + /* Get the current state of the mouse */ + /* This overload allows for passing NULL to y */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetMouseState(out int x, IntPtr y); + + /* Get the current state of the mouse */ + /* This overload allows for passing NULL to both x and y */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetMouseState(IntPtr x, IntPtr y); + + /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetGlobalMouseState(out int x, out int y); + + /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ + /* This overload allows for passing NULL to x */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, out int y); + + /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ + /* This overload allows for passing NULL to y */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetGlobalMouseState(out int x, IntPtr y); + + /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ + /* This overload allows for passing NULL to both x and y */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, IntPtr y); + + /* Get the mouse state with relative coords*/ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetRelativeMouseState(out int x, out int y); + + /* Set the mouse cursor's position (within a window) */ + /* window is an SDL_Window pointer */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_WarpMouseInWindow(IntPtr window, int x, int y); + + /* Set the mouse cursor's position in global screen space */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_WarpMouseGlobal(int x, int y); + + /* Enable/Disable relative mouse mode (grabs mouse, rel coords) */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetRelativeMouseMode(SDL_bool enabled); + + /* Capture the mouse, to track input outside an SDL window */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_CaptureMouse(SDL_bool enabled); + + /* Query if the relative mouse mode is enabled */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_GetRelativeMouseMode(); + + /* Create a cursor from bitmap data (amd mask) in MSB format */ + /* data and mask are byte arrays, and w must be a multiple of 8 */ + /* return value is an SDL_Cursor pointer */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateCursor( + IntPtr data, + IntPtr mask, + int w, + int h, + int hot_x, + int hot_y + ); + + /* Create a cursor from an SDL_Surface */ + /* IntPtr refers to an SDL_Cursor*, surface to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateColorCursor( + IntPtr surface, + int hot_x, + int hot_y + ); + + /* Create a cursor from a system cursor id */ + /* return value is an SDL_Cursor pointer */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_CreateSystemCursor(SDL_SystemCursor id); + + /* Set the active cursor */ + /* cursor is an SDL_Cursor pointer */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_SetCursor(IntPtr cursor); + + /* Return the active cursor */ + /* return value is an SDL_Cursor pointer */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetCursor(); + + /* Frees a cursor created with one of the CreateCursor functions */ + /* cursor in an SDL_Cursor pointer */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_FreeCursor(IntPtr cursor); + + /* Toggle whether or not the cursor is shown */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_ShowCursor(int toggle); + + public static uint SDL_BUTTON(uint X) + { + // If only there were a better way of doing this in C# + return (uint) (1 << ((int) X - 1)); + } + + public const uint SDL_BUTTON_LEFT = 1; + public const uint SDL_BUTTON_MIDDLE = 2; + public const uint SDL_BUTTON_RIGHT = 3; + public const uint SDL_BUTTON_X1 = 4; + public const uint SDL_BUTTON_X2 = 5; + public static readonly UInt32 SDL_BUTTON_LMASK = SDL_BUTTON(SDL_BUTTON_LEFT); + public static readonly UInt32 SDL_BUTTON_MMASK = SDL_BUTTON(SDL_BUTTON_MIDDLE); + public static readonly UInt32 SDL_BUTTON_RMASK = SDL_BUTTON(SDL_BUTTON_RIGHT); + public static readonly UInt32 SDL_BUTTON_X1MASK = SDL_BUTTON(SDL_BUTTON_X1); + public static readonly UInt32 SDL_BUTTON_X2MASK = SDL_BUTTON(SDL_BUTTON_X2); + + #endregion + + #region SDL_touch.h + + public const uint SDL_TOUCH_MOUSEID = uint.MaxValue; + + public struct SDL_Finger + { + public long id; // SDL_FingerID + public float x; + public float y; + public float pressure; + } + + /** + * \brief Get the number of registered touch devices. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetNumTouchDevices(); + + /** + * \brief Get the touch ID with the given index, or 0 if the index is invalid. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern long SDL_GetTouchDevice(int index); + + /** + * \brief Get the number of active fingers for a given touch device. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetNumTouchFingers(long touchID); + + /** + * \brief Get the finger object of the given touch, with the given index. + * Returns pointer to SDL_Finger. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetTouchFinger(long touchID, int index); + + #endregion + + #region SDL_joystick.h + + public const byte SDL_HAT_CENTERED = 0x00; + public const byte SDL_HAT_UP = 0x01; + public const byte SDL_HAT_RIGHT = 0x02; + public const byte SDL_HAT_DOWN = 0x04; + public const byte SDL_HAT_LEFT = 0x08; + public const byte SDL_HAT_RIGHTUP = SDL_HAT_RIGHT | SDL_HAT_UP; + public const byte SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT | SDL_HAT_DOWN; + public const byte SDL_HAT_LEFTUP = SDL_HAT_LEFT | SDL_HAT_UP; + public const byte SDL_HAT_LEFTDOWN = SDL_HAT_LEFT | SDL_HAT_DOWN; + + public enum SDL_JoystickPowerLevel + { + SDL_JOYSTICK_POWER_UNKNOWN = -1, + SDL_JOYSTICK_POWER_EMPTY, + SDL_JOYSTICK_POWER_LOW, + SDL_JOYSTICK_POWER_MEDIUM, + SDL_JOYSTICK_POWER_FULL, + SDL_JOYSTICK_POWER_WIRED, + SDL_JOYSTICK_POWER_MAX + } + + public enum SDL_JoystickType + { + SDL_JOYSTICK_TYPE_UNKNOWN, + SDL_JOYSTICK_TYPE_GAMECONTROLLER, + SDL_JOYSTICK_TYPE_WHEEL, + SDL_JOYSTICK_TYPE_ARCADE_STICK, + SDL_JOYSTICK_TYPE_FLIGHT_STICK, + SDL_JOYSTICK_TYPE_DANCE_PAD, + SDL_JOYSTICK_TYPE_GUITAR, + SDL_JOYSTICK_TYPE_DRUM_KIT, + SDL_JOYSTICK_TYPE_ARCADE_PAD + } + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_JoystickClose(IntPtr joystick); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_JoystickEventState(int state); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern short SDL_JoystickGetAxis( + IntPtr joystick, + int axis + ); + + /* joystick refers to an SDL_Joystick*. + * This function is only available in 2.0.6 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_JoystickGetAxisInitialState( + IntPtr joystick, + int axis, + out ushort state + ); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_JoystickGetBall( + IntPtr joystick, + int ball, + out int dx, + out int dy + ); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern byte SDL_JoystickGetButton( + IntPtr joystick, + int button + ); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern byte SDL_JoystickGetHat( + IntPtr joystick, + int hat + ); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, EntryPoint = "SDL_JoystickName", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_JoystickName( + IntPtr joystick + ); + public static string SDL_JoystickName(IntPtr joystick) + { + return UTF8_ToManaged( + INTERNAL_SDL_JoystickName(joystick) + ); + } + + [DllImport(nativeLibName, EntryPoint = "SDL_JoystickNameForIndex", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_JoystickNameForIndex( + int device_index + ); + public static string SDL_JoystickNameForIndex(int device_index) + { + return UTF8_ToManaged( + INTERNAL_SDL_JoystickNameForIndex(device_index) + ); + } + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_JoystickNumAxes(IntPtr joystick); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_JoystickNumBalls(IntPtr joystick); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_JoystickNumButtons(IntPtr joystick); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_JoystickNumHats(IntPtr joystick); + + /* IntPtr refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_JoystickOpen(int device_index); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_JoystickUpdate(); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_NumJoysticks(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Guid SDL_JoystickGetDeviceGUID( + int device_index + ); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Guid SDL_JoystickGetGUID( + IntPtr joystick + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_JoystickGetGUIDString( + Guid guid, + byte[] pszGUID, + int cbGUID + ); + + [DllImport(nativeLibName, EntryPoint = "SDL_JoystickGetGUIDFromString", CallingConvention = CallingConvention.Cdecl)] + private static extern Guid INTERNAL_SDL_JoystickGetGUIDFromString( + byte[] pchGUID + ); + public static Guid SDL_JoystickGetGUIDFromString(string pchGuid) + { + return INTERNAL_SDL_JoystickGetGUIDFromString( + UTF8_ToNative(pchGuid) + ); + } + + /* This function is only available in 2.0.6 or higher. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern ushort SDL_JoystickGetDeviceVendor(int device_index); + + /* This function is only available in 2.0.6 or higher. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern ushort SDL_JoystickGetDeviceProduct(int device_index); + + /* This function is only available in 2.0.6 or higher. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern ushort SDL_JoystickGetDeviceProductVersion(int device_index); + + /* This function is only available in 2.0.6 or higher. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_JoystickType SDL_JoystickGetDeviceType(int device_index); + + /* int refers to an SDL_JoystickID. + * This function is only available in 2.0.6 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_JoystickGetDeviceInstanceID(int device_index); + + /* joystick refers to an SDL_Joystick*. + * This function is only available in 2.0.6 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern ushort SDL_JoystickGetVendor(IntPtr joystick); + + /* joystick refers to an SDL_Joystick*. + * This function is only available in 2.0.6 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern ushort SDL_JoystickGetProduct(IntPtr joystick); + + /* joystick refers to an SDL_Joystick*. + * This function is only available in 2.0.6 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern ushort SDL_JoystickGetProductVersion(IntPtr joystick); + + /* joystick refers to an SDL_Joystick*. + * This function is only available in 2.0.6 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_JoystickType SDL_JoystickGetType(IntPtr joystick); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_JoystickGetAttached(IntPtr joystick); + + /* int refers to an SDL_JoystickID, joystick to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_JoystickInstanceID(IntPtr joystick); + + /* joystick refers to an SDL_Joystick*. + * This function is only available in 2.0.4 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel( + IntPtr joystick + ); + + /* int refers to an SDL_JoystickID, IntPtr to an SDL_Joystick*. + * This function is only available in 2.0.4 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_JoystickFromInstanceID(int joyid); + + /* Only available in 2.0.7 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_LockJoysticks(); + + /* Only available in 2.0.7 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_UnlockJoysticks(); + + #endregion + + #region SDL_gamecontroller.h + + public enum SDL_GameControllerBindType + { + SDL_CONTROLLER_BINDTYPE_NONE, + SDL_CONTROLLER_BINDTYPE_BUTTON, + SDL_CONTROLLER_BINDTYPE_AXIS, + SDL_CONTROLLER_BINDTYPE_HAT + } + + public enum SDL_GameControllerAxis + { + SDL_CONTROLLER_AXIS_INVALID = -1, + SDL_CONTROLLER_AXIS_LEFTX, + SDL_CONTROLLER_AXIS_LEFTY, + SDL_CONTROLLER_AXIS_RIGHTX, + SDL_CONTROLLER_AXIS_RIGHTY, + SDL_CONTROLLER_AXIS_TRIGGERLEFT, + SDL_CONTROLLER_AXIS_TRIGGERRIGHT, + SDL_CONTROLLER_AXIS_MAX + } + + public enum SDL_GameControllerButton + { + SDL_CONTROLLER_BUTTON_INVALID = -1, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + SDL_CONTROLLER_BUTTON_MAX, + } + + // FIXME: I'd rather this somehow be private... + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_GameControllerButtonBind_hat + { + public int hat; + public int hat_mask; + } + + // FIXME: I'd rather this somehow be private... + [StructLayout(LayoutKind.Explicit)] + public struct INTERNAL_GameControllerButtonBind_union + { + [FieldOffset(0)] + public int button; + [FieldOffset(0)] + public int axis; + [FieldOffset(0)] + public INTERNAL_GameControllerButtonBind_hat hat; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_GameControllerButtonBind + { + public SDL_GameControllerBindType bindType; + public INTERNAL_GameControllerButtonBind_union value; + } + + /* This exists to deal with C# being stupid about blittable types. */ + [StructLayout(LayoutKind.Sequential)] + private struct INTERNAL_SDL_GameControllerButtonBind + { + public int bindType; + /* Largest data type in the union is two ints in size */ + public int unionVal0; + public int unionVal1; + } + + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerAddMapping", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_SDL_GameControllerAddMapping( + byte[] mappingString + ); + public static int SDL_GameControllerAddMapping( + string mappingString + ) { + return INTERNAL_SDL_GameControllerAddMapping( + UTF8_ToNative(mappingString) + ); + } + + /* This function is only available in 2.0.6 or higher. */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GameControllerNumMappings(); + + /* This function is only available in 2.0.6 or higher. */ + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMappingForIndex", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GameControllerMappingForIndex(int mapping_index); + public static string SDL_GameControllerMappingForIndex(int mapping_index) + { + return UTF8_ToManaged( + INTERNAL_SDL_GameControllerMappingForIndex( + mapping_index + ) + ); + } + + /* THIS IS AN RWops FUNCTION! */ + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerAddMappingsFromRW", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_SDL_GameControllerAddMappingsFromRW( + IntPtr rw, + int freerw + ); + public static int SDL_GameControllerAddMappingsFromFile(string file) + { + IntPtr rwops = INTERNAL_SDL_RWFromFile(file, "rb"); + return INTERNAL_SDL_GameControllerAddMappingsFromRW(rwops, 1); + } + + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMappingForGUID", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GameControllerMappingForGUID( + Guid guid + ); + public static string SDL_GameControllerMappingForGUID(Guid guid) + { + return UTF8_ToManaged( + INTERNAL_SDL_GameControllerMappingForGUID(guid) + ); + } + + /* gamecontroller refers to an SDL_GameController* */ + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMapping", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GameControllerMapping( + IntPtr gamecontroller + ); + public static string SDL_GameControllerMapping( + IntPtr gamecontroller + ) { + return UTF8_ToManaged( + INTERNAL_SDL_GameControllerMapping( + gamecontroller + ) + ); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_IsGameController(int joystick_index); + + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerNameForIndex", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GameControllerNameForIndex( + int joystick_index + ); + public static string SDL_GameControllerNameForIndex( + int joystick_index + ) { + return UTF8_ToManaged( + INTERNAL_SDL_GameControllerNameForIndex(joystick_index) + ); + } + + /* IntPtr refers to an SDL_GameController* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GameControllerOpen(int joystick_index); + + /* gamecontroller refers to an SDL_GameController* */ + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerName", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GameControllerName( + IntPtr gamecontroller + ); + public static string SDL_GameControllerName( + IntPtr gamecontroller + ) { + return UTF8_ToManaged( + INTERNAL_SDL_GameControllerName(gamecontroller) + ); + } + + /* gamecontroller refers to an SDL_GameController*. + * This function is only available in 2.0.6 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern ushort SDL_GameControllerGetVendor( + IntPtr gamecontroller + ); + + /* gamecontroller refers to an SDL_GameController*. + * This function is only available in 2.0.6 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern ushort SDL_GameControllerGetProduct( + IntPtr gamecontroller + ); + + /* gamecontroller refers to an SDL_GameController*. + * This function is only available in 2.0.6 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern ushort SDL_GameControllerGetProductVersion( + IntPtr gamecontroller + ); + + /* gamecontroller refers to an SDL_GameController* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_GameControllerGetAttached( + IntPtr gamecontroller + ); + + /* IntPtr refers to an SDL_Joystick* + * gamecontroller refers to an SDL_GameController* + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GameControllerGetJoystick( + IntPtr gamecontroller + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GameControllerEventState(int state); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GameControllerUpdate(); + + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetAxisFromString", CallingConvention = CallingConvention.Cdecl)] + private static extern SDL_GameControllerAxis INTERNAL_SDL_GameControllerGetAxisFromString( + byte[] pchString + ); + public static SDL_GameControllerAxis SDL_GameControllerGetAxisFromString( + string pchString + ) { + return INTERNAL_SDL_GameControllerGetAxisFromString( + UTF8_ToNative(pchString) + ); + } + + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetStringForAxis", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GameControllerGetStringForAxis( + SDL_GameControllerAxis axis + ); + public static string SDL_GameControllerGetStringForAxis( + SDL_GameControllerAxis axis + ) { + return UTF8_ToManaged( + INTERNAL_SDL_GameControllerGetStringForAxis( + axis + ) + ); + } + + /* gamecontroller refers to an SDL_GameController* */ + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetBindForAxis", CallingConvention = CallingConvention.Cdecl)] + private static extern INTERNAL_SDL_GameControllerButtonBind INTERNAL_SDL_GameControllerGetBindForAxis( + IntPtr gamecontroller, + SDL_GameControllerAxis axis + ); + public static SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis( + IntPtr gamecontroller, + SDL_GameControllerAxis axis + ) { + // This is guaranteed to never be null + INTERNAL_SDL_GameControllerButtonBind dumb = INTERNAL_SDL_GameControllerGetBindForAxis( + gamecontroller, + axis + ); + SDL_GameControllerButtonBind result = new SDL_GameControllerButtonBind(); + result.bindType = (SDL_GameControllerBindType) dumb.bindType; + result.value.hat.hat = dumb.unionVal0; + result.value.hat.hat_mask = dumb.unionVal1; + return result; + } + + /* gamecontroller refers to an SDL_GameController* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern short SDL_GameControllerGetAxis( + IntPtr gamecontroller, + SDL_GameControllerAxis axis + ); + + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetButtonFromString", CallingConvention = CallingConvention.Cdecl)] + private static extern SDL_GameControllerButton INTERNAL_SDL_GameControllerGetButtonFromString( + byte[] pchString + ); + public static SDL_GameControllerButton SDL_GameControllerGetButtonFromString( + string pchString + ) { + return INTERNAL_SDL_GameControllerGetButtonFromString( + UTF8_ToNative(pchString) + ); + } + + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetStringForButton", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GameControllerGetStringForButton( + SDL_GameControllerButton button + ); + public static string SDL_GameControllerGetStringForButton( + SDL_GameControllerButton button + ) { + return UTF8_ToManaged( + INTERNAL_SDL_GameControllerGetStringForButton(button) + ); + } + + /* gamecontroller refers to an SDL_GameController* */ + [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetBindForButton", CallingConvention = CallingConvention.Cdecl)] + private static extern INTERNAL_SDL_GameControllerButtonBind INTERNAL_SDL_GameControllerGetBindForButton( + IntPtr gamecontroller, + SDL_GameControllerButton button + ); + public static SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton( + IntPtr gamecontroller, + SDL_GameControllerButton button + ) { + // This is guaranteed to never be null + INTERNAL_SDL_GameControllerButtonBind dumb = INTERNAL_SDL_GameControllerGetBindForButton( + gamecontroller, + button + ); + SDL_GameControllerButtonBind result = new SDL_GameControllerButtonBind(); + result.bindType = (SDL_GameControllerBindType) dumb.bindType; + result.value.hat.hat = dumb.unionVal0; + result.value.hat.hat_mask = dumb.unionVal1; + return result; + } + + /* gamecontroller refers to an SDL_GameController* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern byte SDL_GameControllerGetButton( + IntPtr gamecontroller, + SDL_GameControllerButton button + ); + + /* gamecontroller refers to an SDL_GameController* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_GameControllerClose( + IntPtr gamecontroller + ); + + /* int refers to an SDL_JoystickID, IntPtr to an SDL_GameController*. + * This function is only available in 2.0.4 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GameControllerFromInstanceID(int joyid); + + #endregion + + #region SDL_haptic.h + + /* SDL_HapticEffect type */ + public const ushort SDL_HAPTIC_CONSTANT = (1 << 0); + public const ushort SDL_HAPTIC_SINE = (1 << 1); + public const ushort SDL_HAPTIC_LEFTRIGHT = (1 << 2); + public const ushort SDL_HAPTIC_TRIANGLE = (1 << 3); + public const ushort SDL_HAPTIC_SAWTOOTHUP = (1 << 4); + public const ushort SDL_HAPTIC_SAWTOOTHDOWN = (1 << 5); + public const ushort SDL_HAPTIC_SPRING = (1 << 7); + public const ushort SDL_HAPTIC_DAMPER = (1 << 8); + public const ushort SDL_HAPTIC_INERTIA = (1 << 9); + public const ushort SDL_HAPTIC_FRICTION = (1 << 10); + public const ushort SDL_HAPTIC_CUSTOM = (1 << 11); + public const ushort SDL_HAPTIC_GAIN = (1 << 12); + public const ushort SDL_HAPTIC_AUTOCENTER = (1 << 13); + public const ushort SDL_HAPTIC_STATUS = (1 << 14); + public const ushort SDL_HAPTIC_PAUSE = (1 << 15); + + /* SDL_HapticDirection type */ + public const byte SDL_HAPTIC_POLAR = 0; + public const byte SDL_HAPTIC_CARTESIAN = 1; + public const byte SDL_HAPTIC_SPHERICAL = 2; + + /* SDL_HapticRunEffect */ + public const uint SDL_HAPTIC_INFINITY = 4292967295U; + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct SDL_HapticDirection + { + public byte type; + public fixed int dir[3]; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_HapticConstant + { + // Header + public ushort type; + public SDL_HapticDirection direction; + // Replay + public uint length; + public ushort delay; + // Trigger + public ushort button; + public ushort interval; + // Constant + public short level; + // Envelope + public ushort attack_length; + public ushort attack_level; + public ushort fade_length; + public ushort fade_level; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_HapticPeriodic + { + // Header + public ushort type; + public SDL_HapticDirection direction; + // Replay + public uint length; + public ushort delay; + // Trigger + public ushort button; + public ushort interval; + // Periodic + public ushort period; + public short magnitude; + public short offset; + public ushort phase; + // Envelope + public ushort attack_length; + public ushort attack_level; + public ushort fade_length; + public ushort fade_level; + } + + [StructLayout(LayoutKind.Sequential)] + public unsafe struct SDL_HapticCondition + { + // Header + public ushort type; + public SDL_HapticDirection direction; + // Replay + public uint length; + public ushort delay; + // Trigger + public ushort button; + public ushort interval; + // Condition + public fixed ushort right_sat[3]; + public fixed ushort left_sat[3]; + public fixed short right_coeff[3]; + public fixed short left_coeff[3]; + public fixed ushort deadband[3]; + public fixed short center[3]; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_HapticRamp + { + // Header + public ushort type; + public SDL_HapticDirection direction; + // Replay + public uint length; + public ushort delay; + // Trigger + public ushort button; + public ushort interval; + // Ramp + public short start; + public short end; + // Envelope + public ushort attack_length; + public ushort attack_level; + public ushort fade_length; + public ushort fade_level; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_HapticLeftRight + { + // Header + public ushort type; + // Replay + public uint length; + // Rumble + public ushort large_magnitude; + public ushort small_magnitude; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_HapticCustom + { + // Header + public ushort type; + public SDL_HapticDirection direction; + // Replay + public uint length; + public ushort delay; + // Trigger + public ushort button; + public ushort interval; + // Custom + public byte channels; + public ushort period; + public ushort samples; + public IntPtr data; // Uint16* + // Envelope + public ushort attack_length; + public ushort attack_level; + public ushort fade_length; + public ushort fade_level; + } + + [StructLayout(LayoutKind.Explicit)] + public struct SDL_HapticEffect + { + [FieldOffset(0)] + public ushort type; + [FieldOffset(0)] + public SDL_HapticConstant constant; + [FieldOffset(0)] + public SDL_HapticPeriodic periodic; + [FieldOffset(0)] + public SDL_HapticCondition condition; + [FieldOffset(0)] + public SDL_HapticRamp ramp; + [FieldOffset(0)] + public SDL_HapticLeftRight leftright; + [FieldOffset(0)] + public SDL_HapticCustom custom; + } + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_HapticClose(IntPtr haptic); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_HapticDestroyEffect( + IntPtr haptic, + int effect + ); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticEffectSupported( + IntPtr haptic, + ref SDL_HapticEffect effect + ); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticGetEffectStatus( + IntPtr haptic, + int effect + ); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticIndex(IntPtr haptic); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, EntryPoint = "SDL_HapticName", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_HapticName(int device_index); + public static string SDL_HapticName(int device_index) + { + return UTF8_ToManaged(INTERNAL_SDL_HapticName(device_index)); + } + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticNewEffect( + IntPtr haptic, + ref SDL_HapticEffect effect + ); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticNumAxes(IntPtr haptic); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticNumEffects(IntPtr haptic); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticNumEffectsPlaying(IntPtr haptic); + + /* IntPtr refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_HapticOpen(int device_index); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticOpened(int device_index); + + /* IntPtr refers to an SDL_Haptic*, joystick to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_HapticOpenFromJoystick( + IntPtr joystick + ); + + /* IntPtr refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_HapticOpenFromMouse(); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticPause(IntPtr haptic); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern uint SDL_HapticQuery(IntPtr haptic); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticRumbleInit(IntPtr haptic); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticRumblePlay( + IntPtr haptic, + float strength, + uint length + ); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticRumbleStop(IntPtr haptic); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticRumbleSupported(IntPtr haptic); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticRunEffect( + IntPtr haptic, + int effect, + uint iterations + ); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticSetAutocenter( + IntPtr haptic, + int autocenter + ); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticSetGain( + IntPtr haptic, + int gain + ); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticStopAll(IntPtr haptic); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticStopEffect( + IntPtr haptic, + int effect + ); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticUnpause(IntPtr haptic); + + /* haptic refers to an SDL_Haptic* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_HapticUpdateEffect( + IntPtr haptic, + int effect, + ref SDL_HapticEffect data + ); + + /* joystick refers to an SDL_Joystick* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_JoystickIsHaptic(IntPtr joystick); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_MouseIsHaptic(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_NumHaptics(); + + #endregion + + #region SDL_audio.h + + public const ushort SDL_AUDIO_MASK_BITSIZE = 0xFF; + public const ushort SDL_AUDIO_MASK_DATATYPE = (1 << 8); + public const ushort SDL_AUDIO_MASK_ENDIAN = (1 << 12); + public const ushort SDL_AUDIO_MASK_SIGNED = (1 << 15); + + public static ushort SDL_AUDIO_BITSIZE(ushort x) + { + return (ushort) (x & SDL_AUDIO_MASK_BITSIZE); + } + + public static bool SDL_AUDIO_ISFLOAT(ushort x) + { + return (x & SDL_AUDIO_MASK_DATATYPE) != 0; + } + + public static bool SDL_AUDIO_ISBIGENDIAN(ushort x) + { + return (x & SDL_AUDIO_MASK_ENDIAN) != 0; + } + + public static bool SDL_AUDIO_ISSIGNED(ushort x) + { + return (x & SDL_AUDIO_MASK_SIGNED) != 0; + } + + public static bool SDL_AUDIO_ISINT(ushort x) + { + return (x & SDL_AUDIO_MASK_DATATYPE) == 0; + } + + public static bool SDL_AUDIO_ISLITTLEENDIAN(ushort x) + { + return (x & SDL_AUDIO_MASK_ENDIAN) == 0; + } + + public static bool SDL_AUDIO_ISUNSIGNED(ushort x) + { + return (x & SDL_AUDIO_MASK_SIGNED) == 0; + } + + public const ushort AUDIO_U8 = 0x0008; + public const ushort AUDIO_S8 = 0x8008; + public const ushort AUDIO_U16LSB = 0x0010; + public const ushort AUDIO_S16LSB = 0x8010; + public const ushort AUDIO_U16MSB = 0x1010; + public const ushort AUDIO_S16MSB = 0x9010; + public const ushort AUDIO_U16 = AUDIO_U16LSB; + public const ushort AUDIO_S16 = AUDIO_S16LSB; + public const ushort AUDIO_S32LSB = 0x8020; + public const ushort AUDIO_S32MSB = 0x9020; + public const ushort AUDIO_S32 = AUDIO_S32LSB; + public const ushort AUDIO_F32LSB = 0x8120; + public const ushort AUDIO_F32MSB = 0x9120; + public const ushort AUDIO_F32 = AUDIO_F32LSB; + + public static readonly ushort AUDIO_U16SYS = + BitConverter.IsLittleEndian ? AUDIO_U16LSB : AUDIO_U16MSB; + public static readonly ushort AUDIO_S16SYS = + BitConverter.IsLittleEndian ? AUDIO_S16LSB : AUDIO_S16MSB; + public static readonly ushort AUDIO_S32SYS = + BitConverter.IsLittleEndian ? AUDIO_S32LSB : AUDIO_S32MSB; + public static readonly ushort AUDIO_F32SYS = + BitConverter.IsLittleEndian ? AUDIO_F32LSB : AUDIO_F32MSB; + + public const uint SDL_AUDIO_ALLOW_FREQUENCY_CHANGE = 0x00000001; + public const uint SDL_AUDIO_ALLOW_FORMAT_CHANGE = 0x00000001; + public const uint SDL_AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000001; + public const uint SDL_AUDIO_ALLOW_ANY_CHANGE = ( + SDL_AUDIO_ALLOW_FREQUENCY_CHANGE | + SDL_AUDIO_ALLOW_FORMAT_CHANGE | + SDL_AUDIO_ALLOW_CHANNELS_CHANGE + ); + + public const int SDL_MIX_MAXVOLUME = 128; + + public enum SDL_AudioStatus + { + SDL_AUDIO_STOPPED, + SDL_AUDIO_PLAYING, + SDL_AUDIO_PAUSED + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_AudioSpec + { + public int freq; + public ushort format; // SDL_AudioFormat + public byte channels; + public byte silence; + public ushort samples; + public uint size; + public SDL_AudioCallback callback; + public IntPtr userdata; // void* + } + + /* userdata refers to a void*, stream to a Uint8 */ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void SDL_AudioCallback( + IntPtr userdata, + IntPtr stream, + int len + ); + + [DllImport(nativeLibName, EntryPoint = "SDL_AudioInit", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_SDL_AudioInit( + byte[] driver_name + ); + public static int SDL_AudioInit(string driver_name) + { + return INTERNAL_SDL_AudioInit( + UTF8_ToNative(driver_name) + ); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_AudioQuit(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_CloseAudio(); + + /* dev refers to an SDL_AudioDeviceID */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_CloseAudioDevice(uint dev); + + /* audio_buf refers to a malloc()'d buffer from SDL_LoadWAV */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_FreeWAV(IntPtr audio_buf); + + [DllImport(nativeLibName, EntryPoint = "SDL_GetAudioDeviceName", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetAudioDeviceName( + int index, + int iscapture + ); + public static string SDL_GetAudioDeviceName( + int index, + int iscapture + ) { + return UTF8_ToManaged( + INTERNAL_SDL_GetAudioDeviceName(index, iscapture) + ); + } + + /* dev refers to an SDL_AudioDeviceID */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_AudioStatus SDL_GetAudioDeviceStatus( + uint dev + ); + + [DllImport(nativeLibName, EntryPoint = "SDL_GetAudioDriver", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetAudioDriver(int index); + public static string SDL_GetAudioDriver(int index) + { + return UTF8_ToManaged( + INTERNAL_SDL_GetAudioDriver(index) + ); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_AudioStatus SDL_GetAudioStatus(); + + [DllImport(nativeLibName, EntryPoint = "SDL_GetCurrentAudioDriver", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetCurrentAudioDriver(); + public static string SDL_GetCurrentAudioDriver() + { + return UTF8_ToManaged(INTERNAL_SDL_GetCurrentAudioDriver()); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetNumAudioDevices(int iscapture); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetNumAudioDrivers(); + + /* audio_buf will refer to a malloc()'d byte buffer */ + /* THIS IS AN RWops FUNCTION! */ + [DllImport(nativeLibName, EntryPoint = "SDL_LoadWAV_RW", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_LoadWAV_RW( + IntPtr src, + int freesrc, + ref SDL_AudioSpec spec, + out IntPtr audio_buf, + out uint audio_len + ); + public static SDL_AudioSpec SDL_LoadWAV( + string file, + ref SDL_AudioSpec spec, + out IntPtr audio_buf, + out uint audio_len + ) { + SDL_AudioSpec result; + IntPtr rwops = INTERNAL_SDL_RWFromFile(file, "rb"); + IntPtr result_ptr = INTERNAL_SDL_LoadWAV_RW( + rwops, + 1, + ref spec, + out audio_buf, + out audio_len + ); + result = (SDL_AudioSpec) Marshal.PtrToStructure( + result_ptr, + typeof(SDL_AudioSpec) + ); + return result; + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_LockAudio(); + + /* dev refers to an SDL_AudioDeviceID */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_LockAudioDevice(uint dev); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_MixAudio( + [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)] + byte[] dst, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)] + byte[] src, + uint len, + int volume + ); + + /* format refers to an SDL_AudioFormat */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_MixAudioFormat( + [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 3)] + byte[] dst, + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 3)] + byte[] src, + ushort format, + uint len, + int volume + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_OpenAudio( + ref SDL_AudioSpec desired, + out SDL_AudioSpec obtained + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_OpenAudio( + ref SDL_AudioSpec desired, + IntPtr obtained + ); + + /* uint refers to an SDL_AudioDeviceID */ + [DllImport(nativeLibName, EntryPoint = "SDL_OpenAudioDevice", CallingConvention = CallingConvention.Cdecl)] + private static extern uint INTERNAL_SDL_OpenAudioDevice( + byte[] device, + int iscapture, + ref SDL_AudioSpec desired, + out SDL_AudioSpec obtained, + int allowed_changes + ); + public static uint SDL_OpenAudioDevice( + string device, + int iscapture, + ref SDL_AudioSpec desired, + out SDL_AudioSpec obtained, + int allowed_changes + ) { + return INTERNAL_SDL_OpenAudioDevice( + UTF8_ToNative(device), + iscapture, + ref desired, + out obtained, + allowed_changes + ); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_PauseAudio(int pause_on); + + /* dev refers to an SDL_AudioDeviceID */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_PauseAudioDevice( + uint dev, + int pause_on + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_UnlockAudio(); + + /* dev refers to an SDL_AudioDeviceID */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_UnlockAudioDevice(uint dev); + + /* dev refers to an SDL_AudioDeviceID, data to a void* */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_QueueAudio( + uint dev, + IntPtr data, + UInt32 len + ); + + /* dev refers to an SDL_AudioDeviceID, data to a void* */ + /* Only available in 2.0.5 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern uint SDL_DequeueAudio( + uint dev, + IntPtr data, + uint len + ); + + /* dev refers to an SDL_AudioDeviceID */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetQueuedAudioSize(uint dev); + + /* dev refers to an SDL_AudioDeviceID */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_ClearQueuedAudio(uint dev); + + /* src_format and dst_format refer to SDL_AudioFormats. + * IntPtr refers to an SDL_AudioStream*. + * Only available in 2.0.7 + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_NewAudioStream( + ushort src_format, + byte src_channels, + int src_rate, + ushort dst_format, + byte dst_channels, + int dst_rate + ); + + /* stream refers to an SDL_AudioStream*, buf to a void*. + * Only available in 2.0.7 + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_AudioStreamPut( + IntPtr stream, + IntPtr buf, + int len + ); + + /* stream refers to an SDL_AudioStream*, buf to a void*. + * Only available in 2.0.7 + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_AudioStreamGet( + IntPtr stream, + IntPtr buf, + int len + ); + + /* stream refers to an SDL_AudioStream*. + * Only available in 2.0.7 + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_AudioStreamAvailable(IntPtr stream); + + /* stream refers to an SDL_AudioStream*. + * Only available in 2.0.7 + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_AudioStreamClear(IntPtr stream); + + /* stream refers to an SDL_AudioStream*. + * Only available in 2.0.7 + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_FreeAudioStream(IntPtr stream); + + #endregion + + #region SDL_timer.h + + /* System timers rely on different OS mechanisms depending on + * which operating system SDL2 is compiled against. + */ + + /* Compare tick values, return true if A has passed B. Introduced in SDL 2.0.1, + * but does not require it (it was a macro). + */ + public static bool SDL_TICKS_PASSED(UInt32 A, UInt32 B) + { + return ((Int32)(B - A) <= 0); + } + + /* Delays the thread's processing based on the milliseconds parameter */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_Delay(UInt32 ms); + + /* Returns the milliseconds that have passed since SDL was initialized */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetTicks(); + + /* Get the current value of the high resolution counter */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt64 SDL_GetPerformanceCounter(); + + /* Get the count per second of the high resolution counter */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt64 SDL_GetPerformanceFrequency(); + + /* param refers to a void* */ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate UInt32 SDL_TimerCallback(UInt32 interval, IntPtr param); + + /* int refers to an SDL_TimerID, param to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_AddTimer( + UInt32 interval, + SDL_TimerCallback callback, + IntPtr param + ); + + /* id refers to an SDL_TimerID */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_RemoveTimer(int id); + + #endregion + + #region SDL_syswm.h + + public enum SDL_SYSWM_TYPE + { + SDL_SYSWM_UNKNOWN, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_X11, + SDL_SYSWM_DIRECTFB, + SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_MIR, + SDL_SYSWM_WINRT, + SDL_SYSWM_ANDROID + } + + // FIXME: I wish these weren't public... + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_windows_wminfo + { + public IntPtr window; // Refers to an HWND + public IntPtr hdc; // Refers to an HDC + } + + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_winrt_wminfo + { + public IntPtr window; // Refers to an IInspectable* + } + + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_x11_wminfo + { + public IntPtr display; // Refers to a Display* + public IntPtr window; // Refers to a Window (XID, use ToInt64!) + } + + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_directfb_wminfo + { + public IntPtr dfb; // Refers to an IDirectFB* + public IntPtr window; // Refers to an IDirectFBWindow* + public IntPtr surface; // Refers to an IDirectFBSurface* + } + + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_cocoa_wminfo + { + public IntPtr window; // Refers to an NSWindow* + } + + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_uikit_wminfo + { + public IntPtr window; // Refers to a UIWindow* + public uint framebuffer; + public uint colorbuffer; + public uint resolveFramebuffer; + } + + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_wayland_wminfo + { + public IntPtr display; // Refers to a wl_display* + public IntPtr surface; // Refers to a wl_surface* + public IntPtr shell_surface; // Refers to a wl_shell_surface* + } + + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_mir_wminfo + { + public IntPtr connection; // Refers to a MirConnection* + public IntPtr surface; // Refers to a MirSurface* + } + + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_android_wminfo + { + public IntPtr window; // Refers to an ANativeWindow + public IntPtr surface; // Refers to an EGLSurface + } + + [StructLayout(LayoutKind.Explicit)] + public struct INTERNAL_SysWMDriverUnion + { + [FieldOffset(0)] + public INTERNAL_windows_wminfo win; + [FieldOffset(0)] + public INTERNAL_winrt_wminfo winrt; + [FieldOffset(0)] + public INTERNAL_x11_wminfo x11; + [FieldOffset(0)] + public INTERNAL_directfb_wminfo dfb; + [FieldOffset(0)] + public INTERNAL_cocoa_wminfo cocoa; + [FieldOffset(0)] + public INTERNAL_uikit_wminfo uikit; + [FieldOffset(0)] + public INTERNAL_wayland_wminfo wl; + [FieldOffset(0)] + public INTERNAL_mir_wminfo mir; + [FieldOffset(0)] + public INTERNAL_android_wminfo android; + // private int dummy; + } + + [StructLayout(LayoutKind.Sequential)] + public struct SDL_SysWMinfo + { + public SDL_version version; + public SDL_SYSWM_TYPE subsystem; + public INTERNAL_SysWMDriverUnion info; + } + + /* window refers to an SDL_Window* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_GetWindowWMInfo( + IntPtr window, + ref SDL_SysWMinfo info + ); + + #endregion + + #region SDL_filesystem.h + + /* Only available in 2.0.1 */ + [DllImport(nativeLibName, EntryPoint = "SDL_GetBasePath", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetBasePath(); + public static string SDL_GetBasePath() + { + return UTF8_ToManaged(INTERNAL_SDL_GetBasePath(), true); + } + + /* Only available in 2.0.1 */ + [DllImport(nativeLibName, EntryPoint = "SDL_GetPrefPath", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_SDL_GetPrefPath( + byte[] org, + byte[] app + ); + public static string SDL_GetPrefPath(string org, string app) + { + return UTF8_ToManaged( + INTERNAL_SDL_GetPrefPath( + UTF8_ToNative(org), + UTF8_ToNative(app) + ), + true + ); + } + + #endregion + + #region SDL_power.h + + public enum SDL_PowerState + { + SDL_POWERSTATE_UNKNOWN = 0, + SDL_POWERSTATE_ON_BATTERY, + SDL_POWERSTATE_NO_BATTERY, + SDL_POWERSTATE_CHARGING, + SDL_POWERSTATE_CHARGED + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_PowerState SDL_GetPowerInfo( + out int secs, + out int pct + ); + + #endregion + + #region SDL_cpuinfo.h + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetCPUCount(); + + /* Only available in 2.0.1 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetSystemRAM(); + + #endregion + } +} diff --git a/FNA/lib/SDL2-CS/src/SDL2_image.cs b/FNA/lib/SDL2-CS/src/SDL2_image.cs new file mode 100644 index 0000000..86e0aae --- /dev/null +++ b/FNA/lib/SDL2-CS/src/SDL2_image.cs @@ -0,0 +1,240 @@ +#region License +/* SDL2# - C# Wrapper for SDL2 + * + * Copyright (c) 2013-2016 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace SDL2 +{ + public static class SDL_image + { + #region SDL2# Variables + + /* Used by DllImport to load the native library. */ + private const string nativeLibName = "SDL2_image.dll"; + + #endregion + + #region SDL_image.h + + /* Similar to the headers, this is the version we're expecting to be + * running with. You will likely want to check this somewhere in your + * program! + */ + public const int SDL_IMAGE_MAJOR_VERSION = 2; + public const int SDL_IMAGE_MINOR_VERSION = 0; + public const int SDL_IMAGE_PATCHLEVEL = 2; + + [Flags] + public enum IMG_InitFlags + { + IMG_INIT_JPG = 0x00000001, + IMG_INIT_PNG = 0x00000002, + IMG_INIT_TIF = 0x00000004, + IMG_INIT_WEBP = 0x00000008 + } + + public static void SDL_IMAGE_VERSION(out SDL.SDL_version X) + { + X.major = SDL_IMAGE_MAJOR_VERSION; + X.minor = SDL_IMAGE_MINOR_VERSION; + X.patch = SDL_IMAGE_PATCHLEVEL; + } + + [DllImport(nativeLibName, EntryPoint = "IMG_Linked_Version", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_IMG_Linked_Version(); + public static SDL.SDL_version IMG_Linked_Version() + { + SDL.SDL_version result; + IntPtr result_ptr = INTERNAL_IMG_Linked_Version(); + result = (SDL.SDL_version) Marshal.PtrToStructure( + result_ptr, + typeof(SDL.SDL_version) + ); + return result; + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int IMG_Init(IMG_InitFlags flags); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void IMG_Quit(); + + /* IntPtr refers to an SDL_Surface* */ + [DllImport(nativeLibName, EntryPoint = "IMG_Load", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_IMG_Load( + byte[] file + ); + public static IntPtr IMG_Load(string file) + { + return INTERNAL_IMG_Load(SDL.UTF8_ToNative(file)); + } + + /* src refers to an SDL_RWops*, IntPtr to an SDL_Surface* */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr IMG_Load_RW( + IntPtr src, + int freesrc + ); + + /* src refers to an SDL_RWops*, IntPtr to an SDL_Surface* */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, EntryPoint = "IMG_LoadTyped_RW", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_IMG_LoadTyped_RW( + IntPtr src, + int freesrc, + byte[] type + ); + public static IntPtr IMG_LoadTyped_RW( + IntPtr src, + int freesrc, + string type + ) { + return INTERNAL_IMG_LoadTyped_RW( + src, + freesrc, + SDL.UTF8_ToNative(type) + ); + } + + /* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */ + [DllImport(nativeLibName, EntryPoint = "IMG_LoadTexture", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_IMG_LoadTexture( + IntPtr renderer, + byte[] file + ); + public static IntPtr IMG_LoadTexture( + IntPtr renderer, + string file + ) { + return INTERNAL_IMG_LoadTexture( + renderer, + SDL.UTF8_ToNative(file) + ); + } + + /* renderer refers to an SDL_Renderer*. + * src refers to an SDL_RWops*. + * IntPtr to an SDL_Texture*. + */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr IMG_LoadTexture_RW( + IntPtr renderer, + IntPtr src, + int freesrc + ); + + /* renderer refers to an SDL_Renderer*. + * src refers to an SDL_RWops*. + * IntPtr to an SDL_Texture*. + */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, EntryPoint = "IMG_LoadTextureTyped_RW", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_IMG_LoadTextureTyped_RW( + IntPtr renderer, + IntPtr src, + int freesrc, + byte[] type + ); + public static IntPtr IMG_LoadTextureTyped_RW( + IntPtr renderer, + IntPtr src, + int freesrc, + string type + ) { + return INTERNAL_IMG_LoadTextureTyped_RW( + renderer, + src, + freesrc, + SDL.UTF8_ToNative(type) + ); + } + + /* IntPtr refers to an SDL_Surface* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr IMG_ReadXPMFromArray( + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)] + string[] xpm + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, EntryPoint = "IMG_SavePNG", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_IMG_SavePNG( + IntPtr surface, + byte[] file + ); + public static int IMG_SavePNG(IntPtr surface, string file) + { + return INTERNAL_IMG_SavePNG( + surface, + SDL.UTF8_ToNative(file) + ); + } + + /* surface refers to an SDL_Surface*, dst to an SDL_RWops* */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int IMG_SavePNG_RW( + IntPtr surface, + IntPtr dst, + int freedst + ); + + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, EntryPoint = "IMG_SaveJPG", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_IMG_SaveJPG( + IntPtr surface, + byte[] file, + int quality + ); + public static int IMG_SaveJPG(IntPtr surface, string file, int quality) + { + return INTERNAL_IMG_SaveJPG( + surface, + SDL.UTF8_ToNative(file), + quality + ); + } + + /* surface refers to an SDL_Surface*, dst to an SDL_RWops* */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int IMG_SaveJPG_RW( + IntPtr surface, + IntPtr dst, + int freedst, + int quality + ); + + #endregion + } +} diff --git a/FNA/lib/SDL2-CS/src/SDL2_mixer.cs b/FNA/lib/SDL2-CS/src/SDL2_mixer.cs new file mode 100644 index 0000000..dcdb769 --- /dev/null +++ b/FNA/lib/SDL2-CS/src/SDL2_mixer.cs @@ -0,0 +1,515 @@ +#region License +/* SDL2# - C# Wrapper for SDL2 + * + * Copyright (c) 2013-2016 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace SDL2 +{ + public static class SDL_mixer + { + #region SDL2# Variables + + /* Used by DllImport to load the native library. */ + private const string nativeLibName = "SDL2_mixer.dll"; + + #endregion + + #region SDL_mixer.h + + /* Similar to the headers, this is the version we're expecting to be + * running with. You will likely want to check this somewhere in your + * program! + */ + public const int SDL_MIXER_MAJOR_VERSION = 2; + public const int SDL_MIXER_MINOR_VERSION = 0; + public const int SDL_MIXER_PATCHLEVEL = 2; + + /* In C, you can redefine this value before including SDL_mixer.h. + * We're not going to allow this in SDL2#, since the value of this + * variable is persistent and not dependent on preprocessor ordering. + */ + public const int MIX_CHANNELS = 8; + + public static readonly int MIX_DEFAULT_FREQUENCY = 22050; + public static readonly ushort MIX_DEFAULT_FORMAT = + BitConverter.IsLittleEndian ? SDL.AUDIO_S16LSB : SDL.AUDIO_S16MSB; + public static readonly int MIX_DEFAULT_CHANNELS = 2; + public static readonly byte MIX_MAX_VOLUME = 128; + + [Flags] + public enum MIX_InitFlags + { + MIX_INIT_FLAC = 0x00000001, + MIX_INIT_MOD = 0x00000002, + MIX_INIT_MP3 = 0x00000008, + MIX_INIT_OGG = 0x00000010, + MIX_INIT_MID = 0x00000020, + } + + public enum Mix_Fading + { + MIX_NO_FADING, + MIX_FADING_OUT, + MIX_FADING_IN + } + + public enum Mix_MusicType + { + MUS_NONE, + MUS_CMD, + MUS_WAV, + MUS_MOD, + MUS_MID, + MUS_OGG, + MUS_MP3, + MUS_MP3_MAD, + MUS_FLAC, + MUS_MODPLUG + } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void MixFuncDelegate( + IntPtr udata, // void* + IntPtr stream, // Uint8* + int len + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void Mix_EffectFunc_t( + int chan, + IntPtr stream, // void* + int len, + IntPtr udata // void* + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void Mix_EffectDone_t( + int chan, + IntPtr udata // void* + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void MusicFinishedDelegate(); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void ChannelFinishedDelegate(int channel); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int SoundFontDelegate( + IntPtr a, // const char* + IntPtr b // void* + ); + + public static void SDL_MIXER_VERSION(out SDL.SDL_version X) + { + X.major = SDL_MIXER_MAJOR_VERSION; + X.minor = SDL_MIXER_MINOR_VERSION; + X.patch = SDL_MIXER_PATCHLEVEL; + } + + [DllImport(nativeLibName, EntryPoint = "MIX_Linked_Version", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_MIX_Linked_Version(); + public static SDL.SDL_version MIX_Linked_Version() + { + SDL.SDL_version result; + IntPtr result_ptr = INTERNAL_MIX_Linked_Version(); + result = (SDL.SDL_version) Marshal.PtrToStructure( + result_ptr, + typeof(SDL.SDL_version) + ); + return result; + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_Init(MIX_InitFlags flags); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_Quit(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_OpenAudio( + int frequency, + ushort format, + int channels, + int chunksize + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_AllocateChannels(int numchans); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_QuerySpec( + out int frequency, + out ushort format, + out int channels + ); + + /* src refers to an SDL_RWops*, IntPtr to a Mix_Chunk* */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr Mix_LoadWAV_RW( + IntPtr src, + int freesrc + ); + + /* IntPtr refers to a Mix_Chunk* */ + /* This is an RWops macro in the C header. */ + public static IntPtr Mix_LoadWAV(string file) + { + IntPtr rwops = SDL.INTERNAL_SDL_RWFromFile(file, "rb"); + return Mix_LoadWAV_RW(rwops, 1); + } + + /* IntPtr refers to a Mix_Music* */ + [DllImport(nativeLibName, EntryPoint = "Mix_LoadMUS", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_Mix_LoadMUS( + byte[] file + ); + public static IntPtr Mix_LoadMUS(string file) + { + return INTERNAL_Mix_LoadMUS(SDL.UTF8_ToNative(file)); + } + + /* IntPtr refers to a Mix_Chunk* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr Mix_QuickLoad_WAV( + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1)] + byte[] mem + ); + + /* IntPtr refers to a Mix_Chunk* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr Mix_QuickLoad_RAW( + [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 1)] + byte[] mem, + uint len + ); + + /* chunk refers to a Mix_Chunk* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_FreeChunk(IntPtr chunk); + + /* music refers to a Mix_Music* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_FreeMusic(IntPtr music); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_GetNumChunkDecoders(); + + [DllImport(nativeLibName, EntryPoint = "Mix_GetChunkDecoder", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_Mix_GetChunkDecoder(int index); + public static string Mix_GetChunkDecoder(int index) + { + return SDL.UTF8_ToManaged( + INTERNAL_Mix_GetChunkDecoder(index) + ); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_GetNumMusicDecoders(); + + [DllImport(nativeLibName, EntryPoint = "Mix_GetMusicDecoder", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_Mix_GetMusicDecoder(int index); + public static string Mix_GetMusicDecoder(int index) + { + return SDL.UTF8_ToManaged( + INTERNAL_Mix_GetMusicDecoder(index) + ); + } + + /* music refers to a Mix_Music* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Mix_MusicType Mix_GetMusicType(IntPtr music); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_SetPostMix( + MixFuncDelegate mix_func, + IntPtr arg // void* + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_HookMusic( + MixFuncDelegate mix_func, + IntPtr arg // void* + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_HookMusicFinished( + MusicFinishedDelegate music_finished + ); + + /* IntPtr refers to a void* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr Mix_GetMusicHookData(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_ChannelFinished( + ChannelFinishedDelegate channel_finished + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_RegisterEffect( + int chan, + Mix_EffectFunc_t f, + Mix_EffectDone_t d, + IntPtr arg // void* + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_UnregisterEffect( + int channel, + Mix_EffectFunc_t f + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_UnregisterAllEffects(int channel); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_SetPanning( + int channel, + byte left, + byte right + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_SetPosition( + int channel, + short angle, + byte distance + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_SetDistance(int channel, byte distance); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_SetReverseStereo(int channel, int flip); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_ReserveChannels(int num); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_GroupChannel(int which, int tag); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_GroupChannels(int from, int to, int tag); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_GroupAvailable(int tag); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_GroupCount(int tag); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_GroupOldest(int tag); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_GroupNewer(int tag); + + /* chunk refers to a Mix_Chunk* */ + public static int Mix_PlayChannel( + int channel, + IntPtr chunk, + int loops + ) { + return Mix_PlayChannelTimed(channel, chunk, loops, -1); + } + + /* chunk refers to a Mix_Chunk* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_PlayChannelTimed( + int channel, + IntPtr chunk, + int loops, + int ticks + ); + + /* music refers to a Mix_Music* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_PlayMusic(IntPtr music, int loops); + + /* music refers to a Mix_Music* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_FadeInMusic( + IntPtr music, + int loops, + int ms + ); + + /* music refers to a Mix_Music* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_FadeInMusicPos( + IntPtr music, + int loops, + int ms, + double position + ); + + /* chunk refers to a Mix_Chunk* */ + public static int Mix_FadeInChannel( + int channel, + IntPtr chunk, + int loops, + int ms + ) { + return Mix_FadeInChannelTimed(channel, chunk, loops, ms, -1); + } + + /* chunk refers to a Mix_Chunk* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_FadeInChannelTimed( + int channel, + IntPtr chunk, + int loops, + int ms, + int ticks + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_Volume(int channel, int volume); + + /* chunk refers to a Mix_Chunk* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_VolumeChunk( + IntPtr chunk, + int volume + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_VolumeMusic(int volume); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_HaltChannel(int channel); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_HaltGroup(int tag); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_HaltMusic(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_ExpireChannel(int channel, int ticks); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_FadeOutChannel(int which, int ms); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_FadeOutGroup(int tag, int ms); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_FadeOutMusic(int ms); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Mix_Fading Mix_FadingMusic(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern Mix_Fading Mix_FadingChannel(int which); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_Pause(int channel); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_Resume(int channel); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_Paused(int channel); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_PauseMusic(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_ResumeMusic(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_RewindMusic(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_PausedMusic(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_SetMusicPosition(double position); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_Playing(int channel); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_PlayingMusic(); + + [DllImport(nativeLibName, EntryPoint = "Mix_SetMusicCMD", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_Mix_SetMusicCMD( + byte[] command + ); + public static int Mix_SetMusicCMD(string command) + { + return INTERNAL_Mix_SetMusicCMD( + SDL.UTF8_ToNative(command) + ); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_SetSynchroValue(int value); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_GetSynchroValue(); + + [DllImport(nativeLibName, EntryPoint = "Mix_SetSoundFonts", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_Mix_SetSoundFonts( + byte[] paths + ); + public static int Mix_SetSoundFonts(string paths) + { + return INTERNAL_Mix_SetSoundFonts( + SDL.UTF8_ToNative(paths) + ); + } + + [DllImport(nativeLibName, EntryPoint = "Mix_GetSoundFonts", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_Mix_GetSoundFonts(); + public static string Mix_GetSoundFonts() + { + return SDL.UTF8_ToManaged(INTERNAL_Mix_GetSoundFonts()); + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int Mix_EachSoundFont( + SoundFontDelegate function, + IntPtr data // void* + ); + + /* IntPtr refers to a Mix_Chunk* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr Mix_GetChunk(int channel); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Mix_CloseAudio(); + + #endregion + } +} diff --git a/FNA/lib/SDL2-CS/src/SDL2_ttf.cs b/FNA/lib/SDL2-CS/src/SDL2_ttf.cs new file mode 100644 index 0000000..34ab409 --- /dev/null +++ b/FNA/lib/SDL2-CS/src/SDL2_ttf.cs @@ -0,0 +1,488 @@ +#region License +/* SDL2# - C# Wrapper for SDL2 + * + * Copyright (c) 2013-2016 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace SDL2 +{ + public static class SDL_ttf + { + #region SDL2# Variables + + /* Used by DllImport to load the native library. */ + private const string nativeLibName = "SDL2_ttf.dll"; + + #endregion + + #region SDL_ttf.h + + /* Similar to the headers, this is the version we're expecting to be + * running with. You will likely want to check this somewhere in your + * program! + */ + public const int SDL_TTF_MAJOR_VERSION = 2; + public const int SDL_TTF_MINOR_VERSION = 0; + public const int SDL_TTF_PATCHLEVEL = 12; + + public const int UNICODE_BOM_NATIVE = 0xFEFF; + public const int UNICODE_BOM_SWAPPED = 0xFFFE; + + public const int TTF_STYLE_NORMAL = 0x00; + public const int TTF_STYLE_BOLD = 0x01; + public const int TTF_STYLE_ITALIC = 0x02; + public const int TTF_STYLE_UNDERLINE = 0x04; + public const int TTF_STYLE_STRIKETHROUGH = 0x08; + + public const int TTF_HINTING_NORMAL = 0; + public const int TTF_HINTING_LIGHT = 1; + public const int TTF_HINTING_MONO = 2; + public const int TTF_HINTING_NONE = 3; + + public static void SDL_TTF_VERSION(out SDL.SDL_version X) + { + X.major = SDL_TTF_MAJOR_VERSION; + X.minor = SDL_TTF_MINOR_VERSION; + X.patch = SDL_TTF_PATCHLEVEL; + } + + [DllImport(nativeLibName, EntryPoint = "TTF_LinkedVersion", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_TTF_LinkedVersion(); + public static SDL.SDL_version TTF_LinkedVersion() + { + SDL.SDL_version result; + IntPtr result_ptr = INTERNAL_TTF_LinkedVersion(); + result = (SDL.SDL_version) Marshal.PtrToStructure( + result_ptr, + typeof(SDL.SDL_version) + ); + return result; + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void TTF_ByteSwappedUNICODE(int swapped); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_Init(); + + /* IntPtr refers to a TTF_Font* */ + [DllImport(nativeLibName, EntryPoint = "TTF_OpenFont", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_TTF_OpenFont( + byte[] file, + int ptsize + ); + public static IntPtr TTF_OpenFont(string file, int ptsize) + { + return INTERNAL_TTF_OpenFont( + SDL.UTF8_ToNative(file), + ptsize + ); + } + + /* src refers to an SDL_RWops*, IntPtr to a TTF_Font* */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_OpenFontRW( + IntPtr src, + int freesrc, + int ptsize + ); + + /* IntPtr refers to a TTF_Font* */ + [DllImport(nativeLibName, EntryPoint = "TTF_OpenFontIndex", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_TTF_OpenFontIndex( + byte[] file, + int ptsize, + long index + ); + public static IntPtr TTF_OpenFontIndex( + string file, + int ptsize, + long index + ) { + return INTERNAL_TTF_OpenFontIndex( + SDL.UTF8_ToNative(file), + ptsize, + index + ); + } + + /* src refers to an SDL_RWops*, IntPtr to a TTF_Font* */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_OpenFontIndexRW( + IntPtr src, + int freesrc, + int ptsize, + long index + ); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_GetFontStyle(IntPtr font); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void TTF_SetFontStyle(IntPtr font, int style); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_GetFontOutline(IntPtr font); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void TTF_SetFontOutline(IntPtr font, int outline); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_GetFontHinting(IntPtr font); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void TTF_SetFontHinting(IntPtr font, int hinting); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_FontHeight(IntPtr font); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_FontAscent(IntPtr font); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_FontDescent(IntPtr font); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_FontLineSkip(IntPtr font); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_GetFontKerning(IntPtr font); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void TTF_SetFontKerning(IntPtr font, int allowed); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern long TTF_FontFaces(IntPtr font); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_FontFaceIsFixedWidth(IntPtr font); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, EntryPoint = "TTF_FontFaceFamilyName", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_TTF_FontFaceFamilyName( + IntPtr font + ); + public static string TTF_FontFaceFamilyName(IntPtr font) + { + return SDL.UTF8_ToManaged( + INTERNAL_TTF_FontFaceFamilyName(font) + ); + } + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, EntryPoint = "TTF_FontFaceStyleName", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_TTF_FontFaceStyleName( + IntPtr font + ); + public static string TTF_FontFaceStyleName(IntPtr font) + { + return SDL.UTF8_ToManaged( + INTERNAL_TTF_FontFaceStyleName(font) + ); + } + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_GlyphIsProvided(IntPtr font, ushort ch); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_GlyphMetrics( + IntPtr font, + ushort ch, + out int minx, + out int maxx, + out int miny, + out int maxy, + out int advance + ); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_SizeText( + IntPtr font, + [In()] [MarshalAs(UnmanagedType.LPStr)] + string text, + out int w, + out int h + ); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, EntryPoint = "TTF_SizeUTF8", CallingConvention = CallingConvention.Cdecl)] + public static extern int INTERNAL_TTF_SizeUTF8( + IntPtr font, + byte[] text, + out int w, + out int h + ); + public static int TTF_SizeUTF8( + IntPtr font, + string text, + out int w, + out int h + ) { + return INTERNAL_TTF_SizeUTF8( + font, + SDL.UTF8_ToNative(text), + out w, + out h + ); + } + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_SizeUNICODE( + IntPtr font, + [In()] [MarshalAs(UnmanagedType.LPWStr)] + string text, + out int w, + out int h + ); + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_RenderText_Solid( + IntPtr font, + [In()] [MarshalAs(UnmanagedType.LPStr)] + string text, + SDL.SDL_Color fg + ); + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Solid", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_TTF_RenderUTF8_Solid( + IntPtr font, + byte[] text, + SDL.SDL_Color fg + ); + public static IntPtr TTF_RenderUTF8_Solid( + IntPtr font, + string text, + SDL.SDL_Color fg + ) { + return INTERNAL_TTF_RenderUTF8_Solid( + font, + SDL.UTF8_ToNative(text), + fg + ); + } + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_RenderUNICODE_Solid( + IntPtr font, + [In()] [MarshalAs(UnmanagedType.LPWStr)] + string text, + SDL.SDL_Color fg + ); + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_RenderGlyph_Solid( + IntPtr font, + ushort ch, + SDL.SDL_Color fg + ); + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_RenderText_Shaded( + IntPtr font, + [In()] [MarshalAs(UnmanagedType.LPStr)] + string text, + SDL.SDL_Color fg, + SDL.SDL_Color bg + ); + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Shaded", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_TTF_RenderUTF8_Shaded( + IntPtr font, + byte[] text, + SDL.SDL_Color fg, + SDL.SDL_Color bg + ); + public static IntPtr TTF_RenderUTF8_Shaded( + IntPtr font, + string text, + SDL.SDL_Color fg, + SDL.SDL_Color bg + ) { + return INTERNAL_TTF_RenderUTF8_Shaded( + font, + SDL.UTF8_ToNative(text), + fg, + bg + ); + } + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_RenderUNICODE_Shaded( + IntPtr font, + [In()] [MarshalAs(UnmanagedType.LPWStr)] + string text, + SDL.SDL_Color fg, + SDL.SDL_Color bg + ); + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_RenderGlyph_Shaded( + IntPtr font, + ushort ch, + SDL.SDL_Color fg, + SDL.SDL_Color bg + ); + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_RenderText_Blended( + IntPtr font, + [In()] [MarshalAs(UnmanagedType.LPStr)] + string text, + SDL.SDL_Color fg + ); + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Blended", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_TTF_RenderUTF8_Blended( + IntPtr font, + byte[] text, + SDL.SDL_Color fg + ); + public static IntPtr TTF_RenderUTF8_Blended( + IntPtr font, + string text, + SDL.SDL_Color fg + ) { + return INTERNAL_TTF_RenderUTF8_Blended( + font, + SDL.UTF8_ToNative(text), + fg + ); + } + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_RenderUNICODE_Blended( + IntPtr font, + [In()] [MarshalAs(UnmanagedType.LPWStr)] + string text, + SDL.SDL_Color fg + ); + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_RenderText_Blended_Wrapped( + IntPtr font, + [In()] [MarshalAs(UnmanagedType.LPStr)] + string text, + SDL.SDL_Color fg, + uint wrapped + ); + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Blended_Wrapped", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_TTF_RenderUTF8_Blended_Wrapped( + IntPtr font, + byte[] text, + SDL.SDL_Color fg, + uint wrapped + ); + public static IntPtr TTF_RenderUTF8_Blended_Wrapped( + IntPtr font, + string text, + SDL.SDL_Color fg, + uint wrapped + ) { + return INTERNAL_TTF_RenderUTF8_Blended_Wrapped( + font, + SDL.UTF8_ToNative(text), + fg, + wrapped + ); + } + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_RenderUNICODE_Blended_Wrapped( + IntPtr font, + [In()] [MarshalAs(UnmanagedType.LPWStr)] + string text, + SDL.SDL_Color fg, + uint wrapped + ); + + /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr TTF_RenderGlyph_Blended( + IntPtr font, + ushort ch, + SDL.SDL_Color fg + ); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void TTF_CloseFont(IntPtr font); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void TTF_Quit(); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TTF_WasInit(); + + /* font refers to a TTF_Font* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetFontKerningSize( + IntPtr font, + int prev_index, + int index + ); + + #endregion + } +} diff --git a/FNA/lib/Theorafile/LICENSE b/FNA/lib/Theorafile/LICENSE new file mode 100644 index 0000000..c608003 --- /dev/null +++ b/FNA/lib/Theorafile/LICENSE @@ -0,0 +1,26 @@ +/* Theorafile - Ogg Theora Video Decoder Library + * + * Copyright (c) 2017 Ethan Lee. + * Based on TheoraPlay, Copyright (c) 2011-2016 Ryan C. Gordon. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ diff --git a/FNA/lib/Theorafile/Makefile b/FNA/lib/Theorafile/Makefile new file mode 100644 index 0000000..746acf3 --- /dev/null +++ b/FNA/lib/Theorafile/Makefile @@ -0,0 +1,26 @@ +# Makefile for Theorafile +# Written by Ethan "flibitijibibo" Lee + +# System information +UNAME = $(shell uname) + +# Compiler +ifeq ($(UNAME), Darwin) + CC += -arch i386 -arch x86_64 -mmacosx-version-min=10.6 + TARGET = dylib +else + TARGET = so +endif + +# Dependencies +DEPS = -logg -lvorbis -ltheoradec + +# Targets +all: clean + $(CC) -O2 -fpic -fPIC -shared -o libtheorafile.$(TARGET) theorafile.c $(DEPS) -Wall -pedantic + +clean: + rm -f libtheorafile.$(TARGET) + +test: + $(CC) -g -o theorafile-test sdl2test/sdl2test.c theorafile.c -I. `sdl2-config --cflags --libs` $(DEPS) -Wall diff --git a/FNA/lib/Theorafile/README b/FNA/lib/Theorafile/README new file mode 100644 index 0000000..8455154 --- /dev/null +++ b/FNA/lib/Theorafile/README @@ -0,0 +1,24 @@ +This is Theorafile, a library for quickly and easily decoding Ogg Theora videos. + +Project Website: https://github.com/FNA-XNA/Theorafile + +License +------- +Theorafile is released under the zlib license. See LICENSE for details. + +About Theorafile +----------------- +Theorafile was written to be used for FNA's VideoPlayer. We access this library +via Theorafile#, which you can find in the 'csharp/' directory. + +Dependencies +------------ +Theorafile depends on libogg, libvorbis, and libtheoradec. + +Theorafile's "sdl2test" test program requires SDL2. + +Building Theorafile +------------------- +For *nix platforms, just type `make` in the root directory! + +For Windows, see the 'visualc/' directory. diff --git a/FNA/lib/Theorafile/csharp/LICENSE b/FNA/lib/Theorafile/csharp/LICENSE new file mode 100644 index 0000000..2454220 --- /dev/null +++ b/FNA/lib/Theorafile/csharp/LICENSE @@ -0,0 +1,25 @@ +/* Theorafile# - C# Wrapper for Theorafile + * + * Copyright (c) 2017 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ diff --git a/FNA/lib/Theorafile/csharp/Makefile b/FNA/lib/Theorafile/csharp/Makefile new file mode 100644 index 0000000..2d6f142 --- /dev/null +++ b/FNA/lib/Theorafile/csharp/Makefile @@ -0,0 +1,10 @@ +# Makefile for Theorafile# +# Written by Ethan "flibitijibibo" Lee + +build: clean + mkdir bin + cp Theorafile-CS.dll.config bin + dmcs /unsafe -debug -out:bin/Theorafile-CS.dll -target:library Theorafile.cs + +clean: + rm -rf bin diff --git a/FNA/lib/Theorafile/csharp/README b/FNA/lib/Theorafile/csharp/README new file mode 100644 index 0000000..066c76d --- /dev/null +++ b/FNA/lib/Theorafile/csharp/README @@ -0,0 +1,17 @@ +This is Theorafile#, a C# wrapper for Theorafile, a library for quickly and +easily decoding Ogg Theora videos. + +Project Website: https://github.com/FNA-XNA/Theorafile + +License +------- +Theorafile# is released under the zlib license. See LICENSE for details. + +About Theorafile# +----------------- +Theorafile# was written to be used for FNA's VideoPlayer. We wrap this around +Theorafile compiled as a shared library. + +Building Theorafile# +-------------------- +Just type `make` in the root directory! diff --git a/FNA/lib/Theorafile/csharp/Theorafile-CS.csproj b/FNA/lib/Theorafile/csharp/Theorafile-CS.csproj new file mode 100644 index 0000000..d585605 --- /dev/null +++ b/FNA/lib/Theorafile/csharp/Theorafile-CS.csproj @@ -0,0 +1,44 @@ + + + + Debug + x86 + 9.0.21022 + 2.0 + {47CF0C2E-3710-4188-BB11-30D248B2B5FB} + Library + Theorafile + Theorafile-CS + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + x86 + false + true + + + none + false + bin\Release + prompt + 4 + x86 + false + true + + + + + + + + Always + + + diff --git a/FNA/lib/Theorafile/csharp/Theorafile-CS.dll.config b/FNA/lib/Theorafile/csharp/Theorafile-CS.dll.config new file mode 100644 index 0000000..1e37687 --- /dev/null +++ b/FNA/lib/Theorafile/csharp/Theorafile-CS.dll.config @@ -0,0 +1,5 @@ + + + + + diff --git a/FNA/lib/Theorafile/csharp/Theorafile-CS.sln b/FNA/lib/Theorafile/csharp/Theorafile-CS.sln new file mode 100644 index 0000000..1aef9da --- /dev/null +++ b/FNA/lib/Theorafile/csharp/Theorafile-CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Theorafile-CS", "Theorafile-CS.csproj", "{47CF0C2E-3710-4188-BB11-30D248B2B5FB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {47CF0C2E-3710-4188-BB11-30D248B2B5FB}.Debug|x86.ActiveCfg = Debug|x86 + {47CF0C2E-3710-4188-BB11-30D248B2B5FB}.Debug|x86.Build.0 = Debug|x86 + {47CF0C2E-3710-4188-BB11-30D248B2B5FB}.Release|x86.ActiveCfg = Release|x86 + {47CF0C2E-3710-4188-BB11-30D248B2B5FB}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = Theorafile-CS.csproj + EndGlobalSection +EndGlobal diff --git a/FNA/lib/Theorafile/csharp/Theorafile.cs b/FNA/lib/Theorafile/csharp/Theorafile.cs new file mode 100644 index 0000000..ed6ffe9 --- /dev/null +++ b/FNA/lib/Theorafile/csharp/Theorafile.cs @@ -0,0 +1,238 @@ +/* Theorafile# - C# Wrapper for Theorafile + * + * Copyright (c) 2017 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +public static class Theorafile +{ + #region Native Library Name + + const string nativeLibName = "libtheorafile.dll"; + + #endregion + + #region UTF8 Marshaling + + private static byte[] UTF8_ToNative(string s) + { + if (s == null) + { + return null; + } + + // Add a null terminator. That's kind of it... :/ + return System.Text.Encoding.UTF8.GetBytes(s + '\0'); + } + + #endregion + + #region malloc/free Entry Points + + // Yes, we're seriously using these. -flibit + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr malloc(IntPtr size); + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + private static extern void free(IntPtr memblock); + + #endregion + + #region C stdio Macros + + // Used by ov_callbacks, seek_func + public enum SeekWhence : int + { + // Add TF_ prefix to prevent C macro conflicts + TF_SEEK_SET = 0, + TF_SEEK_CUR = 1, + TF_SEEK_END = 2 + } + + #endregion + + #region Theorafile Delegates + + /* IntPtr refers to a size_t */ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr read_func( + IntPtr ptr, // Refers to a void* + IntPtr size, // Refers to a size_t + IntPtr nmemb, // Refers to a size_t + IntPtr datasource // Refers to a void* + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int seek_func( + IntPtr datasource, // Refers to a void* + long offset, // Refers to an ogg_int64_t + SeekWhence whence + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int close_func( + IntPtr datasource // Refers to a void* + ); + + #endregion + + #region Theorafile Structures + + [StructLayout(LayoutKind.Sequential)] + public struct tf_callbacks + { + public read_func read_func; + public seek_func seek_func; + public close_func close_func; + } + + #endregion + + #region Theorafile Implementation + + [DllImport(nativeLibName, EntryPoint = "tf_open_callbacks", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_tf_open_callbacks( + IntPtr datasource, + IntPtr file, + tf_callbacks io + ); + public static int tf_open_callbacks( + IntPtr datasource, + out IntPtr file, + tf_callbacks io + ) { + file = AllocTheoraFile(); + return INTERNAL_tf_open_callbacks(datasource, file, io); + } + + [DllImport(nativeLibName, EntryPoint = "tf_fopen", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_tf_fopen( + byte[] fname, + IntPtr file + ); + public static int tf_fopen(string fname, out IntPtr file) + { + file = AllocTheoraFile(); + return INTERNAL_tf_fopen(UTF8_ToNative(fname), file); + } + + [DllImport(nativeLibName, EntryPoint = "tf_close", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_tf_close(IntPtr file); + public static int tf_close(ref IntPtr file) + { + int result = INTERNAL_tf_close(file); + free(file); + file = IntPtr.Zero; + return result; + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int tf_hasaudio(IntPtr file); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int tf_hasvideo(IntPtr file); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void tf_videoinfo( + IntPtr file, + out int width, + out int height, + out double fps + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void tf_audioinfo( + IntPtr file, + out int channels, + out int samplerate + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int tf_eos(IntPtr file); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void tf_reset(IntPtr file); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int tf_readvideo(IntPtr file, IntPtr buffer, int numframes); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int tf_readaudio(IntPtr file, IntPtr buffer, int length); + + #endregion + + #region OggTheora_File Allocator + + /* Notice that we did not implement an OggTheora_File struct, but are + * instead using a pointer natively malloc'd. + * + * C# Interop for Xiph structs is basically impossible to do, so + * we just alloc what _should_ be the full size of the structure for + * the OS and architecture, then pass that around as if that's a real + * struct. The size is just what you get from sizeof(OggTheora_File). + * + * Don't get mad at me, get mad at C#. + * + * -flibit + */ + + private static IntPtr AllocTheoraFile() + { + // Do not attempt to understand these numbers at all costs! + const int size32 = 1160; + const int size64Unix = 1472; + const int size64Windows = 1328; + + PlatformID platform = Environment.OSVersion.Platform; + if (IntPtr.Size == 4) + { + /* Technically this could be a little bit smaller, but + * some 32-bit architectures may be higher even on Unix + * targets (like ARMv7). + * -flibit + */ + return malloc((IntPtr) size32); + } + if (IntPtr.Size == 8) + { + if (platform == PlatformID.Unix) + { + return malloc((IntPtr) size64Unix); + } + else if (platform == PlatformID.Win32NT) + { + return malloc((IntPtr) size64Windows); + } + throw new NotSupportedException("Unhandled platform!"); + } + throw new NotSupportedException("Unhandled architecture!"); + } + + #endregion +} diff --git a/FNA/lib/Theorafile/sdl2test/glfuncs.h b/FNA/lib/Theorafile/sdl2test/glfuncs.h new file mode 100644 index 0000000..dc0cbf0 --- /dev/null +++ b/FNA/lib/Theorafile/sdl2test/glfuncs.h @@ -0,0 +1,25 @@ +GL_PROC(void, glDepthMask, (GLenum a)) +GL_PROC(void, glDisable, (GLenum a)) +GL_PROC(void, glPixelStorei, (GLenum a, GLint b)) +GL_PROC(void, glGenTextures, (GLsizei a, GLuint *b)) +GL_PROC(void, glActiveTexture, (GLenum a)) +GL_PROC(void, glBindTexture, (GLenum a, GLuint b)) +GL_PROC(void, glTexImage2D, (GLenum a, GLint b, GLint c, GLsizei d, GLsizei e, GLint f, GLenum g, GLenum h, const GLvoid *i)) +GL_PROC(void, glTexSubImage2D, (GLenum a, GLint b, GLint c, GLint d, GLsizei e, GLsizei f, GLenum g, GLenum h, const GLvoid *i)) +GL_PROC(void, glTexParameteri, (GLenum a, GLenum b, GLint c)) +GL_PROC(GLuint, glCreateShader, (GLenum a)) +GL_PROC(void, glShaderSource, (GLuint a, GLsizei b, const GLchar *const*c, const GLint *d)) +GL_PROC(void, glCompileShader, (GLuint a)) +GL_PROC(GLuint, glCreateProgram, (void)) +GL_PROC(void, glAttachShader, (GLuint a, GLuint b)) +GL_PROC(void, glBindAttribLocation, (GLuint a, GLuint b, const GLchar *c)) +GL_PROC(void, glLinkProgram, (GLuint a)) +GL_PROC(void, glDeleteShader, (GLuint a)) +GL_PROC(void, glUseProgram, (GLuint a)) +GL_PROC(void, glUniform1i, (GLint a, GLint b)) +GL_PROC(GLint, glGetUniformLocation, (GLuint a, const GLchar *b)) +GL_PROC(void, glVertexAttribPointer, (GLuint a, GLint b, GLenum c, GLboolean d, GLsizei e, const void *f)) +GL_PROC(void, glEnableVertexAttribArray, (GLuint a)) +GL_PROC(void, glDrawArrays, (GLenum a, GLint b, GLsizei c)) +GL_PROC(void, glDeleteProgram, (GLuint a)) +GL_PROC(void, glDeleteTextures, (GLsizei a, const GLuint *b)) diff --git a/FNA/lib/Theorafile/sdl2test/glmacros.h b/FNA/lib/Theorafile/sdl2test/glmacros.h new file mode 100644 index 0000000..7527fa7 --- /dev/null +++ b/FNA/lib/Theorafile/sdl2test/glmacros.h @@ -0,0 +1,25 @@ +#define glDepthMask INTERNAL_glDepthMask +#define glDisable INTERNAL_glDisable +#define glPixelStorei INTERNAL_glPixelStorei +#define glGenTextures INTERNAL_glGenTextures +#define glActiveTexture INTERNAL_glActiveTexture +#define glBindTexture INTERNAL_glBindTexture +#define glTexImage2D INTERNAL_glTexImage2D +#define glTexSubImage2D INTERNAL_glTexSubImage2D +#define glTexParameteri INTERNAL_glTexParameteri +#define glCreateShader INTERNAL_glCreateShader +#define glShaderSource INTERNAL_glShaderSource +#define glCompileShader INTERNAL_glCompileShader +#define glCreateProgram INTERNAL_glCreateProgram +#define glAttachShader INTERNAL_glAttachShader +#define glBindAttribLocation INTERNAL_glBindAttribLocation +#define glLinkProgram INTERNAL_glLinkProgram +#define glDeleteShader INTERNAL_glDeleteShader +#define glUseProgram INTERNAL_glUseProgram +#define glUniform1i INTERNAL_glUniform1i +#define glGetUniformLocation INTERNAL_glGetUniformLocation +#define glVertexAttribPointer INTERNAL_glVertexAttribPointer +#define glEnableVertexAttribArray INTERNAL_glEnableVertexAttribArray +#define glDrawArrays INTERNAL_glDrawArrays +#define glDeleteProgram INTERNAL_glDeleteProgram +#define glDeleteTextures INTERNAL_glDeleteTextures diff --git a/FNA/lib/Theorafile/sdl2test/sdl2test.c b/FNA/lib/Theorafile/sdl2test/sdl2test.c new file mode 100644 index 0000000..287a793 --- /dev/null +++ b/FNA/lib/Theorafile/sdl2test/sdl2test.c @@ -0,0 +1,365 @@ +/* Theorafile - Ogg Theora Video Decoder Library + * + * Copyright (c) 2017 Ethan Lee. + * Based on TheoraPlay, Copyright (c) 2011-2016 Ryan C. Gordon. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ + +#include +#include +#include +#include "theorafile.h" + +/* GL Function typedefs */ +#define GL_PROC(ret, func, parms) \ + typedef ret (GLAPIENTRY *glfntype_##func) parms; +#include "glfuncs.h" +#undef GL_PROC +/* GL Function declarations */ +#define GL_PROC(ret, func, parms) \ + glfntype_##func INTERNAL_##func; +#include "glfuncs.h" +#undef GL_PROC + +static const GLchar *GLVert = + "#version 110\n" + "attribute vec2 pos;\n" + "attribute vec2 tex;\n" + "void main() {\n" + "gl_Position = vec4(pos.xy, 0.0, 1.0);\n" + "gl_TexCoord[0].xy = tex;\n" + "}\n"; + +/* This shader was originally from SDL 1.3 */ +static const GLchar *GLFrag = + "#version 110\n" + "uniform sampler2D samp0;\n" + "uniform sampler2D samp1;\n" + "uniform sampler2D samp2;\n" + "const vec3 offset = vec3(-0.0625, -0.5, -0.5);\n" + "const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);\n" + "const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n" + "const vec3 Bcoeff = vec3(1.164, 2.018, 0.000);\n" + "void main() {\n" + " vec2 tcoord;\n" + " vec3 yuv, rgb;\n" + " tcoord = gl_TexCoord[0].xy;\n" + " yuv.x = texture2D(samp0, tcoord).r;\n" + " yuv.y = texture2D(samp1, tcoord).r;\n" + " yuv.z = texture2D(samp2, tcoord).r;\n" + " yuv += offset;\n" + " rgb.r = dot(yuv, Rcoeff);\n" + " rgb.g = dot(yuv, Gcoeff);\n" + " rgb.b = dot(yuv, Bcoeff);\n" + " gl_FragColor = vec4(rgb, 1.0);\n" + "}\n"; + +void AudioCallback(void *userdata, Uint8* stream, int len) +{ + const int samples = len / 4; + int read = tf_readaudio((OggTheora_File*) userdata, (float*) stream, samples); + if (read < samples) + { + SDL_memset(stream + read * 4, '\0', (samples - read) * 4); + } +} + +int main(int argc, char **argv) +{ + /* SDL variables */ + SDL_Window *window; + SDL_GLContext context; + SDL_AudioDeviceID audio; + SDL_AudioSpec spec; + SDL_Event evt; + Uint8 run = 1; + + /* Theorafile variables */ + OggTheora_File fileIn; + int width, height, channels, samplerate; + double fps; + int curframe = 0, thisframe, newframe; + char *frame = NULL; + + /* OpenGL variables */ + GLuint yuvTextures[3]; + GLuint vertex = 0; + GLuint fragment = 0; + GLuint program = 0; + GLint shaderlen = 0; + + /* Vertex client arrays */ + static struct { float pos[2]; float tex[2]; } verts[4] = { + { { -1.0f, 1.0f }, { 0.0f, 0.0f } }, + { { 1.0f, 1.0f }, { 1.0f, 0.0f } }, + { { -1.0f, -1.0f }, { 0.0f, 1.0f } }, + { { 1.0f, -1.0f }, { 1.0f, 1.0f } } + }; + + /* We need a file name! */ + if (argc < 2 || argc > 2) + { + SDL_Log("Need a file name!\n"); + return 1; + } + + /* Open the Theora file */ + if (tf_fopen(argv[1], &fileIn) < 0) + { + SDL_Log("Failed to open file.\n"); + return 1; + } + + /* This is a video test, people! */ + if (!tf_hasvideo(&fileIn)) + { + SDL_Log("No video!\n"); + return 1; + } + + /* Get the video metadata, allocate first frame */ + tf_videoinfo(&fileIn, &width, &height, &fps); + frame = (char*) SDL_malloc(width * height * 2); + while (!tf_readvideo(&fileIn, frame, 1)); + + /* Create window (and audio device, if applicable) */ + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); + window = SDL_CreateWindow( + "Theorafile Test", + SDL_WINDOWPOS_CENTERED, + SDL_WINDOWPOS_CENTERED, + width, + height, + SDL_WINDOW_OPENGL + ); + context = SDL_GL_CreateContext(window); + SDL_GL_SetSwapInterval(1); + + /* GL function loading */ + #define GL_PROC(ret, func, parms) \ + INTERNAL_##func = (glfntype_##func) SDL_GL_GetProcAddress(#func); + #include "glfuncs.h" + #undef GL_PROC + + /* Remap GL function names to internal entry points */ + #include "glmacros.h" + + if (tf_hasaudio(&fileIn)) + { + /* Get the audio metadata, allocate queue */ + tf_audioinfo(&fileIn, &channels, &samplerate); + SDL_zero(spec); + spec.freq = samplerate; + spec.format = AUDIO_F32; + spec.channels = channels; + spec.samples = 4096; + spec.callback = AudioCallback; + spec.userdata = &fileIn; + audio = SDL_OpenAudioDevice( + NULL, + 0, + &spec, + NULL, + 0 + ); + SDL_PauseAudioDevice(audio, 0); + } + + /* Initial GL state */ + glDepthMask(GL_FALSE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + /* YUV buffers */ + glGenTextures(3, yuvTextures); + #define GEN_TEXTURE(index, w, h, ptr) \ + glActiveTexture(GL_TEXTURE0 + index); \ + glBindTexture(GL_TEXTURE_2D, yuvTextures[index]); \ + glTexImage2D( \ + GL_TEXTURE_2D, \ + 0, \ + GL_LUMINANCE8, \ + w, \ + h, \ + 0, \ + GL_LUMINANCE, \ + GL_UNSIGNED_BYTE, \ + ptr \ + ); \ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); \ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); \ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); \ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); \ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); \ + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); + GEN_TEXTURE( + 0, + width, + height, + frame + ) + GEN_TEXTURE( + 1, + width / 2, + height / 2, + frame + (width * height) + ) + GEN_TEXTURE( + 2, + width / 2, + height / 2, + frame + (width * height) + (width / 2 * height / 2) + ) + #undef GEN_TEXTURE + + /* Vertex shader... */ + shaderlen = (GLint) SDL_strlen(GLVert); + vertex = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vertex, 1, &GLVert, &shaderlen); + glCompileShader(vertex); + + /* Fragment shader... */ + shaderlen = (GLint) SDL_strlen(GLFrag); + fragment = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fragment, 1, &GLFrag, &shaderlen); + glCompileShader(fragment); + + /* Program object... */ + program = glCreateProgram(); + glAttachShader(program, vertex); + glAttachShader(program, fragment); + glBindAttribLocation(program, 0, "pos"); + glBindAttribLocation(program, 1, "tex"); + glLinkProgram(program); + glDeleteShader(vertex); + glDeleteShader(fragment); + + /* ... Finally. */ + glUseProgram(program); + glUniform1i(glGetUniformLocation(program, "samp0"), 0); + glUniform1i(glGetUniformLocation(program, "samp1"), 1); + glUniform1i(glGetUniformLocation(program, "samp2"), 2); + + /* Vertex buffers */ + glVertexAttribPointer(0, 2, GL_FLOAT, 0, sizeof (verts[0]), &verts[0].pos[0]); + glVertexAttribPointer(1, 2, GL_FLOAT, 0, sizeof (verts[0]), &verts[0].tex[0]); + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + + while (run) + { + while (SDL_PollEvent(&evt)) + { + if (evt.type == SDL_QUIT) + { + run = 0; + } + else if (evt.type == SDL_KEYDOWN) + { + /* Slowdown simulator */ + SDL_Delay(1000); + } + } + + /* Loop this video! */ + SDL_LockAudioDevice(audio); + if (tf_eos(&fileIn)) + { + tf_reset(&fileIn); + } + SDL_UnlockAudioDevice(audio); + + /* Based on when we started, what frame should we be on? */ + thisframe = (int) (SDL_GetTicks() / (1000.0 / fps)); + if (thisframe > curframe) + { + /* Keep reading frames until we're caught up */ + SDL_LockAudioDevice(audio); + newframe = tf_readvideo(&fileIn, frame, thisframe - curframe); + SDL_UnlockAudioDevice(audio); + curframe = thisframe; + + /* Only update the textures if we need to! */ + if (newframe) + { + glActiveTexture(GL_TEXTURE0); + glTexSubImage2D( + GL_TEXTURE_2D, + 0, + 0, + 0, + width, + height, + GL_LUMINANCE, + GL_UNSIGNED_BYTE, + frame + ); + glActiveTexture(GL_TEXTURE1); + glTexSubImage2D( + GL_TEXTURE_2D, + 0, + 0, + 0, + width / 2, + height / 2, + GL_LUMINANCE, + GL_UNSIGNED_BYTE, + frame + (width * height) + ); + glActiveTexture(GL_TEXTURE2); + glTexSubImage2D( + GL_TEXTURE_2D, + 0, + 0, + 0, + width / 2, + height / 2, + GL_LUMINANCE, + GL_UNSIGNED_BYTE, + frame + (width * height) + (width / 2 * height / 2) + ); + } + } + + /* Draw! */ + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + SDL_GL_SwapWindow(window); + } + + /* Clean up. We out. */ + glDeleteProgram(program); + glDeleteTextures(3, yuvTextures); + SDL_free(frame); + if (tf_hasaudio(&fileIn)) + { + SDL_CloseAudioDevice(audio); + } + tf_close(&fileIn); + SDL_GL_DeleteContext(context); + SDL_DestroyWindow(window); + SDL_Quit(); + SDL_Log("Test complete.\n"); + return 0; +} diff --git a/FNA/lib/Theorafile/theorafile.c b/FNA/lib/Theorafile/theorafile.c new file mode 100644 index 0000000..91b5cb6 --- /dev/null +++ b/FNA/lib/Theorafile/theorafile.c @@ -0,0 +1,573 @@ +/* Theorafile - Ogg Theora Video Decoder Library + * + * Copyright (c) 2017 Ethan Lee. + * Based on TheoraPlay, Copyright (c) 2011-2016 Ryan C. Gordon. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ + +#include "theorafile.h" + +#include /* fopen and friends */ +#include /* memcpy, memset */ + +#define TF_DEFAULT_BUFFER_SIZE 4096 + +#ifdef _WIN32 +#define inline __inline +#endif /* _WIN32 */ + +static inline int INTERNAL_readOggData(OggTheora_File *file) +{ + long buflen = TF_DEFAULT_BUFFER_SIZE; + char *buffer = ogg_sync_buffer(&file->sync, buflen); + if (buffer == NULL) + { + /* If you made it here, you ran out of RAM (wait, what?) */ + return -1; + } + + buflen = file->io.read_func(buffer, 1, buflen, file->datasource); + if (buflen <= 0) + { + return 0; + } + + return (ogg_sync_wrote(&file->sync, buflen) == 0) ? 1 : -1; +} + +static inline void INTERNAL_queueOggPage(OggTheora_File *file) +{ + if (file->tpackets) + { + ogg_stream_pagein(&file->tstream, &file->page); + } + if (file->vpackets) + { + ogg_stream_pagein(&file->vstream, &file->page); + } +} + +static inline int INTERNAL_getNextPacket( + OggTheora_File *file, + ogg_stream_state *stream, + ogg_packet *packet +) { + while (ogg_stream_packetout(stream, packet) <= 0) + { + const int rc = INTERNAL_readOggData(file); + if (rc == 0) + { + file->eos = 1; + return 0; + } + else if (rc < 0) + { + /* If you made it here, something REALLY bad happened. + * + * Unfortunately, ogg_sync_wrote does not give out any + * codes, so I have no idea what that something is. + * + * Be sure you're not doing something nasty like + * accessing one file via multiple threads at one time. + * -flibit + */ + file->eos = 1; + return 0; + } + else + { + while (ogg_sync_pageout(&file->sync, &file->page) > 0) + { + INTERNAL_queueOggPage(file); + } + } + } + return 1; +} + +int tf_open_callbacks(void *datasource, OggTheora_File *file, tf_callbacks io) +{ + ogg_packet packet; + ogg_stream_state filler; + th_setup_info *tsetup = NULL; + int pp_level_max = 0; + int errcode = TF_EUNKNOWN; + + if (datasource == NULL) + { + return TF_ENODATASOURCE; + } + + memset(file, '\0', sizeof(OggTheora_File)); + file->datasource = datasource; + file->io = io; + + #define TF_OPEN_ASSERT(cond) \ + if (cond) goto fail; + + + ogg_sync_init(&file->sync); + vorbis_info_init(&file->vinfo); + vorbis_comment_init(&file->vcomment); + th_info_init(&file->tinfo); + th_comment_init(&file->tcomment); + + /* Is there even data for us to read...? */ + TF_OPEN_ASSERT(INTERNAL_readOggData(file) <= 0) + + /* Read header */ + while (ogg_sync_pageout(&file->sync, &file->page) > 0) + { + if (!ogg_page_bos(&file->page)) + { + /* Not a header! */ + INTERNAL_queueOggPage(file); + break; + } + + ogg_stream_init(&filler, ogg_page_serialno(&file->page)); + ogg_stream_pagein(&filler, &file->page); + ogg_stream_packetout(&filler, &packet); + + if (!file->tpackets && (th_decode_headerin( + &file->tinfo, + &file->tcomment, + &tsetup, + &packet + ) >= 0)) { + memcpy(&file->tstream, &filler, sizeof(filler)); + file->tpackets = 1; + } + else if (!file->vpackets && (vorbis_synthesis_headerin( + &file->vinfo, + &file->vcomment, + &packet + ) >= 0)) { + memcpy(&file->vstream, &filler, sizeof(filler)); + file->vpackets = 1; + } + else + { + /* Whatever it is, we don't care about it */ + ogg_stream_clear(&filler); + } + } + + /* No audio OR video? */ + TF_OPEN_ASSERT(!file->tpackets && !file->vpackets) + + /* Apparently there are 2 more theora and 2 more vorbis headers next. */ + #define TPACKETS (file->tpackets && (file->tpackets < 3)) + #define VPACKETS (file->vpackets && (file->vpackets < 3)) + while (TPACKETS || VPACKETS) + { + while (TPACKETS) + { + if (ogg_stream_packetout( + &file->tstream, + &packet + ) != 1) { + /* Get more data? */ + break; + } + TF_OPEN_ASSERT(!th_decode_headerin( + &file->tinfo, + &file->tcomment, + &tsetup, + &packet + )) + file->tpackets += 1; + } + + while (VPACKETS) + { + if (ogg_stream_packetout( + &file->vstream, + &packet + ) != 1) { + /* Get more data? */ + break; + } + TF_OPEN_ASSERT(vorbis_synthesis_headerin( + &file->vinfo, + &file->vcomment, + &packet + )) + file->vpackets += 1; + } + + /* Get another page, try again? */ + if (ogg_sync_pageout(&file->sync, &file->page) > 0) + { + INTERNAL_queueOggPage(file); + } + else + { + TF_OPEN_ASSERT(INTERNAL_readOggData(file) < 0) + } + } + #undef TPACKETS + #undef VPACKETS + + /* Set up Theora stream */ + if (file->tpackets) + { + /* th_decode_alloc() docs say to check for + * insanely large frames yourself. + */ + TF_OPEN_ASSERT( + (file->tinfo.frame_width > 99999) || + (file->tinfo.frame_height > 99999) + ) + + /* FIXME: We treat "unspecified" as NTSC :shrug: */ + if ( (file->tinfo.colorspace != TH_CS_UNSPECIFIED) && + (file->tinfo.colorspace != TH_CS_ITU_REC_470M) && + (file->tinfo.colorspace != TH_CS_ITU_REC_470BG) ) + { + errcode = TF_EUNSUPPORTED; + goto fail; + } + + /* FIXME: We only support YUV420 :shrug: */ + if (file->tinfo.pixel_fmt != TH_PF_420) + { + errcode = TF_EUNSUPPORTED; + goto fail; + } + + /* The decoder, at last! */ + file->tdec = th_decode_alloc(&file->tinfo, tsetup); + TF_OPEN_ASSERT(!file->tdec) + + /* Set decoder to maximum post-processing level. + * Theoretically we could try dropping this level if we're + * not keeping up. + * + * FIXME: Maybe an API to set this? + * FIXME: Could be TH_DECCTL_GET_PPLEVEL_MAX, for example! + */ + th_decode_ctl( + file->tdec, + TH_DECCTL_SET_PPLEVEL, + &pp_level_max, + sizeof(pp_level_max) + ); + } + + /* Done with this now */ + if (tsetup != NULL) + { + th_setup_free(tsetup); + tsetup = NULL; + } + + /* Set up Vorbis stream */ + if (file->vpackets) + { + file->vdsp_init = vorbis_synthesis_init( + &file->vdsp, + &file->vinfo + ) == 0; + TF_OPEN_ASSERT(!file->vdsp_init) + file->vblock_init = vorbis_block_init( + &file->vdsp, + &file->vblock + ) == 0; + TF_OPEN_ASSERT(!file->vblock_init) + } + + #undef TF_OPEN_ASSERT + + /* Finally. */ + return 0; +fail: + if (tsetup != NULL) + { + th_setup_free(tsetup); + } + tf_close(file); + return errcode; +} + +int tf_fopen(const char *fname, OggTheora_File *file) +{ + tf_callbacks io = + { + (size_t (*) (void*, size_t, size_t, void*)) fread, + (int (*) (void*, ogg_int64_t, int)) fseek, + (int (*) (void*)) fclose, + }; + return tf_open_callbacks( + fopen(fname, "rb"), + file, + io + ); +} + +void tf_close(OggTheora_File *file) +{ + /* Theora Data */ + if (file->tdec != NULL) + { + th_decode_free(file->tdec); + } + + /* Vorbis Data */ + if (file->vblock_init) + { + vorbis_block_clear(&file->vblock); + } + if (file->vdsp_init) + { + vorbis_dsp_clear(&file->vdsp); + } + + /* Stream Data */ + if (file->tpackets) + { + ogg_stream_clear(&file->tstream); + } + if (file->vpackets) + { + ogg_stream_clear(&file->vstream); + } + + /* Metadata */ + th_info_clear(&file->tinfo); + th_comment_clear(&file->tcomment); + vorbis_comment_clear(&file->vcomment); + vorbis_info_clear(&file->vinfo); + + /* Current State */ + ogg_sync_clear(&file->sync); + + /* I/O Data */ + if (file->io.close_func != NULL) + { + file->io.close_func(file->datasource); + } +} + +int tf_hasvideo(OggTheora_File *file) +{ + return file->tpackets != 0; +} + +int tf_hasaudio(OggTheora_File *file) +{ + return file->vpackets != 0; +} + +void tf_videoinfo(OggTheora_File *file, int *width, int *height, double *fps) +{ + if (width != NULL) + { + *width = file->tinfo.pic_width; + } + if (height != NULL) + { + *height = file->tinfo.pic_height; + } + if (fps != NULL) + { + if (file->tinfo.fps_denominator != 0) + { + *fps = ( + ((double) file->tinfo.fps_numerator) / + ((double) file->tinfo.fps_denominator) + ); + } + else + { + *fps = 0.0; + } + } +} + +void tf_audioinfo(OggTheora_File *file, int *channels, int *samplerate) +{ + if (channels != NULL) + { + *channels = file->vinfo.channels; + } + if (samplerate != NULL) + { + *samplerate = file->vinfo.rate; + } +} + +int tf_eos(OggTheora_File *file) +{ + return file->eos; +} + +void tf_reset(OggTheora_File *file) +{ + if (file->tpackets) + { + ogg_stream_reset(&file->tstream); + } + if (file->vpackets) + { + ogg_stream_reset(&file->vstream); + } + ogg_sync_reset(&file->sync); + file->io.seek_func(file->datasource, 0, SEEK_SET); + file->eos = 0; +} + +int tf_readvideo(OggTheora_File *file, char *buffer, int numframes) +{ + int i; + char *dst = buffer; + ogg_int64_t granulepos = 0; + ogg_packet packet; + th_ycbcr_buffer ycbcr; + int rc; + int w, h, off; + unsigned char *plane; + int stride; + int retval = 0; + + for (i = 0; i < numframes; i += 1) + { + /* Keep trying to get a usable packet */ + if (!INTERNAL_getNextPacket(file, &file->tstream, &packet)) + { + /* ... unless there's nothing left for us to read. */ + if (retval) + { + break; + } + return 0; + } + + rc = th_decode_packetin( + file->tdec, + &packet, + &granulepos + ); + + if (rc == 0) /* New frame! */ + { + retval = 1; + } + else if (rc != TH_DUPFRAME) + { + return 0; /* Why did we get here...? */ + } + } + + if (retval) /* New frame! */ + { + if (th_decode_ycbcr_out(file->tdec, ycbcr) != 0) + { + return 0; /* Uhh?! */ + } + + #define TF_COPY_CHANNEL(chan) \ + plane = ycbcr[chan].data + off; \ + stride = ycbcr[chan].stride; \ + for (i = 0; i < h; i += 1, dst += w) \ + { \ + memcpy( \ + dst, \ + plane + (stride * i), \ + w \ + ); \ + } + /* Y */ + w = file->tinfo.pic_width; + h = file->tinfo.pic_height; + off = ( + (file->tinfo.pic_x & ~1) + + ycbcr[0].stride * + (file->tinfo.pic_y & ~1) + ); + TF_COPY_CHANNEL(0) + + /* U/V */ + w /= 2; + h /= 2; + off = ( + (file->tinfo.pic_x / 2) + + (ycbcr[1].stride) * + (file->tinfo.pic_y / 2) + ); + TF_COPY_CHANNEL(1) + TF_COPY_CHANNEL(2) + #undef TF_COPY_CHANNEL + } + return retval; +} + +int tf_readaudio(OggTheora_File *file, float *buffer, int length) +{ + int offset = 0; + int chan, frame; + ogg_packet packet; + float **pcm = NULL; + + while (offset < length) + { + const int frames = vorbis_synthesis_pcmout(&file->vdsp, &pcm); + if (frames > 0) + { + /* I bet this beats the crap out of the CPU cache... */ + for (frame = 0; frame < frames; frame += 1) + for (chan = 0; chan < file->vinfo.channels; chan += 1) + { + buffer[offset++] = pcm[chan][frame]; + if (offset >= length) + { + vorbis_synthesis_read( + &file->vdsp, + frame + ); + return offset; + } + } + vorbis_synthesis_read(&file->vdsp, frames); + } + else /* No audio available left in current packet? */ + { + /* Keep trying to get a usable packet */ + if (!INTERNAL_getNextPacket(file, &file->vstream, &packet)) + { + /* ... unless there's nothing left for us to read. */ + return offset; + } + if (vorbis_synthesis( + &file->vblock, + &packet + ) == 0) { + vorbis_synthesis_blockin( + &file->vdsp, + &file->vblock + ); + } + } + } + return offset; +} diff --git a/FNA/lib/Theorafile/theorafile.h b/FNA/lib/Theorafile/theorafile.h new file mode 100644 index 0000000..70a9be0 --- /dev/null +++ b/FNA/lib/Theorafile/theorafile.h @@ -0,0 +1,131 @@ +/* Theorafile - Ogg Theora Video Decoder Library + * + * Copyright (c) 2017 Ethan Lee. + * Based on TheoraPlay, Copyright (c) 2011-2016 Ryan C. Gordon. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ + +#ifndef THEORAFILE_H +#define THEORAFILE_H + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifndef DECLSPEC +#if defined(_WIN32) +#define DECLSPEC __declspec(dllexport) +#else +#define DECLSPEC +#endif +#endif + +/* I/O Handle + Callbacks */ +typedef struct tf_callbacks +{ + size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); + int (*seek_func) (void *datasource, ogg_int64_t offset, int origin); + int (*close_func) (void *datasource); +} tf_callbacks; + +/* File Handle */ +typedef struct OggTheora_File +{ + /* Current State */ + ogg_sync_state sync; + ogg_page page; + int eos; + + /* Stream Data */ + int tpackets; + int vpackets; + ogg_stream_state tstream; + ogg_stream_state vstream; + + /* Metadata */ + th_info tinfo; + vorbis_info vinfo; + th_comment tcomment; + vorbis_comment vcomment; + + /* Theora Data */ + th_dec_ctx *tdec; + + /* Vorbis Data */ + int vdsp_init; + vorbis_dsp_state vdsp; + int vblock_init; + vorbis_block vblock; + + /* I/O Data */ + tf_callbacks io; + void *datasource; +} OggTheora_File; + +/* Open/Close */ +#define TF_EUNKNOWN -1 +#define TF_EUNSUPPORTED -2 +#define TF_ENODATASOURCE -3 +DECLSPEC int tf_open_callbacks( + void *datasource, + OggTheora_File *file, + tf_callbacks io +); +DECLSPEC int tf_fopen( + const char *fname, + OggTheora_File *file +); +DECLSPEC void tf_close(OggTheora_File *file); + +/* File Info */ +DECLSPEC int tf_hasvideo(OggTheora_File *file); +DECLSPEC int tf_hasaudio(OggTheora_File *file); +DECLSPEC void tf_videoinfo( + OggTheora_File *file, + int *width, + int *height, + double *fps +); +DECLSPEC void tf_audioinfo( + OggTheora_File *file, + int *channels, + int *samplerate +); + +/* Stream State */ +DECLSPEC int tf_eos(OggTheora_File *file); +DECLSPEC void tf_reset(OggTheora_File *file); + +/* Data Reading */ +DECLSPEC int tf_readvideo(OggTheora_File *file, char *buffer, int numframes); +DECLSPEC int tf_readaudio(OggTheora_File *file, float *buffer, int length); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* THEORAFILE_H */ diff --git a/FNA/lib/Theorafile/visualc-winrt/README b/FNA/lib/Theorafile/visualc-winrt/README new file mode 100644 index 0000000..6e4db4b --- /dev/null +++ b/FNA/lib/Theorafile/visualc-winrt/README @@ -0,0 +1,19 @@ +Building Theorafile for UWP +--------------------------- +Theorafile uses Visual Studio 2017 to build on Xbox One. + +Dependencies +------------ +Before building, download libogg/libvorbis/libtheora from the Xiph website: + +https://xiph.org/downloads/ + +After extracting the zip files, be sure to rename the directories to remove the +version numbers (for example, 'libogg-1.3.2' should be 'libogg'). + +Compiling +--------- +1. Rename libvorbis/lib/info.c to libvorbis/lib/vinfo.c +2. Rename libtheora/lib/info.c to libtheora/lib/tinfo.c +3. Build Theorafile/visualc-winrt/libtheorafile.sln +4. Grab the output DLL, ship it! diff --git a/FNA/lib/Theorafile/visualc-winrt/libtheorafile.sln b/FNA/lib/Theorafile/visualc-winrt/libtheorafile.sln new file mode 100644 index 0000000..4a9a2e1 --- /dev/null +++ b/FNA/lib/Theorafile/visualc-winrt/libtheorafile.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2000 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtheorafile", "libtheorafile.vcxproj", "{8F981FCD-813B-44F1-A6A3-9D1C7AA3A8AB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8F981FCD-813B-44F1-A6A3-9D1C7AA3A8AB}.Debug|x64.ActiveCfg = Debug|x64 + {8F981FCD-813B-44F1-A6A3-9D1C7AA3A8AB}.Debug|x64.Build.0 = Debug|x64 + {8F981FCD-813B-44F1-A6A3-9D1C7AA3A8AB}.Release|x64.ActiveCfg = Release|x64 + {8F981FCD-813B-44F1-A6A3-9D1C7AA3A8AB}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AFA98898-C297-401A-AA32-D0B17544493C} + EndGlobalSection +EndGlobal diff --git a/FNA/lib/Theorafile/visualc-winrt/libtheorafile.vcxproj b/FNA/lib/Theorafile/visualc-winrt/libtheorafile.vcxproj new file mode 100644 index 0000000..5e750a4 --- /dev/null +++ b/FNA/lib/Theorafile/visualc-winrt/libtheorafile.vcxproj @@ -0,0 +1,131 @@ + + + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {8f981fcd-813b-44f1-a6a3-9d1c7aa3a8ab} + DynamicLibrary + libtheorafile + en-US + 14.0 + true + Windows Store + 10.0.16299.0 + 10.0.16299.0 + 10.0 + + + + DynamicLibrary + true + v141 + + + DynamicLibrary + false + true + v141 + + + + + + + + + + + + + + + + false + false + + + false + false + + + + NotUsing + false + ..\..\libogg\include;..\..\libvorbis\include;..\..\libtheora\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\libogg\include;..\..\libvorbis\include;..\..\libtheora\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + Console + false + false + + + + + + diff --git a/FNA/lib/Theorafile/visualc/README b/FNA/lib/Theorafile/visualc/README new file mode 100644 index 0000000..2ea1913 --- /dev/null +++ b/FNA/lib/Theorafile/visualc/README @@ -0,0 +1,34 @@ +Building Theorafile for Windows +------------------------------- +Theorafile uses Visual Studio 2010 to build on Windows. + +Dependencies +------------ +Before building, download libogg/libvorbis from the Xiph website: + +https://xiph.org/downloads/ + +After extracting the zip files, be sure to rename the directories to remove the +version numbers (for example, 'libogg-1.3.2' should be 'libogg'). + +As of writing, libtheora 1.1.1 does not build with Visual Studio 2010. Instead, +download the upstream version via Git: + +git clone git://github.com/xiph/theora.git libtheora + +If building the sdl2test program, download SDL2's Visual Studio libraries: + +http://libsdl.org/download-2.0.php + +After extracting the zip file, be sure to rename the directory to remove the +version number (for example, 'SDL2-2.0.5' should be 'SDL2'). + +Compiling +--------- +1. Build libogg/win32/VS2010/libogg_dynamic.sln +2. Build libvorbis/win32/VS2010/libvorbis_dynamic.sln +3. Build libtheora/win32/VS2010/libtheora_dynamic.sln +4. Build Theorafile/visualc/libtheorafile.sln +5. Grab the output DLL from each project, ship it! + +Be sure your build configurations match for each library! diff --git a/FNA/lib/Theorafile/visualc/libtheorafile.sln b/FNA/lib/Theorafile/visualc/libtheorafile.sln new file mode 100644 index 0000000..ae63541 --- /dev/null +++ b/FNA/lib/Theorafile/visualc/libtheorafile.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtheorafile", "libtheorafile\libtheorafile.vcxproj", "{90A103EF-E403-47D4-BBBB-0F206B9FA7F2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl2test", "sdl2test\sdl2test.vcxproj", "{127F9801-EAA6-468F-9699-3802B39BC714}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Debug|Win32.ActiveCfg = Debug|Win32 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Debug|Win32.Build.0 = Debug|Win32 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Release|Win32.ActiveCfg = Release|Win32 + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2}.Release|Win32.Build.0 = Release|Win32 + {127F9801-EAA6-468F-9699-3802B39BC714}.Debug|Win32.ActiveCfg = Debug|Win32 + {127F9801-EAA6-468F-9699-3802B39BC714}.Debug|Win32.Build.0 = Debug|Win32 + {127F9801-EAA6-468F-9699-3802B39BC714}.Release|Win32.ActiveCfg = Release|Win32 + {127F9801-EAA6-468F-9699-3802B39BC714}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/FNA/lib/Theorafile/visualc/libtheorafile/libtheorafile.vcxproj b/FNA/lib/Theorafile/visualc/libtheorafile/libtheorafile.vcxproj new file mode 100644 index 0000000..7f134ba --- /dev/null +++ b/FNA/lib/Theorafile/visualc/libtheorafile/libtheorafile.vcxproj @@ -0,0 +1,80 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {90A103EF-E403-47D4-BBBB-0F206B9FA7F2} + libtheorafile + + + + DynamicLibrary + true + MultiByte + + + DynamicLibrary + false + true + MultiByte + + + + + + + + + + + + + ..\..\..\libtheora\include;..\..\..\libvorbis\include;..\..\..\libogg\include;$(IncludePath) + ..\..\..\libtheora\win32\VS2010\Win32\$(Configuration);..\..\..\libvorbis\win32\VS2010\Win32\$(Configuration);..\..\..\libogg\win32\VS2010\Win32\$(Configuration);$(LibraryPath) + + + ..\..\..\libtheora\include;..\..\..\libvorbis\include;..\..\..\libogg\include;$(IncludePath) + ..\..\..\libtheora\win32\VS2010\Win32\$(Configuration);..\..\..\libvorbis\win32\VS2010\Win32\$(Configuration);..\..\..\libogg\win32\VS2010\Win32\$(Configuration);$(LibraryPath) + + + + Level3 + Disabled + + + true + libtheora.lib;libvorbis.lib;libogg.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + + + true + true + true + libtheora.lib;libvorbis.lib;libogg.lib;%(AdditionalDependencies) + + + + + + + + + + + + diff --git a/FNA/lib/Theorafile/visualc/sdl2test/sdl2test.vcxproj b/FNA/lib/Theorafile/visualc/sdl2test/sdl2test.vcxproj new file mode 100644 index 0000000..439ab1a --- /dev/null +++ b/FNA/lib/Theorafile/visualc/sdl2test/sdl2test.vcxproj @@ -0,0 +1,84 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {127F9801-EAA6-468F-9699-3802B39BC714} + sdl2test + + + + Application + true + MultiByte + + + Application + false + true + MultiByte + + + + + + + + + + + + + ..\..\..\SDL2\include;..\..\..\libtheora\include;..\..\..\libvorbis\include;..\..\..\libogg\include;..\..\;$(IncludePath) + ..\..\..\SDL2\lib\$(PlatformShortName);..\$(Configuration);$(LibraryPath) + + + ..\..\..\SDL2\include;..\..\..\libtheora\include;..\..\..\libvorbis\include;..\..\..\libogg\include;..\..\;$(IncludePath) + ..\..\..\SDL2\lib\$(PlatformShortName);..\$(Configuration);$(LibraryPath) + + + + Level3 + Disabled + Default + + + true + SDL2.lib;SDL2main.lib;libtheorafile.lib;%(AdditionalDependencies) + Console + + + + + Level3 + MaxSpeed + true + true + + + true + true + true + SDL2.lib;SDL2main.lib;libtheorafile.lib;%(AdditionalDependencies) + Console + + + + + + + + + + + + + diff --git a/FNA/lib/Vorbisfile-CS/.gitignore b/FNA/lib/Vorbisfile-CS/.gitignore new file mode 100644 index 0000000..ddb8b56 --- /dev/null +++ b/FNA/lib/Vorbisfile-CS/.gitignore @@ -0,0 +1,5 @@ +bin/ +obj/ +*.pidb +*.userprefs +*.suo diff --git a/FNA/lib/Vorbisfile-CS/Makefile b/FNA/lib/Vorbisfile-CS/Makefile new file mode 100644 index 0000000..cac5518 --- /dev/null +++ b/FNA/lib/Vorbisfile-CS/Makefile @@ -0,0 +1,10 @@ +# Makefile for Vorbisfile# +# Written by Ethan "flibitijibibo" Lee + +build: clean + mkdir bin + cp Vorbisfile-CS.dll.config bin + dmcs /unsafe -debug -out:bin/Vorbisfile-CS.dll -target:library Vorbisfile.cs + +clean: + rm -rf bin diff --git a/FNA/lib/Vorbisfile-CS/README b/FNA/lib/Vorbisfile-CS/README new file mode 100644 index 0000000..d9b33ef --- /dev/null +++ b/FNA/lib/Vorbisfile-CS/README @@ -0,0 +1,23 @@ +This is Vorbisfile#, a C# wrapper for Vorbisfile, a library for quickly and +easily decoding Ogg Vorbis audio files. + +License +------- +Vorbisfile is released under a BSD-style license. +Vorbisfile# is released under the zlib license. +See the licenses/ folder for details. + +About Vorbisfile +---------------- +For more information about Vorbisfile, visit the website: + +http://www.xiph.org/vorbis/doc/vorbisfile/ + +About Vorbisfile# +----------------- +Vorbisfile# was written for FNA's Song support. We stream the Ogg Vorbis data +into a DynamicSoundEffectInstance, allowing for portable Vorbis playback. + +Building Vorbisfile# +-------------------- +Just type `make` in the root directory! diff --git a/FNA/lib/Vorbisfile-CS/Vorbisfile-CS.csproj b/FNA/lib/Vorbisfile-CS/Vorbisfile-CS.csproj new file mode 100644 index 0000000..9e7fadf --- /dev/null +++ b/FNA/lib/Vorbisfile-CS/Vorbisfile-CS.csproj @@ -0,0 +1,44 @@ + + + + Debug + x86 + 9.0.21022 + 2.0 + {C976BE87-E250-4120-9826-98B6C2CD7496} + Library + Vorbisfile + Vorbisfile-CS + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + x86 + false + true + + + none + false + bin\Release + prompt + 4 + x86 + false + true + + + + + + + + Always + + + diff --git a/FNA/lib/Vorbisfile-CS/Vorbisfile-CS.dll.config b/FNA/lib/Vorbisfile-CS/Vorbisfile-CS.dll.config new file mode 100644 index 0000000..a7af866 --- /dev/null +++ b/FNA/lib/Vorbisfile-CS/Vorbisfile-CS.dll.config @@ -0,0 +1,5 @@ + + + + + diff --git a/FNA/lib/Vorbisfile-CS/Vorbisfile-CS.sln b/FNA/lib/Vorbisfile-CS/Vorbisfile-CS.sln new file mode 100644 index 0000000..5e3db0a --- /dev/null +++ b/FNA/lib/Vorbisfile-CS/Vorbisfile-CS.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vorbisfile-CS", "Vorbisfile-CS.csproj", "{47CF0C2E-3710-4188-BB11-30D248B2B5FB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {47CF0C2E-3710-4188-BB11-30D248B2B5FB}.Debug|x86.ActiveCfg = Debug|x86 + {47CF0C2E-3710-4188-BB11-30D248B2B5FB}.Debug|x86.Build.0 = Debug|x86 + {47CF0C2E-3710-4188-BB11-30D248B2B5FB}.Release|x86.ActiveCfg = Release|x86 + {47CF0C2E-3710-4188-BB11-30D248B2B5FB}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = Vorbisfile-CS.csproj + EndGlobalSection +EndGlobal diff --git a/FNA/lib/Vorbisfile-CS/Vorbisfile.cs b/FNA/lib/Vorbisfile-CS/Vorbisfile.cs new file mode 100644 index 0000000..22260a1 --- /dev/null +++ b/FNA/lib/Vorbisfile-CS/Vorbisfile.cs @@ -0,0 +1,295 @@ +#region License +/* Vorbisfile# - C# Wrapper for Vorbisfile + * + * Copyright (c) 2013-2015 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +public static class Vorbisfile +{ + #region Native Library Name + + private const string nativeLibName = "libvorbisfile.dll"; + + #endregion + + #region malloc/free Entry Points + + // Yes, we're seriously using these. -flibit + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr malloc(IntPtr size); + + [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] + private static extern void free(IntPtr memblock); + + #endregion + + #region C stdio Macros + + // Used by ov_callbacks, seek_func + public enum SeekWhence : int + { + SEEK_SET = 0, + SEEK_CUR = 1, + SEEK_END = 2 + } + + #endregion + + #region Vorbis Delegates + + /* IntPtr refers to a size_t */ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr read_func( + IntPtr ptr, // Refers to a void* + IntPtr size, // Refers to a size_t + IntPtr nmemb, // Refers to a size_t + IntPtr datasource // Refers to a void* + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int seek_func( + IntPtr datasource, // Refers to a void* + long offset, // Refers to an ogg_int64_t + SeekWhence whence + ); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate int close_func( + IntPtr datasource // Refers to a void* + ); + + /* IntPtr refers to a long, ignoring Win64! */ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate IntPtr tell_func( + IntPtr datasource // Refers to a void* + ); + + #endregion + + #region Vorbis Structures + + [StructLayout(LayoutKind.Sequential)] + public struct vorbis_info + { + public int version; + public int channels; + public IntPtr rate; // refers to a long, ignoring Win64! + public IntPtr bitrate_upper; // refers to a long, ignoring Win64! + public IntPtr bitrate_nominal; // refers to a long, ignoring Win64! + public IntPtr bitrate_lower; // refers to a long, ignoring Win64! + public IntPtr bitrate_window; // refers to a long, ignoring Win64! + public IntPtr codec_setup; // Refers to a void* + } + + [StructLayout(LayoutKind.Sequential)] + public struct vorbis_comment + { + public IntPtr user_comments; // Refers to a char** + public IntPtr comment_lengths; // Refers to an int* + public int comments; + public IntPtr vendor; // Refers to a char* + } + + [StructLayout(LayoutKind.Sequential)] + public struct ov_callbacks + { + public read_func read_func; + public seek_func seek_func; + public close_func close_func; + public tell_func tell_func; + } + + #endregion + + #region Vorbisfile Implementation + + [DllImport(nativeLibName, EntryPoint = "ov_fopen", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_ov_fopen( + [In()] [MarshalAs(UnmanagedType.LPStr)] + string path, + IntPtr vf + ); + public static int ov_fopen(string path, out IntPtr vf) + { + vf = AllocVorbisFile(); + return INTERNAL_ov_fopen(path, vf); + } + + [DllImport(nativeLibName, EntryPoint = "ov_open_callbacks", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_ov_open_callbacks( + IntPtr datasource, + IntPtr vf, + IntPtr initial, + IntPtr ibytes, + ov_callbacks callbacks + ); + public static int ov_open_callbacks( + IntPtr datasource, // Refers to a void* + out IntPtr vf, + IntPtr initial, // Refers to a char* + IntPtr ibytes, // Refers to a long, ignoring Win64! + ov_callbacks callbacks + ) { + vf = AllocVorbisFile(); + return INTERNAL_ov_open_callbacks( + datasource, + vf, + initial, + ibytes, + callbacks + ); + } + + [DllImport(nativeLibName, EntryPoint = "ov_info", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_ov_info( + IntPtr vf, + int link + ); + public static vorbis_info ov_info( + IntPtr vf, + int link + ) { + IntPtr result = INTERNAL_ov_info(vf, link); + vorbis_info info = (vorbis_info) Marshal.PtrToStructure( + result, + typeof(vorbis_info) + ); + return info; + } + + [DllImport(nativeLibName, EntryPoint = "ov_comment", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr INTERNAL_ov_comment( + IntPtr vf, + int link + ); + public static vorbis_comment ov_comment( + IntPtr vf, + int link + ) { + IntPtr result = INTERNAL_ov_comment(vf, link); + vorbis_comment comment = (vorbis_comment) Marshal.PtrToStructure( + result, + typeof(vorbis_comment) + ); + return comment; + } + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern double ov_time_total(IntPtr vf, int i); + + /* IntPtr refers to a long, ignoring Win64! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr ov_read( + IntPtr vf, + byte[] buffer, + int length, + int bigendianp, + int word, + int sgned, + out int current_section + ); + + /* IntPtr refers to a long, ignoring Win64! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr ov_read( + IntPtr vf, + IntPtr buffer, + int length, + int bigendianp, + int word, + int sgned, + out int current_section + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int ov_time_seek(IntPtr vf, double s); + + [DllImport(nativeLibName, EntryPoint = "ov_clear", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_ov_clear(IntPtr vf); + public static int ov_clear(ref IntPtr vf) + { + int result = INTERNAL_ov_clear(vf); + free(vf); + vf = IntPtr.Zero; + return result; + } + + #endregion + + #region OggVorbis_File Allocator + + /* Notice that we did not implement an OggVorbis_File struct, but are + * instead using a pointer natively malloc'd. + * + * C# Interop for Vorbisfile structs is basically impossible to do, so + * we just alloc what _should_ be the full size of the structure for + * the OS and architecture, then pass that around as if that's a real + * struct. The size is just what you get from sizeof(OggVorbis_File). + * + * Don't get mad at me, get mad at C#. + * + * -flibit + */ + + private static IntPtr AllocVorbisFile() + { + // Do not attempt to understand these numbers at all costs! + const int size32 = 720; + const int size64Unix = 944; + const int size64Windows = 840; + + PlatformID platform = Environment.OSVersion.Platform; + if (IntPtr.Size == 4) + { + /* Technically this could be as low as 704 bytes, but + * some 32-bit architectures may be higher even on Unix + * targets (like ARMv7). + * -flibit + */ + return malloc((IntPtr) size32); + } + if (IntPtr.Size == 8) + { + if (platform == PlatformID.Unix) + { + return malloc((IntPtr) size64Unix); + } + else if (platform == PlatformID.Win32NT) + { + return malloc((IntPtr) size64Windows); + } + throw new NotSupportedException("Unhandled platform!"); + } + throw new NotSupportedException("Unhandled architecture!"); + } + + #endregion +} diff --git a/FNA/lib/Vorbisfile-CS/licenses/LICENSE b/FNA/lib/Vorbisfile-CS/licenses/LICENSE new file mode 100644 index 0000000..35f38f6 --- /dev/null +++ b/FNA/lib/Vorbisfile-CS/licenses/LICENSE @@ -0,0 +1,25 @@ +/* Vorbisfile# - C# Wrapper for Vorbisfile + * + * Copyright (c) 2013-2015 Ethan Lee. + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * Ethan "flibitijibibo" Lee + * + */ diff --git a/FNA/lib/Vorbisfile-CS/licenses/LICENSE.vorbisfile b/FNA/lib/Vorbisfile-CS/licenses/LICENSE.vorbisfile new file mode 100644 index 0000000..28de72a --- /dev/null +++ b/FNA/lib/Vorbisfile-CS/licenses/LICENSE.vorbisfile @@ -0,0 +1,28 @@ +Copyright (c) 2002-2008 Xiph.org Foundation + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +- Neither the name of the Xiph.org Foundation nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/FNA/licenses/LICENSE b/FNA/licenses/LICENSE new file mode 100644 index 0000000..721659c --- /dev/null +++ b/FNA/licenses/LICENSE @@ -0,0 +1,63 @@ +Microsoft Public License (Ms-PL) +FNA - Copyright 2009-2018 Ethan Lee and the MonoGame Team + +All rights reserved. + +This license governs use of the accompanying software. If you use the software, +you accept this license. If you do not accept the license, do not use the +software. + +1. Definitions + +The terms "reproduce," "reproduction," "derivative works," and "distribution" +have the same meaning here as under U.S. copyright law. + +A "contribution" is the original software, or any additions or changes to the +software. + +A "contributor" is any person that distributes its contribution under this +license. + +"Licensed patents" are a contributor's patent claims that read directly on its +contribution. + +2. Grant of Rights + +(A) Copyright Grant- Subject to the terms of this license, including the +license conditions and limitations in section 3, each contributor grants you a +non-exclusive, worldwide, royalty-free copyright license to reproduce its +contribution, prepare derivative works of its contribution, and distribute its +contribution or any derivative works that you create. + +(B) Patent Grant- Subject to the terms of this license, including the license +conditions and limitations in section 3, each contributor grants you a +non-exclusive, worldwide, royalty-free license under its licensed patents to +make, have made, use, sell, offer for sale, import, and/or otherwise dispose of +its contribution in the software or derivative works of the contribution in the +software. + +3. Conditions and Limitations + +(A) No Trademark License- This license does not grant you rights to use any +contributors' name, logo, or trademarks. + +(B) If you bring a patent claim against any contributor over patents that you +claim are infringed by the software, your patent license from such contributor +to the software ends automatically. + +(C) If you distribute any portion of the software, you must retain all +copyright, patent, trademark, and attribution notices that are present in the +software. + +(D) If you distribute any portion of the software in source code form, you may +do so only under this license by including a complete copy of this license with +your distribution. If you distribute any portion of the software in compiled or +object code form, you may only do so under a license that complies with this +license. + +(E) The software is licensed "as-is." You bear the risk of using it. The +contributors give no express warranties, guarantees or conditions. You may have +additional consumer rights under your local laws which this license cannot +change. To the extent permitted under your local laws, the contributors exclude +the implied warranties of merchantability, fitness for a particular purpose and +non-infringement. diff --git a/FNA/licenses/lzxdecoder.LICENSE b/FNA/licenses/lzxdecoder.LICENSE new file mode 100644 index 0000000..c570d11 --- /dev/null +++ b/FNA/licenses/lzxdecoder.LICENSE @@ -0,0 +1,29 @@ +LzxDecoder.cs was derived from libmspack +Copyright 2003-2004 Stuart Caie +Copyright 2011 Ali Scissons + +The LZX method was created by Jonathan Forbes and Tomi Poutanen, adapted +by Microsoft Corporation. + +This source file is Dual licensed; meaning the end-user of this source file +may redistribute/modify it under the LGPL 2.1 or MS-PL licenses. + +About +----- +This derived work is recognized by Stuart Caie and is authorized to adapt +any changes made to lzxd.c in his libmspack library and will still retain +this dual licensing scheme. Big thanks to Stuart Caie! + +This file is a pure C# port of the lzxd.c file from libmspack, with minor +changes towards the decompression of XNB files. The original decompression +software of LZX encoded data was written by Suart Caie in his +libmspack/cabextract projects, which can be located at +http://http://www.cabextract.org.uk/ + +GNU Lesser General Public License, Version 2.1 +---------------------------------------------- +https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html + +Microsoft Public License +------------------------ +http://www.opensource.org/licenses/ms-pl.html diff --git a/FNA/licenses/monoxna.LICENSE b/FNA/licenses/monoxna.LICENSE new file mode 100644 index 0000000..185aa38 --- /dev/null +++ b/FNA/licenses/monoxna.LICENSE @@ -0,0 +1,22 @@ +MIT License +Copyright 2006 The Mono.Xna Team + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/FNA/licenses/unxwb.LICENSE b/FNA/licenses/unxwb.LICENSE new file mode 100644 index 0000000..db65e36 --- /dev/null +++ b/FNA/licenses/unxwb.LICENSE @@ -0,0 +1,12 @@ +The unxwb project, written by Luigi Auriemma, was released in 2006 under the +GNU General Public License, version 2.0: + +http://www.gnu.org/licenses/gpl-2.0.html + +While the unxwb project was released under the GPL, Luigi has given express +permission to the MonoGame project to use code from unxwb under the MonoGame +project license. See LICENSE for details. + +The unxwb website can be found here: + +http://aluigi.altervista.org/papers.htm#xbox diff --git a/FNA/src/Audio/AudioCategory.cs b/FNA/src/Audio/AudioCategory.cs new file mode 100644 index 0000000..bd5649a --- /dev/null +++ b/FNA/src/Audio/AudioCategory.cs @@ -0,0 +1,433 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.Diagnostics; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.audiocategory.aspx + public struct AudioCategory : IEquatable + { + #region Internal Primitive Type Container Class + + internal class PrimitiveInstance + { + public T Value; + public PrimitiveInstance(T initial) + { + Value = initial; + } + } + + #endregion + + #region Public Properties + + private string INTERNAL_name; + public string Name + { + get + { + return INTERNAL_name; + } + } + + #endregion + + #region Internal Variables + + // Grumble, struct returns... + internal PrimitiveInstance INTERNAL_volume; + + internal CrossfadeType crossfadeType; + + internal List subCategories; + + #endregion + + #region Private Variables + + private readonly List activeCues; + private readonly List dyingCues; + + private readonly Dictionary> cueInstanceCounts; + + private readonly float baseVolume; + private readonly byte maxCueInstances; + private readonly MaxInstanceBehavior maxCueBehavior; + private readonly ushort maxFadeInMS; + private readonly ushort maxFadeOutMS; + + #endregion + + #region Internal Constructor + + internal AudioCategory( + string name, + float volume, + byte maxInstances, + int maxBehavior, + ushort fadeInMS, + ushort fadeOutMS, + int fadeType + ) { + INTERNAL_name = name; + INTERNAL_volume = new PrimitiveInstance(volume); + activeCues = new List(); + dyingCues = new List(); + cueInstanceCounts = new Dictionary>(); + + baseVolume = volume; + maxCueInstances = maxInstances; + maxCueBehavior = (MaxInstanceBehavior) maxBehavior; + maxFadeInMS = fadeInMS; + maxFadeOutMS = fadeOutMS; + crossfadeType = (CrossfadeType) fadeType; + subCategories = new List(); + } + + #endregion + + #region Public Methods + + public void Pause() + { + lock (activeCues) + { + foreach (Cue curCue in activeCues) + { + curCue.Pause(); + } + foreach (AudioCategory ac in subCategories) + { + ac.Pause(); + } + } + } + + public void Resume() + { + lock (activeCues) + { + foreach (Cue curCue in activeCues) + { + curCue.Resume(); + } + foreach (AudioCategory ac in subCategories) + { + ac.Resume(); + } + } + } + + public void SetVolume(float volume) + { + lock (activeCues) + { + INTERNAL_volume.Value = baseVolume * volume; + foreach (AudioCategory ac in subCategories) + { + ac.SetVolume(INTERNAL_volume.Value); + } + } + } + + public void Stop(AudioStopOptions options) + { + lock (activeCues) + { + while (activeCues.Count > 0) + { + Cue curCue = activeCues[0]; + curCue.Stop(options); + } + activeCues.Clear(); + if (options == AudioStopOptions.Immediate) + { + lock (dyingCues) + { + while (dyingCues.Count > 0) + { + Cue curCue = dyingCues[0]; + curCue.Stop(AudioStopOptions.Immediate); + } + dyingCues.Clear(); + } + } + foreach (List count in cueInstanceCounts.Values) + { + count.Clear(); + } + foreach (AudioCategory ac in subCategories) + { + ac.Stop(options); + } + } + } + + public override int GetHashCode() + { + return Name.GetHashCode(); + } + + public bool Equals(AudioCategory other) + { + return (GetHashCode() == other.GetHashCode()); + } + + public override bool Equals(Object obj) + { + if (obj is AudioCategory) + { + return Equals((AudioCategory) obj); + } + return false; + } + + public static bool operator ==( + AudioCategory value1, + AudioCategory value2 + ) { + return value1.Equals(value2); + } + + public static bool operator !=( + AudioCategory value1, + AudioCategory value2 + ) { + return !(value1.Equals(value2)); + } + + #endregion + + #region Internal Methods + + internal void INTERNAL_update() + { + /* Believe it or not, someone might run the update on a thread. + * So, we're going to give a lock to this method. + * -flibit + */ + lock (activeCues) + { + for (int i = 0; i < activeCues.Count; i += 1) + { + if (!activeCues[i].INTERNAL_update()) + { + i -= 1; + } + } + } + lock (dyingCues) + { + for (int i = 0; i < dyingCues.Count; i += 1) + { + if (!dyingCues[i].INTERNAL_update()) + { + i -= 1; + } + } + } + } + + internal bool INTERNAL_addCue(Cue newCue) + { + lock (activeCues) + { + if (activeCues.Count >= maxCueInstances) + { + if (maxCueBehavior == MaxInstanceBehavior.Fail) + { + return false; // Just ignore us... + } + else if (maxCueBehavior == MaxInstanceBehavior.Queue) + { + if (maxFadeInMS > 0) + { + newCue.INTERNAL_startFadeIn(maxFadeInMS); + } + if (maxFadeOutMS > 0) + { + activeCues[0].INTERNAL_startFadeOut(maxFadeOutMS); + } + else + { + activeCues[0].Stop(AudioStopOptions.AsAuthored); + } + } + else if (maxCueBehavior == MaxInstanceBehavior.ReplaceOldest) + { + if (!INTERNAL_removeOldestCue(activeCues[0].Name)) + { + return false; // Just ignore us... + } + if (maxFadeInMS > 0) + { + newCue.INTERNAL_startFadeIn(maxFadeInMS); + } + } + else if (maxCueBehavior == MaxInstanceBehavior.ReplaceQuietest) + { + float lowestVolume = float.MaxValue; + int lowestIndex = -1; + for (int i = 0; i < activeCues.Count; i += 1) + { + if (!activeCues[i].JustStarted) + { + float vol = activeCues[i].INTERNAL_calculateVolume(); + if (vol < lowestVolume) + { + lowestVolume = vol; + lowestIndex = i; + } + } + } + if (lowestIndex > -1) + { + activeCues[lowestIndex].Stop(AudioStopOptions.AsAuthored); + } + else + { + return false; // Just ignore us... + } + if (maxFadeInMS > 0) + { + newCue.INTERNAL_startFadeIn(maxFadeInMS); + } + } + else if (maxCueBehavior == MaxInstanceBehavior.ReplaceLowestPriority) + { + // FIXME: Priority? + if (!INTERNAL_removeOldestCue(activeCues[0].Name)) + { + return false; // Just ignore us... + } + if (maxFadeInMS > 0) + { + newCue.INTERNAL_startFadeIn(maxFadeInMS); + } + } + } + + cueInstanceCounts[newCue.Name].Add(newCue); + activeCues.Add(newCue); + } + return true; + } + + internal bool INTERNAL_removeOldestCue(string name) + { + lock (activeCues) + { + for (int i = 0; i < activeCues.Count; i += 1) + { + if (activeCues[i].Name.Equals(name) && !activeCues[i].JustStarted) + { + if (maxFadeOutMS > 0) + { + activeCues[i].INTERNAL_startFadeOut(maxFadeOutMS); + } + else + { + activeCues[i].Stop(AudioStopOptions.AsAuthored); + } + return true; + } + } + return false; + } + } + + internal bool INTERNAL_removeQuietestCue(string name) + { + float lowestVolume = float.MaxValue; + int lowestIndex = -1; + + lock (activeCues) + { + for (int i = 0; i < activeCues.Count; i += 1) + { + if (activeCues[i].Name.Equals(name) && !activeCues[i].JustStarted) + { + float vol = activeCues[i].INTERNAL_calculateVolume(); + if (vol < lowestVolume) + { + lowestVolume = vol; + lowestIndex = i; + } + } + } + + if (lowestIndex > -1) + { + if (maxFadeOutMS > 0) + { + activeCues[lowestIndex].INTERNAL_startFadeOut(maxFadeOutMS); + } + else + { + activeCues[lowestIndex].Stop(AudioStopOptions.AsAuthored); + } + return true; + } + return false; + } + } + + internal void INTERNAL_removeActiveCue(Cue cue) + { + // FIXME: Avoid calling this when a Cue is GC'd! -flibit + if (activeCues != null) + { + lock (activeCues) + { + if (activeCues.Contains(cue)) + { + activeCues.Remove(cue); + cueInstanceCounts[cue.Name].Remove(cue); + } + else if (dyingCues != null) + { + lock (dyingCues) + { + if (dyingCues.Contains(cue)) + { + dyingCues.Remove(cue); + } + } + } + } + } + } + + internal int INTERNAL_cueInstanceCount(string name) + { + if (!cueInstanceCounts.ContainsKey(name)) + { + cueInstanceCounts.Add(name, new List()); + } + return cueInstanceCounts[name].Count; + } + + internal void INTERNAL_moveToDying(Cue cue) + { + INTERNAL_removeActiveCue(cue); + lock (dyingCues) + { + dyingCues.Add(cue); + } + } + + #endregion + } +} diff --git a/FNA/src/Audio/AudioChannels.cs b/FNA/src/Audio/AudioChannels.cs new file mode 100644 index 0000000..aee1ad6 --- /dev/null +++ b/FNA/src/Audio/AudioChannels.cs @@ -0,0 +1,18 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.audiochannels.aspx + public enum AudioChannels + { + Mono = 1, + Stereo = 2 + } +} diff --git a/FNA/src/Audio/AudioDevice.cs b/FNA/src/Audio/AudioDevice.cs new file mode 100644 index 0000000..b12fbd9 --- /dev/null +++ b/FNA/src/Audio/AudioDevice.cs @@ -0,0 +1,260 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + internal static class AudioDevice + { + #region Public Constants + + // Per XAudio2. Yes, it's seriously this high. -flibit + public const float MAX_GAIN_VALUE = 16777216.0f; + + #endregion + + #region SoundEffect Master Properties + + private static float INTERNAL_masterVolume = 1.0f; + public static float MasterVolume + { + get + { + return INTERNAL_masterVolume; + } + set + { + INTERNAL_masterVolume = value; + if (ALDevice != null) + { + ALDevice.SetMasterVolume(value); + } + } + } + + public static float DistanceScale = 1.0f; + + private static float INTERNAL_dopplerScale = 1.0f; + public static float DopplerScale + { + get + { + return INTERNAL_dopplerScale; + } + set + { + INTERNAL_dopplerScale = value; + if (ALDevice != null) + { + ALDevice.SetDopplerScale(value); + } + } + } + + private static float INTERNAL_speedOfSound = 343.5f; + public static float SpeedOfSound + { + get + { + return INTERNAL_speedOfSound; + } + set + { + INTERNAL_speedOfSound = value; + if (ALDevice != null) + { + ALDevice.SetSpeedOfSound(value); + } + } + } + + #endregion + + #region RendererDetail List + + public static ReadOnlyCollection Renderers; + + #endregion + + #region Internal AL Device + + // FIXME: readonly? -flibit + public static IALDevice ALDevice; + + #endregion + + #region SoundEffect Management Variables + + // FIXME: readonly? -flibit + + // Used to store SoundEffectInstances generated internally. + public static List InstancePool; + + // Used to store all DynamicSoundEffectInstances, to check buffer counts. + public static List DynamicInstancePool; + + #endregion + + #region Microphone Management Variables + + // FIXME: readonly? -flibit + + // Used to store Microphones that are currently recording + public static List ActiveMics; + + #endregion + + #region Public Static Initialize Method + + public static void Initialize() + { + // We should only have one of these! + if (ALDevice != null) + { + FNALoggerEXT.LogWarn("ALDevice already exists, overwriting!"); + } + + bool disableSound = Environment.GetEnvironmentVariable( + "FNA_AUDIO_DISABLE_SOUND" + ) == "1"; + + if (disableSound) + { + ALDevice = new NullALDevice(); + } + else + { + ALDevice = FNAPlatform.CreateALDevice(); + } + + // Populate device info + if (ALDevice != null) + { + ALDevice.SetMasterVolume(MasterVolume); + ALDevice.SetDopplerScale(DopplerScale); + ALDevice.SetSpeedOfSound(SpeedOfSound); + + Renderers = ALDevice.GetDevices(); + Microphone.All = ALDevice.GetCaptureDevices(); + + InstancePool = new List(); + DynamicInstancePool = new List(); + ActiveMics = new List(); + AppDomain.CurrentDomain.ProcessExit += Dispose; + } + else + { + Renderers = new ReadOnlyCollection(new List()); + Microphone.All = new ReadOnlyCollection(new List()); + } + } + + #endregion + + #region Private Static Dispose Method + + private static void Dispose(object sender, EventArgs e) + { + InstancePool.Clear(); + DynamicInstancePool.Clear(); + ALDevice.Dispose(); + } + + #endregion + + #region Public Static Update Methods + + public static void Update() + { + ALDevice.Update(); + + for (int i = 0; i < InstancePool.Count; i += 1) + { + if (InstancePool[i].State == SoundState.Stopped) + { + InstancePool[i].Dispose(); + InstancePool.RemoveAt(i); + i -= 1; + } + } + + for (int i = 0; i < DynamicInstancePool.Count; i += 1) + { + DynamicSoundEffectInstance sfi = DynamicInstancePool[i]; + sfi.Update(); + if (sfi.State == SoundState.Stopped) + { + i -= 1; + } + } + + foreach (Microphone mic in ActiveMics) + { + mic.CheckBuffer(); + } + } + + #endregion + + #region Public Static Buffer Methods + + public static IALBuffer GenBuffer(int sampleRate, AudioChannels channels) + { + if (ALDevice == null) + { + throw new NoAudioHardwareException(); + } + return ALDevice.GenBuffer(sampleRate, channels); + } + + public static IALBuffer GenBuffer( + byte[] data, + uint sampleRate, + uint channels, + uint loopStart, + uint loopEnd, + bool isADPCM, + uint formatParameter + ) { + if (ALDevice == null) + { + throw new NoAudioHardwareException(); + } + return ALDevice.GenBuffer( + data, + sampleRate, + channels, + loopStart, + loopEnd, + isADPCM, + formatParameter + ); + } + + #endregion + + #region Public Static Reverb Methods + + public static IALReverb GenReverb(DSPParameter[] parameters) + { + if (ALDevice == null) + { + throw new NoAudioHardwareException(); + } + return ALDevice.GenReverb(parameters); + } + + #endregion + } +} diff --git a/FNA/src/Audio/AudioEmitter.cs b/FNA/src/Audio/AudioEmitter.cs new file mode 100644 index 0000000..5e4fbe7 --- /dev/null +++ b/FNA/src/Audio/AudioEmitter.cs @@ -0,0 +1,78 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.audioemitter.aspx + public class AudioEmitter + { + #region Public Properties + + private float INTERNAL_dopplerScale; + public float DopplerScale + { + get + { + return INTERNAL_dopplerScale; + } + set + { + if (value < 0.0f) + { + throw new ArgumentOutOfRangeException("AudioEmitter.DopplerScale must be greater than or equal to 0.0f"); + } + INTERNAL_dopplerScale = value; + } + } + + public Vector3 Forward + { + get; + set; + } + + public Vector3 Position + { + get; + set; + } + + + public Vector3 Up + { + get; + set; + } + + public Vector3 Velocity + { + get; + set; + } + + #endregion + + #region Public Constructor + + public AudioEmitter() + { + DopplerScale = 1.0f; + Forward = Vector3.Forward; + Position = Vector3.Zero; + Up = Vector3.Up; + Velocity = Vector3.Zero; + } + + #endregion + } +} diff --git a/FNA/src/Audio/AudioEngine.cs b/FNA/src/Audio/AudioEngine.cs new file mode 100644 index 0000000..e495f5c --- /dev/null +++ b/FNA/src/Audio/AudioEngine.cs @@ -0,0 +1,635 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/dd940262.aspx + public class AudioEngine : IDisposable + { + #region Public Constants + + public const int ContentVersion = 46; + + #endregion + + #region Public Properties + + public ReadOnlyCollection RendererDetails + { + get + { + return AudioDevice.Renderers; + } + } + + public bool IsDisposed + { + get; + private set; + } + + #endregion + + #region Private Variables + + private Dictionary INTERNAL_waveBanks; + + private List INTERNAL_categories; + private List INTERNAL_variables; + private Dictionary INTERNAL_RPCs; + private List INTERNAL_dspParameters; + private Dictionary INTERNAL_dspPresets; + + #endregion + + #region Disposing Event + + public event EventHandler Disposing; + + #endregion + + #region Public Constructors + + public AudioEngine(string settingsFile) + { + if (String.IsNullOrEmpty(settingsFile)) + { + throw new ArgumentNullException("settingsFile"); + } + + using (Stream stream = TitleContainer.OpenStream(settingsFile)) + using (BinaryReader reader = new BinaryReader(stream)) + { + // Check the file header. Should be 'XGSF' + if (reader.ReadUInt32() != 0x46534758) + { + throw new ArgumentException("XGSF format not recognized!"); + } + + // Check the Content and Tool versions + if (reader.ReadUInt16() != ContentVersion) + { + throw new ArgumentException("XGSF Content version!"); + } + if (reader.ReadUInt16() != 42) + { + throw new ArgumentException("XGSF Tool version!"); + } + + // Unknown value + reader.ReadUInt16(); + + // Last Modified, Unused + reader.ReadUInt64(); + + // XACT Version, Unused + reader.ReadByte(); + + // Number of AudioCategories + ushort numCategories = reader.ReadUInt16(); + + // Number of XACT Variables + ushort numVariables = reader.ReadUInt16(); + + // KEY#1 Length + /*ushort numKeyOne =*/ reader.ReadUInt16(); + + // KEY#2 Length + /*ushort numKeyTwo =*/ reader.ReadUInt16(); + + // Number of RPC Variables + ushort numRPCs = reader.ReadUInt16(); + + // Number of DSP Presets/Parameters + ushort numDSPPresets = reader.ReadUInt16(); + ushort numDSPParameters = reader.ReadUInt16(); + + // Category Offset in XGS File + uint categoryOffset = reader.ReadUInt32(); + + // Variable Offset in XGS File + uint variableOffset = reader.ReadUInt32(); + + // KEY#1 Offset + /*uint keyOneOffset =*/ reader.ReadUInt32(); + + // Category Name Index Offset, unused + reader.ReadUInt32(); + + // KEY#2 Offset + /*uint keyTwoOffset =*/ reader.ReadUInt32(); + + // Variable Name Index Offset, unused + reader.ReadUInt32(); + + // Category Name Offset in XGS File + uint categoryNameOffset = reader.ReadUInt32(); + + // Variable Name Offset in XGS File + uint variableNameOffset = reader.ReadUInt32(); + + // RPC Variable Offset in XGS File + uint rpcOffset = reader.ReadUInt32(); + + // DSP Preset/Parameter Offsets in XGS File + uint dspPresetOffset = reader.ReadUInt32(); + uint dspParameterOffset = reader.ReadUInt32(); + + /* Unknown table #1 + reader.BaseStream.Seek(keyOneOffset, SeekOrigin.Begin); + for (int i = 0; i < numKeyOne; i += 1) + { + // Appears to consistently be 16 shorts? + System.Console.WriteLine(reader.ReadInt16()); + } + /* OhGodNo + * 1, -1, 4, -1, + * 3, -1, -1, 7, + * -1, 2, 5, -1, + * 6, 0, -1, -1 + * + * Naddachance + * 1, -1, 4, -1, + * 5, -1, -1, -1, + * -1, 2, -1, -1, + * 3, 0, -1, -1 + * + * TFA + * 1, -1, -1, -1, + * -1, -1, -1, -1, + * -1, 2, -1, -1, + * -1, -0, -1, -1 + */ + + /* Unknown table #2 + reader.BaseStream.Seek(keyTwoOffset, SeekOrigin.Begin); + for (int i = 0; i < numKeyTwo; i += 1) + { + // Appears to be between 16-20 shorts? + System.Console.WriteLine(reader.ReadInt16()); + } + /* OhGodNo + * 2, 7, 1, -1, + * -1, 10, 19, -1, + * 11, 3, -1, -1, + * 8, -1, 14, 5, + * 12, 0, 4, 6 + * + * Naddachance + * 2, 3, -1, -1, + * 9, -1, 7, -1, + * 10, 0, 1, 5, + * -1, -1, -1, -1 + * + * TFA + * 2, 3, -1, -1, + * -1, -1, -1, -1, + * -1, 0, 1, 5, + * -1, -1, -1, -1 + */ + + // Obtain the Audio Category Names + reader.BaseStream.Seek(categoryNameOffset, SeekOrigin.Begin); + string[] categoryNames = new string[numCategories]; + for (int i = 0; i < numCategories; i += 1) + { + List builtString = new List(); + while (reader.PeekChar() != 0) + { + builtString.Add(reader.ReadChar()); + } + reader.ReadChar(); // Null terminator + categoryNames[i] = new string(builtString.ToArray()); + } + + // Obtain the Audio Categories + reader.BaseStream.Seek(categoryOffset, SeekOrigin.Begin); + INTERNAL_categories = new List(); + for (int i = 0; i < numCategories; i += 1) + { + // Maximum instances + byte maxInstances = reader.ReadByte(); + + // Fade In/Out + ushort fadeInMS = reader.ReadUInt16(); + ushort fadeOutMS = reader.ReadUInt16(); + + // Instance Behavior Flags + byte instanceFlags = reader.ReadByte(); + int fadeType = instanceFlags & 0x07; + int maxBehavior = instanceFlags >> 3; + + // Parent Category + short parent = reader.ReadInt16(); + + // Volume + float volume = XACTCalculator.CalculateAmplitudeRatio( + XACTCalculator.ParseDecibel( + reader.ReadByte() + ) + ); + + // Visibility Flags, unused + reader.ReadByte(); + + // Add to the engine list and the parent category + INTERNAL_categories.Add( + new AudioCategory( + categoryNames[i], + volume, + maxInstances, + maxBehavior, + fadeInMS, + fadeOutMS, + fadeType + ) + ); + if (parent != -1) + { + INTERNAL_categories[parent].subCategories.Add( + INTERNAL_categories[i] + ); + } + } + + // Obtain the Variable Names + reader.BaseStream.Seek(variableNameOffset, SeekOrigin.Begin); + string[] variableNames = new string[numVariables]; + for (int i = 0; i < numVariables; i += 1) + { + List builtString = new List(); + while (reader.PeekChar() != 0) + { + builtString.Add(reader.ReadChar()); + } + reader.ReadChar(); // Null terminator + variableNames[i] = new string(builtString.ToArray()); + } + + // Obtain the Variables + reader.BaseStream.Seek(variableOffset, SeekOrigin.Begin); + INTERNAL_variables = new List(); + for (int i = 0; i < numVariables; i += 1) + { + // Variable Accessibility (See Variable constructor) + byte varFlags = reader.ReadByte(); + + // Variable Value, Boundaries + float initialValue = reader.ReadSingle(); + float minValue = reader.ReadSingle(); + float maxValue = reader.ReadSingle(); + + // Add to the engine list + INTERNAL_variables.Add( + new Variable( + variableNames[i], + (varFlags & 0x01) != 0, + (varFlags & 0x02) != 0, + (varFlags & 0x04) == 0, + (varFlags & 0x08) != 0, + initialValue, + minValue, + maxValue + ) + ); + } + + // Obtain the RPC Curves + reader.BaseStream.Seek(rpcOffset, SeekOrigin.Begin); + INTERNAL_RPCs = new Dictionary(); + for (int i = 0; i < numRPCs; i += 1) + { + // RPC "Code", used by the SoundBanks + long rpcCode = reader.BaseStream.Position; + + // RPC Variable + ushort rpcVariable = reader.ReadUInt16(); + + // Number of RPC Curve Points + byte numPoints = reader.ReadByte(); + + // RPC Parameter + ushort rpcParameter = reader.ReadUInt16(); + + // RPC Curve Points + RPCPoint[] rpcPoints = new RPCPoint[numPoints]; + for (byte j = 0; j < numPoints; j += 1) + { + float x = reader.ReadSingle(); + float y = reader.ReadSingle(); + byte type = reader.ReadByte(); + rpcPoints[j] = new RPCPoint( + x, y, + (RPCPointType) type + ); + } + + // Add to the engine list + INTERNAL_RPCs.Add( + rpcCode, + new RPC( + INTERNAL_variables[rpcVariable].Name, + rpcParameter, + rpcPoints + ) + ); + } + + // Obtain the DSP Parameters + reader.BaseStream.Seek(dspParameterOffset, SeekOrigin.Begin); + INTERNAL_dspParameters = new List(); + for (int i = 0; i < numDSPParameters; i += 1) + { + // Effect Parameter Type + byte type = reader.ReadByte(); + + // Effect value, boundaries + float value = reader.ReadSingle(); + float minVal = reader.ReadSingle(); + float maxVal = reader.ReadSingle(); + + // Unknown value + reader.ReadUInt16(); + + // Add to Parameter list + INTERNAL_dspParameters.Add( + new DSPParameter( + type, + value, + minVal, + maxVal + ) + ); + } + + // Obtain the DSP Presets + reader.BaseStream.Seek(dspPresetOffset, SeekOrigin.Begin); + INTERNAL_dspPresets = new Dictionary(); + int total = 0; + for (int i = 0; i < numDSPPresets; i += 1) + { + // DSP "Code", used by the SoundBanks + long dspCode = reader.BaseStream.Position; + + // Preset Accessibility + bool global = (reader.ReadByte() == 1); + + // Number of preset parameters + uint numParams = reader.ReadUInt32(); + + // Obtain DSP Parameters + DSPParameter[] parameters = new DSPParameter[numParams]; + for (uint j = 0; j < numParams; j += 1) + { + parameters[j] = INTERNAL_dspParameters[total]; + total += 1; + } + + // Add to DSP Preset list + INTERNAL_dspPresets.Add( + dspCode, + new DSPPreset( + global, + parameters + ) + ); + } + } + + // Create the WaveBank Dictionary + INTERNAL_waveBanks = new Dictionary(); + + // Finally. + IsDisposed = false; + } + + public AudioEngine( + string settingsFile, + TimeSpan lookAheadTime, + string rendererId + ) { + /* TODO: May require either resetting the ALDevice, + * or adding a second AL device/context for this engine. + * -flibit + */ + throw new NotSupportedException(); + } + + #endregion + + #region Destructor + + ~AudioEngine() + { + Dispose(); + } + + #endregion + + #region Public Dispose Methods + + public void Dispose() + { + if (!IsDisposed) + { + if (Disposing != null) + { + Disposing.Invoke(this, null); + } + foreach (AudioCategory curCategory in INTERNAL_categories) + { + curCategory.Stop(AudioStopOptions.Immediate); + } + INTERNAL_categories.Clear(); + foreach (KeyValuePair curDSP in INTERNAL_dspPresets) + { + curDSP.Value.Dispose(); + } + INTERNAL_dspPresets.Clear(); + INTERNAL_dspParameters.Clear(); + INTERNAL_variables.Clear(); + INTERNAL_RPCs.Clear(); + IsDisposed = true; + } + } + + #endregion + + #region Public Methods + + public AudioCategory GetCategory(string name) + { + if (String.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name"); + } + for (int i = 0; i < INTERNAL_categories.Count; i += 1) + { + if (INTERNAL_categories[i].Name.Equals(name)) + { + return INTERNAL_categories[i]; + } + } + throw new InvalidOperationException("Category not found!"); + } + + public float GetGlobalVariable(string name) + { + if (String.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name"); + } + for (int i = 0; i < INTERNAL_variables.Count; i += 1) + { + if (name.Equals(INTERNAL_variables[i].Name)) + { + if (!INTERNAL_variables[i].IsGlobal) + { + throw new InvalidOperationException("Variable not global!"); + } + return INTERNAL_variables[i].GetValue(); + } + } + throw new InvalidOperationException("Variable not found!"); + } + + public void SetGlobalVariable(string name, float value) + { + if (String.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name"); + } + for (int i = 0; i < INTERNAL_variables.Count; i += 1) + { + if (name.Equals(INTERNAL_variables[i].Name)) + { + if (!INTERNAL_variables[i].IsGlobal) + { + throw new InvalidOperationException("Variable not global!"); + } + INTERNAL_variables[i].SetValue(value); + return; // We made it! + } + } + throw new InvalidOperationException("Variable not found!"); + } + + public void Update() + { + // Update Global RPCs + foreach (RPC curRPC in INTERNAL_RPCs.Values) + if (curRPC.Parameter >= RPCParameter.NUM_PARAMETERS) + foreach (Variable curVar in INTERNAL_variables) + if (curVar.Name.Equals(curRPC.Variable) && curVar.IsGlobal) + foreach (DSPPreset curDSP in INTERNAL_dspPresets.Values) + { + /* FIXME: This affects all DSP presets! + * What if there's more than one? + * -flibit + */ + curDSP.SetParameter( + (int) curRPC.Parameter - (int) RPCParameter.NUM_PARAMETERS, + curRPC.CalculateRPC(GetGlobalVariable(curVar.Name)) + ); + } + + // Apply all DSP changes once they have been made + foreach (DSPPreset curDSP in INTERNAL_dspPresets.Values) + { + AudioDevice.ALDevice.CommitReverbChanges(curDSP.Effect); + } + + // Update Cues + foreach (AudioCategory curCategory in INTERNAL_categories) + { + curCategory.INTERNAL_update(); + } + } + + #endregion + + #region Internal Methods + + internal void INTERNAL_addWaveBank(string name, WaveBank waveBank) + { + INTERNAL_waveBanks.Add(name, waveBank); + } + + internal void INTERNAL_removeWaveBank(string name) + { + INTERNAL_waveBanks.Remove(name); + } + + internal SoundEffect INTERNAL_getWaveBankTrack(string name, ushort track) + { + return INTERNAL_waveBanks[name].INTERNAL_getTrack(track); + } + + internal void INTERNAL_dropWaveBankTrack(string name, ushort track) + { + if (INTERNAL_waveBanks.ContainsKey(name)) // AKA !WaveBank.IsDisposed + { + INTERNAL_waveBanks[name].INTERNAL_dropTrack(track); + } + } + + internal string INTERNAL_getVariableName(ushort index) + { + return INTERNAL_variables[index].Name; + } + + internal RPC INTERNAL_getRPC(uint code) + { + return INTERNAL_RPCs[code]; + } + + internal IALReverb INTERNAL_getDSP(uint code) + { + return INTERNAL_dspPresets[code].Effect; + } + + internal AudioCategory INTERNAL_initCue(Cue newCue, ushort category) + { + List cueVariables = new List(); + foreach (Variable curVar in INTERNAL_variables) + { + if (!curVar.IsGlobal) + { + cueVariables.Add(curVar.Clone()); + } + } + newCue.INTERNAL_genVariables(cueVariables); + return INTERNAL_categories[category]; + } + + internal bool INTERNAL_isGlobalVariable(string name) + { + // FIXME: Any way to speed this up? -flibit + foreach (Variable curVar in INTERNAL_variables) + { + if (name.Equals(curVar.Name)) + { + return curVar.IsGlobal; + } + } + + // Variable doesn't even exist here...! + return false; + } + + #endregion + } +} diff --git a/FNA/src/Audio/AudioListener.cs b/FNA/src/Audio/AudioListener.cs new file mode 100644 index 0000000..3abfa35 --- /dev/null +++ b/FNA/src/Audio/AudioListener.cs @@ -0,0 +1,56 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.audiolistener.aspx + public class AudioListener + { + #region Public Properties + + public Vector3 Forward + { + get; + set; + } + + public Vector3 Position + { + get; + set; + } + + + public Vector3 Up + { + get; + set; + } + + public Vector3 Velocity + { + get; + set; + } + + #endregion + + #region Public Constructor + + public AudioListener() + { + Forward = Vector3.Forward; + Position = Vector3.Zero; + Up = Vector3.Up; + Velocity = Vector3.Zero; + } + + #endregion + } +} diff --git a/FNA/src/Audio/AudioStopOptions.cs b/FNA/src/Audio/AudioStopOptions.cs new file mode 100644 index 0000000..3c99300 --- /dev/null +++ b/FNA/src/Audio/AudioStopOptions.cs @@ -0,0 +1,18 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.audiostopoptions.aspx + public enum AudioStopOptions + { + AsAuthored, + Immediate + } +} diff --git a/FNA/src/Audio/Cue.cs b/FNA/src/Audio/Cue.cs new file mode 100644 index 0000000..9845d4c --- /dev/null +++ b/FNA/src/Audio/Cue.cs @@ -0,0 +1,1462 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.Diagnostics; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.cue.aspx + public sealed class Cue : IDisposable + { + #region Public Properties + + // FIXME: What is this...? -flibit + public bool IsCreated + { + get; + private set; + } + + public bool IsDisposed + { + get; + private set; + } + + public bool IsPaused + { + get + { + return ( !INTERNAL_timer.IsRunning && + INTERNAL_timer.ElapsedTicks > 0 ); + } + } + + public bool IsPlaying + { + get + { + return ( INTERNAL_timer.IsRunning || + INTERNAL_timer.ElapsedTicks > 0 ) && !IsStopping; + } + } + + // FIXME: Is this just to load WaveBank tracks? -flibit + public bool IsPrepared + { + get; + private set; + } + + // FIXME: Is this just to load WaveBank tracks? -flibit + public bool IsPreparing + { + get; + private set; + } + + public bool IsStopped + { + get; + private set; + } + + public bool IsStopping + { + get + { + return ( INTERNAL_fadeMode == FadeMode.FadeOut || + INTERNAL_fadeMode == FadeMode.ReleaseRpc ); + } + } + + public string Name + { + get; + private set; + } + + #endregion + + #region Internal Properties + + private ulong elapsedFrames; + internal bool JustStarted + { + get + { + return elapsedFrames < 2; + } + } + + #endregion + + #region Private Variables + + private AudioEngine INTERNAL_baseEngine; + + // Cue information parsed from the SoundBank + private List INTERNAL_waveBankNames; + private CueData INTERNAL_data; + + // Current sound and its events + private XACTSoundInstance INTERNAL_activeSound; + + private Dictionary + INTERNAL_playWaveEventBySound; + + // Used for event timestamps + private Stopwatch INTERNAL_timer; + + // Sound list + private List INTERNAL_instancePool; + private List INTERNAL_instanceVolumes; + private List INTERNAL_instancePitches; + + // RPC data list + private List INTERNAL_rpcTrackVolumes; + private List INTERNAL_rpcTrackPitches; + private ushort INTERNAL_maxRpcReleaseTime; + + // Events can control volume/pitch as well! + internal double eventVolume; + internal float eventPitch; + + // User-controlled sounds require a bit more trickery. + private bool INTERNAL_userControlledPlaying; + private float INTERNAL_controlledValue; + + // 3D audio variables + private bool INTERNAL_isPositional; + private AudioListener INTERNAL_listener; + private AudioEmitter INTERNAL_emitter; + + // XACT instance variables + private List INTERNAL_variables; + + // Category managing this Cue, and whether or not it's user-managed + private AudioCategory INTERNAL_category; + private bool INTERNAL_isManaged; + + // Fading + private enum FadeMode + { + None, + FadeOut, + FadeIn, + ReleaseRpc + } + private long INTERNAL_fadeStart; + private long INTERNAL_fadeEnd; + private FadeMode INTERNAL_fadeMode = FadeMode.None; + + #endregion + + #region Private Static Random Number Generator + + private static Random random = new Random(); + + #endregion + + #region Disposing Event + + public event EventHandler Disposing; + + #endregion + + #region Internal Constructor + + internal Cue( + AudioEngine audioEngine, + List waveBankNames, + string name, + CueData data, + bool managed + ) { + INTERNAL_baseEngine = audioEngine; + INTERNAL_waveBankNames = waveBankNames; + + Name = name; + + INTERNAL_data = data; + IsPrepared = false; + IsPreparing = true; + + INTERNAL_maxRpcReleaseTime = 0; + + foreach (XACTSound curSound in data.Sounds) + { + /* Determine the release times per track, if any, to be used to extend + * the sound when playing the release. + */ + { + ushort maxReleaseMS = 0; + + // Loop over tracks. + for (int i = 0; i < curSound.RPCCodes.Count; i += 1) + { + // Loop over curves. + foreach (uint curCode in curSound.RPCCodes[i]) + { + RPC curRPC = INTERNAL_baseEngine.INTERNAL_getRPC(curCode); + if (!INTERNAL_baseEngine.INTERNAL_isGlobalVariable(curRPC.Variable)) + { + // Only release times applied to volume are considered. + if (curRPC.Variable.Equals("ReleaseTime") && curRPC.Parameter == RPCParameter.Volume) + { + maxReleaseMS = Math.Max((ushort)curRPC.LastPoint.X, maxReleaseMS); + } + } + } + } + + // Keep track of the maximum release time to extend the sound. + INTERNAL_maxRpcReleaseTime = maxReleaseMS; + } + } + + IsPrepared = true; + IsPreparing = false; + + IsStopped = false; + + INTERNAL_isManaged = managed; + + INTERNAL_category = INTERNAL_baseEngine.INTERNAL_initCue( + this, + data.Category + ); + + eventVolume = 0.0; + eventPitch = 0.0f; + + INTERNAL_userControlledPlaying = false; + INTERNAL_isPositional = false; + + INTERNAL_playWaveEventBySound = + new Dictionary(); + + INTERNAL_timer = new Stopwatch(); + + INTERNAL_instancePool = new List(); + INTERNAL_instanceVolumes = new List(); + INTERNAL_instancePitches = new List(); + + INTERNAL_rpcTrackVolumes = new List(); + INTERNAL_rpcTrackPitches = new List(); + } + + #endregion + + #region Destructor + + ~Cue() + { + Dispose(); + } + + #endregion + + #region Public Dispose Method + + public void Dispose() + { + if (!IsDisposed) + { + if (Disposing != null) + { + Disposing.Invoke(this, null); + } + if (INTERNAL_instancePool != null) + { + foreach (SoundEffectInstance sfi in INTERNAL_instancePool) + { + sfi.Dispose(); + } + INTERNAL_instancePool.Clear(); + INTERNAL_instanceVolumes.Clear(); + INTERNAL_instancePitches.Clear(); + INTERNAL_rpcTrackVolumes.Clear(); + INTERNAL_rpcTrackPitches.Clear(); + } + + KillCue(); + + IsDisposed = true; + + // IXACTCue* no longer exists, these should all be false + IsStopped = false; + IsCreated = false; + IsPrepared = false; + } + } + + #endregion + + #region Public Methods + + public void Apply3D(AudioListener listener, AudioEmitter emitter) + { + if ((IsPlaying || IsStopping) && !INTERNAL_isPositional) + { + throw new InvalidOperationException("Apply3D call after Play!"); + } + if (listener == null) + { + throw new ArgumentNullException("listener"); + } + if (emitter == null) + { + throw new ArgumentNullException("emitter"); + } + INTERNAL_listener = listener; + INTERNAL_emitter = emitter; + + // Set Apply3D-related Variables + Vector3 emitterToListener = listener.Position - emitter.Position; + float distance = emitterToListener.Length(); + SetVariable("Distance", distance); + SetVariable( + "DopplerPitchScalar", + INTERNAL_calculateDoppler(emitterToListener, distance) + ); + SetVariable( + "OrientationAngle", + MathHelper.ToDegrees((float) Math.Acos( + Vector3.Dot( + emitterToListener / distance, // Direction... + listener.Forward + ) // Slope... + )) // Angle! + ); + + INTERNAL_isPositional = true; + } + + public float GetVariable(string name) + { + if (String.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name"); + } + if (name.Equals("NumCueInstances")) + { + return INTERNAL_category.INTERNAL_cueInstanceCount(Name); + } + foreach (Variable curVar in INTERNAL_variables) + { + if (name.Equals(curVar.Name)) + { + return curVar.GetValue(); + } + } + throw new ArgumentException("Instance variable not found!"); + } + + public void Pause() + { + if (IsPlaying) + { + INTERNAL_timer.Stop(); + foreach (SoundEffectInstance sfi in INTERNAL_instancePool) + { + sfi.Pause(); + } + } + } + + public void Play() + { + if (IsPlaying || IsStopping) + { + throw new InvalidOperationException("Cue already playing!"); + } + + // Instance limiting + if (INTERNAL_category.INTERNAL_cueInstanceCount(Name) >= INTERNAL_data.InstanceLimit) + { + if (INTERNAL_data.MaxCueBehavior == MaxInstanceBehavior.Fail) + { + return; // Just ignore us... + } + else if (INTERNAL_data.MaxCueBehavior == MaxInstanceBehavior.Queue) + { + throw new NotImplementedException("Cue Queueing not handled!"); + } + else if (INTERNAL_data.MaxCueBehavior == MaxInstanceBehavior.ReplaceOldest) + { + if (!INTERNAL_category.INTERNAL_removeOldestCue(Name)) + { + return; // Just ignore us... + } + } + else if (INTERNAL_data.MaxCueBehavior == MaxInstanceBehavior.ReplaceQuietest) + { + if (!INTERNAL_category.INTERNAL_removeQuietestCue(Name)) + { + return; // Just ignore us... + } + } + else if (INTERNAL_data.MaxCueBehavior == MaxInstanceBehavior.ReplaceLowestPriority) + { + // FIXME: Priority? + if (!INTERNAL_category.INTERNAL_removeOldestCue(Name)) + { + return; // Just ignore us... + } + } + } + + if (!INTERNAL_category.INTERNAL_addCue(this)) + { + Debug.Assert(false); + return; + } + + elapsedFrames = 0; + INTERNAL_timer.Start(); + if (INTERNAL_data.FadeInMS > 0) + { + INTERNAL_startFadeIn(INTERNAL_data.FadeInMS); + } + + if (!INTERNAL_calculateNextSound()) + { + return; + } + + INTERNAL_activeSound.InitializeClips(); + + IsPrepared = false; + } + + public void Resume() + { + if (IsPaused) + { + INTERNAL_timer.Start(); + foreach (SoundEffectInstance sfi in INTERNAL_instancePool) + { + sfi.Resume(); + } + } + } + + public void SetVariable(string name, float value) + { + if (String.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name"); + } + foreach (Variable curVar in INTERNAL_variables) + { + if (name.Equals(curVar.Name)) + { + if (curVar.IsGlobal) + { + throw new ArgumentException("Global variables cannot be set on a cue instance!"); + } + + if (!curVar.IsPublic) + { + throw new ArgumentException("Private variables cannot be set!"); + } + + if (curVar.IsReadOnly) + { + throw new ArgumentException("Readonly variables cannot be set!"); + } + + curVar.SetValue(value); + return; + } + } + throw new ArgumentException("Instance variable not found!"); + } + + public void Stop(AudioStopOptions options) + { + if (IsPlaying || IsStopping) + { + if (!IsPaused) + { + if (options == AudioStopOptions.AsAuthored) + { + if (INTERNAL_data.FadeOutMS > 0) + { + INTERNAL_startFadeOut(INTERNAL_data.FadeOutMS); + return; + } + else if (INTERNAL_maxRpcReleaseTime > 0) + { + INTERNAL_startReleaseRpc(INTERNAL_maxRpcReleaseTime); + return; + } + } + } + foreach (SoundEffectInstance sfi in INTERNAL_instancePool) + { + sfi.Stop(); + sfi.Dispose(); + } + INTERNAL_instancePool.Clear(); + INTERNAL_instanceVolumes.Clear(); + INTERNAL_instancePitches.Clear(); + INTERNAL_rpcTrackVolumes.Clear(); + INTERNAL_rpcTrackPitches.Clear(); + INTERNAL_userControlledPlaying = false; + + KillCue(); + + IsStopped = true; + + // If this is a managed Cue, we're done here. + if (INTERNAL_isManaged) + { + Dispose(); + } + } + } + + #endregion + + #region Internal Methods + + internal bool INTERNAL_update() + { + // If we're not running, save some instructions... + if (!INTERNAL_timer.IsRunning) + { + return true; + } + elapsedFrames += 1; + + // User control updates + if (INTERNAL_data.IsUserControlled) + { + string varName = INTERNAL_data.UserControlVariable; + if ( INTERNAL_userControlledPlaying && + (INTERNAL_baseEngine.INTERNAL_isGlobalVariable(varName) ? + !MathHelper.WithinEpsilon(INTERNAL_controlledValue, INTERNAL_baseEngine.GetGlobalVariable(varName)) : + !MathHelper.WithinEpsilon(INTERNAL_controlledValue, GetVariable(INTERNAL_data.UserControlVariable))) ) + { + // TODO: Crossfading + foreach (SoundEffectInstance sfi in INTERNAL_instancePool) + { + sfi.Stop(); + sfi.Dispose(); + } + INTERNAL_instancePool.Clear(); + INTERNAL_instanceVolumes.Clear(); + INTERNAL_instancePitches.Clear(); + INTERNAL_rpcTrackVolumes.Clear(); + INTERNAL_rpcTrackPitches.Clear(); + if (!INTERNAL_calculateNextSound()) + { + // Nothing to play, bail. + return true; + } + INTERNAL_activeSound.InitializeClips(); + INTERNAL_timer.Stop(); + INTERNAL_timer.Reset(); + INTERNAL_timer.Start(); + } + + if (INTERNAL_activeSound == null) + { + return INTERNAL_userControlledPlaying; + } + } + + // Trigger events for each track + foreach (XACTClipInstance clip in INTERNAL_activeSound.Clips) + { + // Play events when the timestamp has been hit. + for (int i = 0; i < clip.Events.Count; i += 1) + { + EventInstance evt = clip.Events[i]; + + if ( !evt.Played && + INTERNAL_timer.ElapsedMilliseconds > evt.Timestamp ) + { + evt.Apply( + this, + null, + INTERNAL_timer.ElapsedMilliseconds / 1000.0f + ); + } + } + } + + + // Clear out sound effect instances as they finish + for (int i = 0; i < INTERNAL_instancePool.Count; i += 1) + { + if (INTERNAL_instancePool[i].State == SoundState.Stopped) + { + // Get the event that spawned this instance... + PlayWaveEventInstance evtInstance = + INTERNAL_playWaveEventBySound[INTERNAL_instancePool[i]]; + double prevVolume = INTERNAL_instanceVolumes[i]; + short prevPitch = INTERNAL_instancePitches[i]; + + // Then delete all the guff + INTERNAL_playWaveEventBySound.Remove(INTERNAL_instancePool[i]); + INTERNAL_instancePool[i].Dispose(); + INTERNAL_instancePool.RemoveAt(i); + INTERNAL_instanceVolumes.RemoveAt(i); + INTERNAL_instancePitches.RemoveAt(i); + INTERNAL_rpcTrackVolumes.RemoveAt(i); + INTERNAL_rpcTrackPitches.RemoveAt(i); + + // Increment the loop counter, try to get another loop + evtInstance.LoopCount += 1; + PlayWave(evtInstance, prevVolume, prevPitch); + + // Removed a wave, have to step back... + i -= 1; + } + } + + // Fade in/out + float fadePerc = 1.0f; + if (INTERNAL_fadeMode != FadeMode.None) + { + if (INTERNAL_fadeMode == FadeMode.FadeOut) + { + if (INTERNAL_category.crossfadeType == CrossfadeType.Linear) + { + fadePerc = ( + INTERNAL_fadeEnd - + ( + INTERNAL_timer.ElapsedMilliseconds - + INTERNAL_fadeStart + ) + ) / (float) INTERNAL_fadeEnd; + } + else + { + throw new NotImplementedException("Unhandled CrossfadeType!"); + } + if (fadePerc <= 0.0f) + { + Stop(AudioStopOptions.Immediate); + INTERNAL_fadeMode = FadeMode.None; + return false; + } + } + else if (INTERNAL_fadeMode == FadeMode.FadeIn) + { + if (INTERNAL_category.crossfadeType == CrossfadeType.Linear) + { + fadePerc = INTERNAL_timer.ElapsedMilliseconds / (float) INTERNAL_fadeEnd; + } + else + { + throw new NotImplementedException("Unhandled CrossfadeType!"); + } + if (fadePerc > 1.0f) + { + fadePerc = 1.0f; + INTERNAL_fadeMode = FadeMode.None; + } + } + else if (INTERNAL_fadeMode == FadeMode.ReleaseRpc) + { + float releasePerc = ( + INTERNAL_timer.ElapsedMilliseconds - + INTERNAL_fadeStart + ) / (float) INTERNAL_maxRpcReleaseTime; + if (releasePerc > 1.0f) + { + Stop(AudioStopOptions.Immediate); + INTERNAL_fadeMode = FadeMode.None; + return false; + } + } + else + { + throw new NotImplementedException("Unsupported FadeMode!"); + } + } + + // If everything has been played and finished, we're done here. + if (INTERNAL_instancePool.Count == 0) + { + bool allPlayed = true; + foreach (XACTClipInstance clipInstance in INTERNAL_activeSound.Clips) + { + foreach (EventInstance evt in clipInstance.Events) + { + if (!evt.Played) + { + allPlayed = false; + break; + } + } + } + if (allPlayed) + { + // If this is managed, we're done completely. + if (INTERNAL_isManaged) + { + Dispose(); + } + else + { + KillCue(); + } + if (INTERNAL_userControlledPlaying) + { + // We're "still" "playing" right now... + return true; + } + IsStopped = true; + return false; + } + } + + // RPC updates + float rpcVolume = 0.0f; + float rpcPitch = 0.0f; + float hfGain = 1.0f; + float lfGain = 1.0f; + for (int i = 0; i < INTERNAL_activeSound.Sound.RPCCodes.Count; i += 1) + { + // Are we processing an RPC targeting the sound itself rather than a track? + bool isSoundRpc = i == 0 && INTERNAL_activeSound.Sound.HasSoundRpcs; + + // If there is an RPC targeting the sound instance itself, it is handled in rpcVolume/rpcPitch, and the first track is at i-1. + int trackRpcIndex = INTERNAL_activeSound.Sound.HasSoundRpcs ? i - 1 : i; + + // If this RPC Code is for a track that is not active yet, we have nothing to do. + if (trackRpcIndex >= INTERNAL_instancePool.Count) + { + // FIXME: This presumes that tracks start in order, which doesn't have to be true. + break; + } + if (!isSoundRpc) + { + INTERNAL_rpcTrackVolumes[trackRpcIndex] = 0.0f; + INTERNAL_rpcTrackPitches[trackRpcIndex] = 0.0f; + } + + foreach (uint curCode in INTERNAL_activeSound.Sound.RPCCodes[i]) + { + RPC curRPC = INTERNAL_baseEngine.INTERNAL_getRPC(curCode); + float result; + if (!INTERNAL_baseEngine.INTERNAL_isGlobalVariable(curRPC.Variable)) + { + float variableValue; + + if (curRPC.Variable.Equals("AttackTime")) + { + PlayWaveEvent playWaveEvent = + (PlayWaveEvent) INTERNAL_activeSound.Sound.INTERNAL_clips[trackRpcIndex].Events[0]; + + long elapsedFromPlay = INTERNAL_timer.ElapsedMilliseconds + - playWaveEvent.Timestamp; + variableValue = elapsedFromPlay; + } + else if (curRPC.Variable.Equals("ReleaseTime")) + { + if (INTERNAL_fadeMode == FadeMode.ReleaseRpc) + { + long elapsedFromStop = INTERNAL_timer.ElapsedMilliseconds - INTERNAL_fadeStart; + variableValue = elapsedFromStop; + } + else + { + variableValue = 0.0f; + } + } + else + { + variableValue = GetVariable(curRPC.Variable); + } + + result = curRPC.CalculateRPC(variableValue); + } + else + { + // It's a global variable we're looking for! + result = curRPC.CalculateRPC( + INTERNAL_baseEngine.GetGlobalVariable( + curRPC.Variable + ) + ); + } + if (curRPC.Parameter == RPCParameter.Volume) + { + // If this RPC targets the sound instance itself then apply to the dedicated variable. + if (isSoundRpc) + { + rpcVolume += result; + } + else + { + INTERNAL_rpcTrackVolumes[trackRpcIndex] += result; + } + } + else if (curRPC.Parameter == RPCParameter.Pitch) + { + float pitch = result; + if (isSoundRpc) + { + rpcPitch += pitch; + } + else + { + INTERNAL_rpcTrackPitches[trackRpcIndex] += pitch; + } + } + else if (curRPC.Parameter == RPCParameter.FilterFrequency) + { + // FIXME: Just listening to the last RPC! + float hf = result / 20000.0f; + float lf = 1.0f - hf; + if (isSoundRpc) + { + hfGain = hf; + lfGain = lf; + } + else + { + throw new NotImplementedException("Per-track filter RPCs!"); + } + } + else + { + throw new NotImplementedException( + "RPC Parameter Type: " + curRPC.Parameter.ToString() + ); + } + } + } + + // Sound effect instance updates + for (int i = 0; i < INTERNAL_instancePool.Count; i += 1) + { + /* The final volume should be the combination of the + * authored volume, category volume, RPC sound/track + * volumes, event volumes, and fade. + */ + INTERNAL_instancePool[i].Volume = XACTCalculator.CalculateAmplitudeRatio( + INTERNAL_instanceVolumes[i] + + rpcVolume + + INTERNAL_rpcTrackVolumes[i] + + eventVolume + ) * INTERNAL_category.INTERNAL_volume.Value * fadePerc; + + /* The final pitch should be the combination of the + * authored pitch, RPC sound/track pitches, and event + * pitch. + * + * XACT uses -1200 to 1200 (+/- 12 semitones), + * XNA uses -1.0f to 1.0f (+/- 1 octave). + */ + INTERNAL_instancePool[i].Pitch = ( + INTERNAL_instancePitches[i] + + rpcPitch + + INTERNAL_rpcTrackPitches[i] + + eventPitch + ) / 1200.0f; + + /* The final filter is determined by the instance's filter type, + * in addition to our calculation of the HF/LF gain values. + */ + byte fType = INTERNAL_instancePool[i].FilterType; + if (fType == 0xFF) + { + // No-op, no filter! + } + else if (fType == 0) + { + INTERNAL_instancePool[i].INTERNAL_applyLowPassFilter(hfGain); + } + else if (fType == 1) + { + INTERNAL_instancePool[i].INTERNAL_applyHighPassFilter(lfGain); + } + else if (fType == 2) + { + INTERNAL_instancePool[i].INTERNAL_applyBandPassFilter(hfGain, lfGain); + } + else + { + throw new InvalidOperationException("Unhandled filter type!"); + } + + // Update 3D position, if applicable + if (INTERNAL_isPositional) + { + INTERNAL_instancePool[i].Apply3D( + INTERNAL_listener, + INTERNAL_emitter + ); + } + } + + return true; + } + + internal void INTERNAL_genVariables(List cueVariables) + { + INTERNAL_variables = cueVariables; + } + + internal float INTERNAL_calculateVolume() + { + float retval = 0.0f; + for (int i = 0; i < INTERNAL_activeSound.Sound.RPCCodes.Count; i += 1) + foreach (uint curCode in INTERNAL_activeSound.Sound.RPCCodes[i]) + { + RPC curRPC = INTERNAL_baseEngine.INTERNAL_getRPC(curCode); + if (curRPC.Parameter != RPCParameter.Volume) + { + continue; + } + float result; + if (!INTERNAL_baseEngine.INTERNAL_isGlobalVariable(curRPC.Variable)) + { + float variableValue; + + if (curRPC.Variable.Equals("AttackTime")) + { + long elapsedFromPlay = INTERNAL_timer.ElapsedMilliseconds; + variableValue = elapsedFromPlay; + } + else if (curRPC.Variable.Equals("ReleaseTime")) + { + if (INTERNAL_fadeMode == FadeMode.ReleaseRpc) + { + long elapsedFromStop = INTERNAL_timer.ElapsedMilliseconds - INTERNAL_fadeStart; + variableValue = elapsedFromStop; + } + else + { + variableValue = 0.0f; + } + } + else + { + variableValue = GetVariable(curRPC.Variable); + } + + result = curRPC.CalculateRPC(variableValue); + } + else + { + // It's a global variable we're looking for! + result = curRPC.CalculateRPC( + INTERNAL_baseEngine.GetGlobalVariable( + curRPC.Variable + ) + ); + } + retval += result; + } + return retval; + } + + internal void INTERNAL_startFadeIn(ushort ms) + { + // start is not used, since it's always 0 anyway -flibit + INTERNAL_fadeEnd = ms; + INTERNAL_fadeMode = FadeMode.FadeIn; + } + + internal void INTERNAL_startFadeOut(ushort ms) + { + if (INTERNAL_fadeMode == FadeMode.FadeOut) + { + return; // Already in the middle of something... + } + INTERNAL_fadeStart = INTERNAL_timer.ElapsedMilliseconds; + INTERNAL_fadeEnd = ms; + INTERNAL_fadeMode = FadeMode.FadeOut; + INTERNAL_category.INTERNAL_moveToDying(this); + } + + internal void INTERNAL_startReleaseRpc(ushort ms) + { + INTERNAL_fadeStart = INTERNAL_timer.ElapsedMilliseconds; + INTERNAL_fadeEnd = ms; + INTERNAL_fadeMode = FadeMode.ReleaseRpc; + } + + #endregion + + #region Private Methods + + private bool INTERNAL_calculateNextSound() + { + if (INTERNAL_activeSound != null) + { + INTERNAL_activeSound.Dispose( + INTERNAL_baseEngine, + INTERNAL_waveBankNames + ); + INTERNAL_activeSound = null; + } + + INTERNAL_playWaveEventBySound.Clear(); + + // Pick a sound based on a Cue instance variable + if (INTERNAL_data.IsUserControlled) + { + INTERNAL_userControlledPlaying = true; + if (INTERNAL_baseEngine.INTERNAL_isGlobalVariable(INTERNAL_data.UserControlVariable)) + { + INTERNAL_controlledValue = INTERNAL_baseEngine.GetGlobalVariable( + INTERNAL_data.UserControlVariable + ); + } + else + { + INTERNAL_controlledValue = GetVariable( + INTERNAL_data.UserControlVariable + ); + } + for (int i = 0; i < INTERNAL_data.Probabilities.Length / 2; i += 1) + { + if ( INTERNAL_controlledValue <= INTERNAL_data.Probabilities[i, 0] && + INTERNAL_controlledValue >= INTERNAL_data.Probabilities[i, 1] ) + { + INTERNAL_activeSound = INTERNAL_data.Sounds[i].GenInstance( + INTERNAL_baseEngine, + INTERNAL_waveBankNames + ); + return true; + } + } + + /* This should only happen when the + * UserControlVariable is none of the sound + * probabilities, in which case we are just + * silent. But, we are still claiming to be + * "playing" in the meantime. + * -flibit + */ + return false; + } + + // Randomly pick a sound + double max = 0.0; + for (int i = 0; i < INTERNAL_data.Probabilities.GetLength(0); i += 1) + { + max += INTERNAL_data.Probabilities[i, 0] - INTERNAL_data.Probabilities[i, 1]; + } + double next = random.NextDouble() * max; + + for (int i = INTERNAL_data.Probabilities.GetLength(0) - 1; i >= 0; i -= 1) + { + if (next > max - (INTERNAL_data.Probabilities[i, 0] - INTERNAL_data.Probabilities[i, 1])) + { + INTERNAL_activeSound = INTERNAL_data.Sounds[i].GenInstance( + INTERNAL_baseEngine, + INTERNAL_waveBankNames + ); + break; + } + max -= INTERNAL_data.Probabilities[i, 0] - INTERNAL_data.Probabilities[i, 1]; + } + + return true; + } + + private void KillCue() + { + INTERNAL_timer.Stop(); + INTERNAL_timer.Reset(); + if (INTERNAL_activeSound != null) + { + if (INTERNAL_waveBankNames.Count > 0) // AKA !SoundBank.IsDisposed + { + INTERNAL_activeSound.Dispose( + INTERNAL_baseEngine, + INTERNAL_waveBankNames + ); + } + INTERNAL_activeSound = null; + } + INTERNAL_category.INTERNAL_removeActiveCue(this); + } + + internal void PlayWave( + EventInstance eventInstance, + double? prevVolume = null, + short? prevPitch = null + ) { + PlayWaveEventInstance playWaveEventInstance = + (PlayWaveEventInstance) eventInstance; + PlayWaveEvent evt = (PlayWaveEvent) eventInstance.Event; + + double finalVolume; + short finalPitch; + SoundEffectInstance sfi = evt.GenerateInstance( + INTERNAL_activeSound.Sound.Volume, + INTERNAL_activeSound.Sound.Pitch, + playWaveEventInstance.LoopCount, + prevVolume, + prevPitch, + out finalVolume, + out finalPitch + ); + if (sfi != null) + { + if (INTERNAL_isPositional) + { + sfi.Apply3D(INTERNAL_listener, INTERNAL_emitter); + } + foreach (uint curDSP in INTERNAL_activeSound.Sound.DSPCodes) + { + // FIXME: This only applies the last DSP! + sfi.INTERNAL_applyReverb( + INTERNAL_baseEngine.INTERNAL_getDSP(curDSP) + ); + } + INTERNAL_instancePool.Add(sfi); + INTERNAL_instanceVolumes.Add(finalVolume); + INTERNAL_instancePitches.Add(finalPitch); + + INTERNAL_playWaveEventBySound.Add(sfi, playWaveEventInstance); + INTERNAL_rpcTrackVolumes.Add(0.0f); + INTERNAL_rpcTrackPitches.Add(0.0f); + sfi.Play(); + } + } + + private float INTERNAL_calculateDoppler(Vector3 emitterToListener, float distance) + { + /* Adapted from algorithm published as a part of the webaudio specification: + * https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#Spatialization-doppler-shift + * -Chad + */ + + float dopplerShift = 1.0f; + + float dopplerFactor = INTERNAL_emitter.DopplerScale; + if (dopplerFactor > 0.0f) + { + float speedOfSound = INTERNAL_baseEngine.GetGlobalVariable("SpeedOfSound"); + float scaledSpeedOfSound = speedOfSound / dopplerFactor; + + // Project the velocities along the emitter to listener vector. + float projectedListenerVelocity = Vector3.Dot( + emitterToListener, + INTERNAL_listener.Velocity + ) / distance; + float projectedEmitterVelocity = Vector3.Dot( + emitterToListener, + INTERNAL_emitter.Velocity + ) / distance; + + // Clamp to the speed of the medium. + projectedListenerVelocity = Math.Min( + projectedListenerVelocity, + scaledSpeedOfSound + ); + projectedEmitterVelocity = Math.Min( + projectedEmitterVelocity, + scaledSpeedOfSound + ); + + // Apply doppler effect. + dopplerShift = ( + speedOfSound - dopplerFactor * projectedListenerVelocity + ) / ( + speedOfSound - dopplerFactor * projectedEmitterVelocity + ); + if (float.IsNaN(dopplerShift)) + { + dopplerShift = 1.0f; + } + + // Limit the pitch shifting to 2 octaves up and 1 octaves down per XACT behavior. + dopplerShift = MathHelper.Clamp(dopplerShift, 0.5f, 4.0f); + } + + return dopplerShift; + } + + #endregion + } + + internal class XACTSoundInstance + { + public readonly XACTSound Sound; + public readonly List Clips = new List(); + + public XACTSoundInstance(XACTSound sound) + { + Sound = sound; + } + + public void Dispose(AudioEngine audioEngine, List waveBankNames) + { + Clips.Clear(); + Sound.DisposeInstance(this, audioEngine, waveBankNames); + } + + internal void InitializeClips() + { + // Create clip instances for each clip (track). + foreach (XACTClip curClip in Sound.INTERNAL_clips) + { + XACTClipInstance clipInstance = new XACTClipInstance(curClip); + Clips.Add(clipInstance); + } + } + } + + internal class XACTClipInstance + { + public readonly XACTClip Clip; + public readonly List Events = new List(); + + public XACTClipInstance(XACTClip clip) + { + Clip = clip; + + // Create event instances for each event. + foreach (XACTEvent evt in Clip.Events) + { + // TODO: How best to eliminate this switch? Factory template method? Table of delegates? + EventInstance eventInstance = null; + if (evt is PlayWaveEvent) + { + eventInstance = new PlayWaveEventInstance((PlayWaveEvent) evt); + } + else if (evt is StopEvent) + { + eventInstance = new StopEventInstance((StopEvent) evt); + } + else if (evt is SetValueEvent) + { + eventInstance = new SetValueEventInstance((SetValueEvent) evt); + } + else if (evt is SetRandomValueEvent) + { + eventInstance = new SetRandomValueEventInstance((SetRandomValueEvent) evt); + } + else if (evt is SetRampValueEvent) + { + eventInstance = new SetRampValueEventInstance((SetRampValueEvent) evt); + } + else if (evt is MarkerEvent) + { + eventInstance = new MarkerEventInstance((MarkerEvent) evt); + } + + Debug.Assert(eventInstance != null); + Events.Add(eventInstance); + } + } + } + + internal abstract class EventInstance + { + public readonly XACTEvent Event; + public float Timestamp; + public int LoopCount; + public bool Played; + + public EventInstance(XACTEvent evt) + { + Event = evt; + Timestamp = ( + Event.Timestamp + + XACTEvent.Random.Next(0, Event.RandomOffset) + ); + LoopCount = Event.LoopCount; + Played = false; + } + + public abstract void Apply(Cue cue, XACTClip track, float elapsedTime); + + protected void HandleRepeating() + { + if (LoopCount > 0) + { + // If not set to infinite looping. + if (Event.LoopCount != 65535) + { + LoopCount = LoopCount - 1; + } + + // FIXME: Use Frequency Units (Seconds / Beats per Minute) instead of constant of seconds. + Timestamp = Timestamp + Event.Frequency * 1000.0f; + } + else + { + Played = true; + } + } + } + + internal class PlayWaveEventInstance : EventInstance + { + public PlayWaveEventInstance(PlayWaveEvent evt) + : base(evt) + { + } + + public override void Apply(Cue cue, XACTClip track, float elapsedTime) + { + // Only actually play if we are not in the process of stopping. + if (!cue.IsStopping) + { + cue.PlayWave(this); + } + Played = true; + } + } + + internal class StopEventInstance : EventInstance + { + public StopEventInstance(StopEvent evt) + : base(evt) + { + } + + public override void Apply(Cue cue, XACTClip track, float elapsedTime) + { + StopEvent evt = (StopEvent) Event; + + AudioStopOptions stopOptions = evt.StopOptions; + + switch (evt.Scope) + { + case XACTClip.StopEventScope.Cue: + cue.Stop(stopOptions); + break; + case XACTClip.StopEventScope.Track: + /* FIXME: Need to stop this and ONLY this track + * track.Stop(stopOptions); + */ + break; + } + + Played = true; + } + } + + internal class SetValueEventInstance : EventInstance + { + public SetValueEventInstance(SetValueEvent evt) + : base(evt) + { + } + + public override void Apply(Cue cue, XACTClip track, float elapsedTime) + { + SetValueEvent evt = (SetValueEvent) Event; + switch (evt.Property) + { + case CueProperty.Volume: + cue.eventVolume = evt.GetVolume(cue.eventVolume); + break; + case CueProperty.Pitch: + cue.eventPitch = evt.GetPitch(cue.eventPitch); + break; + } + + HandleRepeating(); + } + } + + internal class SetRandomValueEventInstance : EventInstance + { + public SetRandomValueEventInstance(SetRandomValueEvent evt) + : base(evt) + { + } + + public override void Apply(Cue cue, XACTClip track, float elapsedTime) + { + SetRandomValueEvent evt = (SetRandomValueEvent) Event; + switch (evt.Property) + { + case CueProperty.Volume: + cue.eventVolume = evt.GetVolume(cue.eventVolume); + break; + case CueProperty.Pitch: + cue.eventPitch = evt.GetPitch(cue.eventPitch); + break; + } + + HandleRepeating(); + } + } + + internal class SetRampValueEventInstance : EventInstance + { + public SetRampValueEventInstance(SetRampValueEvent evt) + : base(evt) + { + } + + public override void Apply(Cue cue, XACTClip track, float elapsedTime) + { + SetRampValueEvent evt = (SetRampValueEvent) Event; + if (elapsedTime <= Timestamp / 1000.0f + evt.Duration) + { + switch (evt.Property) + { + case CueProperty.Volume: + cue.eventVolume = GetValue(evt, elapsedTime); + break; + case CueProperty.Pitch: + cue.eventPitch = GetValue(evt, elapsedTime); + break; + } + } + else + { + HandleRepeating(); + } + } + + private float GetValue(SetRampValueEvent x, float elapsedTime) + { + // Number of slices to break up the duration. + const float slices = 10; + float endValue = x.InitialSlope * x.Duration * slices + x.InitialValue; + + // FIXME: Incorporate 2nd derivative into the interpolated pitch. + + float amount = MathHelper.Clamp( + (elapsedTime - Timestamp / 1000.0f) / x.Duration, + 0.0f, + 1.0f + ); + return MathHelper.Lerp(x.InitialValue, endValue, amount); + } + } + + internal class MarkerEventInstance : EventInstance + { + public MarkerEventInstance(MarkerEvent evt) + : base(evt) + { + } + + public override void Apply(Cue cue, XACTClip track, float elapsedTime) + { + // FIXME: Implement action for a marker event. Some kind of callback? + + HandleRepeating(); + } + } +} diff --git a/FNA/src/Audio/CueData.cs b/FNA/src/Audio/CueData.cs new file mode 100644 index 0000000..a4c5cf3 --- /dev/null +++ b/FNA/src/Audio/CueData.cs @@ -0,0 +1,1670 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + internal class CueData + { + public XACTSound[] Sounds + { + get; + private set; + } + + public ushort Category + { + get; + private set; + } + + public float[,] Probabilities + { + get; + private set; + } + + public bool IsUserControlled + { + get; + private set; + } + + public string UserControlVariable + { + get; + private set; + } + + public byte InstanceLimit + { + get; + private set; + } + + public MaxInstanceBehavior MaxCueBehavior + { + get; + private set; + } + + public ushort FadeInMS + { + get; + private set; + } + + public ushort FadeOutMS + { + get; + private set; + } + + public CueData(XACTSound sound) + { + Sounds = new XACTSound[1]; + Probabilities = new float[1, 2]; + + Sounds[0] = sound; + Category = sound.Category; + Probabilities[0, 0] = 1.0f; + Probabilities[0, 1] = 0.0f; + IsUserControlled = false; + + // Assume we can have max instances, for now. + InstanceLimit = 255; + MaxCueBehavior = MaxInstanceBehavior.ReplaceOldest; + FadeInMS = 0; + FadeOutMS = 0; + } + + public CueData( + XACTSound[] sounds, + float[,] probabilities, + string controlVariable + ) { + Sounds = sounds; + Category = Sounds[0].Category; // FIXME: Assumption! + Probabilities = probabilities; + IsUserControlled = !String.IsNullOrEmpty(controlVariable); + UserControlVariable = controlVariable; + + // Assume we can have max instances, for now. + InstanceLimit = 255; + MaxCueBehavior = MaxInstanceBehavior.ReplaceOldest; + FadeInMS = 0; + FadeOutMS = 0; + } + + public void SetLimit( + byte instanceLimit, + byte behavior, + ushort fadeIn, + ushort fadeOut + ) { + InstanceLimit = instanceLimit; + MaxCueBehavior = (MaxInstanceBehavior) (behavior >> 3); + FadeInMS = fadeIn; + FadeOutMS = fadeOut; + } + } + + internal class XACTSound + { + internal XACTClip[] INTERNAL_clips; + + public double Volume + { + get; + private set; + } + + public short Pitch + { + get; + private set; + } + + public ushort Category + { + get; + private set; + } + + public readonly bool HasSoundRpcs; + + public List RPCCodes + { + get; + private set; + } + + public uint[] DSPCodes + { + get; + private set; + } + + private List instances; + + public XACTSound(ushort track, byte waveBank) + { + INTERNAL_clips = new XACTClip[1]; + INTERNAL_clips[0] = new XACTClip(track, waveBank); + Category = 0; + Volume = 0.0; + + instances = new List(); + } + + public XACTSound(BinaryReader reader) + { + instances = new List(); + + // Sound Effect Flags + byte soundFlags = reader.ReadByte(); + bool complex = (soundFlags & 0x01) != 0; + + // Indicates that the data contains RPC codes targeting the sound itself. + HasSoundRpcs = (soundFlags & 0x02) == 0x02; + + // AudioCategory Index + Category = reader.ReadUInt16(); + + // Sound Volume + Volume = XACTCalculator.ParseDecibel(reader.ReadByte()); + + // Sound Pitch + Pitch = reader.ReadInt16(); + + // Unknown value + reader.ReadByte(); + + // Length of Sound Entry, unused + reader.ReadUInt16(); + + // Number of Sound Clips + if (complex) + { + INTERNAL_clips = new XACTClip[reader.ReadByte()]; + } + else + { + // Simple Sounds always have 1 PlayWaveEvent. + INTERNAL_clips = new XACTClip[1]; + ushort track = reader.ReadUInt16(); + byte waveBank = reader.ReadByte(); + INTERNAL_clips[0] = new XACTClip(track, waveBank); + } + + // Parse RPC Properties + RPCCodes = new List(); + if ((soundFlags & 0x0E) != 0) + { + // RPC data length + ushort rpcDataLength = reader.ReadUInt16(); + ushort totalDataRead = 2; + + while (totalDataRead < rpcDataLength) + { + // Number of RPC Presets (for this track) + uint[] codeList = new uint[reader.ReadByte()]; + + // Obtain RPC curve codes (in this block) + for (int i = 0; i < codeList.Length; i += 1) + { + codeList[i] = reader.ReadUInt32(); + } + + // Add this track's code list to the master list + RPCCodes.Add(codeList); + + totalDataRead += (ushort) (1 + (4 * codeList.Length)); + } + } + + // Parse DSP Presets + DSPCodes = new uint[0]; // Eww... -flibit + if ((soundFlags & 0x10) != 0) + { + // DSP Presets Length, unused + reader.ReadUInt16(); + + // Number of DSP Presets + DSPCodes = new uint[reader.ReadByte()]; + + // Obtain DSP Preset codes + for (byte j = 0; j < DSPCodes.Length; j += 1) + { + DSPCodes[j] = reader.ReadUInt32(); + } + } + + // Parse Sound Clips + if (complex) + { + for (int i = 0; i < INTERNAL_clips.Length; i += 1) + { + // XACT Clip volume + double clipVolume = XACTCalculator.ParseDecibel(reader.ReadByte()); + + // XACT Clip Offset in Bank + uint offset = reader.ReadUInt32(); + + // XACT Clip filter + byte filterFlags = reader.ReadByte(); + byte filterType; + if ((filterFlags & 0x01) == 0x01) + { + filterType = (byte) ((filterFlags >> 1) & 0x02); + } + else + { + filterType = 0xFF; + } + reader.ReadByte(); // QFactor? + reader.ReadUInt16(); // Frequency + + // Store this for when we're done reading the clip. + long curPos = reader.BaseStream.Position; + + // Go to the Clip in the Bank. + reader.BaseStream.Seek(offset, SeekOrigin.Begin); + + // Parse the Clip. + INTERNAL_clips[i] = new XACTClip(reader, clipVolume, filterType); + + // Back to where we were... + reader.BaseStream.Seek(curPos, SeekOrigin.Begin); + } + } + } + + public void GatherEvents(List eventList) + { + foreach (XACTClip curClip in INTERNAL_clips) + { + eventList.AddRange(curClip.Events); + } + } + + public XACTSoundInstance GenInstance( + AudioEngine audioEngine, + List waveBankNames + ) { + XACTSoundInstance result = new XACTSoundInstance(this); + if (instances.Count == 0) + { + foreach (XACTClip curClip in INTERNAL_clips) + { + curClip.LoadEvents(audioEngine, waveBankNames); + } + } + instances.Add(result); + return result; + } + + public void DisposeInstance( + XACTSoundInstance instance, + AudioEngine audioEngine, + List waveBankNames + ) { + instances.Remove(instance); + if (instances.Count == 0) + { + foreach (XACTClip curClip in INTERNAL_clips) + { + curClip.UnloadEvents(audioEngine, waveBankNames); + } + } + } + } + + internal enum CueProperty + { + Volume, + Pitch + } + + internal class XACTClip + { + internal enum EventTypeCode + { + Stop = 0, + PlayWave = 1, + PlayWaveWithTrackVariation = 3, + PlayWaveWithEffectVariation = 4, + PlayWaveWithTrackAndEffectVariation = 6, + Pitch = 7, + Volume = 8, + Marker = 9, + PitchRepeating = 16, + VolumeRepeating = 17, + MarkerRepeating = 18 + } + + internal enum StopEventScope + { + Track = 0x00, + Cue = 0x02 + } + + internal enum XactEventSettingType + { + Equation = 0x00, + Ramp = 0x01 + } + + internal enum XactEventEquationType + { + Value = 0x04, + Random = 0x08 + } + + internal enum XactEventOp + { + Replace = 0x00, + Add = 0x01 + } + + public XACTEvent[] Events + { + get; + private set; + } + + public XACTClip(ushort track, byte waveBank) + { + Events = new XACTEvent[1]; + Events[0] = new PlayWaveEvent( + 0, + 0, // FIXME: Is there such a thing as a random offset for a "simple" instance? + new ushort[] { track }, + new byte[] { waveBank }, + 0, + 0, + 0.0, + 0.0, + 0xFF, + 0, + false, + false, + false, + false, + 0, + false, + new byte[] { 0xFF } + ); + } + + public XACTClip(BinaryReader reader, double clipVolume, byte filterType) + { + // Number of XACT Events + Events = new XACTEvent[reader.ReadByte()]; + + for (int i = 0; i < Events.Length; i += 1) + { + // Full Event information + uint eventInfo = reader.ReadUInt32(); + + // XACT Event Type, Timestamp + EventTypeCode eventType = (EventTypeCode) (eventInfo & 0x0000001F); + uint eventTimestamp = (eventInfo >> 5) & 0x0000FFFF; + // uint eventUnknown = eventInfo >> 21; + + ushort randomOffset = reader.ReadUInt16(); + + // Unused byte (separator?) + byte separator = reader.ReadByte(); + Debug.Assert(separator == 0xFF); + + // Load the Event + XACTEvent evt = null; + if (eventType == EventTypeCode.Stop) + { + evt = StopEvent.ParseMarkerEvent( + reader, + eventTimestamp, + randomOffset + ); + } + else if (eventType == EventTypeCode.PlayWave) + { + evt = PlayWaveEvent.ParsePlayWaveEvent( + reader, + eventTimestamp, + randomOffset, + clipVolume, + filterType + ); + } + else if (eventType == EventTypeCode.PlayWaveWithTrackVariation) + { + evt = PlayWaveEvent.ParsePlayWaveWithTrackVariation( + reader, + eventTimestamp, + randomOffset, + clipVolume, + filterType + ); + } + else if (eventType == EventTypeCode.PlayWaveWithEffectVariation) + { + evt = PlayWaveEvent.ParsePlayWaveWithEffectVariation( + reader, + eventTimestamp, + randomOffset, + clipVolume, + filterType + ); + } + else if (eventType == EventTypeCode.PlayWaveWithTrackAndEffectVariation) + { + evt = PlayWaveEvent.ParsePlayWaveWithTrackAndEffectVariation( + reader, + eventTimestamp, + randomOffset, + clipVolume, + filterType + ); + } + else if (eventType == EventTypeCode.Pitch) + { + evt = ParseVolumeOrPitchEvent( + reader, + eventTimestamp, + randomOffset, + CueProperty.Pitch, + false + ); + } + else if (eventType == EventTypeCode.PitchRepeating) + { + evt = ParseVolumeOrPitchEvent( + reader, + eventTimestamp, + randomOffset, + CueProperty.Pitch, + true + ); + } + else if (eventType == EventTypeCode.Volume) + { + evt = ParseVolumeOrPitchEvent( + reader, + eventTimestamp, + randomOffset, + CueProperty.Volume, + false + ); + } + else if (eventType == EventTypeCode.VolumeRepeating) + { + evt = ParseVolumeOrPitchEvent( + reader, + eventTimestamp, + randomOffset, + CueProperty.Volume, + true + ); + } + else if (eventType == EventTypeCode.Marker) + { + evt = MarkerEvent.ParseMarkerEvent( + reader, + eventTimestamp, + randomOffset, + false + ); + } + else if (eventType == EventTypeCode.MarkerRepeating) + { + evt = MarkerEvent.ParseMarkerEvent( + reader, + eventTimestamp, + randomOffset, + true + ); + } + else + { + throw new NotImplementedException( + "EVENT TYPE " + eventType.ToString() + " NOT IMPLEMENTED!" + ); + } + + Events[i] = evt; + } + } + + private static XACTEvent ParseVolumeOrPitchEvent( + BinaryReader reader, + uint eventTimestamp, + ushort randomOffset, + CueProperty property, + bool repeating + ) { + // Read and convert the event setting type (Equation or Ramp). + XactEventSettingType settingType = + (XactEventSettingType) (reader.ReadByte() & 0x01); + + if (settingType == XactEventSettingType.Equation) + { + /* Event Flags + * bit0 - 0=Replace 1=Add + * bit1 - Unknown + * bit2-3 - 01=Value 10=Random + */ + byte eventFlags = reader.ReadByte(); + XactEventEquationType equationType = + (XactEventEquationType) (eventFlags & (0x04 | 0x08)); + XactEventOp operation = (XactEventOp) (eventFlags & 0x01); + + if (equationType == XactEventEquationType.Value) + { + return SetValueEvent.ParseSetValueEvent( + reader, + eventTimestamp, + randomOffset, + property, + repeating, + operation + ); + } + if (equationType == XactEventEquationType.Random) + { + return SetRandomValueEvent.ParseSetRandomValueEvent( + reader, + eventTimestamp, + randomOffset, + property, + repeating, + operation + ); + } + throw new NotImplementedException( + "Encountered event unexpected equation type." + ); + } + if (settingType == XactEventSettingType.Ramp) + { + return SetRampValueEvent.ParseSetRampValueEvent( + reader, + eventTimestamp, + randomOffset, + property + ); + } + + throw new NotImplementedException("Unknown setting type!"); + } + + public void LoadEvents(AudioEngine audioEngine, List waveBankNames) + { + foreach (XACTEvent curEvent in Events) + { + if (curEvent is PlayWaveEvent) + { + ((PlayWaveEvent) curEvent).LoadWaves( + audioEngine, + waveBankNames + ); + } + } + } + + public void UnloadEvents(AudioEngine audioEngine, List waveBankNames) + { + foreach (XACTEvent curEvent in Events) + { + if (curEvent is PlayWaveEvent) + { + ((PlayWaveEvent) curEvent).UnloadWaves( + audioEngine, + waveBankNames + ); + } + } + } + } + + internal abstract class XACTEvent + { + public uint Timestamp + { + get; + private set; + } + + /* FIXME: This needs to be used when processing events. + * Event instances should take the time stamp, apply a random + * offset bounded by this, and use it as the instance timestamp. + */ + public ushort RandomOffset + { + get; + private set; + } + + public int LoopCount + { + get; + private set; + } + + public float Frequency + { + get; + private set; + } + + public static readonly Random Random = new Random(); + + public XACTEvent(uint timestamp, ushort randomOffset) + : this(timestamp, randomOffset, 0, 0) + { + } + + protected XACTEvent( + uint timestamp, + ushort randomOffset, + int loopCount, + float frequency + ) { + Timestamp = timestamp; + RandomOffset = randomOffset; + LoopCount = loopCount; + Frequency = frequency; + } + + public static void ReadRecurrenceData( + BinaryReader reader, + out int count, + out float frequency + ) { + count = reader.ReadUInt16(); + frequency = reader.ReadUInt16() / 1000.0f; + } + } + + internal class StopEvent : XACTEvent + { + public readonly AudioStopOptions StopOptions; + public readonly XACTClip.StopEventScope Scope; + + public StopEvent( + uint timestamp, + ushort randomOffset, + AudioStopOptions stopOptions, + XACTClip.StopEventScope scope + ) : base(timestamp, randomOffset) { + StopOptions = stopOptions; + Scope = scope; + } + + public static StopEvent ParseMarkerEvent( + BinaryReader reader, + uint timestamp, + ushort randomOffset + ) { + /* Event Flags + * bit0 - Play Release (0), Immediate (1) + * bit1 - Stop Track (0), Stop Cue (1) + * bit2-7 - Unused + */ + byte eventFlags = reader.ReadByte(); + AudioStopOptions stopOptions = ((eventFlags & 0x1) == 1) + ? AudioStopOptions.Immediate + : AudioStopOptions.AsAuthored; + XACTClip.StopEventScope scope = (XACTClip.StopEventScope) (eventFlags & 0x02); + + return new StopEvent(timestamp, randomOffset, stopOptions, scope); + } + } + + internal class PlayWaveEvent : XACTEvent + { + private enum VariationPlaylistType : ushort + { + Ordered, + OrderedFromRandom, + Random, + RandomNoImmediateRepeats, + Shuffle + } + + private ushort[] INTERNAL_tracks; + private byte[] INTERNAL_waveBanks; + + private short INTERNAL_minPitch; + private short INTERNAL_maxPitch; + + private double INTERNAL_minVolume; + private double INTERNAL_maxVolume; + + private byte INTERNAL_filterType; + + private byte INTERNAL_loopCount; + + private bool INTERNAL_pitchVariationOnLoop; + private bool INTERNAL_pitchVariationAdd; + private bool INTERNAL_volumeVariationOnLoop; + private bool INTERNAL_volumeVariationAdd; + private VariationPlaylistType INTERNAL_trackVariationType; + private bool INTERNAL_trackVariationOnLoop; + private byte[] INTERNAL_weights; + private int INTERNAL_curWave; + + private SoundEffect[] INTERNAL_waves; + + public PlayWaveEvent( + uint timestamp, + ushort randomOffset, + ushort[] tracks, + byte[] waveBanks, + short minPitch, + short maxPitch, + double minVolume, + double maxVolume, + byte filterType, + byte loopCount, + bool pitchVariationOnLoop, + bool pitchVariationAdd, + bool volumeVariationOnLoop, + bool volumeVariationAdd, + ushort trackVariationType, + bool trackVariationOnLoop, + byte[] weights + ) : base(timestamp, randomOffset) { + INTERNAL_tracks = tracks; + INTERNAL_waveBanks = waveBanks; + INTERNAL_minPitch = minPitch; + INTERNAL_maxPitch = maxPitch; + INTERNAL_minVolume = minVolume; + INTERNAL_maxVolume = maxVolume; + INTERNAL_filterType = filterType; + INTERNAL_loopCount = loopCount; + INTERNAL_pitchVariationOnLoop = pitchVariationOnLoop; + INTERNAL_pitchVariationAdd = pitchVariationAdd; + INTERNAL_volumeVariationOnLoop = volumeVariationOnLoop; + INTERNAL_volumeVariationAdd = volumeVariationAdd; + INTERNAL_trackVariationType = (VariationPlaylistType) trackVariationType; + INTERNAL_trackVariationOnLoop = trackVariationOnLoop; + INTERNAL_weights = weights; + INTERNAL_waves = new SoundEffect[tracks.Length]; + INTERNAL_curWave = -1; + } + + public void LoadWaves(AudioEngine audioEngine, List waveBankNames) + { + for (int i = 0; i < INTERNAL_waves.Length; i += 1) + { + INTERNAL_waves[i] = audioEngine.INTERNAL_getWaveBankTrack( + waveBankNames[INTERNAL_waveBanks[i]], + INTERNAL_tracks[i] + ); + } + } + + public void UnloadWaves(AudioEngine audioEngine, List waveBankNames) + { + for (int i = 0; i < INTERNAL_waves.Length; i += 1) + { + audioEngine.INTERNAL_dropWaveBankTrack( + waveBankNames[INTERNAL_waveBanks[i]], + INTERNAL_tracks[i] + ); + } + Array.Clear(INTERNAL_waves, 0, INTERNAL_waves.Length); + } + + public SoundEffectInstance GenerateInstance( + double soundVolume, + short soundPitch, + int currentLoop, + double? prevVolume, + short? prevPitch, + out double finalVolume, + out short finalPitch + ) { + if (currentLoop > INTERNAL_loopCount && INTERNAL_loopCount != 255) + { + // We've finished all the loops! + finalVolume = 0.0; + finalPitch = 0; + return null; + } + INTERNAL_getNextSound(); + SoundEffectInstance result = INTERNAL_waves[INTERNAL_curWave].CreateInstance(); + result.INTERNAL_isXACTSource = true; + + finalVolume = ( + Random.NextDouble() * + (INTERNAL_maxVolume - INTERNAL_minVolume) + ) + INTERNAL_minVolume; + if (INTERNAL_volumeVariationAdd && currentLoop > 0) + { + finalVolume += prevVolume.Value; + } + else + { + finalVolume += soundVolume; + } + result.Volume = XACTCalculator.CalculateAmplitudeRatio(finalVolume); + + finalPitch = (short) Random.Next( + INTERNAL_minPitch, + INTERNAL_maxPitch + ); + if (INTERNAL_pitchVariationAdd && currentLoop > 0) + { + finalPitch += prevPitch.Value; + } + else + { + finalPitch += soundPitch; + } + result.Pitch = finalPitch / 1200.0f; + + result.FilterType = INTERNAL_filterType; + result.IsLooped = ( + (INTERNAL_loopCount == 255) && + !INTERNAL_trackVariationOnLoop && + !INTERNAL_volumeVariationOnLoop && + !INTERNAL_pitchVariationOnLoop + ); + return result; + } + + private void INTERNAL_getNextSound() + { + if (INTERNAL_trackVariationType == VariationPlaylistType.Ordered) + { + INTERNAL_curWave += 1; + if (INTERNAL_curWave >= INTERNAL_waves.Length) + { + INTERNAL_curWave = 0; + } + } + else if (INTERNAL_trackVariationType == VariationPlaylistType.OrderedFromRandom) + { + // FIXME: It seems like XACT organizes this for us? + INTERNAL_curWave += 1; + if (INTERNAL_curWave >= INTERNAL_waves.Length) + { + INTERNAL_curWave = 0; + } + } + else if (INTERNAL_trackVariationType == VariationPlaylistType.Random) + { + double max = 0.0; + for (int i = 0; i < INTERNAL_weights.Length; i += 1) + { + max += INTERNAL_weights[i]; + } + double next = Random.NextDouble() * max; + for (int i = INTERNAL_weights.Length - 1; i >= 0; i -= 1) + { + if (next > max - INTERNAL_weights[i]) + { + INTERNAL_curWave = i; + return; + } + max -= INTERNAL_weights[i]; + } + } + else if ( INTERNAL_trackVariationType == VariationPlaylistType.RandomNoImmediateRepeats || + INTERNAL_trackVariationType == VariationPlaylistType.Shuffle ) + { + // FIXME: Is Shuffle really any different from this? + double max = 0.0; + for (int i = 0; i < INTERNAL_weights.Length; i += 1) + { + if (i == INTERNAL_curWave) + { + continue; + } + max += INTERNAL_weights[i]; + } + double next = Random.NextDouble() * max; + for (int i = INTERNAL_weights.Length - 1; i >= 0; i -= 1) + { + if (i == INTERNAL_curWave) + { + continue; + } + if (next > max - INTERNAL_weights[i]) + { + INTERNAL_curWave = i; + return; + } + max -= INTERNAL_weights[i]; + } + } + else + { + throw new NotImplementedException( + "Variation Playlist Type unhandled: " + + INTERNAL_trackVariationType.ToString() + ); + } + } + + + public static XACTEvent ParsePlayWaveEvent( + BinaryReader reader, + uint eventTimestamp, + ushort randomOffset, + double clipVolume, + byte filterType + ) { + // Play Wave Header + byte waveBank; + byte loopCount; + ushort position; + ushort angle; + ushort track; + ParsePlayWaveBasicHeader( + reader, + out track, + out waveBank, + out loopCount, + out position, + out angle + ); + + return new PlayWaveEvent( + eventTimestamp, + randomOffset, + new ushort[] { track }, + new byte[] { waveBank }, + 0, + 0, + clipVolume, + clipVolume, + filterType, + loopCount, + false, + false, + false, + false, + 0, + false, + new byte[] { 0xFF } + ); + } + + public static XACTEvent ParsePlayWaveWithTrackVariation( + BinaryReader reader, + uint eventTimestamp, + ushort randomOffset, + double clipVolume, + byte filterType + ) { + // Play Wave Header + byte loopCount; + ushort position; + ushort angle; + ParsePlayWaveComplexHeader( + reader, + out loopCount, + out position, + out angle + ); + + // Track Variation Block + ushort numTracks; + ushort variationValues; + ushort variationType; + bool variationOnLoop; + ushort[] tracks; + byte[] waveBanks; + byte[] weights; + ParseTrackVariation( + reader, + out variationType, + out numTracks, + out variationValues, + out variationOnLoop, + out tracks, + out waveBanks, + out weights + ); + + return new PlayWaveEvent( + eventTimestamp, + randomOffset, + tracks, + waveBanks, + 0, + 0, + clipVolume, + clipVolume, + filterType, + loopCount, + false, + false, + false, + false, + variationType, + variationOnLoop, + weights + ); + } + + public static XACTEvent ParsePlayWaveWithEffectVariation( + BinaryReader reader, + uint eventTimestamp, + ushort randomOffset, + double clipVolume, + byte filterType + ) { + // Play Wave Header + byte waveBank; + byte loopCount; + ushort position; + ushort angle; + ushort track; + ParsePlayWaveBasicHeader( + reader, + out track, + out waveBank, + out loopCount, + out position, + out angle + ); + + // Effect Variation Block + short minPitch; + short maxPitch; + double minVolume; + double maxVolume; + ushort varFlags; + bool pitchVarLoop; + bool volumeVarLoop; + bool pitchVarAdd; + bool volumeVarAdd; + ParseEffectVariation( + reader, + clipVolume, + out minPitch, + out maxPitch, + out minVolume, + out maxVolume, + out varFlags, + out pitchVarLoop, + out volumeVarLoop, + out pitchVarAdd, + out volumeVarAdd + ); + + return new PlayWaveEvent( + eventTimestamp, + randomOffset, + new ushort[] { track }, + new byte[] { waveBank }, + minPitch, + maxPitch, + minVolume, + maxVolume, + filterType, + loopCount, + pitchVarLoop, + pitchVarAdd, + volumeVarLoop, + volumeVarAdd, + 0, + false, + new byte[] { 0xFF } + ); + } + + public static XACTEvent ParsePlayWaveWithTrackAndEffectVariation( + BinaryReader reader, + uint eventTimestamp, + ushort randomOffset, + double clipVolume, + byte filterType + ) { + // Play Wave Header + byte loopCount; + ushort position; + ushort angle; + ParsePlayWaveComplexHeader( + reader, + out loopCount, + out position, + out angle + ); + + // Effect Variation Block + short minPitch; + short maxPitch; + double minVolume; + double maxVolume; + ushort varFlags; + bool pitchVarLoop; + bool volumeVarLoop; + bool pitchVarAdd; + bool volumeVarAdd; + ParseEffectVariation( + reader, + clipVolume, + out minPitch, + out maxPitch, + out minVolume, + out maxVolume, + out varFlags, + out pitchVarLoop, + out volumeVarLoop, + out pitchVarAdd, + out volumeVarAdd + ); + + // Track Variation Block + ushort numTracks; + ushort variationValues; + ushort variationType; + bool variationOnLoop; + ushort[] tracks; + byte[] waveBanks; + byte[] weights; + ParseTrackVariation( + reader, + out variationType, + out numTracks, + out variationValues, + out variationOnLoop, + out tracks, + out waveBanks, + out weights + ); + + return new PlayWaveEvent( + eventTimestamp, + randomOffset, + tracks, + waveBanks, + minPitch, + maxPitch, + minVolume, + maxVolume, + filterType, + loopCount, + pitchVarLoop, + pitchVarAdd, + volumeVarLoop, + volumeVarAdd, + variationType, + variationOnLoop, + weights + ); + } + + + private static void ParsePlayWaveBasicHeader( + BinaryReader reader, + out ushort track, + out byte waveBank, + out byte loopCount, + out ushort position, + out ushort angle + ) { + /* Event Flags + * 0x01 = Break Loop + * 0x02 = Use Speaker Position + * 0x04 = Use Center Speaker + * 0x08 = New Speaker Position On Loop + */ + reader.ReadByte(); + + // WaveBank Track Index + track = reader.ReadUInt16(); + + // WaveBank Index + waveBank = reader.ReadByte(); + + // Number of times to loop wave (255 is infinite) + loopCount = reader.ReadByte(); + + // Speaker position angle/arc, unused + position = reader.ReadUInt16(); + angle = reader.ReadUInt16(); + } + + private static void ParsePlayWaveComplexHeader( + BinaryReader reader, + out byte loopCount, + out ushort position, + out ushort angle + ) { + /* Event Flags + * 0x01 = Break Loop + * 0x02 = Use Speaker Position + * 0x04 = Use Center Speaker + * 0x08 = New Speaker Position On Loop + */ + reader.ReadByte(); + + // Number of times to loop wave (255 is infinite) + loopCount = reader.ReadByte(); + + // Speaker position angle/arc, unused + position = reader.ReadUInt16(); + angle = reader.ReadUInt16(); + } + + private static void ParseTrackVariation( + BinaryReader reader, + out ushort variationType, + out ushort numTracks, + out ushort variationValues, + out bool variationOnLoop, + out ushort[] tracks, + out byte[] waveBanks, + out byte[] weights + ) { + // Number of WaveBank tracks + numTracks = reader.ReadUInt16(); + + /* Variation Playlist Type. + * First 4 bytes indicates Variation Type. + * Next 4 bytes appear to indicate New Variation On Loop. + * The rest is currently unknown. + * -flibit + */ + variationValues = reader.ReadUInt16(); + variationType = (ushort) (variationValues & 0x000F); + variationOnLoop = (variationValues & 0x00F0) > 0; + + // Unknown values + reader.ReadBytes(4); + + // Obtain WaveBank track information + tracks = new ushort[numTracks]; + waveBanks = new byte[numTracks]; + weights = new byte[numTracks]; + for (ushort j = 0; j < numTracks; j += 1) + { + tracks[j] = reader.ReadUInt16(); + waveBanks[j] = reader.ReadByte(); + byte minWeight = reader.ReadByte(); + byte maxWeight = reader.ReadByte(); + weights[j] = (byte) (maxWeight - minWeight); + } + } + + private static void ParseEffectVariation( + BinaryReader reader, + double clipVolume, + out short minPitch, + out short maxPitch, + out double minVolume, + out double maxVolume, + out ushort varFlags, + out bool pitchVarLoop, + out bool volumeVarLoop, + out bool pitchVarAdd, + out bool volumeVarAdd + ) { + // Pitch Variation + minPitch = reader.ReadInt16(); + maxPitch = reader.ReadInt16(); + + // Volume Variation + minVolume = XACTCalculator.ParseDecibel(reader.ReadByte()); + maxVolume = XACTCalculator.ParseDecibel(reader.ReadByte()); + + // Frequency Variation, unsued + reader.ReadSingle(); + reader.ReadSingle(); + + // Q Factor Variation, unused + reader.ReadSingle(); + reader.ReadSingle(); + + // Variation On Loop flags + varFlags = reader.ReadUInt16(); + if ((varFlags & 0x1000) == 0) + { + minPitch = 0; + maxPitch = 0; + } + if ((varFlags & 0x2000) == 0) + { + minVolume = clipVolume; + maxVolume = clipVolume; + } + // varFlags & 0xC000 is freq/qfactor, always together + pitchVarLoop = (varFlags & 0x0100) > 0; + volumeVarLoop = (varFlags & 0x0200) > 0; + // varFlags & 0x0C00 is freq/qfactor loop, always together + pitchVarAdd = (varFlags & 0x0004) > 0; + volumeVarAdd = (varFlags & 0x0001) > 0; + // varFlags & 0x0050 is freq/qfactor add, can be separate + } + } + + internal class SetValueEvent : XACTEvent + { + public readonly float Value; + public readonly CueProperty Property; + public readonly XACTClip.XactEventOp Operation; + + public SetValueEvent( + uint timestamp, + ushort randomOffset, + float value, + CueProperty property, + XACTClip.XactEventOp operation, + int loopCount = 0, + float frequency = 0 + ) : base( + timestamp, + randomOffset, + loopCount, + frequency + ) { + Value = value; + Property = property; + Operation = operation; + } + + public double GetVolume(double currentVolume) + { + switch (Operation) + { + case XACTClip.XactEventOp.Replace: + return Value; + case XACTClip.XactEventOp.Add: + return currentVolume + Value; + default: + return currentVolume; + } + } + + public float GetPitch(float currentPitch) + { + switch (Operation) + { + case XACTClip.XactEventOp.Replace: + return Value; + case XACTClip.XactEventOp.Add: + return currentPitch + Value; + default: + return currentPitch; + } + } + + public static XACTEvent ParseSetValueEvent( + BinaryReader reader, + uint eventTimestamp, + ushort randomOffset, + CueProperty property, + bool repeating, + XACTClip.XactEventOp operation + ) { + // Absolute or relative value to set to. + float eventValue = reader.ReadSingle(); + + // Unused/unknown trailing bytes. + reader.ReadBytes(9); + + // Is this is a recurrence event? + if (repeating) + { + int count; + float frequency; + XACTEvent.ReadRecurrenceData(reader, out count, out frequency); + + return new SetValueEvent( + eventTimestamp, + randomOffset, + eventValue, + property, + operation, + count, + frequency + ); + } + else + { + return new SetValueEvent( + eventTimestamp, + randomOffset, + eventValue, + property, + operation + ); + } + } + } + + internal class SetRandomValueEvent : XACTEvent + { + public readonly float Min; + public readonly float Max; + public readonly CueProperty Property; + public readonly XACTClip.XactEventOp Operation; + + public SetRandomValueEvent( + uint timestamp, + ushort randomOffset, + float min, + float max, + CueProperty property, + XACTClip.XactEventOp operation, + int loopCount = 0, + float frequency = 0 + ) : base( + timestamp, + randomOffset, + loopCount, + frequency + ) { + Min = min; + Max = max; + Property = property; + Operation = operation; + } + + public double GetVolume(double currentVolume) + { + double randomVolume = Min + (Random.NextDouble() * (Max - Min)); + switch (Operation) + { + case XACTClip.XactEventOp.Replace: + return randomVolume; + case XACTClip.XactEventOp.Add: + return currentVolume + randomVolume; + default: + return currentVolume; + } + } + + public float GetPitch(float currentPitch) + { + float randomPitch = Min + (float) (Random.NextDouble() * (Max - Min)); + switch (Operation) + { + case XACTClip.XactEventOp.Replace: + return randomPitch; + case XACTClip.XactEventOp.Add: + return currentPitch + randomPitch; + default: + return currentPitch; + } + } + + public static XACTEvent ParseSetRandomValueEvent( + BinaryReader reader, + uint eventTimestamp, + ushort randomOffset, + CueProperty property, + bool repeating, + XACTClip.XactEventOp operation) + { + // Random min/max. + float eventMin = reader.ReadSingle(); + float eventMax = reader.ReadSingle(); + + // Unused/unknown trailing bytes. + reader.ReadBytes(5); + + // Is this is a recurrence event? + if (repeating) + { + int count; + float frequency; + ReadRecurrenceData(reader, out count, out frequency); + + return new SetRandomValueEvent( + eventTimestamp, + randomOffset, + eventMin, + eventMax, + property, + operation, + count, + frequency + ); + } + else + { + return new SetRandomValueEvent( + eventTimestamp, + randomOffset, + eventMin, + eventMax, + property, + operation + ); + } + } + } + + internal class SetRampValueEvent : XACTEvent + { + public readonly float InitialValue; + public readonly float InitialSlope; + public readonly float SlopeDelta; + public readonly float Duration; + public readonly CueProperty Property; + + public SetRampValueEvent( + uint timestamp, + ushort randomOffset, + float initialValue, + float initialSlope, + float slopeDelta, + float duration, + CueProperty property, + int loopCount = 0, + float frequency = 0 + ) : base( + timestamp, + randomOffset, + loopCount, + frequency + ) { + InitialValue = initialValue; + InitialSlope = initialSlope; + SlopeDelta = slopeDelta; + Duration = duration; + Property = property; + } + + public static XACTEvent ParseSetRampValueEvent( + BinaryReader reader, + uint eventTimestamp, + ushort randomOffset, + CueProperty property + ) { + // Ramp type. + float initialValue = reader.ReadSingle(); + + // Slope appears to be encoded as (endValue - startValue) / duration; + float initialSlope = reader.ReadSingle() * 100.0f; + float slopeDelta = reader.ReadSingle() * 100.0f; + + // Duration of the ramp in seconds. + float duration = reader.ReadUInt16() / 1000.0f; + + // Number of slices to break up the duration. + // const float slices = 10; + // float endValue = initialSlope * duration * slices + initialValue; + + return new SetRampValueEvent( + eventTimestamp, + randomOffset, + initialValue, + initialSlope, + slopeDelta, + duration, + property + ); + } + } + + internal class MarkerEvent : XACTEvent + { + // private readonly int markerData; + + public MarkerEvent( + uint timestamp, + ushort randomOffset, + int markerData, + int loopCount = 0, + float frequency = 0 + ) : base( + timestamp, + randomOffset, + loopCount, + frequency + ) { + // FIXME: this.markerData = markerData; + } + + public static MarkerEvent ParseMarkerEvent( + BinaryReader reader, + uint eventTimestamp, + ushort randomOffset, + bool repeating + ) { + // Data value for the marker (0-999) + int markerData = reader.ReadInt32(); + + // Is this is a recurrence marker event? + if (repeating) + { + int count; + float frequency; + XACTEvent.ReadRecurrenceData(reader, out count, out frequency); + + return new MarkerEvent( + eventTimestamp, + randomOffset, + markerData, + count, + frequency + ); + } + else + { + return new MarkerEvent(eventTimestamp, randomOffset, markerData); + } + } + } +} diff --git a/FNA/src/Audio/DynamicSoundEffectInstance.cs b/FNA/src/Audio/DynamicSoundEffectInstance.cs new file mode 100644 index 0000000..4f5b125 --- /dev/null +++ b/FNA/src/Audio/DynamicSoundEffectInstance.cs @@ -0,0 +1,417 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.dynamicsoundeffectinstance.aspx + public sealed class DynamicSoundEffectInstance : SoundEffectInstance + { + #region Public Properties + + public int PendingBufferCount + { + get; + private set; + } + + public override bool IsLooped + { + get + { + return false; + } + set + { + // No-op, DynamicSoundEffectInstance cannot be looped! + } + } + + #endregion + + #region Private XNA Variables + + private int sampleRate; + private AudioChannels channels; + + private const int MINIMUM_BUFFER_CHECK = 3; + + #endregion + + #region Private AL Variables + + private Queue queuedBuffers; + private Queue buffersToQueue; + private Queue availableBuffers; + + #endregion + + #region BufferNeeded Event + + public event EventHandler BufferNeeded; + + #endregion + + #region Public Constructor + + public DynamicSoundEffectInstance(int sampleRate, AudioChannels channels) : base(null) + { + this.sampleRate = sampleRate; + this.channels = channels; + + PendingBufferCount = 0; + + isDynamic = true; + queuedBuffers = new Queue(); + buffersToQueue = new Queue(); + availableBuffers = new Queue(); + } + + #endregion + + #region Destructor + + ~DynamicSoundEffectInstance() + { + Dispose(); + } + + #endregion + + #region Public Dispose Method + + public override void Dispose() + { + if (!IsDisposed) + { + base.Dispose(); // Will call Stop(true); + + // Delete all known buffer objects + while (queuedBuffers.Count > 0) + { + AudioDevice.ALDevice.DeleteBuffer(queuedBuffers.Dequeue()); + } + queuedBuffers = null; + while (availableBuffers.Count > 0) + { + AudioDevice.ALDevice.DeleteBuffer(availableBuffers.Dequeue()); + } + availableBuffers = null; + while (buffersToQueue.Count > 0) + { + AudioDevice.ALDevice.DeleteBuffer(buffersToQueue.Dequeue()); + } + buffersToQueue = null; + + IsDisposed = true; + } + } + + #endregion + + #region Public Time/Sample Information Methods + + public TimeSpan GetSampleDuration(int sizeInBytes) + { + return SoundEffect.GetSampleDuration( + sizeInBytes, + sampleRate, + channels + ); + } + + public int GetSampleSizeInBytes(TimeSpan duration) + { + return SoundEffect.GetSampleSizeInBytes( + duration, + sampleRate, + channels + ); + } + + #endregion + + #region Public SubmitBuffer Methods + + public void SubmitBuffer(byte[] buffer) + { + this.SubmitBuffer(buffer, 0, buffer.Length); + } + + public void SubmitBuffer(byte[] buffer, int offset, int count) + { + // Generate a buffer if we don't have any to use. + if (availableBuffers.Count == 0) + { + availableBuffers.Enqueue( + AudioDevice.ALDevice.GenBuffer(sampleRate, channels) + ); + } + + // Push buffer to the AL. + IALBuffer newBuf = availableBuffers.Dequeue(); + GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + AudioDevice.ALDevice.SetBufferData( + newBuf, + handle.AddrOfPinnedObject(), + offset, + count + ); + handle.Free(); + + // If we're already playing, queue immediately. + if (INTERNAL_alSource != null) + { + AudioDevice.ALDevice.QueueSourceBuffer( + INTERNAL_alSource, + newBuf + ); + queuedBuffers.Enqueue(newBuf); + + // If the source stopped, reboot it now. + if (AudioDevice.ALDevice.GetSourceState(INTERNAL_alSource) == SoundState.Stopped) + { + AudioDevice.ALDevice.PlaySource(INTERNAL_alSource); + } + } + else + { + buffersToQueue.Enqueue(newBuf); + } + + PendingBufferCount += 1; + } + + #endregion + + #region Public Play Method + + public override void Play() + { + Play(true); + } + + #endregion + + #region Internal Play Method + + internal void Play(bool isManaged) + { + // No-op if we're already playing. + if (State != SoundState.Stopped) + { + if (State == SoundState.Paused) + { + // ... but be sure pause/resume still works + Resume(); + } + return; + } + + if (INTERNAL_alSource != null) + { + // The sound has stopped, but hasn't cleaned up yet... + AudioDevice.ALDevice.StopAndDisposeSource(INTERNAL_alSource); + INTERNAL_alSource = null; + } + while (queuedBuffers.Count > 0) + { + availableBuffers.Enqueue(queuedBuffers.Dequeue()); + PendingBufferCount -= 1; + } + + if (AudioDevice.ALDevice == null) + { + throw new NoAudioHardwareException(); + } + + INTERNAL_alSource = AudioDevice.ALDevice.GenSource(); + if (INTERNAL_alSource == null) + { + FNALoggerEXT.LogWarn("AL SOURCE WAS NOT AVAILABLE, SKIPPING."); + return; + } + + // Queue the buffers to this source + while (buffersToQueue.Count > 0) + { + IALBuffer nextBuf = buffersToQueue.Dequeue(); + queuedBuffers.Enqueue(nextBuf); + AudioDevice.ALDevice.QueueSourceBuffer(INTERNAL_alSource, nextBuf); + } + + // Apply Pan/Position + if (INTERNAL_positionalAudio) + { + INTERNAL_positionalAudio = false; + AudioDevice.ALDevice.SetSourcePosition( + INTERNAL_alSource, + position + ); + } + else + { + Pan = Pan; + } + + // Reassign Properties, in case the AL properties need to be applied. + Volume = Volume; + Pitch = Pitch; + + // ... but wait! What if we need moar buffers? + for ( + int i = MINIMUM_BUFFER_CHECK - PendingBufferCount; + (i > 0) && BufferNeeded != null; + i -= 1 + ) { + BufferNeeded(this, null); + } + + // Finally. + AudioDevice.ALDevice.PlaySource(INTERNAL_alSource); + if (isManaged) + { + AudioDevice.DynamicInstancePool.Add(this); + } + } + + #endregion + + #region Internal Update Method + + internal void Update() + { + // Get the number of processed buffers. + int finishedBuffers = AudioDevice.ALDevice.CheckProcessedBuffers( + INTERNAL_alSource + ); + if (finishedBuffers == 0) + { + // Nothing to do... yet. + return; + } + + // Dequeue the processed buffers, error checking as needed. + AudioDevice.ALDevice.DequeueSourceBuffers( + INTERNAL_alSource, + finishedBuffers, + queuedBuffers + ); + + // The processed buffers are now available. + for (int i = 0; i < finishedBuffers; i += 1) + { + availableBuffers.Enqueue(queuedBuffers.Dequeue()); + } + + // PendingBufferCount changed during playback, trigger now! + PendingBufferCount -= finishedBuffers; + if (BufferNeeded != null) + { + BufferNeeded(this, null); + } + + // Do we need even moar buffers? + for ( + int i = MINIMUM_BUFFER_CHECK - PendingBufferCount; + (i > 0) && BufferNeeded != null; + i -= 1 + ) { + BufferNeeded(this, null); + } + } + + #endregion + + #region Internal Sample Data Retrieval Method + + internal void GetSamples(float[] samples) + { + if (INTERNAL_alSource != null && queuedBuffers.Count > 0) + { + GCHandle handle = GCHandle.Alloc(samples, GCHandleType.Pinned); + AudioDevice.ALDevice.GetBufferData( + INTERNAL_alSource, + queuedBuffers.ToArray(), // FIXME: Blech -flibit + handle.AddrOfPinnedObject(), + samples.Length, + channels + ); + handle.Free(); + } + else + { + Array.Clear(samples, 0, samples.Length); + } + } + + #endregion + + #region Public FNA Extension Methods + + public void SubmitFloatBufferEXT(float[] buffer) + { + SubmitFloatBufferEXT(buffer, 0, buffer.Length); + } + + public void SubmitFloatBufferEXT(float[] buffer, int offset, int count) + { + /* Float samples are the typical format received from decoders. + * We currently use this for the VideoPlayer. + * -flibit + */ + + // Generate a buffer if we don't have any to use. + if (availableBuffers.Count == 0) + { + availableBuffers.Enqueue(AudioDevice.ALDevice.GenBuffer(sampleRate, channels)); + } + + // Push buffer to the AL. + IALBuffer newBuf = availableBuffers.Dequeue(); + GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + AudioDevice.ALDevice.SetBufferFloatData( + newBuf, + handle.AddrOfPinnedObject(), + offset, + count + ); + handle.Free(); + + // If we're already playing, queue immediately. + if (INTERNAL_alSource != null) + { + AudioDevice.ALDevice.QueueSourceBuffer( + INTERNAL_alSource, + newBuf + ); + queuedBuffers.Enqueue(newBuf); + + // If the source stopped, reboot it now. + if (AudioDevice.ALDevice.GetSourceState(INTERNAL_alSource) == SoundState.Stopped) + { + AudioDevice.ALDevice.PlaySource(INTERNAL_alSource); + } + } + else + { + buffersToQueue.Enqueue(newBuf); + } + + PendingBufferCount += 1; + } + + #endregion + } +} diff --git a/FNA/src/Audio/InstancePlayLimitException.cs b/FNA/src/Audio/InstancePlayLimitException.cs new file mode 100644 index 0000000..cea7464 --- /dev/null +++ b/FNA/src/Audio/InstancePlayLimitException.cs @@ -0,0 +1,22 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.instanceplaylimitexception.aspx + [Serializable] + public sealed class InstancePlayLimitException : ExternalException + { + } +} diff --git a/FNA/src/Audio/Microphone.cs b/FNA/src/Audio/Microphone.cs new file mode 100644 index 0000000..2804534 --- /dev/null +++ b/FNA/src/Audio/Microphone.cs @@ -0,0 +1,221 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.ObjectModel; +using System.Runtime.InteropServices; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + public class Microphone + { + #region Public Static Properties + + public static ReadOnlyCollection All + { + get; + internal set; + } + + public static Microphone Default + { + get + { + if (All.Count == 0) + { + return null; + } + return All[0]; + } + } + + #endregion + + #region Public Properties + + public TimeSpan BufferDuration + { + get + { + return bufferDuration; + } + set + { + if ( value.Milliseconds < 100 || + value.Milliseconds > 1000 || + value.Milliseconds % 10 != 0 ) + { + throw new ArgumentOutOfRangeException(); + } + bufferDuration = value; + } + } + + public bool IsHeadset + { + get + { + // FIXME: I think this is just for Windows Phone? -flibit + return false; + } + } + + public int SampleRate + { + get + { + return SAMPLERATE; + } + } + + public MicrophoneState State + { + get; + private set; + } + + #endregion + + #region Public Variables + + public readonly string Name; + + #endregion + + #region Private Variables + + private TimeSpan bufferDuration; + private IntPtr nativeMic; + + #endregion + + #region Events + + public event EventHandler BufferReady; + + #endregion + + #region Private Constants + + /* FIXME: This is what XNA4 aims for, but it _could_ be lower. + * Something work looking at is falling back to lower sample rates in + * powers of two, i.e. 44100, 22050, 11025, etc. + * -flibit + */ + private const int SAMPLERATE = 44100; + + #endregion + + #region Internal Constructor + + internal Microphone(string name) + { + Name = name; + bufferDuration = TimeSpan.FromSeconds(1.0); + State = MicrophoneState.Stopped; + } + + #endregion + + #region Public Methods + + public int GetData(byte[] buffer) + { + return GetData(buffer, 0, buffer.Length); + } + + public int GetData(byte[] buffer, int offset, int count) + { + if (buffer == null) + { + throw new ArgumentException("buffer is null!"); + } + if (offset < 0 || offset > buffer.Length) + { + throw new ArgumentException("offset"); + } + if (count <= 0 || (offset + count) > buffer.Length) + { + throw new ArgumentException("count"); + } + GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + int read = AudioDevice.ALDevice.CaptureSamples( + nativeMic, + handle.AddrOfPinnedObject() + offset, + count + ); + handle.Free(); + return read; + } + + public TimeSpan GetSampleDuration(int sizeInBytes) + { + return SoundEffect.GetSampleDuration( + sizeInBytes, + SampleRate, + AudioChannels.Mono + ); + } + + public int GetSampleSizeInBytes(TimeSpan duration) + { + return SoundEffect.GetSampleSizeInBytes( + duration, + SampleRate, + AudioChannels.Mono + ); + } + + public void Start() + { + if (State == MicrophoneState.Stopped) + { + nativeMic = AudioDevice.ALDevice.StartDeviceCapture( + Name, + SampleRate, + GetSampleSizeInBytes(bufferDuration) + ); + if (nativeMic == IntPtr.Zero) + { + throw new NoMicrophoneConnectedException(Name); + } + AudioDevice.ActiveMics.Add(this); + State = MicrophoneState.Started; + } + } + + public void Stop() + { + if (State == MicrophoneState.Started) + { + AudioDevice.ActiveMics.Remove(this); + AudioDevice.ALDevice.StopDeviceCapture(nativeMic); + nativeMic = IntPtr.Zero; + State = MicrophoneState.Stopped; + } + } + + #endregion + + #region Internal Methods + + internal void CheckBuffer() + { + if ( BufferReady != null && + AudioDevice.ALDevice.CaptureHasSamples(nativeMic) ) + { + BufferReady(this, EventArgs.Empty); + } + } + + #endregion + } +} diff --git a/FNA/src/Audio/MicrophoneState.cs b/FNA/src/Audio/MicrophoneState.cs new file mode 100644 index 0000000..9699400 --- /dev/null +++ b/FNA/src/Audio/MicrophoneState.cs @@ -0,0 +1,17 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + public enum MicrophoneState + { + Started, + Stopped + } +} diff --git a/FNA/src/Audio/NoAudioHardwareException.cs b/FNA/src/Audio/NoAudioHardwareException.cs new file mode 100644 index 0000000..8e933cb --- /dev/null +++ b/FNA/src/Audio/NoAudioHardwareException.cs @@ -0,0 +1,35 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.noaudiohardwareexception.aspx + [Serializable] + public sealed class NoAudioHardwareException : ExternalException + { + public NoAudioHardwareException() + { + } + + public NoAudioHardwareException(String message) + : base(message) + { + } + + public NoAudioHardwareException(String message, Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/FNA/src/Audio/NoMicrophoneConnectedException.cs b/FNA/src/Audio/NoMicrophoneConnectedException.cs new file mode 100644 index 0000000..bcb3fa8 --- /dev/null +++ b/FNA/src/Audio/NoMicrophoneConnectedException.cs @@ -0,0 +1,35 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Runtime.InteropServices; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.nomicrophoneconnectedexception.aspx + [Serializable] + public sealed class NoMicrophoneConnectedException : Exception + { + public NoMicrophoneConnectedException() + { + } + + public NoMicrophoneConnectedException(String message) + : base(message) + { + } + + public NoMicrophoneConnectedException(String message, Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/FNA/src/Audio/RendererDetail.cs b/FNA/src/Audio/RendererDetail.cs new file mode 100644 index 0000000..e217bf2 --- /dev/null +++ b/FNA/src/Audio/RendererDetail.cs @@ -0,0 +1,79 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + [Serializable] + public struct RendererDetail + { + #region Public Properties + + public string FriendlyName + { + get; + private set; + } + + public string RendererId + { + get; + private set; + } + + #endregion + + #region Internal Constructor + + internal RendererDetail(string name, string id) : this() + { + FriendlyName = name; + RendererId = id; + } + + #endregion + + #region Public Methods + + public override bool Equals(object obj) + { + return ( (obj is RendererDetail) && + RendererId.Equals(((RendererDetail) obj).RendererId) ); + } + + public override int GetHashCode() + { + return RendererId.GetHashCode(); + } + + public override string ToString() + { + return FriendlyName; + } + + #endregion + + #region Public Static Operator Overloads + + public static bool operator==(RendererDetail left, RendererDetail right) + { + return left.RendererId.Equals(right.RendererId); + } + + public static bool operator!=(RendererDetail left, RendererDetail right) + { + return !left.RendererId.Equals(right.RendererId); + } + + #endregion + } +} diff --git a/FNA/src/Audio/SoundBank.cs b/FNA/src/Audio/SoundBank.cs new file mode 100644 index 0000000..53e3480 --- /dev/null +++ b/FNA/src/Audio/SoundBank.cs @@ -0,0 +1,487 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.IO; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.soundbank.aspx + public class SoundBank : IDisposable + { + #region Public Properties + + public bool IsDisposed + { + get; + private set; + } + + public bool IsInUse + { + get + { + throw new NotImplementedException("Bank Cue instance count tracking!"); + } + } + + #endregion + + #region Private Variables + + private AudioEngine INTERNAL_baseEngine; + + private List INTERNAL_waveBankNames; + private Dictionary INTERNAL_cueData; + + #endregion + + #region Disposing Event + + public event EventHandler Disposing; + + #endregion + + #region Public Constructor + + public SoundBank(AudioEngine audioEngine, string filename) + { + if (audioEngine == null) + { + throw new ArgumentNullException("audioEngine"); + } + if (String.IsNullOrEmpty(filename)) + { + throw new ArgumentNullException("filename"); + } + + INTERNAL_baseEngine = audioEngine; + + using (Stream soundBankStream = TitleContainer.OpenStream(filename)) + using (BinaryReader reader = new BinaryReader(soundBankStream)) + { + // Check the file header. Should be 'SDBK' + if (reader.ReadUInt32() != 0x4B424453) + { + throw new ArgumentException("SDBK format not recognized!"); + } + + // Check the content version. Assuming XNA4 Refresh. + if (reader.ReadUInt16() != AudioEngine.ContentVersion) + { + throw new ArgumentException("SDBK Content version!"); + } + + // Check the tool version. Assuming XNA4 Refresh. + if (reader.ReadUInt16() != 43) + { + throw new ArgumentException("SDBK Tool version!"); + } + + // CRC, unused + reader.ReadUInt16(); + + // Last modified, unused + reader.ReadUInt64(); + + // Unknown value, Internet suggests platform + reader.ReadByte(); + + // Cue Counts + ushort numCueSimple = reader.ReadUInt16(); + ushort numCueComplex = reader.ReadUInt16(); + + // Unknown value + reader.ReadUInt16(); + + // Total Cues, unused + reader.ReadUInt16(); + + // Number of associated WaveBanks + byte numWaveBanks = reader.ReadByte(); + + // Unknown, Internet suggest number of "sounds" + reader.ReadUInt16(); + + // Cue Name Table Length + ushort cueNameTableLength = reader.ReadUInt16(); + + // Unknown value + reader.ReadUInt16(); + + // Cue Offsets + uint cueSimpleOffset = reader.ReadUInt32(); + uint cueComplexOffset = reader.ReadUInt32(); + + // Cue Name Table Offset + uint cueNameTableOffset = reader.ReadUInt32(); + + // Unknown value + reader.ReadUInt32(); + + // Variable Tables Offset, unused + reader.ReadUInt32(); + + // Unknown value + reader.ReadUInt32(); + + // WaveBank Name Table Offset + uint waveBankNameTableOffset = reader.ReadUInt32(); + + // Cue Name Hash Offsets, unused + reader.ReadUInt32(); + reader.ReadUInt32(); + + // Unknown value, Internet suggest "sounds" offset + reader.ReadUInt32(); + + // SoundBank Name, unused + reader.ReadBytes(64); + + // Parse WaveBank names + soundBankStream.Seek(waveBankNameTableOffset, SeekOrigin.Begin); + INTERNAL_waveBankNames = new List(); + for (byte i = 0; i < numWaveBanks; i += 1) + { + INTERNAL_waveBankNames.Add( + System.Text.Encoding.UTF8.GetString( + reader.ReadBytes(64), 0, 64 + ).Replace("\0", "") + ); + } + + // Parse Cue name list + soundBankStream.Seek(cueNameTableOffset, SeekOrigin.Begin); + string[] cueNames = System.Text.Encoding.UTF8.GetString( + reader.ReadBytes(cueNameTableLength), + 0, + cueNameTableLength + ).Split('\0'); + + // Create our CueData Dictionary + INTERNAL_cueData = new Dictionary(); + + // Parse Simple Cues + soundBankStream.Seek(cueSimpleOffset, SeekOrigin.Begin); + for (ushort i = 0; i < numCueSimple; i += 1) + { + // Cue flags, unused + reader.ReadByte(); + + // Cue Sound Offset + uint offset = reader.ReadUInt32(); + + // Store this for when we're done reading the sound. + long curPos = reader.BaseStream.Position; + + // Go to the sound in the Bank. + reader.BaseStream.Seek(offset, SeekOrigin.Begin); + + // Parse the Sound + INTERNAL_cueData.Add( + cueNames[i], + new CueData(new XACTSound(reader)) + ); + + // Back to where we were... + reader.BaseStream.Seek(curPos, SeekOrigin.Begin); + } + + // Parse Complex Cues + soundBankStream.Seek(cueComplexOffset, SeekOrigin.Begin); + for (ushort i = 0; i < numCueComplex; i += 1) + { + // Cue flags + byte cueFlags = reader.ReadByte(); + + if ((cueFlags & 0x04) != 0) // FIXME: ??? + { + // Cue Sound Offset + uint offset = reader.ReadUInt32(); + + // Unknown value + reader.ReadUInt32(); + + // Store this for when we're done reading the sound. + long curPos = reader.BaseStream.Position; + + // Go to the sound in the bank + reader.BaseStream.Seek(offset, SeekOrigin.Begin); + + // Parse the Sound + INTERNAL_cueData.Add( + cueNames[numCueSimple + i], + new CueData(new XACTSound(reader)) + ); + + // Back to where we were... + reader.BaseStream.Seek(curPos, SeekOrigin.Begin); + } + else + { + // Variation Table Offset for this Cue + uint offset = reader.ReadUInt32(); + + // Transition Table Offset for this Cue, unused + reader.ReadUInt32(); + + // Store this for when we're done reading the Variation Table + long curPos = reader.BaseStream.Position; + + // Seek to the Variation Table in the file + reader.BaseStream.Seek(offset, SeekOrigin.Begin); + + // Number of Variations in the Table + ushort numVariations = reader.ReadUInt16(); + + // Variation Table Flags + ushort varTableFlags = reader.ReadUInt16(); + + // Unknown value + reader.ReadUInt16(); + + // Probability Control Variable, if applicable + ushort variable = reader.ReadUInt16(); + + // Create data for the CueData + XACTSound[] cueSounds = new XACTSound[numVariations]; + float[,] cueProbs = new float[numVariations, 2]; + + // Used to determine Variation storage format + int varTableType = (varTableFlags >> 3) & 0x0007; + + for (ushort j = 0; j < numVariations; j += 1) + { + if (varTableType == 0) + { + // Wave with byte min/max + ushort track = reader.ReadUInt16(); + byte waveBank = reader.ReadByte(); + byte wMin = reader.ReadByte(); + byte wMax = reader.ReadByte(); + + // Create the Sound + cueSounds[j] = new XACTSound(track, waveBank); + + // Calculate probability based on weight + cueProbs[j, 0] = wMax / 255.0f; + cueProbs[j, 1] = wMin / 255.0f; + } + else if (varTableType == 1) + { + // Complex with byte min/max + uint varOffset = reader.ReadUInt32(); + byte wMin = reader.ReadByte(); + byte wMax = reader.ReadByte(); + + // Store for sound read + long varPos = reader.BaseStream.Position; + + // Seek to the sound in the Bank + reader.BaseStream.Seek(varOffset, SeekOrigin.Begin); + + // Read the sound + cueSounds[j] = new XACTSound(reader); + + // Back to where we were... + reader.BaseStream.Seek(varPos, SeekOrigin.Begin); + + // Calculate probability based on weight + cueProbs[j, 0] = wMax / 255.0f; + cueProbs[j, 1] = wMin / 255.0f; + } + else if (varTableType == 3) + { + // Complex with float min/max + uint varOffset = reader.ReadUInt32(); + float wMin = reader.ReadSingle(); + float wMax = reader.ReadSingle(); + + // Unknown value + reader.ReadUInt32(); + + // Store for sound read + long varPos = reader.BaseStream.Position; + + // Seek to the sound in the Bank + reader.BaseStream.Seek(varOffset, SeekOrigin.Begin); + + // Read the sound + cueSounds[j] = new XACTSound(reader); + + // Back to where we were... + reader.BaseStream.Seek(varPos, SeekOrigin.Begin); + + // Calculate probability based on weight + cueProbs[j, 0] = wMax; + cueProbs[j, 1] = wMin; + } + else if (varTableType == 4) + { + // Compact Wave + ushort track = reader.ReadUInt16(); + byte waveBank = reader.ReadByte(); + + // Create the Sound + cueSounds[j] = new XACTSound(track, waveBank); + + // FIXME: Assume Sound weight is 100% + cueProbs[j, 0] = 1.0f; + cueProbs[j, 1] = 0.0f; + } + else + { + throw new NotSupportedException(); + } + } + + // Back to where we were... + reader.BaseStream.Seek(curPos, SeekOrigin.Begin); + + // Add Built CueData to Dictionary + INTERNAL_cueData.Add( + cueNames[numCueSimple + i], + new CueData( + cueSounds, + cueProbs, + (varTableType == 3) ? INTERNAL_baseEngine.INTERNAL_getVariableName(variable) : String.Empty + ) + ); + } + + // Cue instance limit + byte instanceLimit = reader.ReadByte(); + + // Fade In/Out + ushort fadeIn = reader.ReadUInt16(); + ushort fadeOut = reader.ReadUInt16(); + + // Cue max instance behavior + byte behavior = reader.ReadByte(); + + INTERNAL_cueData[cueNames[numCueSimple + i]].SetLimit( + instanceLimit, + behavior, + fadeIn, + fadeOut + ); + } + } + IsDisposed = false; + } + + #endregion + + #region Destructor + + ~SoundBank() + { + Dispose(true); + } + + #endregion + + #region Public Dispose Method + + public void Dispose() + { + Dispose(false); + } + + #endregion + + #region Protected Dispose Method + + protected void Dispose(bool disposing) + { + if (!IsDisposed) + { + if (Disposing != null) + { + Disposing.Invoke(this, null); + } + INTERNAL_waveBankNames.Clear(); + INTERNAL_cueData.Clear(); + IsDisposed = true; + } + } + + #endregion + + #region Public Methods + + public Cue GetCue(string name) + { + if (String.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name"); + } + if (!INTERNAL_cueData.ContainsKey(name)) + { + throw new ArgumentException("Cue name not found: " + name); + } + return new Cue( + INTERNAL_baseEngine, + INTERNAL_waveBankNames, + name, + INTERNAL_cueData[name], + false + ); + } + + public void PlayCue(string name) + { + if (String.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name"); + } + if (!INTERNAL_cueData.ContainsKey(name)) + { + throw new InvalidOperationException("name not found!"); + } + Cue newCue = new Cue( + INTERNAL_baseEngine, + INTERNAL_waveBankNames, + name, + INTERNAL_cueData[name], + true + ); + newCue.Play(); + } + + public void PlayCue( + string name, + AudioListener listener, + AudioEmitter emitter + ) { + if (String.IsNullOrEmpty(name)) + { + throw new ArgumentNullException("name"); + } + if (!INTERNAL_cueData.ContainsKey(name)) + { + throw new InvalidOperationException("name not found!"); + } + Cue newCue = new Cue( + INTERNAL_baseEngine, + INTERNAL_waveBankNames, + name, + INTERNAL_cueData[name], + true + ); + newCue.Apply3D(listener, emitter); + newCue.Play(); + } + + #endregion + } +} diff --git a/FNA/src/Audio/SoundEffect.cs b/FNA/src/Audio/SoundEffect.cs new file mode 100644 index 0000000..18a5f5d --- /dev/null +++ b/FNA/src/Audio/SoundEffect.cs @@ -0,0 +1,404 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.IO; +using System.Collections.Generic; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.soundeffect.aspx + public sealed class SoundEffect : IDisposable + { + #region Public Properties + + public TimeSpan Duration + { + get + { + return INTERNAL_buffer.Duration; + } + } + + public bool IsDisposed + { + get; + private set; + } + + public string Name + { + get; + set; + } + + #endregion + + #region Public Static Properties + + public static float MasterVolume + { + get + { + return AudioDevice.MasterVolume; + } + set + { + AudioDevice.MasterVolume = value; + } + } + + public static float DistanceScale + { + get + { + return AudioDevice.DistanceScale; + } + set + { + if (value <= 0.0f) + { + throw new ArgumentOutOfRangeException("value <= 0.0f"); + } + AudioDevice.DistanceScale = value; + } + } + + public static float DopplerScale + { + get + { + return AudioDevice.DopplerScale; + } + set + { + if (value <= 0.0f) + { + throw new ArgumentOutOfRangeException("value <= 0.0f"); + } + AudioDevice.DopplerScale = value; + } + } + + public static float SpeedOfSound + { + get + { + return AudioDevice.SpeedOfSound; + } + set + { + AudioDevice.SpeedOfSound = value; + } + } + + #endregion + + #region Internal Variables + + internal List Instances = new List(); + internal IALBuffer INTERNAL_buffer; + internal IALBuffer INTERNAL_monoBuffer; + + #endregion + + #region Public Constructors + + public SoundEffect( + byte[] buffer, + int sampleRate, + AudioChannels channels + ) { + INTERNAL_buffer = AudioDevice.GenBuffer( + buffer, + (uint) sampleRate, + (uint) channels, + 0, + 0, + false, + 1 + ); + } + + public SoundEffect( + byte[] buffer, + int offset, + int count, + int sampleRate, + AudioChannels channels, + int loopStart, + int loopLength + ) { + byte[] sendBuf; + if (offset != 0 || count != buffer.Length) + { + // I kind of hate this. -flibit + sendBuf = new byte[count]; + Array.Copy(buffer, offset, sendBuf, 0, count); + } + else + { + sendBuf = buffer; + } + + INTERNAL_buffer = AudioDevice.GenBuffer( + sendBuf, + (uint) sampleRate, + (uint) channels, + (uint) loopStart, + (uint) (loopStart + loopLength), + false, + 1 + ); + } + + #endregion + + #region Internal Constructors + + internal SoundEffect(Stream s) + { + INTERNAL_loadAudioStream(s); + } + + internal SoundEffect( + string name, + byte[] buffer, + uint sampleRate, + uint channels, + uint loopStart, + uint loopLength, + bool isADPCM, + uint formatParameter + ) { + Name = name; + INTERNAL_buffer = AudioDevice.GenBuffer( + buffer, + sampleRate, + channels, + loopStart, + loopStart + loopLength, + isADPCM, + formatParameter + ); + } + + #endregion + + #region Destructor + + ~SoundEffect() + { + Dispose(); + } + + #endregion + + #region Public Dispose Method + + public void Dispose() + { + if (!IsDisposed) + { + /* FIXME: Is it ironic that we're generating + * garbage with ToArray while cleaning up after + * the program's leaks? + * -flibit + */ + foreach (WeakReference instance in Instances.ToArray()) + { + object target = instance.Target; + if (target != null) + { + (target as IDisposable).Dispose(); + } + } + Instances.Clear(); + if (INTERNAL_buffer != null) + { + AudioDevice.ALDevice.DeleteBuffer(INTERNAL_buffer); + } + if (INTERNAL_monoBuffer != null) + { + AudioDevice.ALDevice.DeleteBuffer(INTERNAL_monoBuffer); + } + IsDisposed = true; + } + } + + #endregion + + #region Additional SoundEffect/SoundEffectInstance Creation Methods + + public SoundEffectInstance CreateInstance() + { + return new SoundEffectInstance(this); + } + + public static SoundEffect FromStream(Stream stream) + { + return new SoundEffect(stream); + } + + #endregion + + #region Public Play Methods + + public bool Play() + { + return Play(1.0f, 0.0f, 0.0f); + } + + public bool Play(float volume, float pitch, float pan) + { + SoundEffectInstance instance = CreateInstance(); + instance.Volume = volume; + instance.Pitch = pitch; + instance.Pan = pan; + instance.Play(); + if (instance.State != SoundState.Playing) + { + // Ran out of AL sources, probably. + instance.Dispose(); + return false; + } + AudioDevice.InstancePool.Add(instance); + return true; + } + + #endregion + + #region Private WAV Loading Method + + private void INTERNAL_loadAudioStream(Stream s) + { + byte[] data; + uint sampleRate = 0; + uint numChannels = 0; + bool isADPCM = false; + uint formatParameter = 0; + + using (BinaryReader reader = new BinaryReader(s)) + { + // RIFF Signature + string signature = new string(reader.ReadChars(4)); + if (signature != "RIFF") + { + throw new NotSupportedException("Specified stream is not a wave file."); + } + + reader.ReadUInt32(); // Riff Chunk Size + + string wformat = new string(reader.ReadChars(4)); + if (wformat != "WAVE") + { + throw new NotSupportedException("Specified stream is not a wave file."); + } + + // WAVE Header + string format_signature = new string(reader.ReadChars(4)); + while (format_signature != "fmt ") + { + reader.ReadBytes(reader.ReadInt32()); + format_signature = new string(reader.ReadChars(4)); + } + + int format_chunk_size = reader.ReadInt32(); + + // Header Information + uint audio_format = reader.ReadUInt16(); // 2 + numChannels = reader.ReadUInt16(); // 4 + sampleRate = reader.ReadUInt32(); // 8 + reader.ReadUInt32(); // 12, Byte Rate + ushort blockAlign = reader.ReadUInt16(); // 14, Block Align + ushort bitDepth = reader.ReadUInt16(); // 16, Bits Per Sample + + if (audio_format == 1) + { + System.Diagnostics.Debug.Assert(bitDepth == 8 || bitDepth == 16); + formatParameter = (uint) (bitDepth / 16); // 1 for 16, 0 for 8 + } + else if (audio_format == 2) + { + isADPCM = true; + formatParameter = (((blockAlign / numChannels) - 6) * 2); + } + else + { + throw new NotSupportedException("Wave format is not supported."); + } + + // Reads residual bytes + if (format_chunk_size > 16) + { + reader.ReadBytes(format_chunk_size - 16); + } + + // data Signature + string data_signature = new string(reader.ReadChars(4)); + while (data_signature.ToLowerInvariant() != "data") + { + reader.ReadBytes(reader.ReadInt32()); + data_signature = new string(reader.ReadChars(4)); + } + if (data_signature != "data") + { + throw new NotSupportedException("Specified wave file is not supported."); + } + + int waveDataLength = reader.ReadInt32(); + data = reader.ReadBytes(waveDataLength); + } + + INTERNAL_buffer = AudioDevice.GenBuffer( + data, + sampleRate, + numChannels, + 0, + 0, + isADPCM, + formatParameter + ); + } + + #endregion + + #region Public Static Methods + + public static TimeSpan GetSampleDuration( + int sizeInBytes, + int sampleRate, + AudioChannels channels + ) { + sizeInBytes /= 2; // 16-bit PCM! + int ms = (int) ( + (sizeInBytes / (int) channels) / + (sampleRate / 1000.0f) + ); + return new TimeSpan(0, 0, 0, 0, ms); + } + + public static int GetSampleSizeInBytes( + TimeSpan duration, + int sampleRate, + AudioChannels channels + ) { + return (int) ( + duration.TotalSeconds * + sampleRate * + (int) channels * + 2 // 16-bit PCM! + ); + } + + #endregion + } +} diff --git a/FNA/src/Audio/SoundEffectInstance.cs b/FNA/src/Audio/SoundEffectInstance.cs new file mode 100644 index 0000000..180e5c0 --- /dev/null +++ b/FNA/src/Audio/SoundEffectInstance.cs @@ -0,0 +1,431 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.soundeffectinstance.aspx + public class SoundEffectInstance : IDisposable + { + #region Public Properties + + public bool IsDisposed + { + get; + protected set; + } + + private bool INTERNAL_looped = false; + public virtual bool IsLooped + { + get + { + return INTERNAL_looped; + } + set + { + INTERNAL_looped = value; + if (INTERNAL_alSource != null) + { + AudioDevice.ALDevice.SetSourceLooped( + INTERNAL_alSource, + value + ); + } + } + } + + private float INTERNAL_pan = 0.0f; + public float Pan + { + get + { + return INTERNAL_pan; + } + set + { + INTERNAL_pan = value; + if (INTERNAL_alSource != null) + { + AudioDevice.ALDevice.SetSourcePan( + INTERNAL_alSource, + value + ); + } + } + } + + private float INTERNAL_pitch = 0f; + public float Pitch + { + get + { + return INTERNAL_pitch; + } + set + { + if (INTERNAL_isXACTSource) + { + value = MathHelper.Clamp(value, -2.0f, 2.0f); + } + else + { + value = MathHelper.Clamp(value, -1.0f, 1.0f); + } + INTERNAL_pitch = value; + if (INTERNAL_alSource != null) + { + AudioDevice.ALDevice.SetSourcePitch( + INTERNAL_alSource, + value, + !INTERNAL_isXACTSource + ); + } + } + } + + public SoundState State + { + get + { + if (INTERNAL_alSource == null) + { + return SoundState.Stopped; + } + SoundState result = AudioDevice.ALDevice.GetSourceState( + INTERNAL_alSource + ); + if (result == SoundState.Stopped && isDynamic) + { + // Force playing at all times for DSFI! + return SoundState.Playing; + } + return result; + } + } + + private float INTERNAL_volume = 1.0f; + public float Volume + { + get + { + return INTERNAL_volume; + } + set + { + if (!INTERNAL_isXACTSource) + { + value = MathHelper.Clamp(value, 0.0f, 1.0f); + } + INTERNAL_volume = value; + if (INTERNAL_alSource != null) + { + AudioDevice.ALDevice.SetSourceVolume( + INTERNAL_alSource, + value + ); + } + } + } + + #endregion + + #region Internal Variables: 3D Audio + + internal bool INTERNAL_positionalAudio = false; + internal Vector3 position = new Vector3(0.0f, 0.0f, 0.1f); + + #endregion + + #region Internal Variables: XACT Filters + + internal byte FilterType; + + #endregion + + #region Private Variables: XNA Implementation + + private SoundEffect INTERNAL_parentEffect; + private WeakReference selfReference; + + internal bool isDynamic; + + /* FNA' XACT runtime wraps around SoundEffect for audio output. + * Only problem: XACT pitch has no boundaries, SoundEffect does. + * So, we're going to use this to tell the pitch clamp to STFU. + * -flibit + */ + internal bool INTERNAL_isXACTSource = false; + + #endregion + + #region Private Variables: AL Source, EffectSlot + + internal IALSource INTERNAL_alSource; + private IALReverb INTERNAL_alReverb; + + #endregion + + #region Internal Constructor + + internal SoundEffectInstance(SoundEffect parent) + { + INTERNAL_parentEffect = parent; + if (INTERNAL_parentEffect != null) + { + selfReference = new WeakReference(this); + INTERNAL_parentEffect.Instances.Add(selfReference); + } + isDynamic = false; + } + + #endregion + + #region Destructor + + ~SoundEffectInstance() + { + Dispose(); + } + + #endregion + + #region Public Dispose Method + + public virtual void Dispose() + { + if (!IsDisposed) + { + Stop(true); + if (INTERNAL_parentEffect != null) + { + INTERNAL_parentEffect.Instances.Remove(selfReference); + selfReference = null; + } + IsDisposed = true; + } + } + + #endregion + + #region Public 3D Audio Methods + + public void Apply3D(AudioListener listener, AudioEmitter emitter) + { + // We positional now + if (!INTERNAL_positionalAudio) + { + // Do we need to convert a stereo buffer to mono? + if ( !isDynamic && + INTERNAL_parentEffect.INTERNAL_buffer.Channels == 2 && + INTERNAL_parentEffect.INTERNAL_monoBuffer == null ) + { + INTERNAL_parentEffect.INTERNAL_monoBuffer = AudioDevice.ALDevice.ConvertStereoToMono( + INTERNAL_parentEffect.INTERNAL_buffer + ); + } + + // K, we really positional now + INTERNAL_positionalAudio = true; + } + + // Set up our final position according to orientation of listener + position = Vector3.Transform( + emitter.Position - listener.Position, + Matrix.CreateWorld(Vector3.Zero, listener.Forward, listener.Up) + ); + + // XACT doesn't do automated attenuation! + if (INTERNAL_isXACTSource && position != Vector3.Zero) + { + position.Normalize(); + } + + // This can get called before Play()... + if (INTERNAL_alSource != null) + { + // Finally. + AudioDevice.ALDevice.SetSourcePosition( + INTERNAL_alSource, + position + ); + } + } + + public void Apply3D(AudioListener[] listeners, AudioEmitter emitter) + { + if (listeners == null) + { + throw new ArgumentNullException("listeners"); + } + if (listeners.Length == 1) + { + Apply3D(listeners[0], emitter); + return; + } + throw new NotSupportedException("Only one listener is supported."); + } + + #endregion + + #region Public Playback Methods + + public virtual void Play() + { + if (State != SoundState.Stopped) + { + return; + } + + if (INTERNAL_alSource != null) + { + // The sound has stopped, but hasn't cleaned up yet... + AudioDevice.ALDevice.StopAndDisposeSource(INTERNAL_alSource); + INTERNAL_alSource = null; + } + + IALBuffer srcBuf; + if (INTERNAL_positionalAudio && INTERNAL_parentEffect.INTERNAL_monoBuffer != null) + { + srcBuf = INTERNAL_parentEffect.INTERNAL_monoBuffer; + } + else + { + srcBuf = INTERNAL_parentEffect.INTERNAL_buffer; + } + INTERNAL_alSource = AudioDevice.ALDevice.GenSource( + srcBuf, + INTERNAL_isXACTSource + ); + if (INTERNAL_alSource == null) + { + FNALoggerEXT.LogWarn("AL SOURCE WAS NOT AVAILABLE, SKIPPING."); + return; + } + + // Apply Pan/Position + if (INTERNAL_positionalAudio) + { + AudioDevice.ALDevice.SetSourcePosition( + INTERNAL_alSource, + position + ); + } + else + { + Pan = Pan; + } + + // Reassign Properties, in case the AL properties need to be applied. + Volume = Volume; + IsLooped = IsLooped; + Pitch = Pitch; + + // Apply EFX + if (INTERNAL_alReverb != null) + { + AudioDevice.ALDevice.SetSourceReverb( + INTERNAL_alSource, + INTERNAL_alReverb + ); + } + + AudioDevice.ALDevice.PlaySource(INTERNAL_alSource); + } + + public void Pause() + { + if (INTERNAL_alSource != null && State == SoundState.Playing) + { + AudioDevice.ALDevice.PauseSource(INTERNAL_alSource); + } + } + + public void Resume() + { + if (INTERNAL_alSource == null) + { + // XNA4 just plays if we've not started yet. + Play(); + } + else if (State == SoundState.Paused) + { + AudioDevice.ALDevice.ResumeSource(INTERNAL_alSource); + } + } + + public void Stop() + { + if (INTERNAL_alSource != null) + { + // TODO: GraphicsResource-like reference management -flibit + if (AudioDevice.ALDevice != null) + { + AudioDevice.ALDevice.StopAndDisposeSource(INTERNAL_alSource); + DynamicSoundEffectInstance dsfi = this as DynamicSoundEffectInstance; + if (dsfi != null && AudioDevice.DynamicInstancePool.Contains(dsfi)) + { + AudioDevice.DynamicInstancePool.Remove(dsfi); + } + } + INTERNAL_alSource = null; + } + } + + public void Stop(bool immediate) + { + Stop(); + } + + #endregion + + #region Internal Effects Methods + + internal void INTERNAL_applyReverb(IALReverb reverb) + { + INTERNAL_alReverb = reverb; + if (INTERNAL_alSource != null) + { + AudioDevice.ALDevice.SetSourceReverb( + INTERNAL_alSource, + INTERNAL_alReverb + ); + } + } + + internal void INTERNAL_applyLowPassFilter(float hfGain) + { + if (INTERNAL_alSource != null) + { + AudioDevice.ALDevice.SetSourceLowPassFilter(INTERNAL_alSource, hfGain); + } + } + + internal void INTERNAL_applyHighPassFilter(float lfGain) + { + if (INTERNAL_alSource != null) + { + AudioDevice.ALDevice.SetSourceHighPassFilter(INTERNAL_alSource, lfGain); + } + } + + internal void INTERNAL_applyBandPassFilter(float hfGain, float lfGain) + { + if (INTERNAL_alSource != null) + { + AudioDevice.ALDevice.SetSourceBandPassFilter(INTERNAL_alSource, hfGain, lfGain); + } + } + + #endregion + } +} diff --git a/FNA/src/Audio/SoundState.cs b/FNA/src/Audio/SoundState.cs new file mode 100644 index 0000000..f1410a8 --- /dev/null +++ b/FNA/src/Audio/SoundState.cs @@ -0,0 +1,19 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.soundstate.aspx + public enum SoundState + { + Playing, + Paused, + Stopped + } +} diff --git a/FNA/src/Audio/WaveBank.cs b/FNA/src/Audio/WaveBank.cs new file mode 100644 index 0000000..0167d76 --- /dev/null +++ b/FNA/src/Audio/WaveBank.cs @@ -0,0 +1,553 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* The unxwb project, written by Luigi Auriemma, was released in 2006 under the + * GNU General Public License, version 2.0: + * + * http://www.gnu.org/licenses/gpl-2.0.html + * + * While the unxwb project was released under the GPL, Luigi has given express + * permission to the MonoGame project to use code from unxwb under the MonoGame + * project license. See LICENSE for details. + * + * The unxwb website can be found here: + * + * http://aluigi.altervista.org/papers.htm#xbox + */ +#endregion + +#region Using Statements +using System; +using System.IO; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + // http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.wavebank.aspx + public class WaveBank : IDisposable + { + #region Private Sound Entry Container Class + + // Used to store sound entry data, mainly for streaming WaveBanks + private class SoundStreamEntry + { + public uint PlayOffset + { + get; + private set; + } + + public uint PlayLength + { + get; + private set; + } + + public uint Codec + { + get; + private set; + } + + public uint Frequency + { + get; + private set; + } + + public uint Channels + { + get; + private set; + } + + public uint LoopOffset + { + get; + private set; + } + + public uint LoopLength + { + get; + private set; + } + + public uint Alignment + { + get; + private set; + } + + public uint BitDepth + { + get; + private set; + } + + private int referenceCount; + + public SoundStreamEntry( + uint playOffset, + uint playLength, + uint codec, + uint frequency, + uint channels, + uint loopOffset, + uint loopLength, + uint alignment, + uint bitDepth + ) { + PlayOffset = playOffset; + PlayLength = playLength; + Codec = codec; + Frequency = frequency; + Channels = channels; + LoopOffset = loopOffset; + LoopLength = loopLength; + Alignment = alignment; + BitDepth = bitDepth; + + referenceCount = 0; + } + + public bool AddReference() + { + // Specifically 1. 2+ means it's already allocated + return (++referenceCount == 1); + } + + public bool SubReference() + { + return (--referenceCount == 0); + } + } + + #endregion + + #region Public Properties + + public bool IsDisposed + { + get; + private set; + } + + public bool IsPrepared + { + get; + private set; + } + + public bool IsInUse + { + get + { + throw new NotImplementedException("Cue wave entry dependency tracking!"); + } + } + + #endregion + + #region Private Variables + + // We keep this in order to Dispose ourselves later. + private AudioEngine INTERNAL_baseEngine; + private string INTERNAL_name; + + // These are only used for streaming WaveBanks + private BinaryReader INTERNAL_waveBankReader; + private SoundStreamEntry[] INTERNAL_soundStreamEntries; + + // Stores the actual wavedata + private SoundEffect[] INTERNAL_sounds; + + #endregion + + #region Disposing Event + + public event EventHandler Disposing; + + #endregion + + #region Public Constructors + + public WaveBank( + AudioEngine audioEngine, + string nonStreamingWaveBankFilename + ) { + if (audioEngine == null) + { + throw new ArgumentNullException("audioEngine"); + } + if (String.IsNullOrEmpty(nonStreamingWaveBankFilename)) + { + throw new ArgumentNullException("nonStreamingWaveBankFilename"); + } + + using (Stream stream = TitleContainer.OpenStream(nonStreamingWaveBankFilename)) + using (BinaryReader reader = new BinaryReader(stream)) + { + LoadWaveBank(audioEngine, reader, false); + } + } + + public WaveBank( + AudioEngine audioEngine, + string streamingWaveBankFilename, + int offset, + short packetsize + ) { + /* Note that offset and packetsize go unused, + * because we're frauds and aren't actually streaming. + * -flibit + */ + + if (audioEngine == null) + { + throw new ArgumentNullException("audioEngine"); + } + if (String.IsNullOrEmpty(streamingWaveBankFilename)) + { + throw new ArgumentNullException("streamingWaveBankFilename"); + } + + INTERNAL_waveBankReader = new BinaryReader( + TitleContainer.OpenStream(streamingWaveBankFilename) + ); + LoadWaveBank(audioEngine, INTERNAL_waveBankReader, true); + } + + #endregion + + #region Destructor + + ~WaveBank() + { + Dispose(true); + } + + #endregion + + #region Public Dispose Method + + public void Dispose() + { + Dispose(false); + } + + #endregion + + #region Protected Dispose Method + + protected virtual void Dispose(bool disposing) + { + if (!IsDisposed) + { + if (Disposing != null) + { + Disposing.Invoke(this, null); + } + foreach (SoundEffect se in INTERNAL_sounds) + { + if (se != null) + { + se.Dispose(); + } + } + INTERNAL_baseEngine.INTERNAL_removeWaveBank(INTERNAL_name); + INTERNAL_sounds = null; + if (INTERNAL_waveBankReader != null) + { + INTERNAL_waveBankReader.Close(); + INTERNAL_waveBankReader = null; + } + IsDisposed = true; + IsPrepared = false; + } + } + + #endregion + + #region Internal Methods + + internal SoundEffect INTERNAL_getTrack(ushort track) + { + if (INTERNAL_soundStreamEntries != null && INTERNAL_soundStreamEntries[track].AddReference()) + { + LoadWaveEntry( + INTERNAL_soundStreamEntries[track], + track, + INTERNAL_waveBankReader + ); + } + return INTERNAL_sounds[track]; + } + + internal void INTERNAL_dropTrack(ushort track) + { + if (INTERNAL_soundStreamEntries != null && INTERNAL_soundStreamEntries[track].SubReference()) + { + INTERNAL_sounds[track].Dispose(); + INTERNAL_sounds[track] = null; + } + } + + #endregion + + #region Private WaveBank Load Method + + private void LoadWaveBank(AudioEngine audioEngine, BinaryReader reader, bool streaming) + { + /* Until we finish the LoadWaveBank process, this WaveBank is NOT + * ready to run. For us this doesn't really matter, but the game + * could be loading WaveBanks asynchronously, so let's be careful. + * -flibit + */ + IsPrepared = false; + + INTERNAL_baseEngine = audioEngine; + + // Check the file header. Should be 'WBND' + if (reader.ReadUInt32() != 0x444E4257) + { + throw new ArgumentException("WBND format not recognized!"); + } + + // Check the content version. Assuming XNA4 Refresh. + if (reader.ReadUInt32() != AudioEngine.ContentVersion) + { + throw new ArgumentException("WBND Content version!"); + } + + // Check the tool version. Assuming XNA4 Refresh. + if (reader.ReadUInt32() != 44) + { + throw new ArgumentException("WBND Tool version!"); + } + + // Obtain WaveBank chunk offsets/lengths + uint[] offsets = new uint[5]; + uint[] lengths = new uint[5]; + for (int i = 0; i < 5; i += 1) + { + offsets[i] = reader.ReadUInt32(); + lengths[i] = reader.ReadUInt32(); + } + + // Seek to the first offset, obtain WaveBank info + reader.BaseStream.Seek(offsets[0], SeekOrigin.Begin); + + // IsStreaming bool, unused + reader.ReadUInt16(); + + // WaveBank Flags + ushort wavebankFlags = reader.ReadUInt16(); + // bool containsEntryNames = (wavebankFlags & 0x0001) != 0; + bool compact = (wavebankFlags & 0x0002) != 0; + // bool syncDisabled = (wavebankFlags & 0x0004) != 0; + // bool containsSeekTables = (wavebankFlags & 0x0008) != 0; + + // WaveBank Entry Count + uint numEntries = reader.ReadUInt32(); + + // WaveBank Name + INTERNAL_name = System.Text.Encoding.UTF8.GetString( + reader.ReadBytes(64), 0, 64 + ).Replace("\0", ""); + + // WaveBank entry information + uint metadataElementSize = reader.ReadUInt32(); + reader.ReadUInt32(); // nameElementSize + uint alignment = reader.ReadUInt32(); + + // Determine the generic play region offset + uint playRegionOffset = offsets[4]; + if (playRegionOffset == 0) + { + playRegionOffset = offsets[1] + (numEntries * metadataElementSize); + } + + // Entry format. Read early for Compact data + uint entryFormat = 0; + if (compact) + { + entryFormat = reader.ReadUInt32(); + } + + // Read in the wavedata + INTERNAL_sounds = new SoundEffect[numEntries]; + if (streaming) + { + INTERNAL_soundStreamEntries = new SoundStreamEntry[numEntries]; + } + uint curOffset = offsets[1]; + for (int curEntry = 0; curEntry < numEntries; curEntry += 1) + { + // Seek to the current entry + reader.BaseStream.Seek(curOffset, SeekOrigin.Begin); + + // Entry Information + uint entryPlayOffset = 0; + uint entryPlayLength = 0; + uint entryLoopOffset = 0; + uint entryLoopLength = 0; + + // Obtain Entry Information + if (compact) + { + uint entryLength = reader.ReadUInt32(); + + entryPlayOffset = + (entryLength & ((1 << 21) - 1)) * + alignment; + entryPlayLength = + (entryLength >> 21) & ((1 << 11) - 1); + + // FIXME: Deviation Length + reader.BaseStream.Seek( + curOffset + metadataElementSize, + SeekOrigin.Begin + ); + + if (curEntry == (numEntries - 1)) + { + // Last track, last length. + entryLength = lengths[4]; + } + else + { + entryLength = ( + ( + reader.ReadUInt32() & + ((1 << 21) - 1) + ) * alignment + ); + } + entryPlayLength = entryLength - entryPlayOffset; + } + else + { + if (metadataElementSize >= 4) + reader.ReadUInt32(); // Flags/Duration, unused + if (metadataElementSize >= 8) + entryFormat = reader.ReadUInt32(); + if (metadataElementSize >= 12) + entryPlayOffset = reader.ReadUInt32(); + if (metadataElementSize >= 16) + entryPlayLength = reader.ReadUInt32(); + if (metadataElementSize >= 20) + entryLoopOffset = reader.ReadUInt32(); + if (metadataElementSize >= 24) + entryLoopLength = reader.ReadUInt32(); + else + { + // FIXME: This is a bit hacky. + if (entryPlayLength != 0) + { + entryPlayLength = lengths[4]; + } + } + } + + // Update seek offsets + curOffset += metadataElementSize; + entryPlayOffset += playRegionOffset; + + // Parse Format for Wavedata information + uint entryCodec = (entryFormat >> 0) & ((1 << 2) - 1); + uint entryChannels = (entryFormat >> 2) & ((1 << 3) - 1); + uint entryFrequency = (entryFormat >> (2 + 3)) & ((1 << 18) - 1); + uint entryAlignment = (entryFormat >> (2 + 3 + 18)) & ((1 << 8) - 1); + uint entryBitDepth = (entryFormat >> (2 + 3 + 18 + 8)); + + if (streaming) + { + INTERNAL_soundStreamEntries[curEntry] = new SoundStreamEntry( + entryPlayOffset, + entryPlayLength, + entryCodec, + entryFrequency, + entryChannels, + entryLoopOffset, + entryLoopLength, + entryAlignment, + entryBitDepth + ); + } + else + { + SoundStreamEntry filler = new SoundStreamEntry( + entryPlayOffset, + entryPlayLength, + entryCodec, + entryFrequency, + entryChannels, + entryLoopOffset, + entryLoopLength, + entryAlignment, + entryBitDepth + ); + LoadWaveEntry(filler, (ushort) curEntry, reader); + } + } + + // Add this WaveBank to the AudioEngine Dictionary + audioEngine.INTERNAL_addWaveBank(INTERNAL_name, this); + + // Finally. + IsDisposed = false; + IsPrepared = true; + } + + #endregion + + #region Private WaveBank Entry Load Method + + private void LoadWaveEntry(SoundStreamEntry entry, ushort track, BinaryReader reader) + { + // Read Wavedata + reader.BaseStream.Seek(entry.PlayOffset, SeekOrigin.Begin); + byte[] entryData = reader.ReadBytes((int) entry.PlayLength); + + // Load SoundEffect based on codec + if (entry.Codec == 0x0) // PCM + { + INTERNAL_sounds[track] = new SoundEffect( + "WaveBank Sound", + entryData, + entry.Frequency, + entry.Channels, + entry.LoopOffset, + entry.LoopLength, + false, + entry.BitDepth + ); + } + else if (entry.Codec == 0x2) // ADPCM + { + INTERNAL_sounds[track] = new SoundEffect( + "WaveBank Sound", + entryData, + entry.Frequency, + entry.Channels, + entry.LoopOffset, + entry.LoopLength, + true, + (entry.Alignment + 16) * 2 + ); + } + else // Includes 0x1 - XMA, 0x3 - WMA + { + throw new NotSupportedException("Rebuild your WaveBanks with ADPCM!"); + } + } + + #endregion + } +} diff --git a/FNA/src/Audio/XACTInternal.cs b/FNA/src/Audio/XACTInternal.cs new file mode 100644 index 0000000..ab2c26d --- /dev/null +++ b/FNA/src/Audio/XACTInternal.cs @@ -0,0 +1,455 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +#endregion + +namespace Microsoft.Xna.Framework.Audio +{ + internal static class XACTCalculator + { + public static double ParseDecibel(byte binaryValue) + { + /* FIXME: This magnificent beauty came from Mathematica! + * The byte values for all possible input dB values from the .xap are here: + * http://www.flibitijibibo.com/XACTVolume.txt + * Yes, this is actually what the XACT builder really does. + * + * Thanks to Kenny for plotting all that data. + * -flibit + */ + return ( + (3969.0 * Math.Log10(binaryValue / 28240.0)) + 8715.0 + ); + } + + // Note: This takes 'decibels * 100' as input! + public static float CalculateAmplitudeRatio(double decibel) + { + return (float) Math.Pow(10, decibel / 2000.0); + } + + // Interestingly, Reverb gains are stored as floats without the x100! + public static float CalculateReverbAmplitudeRatio(float decibel) + { + return (float) Math.Pow(10, decibel / 20.0f); + } + } + + internal enum MaxInstanceBehavior : byte + { + Fail, + Queue, + ReplaceOldest, + ReplaceQuietest, + ReplaceLowestPriority + } + + internal enum CrossfadeType : byte + { + Linear, + Logarithmic, + EqualPower + } + + internal class Variable + { + public string Name + { + get; + private set; + } + + // Variable Accessibility + public bool IsPublic + { + get; + private set; + } + + public bool IsReadOnly + { + get; + private set; + } + + public bool IsGlobal + { + get; + private set; + } + + public bool IsReserved + { + get; + private set; + } + + // Variable Value, Boundaries + private float value; + private float minValue; + private float maxValue; + + public Variable( + string name, + bool varIsPublic, + bool varIsReadOnly, + bool varIsGlobal, + bool varIsReserved, + float varInitialValue, + float varMinValue, + float varMaxValue + ) { + Name = name; + IsPublic = varIsPublic; + IsReadOnly = varIsReadOnly; + IsGlobal = varIsGlobal; + IsReserved = varIsReserved; + value = varInitialValue; + minValue = varMinValue; + maxValue = varMaxValue; + } + + public void SetValue(float newValue) + { + if (newValue < minValue) + { + value = minValue; + } + else if (newValue > maxValue) + { + value = maxValue; + } + else + { + value = newValue; + } + } + + public float GetValue() + { + return value; + } + + public Variable Clone() + { + return new Variable( + Name, + IsPublic, + IsReadOnly, + IsGlobal, + IsReserved, + value, + minValue, + maxValue + ); + } + } + + internal enum RPCPointType : byte + { + Linear, + Fast, + Slow, + SinCos + } + + internal enum RPCParameter : ushort + { + Volume, + Pitch, + ReverbSend, + FilterFrequency, + FilterQFactor, + NUM_PARAMETERS // If >=, DSP Parameter! + } + + internal class RPCPoint + { + public float X + { + get; + private set; + } + + public float Y + { + get; + private set; + } + + public RPCPointType Type + { + get; + private set; + } + + public RPCPoint(float x, float y, RPCPointType type) + { + X = x; + Y = y; + Type = type; + } + } + + internal class RPC + { + // Parent Variable + public string Variable + { + get; + private set; + } + + // RPC Parameter + public RPCParameter Parameter + { + get; + private set; + } + + // RPC Curve Points + private RPCPoint[] Points; + + public RPC( + string rpcVariable, + ushort rpcParameter, + RPCPoint[] rpcPoints + ) { + Variable = rpcVariable; + Parameter = (RPCParameter) rpcParameter; + Points = rpcPoints; + } + + public RPCPoint LastPoint { get { return Points[Points.Length - 1]; } } + + public float CalculateRPC(float varInput) + { + // Min/Max + if (varInput <= Points[0].X) + { + // Zero to first defined point + return Points[0].Y; + } + if (varInput >= Points[Points.Length - 1].X) + { + // Last defined point to infinity + return Points[Points.Length - 1].Y; + } + + // Something between points... TODO: Non-linear curves + float result = 0.0f; + for (int i = 0; i < Points.Length - 1; i += 1) + { + // y = b + result = Points[i].Y; + if (varInput >= Points[i].X && varInput <= Points[i + 1].X) + { + // y += mx + result += + ((Points[i + 1].Y - Points[i].Y) / + (Points[i + 1].X - Points[i].X)) * + (varInput - Points[i].X); + // Pre-algebra, rockin`! + break; + } + } + return result; + } + } + + internal class DSPParameter + { + public byte Type + { + get; + private set; + } + + public float Minimum + { + get; + private set; + } + + public float Maximum + { + get; + private set; + } + + private float INTERNAL_value; + public float Value + { + get + { + return INTERNAL_value; + } + set + { + if (value < Minimum) + { + INTERNAL_value = Minimum; + } + else if (value > Maximum) + { + INTERNAL_value = Maximum; + } + else + { + INTERNAL_value = value; + } + } + } + public DSPParameter(byte type, float val, float min, float max) + { + Type = type; + Minimum = min; + Maximum = max; + INTERNAL_value = val; + } + } + + internal class DSPPreset + { + public IALReverb Effect + { + get; + private set; + } + + public bool IsGlobal + { + get; + private set; + } + + public DSPParameter[] Parameters + { + get; + private set; + } + + public DSPPreset( + bool global, + DSPParameter[] parameters + ) { + IsGlobal = global; + Parameters = parameters; + + // FIXME: Did XACT ever go past Reverb? -flibit + Effect = AudioDevice.GenReverb(Parameters); + } + + public void Dispose() + { + AudioDevice.ALDevice.DeleteReverb(Effect); + } + + public void SetParameter(int index, float value) + { + Parameters[index].Value = value; + + // Apply the value to the effect + if (index == 0) + { + AudioDevice.ALDevice.SetReverbReflectionsDelay(Effect, Parameters[index].Value); + } + else if (index == 1) + { + AudioDevice.ALDevice.SetReverbDelay(Effect, Parameters[index].Value); + } + else if (index == 2) + { + AudioDevice.ALDevice.SetReverbPositionLeft(Effect, Parameters[index].Value); + } + else if (index == 3) + { + AudioDevice.ALDevice.SetReverbPositionRight(Effect, Parameters[index].Value); + } + else if (index == 4) + { + AudioDevice.ALDevice.SetReverbPositionLeftMatrix(Effect, Parameters[index].Value); + } + else if (index == 5) + { + AudioDevice.ALDevice.SetReverbPositionRightMatrix(Effect, Parameters[index].Value); + } + else if (index == 6) + { + AudioDevice.ALDevice.SetReverbEarlyDiffusion(Effect, Parameters[index].Value); + } + else if (index == 7) + { + AudioDevice.ALDevice.SetReverbLateDiffusion(Effect, Parameters[index].Value); + } + else if (index == 8) + { + AudioDevice.ALDevice.SetReverbLowEQGain(Effect, Parameters[index].Value); + } + else if (index == 9) + { + AudioDevice.ALDevice.SetReverbLowEQCutoff(Effect, Parameters[index].Value); + } + else if (index == 10) + { + AudioDevice.ALDevice.SetReverbHighEQGain(Effect, Parameters[index].Value); + } + else if (index == 11) + { + AudioDevice.ALDevice.SetReverbHighEQCutoff(Effect, Parameters[index].Value); + } + else if (index == 12) + { + AudioDevice.ALDevice.SetReverbRearDelay(Effect, Parameters[index].Value); + } + else if (index == 13) + { + AudioDevice.ALDevice.SetReverbRoomFilterFrequency(Effect, Parameters[index].Value); + } + else if (index == 14) + { + AudioDevice.ALDevice.SetReverbRoomFilterMain(Effect, Parameters[index].Value); + } + else if (index == 15) + { + AudioDevice.ALDevice.SetReverbRoomFilterHighFrequency(Effect, Parameters[index].Value); + } + else if (index == 16) + { + AudioDevice.ALDevice.SetReverbReflectionsGain(Effect, Parameters[index].Value); + } + else if (index == 17) + { + AudioDevice.ALDevice.SetReverbGain(Effect, Parameters[index].Value); + } + else if (index == 18) + { + AudioDevice.ALDevice.SetReverbDecayTime(Effect, Parameters[index].Value); + } + else if (index == 19) + { + AudioDevice.ALDevice.SetReverbDensity(Effect, Parameters[index].Value); + } + else if (index == 20) + { + AudioDevice.ALDevice.SetReverbRoomSize(Effect, Parameters[index].Value); + } + else if (index == 21) + { + AudioDevice.ALDevice.SetReverbWetDryMix(Effect, Parameters[index].Value); + } + else + { + throw new NotImplementedException("DSP parameter unhandled: " + index.ToString()); + } + } + } +} diff --git a/FNA/src/BoundingBox.cs b/FNA/src/BoundingBox.cs new file mode 100644 index 0000000..1851219 --- /dev/null +++ b/FNA/src/BoundingBox.cs @@ -0,0 +1,614 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; + +using Microsoft.Xna.Framework.Design; +#endregion + +namespace Microsoft.Xna.Framework +{ + [Serializable] + [TypeConverter(typeof(BoundingBoxConverter))] + [DebuggerDisplay("{DebugDisplayString,nq}")] + public struct BoundingBox : IEquatable + { + #region Internal Properties + + internal string DebugDisplayString + { + get + { + return string.Concat( + "Min( ", Min.DebugDisplayString, " ) \r\n", + "Max( ", Max.DebugDisplayString, " )" + ); + } + } + + #endregion + + #region Public Fields + + public Vector3 Min; + + public Vector3 Max; + + public const int CornerCount = 8; + + #endregion + + #region Private Static Variables + + private static readonly Vector3 MaxVector3 = new Vector3(float.MaxValue); + private static readonly Vector3 MinVector3 = new Vector3(float.MinValue); + + #endregion + + #region Public Constructors + + public BoundingBox(Vector3 min, Vector3 max) + { + this.Min = min; + this.Max = max; + } + + #endregion + + #region Public Methods + + public void Contains(ref BoundingBox box, out ContainmentType result) + { + result = Contains(box); + } + + public void Contains(ref BoundingSphere sphere, out ContainmentType result) + { + result = this.Contains(sphere); + } + + public ContainmentType Contains(Vector3 point) + { + ContainmentType result; + this.Contains(ref point, out result); + return result; + } + + public ContainmentType Contains(BoundingBox box) + { + // Test if all corner is in the same side of a face by just checking min and max + if ( box.Max.X < Min.X || + box.Min.X > Max.X || + box.Max.Y < Min.Y || + box.Min.Y > Max.Y || + box.Max.Z < Min.Z || + box.Min.Z > Max.Z ) + { + return ContainmentType.Disjoint; + } + + + if ( box.Min.X >= Min.X && + box.Max.X <= Max.X && + box.Min.Y >= Min.Y && + box.Max.Y <= Max.Y && + box.Min.Z >= Min.Z && + box.Max.Z <= Max.Z ) + { + return ContainmentType.Contains; + } + + return ContainmentType.Intersects; + } + + public ContainmentType Contains(BoundingFrustum frustum) + { + /* TODO: bad done here need a fix. + * Because the question is not if frustum contains box but the reverse and + * this is not the same. + */ + int i; + ContainmentType contained; + Vector3[] corners = frustum.GetCorners(); + + // First we check if frustum is in box. + for (i = 0; i < corners.Length; i += 1) + { + this.Contains(ref corners[i], out contained); + if (contained == ContainmentType.Disjoint) + { + break; + } + } + + // This means we checked all the corners and they were all contain or instersect + if (i == corners.Length) + { + return ContainmentType.Contains; + } + + // If i is not equal to zero, we can fastpath and say that this box intersects + if (i != 0) + { + return ContainmentType.Intersects; + } + + + /* If we get here, it means the first (and only) point we checked was + * actually contained in the frustum. So we assume that all other points + * will also be contained. If one of the points is disjoint, we can + * exit immediately saying that the result is Intersects + */ + i += 1; + for (; i < corners.Length; i += 1) + { + this.Contains(ref corners[i], out contained); + if (contained != ContainmentType.Contains) + { + return ContainmentType.Intersects; + } + + } + + /* If we get here, then we know all the points were actually contained, + * therefore result is Contains. + */ + return ContainmentType.Contains; + } + + public ContainmentType Contains(BoundingSphere sphere) + { + if ( sphere.Center.X - Min.X >= sphere.Radius && + sphere.Center.Y - Min.Y >= sphere.Radius && + sphere.Center.Z - Min.Z >= sphere.Radius && + Max.X - sphere.Center.X >= sphere.Radius && + Max.Y - sphere.Center.Y >= sphere.Radius && + Max.Z - sphere.Center.Z >= sphere.Radius ) + { + return ContainmentType.Contains; + } + + double dmin = 0; + + double e = sphere.Center.X - Min.X; + if (e < 0) + { + if (e < -sphere.Radius) + { + return ContainmentType.Disjoint; + } + dmin += e * e; + } + else + { + e = sphere.Center.X - Max.X; + if (e > 0) + { + if (e > sphere.Radius) + { + return ContainmentType.Disjoint; + } + dmin += e * e; + } + } + + e = sphere.Center.Y - Min.Y; + if (e < 0) + { + if (e < -sphere.Radius) + { + return ContainmentType.Disjoint; + } + dmin += e * e; + } + else + { + e = sphere.Center.Y - Max.Y; + if (e > 0) + { + if (e > sphere.Radius) + { + return ContainmentType.Disjoint; + } + dmin += e * e; + } + } + + e = sphere.Center.Z - Min.Z; + if (e < 0) + { + if (e < -sphere.Radius) + { + return ContainmentType.Disjoint; + } + dmin += e * e; + } + else + { + e = sphere.Center.Z - Max.Z; + if (e > 0) + { + if (e > sphere.Radius) + { + return ContainmentType.Disjoint; + } + dmin += e * e; + } + } + + if (dmin <= sphere.Radius * sphere.Radius) + { + return ContainmentType.Intersects; + } + + return ContainmentType.Disjoint; + } + + public void Contains(ref Vector3 point, out ContainmentType result) + { + // Determine if point is outside of this box. + if ( point.X < this.Min.X || + point.X > this.Max.X || + point.Y < this.Min.Y || + point.Y > this.Max.Y || + point.Z < this.Min.Z || + point.Z > this.Max.Z ) + { + result = ContainmentType.Disjoint; + } + else + { + result = ContainmentType.Contains; + } + } + + public Vector3[] GetCorners() + { + return new Vector3[] { + new Vector3(this.Min.X, this.Max.Y, this.Max.Z), + new Vector3(this.Max.X, this.Max.Y, this.Max.Z), + new Vector3(this.Max.X, this.Min.Y, this.Max.Z), + new Vector3(this.Min.X, this.Min.Y, this.Max.Z), + new Vector3(this.Min.X, this.Max.Y, this.Min.Z), + new Vector3(this.Max.X, this.Max.Y, this.Min.Z), + new Vector3(this.Max.X, this.Min.Y, this.Min.Z), + new Vector3(this.Min.X, this.Min.Y, this.Min.Z) + }; + } + + public void GetCorners(Vector3[] corners) + { + if (corners == null) + { + throw new ArgumentNullException("corners"); + } + if (corners.Length < 8) + { + throw new ArgumentOutOfRangeException("corners", "Not Enought Corners"); + } + corners[0].X = this.Min.X; + corners[0].Y = this.Max.Y; + corners[0].Z = this.Max.Z; + corners[1].X = this.Max.X; + corners[1].Y = this.Max.Y; + corners[1].Z = this.Max.Z; + corners[2].X = this.Max.X; + corners[2].Y = this.Min.Y; + corners[2].Z = this.Max.Z; + corners[3].X = this.Min.X; + corners[3].Y = this.Min.Y; + corners[3].Z = this.Max.Z; + corners[4].X = this.Min.X; + corners[4].Y = this.Max.Y; + corners[4].Z = this.Min.Z; + corners[5].X = this.Max.X; + corners[5].Y = this.Max.Y; + corners[5].Z = this.Min.Z; + corners[6].X = this.Max.X; + corners[6].Y = this.Min.Y; + corners[6].Z = this.Min.Z; + corners[7].X = this.Min.X; + corners[7].Y = this.Min.Y; + corners[7].Z = this.Min.Z; + } + + public Nullable Intersects(Ray ray) + { + return ray.Intersects(this); + } + + public void Intersects(ref Ray ray, out Nullable result) + { + result = Intersects(ray); + } + + public bool Intersects(BoundingFrustum frustum) + { + return frustum.Intersects(this); + } + + public void Intersects(ref BoundingSphere sphere, out bool result) + { + result = Intersects(sphere); + } + + public bool Intersects(BoundingBox box) + { + bool result; + Intersects(ref box, out result); + return result; + } + + public PlaneIntersectionType Intersects(Plane plane) + { + PlaneIntersectionType result; + Intersects(ref plane, out result); + return result; + } + + public void Intersects(ref BoundingBox box, out bool result) + { + if ((this.Max.X >= box.Min.X) && (this.Min.X <= box.Max.X)) + { + if ((this.Max.Y < box.Min.Y) || (this.Min.Y > box.Max.Y)) + { + result = false; + return; + } + + result = (this.Max.Z >= box.Min.Z) && (this.Min.Z <= box.Max.Z); + return; + } + + result = false; + return; + } + + public bool Intersects(BoundingSphere sphere) + { + if ( sphere.Center.X - Min.X > sphere.Radius && + sphere.Center.Y - Min.Y > sphere.Radius && + sphere.Center.Z - Min.Z > sphere.Radius && + Max.X - sphere.Center.X > sphere.Radius && + Max.Y - sphere.Center.Y > sphere.Radius && + Max.Z - sphere.Center.Z > sphere.Radius ) + { + return true; + } + + double dmin = 0; + + if (sphere.Center.X - Min.X <= sphere.Radius) + { + dmin += (sphere.Center.X - Min.X) * (sphere.Center.X - Min.X); + } + else if (Max.X - sphere.Center.X <= sphere.Radius) + { + dmin += (sphere.Center.X - Max.X) * (sphere.Center.X - Max.X); + } + + if (sphere.Center.Y - Min.Y <= sphere.Radius) + { + dmin += (sphere.Center.Y - Min.Y) * (sphere.Center.Y - Min.Y); + } + else if (Max.Y - sphere.Center.Y <= sphere.Radius) + { + dmin += (sphere.Center.Y - Max.Y) * (sphere.Center.Y - Max.Y); + } + + if (sphere.Center.Z - Min.Z <= sphere.Radius) + { + dmin += (sphere.Center.Z - Min.Z) * (sphere.Center.Z - Min.Z); + } + else if (Max.Z - sphere.Center.Z <= sphere.Radius) + { + dmin += (sphere.Center.Z - Max.Z) * (sphere.Center.Z - Max.Z); + } + + if (dmin <= sphere.Radius * sphere.Radius) + { + return true; + } + + return false; + } + + public void Intersects(ref Plane plane, out PlaneIntersectionType result) + { + // See http://zach.in.tu-clausthal.de/teaching/cg_literatur/lighthouse3d_view_frustum_culling/index.html + + Vector3 positiveVertex; + Vector3 negativeVertex; + + if (plane.Normal.X >= 0) + { + positiveVertex.X = Max.X; + negativeVertex.X = Min.X; + } + else + { + positiveVertex.X = Min.X; + negativeVertex.X = Max.X; + } + + if (plane.Normal.Y >= 0) + { + positiveVertex.Y = Max.Y; + negativeVertex.Y = Min.Y; + } + else + { + positiveVertex.Y = Min.Y; + negativeVertex.Y = Max.Y; + } + + if (plane.Normal.Z >= 0) + { + positiveVertex.Z = Max.Z; + negativeVertex.Z = Min.Z; + } + else + { + positiveVertex.Z = Min.Z; + negativeVertex.Z = Max.Z; + } + + // Inline Vector3.Dot(plane.Normal, negativeVertex) + plane.D; + float distance = ( + plane.Normal.X * negativeVertex.X + + plane.Normal.Y * negativeVertex.Y + + plane.Normal.Z * negativeVertex.Z + + plane.D + ); + if (distance > 0) + { + result = PlaneIntersectionType.Front; + return; + } + + // Inline Vector3.Dot(plane.Normal, positiveVertex) + plane.D; + distance = ( + plane.Normal.X * positiveVertex.X + + plane.Normal.Y * positiveVertex.Y + + plane.Normal.Z * positiveVertex.Z + + plane.D + ); + if (distance < 0) + { + result = PlaneIntersectionType.Back; + return; + } + + result = PlaneIntersectionType.Intersecting; + } + + public bool Equals(BoundingBox other) + { + return (this.Min == other.Min) && (this.Max == other.Max); + } + + #endregion + + #region Public Static Methods + + /// + /// Create a bounding box from the given list of points. + /// + /// + /// The list of Vector3 instances defining the point cloud to bound. + /// + /// A bounding box that encapsulates the given point cloud. + /// + /// Thrown if the given list has no points. + /// + public static BoundingBox CreateFromPoints(IEnumerable points) + { + if (points == null) + { + throw new ArgumentNullException("points"); + } + + bool empty = true; + Vector3 minVec = MaxVector3; + Vector3 maxVec = MinVector3; + foreach (Vector3 ptVector in points) + { + minVec.X = (minVec.X < ptVector.X) ? minVec.X : ptVector.X; + minVec.Y = (minVec.Y < ptVector.Y) ? minVec.Y : ptVector.Y; + minVec.Z = (minVec.Z < ptVector.Z) ? minVec.Z : ptVector.Z; + + maxVec.X = (maxVec.X > ptVector.X) ? maxVec.X : ptVector.X; + maxVec.Y = (maxVec.Y > ptVector.Y) ? maxVec.Y : ptVector.Y; + maxVec.Z = (maxVec.Z > ptVector.Z) ? maxVec.Z : ptVector.Z; + + empty = false; + } + if (empty) + { + throw new ArgumentException("Collection is empty", "points"); + } + + return new BoundingBox(minVec, maxVec); + } + + public static BoundingBox CreateFromSphere(BoundingSphere sphere) + { + BoundingBox result; + CreateFromSphere(ref sphere, out result); + return result; + } + + public static void CreateFromSphere(ref BoundingSphere sphere, out BoundingBox result) + { + Vector3 corner = new Vector3(sphere.Radius); + result.Min = sphere.Center - corner; + result.Max = sphere.Center + corner; + } + + public static BoundingBox CreateMerged(BoundingBox original, BoundingBox additional) + { + BoundingBox result; + CreateMerged(ref original, ref additional, out result); + return result; + } + + public static void CreateMerged(ref BoundingBox original, ref BoundingBox additional, out BoundingBox result) + { + result.Min.X = Math.Min(original.Min.X, additional.Min.X); + result.Min.Y = Math.Min(original.Min.Y, additional.Min.Y); + result.Min.Z = Math.Min(original.Min.Z, additional.Min.Z); + result.Max.X = Math.Max(original.Max.X, additional.Max.X); + result.Max.Y = Math.Max(original.Max.Y, additional.Max.Y); + result.Max.Z = Math.Max(original.Max.Z, additional.Max.Z); + } + + #endregion + + #region Public Static Operators and Override Methods + + public override bool Equals(object obj) + { + return (obj is BoundingBox) && Equals((BoundingBox) obj); + } + + public override int GetHashCode() + { + return this.Min.GetHashCode() + this.Max.GetHashCode(); + } + + public static bool operator ==(BoundingBox a, BoundingBox b) + { + return a.Equals(b); + } + + public static bool operator !=(BoundingBox a, BoundingBox b) + { + return !a.Equals(b); + } + + public override string ToString() + { + return ( + "{{Min:" + Min.ToString() + + " Max:" + Max.ToString() + + "}}" + ); + } + + #endregion + } +} diff --git a/FNA/src/BoundingFrustum.cs b/FNA/src/BoundingFrustum.cs new file mode 100644 index 0000000..a3cca6e --- /dev/null +++ b/FNA/src/BoundingFrustum.cs @@ -0,0 +1,727 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Diagnostics; +using System.Text; +#endregion + +namespace Microsoft.Xna.Framework +{ + /// + /// Defines a viewing frustum for intersection operations. + /// + [DebuggerDisplay("{DebugDisplayString,nq}")] + public class BoundingFrustum : IEquatable + { + #region Public Properties + + /// + /// Gets or sets the of the frustum. + /// + public Matrix Matrix + { + get + { + return this.matrix; + } + set + { + /* FIXME: The odds are the planes will be used a lot more often than + * the matrix is updated, so this should help performance. I hope. ;) + */ + this.matrix = value; + this.CreatePlanes(); + this.CreateCorners(); + } + } + + /// + /// Gets the near plane of the frustum. + /// + public Plane Near + { + get + { + return this.planes[0]; + } + } + + /// + /// Gets the far plane of the frustum. + /// + public Plane Far + { + get + { + return this.planes[1]; + } + } + + /// + /// Gets the left plane of the frustum. + /// + public Plane Left + { + get + { + return this.planes[2]; + } + } + + /// + /// Gets the right plane of the frustum. + /// + public Plane Right + { + get + { + return this.planes[3]; + } + } + + /// + /// Gets the top plane of the frustum. + /// + public Plane Top + { + get + { + return this.planes[4]; + } + } + + /// + /// Gets the bottom plane of the frustum. + /// + public Plane Bottom + { + get + { + return this.planes[5]; + } + } + + #endregion + + #region Internal Properties + + internal string DebugDisplayString + { + get + { + return string.Concat( + "Near( ", planes[0].DebugDisplayString, " ) \r\n", + "Far( ", planes[1].DebugDisplayString, " ) \r\n", + "Left( ", planes[2].DebugDisplayString, " ) \r\n", + "Right( ", planes[3].DebugDisplayString, " ) \r\n", + "Top( ", planes[4].DebugDisplayString, " ) \r\n", + "Bottom( ", planes[5].DebugDisplayString, " ) " + ); + } + } + + #endregion + + #region Public Fields + + /// + /// The number of corner points in the frustum. + /// + public const int CornerCount = 8; + + #endregion + + #region Private Fields + + private Matrix matrix; + private readonly Vector3[] corners = new Vector3[CornerCount]; + private readonly Plane[] planes = new Plane[PlaneCount]; + + /// + /// The number of planes in the frustum. + /// + private const int PlaneCount = 6; + + #endregion + + #region Public Constructors + + /// + /// Constructs the frustum by extracting the view planes from a matrix. + /// + /// Combined matrix which usually is (View * Projection). + public BoundingFrustum(Matrix value) + { + this.matrix = value; + this.CreatePlanes(); + this.CreateCorners(); + } + + #endregion + + #region Public Methods + + /// + /// Containment test between this and specified . + /// + /// A for testing. + /// Result of testing for containment between this and specified . + public ContainmentType Contains(BoundingFrustum frustum) + { + if (this == frustum) + { + return ContainmentType.Contains; + } + bool intersects = false; + for (int i = 0; i < PlaneCount; i += 1) + { + PlaneIntersectionType planeIntersectionType; + frustum.Intersects(ref planes[i], out planeIntersectionType); + if (planeIntersectionType == PlaneIntersectionType.Front) + { + return ContainmentType.Disjoint; + } + else if (planeIntersectionType == PlaneIntersectionType.Intersecting) + { + intersects = true; + } + } + return intersects ? ContainmentType.Intersects : ContainmentType.Contains; + } + + /// + /// Containment test between this and specified . + /// + /// A for testing. + /// Result of testing for containment between this and specified . + public ContainmentType Contains(BoundingBox box) + { + ContainmentType result = default(ContainmentType); + this.Contains(ref box, out result); + return result; + } + + /// + /// Containment test between this and specified . + /// + /// A for testing. + /// Result of testing for containment between this and specified as an output parameter. + public void Contains(ref BoundingBox box, out ContainmentType result) + { + bool intersects = false; + for (int i = 0; i < PlaneCount; i += 1) + { + PlaneIntersectionType planeIntersectionType = default(PlaneIntersectionType); + box.Intersects(ref this.planes[i], out planeIntersectionType); + switch (planeIntersectionType) + { + case PlaneIntersectionType.Front: + result = ContainmentType.Disjoint; + return; + case PlaneIntersectionType.Intersecting: + intersects = true; + break; + } + } + result = intersects ? ContainmentType.Intersects : ContainmentType.Contains; + } + + /// + /// Containment test between this and specified . + /// + /// A for testing. + /// Result of testing for containment between this and specified . + public ContainmentType Contains(BoundingSphere sphere) + { + ContainmentType result = default(ContainmentType); + this.Contains(ref sphere, out result); + return result; + } + + /// + /// Containment test between this and specified . + /// + /// A for testing. + /// Result of testing for containment between this and specified as an output parameter. + public void Contains(ref BoundingSphere sphere, out ContainmentType result) + { + bool intersects = false; + for (int i = 0; i < PlaneCount; i += 1) + { + PlaneIntersectionType planeIntersectionType = default(PlaneIntersectionType); + + // TODO: We might want to inline this for performance reasons. + sphere.Intersects(ref this.planes[i], out planeIntersectionType); + switch (planeIntersectionType) + { + case PlaneIntersectionType.Front: + result = ContainmentType.Disjoint; + return; + case PlaneIntersectionType.Intersecting: + intersects = true; + break; + } + } + result = intersects ? ContainmentType.Intersects : ContainmentType.Contains; + } + + /// + /// Containment test between this and specified . + /// + /// A for testing. + /// Result of testing for containment between this and specified . + public ContainmentType Contains(Vector3 point) + { + ContainmentType result = default(ContainmentType); + this.Contains(ref point, out result); + return result; + } + + /// + /// Containment test between this and specified . + /// + /// A for testing. + /// Result of testing for containment between this and specified as an output parameter. + public void Contains(ref Vector3 point, out ContainmentType result) + { + bool intersects = false; + for (int i = 0; i < PlaneCount; i += 1) + { + float classifyPoint = ( + (point.X * planes[i].Normal.X) + + (point.Y * planes[i].Normal.Y) + + (point.Z * planes[i].Normal.Z) + + planes[i].D + ); + if (classifyPoint > 0) + { + result = ContainmentType.Disjoint; + return; + } + else if (classifyPoint == 0) + { + intersects = true; + break; + } + } + result = intersects ? ContainmentType.Intersects : ContainmentType.Contains; + } + + /// + /// Returns a copy of internal corners array. + /// + /// The array of corners. + public Vector3[] GetCorners() + { + return (Vector3[]) this.corners.Clone(); + } + + /// + /// Returns a copy of internal corners array. + /// + /// The array which values will be replaced to corner values of this instance. It must have size of . + public void GetCorners(Vector3[] corners) + { + if (corners == null) + { + throw new ArgumentNullException("corners"); + } + if (corners.Length < CornerCount) + { + throw new ArgumentOutOfRangeException("corners"); + } + + this.corners.CopyTo(corners, 0); + } + + /// + /// Gets whether or not a specified intersects with this . + /// + /// An other for intersection test. + /// true if other intersects with this ; false otherwise. + public bool Intersects(BoundingFrustum frustum) + { + return (Contains(frustum) != ContainmentType.Disjoint); + } + + /// + /// Gets whether or not a specified intersects with this . + /// + /// A for intersection test. + /// true if specified intersects with this ; false otherwise. + public bool Intersects(BoundingBox box) + { + bool result = false; + this.Intersects(ref box, out result); + return result; + } + + /// + /// Gets whether or not a specified intersects with this . + /// + /// A for intersection test. + /// true if specified intersects with this ; false otherwise as an output parameter. + public void Intersects(ref BoundingBox box, out bool result) + { + ContainmentType containment = default(ContainmentType); + this.Contains(ref box, out containment); + result = containment != ContainmentType.Disjoint; + } + + /// + /// Gets whether or not a specified intersects with this . + /// + /// A for intersection test. + /// true if specified intersects with this ; false otherwise. + public bool Intersects(BoundingSphere sphere) + { + bool result = default(bool); + this.Intersects(ref sphere, out result); + return result; + } + + /// + /// Gets whether or not a specified intersects with this . + /// + /// A for intersection test. + /// true if specified intersects with this ; false otherwise as an output parameter. + public void Intersects(ref BoundingSphere sphere, out bool result) + { + ContainmentType containment = default(ContainmentType); + this.Contains(ref sphere, out containment); + result = containment != ContainmentType.Disjoint; + } + + /// + /// Gets type of intersection between specified and this . + /// + /// A for intersection test. + /// A plane intersection type. + public PlaneIntersectionType Intersects(Plane plane) + { + PlaneIntersectionType result; + Intersects(ref plane, out result); + return result; + } + + /// + /// Gets type of intersection between specified and this . + /// + /// A for intersection test. + /// A plane intersection type as an output parameter. + public void Intersects(ref Plane plane, out PlaneIntersectionType result) + { + result = plane.Intersects(ref corners[0]); + for (int i = 1; i < corners.Length; i += 1) + { + if (plane.Intersects(ref corners[i]) != result) + { + result = PlaneIntersectionType.Intersecting; + } + } + } + + /// + /// Gets the distance of intersection of and this or null if no intersection happens. + /// + /// A for intersection test. + /// Distance at which ray intersects with this or null if no intersection happens. + public float? Intersects(Ray ray) + { + float? result; + Intersects(ref ray, out result); + return result; + } + + /// + /// Gets the distance of intersection of and this or null if no intersection happens. + /// + /// A for intersection test. + /// Distance at which ray intersects with this or null if no intersection happens as an output parameter. + public void Intersects(ref Ray ray, out float? result) + { + ContainmentType ctype; + Contains(ref ray.Position, out ctype); + + if (ctype == ContainmentType.Disjoint) + { + result = null; + return; + } + if (ctype == ContainmentType.Contains) + { + result = 0.0f; + return; + } + if (ctype != ContainmentType.Intersects) + { + throw new ArgumentOutOfRangeException("ctype"); + } + + throw new NotImplementedException(); + } + + #endregion + + #region Private Methods + + private void CreateCorners() + { + IntersectionPoint( + ref this.planes[0], + ref this.planes[2], + ref this.planes[4], + out this.corners[0] + ); + IntersectionPoint( + ref this.planes[0], + ref this.planes[3], + ref this.planes[4], + out this.corners[1] + ); + IntersectionPoint( + ref this.planes[0], + ref this.planes[3], + ref this.planes[5], + out this.corners[2] + ); + IntersectionPoint( + ref this.planes[0], + ref this.planes[2], + ref this.planes[5], + out this.corners[3] + ); + IntersectionPoint( + ref this.planes[1], + ref this.planes[2], + ref this.planes[4], + out this.corners[4] + ); + IntersectionPoint( + ref this.planes[1], + ref this.planes[3], + ref this.planes[4], + out this.corners[5] + ); + IntersectionPoint( + ref this.planes[1], + ref this.planes[3], + ref this.planes[5], + out this.corners[6] + ); + IntersectionPoint( + ref this.planes[1], + ref this.planes[2], + ref this.planes[5], + out this.corners[7] + ); + } + + private void CreatePlanes() + { + this.planes[0] = new Plane( + -this.matrix.M13, + -this.matrix.M23, + -this.matrix.M33, + -this.matrix.M43 + ); + this.planes[1] = new Plane( + this.matrix.M13 - this.matrix.M14, + this.matrix.M23 - this.matrix.M24, + this.matrix.M33 - this.matrix.M34, + this.matrix.M43 - this.matrix.M44 + ); + this.planes[2] = new Plane( + -this.matrix.M14 - this.matrix.M11, + -this.matrix.M24 - this.matrix.M21, + -this.matrix.M34 - this.matrix.M31, + -this.matrix.M44 - this.matrix.M41 + ); + this.planes[3] = new Plane( + this.matrix.M11 - this.matrix.M14, + this.matrix.M21 - this.matrix.M24, + this.matrix.M31 - this.matrix.M34, + this.matrix.M41 - this.matrix.M44 + ); + this.planes[4] = new Plane( + this.matrix.M12 - this.matrix.M14, + this.matrix.M22 - this.matrix.M24, + this.matrix.M32 - this.matrix.M34, + this.matrix.M42 - this.matrix.M44 + ); + this.planes[5] = new Plane( + -this.matrix.M14 - this.matrix.M12, + -this.matrix.M24 - this.matrix.M22, + -this.matrix.M34 - this.matrix.M32, + -this.matrix.M44 - this.matrix.M42 + ); + + this.NormalizePlane(ref this.planes[0]); + this.NormalizePlane(ref this.planes[1]); + this.NormalizePlane(ref this.planes[2]); + this.NormalizePlane(ref this.planes[3]); + this.NormalizePlane(ref this.planes[4]); + this.NormalizePlane(ref this.planes[5]); + } + + private void NormalizePlane(ref Plane p) + { + float factor = 1f / p.Normal.Length(); + p.Normal.X *= factor; + p.Normal.Y *= factor; + p.Normal.Z *= factor; + p.D *= factor; + } + + #endregion + + #region Private Static Methods + + private static void IntersectionPoint( + ref Plane a, + ref Plane b, + ref Plane c, + out Vector3 result + ) { + /* Formula used + * d1 ( N2 * N3 ) + d2 ( N3 * N1 ) + d3 ( N1 * N2 ) + * P = ------------------------------------------------------------------- + * N1 . ( N2 * N3 ) + * + * Note: N refers to the normal, d refers to the displacement. '.' means dot + * product. '*' means cross product + */ + + Vector3 v1, v2, v3; + Vector3 cross; + + Vector3.Cross(ref b.Normal, ref c.Normal, out cross); + + float f; + Vector3.Dot(ref a.Normal, ref cross, out f); + f *= -1.0f; + + Vector3.Cross(ref b.Normal, ref c.Normal, out cross); + Vector3.Multiply(ref cross, a.D, out v1); + // v1 = (a.D * (Vector3.Cross(b.Normal, c.Normal))); + + + Vector3.Cross(ref c.Normal, ref a.Normal, out cross); + Vector3.Multiply(ref cross, b.D, out v2); + // v2 = (b.D * (Vector3.Cross(c.Normal, a.Normal))); + + + Vector3.Cross(ref a.Normal, ref b.Normal, out cross); + Vector3.Multiply(ref cross, c.D, out v3); + // v3 = (c.D * (Vector3.Cross(a.Normal, b.Normal))); + + result.X = (v1.X + v2.X + v3.X) / f; + result.Y = (v1.Y + v2.Y + v3.Y) / f; + result.Z = (v1.Z + v2.Z + v3.Z) / f; + } + + #endregion + + #region Public Static Operators and Override Methods + + /// + /// Compares whether two instances are equal. + /// + /// instance on the left of the equal sign. + /// instance on the right of the equal sign. + /// true if the instances are equal; false otherwise. + public static bool operator ==(BoundingFrustum a, BoundingFrustum b) + { + if (object.Equals(a, null)) + { + return (object.Equals(b, null)); + } + + if (object.Equals(b, null)) + { + return (object.Equals(a, null)); + } + + return a.matrix == (b.matrix); + } + + /// + /// Compares whether two instances are not equal. + /// + /// instance on the left of the not equal sign. + /// instance on the right of the not equal sign. + /// true if the instances are not equal; false otherwise. + public static bool operator !=(BoundingFrustum a, BoundingFrustum b) + { + return !(a == b); + } + + /// + /// Compares whether current instance is equal to specified . + /// + /// The to compare. + /// true if the instances are equal; false otherwise. + public bool Equals(BoundingFrustum other) + { + return (this == other); + } + + /// + /// Compares whether current instance is equal to specified . + /// + /// The to compare. + /// true if the instances are equal; false otherwise. + public override bool Equals(object obj) + { + return (obj is BoundingFrustum) && Equals((BoundingFrustum) obj); + } + + /// + /// Returns a representation of this in the format: + /// {Near:[nearPlane] Far:[farPlane] Left:[leftPlane] Right:[rightPlane] Top:[topPlane] Bottom:[bottomPlane]} + /// + /// representation of this . + public override string ToString() + { + StringBuilder sb = new StringBuilder(256); + sb.Append("{Near:"); + sb.Append(this.planes[0].ToString()); + sb.Append(" Far:"); + sb.Append(this.planes[1].ToString()); + sb.Append(" Left:"); + sb.Append(this.planes[2].ToString()); + sb.Append(" Right:"); + sb.Append(this.planes[3].ToString()); + sb.Append(" Top:"); + sb.Append(this.planes[4].ToString()); + sb.Append(" Bottom:"); + sb.Append(this.planes[5].ToString()); + sb.Append("}"); + return sb.ToString(); + } + + /// + /// Gets the hash code of this . + /// + /// Hash code of this . + public override int GetHashCode() + { + return this.matrix.GetHashCode(); + } + + #endregion + } +} + diff --git a/FNA/src/BoundingSphere.cs b/FNA/src/BoundingSphere.cs new file mode 100644 index 0000000..f5208e0 --- /dev/null +++ b/FNA/src/BoundingSphere.cs @@ -0,0 +1,683 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; + +using Microsoft.Xna.Framework.Design; +#endregion + +namespace Microsoft.Xna.Framework +{ + /// + /// Describes a sphere in 3D-space for bounding operations. + /// + [Serializable] + [TypeConverter(typeof(BoundingSphereConverter))] + [DebuggerDisplay("{DebugDisplayString,nq}")] + public struct BoundingSphere : IEquatable + { + #region Internal Properties + + internal string DebugDisplayString + { + get + { + return string.Concat( + "Center( ", Center.DebugDisplayString, " ) \r\n", + "Radius( ", Radius.ToString(), " ) " + ); + } + } + + #endregion + + #region Public Fields + + /// + /// The sphere center. + /// + public Vector3 Center; + + /// + /// The sphere radius. + /// + public float Radius; + + #endregion + + #region Public Constructors + + /// + /// Constructs a bounding sphere with the specified center and radius. + /// + /// The sphere center. + /// The sphere radius. + public BoundingSphere(Vector3 center, float radius) + { + this.Center = center; + this.Radius = radius; + } + + #endregion + + #region Public Methods + + /// + /// Creates a new that contains a transformation of translation and scale from this sphere by the specified . + /// + /// The transformation . + /// Transformed . + public BoundingSphere Transform(Matrix matrix) + { + BoundingSphere sphere = new BoundingSphere(); + sphere.Center = Vector3.Transform(this.Center, matrix); + sphere.Radius = this.Radius * + ( + (float) Math.Sqrt((double) Math.Max( + ((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13), + Math.Max( + ((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23), + ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33)) + ) + ) + ); + return sphere; + } + + /// + /// Creates a new that contains a transformation of translation and scale from this sphere by the specified . + /// + /// The transformation . + /// Transformed as an output parameter. + public void Transform(ref Matrix matrix, out BoundingSphere result) + { + result.Center = Vector3.Transform(this.Center, matrix); + result.Radius = this.Radius * + ( + (float) Math.Sqrt((double) Math.Max( + ((matrix.M11 * matrix.M11) + (matrix.M12 * matrix.M12)) + (matrix.M13 * matrix.M13), + Math.Max( + ((matrix.M21 * matrix.M21) + (matrix.M22 * matrix.M22)) + (matrix.M23 * matrix.M23), + ((matrix.M31 * matrix.M31) + (matrix.M32 * matrix.M32)) + (matrix.M33 * matrix.M33)) + ) + ) + ); + } + + /// + /// Test if a bounding box is fully inside, outside, or just intersecting the sphere. + /// + /// The box for testing. + /// The containment type as an output parameter. + public void Contains(ref BoundingBox box, out ContainmentType result) + { + result = this.Contains(box); + } + + /// + /// Test if a sphere is fully inside, outside, or just intersecting the sphere. + /// + /// The other sphere for testing. + /// The containment type as an output parameter. + public void Contains(ref BoundingSphere sphere, out ContainmentType result) + { + result = Contains(sphere); + } + + /// + /// Test if a point is fully inside, outside, or just intersecting the sphere. + /// + /// The vector in 3D-space for testing. + /// The containment type as an output parameter. + public void Contains(ref Vector3 point, out ContainmentType result) + { + result = Contains(point); + } + + /// + /// Test if a bounding box is fully inside, outside, or just intersecting the sphere. + /// + /// The box for testing. + /// The containment type. + public ContainmentType Contains(BoundingBox box) + { + // Check if all corners are in sphere. + bool inside = true; + foreach (Vector3 corner in box.GetCorners()) + { + if (this.Contains(corner) == ContainmentType.Disjoint) + { + inside = false; + break; + } + } + + if (inside) + { + return ContainmentType.Contains; + } + + // Check if the distance from sphere center to cube face is less than radius. + double dmin = 0; + + if (Center.X < box.Min.X) + { + dmin += (Center.X - box.Min.X) * (Center.X - box.Min.X); + } + else if (Center.X > box.Max.X) + { + dmin += (Center.X - box.Max.X) * (Center.X - box.Max.X); + } + + if (Center.Y < box.Min.Y) + { + dmin += (Center.Y - box.Min.Y) * (Center.Y - box.Min.Y); + } + else if (Center.Y > box.Max.Y) + { + dmin += (Center.Y - box.Max.Y) * (Center.Y - box.Max.Y); + } + + if (Center.Z < box.Min.Z) + { + dmin += (Center.Z - box.Min.Z) * (Center.Z - box.Min.Z); + } + else if (Center.Z > box.Max.Z) + { + dmin += (Center.Z - box.Max.Z) * (Center.Z - box.Max.Z); + } + + if (dmin <= Radius * Radius) + { + return ContainmentType.Intersects; + } + + // Else disjoint + return ContainmentType.Disjoint; + } + + /// + /// Test if a frustum is fully inside, outside, or just intersecting the sphere. + /// + /// The box for testing. + /// The containment type as an output parameter. + public ContainmentType Contains(BoundingFrustum frustum) + { + // Check if all corners are in sphere. + bool inside = true; + + Vector3[] corners = frustum.GetCorners(); + foreach (Vector3 corner in corners) + { + if (this.Contains(corner) == ContainmentType.Disjoint) + { + inside = false; + break; + } + } + if (inside) + { + return ContainmentType.Contains; + } + + // Check if the distance from sphere center to frustrum face is less than radius. + double dmin = 0; + // TODO : calcul dmin + + if (dmin <= Radius * Radius) + { + return ContainmentType.Intersects; + } + + // Else disjoint + return ContainmentType.Disjoint; + } + + /// + /// Test if a sphere is fully inside, outside, or just intersecting the sphere. + /// + /// The other sphere for testing. + /// The containment type. + public ContainmentType Contains(BoundingSphere sphere) + { + float sqDistance; + Vector3.DistanceSquared(ref sphere.Center, ref Center, out sqDistance); + + if (sqDistance > (sphere.Radius + Radius) * (sphere.Radius + Radius)) + { + return ContainmentType.Disjoint; + } + else if (sqDistance <= (Radius - sphere.Radius) * (Radius - sphere.Radius)) + { + return ContainmentType.Contains; + } + return ContainmentType.Intersects; + } + + /// + /// Test if a point is fully inside, outside, or just intersecting the sphere. + /// + /// The vector in 3D-space for testing. + /// The containment type. + public ContainmentType Contains(Vector3 point) + { + float sqRadius = Radius * Radius; + float sqDistance; + Vector3.DistanceSquared(ref point, ref Center, out sqDistance); + + if (sqDistance > sqRadius) + { + return ContainmentType.Disjoint; + } + else if (sqDistance < sqRadius) + { + return ContainmentType.Contains; + } + return ContainmentType.Intersects; + } + + /// + /// Compares whether current instance is equal to specified . + /// + /// The to compare. + /// true if the instances are equal; false otherwise. + public bool Equals(BoundingSphere other) + { + return ( Center == other.Center && + Radius == other.Radius ); + } + + #endregion + + #region Public Static Methods + + /// + /// Creates the smallest that can contain a specified . + /// + /// The box to create the sphere from. + /// The new . + public static BoundingSphere CreateFromBoundingBox(BoundingBox box) + { + BoundingSphere result; + CreateFromBoundingBox(ref box, out result); + return result; + } + + /// + /// Creates the smallest that can contain a specified . + /// + /// The box to create the sphere from. + /// The new as an output parameter. + public static void CreateFromBoundingBox(ref BoundingBox box, out BoundingSphere result) + { + // Find the center of the box. + Vector3 center = new Vector3( + (box.Min.X + box.Max.X) / 2.0f, + (box.Min.Y + box.Max.Y) / 2.0f, + (box.Min.Z + box.Max.Z) / 2.0f + ); + + // Find the distance between the center and one of the corners of the box. + float radius = Vector3.Distance(center, box.Max); + + result = new BoundingSphere(center, radius); + } + + /// + /// Creates the smallest that can contain a specified . + /// + /// The frustum to create the sphere from. + /// The new . + public static BoundingSphere CreateFromFrustum(BoundingFrustum frustum) + { + return CreateFromPoints(frustum.GetCorners()); + } + + /// + /// Creates the smallest that can contain a specified list of points in 3D-space. + /// + /// List of point to create the sphere from. + /// The new . + public static BoundingSphere CreateFromPoints(IEnumerable points) + { + if (points == null) + { + throw new ArgumentNullException("points"); + } + + // From "Real-Time Collision Detection" (Page 89) + + Vector3 minx = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue); + Vector3 maxx = -minx; + Vector3 miny = minx; + Vector3 maxy = -minx; + Vector3 minz = minx; + Vector3 maxz = -minx; + + // Find the most extreme points along the principle axis. + int numPoints = 0; + foreach (Vector3 pt in points) + { + numPoints += 1; + + if (pt.X < minx.X) + { + minx = pt; + } + if (pt.X > maxx.X) + { + maxx = pt; + } + if (pt.Y < miny.Y) + { + miny = pt; + } + if (pt.Y > maxy.Y) + { + maxy = pt; + } + if (pt.Z < minz.Z) + { + minz = pt; + } + if (pt.Z > maxz.Z) + { + maxz = pt; + } + } + + if (numPoints == 0) + { + throw new ArgumentException( + "You should have at least one point in points." + ); + } + + float sqDistX = Vector3.DistanceSquared(maxx, minx); + float sqDistY = Vector3.DistanceSquared(maxy, miny); + float sqDistZ = Vector3.DistanceSquared(maxz, minz); + + // Pick the pair of most distant points. + Vector3 min = minx; + Vector3 max = maxx; + if (sqDistY > sqDistX && sqDistY > sqDistZ) + { + max = maxy; + min = miny; + } + if (sqDistZ > sqDistX && sqDistZ > sqDistY) + { + max = maxz; + min = minz; + } + + Vector3 center = (min + max) * 0.5f; + float radius = Vector3.Distance(max, center); + + // Test every point and expand the sphere. + // The current bounding sphere is just a good approximation and may not enclose all points. + // From: Mathematics for 3D Game Programming and Computer Graphics, Eric Lengyel, Third Edition. + // Page 218 + float sqRadius = radius * radius; + foreach (Vector3 pt in points) + { + Vector3 diff = (pt - center); + float sqDist = diff.LengthSquared(); + if (sqDist > sqRadius) + { + float distance = (float) Math.Sqrt(sqDist); // equal to diff.Length(); + Vector3 direction = diff / distance; + Vector3 G = center - radius * direction; + center = (G + pt) / 2; + radius = Vector3.Distance(pt, center); + sqRadius = radius * radius; + } + } + + return new BoundingSphere(center, radius); + } + + /// + /// Creates the smallest that can contain two spheres. + /// + /// First sphere. + /// Second sphere. + /// The new . + public static BoundingSphere CreateMerged(BoundingSphere original, BoundingSphere additional) + { + BoundingSphere result; + CreateMerged(ref original, ref additional, out result); + return result; + } + + /// + /// Creates the smallest that can contain two spheres. + /// + /// First sphere. + /// Second sphere. + /// The new as an output parameter. + public static void CreateMerged( + ref BoundingSphere original, + ref BoundingSphere additional, + out BoundingSphere result + ) { + Vector3 ocenterToaCenter = Vector3.Subtract(additional.Center, original.Center); + float distance = ocenterToaCenter.Length(); + + // Intersect + if (distance <= original.Radius + additional.Radius) + { + // Original contains additional. + if (distance <= original.Radius - additional.Radius) + { + result = original; + return; + } + + // Additional contains original. + if (distance <= additional.Radius - original.Radius) + { + result = additional; + return; + } + } + + // Else find center of new sphere and radius + float leftRadius = Math.Max(original.Radius - distance, additional.Radius); + float Rightradius = Math.Max(original.Radius + distance, additional.Radius); + + // oCenterToResultCenter + ocenterToaCenter = ocenterToaCenter + + ( + ((leftRadius - Rightradius) / (2 * ocenterToaCenter.Length())) + * ocenterToaCenter + ); + + result = new BoundingSphere(); + result.Center = original.Center + ocenterToaCenter; + result.Radius = (leftRadius + Rightradius) / 2; + } + + /// + /// Gets whether or not a specified intersects with this sphere. + /// + /// The box for testing. + /// true if intersects with this sphere; false otherwise. + public bool Intersects(BoundingBox box) + { + return box.Intersects(this); + } + + /// + /// Gets whether or not a specified intersects with this sphere. + /// + /// The box for testing. + /// true if intersects with this sphere; false otherwise. As an output parameter. + public void Intersects(ref BoundingBox box, out bool result) + { + box.Intersects(ref this, out result); + } + + public bool Intersects(BoundingFrustum frustum) + { + return frustum.Intersects(this); + } + + /// + /// Gets whether or not the other intersects with this sphere. + /// + /// The other sphere for testing. + /// true if other intersects with this sphere; false otherwise. + public bool Intersects(BoundingSphere sphere) + { + bool result; + Intersects(ref sphere, out result); + return result; + } + + /// + /// Gets whether or not the other intersects with this sphere. + /// + /// The other sphere for testing. + /// true if other intersects with this sphere; false otherwise. As an output parameter. + public void Intersects(ref BoundingSphere sphere, out bool result) + { + float sqDistance; + Vector3.DistanceSquared(ref sphere.Center, ref Center, out sqDistance); + result = !(sqDistance > (sphere.Radius + Radius) * (sphere.Radius + Radius)); + } + + /// + /// Gets whether or not a specified intersects with this sphere. + /// + /// The ray for testing. + /// Distance of ray intersection or null if there is no intersection. + public float? Intersects(Ray ray) + { + return ray.Intersects(this); + } + + /// + /// Gets whether or not a specified intersects with this sphere. + /// + /// The ray for testing. + /// Distance of ray intersection or null if there is no intersection as an output parameter. + public void Intersects(ref Ray ray, out float? result) + { + ray.Intersects(ref this, out result); + } + + /// + /// Gets whether or not a specified intersects with this sphere. + /// + /// The plane for testing. + /// Type of intersection. + public PlaneIntersectionType Intersects(Plane plane) + { + PlaneIntersectionType result = default(PlaneIntersectionType); + // TODO: We might want to inline this for performance reasons. + this.Intersects(ref plane, out result); + return result; + } + + /// + /// Gets whether or not a specified intersects with this sphere. + /// + /// The plane for testing. + /// Type of intersection as an output parameter. + public void Intersects(ref Plane plane, out PlaneIntersectionType result) + { + float distance = default(float); + // TODO: We might want to inline this for performance reasons. + Vector3.Dot(ref plane.Normal, ref this.Center, out distance); + distance += plane.D; + if (distance > this.Radius) + { + result = PlaneIntersectionType.Front; + } + else if (distance < -this.Radius) + { + result = PlaneIntersectionType.Back; + } + else + { + result = PlaneIntersectionType.Intersecting; + } + } + + #endregion + + #region Public Static Operators and Override Methods + + /// + /// Compares whether current instance is equal to specified . + /// + /// The to compare. + /// true if the instances are equal; false otherwise. + public override bool Equals(object obj) + { + return (obj is BoundingSphere) && Equals((BoundingSphere) obj); + } + + /// + /// Gets the hash code of this . + /// + /// Hash code of this . + public override int GetHashCode() + { + return this.Center.GetHashCode() + this.Radius.GetHashCode(); + } + + /// + /// Returns a representation of this in the format: + /// {Center:[] Radius:[]} + /// + /// A representation of this . + public override string ToString() + { + return ( + "{Center:" + Center.ToString() + + " Radius:" + Radius.ToString() + + "}" + ); + } + + /// + /// Compares whether two instances are equal. + /// + /// instance on the left of the equal sign. + /// instance on the right of the equal sign. + /// true if the instances are equal; false otherwise. + public static bool operator ==(BoundingSphere a, BoundingSphere b) + { + return a.Equals(b); + } + + /// + /// Compares whether two instances are not equal. + /// + /// instance on the left of the not equal sign. + /// instance on the right of the not equal sign. + /// true if the instances are not equal; false otherwise. + public static bool operator !=(BoundingSphere a, BoundingSphere b) + { + return !a.Equals(b); + } + + #endregion + } +} diff --git a/FNA/src/Color.cs b/FNA/src/Color.cs new file mode 100644 index 0000000..4df6a02 --- /dev/null +++ b/FNA/src/Color.cs @@ -0,0 +1,1922 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Text; + +using Microsoft.Xna.Framework.Design; +using Microsoft.Xna.Framework.Graphics.PackedVector; +#endregion + +namespace Microsoft.Xna.Framework +{ + /// + /// Describes a 32-bit packed color. + /// + [Serializable] + [TypeConverter(typeof(ColorConverter))] + [DebuggerDisplay("{DebugDisplayString,nq}")] + public struct Color : IEquatable, IPackedVector, IPackedVector + { + #region Public Properties + + /// + /// Gets or sets the blue component. + /// + public byte B + { + get + { + unchecked + { + return (byte) (this.packedValue >> 16); + } + } + set + { + this.packedValue = (this.packedValue & 0xff00ffff) | ((uint) value << 16); + } + } + + /// + /// Gets or sets the green component. + /// + public byte G + { + get + { + unchecked + { + return (byte) (this.packedValue >> 8); + } + } + set + { + this.packedValue = (this.packedValue & 0xffff00ff) | ((uint) value << 8); + } + } + + /// + /// Gets or sets the red component. + /// + public byte R + { + get + { + unchecked + { + return (byte) (this.packedValue); + } + } + set + { + this.packedValue = (this.packedValue & 0xffffff00) | value; + } + } + + /// + /// Gets or sets the alpha component. + /// + public byte A + { + get + { + unchecked + { + return (byte) (this.packedValue >> 24); + } + } + set + { + this.packedValue = (this.packedValue & 0x00ffffff) | ((uint) value << 24); + } + } + + /// + /// Gets or sets packed value of this . + /// + [CLSCompliant(false)] + public UInt32 PackedValue + { + get + { + return packedValue; + } + set + { + packedValue = value; + } + } + + #endregion + + #region Public Static Color Properties + + /// + /// Transparent color (R:0,G:0,B:0,A:0). + /// + public static Color Transparent + { + get; + private set; + } + + /// + /// AliceBlue color (R:240,G:248,B:255,A:255). + /// + public static Color AliceBlue + { + get; + private set; + } + + /// + /// AntiqueWhite color (R:250,G:235,B:215,A:255). + /// + public static Color AntiqueWhite + { + get; + private set; + } + + /// + /// Aqua color (R:0,G:255,B:255,A:255). + /// + public static Color Aqua + { + get; + private set; + } + + /// + /// Aquamarine color (R:127,G:255,B:212,A:255). + /// + public static Color Aquamarine + { + get; + private set; + } + + /// + /// Azure color (R:240,G:255,B:255,A:255). + /// + public static Color Azure + { + get; + private set; + } + + /// + /// Beige color (R:245,G:245,B:220,A:255). + /// + public static Color Beige + { + get; + private set; + } + + /// + /// Bisque color (R:255,G:228,B:196,A:255). + /// + public static Color Bisque + { + get; + private set; + } + + /// + /// Black color (R:0,G:0,B:0,A:255). + /// + public static Color Black + { + get; + private set; + } + + /// + /// BlanchedAlmond color (R:255,G:235,B:205,A:255). + /// + public static Color BlanchedAlmond + { + get; + private set; + } + + /// + /// Blue color (R:0,G:0,B:255,A:255). + /// + public static Color Blue + { + get; + private set; + } + + /// + /// BlueViolet color (R:138,G:43,B:226,A:255). + /// + public static Color BlueViolet + { + get; + private set; + } + + /// + /// Brown color (R:165,G:42,B:42,A:255). + /// + public static Color Brown + { + get; + private set; + } + + /// + /// BurlyWood color (R:222,G:184,B:135,A:255). + /// + public static Color BurlyWood + { + get; + private set; + } + + /// + /// CadetBlue color (R:95,G:158,B:160,A:255). + /// + public static Color CadetBlue + { + get; + private set; + } + + /// + /// Chartreuse color (R:127,G:255,B:0,A:255). + /// + public static Color Chartreuse + { + get; + private set; + } + + /// + /// Chocolate color (R:210,G:105,B:30,A:255). + /// + public static Color Chocolate + { + get; + private set; + } + + /// + /// Coral color (R:255,G:127,B:80,A:255). + /// + public static Color Coral + { + get; + private set; + } + + /// + /// CornflowerBlue color (R:100,G:149,B:237,A:255). + /// + public static Color CornflowerBlue + { + get; + private set; + } + + /// + /// Cornsilk color (R:255,G:248,B:220,A:255). + /// + public static Color Cornsilk + { + get; + private set; + } + + /// + /// Crimson color (R:220,G:20,B:60,A:255). + /// + public static Color Crimson + { + get; + private set; + } + + /// + /// Cyan color (R:0,G:255,B:255,A:255). + /// + public static Color Cyan + { + get; + private set; + } + + /// + /// DarkBlue color (R:0,G:0,B:139,A:255). + /// + public static Color DarkBlue + { + get; + private set; + } + + /// + /// DarkCyan color (R:0,G:139,B:139,A:255). + /// + public static Color DarkCyan + { + get; + private set; + } + + /// + /// DarkGoldenrod color (R:184,G:134,B:11,A:255). + /// + public static Color DarkGoldenrod + { + get; + private set; + } + + /// + /// DarkGray color (R:169,G:169,B:169,A:255). + /// + public static Color DarkGray + { + get; + private set; + } + + /// + /// DarkGreen color (R:0,G:100,B:0,A:255). + /// + public static Color DarkGreen + { + get; + private set; + } + + /// + /// DarkKhaki color (R:189,G:183,B:107,A:255). + /// + public static Color DarkKhaki + { + get; + private set; + } + + /// + /// DarkMagenta color (R:139,G:0,B:139,A:255). + /// + public static Color DarkMagenta + { + get; + private set; + } + + /// + /// DarkOliveGreen color (R:85,G:107,B:47,A:255). + /// + public static Color DarkOliveGreen + { + get; + private set; + } + + /// + /// DarkOrange color (R:255,G:140,B:0,A:255). + /// + public static Color DarkOrange + { + get; + private set; + } + + /// + /// DarkOrchid color (R:153,G:50,B:204,A:255). + /// + public static Color DarkOrchid + { + get; + private set; + } + + /// + /// DarkRed color (R:139,G:0,B:0,A:255). + /// + public static Color DarkRed + { + get; + private set; + } + + /// + /// DarkSalmon color (R:233,G:150,B:122,A:255). + /// + public static Color DarkSalmon + { + get; + private set; + } + + /// + /// DarkSeaGreen color (R:143,G:188,B:139,A:255). + /// + public static Color DarkSeaGreen + { + get; + private set; + } + + /// + /// DarkSlateBlue color (R:72,G:61,B:139,A:255). + /// + public static Color DarkSlateBlue + { + get; + private set; + } + + /// + /// DarkSlateGray color (R:47,G:79,B:79,A:255). + /// + public static Color DarkSlateGray + { + get; + private set; + } + + /// + /// DarkTurquoise color (R:0,G:206,B:209,A:255). + /// + public static Color DarkTurquoise + { + get; + private set; + } + + /// + /// DarkViolet color (R:148,G:0,B:211,A:255). + /// + public static Color DarkViolet + { + get; + private set; + } + + /// + /// DeepPink color (R:255,G:20,B:147,A:255). + /// + public static Color DeepPink + { + get; + private set; + } + + /// + /// DeepSkyBlue color (R:0,G:191,B:255,A:255). + /// + public static Color DeepSkyBlue + { + get; + private set; + } + + /// + /// DimGray color (R:105,G:105,B:105,A:255). + /// + public static Color DimGray + { + get; + private set; + } + + /// + /// DodgerBlue color (R:30,G:144,B:255,A:255). + /// + public static Color DodgerBlue + { + get; + private set; + } + + /// + /// Firebrick color (R:178,G:34,B:34,A:255). + /// + public static Color Firebrick + { + get; + private set; + } + + /// + /// FloralWhite color (R:255,G:250,B:240,A:255). + /// + public static Color FloralWhite + { + get; + private set; + } + + /// + /// ForestGreen color (R:34,G:139,B:34,A:255). + /// + public static Color ForestGreen + { + get; + private set; + } + + /// + /// Fuchsia color (R:255,G:0,B:255,A:255). + /// + public static Color Fuchsia + { + get; + private set; + } + + /// + /// Gainsboro color (R:220,G:220,B:220,A:255). + /// + public static Color Gainsboro + { + get; + private set; + } + + /// + /// GhostWhite color (R:248,G:248,B:255,A:255). + /// + public static Color GhostWhite + { + get; + private set; + } + /// + /// Gold color (R:255,G:215,B:0,A:255). + /// + public static Color Gold + { + get; + private set; + } + + /// + /// Goldenrod color (R:218,G:165,B:32,A:255). + /// + public static Color Goldenrod + { + get; + private set; + } + + /// + /// Gray color (R:128,G:128,B:128,A:255). + /// + public static Color Gray + { + get; + private set; + } + + /// + /// Green color (R:0,G:128,B:0,A:255). + /// + public static Color Green + { + get; + private set; + } + + /// + /// GreenYellow color (R:173,G:255,B:47,A:255). + /// + public static Color GreenYellow + { + get; + private set; + } + + /// + /// Honeydew color (R:240,G:255,B:240,A:255). + /// + public static Color Honeydew + { + get; + private set; + } + + /// + /// HotPink color (R:255,G:105,B:180,A:255). + /// + public static Color HotPink + { + get; + private set; + } + + /// + /// IndianRed color (R:205,G:92,B:92,A:255). + /// + public static Color IndianRed + { + get; + private set; + } + + /// + /// Indigo color (R:75,G:0,B:130,A:255). + /// + public static Color Indigo + { + get; + private set; + } + + /// + /// Ivory color (R:255,G:255,B:240,A:255). + /// + public static Color Ivory + { + get; + private set; + } + + /// + /// Khaki color (R:240,G:230,B:140,A:255). + /// + public static Color Khaki + { + get; + private set; + } + + /// + /// Lavender color (R:230,G:230,B:250,A:255). + /// + public static Color Lavender + { + get; + private set; + } + + /// + /// LavenderBlush color (R:255,G:240,B:245,A:255). + /// + public static Color LavenderBlush + { + get; + private set; + } + + /// + /// LawnGreen color (R:124,G:252,B:0,A:255). + /// + public static Color LawnGreen + { + get; + private set; + } + + /// + /// LemonChiffon color (R:255,G:250,B:205,A:255). + /// + public static Color LemonChiffon + { + get; + private set; + } + + /// + /// LightBlue color (R:173,G:216,B:230,A:255). + /// + public static Color LightBlue + { + get; + private set; + } + + /// + /// LightCoral color (R:240,G:128,B:128,A:255). + /// + public static Color LightCoral + { + get; + private set; + } + + /// + /// LightCyan color (R:224,G:255,B:255,A:255). + /// + public static Color LightCyan + { + get; + private set; + } + + /// + /// LightGoldenrodYellow color (R:250,G:250,B:210,A:255). + /// + public static Color LightGoldenrodYellow + { + get; + private set; + } + + /// + /// LightGray color (R:211,G:211,B:211,A:255). + /// + public static Color LightGray + { + get; + private set; + } + + /// + /// LightGreen color (R:144,G:238,B:144,A:255). + /// + public static Color LightGreen + { + get; + private set; + } + + /// + /// LightPink color (R:255,G:182,B:193,A:255). + /// + public static Color LightPink + { + get; + private set; + } + + /// + /// LightSalmon color (R:255,G:160,B:122,A:255). + /// + public static Color LightSalmon + { + get; + private set; + } + + /// + /// LightSeaGreen color (R:32,G:178,B:170,A:255). + /// + public static Color LightSeaGreen + { + get; + private set; + } + + /// + /// LightSkyBlue color (R:135,G:206,B:250,A:255). + /// + public static Color LightSkyBlue + { + get; + private set; + } + + /// + /// LightSlateGray color (R:119,G:136,B:153,A:255). + /// + public static Color LightSlateGray + { + get; + private set; + } + + /// + /// LightSteelBlue color (R:176,G:196,B:222,A:255). + /// + public static Color LightSteelBlue + { + get; + private set; + } + + /// + /// LightYellow color (R:255,G:255,B:224,A:255). + /// + public static Color LightYellow + { + get; + private set; + } + + /// + /// Lime color (R:0,G:255,B:0,A:255). + /// + public static Color Lime + { + get; + private set; + } + + /// + /// LimeGreen color (R:50,G:205,B:50,A:255). + /// + public static Color LimeGreen + { + get; + private set; + } + + /// + /// Linen color (R:250,G:240,B:230,A:255). + /// + public static Color Linen + { + get; + private set; + } + + /// + /// Magenta color (R:255,G:0,B:255,A:255). + /// + public static Color Magenta + { + get; + private set; + } + + /// + /// Maroon color (R:128,G:0,B:0,A:255). + /// + public static Color Maroon + { + get; + private set; + } + + /// + /// MediumAquamarine color (R:102,G:205,B:170,A:255). + /// + public static Color MediumAquamarine + { + get; + private set; + } + + /// + /// MediumBlue color (R:0,G:0,B:205,A:255). + /// + public static Color MediumBlue + { + get; + private set; + } + + /// + /// MediumOrchid color (R:186,G:85,B:211,A:255). + /// + public static Color MediumOrchid + { + get; + private set; + } + + /// + /// MediumPurple color (R:147,G:112,B:219,A:255). + /// + public static Color MediumPurple + { + get; + private set; + } + + /// + /// MediumSeaGreen color (R:60,G:179,B:113,A:255). + /// + public static Color MediumSeaGreen + { + get; + private set; + } + + /// + /// MediumSlateBlue color (R:123,G:104,B:238,A:255). + /// + public static Color MediumSlateBlue + { + get; + private set; + } + + /// + /// MediumSpringGreen color (R:0,G:250,B:154,A:255). + /// + public static Color MediumSpringGreen + { + get; + private set; + } + + /// + /// MediumTurquoise color (R:72,G:209,B:204,A:255). + /// + public static Color MediumTurquoise + { + get; + private set; + } + + /// + /// MediumVioletRed color (R:199,G:21,B:133,A:255). + /// + public static Color MediumVioletRed + { + get; + private set; + } + + /// + /// MidnightBlue color (R:25,G:25,B:112,A:255). + /// + public static Color MidnightBlue + { + get; + private set; + } + + /// + /// MintCream color (R:245,G:255,B:250,A:255). + /// + public static Color MintCream + { + get; + private set; + } + + /// + /// MistyRose color (R:255,G:228,B:225,A:255). + /// + public static Color MistyRose + { + get; + private set; + } + + /// + /// Moccasin color (R:255,G:228,B:181,A:255). + /// + public static Color Moccasin + { + get; + private set; + } + + /// + /// NavajoWhite color (R:255,G:222,B:173,A:255). + /// + public static Color NavajoWhite + { + get; + private set; + } + + /// + /// Navy color (R:0,G:0,B:128,A:255). + /// + public static Color Navy + { + get; + private set; + } + + /// + /// OldLace color (R:253,G:245,B:230,A:255). + /// + public static Color OldLace + { + get; + private set; + } + + /// + /// Olive color (R:128,G:128,B:0,A:255). + /// + public static Color Olive + { + get; + private set; + } + + /// + /// OliveDrab color (R:107,G:142,B:35,A:255). + /// + public static Color OliveDrab + { + get; + private set; + } + + /// + /// Orange color (R:255,G:165,B:0,A:255). + /// + public static Color Orange + { + get; + private set; + } + + /// + /// OrangeRed color (R:255,G:69,B:0,A:255). + /// + public static Color OrangeRed + { + get; + private set; + } + + /// + /// Orchid color (R:218,G:112,B:214,A:255). + /// + public static Color Orchid + { + get; + private set; + } + + /// + /// PaleGoldenrod color (R:238,G:232,B:170,A:255). + /// + public static Color PaleGoldenrod + { + get; + private set; + } + + /// + /// PaleGreen color (R:152,G:251,B:152,A:255). + /// + public static Color PaleGreen + { + get; + private set; + } + + /// + /// PaleTurquoise color (R:175,G:238,B:238,A:255). + /// + public static Color PaleTurquoise + { + get; + private set; + } + /// + /// PaleVioletRed color (R:219,G:112,B:147,A:255). + /// + public static Color PaleVioletRed + { + get; + private set; + } + + /// + /// PapayaWhip color (R:255,G:239,B:213,A:255). + /// + public static Color PapayaWhip + { + get; + private set; + } + + /// + /// PeachPuff color (R:255,G:218,B:185,A:255). + /// + public static Color PeachPuff + { + get; + private set; + } + + /// + /// Peru color (R:205,G:133,B:63,A:255). + /// + public static Color Peru + { + get; + private set; + } + + /// + /// Pink color (R:255,G:192,B:203,A:255). + /// + public static Color Pink + { + get; + private set; + } + + /// + /// Plum color (R:221,G:160,B:221,A:255). + /// + public static Color Plum + { + get; + private set; + } + + /// + /// PowderBlue color (R:176,G:224,B:230,A:255). + /// + public static Color PowderBlue + { + get; + private set; + } + + /// + /// Purple color (R:128,G:0,B:128,A:255). + /// + public static Color Purple + { + get; + private set; + } + + /// + /// Red color (R:255,G:0,B:0,A:255). + /// + public static Color Red + { + get; + private set; + } + + /// + /// RosyBrown color (R:188,G:143,B:143,A:255). + /// + public static Color RosyBrown + { + get; + private set; + } + + /// + /// RoyalBlue color (R:65,G:105,B:225,A:255). + /// + public static Color RoyalBlue + { + get; + private set; + } + + /// + /// SaddleBrown color (R:139,G:69,B:19,A:255). + /// + public static Color SaddleBrown + { + get; + private set; + } + + /// + /// Salmon color (R:250,G:128,B:114,A:255). + /// + public static Color Salmon + { + get; + private set; + } + + /// + /// SandyBrown color (R:244,G:164,B:96,A:255). + /// + public static Color SandyBrown + { + get; + private set; + } + + /// + /// SeaGreen color (R:46,G:139,B:87,A:255). + /// + public static Color SeaGreen + { + get; + private set; + } + + /// + /// SeaShell color (R:255,G:245,B:238,A:255). + /// + public static Color SeaShell + { + get; + private set; + } + + /// + /// Sienna color (R:160,G:82,B:45,A:255). + /// + public static Color Sienna + { + get; + private set; + } + + /// + /// Silver color (R:192,G:192,B:192,A:255). + /// + public static Color Silver + { + get; + private set; + } + + /// + /// SkyBlue color (R:135,G:206,B:235,A:255). + /// + public static Color SkyBlue + { + get; + private set; + } + + /// + /// SlateBlue color (R:106,G:90,B:205,A:255). + /// + public static Color SlateBlue + { + get; + private set; + } + + /// + /// SlateGray color (R:112,G:128,B:144,A:255). + /// + public static Color SlateGray + { + get; + private set; + } + + /// + /// Snow color (R:255,G:250,B:250,A:255). + /// + public static Color Snow + { + get; + private set; + } + + /// + /// SpringGreen color (R:0,G:255,B:127,A:255). + /// + public static Color SpringGreen + { + get; + private set; + } + + /// + /// SteelBlue color (R:70,G:130,B:180,A:255). + /// + public static Color SteelBlue + { + get; + private set; + } + + /// + /// Tan color (R:210,G:180,B:140,A:255). + /// + public static Color Tan + { + get; + private set; + } + + /// + /// Teal color (R:0,G:128,B:128,A:255). + /// + public static Color Teal + { + get; + private set; + } + + /// + /// Thistle color (R:216,G:191,B:216,A:255). + /// + public static Color Thistle + { + get; + private set; + } + + /// + /// Tomato color (R:255,G:99,B:71,A:255). + /// + public static Color Tomato + { + get; + private set; + } + + /// + /// Turquoise color (R:64,G:224,B:208,A:255). + /// + public static Color Turquoise + { + get; + private set; + } + + /// + /// Violet color (R:238,G:130,B:238,A:255). + /// + public static Color Violet + { + get; + private set; + } + + /// + /// Wheat color (R:245,G:222,B:179,A:255). + /// + public static Color Wheat + { + get; + private set; + } + + /// + /// White color (R:255,G:255,B:255,A:255). + /// + public static Color White + { + get; + private set; + } + + /// + /// WhiteSmoke color (R:245,G:245,B:245,A:255). + /// + public static Color WhiteSmoke + { + get; + private set; + } + + /// + /// Yellow color (R:255,G:255,B:0,A:255). + /// + public static Color Yellow + { + get; + private set; + } + + /// + /// YellowGreen color (R:154,G:205,B:50,A:255). + /// + public static Color YellowGreen + { + get; + private set; + } + + #endregion + + #region Internal Properties + + internal string DebugDisplayString + { + get + { + return string.Concat( + R.ToString(), " ", + G.ToString(), " ", + B.ToString(), " ", + A.ToString() + ); + } + } + + #endregion + + #region Private Variables + + // ARGB. Keep this name as it is used by XNA games in reflection! + private uint packedValue; + + #endregion + + #region Private Static Constructors + + static Color() + { + Transparent = new Color(0); + AliceBlue = new Color(0xfffff8f0); + AntiqueWhite = new Color(0xffd7ebfa); + Aqua = new Color(0xffffff00); + Aquamarine = new Color(0xffd4ff7f); + Azure = new Color(0xfffffff0); + Beige = new Color(0xffdcf5f5); + Bisque = new Color(0xffc4e4ff); + Black = new Color(0xff000000); + BlanchedAlmond = new Color(0xffcdebff); + Blue = new Color(0xffff0000); + BlueViolet = new Color(0xffe22b8a); + Brown = new Color(0xff2a2aa5); + BurlyWood = new Color(0xff87b8de); + CadetBlue = new Color(0xffa09e5f); + Chartreuse = new Color(0xff00ff7f); + Chocolate = new Color(0xff1e69d2); + Coral = new Color(0xff507fff); + CornflowerBlue = new Color(0xffed9564); + Cornsilk = new Color(0xffdcf8ff); + Crimson = new Color(0xff3c14dc); + Cyan = new Color(0xffffff00); + DarkBlue = new Color(0xff8b0000); + DarkCyan = new Color(0xff8b8b00); + DarkGoldenrod = new Color(0xff0b86b8); + DarkGray = new Color(0xffa9a9a9); + DarkGreen = new Color(0xff006400); + DarkKhaki = new Color(0xff6bb7bd); + DarkMagenta = new Color(0xff8b008b); + DarkOliveGreen = new Color(0xff2f6b55); + DarkOrange = new Color(0xff008cff); + DarkOrchid = new Color(0xffcc3299); + DarkRed = new Color(0xff00008b); + DarkSalmon = new Color(0xff7a96e9); + DarkSeaGreen = new Color(0xff8bbc8f); + DarkSlateBlue = new Color(0xff8b3d48); + DarkSlateGray = new Color(0xff4f4f2f); + DarkTurquoise = new Color(0xffd1ce00); + DarkViolet = new Color(0xffd30094); + DeepPink = new Color(0xff9314ff); + DeepSkyBlue = new Color(0xffffbf00); + DimGray = new Color(0xff696969); + DodgerBlue = new Color(0xffff901e); + Firebrick = new Color(0xff2222b2); + FloralWhite = new Color(0xfff0faff); + ForestGreen = new Color(0xff228b22); + Fuchsia = new Color(0xffff00ff); + Gainsboro = new Color(0xffdcdcdc); + GhostWhite = new Color(0xfffff8f8); + Gold = new Color(0xff00d7ff); + Goldenrod = new Color(0xff20a5da); + Gray = new Color(0xff808080); + Green = new Color(0xff008000); + GreenYellow = new Color(0xff2fffad); + Honeydew = new Color(0xfff0fff0); + HotPink = new Color(0xffb469ff); + IndianRed = new Color(0xff5c5ccd); + Indigo = new Color(0xff82004b); + Ivory = new Color(0xfff0ffff); + Khaki = new Color(0xff8ce6f0); + Lavender = new Color(0xfffae6e6); + LavenderBlush = new Color(0xfff5f0ff); + LawnGreen = new Color(0xff00fc7c); + LemonChiffon = new Color(0xffcdfaff); + LightBlue = new Color(0xffe6d8ad); + LightCoral = new Color(0xff8080f0); + LightCyan = new Color(0xffffffe0); + LightGoldenrodYellow = new Color(0xffd2fafa); + LightGray = new Color(0xffd3d3d3); + LightGreen = new Color(0xff90ee90); + LightPink = new Color(0xffc1b6ff); + LightSalmon = new Color(0xff7aa0ff); + LightSeaGreen = new Color(0xffaab220); + LightSkyBlue = new Color(0xffface87); + LightSlateGray = new Color(0xff998877); + LightSteelBlue = new Color(0xffdec4b0); + LightYellow = new Color(0xffe0ffff); + Lime = new Color(0xff00ff00); + LimeGreen = new Color(0xff32cd32); + Linen = new Color(0xffe6f0fa); + Magenta = new Color(0xffff00ff); + Maroon = new Color(0xff000080); + MediumAquamarine = new Color(0xffaacd66); + MediumBlue = new Color(0xffcd0000); + MediumOrchid = new Color(0xffd355ba); + MediumPurple = new Color(0xffdb7093); + MediumSeaGreen = new Color(0xff71b33c); + MediumSlateBlue = new Color(0xffee687b); + MediumSpringGreen = new Color(0xff9afa00); + MediumTurquoise = new Color(0xffccd148); + MediumVioletRed = new Color(0xff8515c7); + MidnightBlue = new Color(0xff701919); + MintCream = new Color(0xfffafff5); + MistyRose = new Color(0xffe1e4ff); + Moccasin = new Color(0xffb5e4ff); + NavajoWhite = new Color(0xffaddeff); + Navy = new Color(0xff800000); + OldLace = new Color(0xffe6f5fd); + Olive = new Color(0xff008080); + OliveDrab = new Color(0xff238e6b); + Orange = new Color(0xff00a5ff); + OrangeRed = new Color(0xff0045ff); + Orchid = new Color(0xffd670da); + PaleGoldenrod = new Color(0xffaae8ee); + PaleGreen = new Color(0xff98fb98); + PaleTurquoise = new Color(0xffeeeeaf); + PaleVioletRed = new Color(0xff9370db); + PapayaWhip = new Color(0xffd5efff); + PeachPuff = new Color(0xffb9daff); + Peru = new Color(0xff3f85cd); + Pink = new Color(0xffcbc0ff); + Plum = new Color(0xffdda0dd); + PowderBlue = new Color(0xffe6e0b0); + Purple = new Color(0xff800080); + Red = new Color(0xff0000ff); + RosyBrown = new Color(0xff8f8fbc); + RoyalBlue = new Color(0xffe16941); + SaddleBrown = new Color(0xff13458b); + Salmon= new Color(0xff7280fa); + SandyBrown = new Color(0xff60a4f4); + SeaGreen = new Color(0xff578b2e); + SeaShell = new Color(0xffeef5ff); + Sienna = new Color(0xff2d52a0); + Silver = new Color(0xffc0c0c0); + SkyBlue = new Color(0xffebce87); + SlateBlue= new Color(0xffcd5a6a); + SlateGray= new Color(0xff908070); + Snow= new Color(0xfffafaff); + SpringGreen= new Color(0xff7fff00); + SteelBlue= new Color(0xffb48246); + Tan= new Color(0xff8cb4d2); + Teal= new Color(0xff808000); + Thistle= new Color(0xffd8bfd8); + Tomato= new Color(0xff4763ff); + Turquoise= new Color(0xffd0e040); + Violet= new Color(0xffee82ee); + Wheat= new Color(0xffb3def5); + White= new Color(uint.MaxValue); + WhiteSmoke= new Color(0xfff5f5f5); + Yellow = new Color(0xff00ffff); + YellowGreen = new Color(0xff32cd9a); + } + + #endregion + + #region Public Constructors + + /// + /// Creates a new instance of struct. + /// + /// A representing a color. + public Color(Vector4 color) + { + packedValue = 0; + + R = (byte) MathHelper.Clamp(color.X * 255, Byte.MinValue, Byte.MaxValue); + G = (byte) MathHelper.Clamp(color.Y * 255, Byte.MinValue, Byte.MaxValue); + B = (byte) MathHelper.Clamp(color.Z * 255, Byte.MinValue, Byte.MaxValue); + A = (byte) MathHelper.Clamp(color.W * 255, Byte.MinValue, Byte.MaxValue); + } + + /// + /// Constructs an RGBA color from the XYZW unit length components of a vector. + /// + /// A representing a color. + public Color(Vector3 color) + { + packedValue = 0; + + R = (byte) MathHelper.Clamp(color.X * 255, Byte.MinValue, Byte.MaxValue); + G = (byte) MathHelper.Clamp(color.Y * 255, Byte.MinValue, Byte.MaxValue); + B = (byte) MathHelper.Clamp(color.Z * 255, Byte.MinValue, Byte.MaxValue); + A = 255; + } + + /// + /// Constructs an RGBA color from a and an alpha value. + /// + /// + /// A for RGB values of new instance. + /// + /// The alpha component value from 0 to 255. + public Color(Color color, int alpha) + { + packedValue = 0; + + R = color.R; + G = color.G; + B = color.B; + A = (byte) MathHelper.Clamp(alpha, Byte.MinValue, Byte.MaxValue); + } + + /// + /// Constructs an RGBA color from color and alpha value. + /// + /// + /// A for RGB values of new instance. + /// + /// Alpha component value from 0.0f to 1.0f. + public Color(Color color, float alpha) + { + packedValue = 0; + + R = color.R; + G = color.G; + B = color.B; + A = (byte) MathHelper.Clamp(alpha * 255, Byte.MinValue, Byte.MaxValue); + } + + /// + /// Constructs an RGBA color from scalars which representing red, green and blue values. Alpha value will be opaque. + /// + /// Red component value from 0.0f to 1.0f. + /// Green component value from 0.0f to 1.0f. + /// Blue component value from 0.0f to 1.0f. + public Color(float r, float g, float b) + { + packedValue = 0; + + R = (byte) MathHelper.Clamp(r * 255, Byte.MinValue, Byte.MaxValue); + G = (byte) MathHelper.Clamp(g * 255, Byte.MinValue, Byte.MaxValue); + B = (byte) MathHelper.Clamp(b * 255, Byte.MinValue, Byte.MaxValue); + A = 255; + } + + /// + /// Constructs an RGBA color from scalars which representing red, green and blue values. Alpha value will be opaque. + /// + /// Red component value from 0 to 255. + /// Green component value from 0 to 255. + /// Blue component value from 0 to 255. + public Color(int r, int g, int b) + { + packedValue = 0; + R = (byte) MathHelper.Clamp(r, Byte.MinValue, Byte.MaxValue); + G = (byte) MathHelper.Clamp(g, Byte.MinValue, Byte.MaxValue); + B = (byte) MathHelper.Clamp(b, Byte.MinValue, Byte.MaxValue); + A = (byte)255; + } + + /// + /// Constructs an RGBA color from scalars which representing red, green, blue and alpha values. + /// + /// Red component value from 0 to 255. + /// Green component value from 0 to 255. + /// Blue component value from 0 to 255. + /// Alpha component value from 0 to 255. + public Color(int r, int g, int b, int alpha) + { + packedValue = 0; + R = (byte) MathHelper.Clamp(r, Byte.MinValue, Byte.MaxValue); + G = (byte) MathHelper.Clamp(g, Byte.MinValue, Byte.MaxValue); + B = (byte) MathHelper.Clamp(b, Byte.MinValue, Byte.MaxValue); + A = (byte) MathHelper.Clamp(alpha, Byte.MinValue, Byte.MaxValue); + } + + /// + /// Constructs an RGBA color from scalars which representing red, green, blue and alpha values. + /// + /// Red component value from 0.0f to 1.0f. + /// Green component value from 0.0f to 1.0f. + /// Blue component value from 0.0f to 1.0f. + /// Alpha component value from 0.0f to 1.0f. + public Color(float r, float g, float b, float alpha) + { + packedValue = 0; + + R = (byte) MathHelper.Clamp(r * 255, Byte.MinValue, Byte.MaxValue); + G = (byte) MathHelper.Clamp(g * 255, Byte.MinValue, Byte.MaxValue); + B = (byte) MathHelper.Clamp(b * 255, Byte.MinValue, Byte.MaxValue); + A = (byte) MathHelper.Clamp(alpha * 255, Byte.MinValue, Byte.MaxValue); + } + + #endregion + + #region Private Constructors + + private Color(uint packedValue) + { + this.packedValue = packedValue; + } + + #endregion + + #region Public Methods + + /// + /// Compares whether current instance is equal to specified . + /// + /// The to compare. + /// true if the instances are equal; false otherwise. + public bool Equals(Color other) + { + return this.PackedValue == other.PackedValue; + } + + /// + /// Gets a representation for this object. + /// + /// A representation for this object. + public Vector3 ToVector3() + { + return new Vector3(R / 255.0f, G / 255.0f, B / 255.0f); + } + + /// + /// Gets a representation for this object. + /// + /// A representation for this object. + public Vector4 ToVector4() + { + return new Vector4(R / 255.0f, G / 255.0f, B / 255.0f, A / 255.0f); + } + + #endregion + + #region Public Static Methods + + /// + /// Performs linear interpolation of . + /// + /// Source . + /// Destination . + /// Interpolation factor. + /// Interpolated . + public static Color Lerp(Color value1, Color value2, float amount) + { + amount = MathHelper.Clamp(amount, 0.0f, 1.0f); + return new Color( + (int) MathHelper.Lerp(value1.R, value2.R, amount), + (int) MathHelper.Lerp(value1.G, value2.G, amount), + (int) MathHelper.Lerp(value1.B, value2.B, amount), + (int) MathHelper.Lerp(value1.A, value2.A, amount) + ); + } + + /// + /// Translate a non-premultipled alpha to a + /// that contains premultiplied alpha. + /// + /// A representing color. + /// A which contains premultiplied alpha data. + public static Color FromNonPremultiplied(Vector4 vector) + { + return new Color( + vector.X * vector.W, + vector.Y * vector.W, + vector.Z * vector.W, + vector.W + ); + } + + /// + /// Translate a non-premultipled alpha to a + /// that contains premultiplied alpha. + /// + /// Red component value. + /// Green component value. + /// Blue component value. + /// Alpha component value. + /// A which contains premultiplied alpha data. + public static Color FromNonPremultiplied(int r, int g, int b, int a) + { + return new Color( + (r * a / 255), + (g * a / 255), + (b * a / 255), + a + ); + } + + #endregion + + #region Public Static Operators and Override Methods + + /// + /// Compares whether two instances are equal. + /// + /// instance on the left of the equal sign. + /// instance on the right of the equal sign. + /// True if the instances are equal; false otherwise. + public static bool operator ==(Color a, Color b) + { + return ( a.A == b.A && + a.R == b.R && + a.G == b.G && + a.B == b.B ); + } + + /// + /// Compares whether two instances are not equal. + /// + /// + /// instance on the left of the not equal sign. + /// + /// + /// instance on the right of the not equal sign. + /// + /// + /// True if the instances are not equal; false otherwise. + /// + public static bool operator !=(Color a, Color b) + { + return !(a == b); + } + + /// + /// Gets the hash code of this . + /// + /// Hash code of this . + public override int GetHashCode() + { + return this.packedValue.GetHashCode(); + } + + /// + /// Compares whether current instance is equal to specified object. + /// + /// The to compare. + /// True if the instances are equal; false otherwise. + public override bool Equals(object obj) + { + return ((obj is Color) && this.Equals((Color) obj)); + } + + /// + /// Multiply by value. + /// + /// Source . + /// Multiplicator. + /// Multiplication result. + public static Color Multiply(Color value, float scale) + { + return new Color( + (int) (value.R * scale), + (int) (value.G * scale), + (int) (value.B * scale), + (int) (value.A * scale) + ); + } + + /// + /// Multiply by value. + /// + /// Source . + /// Multiplicator. + /// Multiplication result. + public static Color operator *(Color value, float scale) + { + return new Color( + (int) (value.R * scale), + (int) (value.G * scale), + (int) (value.B * scale), + (int) (value.A * scale) + ); + } + + /// + /// Returns a representation of this in the format: + /// {R:[red] G:[green] B:[blue] A:[alpha]} + /// + /// representation of this . + public override string ToString() + { + StringBuilder sb = new StringBuilder(25); + sb.Append("{R:"); + sb.Append(R); + sb.Append(" G:"); + sb.Append(G); + sb.Append(" B:"); + sb.Append(B); + sb.Append(" A:"); + sb.Append(A); + sb.Append("}"); + return sb.ToString(); + } + + #endregion + + #region IPackedVector Member + + /// + /// Pack a four-component color from a vector format into the format of a color object. + /// + /// A four-component color. + void IPackedVector.PackFromVector4(Vector4 vector) + { + // Should we round here? + R = (byte) (vector.X * 255.0f); + G = (byte) (vector.Y * 255.0f); + B = (byte) (vector.Z * 255.0f); + A = (byte) (vector.W * 255.0f); + } + + #endregion + + } +} diff --git a/FNA/src/ContainmentType.cs b/FNA/src/ContainmentType.cs new file mode 100644 index 0000000..2d36442 --- /dev/null +++ b/FNA/src/ContainmentType.cs @@ -0,0 +1,34 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework +{ + /// + /// Defines how the bounding volumes intersects or contain one another. + /// + public enum ContainmentType + { + /// + /// Indicates that there is no overlap between two bounding volumes. + /// + Disjoint, + /// + /// Indicates that one bounding volume completely contains another volume. + /// + Contains, + /// + /// Indicates that bounding volumes partially overlap one another. + /// + Intersects + } +} diff --git a/FNA/src/Content/ContentExtensions.cs b/FNA/src/Content/ContentExtensions.cs new file mode 100644 index 0000000..07210bd --- /dev/null +++ b/FNA/src/Content/ContentExtensions.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Reflection; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal static class ContentExtensions + { + #region Public Static Constructor Extractor Method + + public static ConstructorInfo GetDefaultConstructor(this Type type) + { + return type.GetConstructor( + BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, + null, + new Type[0], + null + ); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentLoadException.cs b/FNA/src/Content/ContentLoadException.cs new file mode 100644 index 0000000..6b4cb71 --- /dev/null +++ b/FNA/src/Content/ContentLoadException.cs @@ -0,0 +1,35 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + public class ContentLoadException : Exception + { + #region Public Constructors + + public ContentLoadException() : base() + { + } + + public ContentLoadException(string message) : base(message) + { + } + + public ContentLoadException(string message, Exception innerException) : base(message,innerException) + { + } + + #endregion + } +} + diff --git a/FNA/src/Content/ContentManager.cs b/FNA/src/Content/ContentManager.cs new file mode 100644 index 0000000..1dc8f7b --- /dev/null +++ b/FNA/src/Content/ContentManager.cs @@ -0,0 +1,631 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Reflection; + +using Microsoft.Xna.Framework.Audio; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Media; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + public partial class ContentManager : IDisposable + { + #region Public ServiceProvider Property + + public IServiceProvider ServiceProvider + { + get; + private set; + } + + #endregion + + #region Public RootDirectory Property + + public string RootDirectory + { + get; + set; + } + + #endregion + + #region Internal Root Directory Path Property + + internal string RootDirectoryFullPath + { + get + { + if (Path.IsPathRooted(RootDirectory)) + { + return RootDirectory; + } + return Path.Combine(TitleLocation.Path, RootDirectory); + } + } + + #endregion + + #region Private Variables + + private IGraphicsDeviceService graphicsDeviceService; + private Dictionary loadedAssets = new Dictionary(StringComparer.OrdinalIgnoreCase); + private List disposableAssets = new List(); + private bool disposed; + + #endregion + + #region Private Static Variables + + private static object ContentManagerLock = new object(); + private static List ContentManagers = new List(); + + private static readonly byte[] xnbHeader = new byte[4]; + private static List targetPlatformIdentifiers = new List() + { + 'w', // Windows (DirectX) + 'x', // Xbox360 + 'm', // WindowsPhone + 'i', // iOS + 'a', // Android + 'd', // DesktopGL + 'X', // MacOSX + 'W', // WindowsStoreApp + 'n', // NativeClient + 'u', // Ouya + 'p', // PlayStationMobile + 'M', // WindowsPhone8 + 'r', // RaspberryPi + 'P', // Playstation 4 + 'g', // WindowsGL (deprecated for DesktopGL) + 'l', // Linux (deprecated for DesktopGL) + }; + + #endregion + + #region Public Constructors + + public ContentManager(IServiceProvider serviceProvider) + { + if (serviceProvider == null) + { + throw new ArgumentNullException("serviceProvider"); + } + ServiceProvider = serviceProvider; + RootDirectory = string.Empty; + AddContentManager(this); + } + + public ContentManager(IServiceProvider serviceProvider, string rootDirectory) + { + if (serviceProvider == null) + { + throw new ArgumentNullException("serviceProvider"); + } + if (rootDirectory == null) + { + throw new ArgumentNullException("rootDirectory"); + } + ServiceProvider = serviceProvider; + RootDirectory = rootDirectory; + AddContentManager(this); + } + + #endregion + + #region Destructor + + /* Use C# destructor syntax for finalization code. + * This destructor will run only if the Dispose method + * does not get called. + * It gives your base class the opportunity to finalize. + * Do not provide destructors in types derived from this class. + */ + ~ContentManager() + { + /* Do not re-create Dispose clean-up code here. + * Calling Dispose(false) is optimal in terms of + * readability and maintainability. + */ + Dispose(false); + } + + #endregion + + #region Dispose Methods + + public void Dispose() + { + Dispose(true); + /* Tell the garbage collector not to call the finalizer + * since all the cleanup will already be done. + */ + GC.SuppressFinalize(this); + // Once disposed, content manager wont be used again + RemoveContentManager(this); + } + + /* If disposing is true, it was called explicitly and we should dispose managed + * objects. If disposing is false, it was called by the finalizer and managed + * objects should not be disposed. + */ + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + Unload(); + } + disposed = true; + } + } + + #endregion + + #region Public Methods + + public virtual T Load(string assetName) + { + if (string.IsNullOrEmpty(assetName)) + { + throw new ArgumentNullException("assetName"); + } + if (disposed) + { + throw new ObjectDisposedException("ContentManager"); + } + T result = default(T); + + /* On some platforms, name and slash direction matter. + * We store the asset by a /-separating key rather than + * how the path to the file was passed to us to avoid + * loading "content/asset1.xnb" and "content\\ASSET1.xnb" + * as if they were two different files. this matches + * stock XNA behavior. The Dictionary will ignore case + * differences. + */ + string key = assetName.Replace('\\', '/'); + + // Check for a previously loaded asset first + object asset = null; + if (loadedAssets.TryGetValue(key, out asset)) + { + if (asset is T) + { + return (T) asset; + } + } + // Load the asset. + result = ReadAsset(assetName, null); + loadedAssets[key] = result; + return result; + } + + public virtual void Unload() + { + // Look for disposable assets. + foreach (IDisposable disposable in disposableAssets) + { + if (disposable != null) + { + disposable.Dispose(); + } + } + disposableAssets.Clear(); + loadedAssets.Clear(); + } + + #endregion + + #region Protected Methods + + protected virtual Stream OpenStream(string assetName) + { + Stream stream; + try + { + stream = TitleContainer.OpenStream( + Path.Combine(RootDirectory, assetName) + ".xnb" + ); + } + catch (FileNotFoundException fileNotFound) + { + throw new ContentLoadException("The content file was not found.", fileNotFound); + } + catch (DirectoryNotFoundException directoryNotFound) + { + throw new ContentLoadException("The directory was not found.", directoryNotFound); + } + catch (Exception exception) + { + throw new ContentLoadException("Opening stream error.", exception); + } + return stream; + } + + protected T ReadAsset(string assetName, Action recordDisposableObject) + { + if (string.IsNullOrEmpty(assetName)) + { + throw new ArgumentNullException("assetName"); + } + if (disposed) + { + throw new ObjectDisposedException("ContentManager"); + } + + object result = null; + + // FIXME: Should this block be here? -flibit + if (graphicsDeviceService == null) + { + graphicsDeviceService = ServiceProvider.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService; + if (graphicsDeviceService == null) + { + throw new InvalidOperationException("No Graphics Device Service"); + } + } + + Stream stream = null; + string modifiedAssetName = String.Empty; // Will be used if we have to guess a filename + try + { + stream = OpenStream(assetName); + } + catch (Exception e) + { + // Okay, so we couldn't open it. Maybe it needs a different extension? + // FIXME: This only works for files on the disk, what about custom streams? -flibit + modifiedAssetName = MonoGame.Utilities.FileHelpers.NormalizeFilePathSeparators( + Path.Combine(RootDirectoryFullPath, assetName) + ); + if (typeof(T) == typeof(Texture2D) || typeof(T) == typeof(Texture)) + { + modifiedAssetName = Texture2DReader.Normalize(modifiedAssetName); + } + else if ((typeof(T) == typeof(SoundEffect))) + { + modifiedAssetName = SoundEffectReader.Normalize(modifiedAssetName); + } + else if ((typeof(T) == typeof(Effect))) + { + modifiedAssetName = EffectReader.Normalize(modifiedAssetName); + } + else if ((typeof(T) == typeof(Song))) + { + modifiedAssetName = SongReader.Normalize(modifiedAssetName); + } + else if ((typeof(T) == typeof(Video))) + { + modifiedAssetName = VideoReader.Normalize(modifiedAssetName); + } + + // Did we get anything...? + if (String.IsNullOrEmpty(modifiedAssetName)) + { + // Nope, nothing we're aware of! + throw new ContentLoadException( + "Could not load asset " + assetName + "! Error: " + e.Message, + e + ); + } + + stream = TitleContainer.OpenStream(modifiedAssetName); + } + + // Check for XNB header + stream.Read(xnbHeader, 0, xnbHeader.Length); + if ( xnbHeader[0] == 'X' && + xnbHeader[1] == 'N' && + xnbHeader[2] == 'B' && + targetPlatformIdentifiers.Contains((char) xnbHeader[3]) ) + { + using (BinaryReader xnbReader = new BinaryReader(stream)) + using (ContentReader reader = GetContentReaderFromXnb(assetName, ref stream, xnbReader, (char) xnbHeader[3], recordDisposableObject)) + { + result = reader.ReadAsset(); + GraphicsResource resource = result as GraphicsResource; + if (resource != null) + { + resource.Name = assetName; + } + } + } + else + { + // It's not an XNB file. Try to load as a raw asset instead. + + // FIXME: Assuming seekable streams! -flibit + stream.Seek(0, SeekOrigin.Begin); + + if (typeof(T) == typeof(Texture2D) || typeof(T) == typeof(Texture)) + { + Texture2D texture; + if ( xnbHeader[0] == 'D' && + xnbHeader[1] == 'D' && + xnbHeader[2] == 'S' && + xnbHeader[3] == ' ' ) + { + texture = Texture2D.DDSFromStreamEXT( + graphicsDeviceService.GraphicsDevice, + stream + ); + } + else + { + texture = Texture2D.FromStream( + graphicsDeviceService.GraphicsDevice, + stream + ); + } + texture.Name = assetName; + result = texture; + } + else if ((typeof(T) == typeof(SoundEffect))) + { + result = SoundEffect.FromStream(stream); + } + else if ((typeof(T) == typeof(Effect))) + { + byte[] data = new byte[stream.Length]; + stream.Read(data, 0, (int) stream.Length); + result = new Effect(graphicsDeviceService.GraphicsDevice, data); + } + else if ((typeof(T) == typeof(Song))) + { + // FIXME: Not using the stream! -flibit + result = new Song(modifiedAssetName); + } + else if ((typeof(T) == typeof(Video))) + { + // FIXME: Not using the stream! -flibit + result = new Video(modifiedAssetName, graphicsDeviceService.GraphicsDevice); + FNALoggerEXT.LogWarn( + "Video " + + modifiedAssetName + + " does not have an XNB file! Hacking Duration property!" + ); + } + else + { + stream.Close(); + throw new ContentLoadException("Could not load " + assetName + " asset!"); + } + + /* Because Raw Assets skip the ContentReader step, they need to have their + * disposables recorded here. Doing it outside of this catch will + * result in disposables being logged twice. + */ + IDisposable disposableResult = result as IDisposable; + if (disposableResult != null) + { + if (recordDisposableObject != null) + { + recordDisposableObject(disposableResult); + } + else + { + disposableAssets.Add(disposableResult); + } + } + + /* Because we're not using a BinaryReader for raw assets, we + * need to close the stream ourselves. + * -flibit + */ + stream.Close(); + } + + return (T) result; + } + + #endregion + + #region Internal Methods + + internal void RecordDisposable(IDisposable disposable) + { + Debug.Assert(disposable != null, "The disposable is null!"); + + /* Avoid recording disposable objects twice. ReloadAsset will try to record + * the disposables again. We don't know which asset recorded which + * disposable so just guard against storing multiple of the same instance. + */ + if (!disposableAssets.Contains(disposable)) + { + disposableAssets.Add(disposable); + } + } + + #endregion + + #region Private Methods + + private ContentReader GetContentReaderFromXnb(string originalAssetName, ref Stream stream, BinaryReader xnbReader, char platform, Action recordDisposableObject) + { + byte version = xnbReader.ReadByte(); + byte flags = xnbReader.ReadByte(); + bool compressed = (flags & 0x80) != 0; + if (version != 5 && version != 4) + { + throw new ContentLoadException("Invalid XNB version"); + } + // The next int32 is the length of the XNB file + int xnbLength = xnbReader.ReadInt32(); + ContentReader reader; + if (compressed) + { + /* Decompress the XNB + * Thanks to ShinAli (https://bitbucket.org/alisci01/xnbdecompressor) + */ + int compressedSize = xnbLength - 14; + int decompressedSize = xnbReader.ReadInt32(); + + // This will replace the XNB stream at the end + MemoryStream decompressedStream = new MemoryStream( + new byte[decompressedSize], + 0, + decompressedSize, + true, + true // This MUST be true! Readers may need GetBuffer()! + ); + + /* Read in the whole XNB file at once, into a temp buffer. + * For slow disks, the extra malloc is more than worth the + * performance improvement from not constantly fread()ing! + */ + MemoryStream compressedStream = new MemoryStream( + new byte[compressedSize], + 0, + compressedSize, + true, + true + ); + stream.Read(compressedStream.GetBuffer(), 0, compressedSize); + + // Default window size for XNB encoded files is 64Kb (need 16 bits to represent it) + LzxDecoder dec = new LzxDecoder(16); + int decodedBytes = 0; + long pos = 0; + + while (pos < compressedSize) + { + /* The compressed stream is separated into blocks that will + * decompress into 32kB or some other size if specified. + * Normal, 32kB output blocks will have a short indicating + * the size of the block before the block starts. Blocks + * that have a defined output will be preceded by a byte of + * value 0xFF (255), then a short indicating the output size + * and another for the block size. All shorts for these + * cases are encoded in big endian order. + */ + int hi = compressedStream.ReadByte(); + int lo = compressedStream.ReadByte(); + int block_size = (hi << 8) | lo; + int frame_size = 0x8000; // Frame size is 32kB by default + // Does this block define a frame size? + if (hi == 0xFF) + { + hi = lo; + lo = (byte) compressedStream.ReadByte(); + frame_size = (hi << 8) | lo; + hi = (byte) compressedStream.ReadByte(); + lo = (byte) compressedStream.ReadByte(); + block_size = (hi << 8) | lo; + pos += 5; + } + else + { + pos += 2; + } + // Either says there is nothing to decode + if (block_size == 0 || frame_size == 0) + { + break; + } + dec.Decompress(compressedStream, block_size, decompressedStream, frame_size); + pos += block_size; + decodedBytes += frame_size; + /* Reset the position of the input just in case the bit + * buffer read in some unused bytes. + */ + compressedStream.Seek(pos, SeekOrigin.Begin); + } + if (decompressedStream.Position != decompressedSize) + { + throw new ContentLoadException( + "Decompression of " + originalAssetName + " failed. " + ); + } + decompressedStream.Seek(0, SeekOrigin.Begin); + reader = new ContentReader( + this, + decompressedStream, + graphicsDeviceService.GraphicsDevice, + originalAssetName, + version, + platform, + recordDisposableObject + ); + } + else + { + reader = new ContentReader( + this, + stream, + graphicsDeviceService.GraphicsDevice, + originalAssetName, + version, + platform, + recordDisposableObject + ); + } + return reader; + } + + #endregion + + #region Private Static Methods + + private static void AddContentManager(ContentManager contentManager) + { + lock (ContentManagerLock) + { + /* Check if the list contains this content manager already. Also take + * the opportunity to prune the list of any finalized content managers. + */ + bool contains = false; + for (int i = ContentManagers.Count - 1; i >= 0; i -= 1) + { + WeakReference contentRef = ContentManagers[i]; + if (ReferenceEquals(contentRef.Target, contentManager)) + { + contains = true; + } + if (!contentRef.IsAlive) + { + ContentManagers.RemoveAt(i); + } + } + if (!contains) + { + ContentManagers.Add(new WeakReference(contentManager)); + } + } + } + + private static void RemoveContentManager(ContentManager contentManager) + { + lock (ContentManagerLock) + { + /* Check if the list contains this content manager and remove it. Also + * take the opportunity to prune the list of any finalized content managers. + */ + for (int i = ContentManagers.Count - 1; i >= 0; i -= 1) + { + WeakReference contentRef = ContentManagers[i]; + if (!contentRef.IsAlive || ReferenceEquals(contentRef.Target, contentManager)) + { + ContentManagers.RemoveAt(i); + } + } + } + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReader.cs b/FNA/src/Content/ContentReader.cs new file mode 100644 index 0000000..abe70bb --- /dev/null +++ b/FNA/src/Content/ContentReader.cs @@ -0,0 +1,367 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.IO; + +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + public sealed class ContentReader : BinaryReader + { + #region Public Properties + + public ContentManager ContentManager + { + get + { + return contentManager; + } + } + + public string AssetName + { + get + { + return assetName; + } + } + + #endregion + + #region Internal Properties + + internal ContentTypeReader[] TypeReaders + { + get + { + return typeReaders; + } + } + + internal GraphicsDevice GraphicsDevice + { + get + { + return this.graphicsDevice; + } + } + + #endregion + + #region Internal Variables + + internal int version; + internal int sharedResourceCount; + internal char platform; + + #endregion + + #region Private Variables + + private ContentManager contentManager; + private Action recordDisposableObject; + private ContentTypeReaderManager typeReaderManager; + private GraphicsDevice graphicsDevice; + private string assetName; + private List>> sharedResourceFixups; + private ContentTypeReader[] typeReaders; + + #endregion + + #region Internal Constructor + + internal ContentReader( + ContentManager manager, + Stream stream, + GraphicsDevice graphicsDevice, + string assetName, + int version, + char platform, + Action recordDisposableObject + ) : base(stream) { + this.graphicsDevice = graphicsDevice; + this.recordDisposableObject = recordDisposableObject; + this.contentManager = manager; + this.assetName = assetName; + this.version = version; + this.platform = platform; + } + + #endregion + + #region Public Read Methods + + public T ReadExternalReference() + { + string externalReference = ReadString(); + if (!String.IsNullOrEmpty(externalReference)) + { + return contentManager.Load( + MonoGame.Utilities.FileHelpers.ResolveRelativePath(assetName, externalReference) + ); + } + return default(T); + } + + public Matrix ReadMatrix() + { + Matrix result = new Matrix(); + result.M11 = ReadSingle(); + result.M12 = ReadSingle(); + result.M13 = ReadSingle(); + result.M14 = ReadSingle(); + result.M21 = ReadSingle(); + result.M22 = ReadSingle(); + result.M23 = ReadSingle(); + result.M24 = ReadSingle(); + result.M31 = ReadSingle(); + result.M32 = ReadSingle(); + result.M33 = ReadSingle(); + result.M34 = ReadSingle(); + result.M41 = ReadSingle(); + result.M42 = ReadSingle(); + result.M43 = ReadSingle(); + result.M44 = ReadSingle(); + return result; + } + + public T ReadObject() + { + return ReadObject(default(T)); + } + + public T ReadObject(ContentTypeReader typeReader) + { + T result = (T) typeReader.Read(this, default(T)); + RecordDisposable(result); + return result; + } + + public T ReadObject(T existingInstance) + { + return InnerReadObject(existingInstance); + } + + public T ReadObject(ContentTypeReader typeReader, T existingInstance) + { + if (!typeReader.TargetType.IsValueType) + { + return ReadObject(existingInstance); + } + T result = (T) typeReader.Read(this, existingInstance); + RecordDisposable(result); + return result; + } + + public Quaternion ReadQuaternion() + { + Quaternion result = new Quaternion(); + result.X = ReadSingle(); + result.Y = ReadSingle(); + result.Z = ReadSingle(); + result.W = ReadSingle(); + return result; + } + + public T ReadRawObject() + { + return (T) ReadRawObject(default(T)); + } + + public T ReadRawObject(ContentTypeReader typeReader) + { + return (T) ReadRawObject(typeReader, default(T)); + } + + public T ReadRawObject(T existingInstance) + { + Type objectType = typeof(T); + foreach (ContentTypeReader typeReader in typeReaders) + { + if (typeReader.TargetType == objectType) + { + return (T) ReadRawObject(typeReader,existingInstance); + } + } + throw new NotSupportedException(); + } + + public T ReadRawObject(ContentTypeReader typeReader, T existingInstance) + { + return (T) typeReader.Read(this, existingInstance); + } + + public void ReadSharedResource(Action fixup) + { + int index = Read7BitEncodedInt(); + if (index > 0) + { + sharedResourceFixups.Add( + new KeyValuePair> ( + index - 1, + delegate(object v) + { + if (!(v is T)) + { + throw new ContentLoadException( + String.Format( + "Error loading shared resource. Expected type {0}, received type {1}", + typeof(T).Name, v.GetType().Name + ) + ); + } + fixup((T) v); + } + ) + ); + } + } + + public Vector2 ReadVector2() + { + Vector2 result = new Vector2(); + result.X = ReadSingle(); + result.Y = ReadSingle(); + return result; + } + + public Vector3 ReadVector3() + { + Vector3 result = new Vector3(); + result.X = ReadSingle(); + result.Y = ReadSingle(); + result.Z = ReadSingle(); + return result; + } + + public Vector4 ReadVector4() + { + Vector4 result = new Vector4(); + result.X = ReadSingle(); + result.Y = ReadSingle(); + result.Z = ReadSingle(); + result.W = ReadSingle(); + return result; + } + + public Color ReadColor() + { + Color result = new Color(); + result.R = ReadByte(); + result.G = ReadByte(); + result.B = ReadByte(); + result.A = ReadByte(); + return result; + } + + #endregion + + #region Internal Methods + + internal object ReadAsset() + { + InitializeTypeReaders(); + // Read primary object + object result = ReadObject(); + // Read shared resources + ReadSharedResources(); + return result; + } + + internal void InitializeTypeReaders() + { + typeReaderManager = new ContentTypeReaderManager(); + typeReaders = typeReaderManager.LoadAssetReaders(this); + sharedResourceCount = Read7BitEncodedInt(); + sharedResourceFixups = new List>>(); + } + + internal void ReadSharedResources() + { + if (sharedResourceCount <= 0) + { + return; + } + + object[] sharedResources = new object[sharedResourceCount]; + for (int i = 0; i < sharedResourceCount; i += 1) + { + sharedResources[i] = InnerReadObject(null); + } + // Fixup shared resources by calling each registered action + foreach (KeyValuePair> fixup in sharedResourceFixups) + { + fixup.Value(sharedResources[fixup.Key]); + } + } + + internal new int Read7BitEncodedInt() + { + return base.Read7BitEncodedInt(); + } + + internal BoundingSphere ReadBoundingSphere() + { + Vector3 position = ReadVector3(); + float radius = ReadSingle(); + return new BoundingSphere(position, radius); + } + + #endregion + + #region Private Methods + + private T InnerReadObject(T existingInstance) + { + int typeReaderIndex = Read7BitEncodedInt(); + if (typeReaderIndex == 0) + { + return existingInstance; + } + if (typeReaderIndex > typeReaders.Length) + { + throw new ContentLoadException( + "Incorrect type reader index found!" + ); + } + ContentTypeReader typeReader = typeReaders[typeReaderIndex - 1]; + T result = (T) typeReader.Read(this, default(T)); + RecordDisposable(result); + return result; + } + + private void RecordDisposable(T result) + { + IDisposable disposable = result as IDisposable; + if (disposable == null) + { + return; + } + if (recordDisposableObject != null) + { + recordDisposableObject(disposable); + } + else + { + contentManager.RecordDisposable(disposable); + } + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/AlphaTestEffectReader.cs b/FNA/src/Content/ContentReaders/AlphaTestEffectReader.cs new file mode 100644 index 0000000..219218a --- /dev/null +++ b/FNA/src/Content/ContentReaders/AlphaTestEffectReader.cs @@ -0,0 +1,34 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + class AlphaTestEffectReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override AlphaTestEffect Read(ContentReader input, AlphaTestEffect existingInstance) + { + AlphaTestEffect effect = new AlphaTestEffect(input.GraphicsDevice); + effect.Texture = input.ReadExternalReference() as Texture2D; + effect.AlphaFunction = (CompareFunction) input.ReadInt32(); + effect.ReferenceAlpha = (int) input.ReadUInt32(); + effect.DiffuseColor = input.ReadVector3(); + effect.Alpha = input.ReadSingle(); + effect.VertexColorEnabled = input.ReadBoolean(); + return effect; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/ArrayReader.cs b/FNA/src/Content/ContentReaders/ArrayReader.cs new file mode 100644 index 0000000..04b4d59 --- /dev/null +++ b/FNA/src/Content/ContentReaders/ArrayReader.cs @@ -0,0 +1,85 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class ArrayReader : ContentTypeReader + { + #region Private ContentTypeReader Instance + + ContentTypeReader elementReader; + + #endregion + + #region Public Constructor + + public ArrayReader() + { + } + + #endregion + + #region Protected Initialization Method + + protected internal override void Initialize(ContentTypeReaderManager manager) + { + Type readerType = typeof(T); + elementReader = manager.GetTypeReader(readerType); + } + + #endregion + + #region Protected Read Method + + protected internal override T[] Read(ContentReader input, T[] existingInstance) + { + uint count = input.ReadUInt32(); + T[] array = existingInstance; + if (array == null) + { + array = new T[count]; + } + + if (typeof(T).IsValueType) + { + for (uint i = 0; i < count; i += 1) + { + array[i] = input.ReadObject(elementReader); + } + } + else + { + for (uint i = 0; i < count; i += 1) + { + int readerType = input.Read7BitEncodedInt(); + if (readerType > 0) + { + array[i] = input.ReadObject( + input.TypeReaders[readerType - 1] + ); + } + else { + array[i] = default(T); + } + } + } + return array; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/BasicEffectReader.cs b/FNA/src/Content/ContentReaders/BasicEffectReader.cs new file mode 100644 index 0000000..4de9661 --- /dev/null +++ b/FNA/src/Content/ContentReaders/BasicEffectReader.cs @@ -0,0 +1,42 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class BasicEffectReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override BasicEffect Read( + ContentReader input, + BasicEffect existingInstance + ) { + BasicEffect effect = new BasicEffect(input.GraphicsDevice); + Texture2D texture = input.ReadExternalReference() as Texture2D; + if (texture != null) + { + effect.Texture = texture; + effect.TextureEnabled = true; + } + effect.DiffuseColor = input.ReadVector3(); + effect.EmissiveColor = input.ReadVector3(); + effect.SpecularColor = input.ReadVector3(); + effect.SpecularPower = input.ReadSingle(); + effect.Alpha = input.ReadSingle(); + effect.VertexColorEnabled = input.ReadBoolean(); + return effect; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/BooleanReader.cs b/FNA/src/Content/ContentReaders/BooleanReader.cs new file mode 100644 index 0000000..20fdcd2 --- /dev/null +++ b/FNA/src/Content/ContentReaders/BooleanReader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class BooleanReader : ContentTypeReader + { + #region Internal Constructor + + internal BooleanReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override bool Read( + ContentReader input, + bool existingInstance + ) { + return input.ReadBoolean(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/BoundingBoxReader.cs b/FNA/src/Content/ContentReaders/BoundingBoxReader.cs new file mode 100644 index 0000000..c951d9e --- /dev/null +++ b/FNA/src/Content/ContentReaders/BoundingBoxReader.cs @@ -0,0 +1,29 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + class BoundingBoxReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override BoundingBox Read( + ContentReader input, + BoundingBox existingInstance + ) { + BoundingBox result = new BoundingBox( + input.ReadVector3(), + input.ReadVector3() + ); + return result; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/BoundingFrustumReader.cs b/FNA/src/Content/ContentReaders/BoundingFrustumReader.cs new file mode 100644 index 0000000..2d7c164 --- /dev/null +++ b/FNA/src/Content/ContentReaders/BoundingFrustumReader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class BoundingFrustumReader : ContentTypeReader + { + #region Internal Constructor + + internal BoundingFrustumReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override BoundingFrustum Read( + ContentReader input, + BoundingFrustum existingInstance + ) { + return new BoundingFrustum(input.ReadMatrix()); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/BoundingSphereReader.cs b/FNA/src/Content/ContentReaders/BoundingSphereReader.cs new file mode 100644 index 0000000..c5c6d08 --- /dev/null +++ b/FNA/src/Content/ContentReaders/BoundingSphereReader.cs @@ -0,0 +1,35 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class BoundingSphereReader : ContentTypeReader + { + #region Internal Constructor + + internal BoundingSphereReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override BoundingSphere Read( + ContentReader input, + BoundingSphere existingInstance + ) { + Vector3 center = input.ReadVector3(); + float radius = input.ReadSingle(); + return new BoundingSphere(center, radius); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/ByteReader.cs b/FNA/src/Content/ContentReaders/ByteReader.cs new file mode 100644 index 0000000..fe8b097 --- /dev/null +++ b/FNA/src/Content/ContentReaders/ByteReader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class ByteReader : ContentTypeReader + { + #region Internal Constructor + + internal ByteReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override byte Read( + ContentReader input, + byte existingInstance + ) { + return input.ReadByte(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/CharReader.cs b/FNA/src/Content/ContentReaders/CharReader.cs new file mode 100644 index 0000000..c644a76 --- /dev/null +++ b/FNA/src/Content/ContentReaders/CharReader.cs @@ -0,0 +1,37 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion License + +namespace Microsoft.Xna.Framework.Content +{ + internal class CharReader : ContentTypeReader + { + #region Internal Constructor + + internal CharReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override char Read( + ContentReader input, + char existingInstance + ) { + return input.ReadChar(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/ColorReader.cs b/FNA/src/Content/ContentReaders/ColorReader.cs new file mode 100644 index 0000000..d88b9f8 --- /dev/null +++ b/FNA/src/Content/ContentReaders/ColorReader.cs @@ -0,0 +1,40 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class ColorReader : ContentTypeReader + { + #region Internal Constructor + + internal ColorReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override Color Read( + ContentReader input, + Color existingInstance + ) { + /* Read RGBA as four separate bytes to make sure we + * comply with XNB format document + */ + byte r = input.ReadByte(); + byte g = input.ReadByte(); + byte b = input.ReadByte(); + byte a = input.ReadByte(); + return new Color(r, g, b, a); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/CurveReader.cs b/FNA/src/Content/ContentReaders/CurveReader.cs new file mode 100644 index 0000000..9f13f76 --- /dev/null +++ b/FNA/src/Content/ContentReaders/CurveReader.cs @@ -0,0 +1,52 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class CurveReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override Curve Read( + ContentReader input, + Curve existingInstance + ) { + Curve curve = existingInstance; + if (curve == null) + { + curve = new Curve(); + } + + curve.PreLoop = (CurveLoopType) input.ReadInt32(); + curve.PostLoop = (CurveLoopType) input.ReadInt32(); + int num6 = input.ReadInt32(); + for (int i = 0; i < num6; i += 1) + { + float position = input.ReadSingle(); + float num4 = input.ReadSingle(); + float tangentIn = input.ReadSingle(); + float tangentOut = input.ReadSingle(); + CurveContinuity continuity = (CurveContinuity) input.ReadInt32(); + curve.Keys.Add( + new CurveKey( + position, + num4, + tangentIn, + tangentOut, + continuity + ) + ); + } + return curve; + } + + #endregion + } +} + diff --git a/FNA/src/Content/ContentReaders/DateTimeReader.cs b/FNA/src/Content/ContentReaders/DateTimeReader.cs new file mode 100644 index 0000000..e14bde9 --- /dev/null +++ b/FNA/src/Content/ContentReaders/DateTimeReader.cs @@ -0,0 +1,41 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class DateTimeReader : ContentTypeReader + { + #region Internal Constructor + + internal DateTimeReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override DateTime Read( + ContentReader input, + DateTime existingInstance + ) { + UInt64 value = input.ReadUInt64(); + UInt64 mask = (UInt64) 3 << 62; + long ticks = (long) (value & ~mask); + DateTimeKind kind = (DateTimeKind) ((value >> 62) & 3); + return new DateTime(ticks, kind); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/DecimalReader.cs b/FNA/src/Content/ContentReaders/DecimalReader.cs new file mode 100644 index 0000000..b83a7d3 --- /dev/null +++ b/FNA/src/Content/ContentReaders/DecimalReader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class DecimalReader : ContentTypeReader + { + #region Internal Constructor + + internal DecimalReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override decimal Read( + ContentReader input, + decimal existingInstance + ) { + return input.ReadDecimal(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/DictionaryReader.cs b/FNA/src/Content/ContentReaders/DictionaryReader.cs new file mode 100644 index 0000000..eabcb6c --- /dev/null +++ b/FNA/src/Content/ContentReaders/DictionaryReader.cs @@ -0,0 +1,106 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class DictionaryReader : ContentTypeReader> + { + #region Public Properties + + public override bool CanDeserializeIntoExistingObject + { + get + { + return true; + } + } + + #endregion + + #region Private Variables + + ContentTypeReader keyReader; + ContentTypeReader valueReader; + + Type keyType; + Type valueType; + + #endregion + + #region Public Constructor + + public DictionaryReader() + { + } + + #endregion + + #region Protected Initialization Method + + protected internal override void Initialize(ContentTypeReaderManager manager) + { + keyType = typeof(TKey); + valueType = typeof(TValue); + keyReader = manager.GetTypeReader(keyType); + valueReader = manager.GetTypeReader(valueType); + } + + #endregion + + #region Protected Read Method + + protected internal override Dictionary Read(ContentReader input, Dictionary existingInstance) + { + int count = input.ReadInt32(); + Dictionary dictionary = existingInstance; + if (dictionary == null) + { + dictionary = new Dictionary(count); + } + else + { + dictionary.Clear(); + } + + for (int i = 0; i < count; i += 1) + { + TKey key; + TValue value; + if (keyType.IsValueType) + { + key = input.ReadObject(keyReader); + } + else + { + int readerType = input.Read7BitEncodedInt(); + key = (readerType > 0) ? input.ReadObject(input.TypeReaders[readerType - 1]) : default(TKey); + } + if (valueType.IsValueType) + { + value = input.ReadObject(valueReader); + } + else + { + int readerType = input.Read7BitEncodedInt(); + value = (readerType > 0) ? input.ReadObject(input.TypeReaders[readerType - 1]) : default(TValue); + } + dictionary.Add(key, value); + } + return dictionary; + } + + #endregion + } +} + diff --git a/FNA/src/Content/ContentReaders/DoubleReader.cs b/FNA/src/Content/ContentReaders/DoubleReader.cs new file mode 100644 index 0000000..91dd886 --- /dev/null +++ b/FNA/src/Content/ContentReaders/DoubleReader.cs @@ -0,0 +1,34 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class DoubleReader : ContentTypeReader + { + #region Internal Constructor + + internal DoubleReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override double Read( + ContentReader input, + double existingInstance + ) { + return input.ReadDouble(); + } + + #endregion + } +} + diff --git a/FNA/src/Content/ContentReaders/DualTextureEffectReader.cs b/FNA/src/Content/ContentReaders/DualTextureEffectReader.cs new file mode 100644 index 0000000..6dced63 --- /dev/null +++ b/FNA/src/Content/ContentReaders/DualTextureEffectReader.cs @@ -0,0 +1,36 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + class DualTextureEffectReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override DualTextureEffect Read( + ContentReader input, + DualTextureEffect existingInstance + ) { + DualTextureEffect effect = new DualTextureEffect(input.GraphicsDevice); + effect.Texture = input.ReadExternalReference() as Texture2D; + effect.Texture2 = input.ReadExternalReference() as Texture2D; + effect.DiffuseColor = input.ReadVector3(); + effect.Alpha = input.ReadSingle(); + effect.VertexColorEnabled = input.ReadBoolean(); + return effect; + } + + #endregion + } +} + diff --git a/FNA/src/Content/ContentReaders/EffectMaterialReader.cs b/FNA/src/Content/ContentReaders/EffectMaterialReader.cs new file mode 100644 index 0000000..31c7d43 --- /dev/null +++ b/FNA/src/Content/ContentReaders/EffectMaterialReader.cs @@ -0,0 +1,107 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.Diagnostics; + +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class EffectMaterialReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override EffectMaterial Read( + ContentReader input, + EffectMaterial existingInstance + ) { + Effect effect = input.ReadExternalReference(); + EffectMaterial effectMaterial = new EffectMaterial(effect); + Dictionary dict = input.ReadObject>(); + foreach (KeyValuePair item in dict) { + EffectParameter parameter = effectMaterial.Parameters[item.Key]; + if (parameter != null) + { + Type itemType = item.Value.GetType(); + if (typeof(Texture).IsAssignableFrom(itemType)) + { + parameter.SetValue((Texture) item.Value); + } + else if (typeof(int).IsAssignableFrom(itemType)) + { + parameter.SetValue((int) item.Value); + } + else if (typeof(bool).IsAssignableFrom(itemType)) + { + parameter.SetValue((bool) item.Value); + } + else if (typeof(float).IsAssignableFrom(itemType)) + { + parameter.SetValue((float) item.Value); + } + else if (typeof(float[]).IsAssignableFrom(itemType)) + { + parameter.SetValue((float[]) item.Value); + } + else if (typeof(Vector2).IsAssignableFrom(itemType)) + { + parameter.SetValue((Vector2) item.Value); + } + else if (typeof(Vector2[]).IsAssignableFrom(itemType)) + { + parameter.SetValue((Vector2[]) item.Value); + } + else if (typeof(Vector3).IsAssignableFrom(itemType)) + { + parameter.SetValue((Vector3) item.Value); + } + else if (typeof(Vector3[]).IsAssignableFrom(itemType)) + { + parameter.SetValue((Vector3[]) item.Value); + } + else if (typeof(Vector4).IsAssignableFrom(itemType)) + { + parameter.SetValue((Vector4) item.Value); + } + else if (typeof(Vector4[]).IsAssignableFrom(itemType)) + { + parameter.SetValue((Vector4[]) item.Value); + } + else if (typeof(Matrix).IsAssignableFrom(itemType)) + { + parameter.SetValue((Matrix) item.Value); + } + else if (typeof(Matrix[]).IsAssignableFrom(itemType)) + { + parameter.SetValue((Matrix[]) item.Value); + } + else if (typeof(Quaternion).IsAssignableFrom(itemType)) + { + parameter.SetValue((Quaternion) item.Value); + } + else + { + throw new NotSupportedException("Parameter type is not supported"); + } + } + else + { + Debug.WriteLine("No parameter " + item.Key); + } + } + return effectMaterial; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/EffectReader.cs b/FNA/src/Content/ContentReaders/EffectReader.cs new file mode 100644 index 0000000..fc13ce2 --- /dev/null +++ b/FNA/src/Content/ContentReaders/EffectReader.cs @@ -0,0 +1,50 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class EffectReader : ContentTypeReader + { + #region Private Supported File Extensions Variable + + private static string[] supportedExtensions = new string[] { ".fxb" }; + + #endregion + + #region Internal Filename Normalizer Method + + internal static string Normalize(string FileName) + { + return Normalize(FileName, supportedExtensions); + } + + #endregion + + #region Protected Read Method + + protected internal override Effect Read( + ContentReader input, + Effect existingInstance + ) { + int length = input.ReadInt32(); + Effect effect = new Effect( + input.GraphicsDevice, + input.ReadBytes(length) + ); + effect.Name = input.AssetName; + return effect; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/EnumReader.cs b/FNA/src/Content/ContentReaders/EnumReader.cs new file mode 100644 index 0000000..858acda --- /dev/null +++ b/FNA/src/Content/ContentReaders/EnumReader.cs @@ -0,0 +1,51 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class EnumReader : ContentTypeReader + { + #region Private ContentTypeReader Instance + + ContentTypeReader elementReader; + + #endregion + + #region Public Constructor + + public EnumReader() + { + } + + #endregion + + #region Protected Initialization Method + + protected internal override void Initialize(ContentTypeReaderManager manager) + { + Type readerType = Enum.GetUnderlyingType(typeof(T)); + elementReader = manager.GetTypeReader(readerType); + } + + #endregion + + #region Protected Read Method + + protected internal override T Read(ContentReader input, T existingInstance) + { + return input.ReadRawObject(elementReader); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/EnvironmentMapEffectReader.cs b/FNA/src/Content/ContentReaders/EnvironmentMapEffectReader.cs new file mode 100644 index 0000000..3c44767 --- /dev/null +++ b/FNA/src/Content/ContentReaders/EnvironmentMapEffectReader.cs @@ -0,0 +1,38 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + class EnvironmentMapEffectReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override EnvironmentMapEffect Read( + ContentReader input, + EnvironmentMapEffect existingInstance + ) { + EnvironmentMapEffect effect = new EnvironmentMapEffect(input.GraphicsDevice); + effect.Texture = input.ReadExternalReference() as Texture2D; + effect.EnvironmentMap = input.ReadExternalReference() as TextureCube; + effect.EnvironmentMapAmount = input.ReadSingle(); + effect.EnvironmentMapSpecular = input.ReadVector3(); + effect.FresnelFactor = input.ReadSingle(); + effect.DiffuseColor = input.ReadVector3(); + effect.EmissiveColor = input.ReadVector3(); + effect.Alpha = input.ReadSingle(); + return effect; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/ExternalReferenceReader.cs b/FNA/src/Content/ContentReaders/ExternalReferenceReader.cs new file mode 100644 index 0000000..e6d1321 --- /dev/null +++ b/FNA/src/Content/ContentReaders/ExternalReferenceReader.cs @@ -0,0 +1,36 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + /// + /// External reference reader, provided for compatibility with XNA Framework built content + /// + internal class ExternalReferenceReader : ContentTypeReader + { + #region Public Constructor + + public ExternalReferenceReader() : base(null) + { + } + + #endregion + + #region Protected Read Method + + protected internal override object Read( + ContentReader input, + object existingInstance + ) { + return input.ReadExternalReference(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/IndexBufferReader.cs b/FNA/src/Content/ContentReaders/IndexBufferReader.cs new file mode 100644 index 0000000..b8356c6 --- /dev/null +++ b/FNA/src/Content/ContentReaders/IndexBufferReader.cs @@ -0,0 +1,56 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + class IndexBufferReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override IndexBuffer Read( + ContentReader input, + IndexBuffer existingInstance + ) { + IndexBuffer indexBuffer = existingInstance; + bool sixteenBits = input.ReadBoolean(); + int dataSize = input.ReadInt32(); + byte[] data = input.ReadBytes(dataSize); + if (indexBuffer == null) + { + if (sixteenBits) + { + indexBuffer = new IndexBuffer( + input.GraphicsDevice, + IndexElementSize.SixteenBits, + dataSize / 2, + BufferUsage.None + ); + } + else + { + indexBuffer = new IndexBuffer( + input.GraphicsDevice, + IndexElementSize.ThirtyTwoBits, + dataSize / 4, + BufferUsage.None + ); + } + } + + indexBuffer.SetData(data); + return indexBuffer; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/Int16Reader.cs b/FNA/src/Content/ContentReaders/Int16Reader.cs new file mode 100644 index 0000000..de69a01 --- /dev/null +++ b/FNA/src/Content/ContentReaders/Int16Reader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class Int16Reader : ContentTypeReader + { + #region Internal Constructor + + internal Int16Reader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override short Read( + ContentReader input, + short existingInstance + ) { + return input.ReadInt16(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/Int32Reader.cs b/FNA/src/Content/ContentReaders/Int32Reader.cs new file mode 100644 index 0000000..38edb5c --- /dev/null +++ b/FNA/src/Content/ContentReaders/Int32Reader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class Int32Reader : ContentTypeReader + { + #region Internal Constructor + + internal Int32Reader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override int Read( + ContentReader input, + int existingInstance + ) { + return input.ReadInt32(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/Int64Reader.cs b/FNA/src/Content/ContentReaders/Int64Reader.cs new file mode 100644 index 0000000..b76af6a --- /dev/null +++ b/FNA/src/Content/ContentReaders/Int64Reader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class Int64Reader : ContentTypeReader + { + #region Internal Constructor + + internal Int64Reader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override long Read( + ContentReader input, + long existingInstance + ) { + return input.ReadInt64(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/ListReader.cs b/FNA/src/Content/ContentReaders/ListReader.cs new file mode 100644 index 0000000..63ac139 --- /dev/null +++ b/FNA/src/Content/ContentReaders/ListReader.cs @@ -0,0 +1,89 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class ListReader : ContentTypeReader> + { + #region Public Properties + + public override bool CanDeserializeIntoExistingObject + { + get + { + return true; + } + } + + #endregion + + #region Private ContentTypeReader Instance + + ContentTypeReader elementReader; + + #endregion + + #region Public Constructor + + public ListReader() + { + } + + #endregion + + #region Protected Initialization Method + + protected internal override void Initialize(ContentTypeReaderManager manager) + { + Type readerType = typeof(T); + elementReader = manager.GetTypeReader(readerType); + } + + #endregion + + #region Protected Read Method + + protected internal override List Read( + ContentReader input, + List existingInstance + ) { + int count = input.ReadInt32(); + List list = existingInstance; + if (list == null) + { + list = new List(count); + } + for (int i = 0; i < count; i += 1) + { + Type objectType = typeof(T); + if (objectType.IsValueType) + { + list.Add(input.ReadObject(elementReader)); + } + else + { + int readerType = input.Read7BitEncodedInt(); + list.Add((readerType > 0) ? input.ReadObject(input.TypeReaders[readerType - 1]) : default(T)); + } + } + return list; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/MatrixReader.cs b/FNA/src/Content/ContentReaders/MatrixReader.cs new file mode 100644 index 0000000..b49b371 --- /dev/null +++ b/FNA/src/Content/ContentReaders/MatrixReader.cs @@ -0,0 +1,43 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + class MatrixReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override Matrix Read( + ContentReader input, + Matrix existingInstance + ) { + // 4x4 matrix + return new Matrix( + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle(), + input.ReadSingle() + ); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/ModelReader.cs b/FNA/src/Content/ContentReaders/ModelReader.cs new file mode 100644 index 0000000..f5c749f --- /dev/null +++ b/FNA/src/Content/ContentReaders/ModelReader.cs @@ -0,0 +1,188 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System.Collections.Generic; + +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class ModelReader : ContentTypeReader + { + #region Public Constructor + + public ModelReader() + { + } + + #endregion + + #region Private Bone Helper Method + + private static int ReadBoneReference(ContentReader reader, uint boneCount) + { + uint boneId; + // Read the bone ID, which may be encoded as either an 8 or 32 bit value. + if (boneCount < 255) + { + boneId = reader.ReadByte(); + } + else + { + boneId = reader.ReadUInt32(); + } + if (boneId != 0) + { + return (int) (boneId - 1); + } + + return -1; + } + + #endregion + + #region Protected Read Method + + protected internal override Model Read(ContentReader reader, Model existingInstance) + { + // Read the bone names and transforms. + uint boneCount = reader.ReadUInt32(); + List bones = new List((int) boneCount); + for (uint i = 0; i < boneCount; i += 1) + { + string name = reader.ReadObject(); + Matrix matrix = reader.ReadMatrix(); + ModelBone bone = new ModelBone { + Transform = matrix, + Index = (int) i, + Name = name + }; + bones.Add(bone); + } + // Read the bone hierarchy. + for (int i = 0; i < boneCount; i += 1) + { + ModelBone bone = bones[i]; + // Read the parent bone reference. + int parentIndex = ReadBoneReference(reader, boneCount); + if (parentIndex != -1) + { + bone.Parent = bones[parentIndex]; + } + // Read the child bone references. + uint childCount = reader.ReadUInt32(); + if (childCount != 0) + { + for (uint j = 0; j < childCount; j += 1) + { + int childIndex = ReadBoneReference(reader, boneCount); + if (childIndex != -1) + { + bone.AddChild(bones[childIndex]); + } + } + } + } + + List meshes = new List(); + + // Read the mesh data. + int meshCount = reader.ReadInt32(); + + for (int i = 0; i < meshCount; i += 1) + { + + string name = reader.ReadObject(); + int parentBoneIndex = ReadBoneReference(reader, boneCount); + BoundingSphere boundingSphere = reader.ReadBoundingSphere(); + + // Tag + object meshTag = reader.ReadObject(); + + // Read the mesh part data. + int partCount = reader.ReadInt32(); + + List parts = new List(partCount); + + for (uint j = 0; j < partCount; j += 1) + { + ModelMeshPart part; + if (existingInstance != null) + { + part = existingInstance.Meshes[i].MeshParts[(int) j]; + } + else + { + part = new ModelMeshPart(); + } + + part.VertexOffset = reader.ReadInt32(); + part.NumVertices = reader.ReadInt32(); + part.StartIndex = reader.ReadInt32(); + part.PrimitiveCount = reader.ReadInt32(); + + // Tag + part.Tag = reader.ReadObject(); + + parts.Add(part); + + int jj = (int) j; + reader.ReadSharedResource( + delegate (VertexBuffer v) + { + parts[jj].VertexBuffer = v; + } + ); + reader.ReadSharedResource( + delegate (IndexBuffer v) + { + parts[jj].IndexBuffer = v; + } + ); + reader.ReadSharedResource( + delegate (Effect v) + { + parts[jj].Effect = v; + } + ); + } + if (existingInstance != null) + { + continue; + } + ModelMesh mesh = new ModelMesh(reader.GraphicsDevice, parts); + mesh.Tag = meshTag; + mesh.Name = name; + mesh.ParentBone = bones[parentBoneIndex]; + mesh.ParentBone.AddMesh(mesh); + mesh.BoundingSphere = boundingSphere; + meshes.Add(mesh); + } + if (existingInstance != null) + { + // Read past remaining data and return existing instance + ReadBoneReference(reader, boneCount); + reader.ReadObject(); + return existingInstance; + } + // Read the final pieces of model data. + int rootBoneIndex = ReadBoneReference(reader, boneCount); + Model model = new Model(reader.GraphicsDevice, bones, meshes); + model.Root = bones[rootBoneIndex]; + model.BuildHierarchy(); + // Tag? + model.Tag = reader.ReadObject(); + return model; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/NullableReader.cs b/FNA/src/Content/ContentReaders/NullableReader.cs new file mode 100644 index 0000000..4d3a996 --- /dev/null +++ b/FNA/src/Content/ContentReaders/NullableReader.cs @@ -0,0 +1,55 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class NullableReader : ContentTypeReader where T : struct + { + #region Private ContentTypeReader Instance + + ContentTypeReader elementReader; + + #endregion + + #region Internal Constructor + + internal NullableReader() + { + } + + #endregion + + #region Protected Initialization Method + + protected internal override void Initialize(ContentTypeReaderManager manager) + { + Type readerType = typeof(T); + elementReader = manager.GetTypeReader(readerType); + } + + #endregion + + #region Protected Read Method + + protected internal override T? Read(ContentReader input, T? existingInstance) + { + if (input.ReadBoolean()) + { + return input.ReadObject(elementReader); + } + return null; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/PlaneReader.cs b/FNA/src/Content/ContentReaders/PlaneReader.cs new file mode 100644 index 0000000..b61463a --- /dev/null +++ b/FNA/src/Content/ContentReaders/PlaneReader.cs @@ -0,0 +1,39 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class PlaneReader : ContentTypeReader + { + #region Internal Constructor + + internal PlaneReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override Plane Read( + ContentReader input, + Plane existingInstance + ) { + existingInstance.Normal = input.ReadVector3(); + existingInstance.D = input.ReadSingle(); + return existingInstance; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/PointReader.cs b/FNA/src/Content/ContentReaders/PointReader.cs new file mode 100644 index 0000000..d885602 --- /dev/null +++ b/FNA/src/Content/ContentReaders/PointReader.cs @@ -0,0 +1,39 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class PointReader : ContentTypeReader + { + #region Internal Constructor + + internal PointReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override Point Read( + ContentReader input, + Point existingInstance + ) { + int X = input.ReadInt32(); + int Y = input.ReadInt32(); + return new Point(X, Y); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/QuaternionReader.cs b/FNA/src/Content/ContentReaders/QuaternionReader.cs new file mode 100644 index 0000000..785f1b8 --- /dev/null +++ b/FNA/src/Content/ContentReaders/QuaternionReader.cs @@ -0,0 +1,37 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class QuaternionReader : ContentTypeReader + { + #region Internal Constructor + + internal QuaternionReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override Quaternion Read( + ContentReader input, + Quaternion existingInstance + ) { + return input.ReadQuaternion(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/RayReader.cs b/FNA/src/Content/ContentReaders/RayReader.cs new file mode 100644 index 0000000..e5555ad --- /dev/null +++ b/FNA/src/Content/ContentReaders/RayReader.cs @@ -0,0 +1,35 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class RayReader : ContentTypeReader + { + #region Internal Constructor + + internal RayReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override Ray Read( + ContentReader input, + Ray existingInstance + ) { + Vector3 position = input.ReadVector3(); + Vector3 direction = input.ReadVector3(); + return new Ray(position, direction); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/RectangleReader.cs b/FNA/src/Content/ContentReaders/RectangleReader.cs new file mode 100644 index 0000000..ac95c1a --- /dev/null +++ b/FNA/src/Content/ContentReaders/RectangleReader.cs @@ -0,0 +1,41 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class RectangleReader : ContentTypeReader + { + #region Internal Constructor + + internal RectangleReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override Rectangle Read( + ContentReader input, + Rectangle existingInstance + ) { + int left = input.ReadInt32(); + int top = input.ReadInt32(); + int width = input.ReadInt32(); + int height = input.ReadInt32(); + return new Rectangle(left, top, width, height); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/ReflectiveReader.cs b/FNA/src/Content/ContentReaders/ReflectiveReader.cs new file mode 100644 index 0000000..90950bc --- /dev/null +++ b/FNA/src/Content/ContentReaders/ReflectiveReader.cs @@ -0,0 +1,307 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.Collections.Generic; +using System.Reflection; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class ReflectiveReader : ContentTypeReader + { + #region Reader Delegates + + delegate void ReadElement(ContentReader input, object parent); + + private List readers; + + #endregion + + #region Public Properties + + public override bool CanDeserializeIntoExistingObject + { + get + { + return TargetType.IsClass; + } + } + + #endregion + + #region Private Variables + + private ConstructorInfo constructor; + + private ContentTypeReader baseTypeReader; + + #endregion + + #region Internal Constructor + + internal ReflectiveReader() : base(typeof(T)) + { + } + + #endregion + + #region Protected ContentTypeReader Methods + + protected internal override void Initialize(ContentTypeReaderManager manager) + { + base.Initialize(manager); + + Type baseType = TargetType.BaseType; + if (baseType != null && baseType != typeof(object)) + { + baseTypeReader = manager.GetTypeReader(baseType); + } + + constructor = TargetType.GetDefaultConstructor(); + + const BindingFlags attrs = ( + BindingFlags.NonPublic | + BindingFlags.Public | + BindingFlags.Instance | + BindingFlags.DeclaredOnly + ); + + /* Sometimes, overridden properties of abstract classes can show up even with + * BindingFlags.DeclaredOnly is passed to GetProperties. Make sure that + * all properties in this list are defined in this class by comparing + * its get method with that of its base class. If they're the same + * Then it's an overridden property. + */ + // FIXME: Holy moly does this alloc a lot -flibit + PropertyInfo[] properties = new List( + TargetType.GetProperties(attrs) + ).FindAll( + p => p.GetGetMethod(true) != null && p.GetGetMethod(true) == p.GetGetMethod(true).GetBaseDefinition() + ).ToArray(); + FieldInfo[] fields = TargetType.GetFields(attrs); + readers = new List(fields.Length + properties.Length); + + // Gather the properties. + foreach (PropertyInfo property in properties) + { + ReadElement read = GetElementReader(manager, property); + if (read != null) + { + readers.Add(read); + } + } + + // Gather the fields. + foreach (FieldInfo field in fields) + { + ReadElement read = GetElementReader(manager, field); + if (read != null) + { + readers.Add(read); + } + } + } + + protected internal override object Read(ContentReader input, object existingInstance) + { + T obj; + if (existingInstance != null) + { + obj = (T) existingInstance; + } + else + { + if (constructor == null) + { + obj = (T) Activator.CreateInstance(typeof(T)); + } + else + { + obj = (T) constructor.Invoke(null); + } + } + + if (baseTypeReader != null) + { + baseTypeReader.Read(input, obj); + } + + // Box the type. + object boxed = (object) obj; + + foreach (ReadElement reader in readers) + { + reader(input, boxed); + } + + // Unbox it... required for value types. + obj = (T) boxed; + + return obj; + } + + #endregion + + #region Private Static Methods + + private static ReadElement GetElementReader( + ContentTypeReaderManager manager, + MemberInfo member + ) { + PropertyInfo property = member as PropertyInfo; + FieldInfo field = member as FieldInfo; + + // Properties must have public get and set + if ( property != null && + ( property.CanWrite == false || + property.CanRead == false ) ) + { + return null; + } + + if (property != null) + { + // Properties must have at least a getter. + if (property.CanRead == false) + { + return null; + } + + // Skip over indexer properties + if (property.GetIndexParameters().Length > 0) + { + return null; + } + } + + // Are we explicitly asked to ignore this item? + Attribute attr = Attribute.GetCustomAttribute( + member, + typeof(ContentSerializerIgnoreAttribute) + ); + if (attr != null) + { + return null; + } + + ContentSerializerAttribute contentSerializerAttribute = Attribute.GetCustomAttribute( + member, + typeof(ContentSerializerAttribute) + ) as ContentSerializerAttribute; + if (contentSerializerAttribute == null) + { + if (property != null) + { + /* There is no ContentSerializerAttribute, so non-public + * properties cannot be deserialized. + */ + MethodInfo getMethod = property.GetGetMethod(true); + if (getMethod != null && !getMethod.IsPublic) + { + return null; + } + MethodInfo setMethod = property.GetSetMethod(true); + if (setMethod != null && !setMethod.IsPublic) + { + return null; + } + + /* If the read-only property has a type reader, + * and CanDeserializeIntoExistingObject is true, + * then it is safe to deserialize into the existing object. + */ + if (!property.CanWrite) + { + ContentTypeReader typeReader = manager.GetTypeReader(property.PropertyType); + if (typeReader == null || !typeReader.CanDeserializeIntoExistingObject) + { + return null; + } + } + } + else + { + /* There is no ContentSerializerAttribute, so non-public + * fields cannot be deserialized. + */ + if (!field.IsPublic) + { + return null; + } + + // evolutional: Added check to skip initialise only fields + if (field.IsInitOnly) + { + return null; + } + } + } + + Action setter; + Type elementType; + if (property != null) + { + elementType = property.PropertyType; + if (property.CanWrite) + { + setter = (o, v) => property.SetValue(o, v, null); + } + else + { + setter = (o, v) => { }; + } + } + else + { + elementType = field.FieldType; + setter = field.SetValue; + } + + if ( contentSerializerAttribute != null && + contentSerializerAttribute.SharedResource ) + { + return (input, parent) => + { + Action action = value => setter(parent, value); + input.ReadSharedResource(action); + }; + } + + // We need to have a reader at this point. + ContentTypeReader reader = manager.GetTypeReader(elementType); + if (reader == null) + { + throw new ContentLoadException(string.Format( + "Content reader could not be found for {0} type.", + elementType.FullName + )); + } + + /* We use the construct delegate to pick the correct existing + * object to be the target of deserialization. + */ + Func construct = parent => null; + if (property != null && !property.CanWrite) + { + construct = parent => property.GetValue(parent, null); + } + + return (input, parent) => + { + object existing = construct(parent); + object obj2 = input.ReadObject(reader, existing); + setter(parent, obj2); + }; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/SByteReader.cs b/FNA/src/Content/ContentReaders/SByteReader.cs new file mode 100644 index 0000000..1630759 --- /dev/null +++ b/FNA/src/Content/ContentReaders/SByteReader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class SByteReader : ContentTypeReader + { + #region Internal Constructor + + internal SByteReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override sbyte Read( + ContentReader input, + sbyte existingInstance + ) { + return input.ReadSByte(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/SingleReader.cs b/FNA/src/Content/ContentReaders/SingleReader.cs new file mode 100644 index 0000000..8315976 --- /dev/null +++ b/FNA/src/Content/ContentReaders/SingleReader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class SingleReader : ContentTypeReader + { + #region Internal Constructor + + internal SingleReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override float Read( + ContentReader input, + float existingInstance + ) { + return input.ReadSingle(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/SkinnedEffectReader.cs b/FNA/src/Content/ContentReaders/SkinnedEffectReader.cs new file mode 100644 index 0000000..4b81a58 --- /dev/null +++ b/FNA/src/Content/ContentReaders/SkinnedEffectReader.cs @@ -0,0 +1,37 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + class SkinnedEffectReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override SkinnedEffect Read( + ContentReader input, + SkinnedEffect existingInstance + ) { + SkinnedEffect effect = new SkinnedEffect(input.GraphicsDevice); + effect.Texture = input.ReadExternalReference() as Texture2D; + effect.WeightsPerVertex = input.ReadInt32(); + effect.DiffuseColor = input.ReadVector3(); + effect.EmissiveColor = input.ReadVector3(); + effect.SpecularColor = input.ReadVector3(); + effect.SpecularPower = input.ReadSingle(); + effect.Alpha = input.ReadSingle(); + return effect; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/SongReader.cs b/FNA/src/Content/ContentReaders/SongReader.cs new file mode 100644 index 0000000..194a9be --- /dev/null +++ b/FNA/src/Content/ContentReaders/SongReader.cs @@ -0,0 +1,64 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.IO; + +using Microsoft.Xna.Framework.Media; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class SongReader : ContentTypeReader + { + #region Private Supported File Extensions Variable + + static string[] supportedExtensions = new string[] { ".ogg", ".oga" }; + + #endregion + + #region Internal Filename Normalizer Method + + internal static string Normalize(string fileName) + { + return Normalize(fileName, supportedExtensions); + } + + #endregion + + #region Protected Read Method + + protected internal override Song Read(ContentReader input, Song existingInstance) + { + string path = MonoGame.Utilities.FileHelpers.ResolveRelativePath( + Path.Combine( + input.ContentManager.RootDirectoryFullPath, + input.AssetName + ), + input.ReadString() + ); + + /* The path string includes the ".wma" extension. Let's see if this + * file exists in a format we actually support... + */ + path = Normalize(path.Substring(0, path.Length - 4)); + if (String.IsNullOrEmpty(path)) + { + throw new ContentLoadException(); + } + + int durationMs = input.ReadInt32(); + + return new Song(path, durationMs); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/SoundEffectReader.cs b/FNA/src/Content/ContentReaders/SoundEffectReader.cs new file mode 100644 index 0000000..f8bb987 --- /dev/null +++ b/FNA/src/Content/ContentReaders/SoundEffectReader.cs @@ -0,0 +1,92 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System.IO; + +using Microsoft.Xna.Framework.Audio; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class SoundEffectReader : ContentTypeReader + { + #region Private Supported File Extensions Variable + + static string[] supportedExtensions = new string[] { ".wav" }; + + #endregion + + #region Internal Filename Normalizer Method + + internal static string Normalize(string fileName) + { + return Normalize(fileName, supportedExtensions); + } + + #endregion + + #region Protected Read Method + + protected internal override SoundEffect Read( + ContentReader input, + SoundEffect existingInstance + ) { + // Format block length + uint formatLength = input.ReadUInt32(); + + // Wavedata format + ushort format = input.ReadUInt16(); + + // Number of channels + ushort channels = input.ReadUInt16(); + + // Sample rate + uint sampleRate = input.ReadUInt32(); + + // Averate bytes per second, unused + input.ReadUInt32(); + + // Block alignment, needed for MSADPCM + ushort blockAlign = input.ReadUInt16(); + + // Bit depth + ushort bitDepth = input.ReadUInt16(); + + // cbSize, unused + input.ReadUInt16(); + + // Seek past the rest of this crap (cannot seek though!) + input.ReadBytes((int) (formatLength - 18)); + + // Wavedata + byte[] data = input.ReadBytes(input.ReadInt32()); + + // Loop information + uint loopStart = input.ReadUInt32(); + uint loopLength = input.ReadUInt32(); + + // Sound duration in milliseconds, unused + input.ReadUInt32(); + + return new SoundEffect( + input.AssetName, + data, + sampleRate, + channels, + loopStart, + loopLength, + format == 2, + (uint) ((format == 2) ? (((blockAlign / channels) - 6) * 2) : (bitDepth / 16)) + ); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/SpriteFontReader.cs b/FNA/src/Content/ContentReaders/SpriteFontReader.cs new file mode 100644 index 0000000..856b0f8 --- /dev/null +++ b/FNA/src/Content/ContentReaders/SpriteFontReader.cs @@ -0,0 +1,88 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +#region Using Statements +using System.Collections.Generic; + +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class SpriteFontReader : ContentTypeReader + { + #region Internal Constructor + + internal SpriteFontReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override SpriteFont Read( + ContentReader input, + SpriteFont existingInstance + ) { + if (existingInstance != null) + { + // Read the texture into the existing texture instance + input.ReadObject(existingInstance.textureValue); + + /* Discard the rest of the SpriteFont data as we are only + * reloading GPU resources for now + */ + input.ReadObject>(); + input.ReadObject>(); + input.ReadObject>(); + input.ReadInt32(); + input.ReadSingle(); + input.ReadObject>(); + if (input.ReadBoolean()) + { + input.ReadChar(); + } + return existingInstance; + } + else + { + // Create a fresh SpriteFont instance + Texture2D texture = input.ReadObject(); + List glyphs = input.ReadObject>(); + List cropping = input.ReadObject>(); + List charMap = input.ReadObject>(); + int lineSpacing = input.ReadInt32(); + float spacing = input.ReadSingle(); + List kerning = input.ReadObject>(); + char? defaultCharacter = null; + if (input.ReadBoolean()) + { + defaultCharacter = new char?(input.ReadChar()); + } + return new SpriteFont( + texture, + glyphs, + cropping, + charMap, + lineSpacing, + spacing, + kerning, + defaultCharacter + ); + } + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/StringReader.cs b/FNA/src/Content/ContentReaders/StringReader.cs new file mode 100644 index 0000000..7d14208 --- /dev/null +++ b/FNA/src/Content/ContentReaders/StringReader.cs @@ -0,0 +1,41 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class StringReader : ContentTypeReader + { + #region Internal Constructor + + internal StringReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override string Read( + ContentReader input, + string existingInstance + ) { + return input.ReadString(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/Texture2DReader.cs b/FNA/src/Content/ContentReaders/Texture2DReader.cs new file mode 100644 index 0000000..268fa83 --- /dev/null +++ b/FNA/src/Content/ContentReaders/Texture2DReader.cs @@ -0,0 +1,255 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.IO; + +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class Texture2DReader : ContentTypeReader + { + #region Private Supported File Extensions Variable + + private static string[] supportedExtensions = new string[] + { + ".bmp", ".gif", ".jpg", ".jpeg", ".png", ".tga", ".tif", ".tiff", ".dds" + }; + + #endregion + + #region Internal Constructor + + internal Texture2DReader() + { + } + + #endregion + + #region Internal Filename Normalizer Method + + internal static string Normalize(string fileName) + { + return Normalize(fileName, supportedExtensions); + } + + #endregion + + #region Protected Read Method + + protected internal override Texture2D Read( + ContentReader reader, + Texture2D existingInstance + ) { + Texture2D texture = null; + + SurfaceFormat surfaceFormat; + if (reader.version < 5) + { + /* These integer values are based on the enum values + * from previous XNA versions. + * -flibit + */ + int legacyFormat = reader.ReadInt32(); + if (legacyFormat == 1) + { + surfaceFormat = SurfaceFormat.ColorBgraEXT; + } + else if (legacyFormat == 28) + { + surfaceFormat = SurfaceFormat.Dxt1; + } + else if (legacyFormat == 30) + { + surfaceFormat = SurfaceFormat.Dxt3; + } + else if (legacyFormat == 32) + { + surfaceFormat = SurfaceFormat.Dxt5; + } + else + { + throw new NotSupportedException( + "Unsupported legacy surface format." + ); + } + } + else + { + surfaceFormat = (SurfaceFormat) reader.ReadInt32(); + } + int width = reader.ReadInt32(); + int height = reader.ReadInt32(); + int levelCount = reader.ReadInt32(); + int levelCountOutput = levelCount; + + // Check to see if we need to convert the surface data + SurfaceFormat convertedFormat = surfaceFormat; + if ( surfaceFormat == SurfaceFormat.Dxt1 && + !reader.GraphicsDevice.GLDevice.SupportsDxt1 ) + { + convertedFormat = SurfaceFormat.Color; + } + else if ( ( surfaceFormat == SurfaceFormat.Dxt3 || + surfaceFormat == SurfaceFormat.Dxt5 ) && + !reader.GraphicsDevice.GLDevice.SupportsS3tc ) + { + convertedFormat = SurfaceFormat.Color; + } + + // Check for duplicate instances + if (existingInstance == null) + { + texture = new Texture2D( + reader.GraphicsDevice, + width, + height, + levelCountOutput > 1, + convertedFormat + ); + } + else + { + texture = existingInstance; + } + + for (int level = 0; level < levelCount; level += 1) + { + int levelDataSizeInBytes = reader.ReadInt32(); + byte[] levelData = null; // Don't assign this quite yet... + int levelWidth = width >> level; + int levelHeight = height >> level; + if (level >= levelCountOutput) + { + continue; + } + + // Swap the image data if required. + if (reader.platform == 'x') + { + if ( surfaceFormat == SurfaceFormat.Color || + surfaceFormat == SurfaceFormat.ColorBgraEXT ) + { + levelData = X360TexUtil.SwapColor( + reader.ReadBytes(levelDataSizeInBytes) + ); + levelDataSizeInBytes = levelData.Length; + } + else if (surfaceFormat == SurfaceFormat.Dxt1) + { + levelData = X360TexUtil.SwapDxt1( + reader.ReadBytes(levelDataSizeInBytes), + levelWidth, + levelHeight + ); + levelDataSizeInBytes = levelData.Length; + } + else if (surfaceFormat == SurfaceFormat.Dxt3) + { + levelData = X360TexUtil.SwapDxt3( + reader.ReadBytes(levelDataSizeInBytes), + levelWidth, + levelHeight + ); + levelDataSizeInBytes = levelData.Length; + } + else if (surfaceFormat == SurfaceFormat.Dxt5) + { + levelData = X360TexUtil.SwapDxt5( + reader.ReadBytes(levelDataSizeInBytes), + levelWidth, + levelHeight + ); + levelDataSizeInBytes = levelData.Length; + } + } + + // Convert the image data if required + if (convertedFormat != surfaceFormat) + { + // May already be read in by 'x' conversion + if (levelData == null) + { + levelData = reader.ReadBytes(levelDataSizeInBytes); + } + if (surfaceFormat == SurfaceFormat.Dxt1) + { + levelData = DxtUtil.DecompressDxt1( + levelData, + levelWidth, + levelHeight + ); + } + else if (surfaceFormat == SurfaceFormat.Dxt3) + { + levelData = DxtUtil.DecompressDxt3( + levelData, + levelWidth, + levelHeight + ); + } + else if (surfaceFormat == SurfaceFormat.Dxt5) + { + levelData = DxtUtil.DecompressDxt5( + levelData, + levelWidth, + levelHeight + ); + } + levelDataSizeInBytes = levelData.Length; + } + + int levelDataByteOffset = 0; + if (levelData == null) + { + if ( reader.BaseStream is MemoryStream && + ((MemoryStream) reader.BaseStream).TryGetBuffer(out levelData) ) + { + /* Ideally, we didn't have to perform any conversion or + * unnecessary reading. Just throw the buffer directly + * into SetData, skipping a redundant byte[] copy. + */ + levelDataByteOffset = (int) reader.BaseStream.Seek(0, SeekOrigin.Current); + reader.BaseStream.Seek( + levelDataSizeInBytes, + SeekOrigin.Current + ); + } + else + { + /* If we don't have to perform any conversion and + * the ContentReader is not backed by a MemoryStream + * with a public buffer, we have to read the data in. + */ + levelData = reader.ReadBytes(levelDataSizeInBytes); + } + } + texture.SetData( + level, + null, + levelData, + levelDataByteOffset, + levelDataSizeInBytes + ); + + } + + return texture; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/Texture3DReader.cs b/FNA/src/Content/ContentReaders/Texture3DReader.cs new file mode 100644 index 0000000..cf983fd --- /dev/null +++ b/FNA/src/Content/ContentReaders/Texture3DReader.cs @@ -0,0 +1,78 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; + +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class Texture3DReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override Texture3D Read( + ContentReader reader, + Texture3D existingInstance + ) { + Texture3D texture = null; + + SurfaceFormat format = (SurfaceFormat) reader.ReadInt32(); + int width = reader.ReadInt32(); + int height = reader.ReadInt32(); + int depth = reader.ReadInt32(); + int levelCount = reader.ReadInt32(); + + if (existingInstance == null) + { + texture = new Texture3D( + reader.GraphicsDevice, + width, + height, + depth, + levelCount > 1, + format + ); + } + else + { + texture = existingInstance; + } + + for (int i = 0; i < levelCount; i += 1) + { + int dataSize = reader.ReadInt32(); + byte[] data = reader.ReadBytes(dataSize); + texture.SetData( + i, + 0, + 0, + width, + height, + 0, + depth, + data, + 0, + dataSize + ); + + // Calculate dimensions of next mip level. + width = Math.Max(width >> 1, 1); + height = Math.Max(height >> 1, 1); + depth = Math.Max(depth >> 1, 1); + } + + return texture; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/TextureCubeReader.cs b/FNA/src/Content/ContentReaders/TextureCubeReader.cs new file mode 100644 index 0000000..e3d7425 --- /dev/null +++ b/FNA/src/Content/ContentReaders/TextureCubeReader.cs @@ -0,0 +1,66 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class TextureCubeReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override TextureCube Read( + ContentReader reader, + TextureCube existingInstance + ) { + TextureCube textureCube = null; + + SurfaceFormat surfaceFormat = (SurfaceFormat) reader.ReadInt32(); + int size = reader.ReadInt32(); + int levels = reader.ReadInt32(); + + if (existingInstance == null) + { + textureCube = new TextureCube( + reader.GraphicsDevice, + size, + levels > 1, + surfaceFormat + ); + } + else + { + textureCube = existingInstance; + } + + for (int face = 0; face < 6; face += 1) + { + for (int i = 0; i < levels; i += 1) + { + int faceSize = reader.ReadInt32(); + byte[] faceData = reader.ReadBytes(faceSize); + textureCube.SetData( + (CubeMapFace) face, + i, + null, + faceData, + 0, + faceSize + ); + } + } + + return textureCube; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/TextureReader.cs b/FNA/src/Content/ContentReaders/TextureReader.cs new file mode 100644 index 0000000..74e2d8e --- /dev/null +++ b/FNA/src/Content/ContentReaders/TextureReader.cs @@ -0,0 +1,29 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class TextureReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override Texture Read( + ContentReader reader, + Texture existingInstance + ) { + return existingInstance; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/TimeSpanReader.cs b/FNA/src/Content/ContentReaders/TimeSpanReader.cs new file mode 100644 index 0000000..911dbec --- /dev/null +++ b/FNA/src/Content/ContentReaders/TimeSpanReader.cs @@ -0,0 +1,43 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class TimeSpanReader : ContentTypeReader + { + #region Internal Constructor + + internal TimeSpanReader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override TimeSpan Read( + ContentReader input, + TimeSpan existingInstance + ) { + /* Could not find any information on this really but from + * all the searching it looks like the constructor of number + * of ticks is long so I have placed that here for now. + * long is a Int64 so we read with 64 + * PT2S + */ + return new TimeSpan(input.ReadInt64()); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/UInt16Reader.cs b/FNA/src/Content/ContentReaders/UInt16Reader.cs new file mode 100644 index 0000000..8d05bb4 --- /dev/null +++ b/FNA/src/Content/ContentReaders/UInt16Reader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class UInt16Reader : ContentTypeReader + { + #region Internal Constructor + + internal UInt16Reader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override ushort Read( + ContentReader input, + ushort existingInstance + ) { + return input.ReadUInt16(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/UInt32Reader.cs b/FNA/src/Content/ContentReaders/UInt32Reader.cs new file mode 100644 index 0000000..751b6b5 --- /dev/null +++ b/FNA/src/Content/ContentReaders/UInt32Reader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class UInt32Reader : ContentTypeReader + { + #region Internal Constructor + + internal UInt32Reader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override uint Read( + ContentReader input, + uint existingInstance + ) { + return input.ReadUInt32(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/UInt64Reader.cs b/FNA/src/Content/ContentReaders/UInt64Reader.cs new file mode 100644 index 0000000..19aba67 --- /dev/null +++ b/FNA/src/Content/ContentReaders/UInt64Reader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class UInt64Reader : ContentTypeReader + { + #region Internal Constructor + + internal UInt64Reader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override ulong Read( + ContentReader input, + ulong existingInstance + ) { + return input.ReadUInt64(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/Vector2Reader.cs b/FNA/src/Content/ContentReaders/Vector2Reader.cs new file mode 100644 index 0000000..37acf79 --- /dev/null +++ b/FNA/src/Content/ContentReaders/Vector2Reader.cs @@ -0,0 +1,33 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class Vector2Reader : ContentTypeReader + { + #region Internal Constructor + + internal Vector2Reader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override Vector2 Read( + ContentReader input, + Vector2 existingInstance + ) { + return input.ReadVector2(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/Vector3Reader.cs b/FNA/src/Content/ContentReaders/Vector3Reader.cs new file mode 100644 index 0000000..918a14f --- /dev/null +++ b/FNA/src/Content/ContentReaders/Vector3Reader.cs @@ -0,0 +1,37 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class Vector3Reader : ContentTypeReader + { + #region Internal Constructor + + internal Vector3Reader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override Vector3 Read( + ContentReader input, + Vector3 existingInstance + ) { + return input.ReadVector3(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/Vector4Reader.cs b/FNA/src/Content/ContentReaders/Vector4Reader.cs new file mode 100644 index 0000000..a49230c --- /dev/null +++ b/FNA/src/Content/ContentReaders/Vector4Reader.cs @@ -0,0 +1,37 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class Vector4Reader : ContentTypeReader + { + #region Internal Constructor + + internal Vector4Reader() + { + } + + #endregion + + #region Protected Read Method + + protected internal override Vector4 Read( + ContentReader input, + Vector4 existingInstance + ) { + return input.ReadVector4(); + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/VertexBufferReader.cs b/FNA/src/Content/ContentReaders/VertexBufferReader.cs new file mode 100644 index 0000000..b5c5016 --- /dev/null +++ b/FNA/src/Content/ContentReaders/VertexBufferReader.cs @@ -0,0 +1,44 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ + +/* Derived from code by the Mono.Xna Team (Copyright 2006). + * Released under the MIT License. See monoxna.LICENSE for details. + */ +#endregion + +#region Using Statements +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + class VertexBufferReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override VertexBuffer Read( + ContentReader input, + VertexBuffer existingInstance + ) { + VertexDeclaration declaration = input.ReadRawObject(); + int vertexCount = (int) input.ReadUInt32(); + byte[] data = input.ReadBytes(vertexCount * declaration.VertexStride); + + VertexBuffer buffer = new VertexBuffer( + input.GraphicsDevice, + declaration, + vertexCount, + BufferUsage.None + ); + buffer.SetData(data); + return buffer; + } + + #endregion + } +} diff --git a/FNA/src/Content/ContentReaders/VertexDeclarationReader.cs b/FNA/src/Content/ContentReaders/VertexDeclarationReader.cs new file mode 100644 index 0000000..e54db4b --- /dev/null +++ b/FNA/src/Content/ContentReaders/VertexDeclarationReader.cs @@ -0,0 +1,54 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using Microsoft.Xna.Framework.Graphics; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class VertexDeclarationReader : ContentTypeReader + { + #region Protected Read Method + + protected internal override VertexDeclaration Read( + ContentReader reader, + VertexDeclaration existingInstance + ) { + int vertexStride = reader.ReadInt32(); + int elementCount = reader.ReadInt32(); + VertexElement[] elements = new VertexElement[elementCount]; + for (int i = 0; i < elementCount; i += 1) + { + int offset = reader.ReadInt32(); + VertexElementFormat elementFormat = (VertexElementFormat) reader.ReadInt32(); + VertexElementUsage elementUsage = (VertexElementUsage) reader.ReadInt32(); + int usageIndex = reader.ReadInt32(); + elements[i] = new VertexElement( + offset, + elementFormat, + elementUsage, + usageIndex + ); + } + + /* TODO: This process generates alot of duplicate VertexDeclarations + * which in turn complicates other systems trying to share GPU resources + * like DX11 vertex input layouts. + * + * We should consider caching vertex declarations here and returning + * previously created declarations when they are in our cache. + */ + return new VertexDeclaration(vertexStride, elements); + } + + #endregion + } +} + diff --git a/FNA/src/Content/ContentReaders/VideoReader.cs b/FNA/src/Content/ContentReaders/VideoReader.cs new file mode 100644 index 0000000..dd1ed90 --- /dev/null +++ b/FNA/src/Content/ContentReaders/VideoReader.cs @@ -0,0 +1,78 @@ +#region License +/* FNA - XNA4 Reimplementation for Desktop Platforms + * Copyright 2009-2018 Ethan Lee and the MonoGame Team + * + * Released under the Microsoft Public License. + * See LICENSE for details. + */ +#endregion + +#region Using Statements +using System; +using System.IO; + +using Microsoft.Xna.Framework.Media; +#endregion + +namespace Microsoft.Xna.Framework.Content +{ + internal class VideoReader : ContentTypeReader