mirror of
https://github.com/raylib-cs/raylib-cs
synced 2025-06-30 19:03:42 -04:00
Review bindings
- All raylib structs are now blittable. - Fixing some incorrect functions(types, naming etc). - Remove netfx.props.
This commit is contained in:
@ -6,7 +6,7 @@ using System.Security;
|
||||
namespace Raylib_cs
|
||||
{
|
||||
// Color type, RGBA (32bit)
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Color
|
||||
{
|
||||
public byte r;
|
||||
@ -66,7 +66,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Rectangle type
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Rectangle
|
||||
{
|
||||
public float x;
|
||||
@ -85,7 +85,7 @@ namespace Raylib_cs
|
||||
|
||||
// Image type, bpp always RGBA (32bit)
|
||||
// NOTE: Data stored in CPU memory (RAM)
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Image
|
||||
{
|
||||
public IntPtr data; // Image raw data (void *)
|
||||
@ -97,7 +97,7 @@ namespace Raylib_cs
|
||||
|
||||
// Texture2D type
|
||||
// NOTE: Data stored in GPU memory
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Texture2D
|
||||
{
|
||||
public uint id; // OpenGL texture id
|
||||
@ -108,7 +108,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// RenderTexture2D type, for texture rendering
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RenderTexture2D
|
||||
{
|
||||
public uint id; // OpenGL Framebuffer Object (FBO) id
|
||||
@ -117,7 +117,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// N-Patch layout info
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NPatchInfo
|
||||
{
|
||||
public Rectangle sourceRec; // Region in the texture
|
||||
@ -129,7 +129,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Font character info
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct CharInfo
|
||||
{
|
||||
public int value; // Character value (Unicode)
|
||||
@ -140,7 +140,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Font type, includes texture and charSet array data
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Font
|
||||
{
|
||||
public int baseSize; // Base size (default chars height)
|
||||
@ -152,7 +152,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Camera type, defines a camera position/orientation in 3d space
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Camera3D
|
||||
{
|
||||
public Vector3 position; // Camera position
|
||||
@ -172,7 +172,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Camera2D type, defines a 2d camera
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Camera2D
|
||||
{
|
||||
public Vector2 offset; // Camera offset (displacement from target)
|
||||
@ -191,7 +191,7 @@ namespace Raylib_cs
|
||||
|
||||
// Vertex data definning a mesh
|
||||
// NOTE: Data stored in CPU memory (and GPU)
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Mesh
|
||||
{
|
||||
public int vertexCount; // Number of vertices stored in arrays
|
||||
@ -218,7 +218,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Shader type (generic)
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Shader
|
||||
{
|
||||
public uint id; // Shader program id
|
||||
@ -226,7 +226,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Material texture map
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct MaterialMap
|
||||
{
|
||||
public Texture2D texture; // Material map texture
|
||||
@ -235,7 +235,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Material type (generic)
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Material
|
||||
{
|
||||
public Shader shader; // Material shader
|
||||
@ -244,7 +244,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Transformation properties
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Transform
|
||||
{
|
||||
public Vector3 translation; // Translation
|
||||
@ -253,16 +253,15 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Bone information
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct BoneInfo
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
||||
public char[] name; // Bone name
|
||||
public IntPtr name; // Bone name (char[32])
|
||||
public int parent; // Bone parent
|
||||
}
|
||||
|
||||
// Model type
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Model
|
||||
{
|
||||
public Matrix4x4 transform; // Local transform matrix
|
||||
@ -277,7 +276,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Model animation
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ModelAnimation
|
||||
{
|
||||
public int boneCount; // Number of bones
|
||||
@ -287,7 +286,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Ray type (useful for raycast)
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Ray
|
||||
{
|
||||
public Vector3 position; // Ray position (origin)
|
||||
@ -301,18 +300,17 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Raycast hit information
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RayHitInfo
|
||||
{
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool hit; // Did the ray hit something?
|
||||
public byte hit; // Did the ray hit something?
|
||||
public float distance; // Distance to nearest hit
|
||||
public Vector3 position; // Position of nearest hit
|
||||
public Vector3 normal; // Surface normal of hit
|
||||
}
|
||||
|
||||
// Bounding box type
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct BoundingBox
|
||||
{
|
||||
public Vector3 min; // Minimum vertex box-corner
|
||||
@ -326,7 +324,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Wave type, defines audio wave data
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Wave
|
||||
{
|
||||
public uint sampleCount; // Number of samples
|
||||
@ -338,7 +336,7 @@ namespace Raylib_cs
|
||||
|
||||
// Audio stream type
|
||||
// NOTE: Useful to create custom audio streams not bound to a specific file
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct AudioStream
|
||||
{
|
||||
public IntPtr audioBuffer; // Pointer to internal data(rAudioBuffer *) used by the audio system
|
||||
@ -348,7 +346,7 @@ namespace Raylib_cs
|
||||
}
|
||||
|
||||
// Sound source type
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Sound
|
||||
{
|
||||
public AudioStream stream; // Audio stream
|
||||
@ -357,20 +355,19 @@ namespace Raylib_cs
|
||||
|
||||
// Music stream type (audio file streaming from memory)
|
||||
// NOTE: Anything longer than ~10 seconds should be streamed
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Music
|
||||
{
|
||||
public AudioStream stream; // Audio stream
|
||||
public uint sampleCount; // Total number of samples
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool looping; // Music looping enable
|
||||
public byte looping; // Music looping enable
|
||||
public int ctxType; // Type of music context (audio filetype)
|
||||
public IntPtr ctxData; // Audio context data, depends on type (void *)
|
||||
}
|
||||
|
||||
// Head-Mounted-Display device parameters
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct VrDeviceInfo
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe struct VrDeviceInfo
|
||||
{
|
||||
public int hResolution; // HMD horizontal resolution in pixels
|
||||
public int vResolution; // HMD vertical resolution in pixels
|
||||
@ -380,12 +377,8 @@ namespace Raylib_cs
|
||||
public float eyeToScreenDistance; // HMD distance between eye and display in meters
|
||||
public float lensSeparationDistance; // HMD lens separation distance in meters
|
||||
public float interpupillaryDistance; // HMD IPD (distance between pupils) in meters
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public float[] lensDistortionValues; // HMD lens distortion constant parameters
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public float[] chromaAbCorrection; // HMD chromatic aberration correction parameters
|
||||
public fixed float lensDistortionValues[4]; // HMD lens distortion constant parameters
|
||||
public fixed float chromaAbCorrection[4]; // HMD chromatic aberration correction parameters
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
@ -1196,7 +1189,8 @@ namespace Raylib_cs
|
||||
|
||||
// Save data to file from byte array (write)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SaveFileData(string fileName, IntPtr data, int bytesToWrite);
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool SaveFileData(string fileName, IntPtr data, int bytesToWrite);
|
||||
|
||||
// Check file extension
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -1222,22 +1216,23 @@ namespace Raylib_cs
|
||||
|
||||
// Compress data (DEFLATE algorythm)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern byte[] CompressData(ref byte[] data, int dataLength, ref int compDataLength);
|
||||
public static extern IntPtr CompressData(byte[] data, int dataLength, ref int compDataLength);
|
||||
|
||||
// Decompress data (DEFLATE algorythm)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern byte[] DecompressData(ref byte[] compData, int compDataLength, ref int dataLength);
|
||||
public static extern IntPtr DecompressData(byte[] compData, int compDataLength, ref int dataLength);
|
||||
|
||||
|
||||
// Persistent storage management
|
||||
|
||||
// Save integer value to storage file (to defined position)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void StorageSaveValue(int position, int value);
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool SaveStorageValue(uint position, int value);
|
||||
|
||||
// Load integer value from storage file (from defined position)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int StorageLoadValue(int position);
|
||||
public static extern int LoadStorageValue(uint position);
|
||||
|
||||
// Open URL with default system browser (if available)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -2306,8 +2301,9 @@ namespace Raylib_cs
|
||||
// Mesh loading/unloading functions
|
||||
|
||||
// Load meshes from model file
|
||||
// IntPtr refers to a Mesh *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Mesh[] LoadMeshes(string fileName, ref int meshCount);
|
||||
public static extern IntPtr LoadMeshes(string fileName, ref int meshCount);
|
||||
|
||||
// Unload mesh from memory (RAM and/or VRAM)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -2321,8 +2317,9 @@ namespace Raylib_cs
|
||||
// Material loading/unloading functions
|
||||
|
||||
// Load materials from model file
|
||||
// IntPtr refers to Material *
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Material[] LoadMaterials(string fileName, ref int materialCount);
|
||||
public static extern IntPtr LoadMaterials(string fileName, ref int materialCount);
|
||||
|
||||
// Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
|
||||
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
|
@ -5,16 +5,14 @@ using System.Security;
|
||||
namespace Raylib_cs
|
||||
{
|
||||
// NOTE: Helper types to be used instead of array return types for *ToFloat functions
|
||||
public struct float3
|
||||
public unsafe struct float3
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
|
||||
public float[] v;
|
||||
public fixed float v[3];
|
||||
}
|
||||
|
||||
public struct float16
|
||||
public unsafe struct float16
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
|
||||
public float[] v;
|
||||
public fixed float v[16];
|
||||
}
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
|
Reference in New Issue
Block a user