forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP on native wrapper and generator.
- Loading branch information
1 parent
4305687
commit 37fb5ff
Showing
17 changed files
with
957 additions
and
2,064 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,92 @@ | ||
|
||
using Microsoft.Xna.Framework.Graphics; | ||
using System.Runtime.CompilerServices; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.InteropServices.Marshalling; | ||
|
||
namespace MonoGame.Interop; | ||
|
||
internal readonly struct GamePtr { } | ||
internal readonly struct Game { } | ||
|
||
internal readonly struct GameWindowPtr { } | ||
internal readonly struct GameWindow { } | ||
|
||
internal static unsafe partial class GameWrapper | ||
{ | ||
[LibraryImport("monogame", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial void MG_GW_SetAllowUserResizing(GamePtr* game, GameWindowPtr* gameWindow, [MarshalAs(UnmanagedType.U1)] bool allowuserresizing); | ||
public static partial void MG_GW_SetAllowUserResizing(Game* game, GameWindow* gameWindow, [MarshalAs(UnmanagedType.U1)] bool allowuserresizing); | ||
} | ||
|
||
internal struct PtrTo<T> | ||
{ | ||
public unsafe T* Ptr; | ||
} | ||
|
||
internal readonly struct MGG_GraphicsDevice { } | ||
internal readonly struct MGG_Buffer { } | ||
internal readonly struct MGG_Texture { } | ||
|
||
internal struct MGG_GraphicsDevice_Caps | ||
{ | ||
public int MaxTextureSlots; | ||
public int MaxVertexTextureSlots; | ||
public int MaxVertexBufferSlots; | ||
} | ||
|
||
internal static unsafe partial class MGG | ||
{ | ||
#region GraphicsDevice | ||
|
||
[LibraryImport("monogame", EntryPoint = "MGG_GraphicsDevice_Create", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial MGG_GraphicsDevice* GraphicsDevice_Create(); | ||
|
||
[LibraryImport("monogame", EntryPoint = "MGG_GraphicsDevice_GetCaps", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial void GraphicsDevice_GetCaps(MGG_GraphicsDevice* device, out MGG_GraphicsDevice_Caps caps); | ||
|
||
[LibraryImport("monogame", EntryPoint = "MGG_GraphicsDevice_ResetBackbuffer", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial void GraphicsDevice_ResetBackbuffer(MGG_GraphicsDevice* device, int width, int height, SurfaceFormat color, DepthFormat depth); | ||
|
||
[LibraryImport("monogame", EntryPoint = "MGG_GraphicsDevice_BeginFrame", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial int GraphicsDevice_BeginFrame(MGG_GraphicsDevice* device); | ||
|
||
[LibraryImport("monogame", EntryPoint = "MGG_GraphicsDevice_Present", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial void GraphicsDevice_Present(MGG_GraphicsDevice* device, int currentFrame); | ||
|
||
[LibraryImport("monogame", EntryPoint = "MGG_GraphicsDevice_BindConstantBuffer", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial void GraphicsDevice_BindConstantBuffer(MGG_GraphicsDevice* device, ShaderStage stage, int slot, MGG_Buffer* buffer); | ||
|
||
#endregion | ||
|
||
#region Buffer | ||
|
||
[LibraryImport("monogame", EntryPoint = "MGG_Buffer_Create", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial MGG_Buffer* Buffer_Create(MGG_GraphicsDevice* device, int length); | ||
|
||
[LibraryImport("monogame", EntryPoint = "MGG_Buffer_SetData", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial void Buffer_SetData( | ||
MGG_GraphicsDevice* game, | ||
ref MGG_Buffer* buffer, | ||
int offset, | ||
byte* data, | ||
int length, | ||
[MarshalAs(UnmanagedType.U1)] | ||
bool discard); | ||
|
||
[LibraryImport("monogame", EntryPoint = "MGG_Buffer_Destroy", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial void Buffer_Destroy(MGG_GraphicsDevice* device, MGG_Buffer* buffer); | ||
|
||
#endregion | ||
|
||
#region Texture | ||
|
||
[LibraryImport("monogame", EntryPoint = "MGG_Texture_Create", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial MGG_Texture* Texture_Create(MGG_GraphicsDevice* device, SurfaceFormat format, int width, int height, int levels); | ||
|
||
|
||
[LibraryImport("monogame", EntryPoint = "MGG_Texture_Destroy", StringMarshalling = StringMarshalling.Utf8)] | ||
public static partial void Texture_Destroy(MGG_GraphicsDevice* device, MGG_Texture* texture); | ||
|
||
#endregion | ||
} | ||
|
||
|
Oops, something went wrong.