2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-04-05 11:19:39 -04:00

Fix for Pinvoking structs

This commit is contained in:
msmshazan 2018-10-15 16:24:58 +05:30
parent 463b4037ad
commit 3c81f15df4
2 changed files with 62 additions and 16 deletions

View File

@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}</ProjectGuid> <ProjectGuid>{A2B3BBC8-3D48-46DD-B3CF-263F554E4474}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>Raylib</RootNamespace> <RootNamespace>Raylib</RootNamespace>
<AssemblyName>Bindings</AssemblyName> <AssemblyName>Bindings</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>

View File

@ -506,24 +506,44 @@ namespace Raylib
// Vertex data definning a mesh // Vertex data definning a mesh
// NOTE: Data stored in CPU memory (and GPU) // NOTE: Data stored in CPU memory (and GPU)
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Ansi,Size = 128)]
public struct Mesh public unsafe struct Mesh
{ {
[FieldOffset(0)]
public int vertexCount; public int vertexCount;
[FieldOffset(4)]
public int triangleCount; public int triangleCount;
public float[] vertices; [FieldOffset(8)]
public float[] texcoords; public IntPtr vertices;
public float[] texcoords2; [FieldOffset(16)]
public float[] normals; public IntPtr texcoords;
public float[] tangents; [FieldOffset(24)]
public byte[] colors; public IntPtr texcoords2;
public ushort[] indices; [FieldOffset(32)]
public IntPtr normals;
[FieldOffset(40)]
public IntPtr tangents;
[FieldOffset(48)]
public IntPtr colors;
[FieldOffset(56)]
public IntPtr indices;
[FieldOffset(64)]
public IntPtr baseVertices;
[FieldOffset(72)]
public IntPtr baseNormals;
[FieldOffset(80)]
public IntPtr weightBias;
[FieldOffset(88)]
public IntPtr weightId;
[FieldOffset(96)]
public uint vaoId; public uint vaoId;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)] // Raylib.PHYSAC_MAX_VERTICES)] [FieldOffset(100)]
public uint[] vboId; public fixed uint vboId[7];
} }
// Shader type (generic) // Shader type (generic)
@ -548,17 +568,43 @@ namespace Raylib
public Color color; public Color color;
public float value; public float value;
} }
public unsafe struct FixedMaterials
{
public MaterialMap maps0;
public MaterialMap maps1;
public MaterialMap maps2;
public MaterialMap maps3;
public MaterialMap maps4;
public MaterialMap maps5;
public MaterialMap maps6;
public MaterialMap maps7;
public MaterialMap maps8;
public MaterialMap maps9;
public MaterialMap maps10;
public MaterialMap maps11;
public ref MaterialMap this[int index]
{
get
{
fixed (MaterialMap* e = &maps0)
return ref e[index];
}
}
}
// Material type (generic) // Material type (generic)
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi,Size = 480)]
public struct Material public struct Material
{ {
public Shader shader; public Shader shader;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Raylib.MAX_MATERIAL_MAPS)] public FixedMaterials maps;
public MaterialMap[] maps;
public float[] param; public IntPtr param;
} }
// Model type // Model type