diff --git a/README.md b/README.md index d9d8250..c8e357c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ MoonWorks uses strictly Free Open Source Software. It will never have any kind o ## Documentation -High-level documentation is provided here: https://moonside.games/docs/moonworks/ +High-level documentation is provided here: http://moonside.games/docs/moonworks/ For an actual API reference, the source is documented in doc comments that your preferred IDE can read. @@ -24,7 +24,7 @@ For an actual API reference, the source is documented in doc comments that your * [Wellspring](https://gitea.moonside.games/MoonsideGames/Wellspring) - Font Rendering * [Theorafile](https://github.com/FNA-XNA/Theorafile) - Compressed Video -Prebuilt dependencies can be obtained here: https://moonside.games/files/moonlibs.tar.bz2 +Prebuilt dependencies can be obtained here: http://moonside.games/files/moonlibs.tar.bz2 ## License diff --git a/lib/FAudio b/lib/FAudio index 09568a0..0b6d5da 160000 --- a/lib/FAudio +++ b/lib/FAudio @@ -1 +1 @@ -Subproject commit 09568a04683a497872937a2ffea0f82a359bb21b +Subproject commit 0b6d5dabbf428633482fe3a956fbdb53228fcf35 diff --git a/lib/RefreshCS b/lib/RefreshCS index c378027..98c590a 160000 --- a/lib/RefreshCS +++ b/lib/RefreshCS @@ -1 +1 @@ -Subproject commit c378027989dbc4233c7ead476aba4e22b335ba0f +Subproject commit 98c590ae77c3b6a64a370bac439f20728959a8b6 diff --git a/lib/SDL2-CS b/lib/SDL2-CS index b72c0c5..b35aaa4 160000 --- a/lib/SDL2-CS +++ b/lib/SDL2-CS @@ -1 +1 @@ -Subproject commit b72c0c57128fafb6fc5aa4f258a41d928f98a438 +Subproject commit b35aaa494e44d08242788ff0ba2cb7a508f4d8f0 diff --git a/src/Audio/AudioDevice.cs b/src/Audio/AudioDevice.cs index 27cb803..adf4b37 100644 --- a/src/Audio/AudioDevice.cs +++ b/src/Audio/AudioDevice.cs @@ -25,7 +25,7 @@ namespace MoonWorks.Audio public unsafe AudioDevice() { - FAudio.FAudioCreate(out var handle, 0, 0); + FAudio.FAudioCreate(out var handle, 0, FAudio.FAUDIO_DEFAULT_PROCESSOR); Handle = handle; /* Find a suitable device */ diff --git a/src/Audio/FilterType.cs b/src/Audio/FilterType.cs deleted file mode 100644 index 345aa68..0000000 --- a/src/Audio/FilterType.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MoonWorks.Audio -{ - public enum FilterType - { - None, - LowPass, - BandPass, - HighPass - } -} diff --git a/src/Audio/SoundInstance.cs b/src/Audio/SoundInstance.cs index 07d02e3..31df632 100644 --- a/src/Audio/SoundInstance.cs +++ b/src/Audio/SoundInstance.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.InteropServices; namespace MoonWorks.Audio @@ -14,21 +14,21 @@ namespace MoonWorks.Audio public virtual SoundState State { get; protected set; } - private float pan = 0; + private float _pan = 0; public float Pan { - get => pan; + get => _pan; set { - pan = value; + _pan = value; - if (pan < -1f) + if (_pan < -1f) { - pan = -1f; + _pan = -1f; } - if (pan > 1f) + if (_pan > 1f) { - pan = 1f; + _pan = 1f; } if (Is3D) { return; } @@ -45,41 +45,41 @@ namespace MoonWorks.Audio } } - private float pitch = 0; + private float _pitch = 0; public float Pitch { - get => pitch; + get => _pitch; set { - pitch = Math.MathHelper.Clamp(value, -1f, 1f); + _pitch = Math.MathHelper.Clamp(value, -1f, 1f); UpdatePitch(); } } - private float volume = 1; + private float _volume = 1; public float Volume { - get => volume; + get => _volume; set { - volume = value; - FAudio.FAudioVoice_SetVolume(Handle, volume, 0); + _volume = value; + FAudio.FAudioVoice_SetVolume(Handle, _volume, 0); } } - private float reverb; + private float _reverb; public unsafe float Reverb { - get => reverb; + get => _reverb; set { - reverb = value; + _reverb = value; float* outputMatrix = (float*) dspSettings.pMatrixCoefficients; - outputMatrix[0] = reverb; + outputMatrix[0] = _reverb; if (dspSettings.SrcChannelCount == 2) { - outputMatrix[1] = reverb; + outputMatrix[1] = _reverb; } FAudio.FAudioVoice_SetOutputMatrix( @@ -93,83 +93,67 @@ namespace MoonWorks.Audio } } - private const float MAX_FILTER_FREQUENCY = 1f; - private const float MAX_FILTER_ONEOVERQ = 1.5f; - - private FAudio.FAudioFilterParameters filterParameters = new FAudio.FAudioFilterParameters + private float _lowPassFilter; + public float LowPassFilter { - Type = FAudio.FAudioFilterType.FAudioLowPassFilter, - Frequency = 1f, - OneOverQ = 1f - }; - - private float FilterFrequency - { - get => filterParameters.Frequency; + get => _lowPassFilter; set { - value = System.Math.Clamp(value, 0.01f, MAX_FILTER_FREQUENCY); - filterParameters.Frequency = value; + _lowPassFilter = value; - FAudio.FAudioVoice_SetFilterParameters( - Handle, - ref filterParameters, - 0 - ); - } - } - - private float FilterOneOverQ - { - get => filterParameters.OneOverQ; - set - { - value = System.Math.Clamp(value, 0.01f, MAX_FILTER_ONEOVERQ); - filterParameters.OneOverQ = value; - - FAudio.FAudioVoice_SetFilterParameters( - Handle, - ref filterParameters, - 0 - ); - } - } - - private FilterType filterType; - public FilterType FilterType - { - get => filterType; - set - { - filterType = value; - - switch (filterType) + FAudio.FAudioFilterParameters p = new FAudio.FAudioFilterParameters { - case FilterType.None: - filterParameters = new FAudio.FAudioFilterParameters - { - Type = FAudio.FAudioFilterType.FAudioLowPassFilter, - Frequency = 1f, - OneOverQ = 1f - }; - break; - - case FilterType.LowPass: - filterParameters.Type = FAudio.FAudioFilterType.FAudioLowPassFilter; - break; - - case FilterType.BandPass: - filterParameters.Type = FAudio.FAudioFilterType.FAudioBandPassFilter; - break; - - case FilterType.HighPass: - filterParameters.Type = FAudio.FAudioFilterType.FAudioHighPassFilter; - break; - } - + Type = FAudio.FAudioFilterType.FAudioLowPassFilter, + Frequency = _lowPassFilter, + OneOverQ = 1f + }; FAudio.FAudioVoice_SetFilterParameters( Handle, - ref filterParameters, + ref p, + 0 + ); + } + } + + private float _highPassFilter; + public float HighPassFilter + { + get => _highPassFilter; + set + { + _highPassFilter = value; + + FAudio.FAudioFilterParameters p = new FAudio.FAudioFilterParameters + { + Type = FAudio.FAudioFilterType.FAudioHighPassFilter, + Frequency = _highPassFilter, + OneOverQ = 1f + }; + FAudio.FAudioVoice_SetFilterParameters( + Handle, + ref p, + 0 + ); + } + } + + private float _bandPassFilter; + public float BandPassFilter + { + get => _bandPassFilter; + set + { + _bandPassFilter = value; + + FAudio.FAudioFilterParameters p = new FAudio.FAudioFilterParameters + { + Type = FAudio.FAudioFilterType.FAudioBandPassFilter, + Frequency = _bandPassFilter, + OneOverQ = 1f + }; + FAudio.FAudioVoice_SetFilterParameters( + Handle, + ref p, 0 ); } @@ -297,7 +281,7 @@ namespace MoonWorks.Audio FAudio.FAudioSourceVoice_SetFrequencyRatio( Handle, - (float) System.Math.Pow(2.0, pitch) * doppler, + (float) System.Math.Pow(2.0, _pitch) * doppler, 0 ); } @@ -321,8 +305,8 @@ namespace MoonWorks.Audio } else { - outputMatrix[0] = (pan > 0.0f) ? (1.0f - pan) : 1.0f; - outputMatrix[1] = (pan < 0.0f) ? (1.0f + pan) : 1.0f; + outputMatrix[0] = (_pan > 0.0f) ? (1.0f - _pan) : 1.0f; + outputMatrix[1] = (_pan < 0.0f) ? (1.0f + _pan) : 1.0f; } } else @@ -334,23 +318,23 @@ namespace MoonWorks.Audio } else { - if (pan <= 0.0f) + if (_pan <= 0.0f) { // Left speaker blends left/right channels - outputMatrix[0] = 0.5f * pan + 1.0f; - outputMatrix[1] = 0.5f * -pan; + outputMatrix[0] = 0.5f * _pan + 1.0f; + outputMatrix[1] = 0.5f * -_pan; // Right speaker gets less of the right channel outputMatrix[2] = 0.0f; - outputMatrix[3] = pan + 1.0f; + outputMatrix[3] = _pan + 1.0f; } else { // Left speaker gets less of the left channel - outputMatrix[0] = -pan + 1.0f; + outputMatrix[0] = -_pan + 1.0f; outputMatrix[1] = 0.0f; // Right speaker blends right/left channels - outputMatrix[2] = 0.5f * pan; - outputMatrix[3] = 0.5f * -pan + 1.0f; + outputMatrix[2] = 0.5f * _pan; + outputMatrix[3] = 0.5f * -_pan + 1.0f; } } } diff --git a/src/Audio/StaticSound.cs b/src/Audio/StaticSound.cs index 8707322..4976244 100644 --- a/src/Audio/StaticSound.cs +++ b/src/Audio/StaticSound.cs @@ -283,7 +283,6 @@ namespace MoonWorks.Audio internal void FreeInstance(StaticSoundInstance instance) { - instance.Reset(); Instances.Push(instance); } diff --git a/src/Audio/StaticSoundInstance.cs b/src/Audio/StaticSoundInstance.cs index f2d7549..7f52a97 100644 --- a/src/Audio/StaticSoundInstance.cs +++ b/src/Audio/StaticSoundInstance.cs @@ -107,17 +107,5 @@ namespace MoonWorks.Audio { Parent.FreeInstance(this); } - - internal void Reset() - { - Pan = 0; - Pitch = 0; - Volume = 1; - Reverb = 0; - Loop = false; - Is3D = false; - FilterType = FilterType.None; - Reverb = 0; - } } } diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index 81a2c91..598d50b 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -34,12 +34,14 @@ namespace MoonWorks.Graphics #if DEBUG if (colorAttachmentInfos.Length == 0) { - throw new System.ArgumentException("Render pass must contain at least one attachment!"); + Logger.LogError("Render pass must contain at least one attachment!"); + return; } if (colorAttachmentInfos.Length > 4) { - throw new System.ArgumentException("Render pass cannot have more than 4 color attachments!"); + Logger.LogError("Render pass cannot have more than 4 color attachments!"); + return; } #endif @@ -76,9 +78,16 @@ namespace MoonWorks.Graphics ) { #if DEBUG + if (colorAttachmentInfos.Length == 0) + { + Logger.LogError("Render pass must contain at least one attachment!"); + return; + } + if (colorAttachmentInfos.Length > 4) { - throw new System.ArgumentException("Render pass cannot have more than 4 color attachments!"); + Logger.LogError("Render pass cannot have more than 4 color attachments!"); + return; } #endif @@ -119,12 +128,14 @@ namespace MoonWorks.Graphics #if DEBUG if (colorAttachmentInfos.Length == 0) { - throw new System.ArgumentException("Render pass must contain at least one attachment!"); + Logger.LogError("Render pass must contain at least one attachment!"); + return; } if (colorAttachmentInfos.Length > 4) { - throw new System.ArgumentException("Render pass cannot have more than 4 color attachments!"); + Logger.LogError("Render pass cannot have more than 4 color attachments!"); + return; } #endif @@ -163,9 +174,16 @@ namespace MoonWorks.Graphics ) { #if DEBUG + if (colorAttachmentInfos.Length == 0) + { + Logger.LogError("Render pass must contain at least one attachment!"); + return; + } + if (colorAttachmentInfos.Length > 4) { - throw new System.ArgumentException("Render pass cannot have more than 4 color attachments!"); + Logger.LogError("Render pass cannot have more than 4 color attachments!"); + return; } #endif @@ -616,36 +634,6 @@ namespace MoonWorks.Graphics ); } - /// - /// Similar to DrawPrimitives, but parameters are set from a buffer. - /// - /// The draw parameters buffer. - /// The offset to start reading from the draw parameters buffer. - /// The number of draw parameter sets that should be read from the buffer. - /// The byte stride between sets of draw parameters. - /// An offset value obtained from PushVertexShaderUniforms. If no uniforms are required then use 0. - /// An offset value obtained from PushFragmentShaderUniforms. If no uniforms are required the use 0. - public void DrawPrimitivesIndirect( - Buffer buffer, - uint offsetInBytes, - uint drawCount, - uint stride, - uint vertexParamOffset, - uint fragmentParamOffset - ) - { - Refresh.Refresh_DrawPrimitivesIndirect( - Device.Handle, - Handle, - buffer.Handle, - offsetInBytes, - drawCount, - stride, - vertexParamOffset, - fragmentParamOffset - ); - } - /// /// Ends the current render pass. /// This must be called before beginning another render pass or submitting the command buffer. diff --git a/src/Graphics/RefreshEnums.cs b/src/Graphics/RefreshEnums.cs index 50ba244..12d70c8 100644 --- a/src/Graphics/RefreshEnums.cs +++ b/src/Graphics/RefreshEnums.cs @@ -91,8 +91,7 @@ namespace MoonWorks.Graphics { Sampler = 1, ColorTarget = 2, - DepthStencilTarget = 4, - Compute = 8 + DepthStencilTarget = 4 } public enum SampleCount @@ -121,8 +120,7 @@ namespace MoonWorks.Graphics { Vertex = 1, Index = 2, - Compute = 4, - Indirect = 8 + Compute = 4 } public enum VertexElementFormat diff --git a/src/Graphics/State/RasterizerState.cs b/src/Graphics/State/RasterizerState.cs index 8d5b4ac..042a55d 100644 --- a/src/Graphics/State/RasterizerState.cs +++ b/src/Graphics/State/RasterizerState.cs @@ -69,7 +69,7 @@ { CullMode = CullMode.None, FrontFace = FrontFace.Clockwise, - FillMode = FillMode.Line, + FillMode = FillMode.Fill, DepthBiasEnable = false }; @@ -101,7 +101,7 @@ { CullMode = CullMode.None, FrontFace = FrontFace.CounterClockwise, - FillMode = FillMode.Line, + FillMode = FillMode.Fill, DepthBiasEnable = false }; }