Skip to content

Commit

Permalink
Add stubs for the Native platform (MonoGame#8191)
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-cpp authored Feb 20, 2024
1 parent c6e47a1 commit 7dc8aa0
Show file tree
Hide file tree
Showing 51 changed files with 1,478 additions and 40 deletions.
22 changes: 22 additions & 0 deletions MonoGame.Framework.Native.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Framework.Native", "MonoGame.Framework\MonoGame.Framework.Native.csproj", "{56BA741D-6AF1-489B-AB00-338DE11B1D32}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{56BA741D-6AF1-489B-AB00-338DE11B1D32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56BA741D-6AF1-489B-AB00-338DE11B1D32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56BA741D-6AF1-489B-AB00-338DE11B1D32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56BA741D-6AF1-489B-AB00-338DE11B1D32}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
14 changes: 6 additions & 8 deletions MonoGame.Framework/Graphics/SamplerStateCollection.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// MonoGame - Copyright (C) MonoGame Foundation, Inc
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
//
// Author: Kenneth James Pouncey

using System;

Expand Down Expand Up @@ -40,15 +38,15 @@ internal SamplerStateCollection(GraphicsDevice device, int maxSamplers, bool app

Clear();
}
public SamplerState this [int index]

public SamplerState this [int index]
{
get
{
return _samplers[index];
get
{
return _samplers[index];
}

set
set
{
if (value == null)
throw new ArgumentNullException("value");
Expand Down
2 changes: 2 additions & 0 deletions MonoGame.Framework/Media/AlbumCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace Microsoft.Xna.Framework.Media
/// </remarks>
public sealed class AlbumCollection : IDisposable
{
public static readonly AlbumCollection Empty = new AlbumCollection(new List<Album>());

private List<Album> albumCollection;

/// <summary>
Expand Down
22 changes: 11 additions & 11 deletions MonoGame.Framework/Media/MediaQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ public sealed class MediaQueue

public MediaQueue()
{

}

public Song ActiveSong
{
get
{
if (songs.Count == 0 || _activeSongIndex < 0)
return null;

return songs[_activeSongIndex];
}
}

public int ActiveSongIndex
{
get
Expand Down Expand Up @@ -69,26 +69,26 @@ internal Song GetNextSong(int direction, bool shuffle)
{
if (shuffle)
_activeSongIndex = random.Next(songs.Count);
else
else
_activeSongIndex = (int)MathHelper.Clamp(_activeSongIndex + direction, 0, songs.Count - 1);

return songs[_activeSongIndex];
}

internal void Clear()
{
Song song;
for(; songs.Count > 0; )
{
song = songs[0];
#if !DIRECTX
#if !DIRECTX && !NATIVE
song.Stop();
#endif
songs.Remove(song);
}
}
}

#if !DIRECTX
#if !DIRECTX && !NATIVE
internal void SetVolume(float volume)
{
int count = songs.Count;
Expand All @@ -102,7 +102,7 @@ internal void Add(Song song)
songs.Add(song);
}

#if !DIRECTX
#if !DIRECTX && !NATIVE
internal void Stop()
{
int count = songs.Count;
Expand Down
40 changes: 21 additions & 19 deletions MonoGame.Framework/Media/SongCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
using System;
using System.Collections;
using System.Collections.Generic;

namespace Microsoft.Xna.Framework.Media
{
public class SongCollection : ICollection<Song>, IEnumerable<Song>, IEnumerable, IDisposable
{

namespace Microsoft.Xna.Framework.Media
{
public class SongCollection : ICollection<Song>, IEnumerable<Song>, IEnumerable, IDisposable
{
public static readonly SongCollection Empty = new SongCollection();

private bool isReadOnly = false;
private List<Song> innerlist = new List<Song>();

Expand All @@ -26,12 +28,12 @@ internal SongCollection(List<Song> songs)
public void Dispose()
{
}

public IEnumerator<Song> GetEnumerator()
{
return innerlist.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return innerlist.GetEnumerator();
Expand All @@ -44,7 +46,7 @@ public int Count
return innerlist.Count;
}
}

public bool IsReadOnly
{
get
Expand All @@ -60,7 +62,7 @@ public Song this[int index]
return this.innerlist[index];
}
}

public void Add(Song item)
{

Expand All @@ -84,39 +86,39 @@ public void Add(Song item)

this.innerlist.Add(item);
}

public void Clear()
{
innerlist.Clear();
}

public SongCollection Clone()
{
SongCollection sc = new SongCollection();
foreach (Song song in this.innerlist)
sc.Add(song);
return sc;
}

public bool Contains(Song item)
{
return innerlist.Contains(item);
}

public void CopyTo(Song[] array, int arrayIndex)
{
innerlist.CopyTo(array, arrayIndex);
}

public int IndexOf(Song item)
{
return innerlist.IndexOf(item);
}

public bool Remove(Song item)
{
return innerlist.Remove(item);
}
}
}

}
}
}
26 changes: 26 additions & 0 deletions MonoGame.Framework/MonoGame.Framework.Native.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<DefineConstants>XNADESIGNPROVIDED;NATIVE;SUPPORTS_EFX;NETSTANDARD;STBSHARP_INTERNAL</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Description>The MonoGame Native platform.</Description>
<PackageTags>monogame;.net core;core;.net standard;standard;native</PackageTags>
<PackageId>MonoGame.Framework.Native</PackageId>
<AppendTargetFrameworkToOutputPath>False</AppendTargetFrameworkToOutputPath>
<CopyContentFiles>True</CopyContentFiles>
</PropertyGroup>

<ItemGroup>
<Compile Remove="bin\**\*" />
<Compile Remove="obj\**\*" />
<Compile Remove="Platform\**\*" />
<Compile Remove="Properties\**\*" />
<Compile Include="Platform\Native\**\*" />
</ItemGroup>

<ItemGroup>
<None Remove="Platform\**\*" />
</ItemGroup>

</Project>
23 changes: 23 additions & 0 deletions MonoGame.Framework/Platform/Native/ConstantBuffer.Native.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

namespace Microsoft.Xna.Framework.Graphics;

internal partial class ConstantBuffer
{
private void PlatformInitialize()
{

}

private void PlatformClear()
{

}

internal void PlatformApply(GraphicsDevice device, ShaderStage stage, int slot)
{

}
}
13 changes: 13 additions & 0 deletions MonoGame.Framework/Platform/Native/DepthStencilState.Native.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

namespace Microsoft.Xna.Framework.Graphics;

public partial class DepthStencilState
{
internal void PlatformApplyState(GraphicsDevice device)
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

namespace Microsoft.Xna.Framework.Audio;

public sealed partial class DynamicSoundEffectInstance : SoundEffectInstance
{
private void PlatformCreate()
{
}

private int PlatformGetPendingBufferCount()
{
return 0;
}

private void PlatformPlay()
{
}

private void PlatformPause()
{
}

private void PlatformResume()
{
}

private void PlatformStop()
{
}

private void PlatformSubmitBuffer(byte[] buffer, int offset, int count)
{
}

private void PlatformDispose(bool disposing)
{
}

private void PlatformUpdateQueue()
{
}
}
16 changes: 16 additions & 0 deletions MonoGame.Framework/Platform/Native/EffectResource.Native.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

namespace Microsoft.Xna.Framework.Graphics;

internal partial class EffectResource
{
// TODO: These should be loaded from the native library and not from the C# embedded resources!
const string AlphaTestEffectName = "Microsoft.Xna.Framework.Platform.Graphics.Effect.Resources.AlphaTestEffect.ogl.mgfxo";
const string BasicEffectName = "Microsoft.Xna.Framework.Platform.Graphics.Effect.Resources.BasicEffect.ogl.mgfxo";
const string DualTextureEffectName = "Microsoft.Xna.Framework.Platform.Graphics.Effect.Resources.DualTextureEffect.ogl.mgfxo";
const string EnvironmentMapEffectName = "Microsoft.Xna.Framework.Platform.Graphics.Effect.Resources.EnvironmentMapEffect.ogl.mgfxo";
const string SkinnedEffectName = "Microsoft.Xna.Framework.Platform.Graphics.Effect.Resources.SkinnedEffect.ogl.mgfxo";
const string SpriteEffectName = "Microsoft.Xna.Framework.Platform.Graphics.Effect.Resources.SpriteEffect.ogl.mgfxo";
}
28 changes: 28 additions & 0 deletions MonoGame.Framework/Platform/Native/GamePad.Native.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

namespace Microsoft.Xna.Framework.Input;

static partial class GamePad
{
private static int PlatformGetMaxNumberOfGamePads()
{
return 16;
}

private static GamePadCapabilities PlatformGetCapabilities(int index)
{
return new GamePadCapabilities();
}

private static GamePadState PlatformGetState(int index, GamePadDeadZone leftDeadZoneMode, GamePadDeadZone rightDeadZoneMode)
{
return new GamePadState();
}

private static bool PlatformSetVibration(int index, float leftMotor, float rightMotor, float leftTrigger, float rightTrigger)
{
return false;
}
}
Loading

0 comments on commit 7dc8aa0

Please sign in to comment.