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

Add .editorconfig and apply formatting

This commit is contained in:
ChrisDill 2023-08-27 15:20:26 +01:00
parent d1f0b9fd91
commit 696955463f
32 changed files with 7217 additions and 7194 deletions

51
.editorconfig Normal file
View File

@ -0,0 +1,51 @@
# EditorConfig is awesome: http://EditorConfig.org
root = true
[*]
indent_style = space
# General
[*.{cs,csx,vb,vbx}]
indent_size = 4
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
# C# styles
[*.cs]
# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left
csharp_style_namespace_declarations = file_scoped:warning
# Newline settings
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# Spacing
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_around_binary_operators = before_and_after
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
# Blocks are allowed
csharp_prefer_braces = true:error
csharp_preserve_single_line_blocks = false
csharp_preserve_single_line_statements = false

View File

@ -30,41 +30,40 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Serialization; using System.Runtime.Serialization;
namespace Raylib_cs.Tests namespace Raylib_cs.Tests;
public static class BlittableHelper
{ {
public static class BlittableHelper public static bool IsBlittable<T>()
{ {
public static bool IsBlittable<T>() return IsBlittableCache<T>.VALUE;
{ }
return IsBlittableCache<T>.VALUE;
}
public static bool IsBlittable(this Type type) public static bool IsBlittable(this Type type)
{
if (type == typeof(decimal))
{ {
if (type == typeof(decimal)) return false;
{
return false;
}
if (type.IsArray)
{
var elementType = type.GetElementType();
return elementType != null && elementType.IsValueType && IsBlittable(elementType);
}
try
{
var instance = FormatterServices.GetUninitializedObject(type);
GCHandle.Alloc(instance, GCHandleType.Pinned).Free();
return true;
}
catch
{
return false;
}
} }
if (type.IsArray)
private static class IsBlittableCache<T>
{ {
public static readonly bool VALUE = IsBlittable(typeof(T)); var elementType = type.GetElementType();
return elementType != null && elementType.IsValueType && IsBlittable(elementType);
}
try
{
var instance = FormatterServices.GetUninitializedObject(type);
GCHandle.Alloc(instance, GCHandleType.Pinned).Free();
return true;
}
catch
{
return false;
} }
} }
private static class IsBlittableCache<T>
{
public static readonly bool VALUE = IsBlittable(typeof(T));
}
} }

View File

@ -1,46 +1,45 @@
using System; using System;
using Xunit; using Xunit;
namespace Raylib_cs.Tests namespace Raylib_cs.Tests;
{
public class RaylibTests
{
private unsafe void CheckType<T>() where T : unmanaged
{
Assert.True(BlittableHelper.IsBlittable<T>());
}
[Fact] public class RaylibTests
public void CheckTypes() {
{ private unsafe void CheckType<T>() where T : unmanaged
CheckType<Color>(); {
CheckType<Rectangle>(); Assert.True(BlittableHelper.IsBlittable<T>());
CheckType<Image>(); }
CheckType<Texture2D>();
CheckType<RenderTexture2D>(); [Fact]
CheckType<NPatchInfo>(); public void CheckTypes()
CheckType<GlyphInfo>(); {
CheckType<Font>(); CheckType<Color>();
CheckType<Camera2D>(); CheckType<Rectangle>();
CheckType<Camera3D>(); CheckType<Image>();
CheckType<Mesh>(); CheckType<Texture2D>();
CheckType<Shader>(); CheckType<RenderTexture2D>();
CheckType<MaterialMap>(); CheckType<NPatchInfo>();
CheckType<Material>(); CheckType<GlyphInfo>();
CheckType<Transform>(); CheckType<Font>();
CheckType<BoneInfo>(); CheckType<Camera2D>();
CheckType<Model>(); CheckType<Camera3D>();
CheckType<ModelAnimation>(); CheckType<Mesh>();
CheckType<Ray>(); CheckType<Shader>();
CheckType<RayCollision>(); CheckType<MaterialMap>();
CheckType<BoundingBox>(); CheckType<Material>();
CheckType<Wave>(); CheckType<Transform>();
CheckType<AudioStream>(); CheckType<BoneInfo>();
CheckType<Sound>(); CheckType<Model>();
CheckType<Music>(); CheckType<ModelAnimation>();
CheckType<VrDeviceInfo>(); CheckType<Ray>();
CheckType<VrStereoConfig>(); CheckType<RayCollision>();
CheckType<RenderBatch>(); CheckType<BoundingBox>();
} CheckType<Wave>();
CheckType<AudioStream>();
CheckType<Sound>();
CheckType<Music>();
CheckType<VrDeviceInfo>();
CheckType<VrStereoConfig>();
CheckType<RenderBatch>();
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,123 +1,122 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Wave type, defines audio wave data
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Wave
{ {
/// <summary> /// <summary>
/// Wave type, defines audio wave data /// Number of samples
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public uint SampleCount;
public unsafe partial struct Wave
{
/// <summary>
/// Number of samples
/// </summary>
public uint SampleCount;
/// <summary>
/// Frequency (samples per second)
/// </summary>
public uint SampleRate;
/// <summary>
/// Bit depth (bits per sample): 8, 16, 32 (24 not supported)
/// </summary>
public uint SampleSize;
/// <summary>
/// Number of channels (1-mono, 2-stereo)
/// </summary>
public uint Channels;
//TODO: SPAN<byte> ?
/// <summary>
/// Buffer data pointer
/// </summary>
public void* Data;
}
/// <summary> /// <summary>
/// Audio stream type<br/> /// Frequency (samples per second)
/// NOTE: Useful to create custom audio streams not bound to a specific file
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public uint SampleRate;
public partial struct AudioStream
{
//TODO: convert
/// <summary>
/// Pointer to internal data(rAudioBuffer *) used by the audio system
/// </summary>
public IntPtr Buffer;
/// <summary>
/// Pointer to internal data processor, useful for audio effects
/// </summary>
public IntPtr Processor;
/// <summary>
/// Frequency (samples per second)
/// </summary>
public uint SampleRate;
/// <summary>
/// Bit depth (bits per sample): 8, 16, 32 (24 not supported)
/// </summary>
public uint SampleSize;
/// <summary>
/// Number of channels (1-mono, 2-stereo)
/// </summary>
public uint Channels;
}
/// <summary> /// <summary>
/// Sound source type /// Bit depth (bits per sample): 8, 16, 32 (24 not supported)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public uint SampleSize;
public partial struct Sound
{
/// <summary>
/// Audio stream
/// </summary>
public AudioStream Stream;
/// <summary>
/// Total number of frames (considering channels)
/// </summary>
public uint FrameCount;
}
/// <summary> /// <summary>
/// Music stream type (audio file streaming from memory)<br/> /// Number of channels (1-mono, 2-stereo)
/// NOTE: Anything longer than ~10 seconds should be streamed
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public uint Channels;
public unsafe partial struct Music
{
/// <summary>
/// Audio stream
/// </summary>
public AudioStream Stream;
/// <summary> //TODO: SPAN<byte> ?
/// Total number of samples /// <summary>
/// </summary> /// Buffer data pointer
public uint FrameCount; /// </summary>
public void* Data;
/// <summary> }
/// Music looping enable
/// </summary> /// <summary>
public CBool Looping; /// Audio stream type<br/>
/// NOTE: Useful to create custom audio streams not bound to a specific file
/// <summary> /// </summary>
/// Type of music context (audio filetype) [StructLayout(LayoutKind.Sequential)]
/// </summary> public partial struct AudioStream
public int CtxType; {
//TODO: convert
//TODO span /// <summary>
/// <summary> /// Pointer to internal data(rAudioBuffer *) used by the audio system
/// Audio context data, depends on type /// </summary>
/// </summary> public IntPtr Buffer;
public void* CtxData;
} /// <summary>
/// Pointer to internal data processor, useful for audio effects
/// </summary>
public IntPtr Processor;
/// <summary>
/// Frequency (samples per second)
/// </summary>
public uint SampleRate;
/// <summary>
/// Bit depth (bits per sample): 8, 16, 32 (24 not supported)
/// </summary>
public uint SampleSize;
/// <summary>
/// Number of channels (1-mono, 2-stereo)
/// </summary>
public uint Channels;
}
/// <summary>
/// Sound source type
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Sound
{
/// <summary>
/// Audio stream
/// </summary>
public AudioStream Stream;
/// <summary>
/// Total number of frames (considering channels)
/// </summary>
public uint FrameCount;
}
/// <summary>
/// Music stream type (audio file streaming from memory)<br/>
/// NOTE: Anything longer than ~10 seconds should be streamed
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Music
{
/// <summary>
/// Audio stream
/// </summary>
public AudioStream Stream;
/// <summary>
/// Total number of samples
/// </summary>
public uint FrameCount;
/// <summary>
/// Music looping enable
/// </summary>
public CBool Looping;
/// <summary>
/// Type of music context (audio filetype)
/// </summary>
public int CtxType;
//TODO span
/// <summary>
/// Audio context data, depends on type
/// </summary>
public void* CtxData;
} }

View File

@ -1,26 +1,25 @@
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>Bounding box type</summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct BoundingBox
{ {
/// <summary>Bounding box type</summary> /// <summary>
[StructLayout(LayoutKind.Sequential)] /// Minimum vertex box-corner
public partial struct BoundingBox /// </summary>
public Vector3 Min;
/// <summary>
/// Maximum vertex box-corner
/// </summary>
public Vector3 Max;
public BoundingBox(Vector3 min, Vector3 max)
{ {
/// <summary> this.Min = min;
/// Minimum vertex box-corner this.Max = max;
/// </summary>
public Vector3 Min;
/// <summary>
/// Maximum vertex box-corner
/// </summary>
public Vector3 Max;
public BoundingBox(Vector3 min, Vector3 max)
{
this.Min = min;
this.Max = max;
}
} }
} }

View File

@ -1,40 +1,39 @@
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Camera2D, defines position/orientation in 2d space
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Camera2D
{ {
/// <summary> /// <summary>
/// Camera2D, defines position/orientation in 2d space /// Camera offset (displacement from target)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public Vector2 Offset;
public partial struct Camera2D
/// <summary>
/// Camera target (rotation and zoom origin)
/// </summary>
public Vector2 Target;
/// <summary>
/// Camera rotation in degrees
/// </summary>
public float Rotation;
/// <summary>
/// Camera zoom (scaling), should be 1.0f by default
/// </summary>
public float Zoom;
public Camera2D(Vector2 offset, Vector2 target, float rotation, float zoom)
{ {
/// <summary> this.Offset = offset;
/// Camera offset (displacement from target) this.Target = target;
/// </summary> this.Rotation = rotation;
public Vector2 Offset; this.Zoom = zoom;
/// <summary>
/// Camera target (rotation and zoom origin)
/// </summary>
public Vector2 Target;
/// <summary>
/// Camera rotation in degrees
/// </summary>
public float Rotation;
/// <summary>
/// Camera zoom (scaling), should be 1.0f by default
/// </summary>
public float Zoom;
public Camera2D(Vector2 offset, Vector2 target, float rotation, float zoom)
{
this.Offset = offset;
this.Target = target;
this.Rotation = rotation;
this.Zoom = zoom;
}
} }
} }

View File

@ -1,67 +1,66 @@
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Camera system modes
/// </summary>
public enum CameraMode
{
CAMERA_CUSTOM = 0,
CAMERA_FREE,
CAMERA_ORBITAL,
CAMERA_FIRST_PERSON,
CAMERA_THIRD_PERSON
}
/// <summary>
/// Camera projection
/// </summary>
public enum CameraProjection
{
CAMERA_PERSPECTIVE = 0,
CAMERA_ORTHOGRAPHIC
}
/// <summary>
/// Camera3D, defines position/orientation in 3d space
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Camera3D
{ {
/// <summary> /// <summary>
/// Camera system modes /// Camera position
/// </summary> /// </summary>
public enum CameraMode public Vector3 Position;
{
CAMERA_CUSTOM = 0,
CAMERA_FREE,
CAMERA_ORBITAL,
CAMERA_FIRST_PERSON,
CAMERA_THIRD_PERSON
}
/// <summary> /// <summary>
/// Camera projection /// Camera target it looks-at
/// </summary> /// </summary>
public enum CameraProjection public Vector3 Target;
{
CAMERA_PERSPECTIVE = 0,
CAMERA_ORTHOGRAPHIC
}
/// <summary> /// <summary>
/// Camera3D, defines position/orientation in 3d space /// Camera up vector (rotation over its axis)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public Vector3 Up;
public partial struct Camera3D
/// <summary>
/// Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic
/// </summary>
public float FovY;
/// <summary>
/// Camera type, defines projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
/// </summary>
public CameraProjection Projection;
public Camera3D(Vector3 position, Vector3 target, Vector3 up, float fovY, CameraProjection projection)
{ {
/// <summary> this.Position = position;
/// Camera position this.Target = target;
/// </summary> this.Up = up;
public Vector3 Position; this.FovY = fovY;
this.Projection = projection;
/// <summary>
/// Camera target it looks-at
/// </summary>
public Vector3 Target;
/// <summary>
/// Camera up vector (rotation over its axis)
/// </summary>
public Vector3 Up;
/// <summary>
/// Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic
/// </summary>
public float FovY;
/// <summary>
/// Camera type, defines projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
/// </summary>
public CameraProjection Projection;
public Camera3D(Vector3 position, Vector3 target, Vector3 up, float fovY, CameraProjection projection)
{
this.Position = position;
this.Target = target;
this.Up = up;
this.FovY = fovY;
this.Projection = projection;
}
} }
} }

View File

@ -1,67 +1,66 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Color type, RGBA (32bit)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Color
{ {
/// <summary> public byte R;
/// Color type, RGBA (32bit) public byte G;
/// </summary> public byte B;
[StructLayout(LayoutKind.Sequential)] public byte A;
public partial struct Color
// Example - Color.RED instead of RED
// Custom raylib color palette for amazing visuals
public static readonly Color LIGHTGRAY = new Color(200, 200, 200, 255);
public static readonly Color GRAY = new Color(130, 130, 130, 255);
public static readonly Color DARKGRAY = new Color(80, 80, 80, 255);
public static readonly Color YELLOW = new Color(253, 249, 0, 255);
public static readonly Color GOLD = new Color(255, 203, 0, 255);
public static readonly Color ORANGE = new Color(255, 161, 0, 255);
public static readonly Color PINK = new Color(255, 109, 194, 255);
public static readonly Color RED = new Color(230, 41, 55, 255);
public static readonly Color MAROON = new Color(190, 33, 55, 255);
public static readonly Color GREEN = new Color(0, 228, 48, 255);
public static readonly Color LIME = new Color(0, 158, 47, 255);
public static readonly Color DARKGREEN = new Color(0, 117, 44, 255);
public static readonly Color SKYBLUE = new Color(102, 191, 255, 255);
public static readonly Color BLUE = new Color(0, 121, 241, 255);
public static readonly Color DARKBLUE = new Color(0, 82, 172, 255);
public static readonly Color PURPLE = new Color(200, 122, 255, 255);
public static readonly Color VIOLET = new Color(135, 60, 190, 255);
public static readonly Color DARKPURPLE = new Color(112, 31, 126, 255);
public static readonly Color BEIGE = new Color(211, 176, 131, 255);
public static readonly Color BROWN = new Color(127, 106, 79, 255);
public static readonly Color DARKBROWN = new Color(76, 63, 47, 255);
public static readonly Color WHITE = new Color(255, 255, 255, 255);
public static readonly Color BLACK = new Color(0, 0, 0, 255);
public static readonly Color BLANK = new Color(0, 0, 0, 0);
public static readonly Color MAGENTA = new Color(255, 0, 255, 255);
public static readonly Color RAYWHITE = new Color(245, 245, 245, 255);
public Color(byte r, byte g, byte b, byte a)
{ {
public byte R; this.R = r;
public byte G; this.G = g;
public byte B; this.B = b;
public byte A; this.A = a;
}
// Example - Color.RED instead of RED public Color(int r, int g, int b, int a)
// Custom raylib color palette for amazing visuals {
public static readonly Color LIGHTGRAY = new Color(200, 200, 200, 255); this.R = Convert.ToByte(r);
public static readonly Color GRAY = new Color(130, 130, 130, 255); this.G = Convert.ToByte(g);
public static readonly Color DARKGRAY = new Color(80, 80, 80, 255); this.B = Convert.ToByte(b);
public static readonly Color YELLOW = new Color(253, 249, 0, 255); this.A = Convert.ToByte(a);
public static readonly Color GOLD = new Color(255, 203, 0, 255); }
public static readonly Color ORANGE = new Color(255, 161, 0, 255);
public static readonly Color PINK = new Color(255, 109, 194, 255);
public static readonly Color RED = new Color(230, 41, 55, 255);
public static readonly Color MAROON = new Color(190, 33, 55, 255);
public static readonly Color GREEN = new Color(0, 228, 48, 255);
public static readonly Color LIME = new Color(0, 158, 47, 255);
public static readonly Color DARKGREEN = new Color(0, 117, 44, 255);
public static readonly Color SKYBLUE = new Color(102, 191, 255, 255);
public static readonly Color BLUE = new Color(0, 121, 241, 255);
public static readonly Color DARKBLUE = new Color(0, 82, 172, 255);
public static readonly Color PURPLE = new Color(200, 122, 255, 255);
public static readonly Color VIOLET = new Color(135, 60, 190, 255);
public static readonly Color DARKPURPLE = new Color(112, 31, 126, 255);
public static readonly Color BEIGE = new Color(211, 176, 131, 255);
public static readonly Color BROWN = new Color(127, 106, 79, 255);
public static readonly Color DARKBROWN = new Color(76, 63, 47, 255);
public static readonly Color WHITE = new Color(255, 255, 255, 255);
public static readonly Color BLACK = new Color(0, 0, 0, 255);
public static readonly Color BLANK = new Color(0, 0, 0, 0);
public static readonly Color MAGENTA = new Color(255, 0, 255, 255);
public static readonly Color RAYWHITE = new Color(245, 245, 245, 255);
public Color(byte r, byte g, byte b, byte a) public override string ToString()
{ {
this.R = r; return $"{{R:{R} G:{G} B:{B} A:{A}}}";
this.G = g;
this.B = b;
this.A = a;
}
public Color(int r, int g, int b, int a)
{
this.R = Convert.ToByte(r);
this.G = Convert.ToByte(g);
this.B = Convert.ToByte(b);
this.A = Convert.ToByte(a);
}
public override string ToString()
{
return $"{{R:{R} G:{G} B:{B} A:{A}}}";
}
} }
} }

View File

@ -1,181 +1,180 @@
using System; using System;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// System config flags<br/>
/// NOTE: Every bit registers one state (use it with bit masks)<br/>
/// By default all flags are set to 0
/// </summary>
[Flags]
public enum ConfigFlags : uint
{ {
/// <summary> /// <summary>
/// System config flags<br/> /// Set to try enabling V-Sync on GPU
/// NOTE: Every bit registers one state (use it with bit masks)<br/>
/// By default all flags are set to 0
/// </summary> /// </summary>
[Flags] FLAG_VSYNC_HINT = 0x00000040,
public enum ConfigFlags : uint
{
/// <summary>
/// Set to try enabling V-Sync on GPU
/// </summary>
FLAG_VSYNC_HINT = 0x00000040,
/// <summary>
/// Set to run program in fullscreen
/// </summary>
FLAG_FULLSCREEN_MODE = 0x00000002,
/// <summary>
/// Set to allow resizable window
/// </summary>
FLAG_WINDOW_RESIZABLE = 0x00000004,
/// <summary>
/// Set to disable window decoration (frame and buttons)
/// </summary>
FLAG_WINDOW_UNDECORATED = 0x00000008,
/// <summary>
/// Set to hide window
/// </summary>
FLAG_WINDOW_HIDDEN = 0x00000080,
/// <summary>
/// Set to minimize window (iconify)
/// </summary>
FLAG_WINDOW_MINIMIZED = 0x00000200,
/// <summary>
/// Set to maximize window (expanded to monitor)
/// </summary>
FLAG_WINDOW_MAXIMIZED = 0x00000400,
/// <summary>
/// Set to window non focused
/// </summary>
FLAG_WINDOW_UNFOCUSED = 0x00000800,
/// <summary>
/// Set to window always on top
/// </summary>
FLAG_WINDOW_TOPMOST = 0x00001000,
/// <summary>
/// Set to allow windows running while minimized
/// </summary>
FLAG_WINDOW_ALWAYS_RUN = 0x00000100,
/// <summary>
/// Set to allow transparent framebuffer
/// </summary>
FLAG_WINDOW_TRANSPARENT = 0x00000010,
/// <summary>
/// Set to support HighDPI
/// </summary>
FLAG_WINDOW_HIGHDPI = 0x00002000,
/// <summary>
/// Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED
/// </summary>
FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000,
/// <summary>
/// Set to try enabling MSAA 4X
/// </summary>
FLAG_MSAA_4X_HINT = 0x00000020,
/// <summary>
/// Set to try enabling interlaced video format (for V3D)
/// </summary>
FLAG_INTERLACED_HINT = 0x00010000,
}
/// <summary> /// <summary>
/// Trace log level<br/> /// Set to run program in fullscreen
/// NOTE: Organized by priority level
/// </summary> /// </summary>
public enum TraceLogLevel FLAG_FULLSCREEN_MODE = 0x00000002,
{
/// <summary>
/// Display all logs
/// </summary>
LOG_ALL = 0,
/// <summary>
/// Trace logging, intended for internal use only
/// </summary>
LOG_TRACE,
/// <summary>
/// Debug logging, used for internal debugging, it should be disabled on release builds
/// </summary>
LOG_DEBUG,
/// <summary>
/// Info logging, used for program execution info
/// </summary>
LOG_INFO,
/// <summary>
/// Warning logging, used on recoverable failures
/// </summary>
LOG_WARNING,
/// <summary>
/// Error logging, used on unrecoverable failures
/// </summary>
LOG_ERROR,
/// <summary>
/// Fatal logging, used to abort program: exit(EXIT_FAILURE)
/// </summary>
LOG_FATAL,
/// <summary>
/// Disable logging
/// </summary>
LOG_NONE
}
/// <summary> /// <summary>
/// Color blending modes (pre-defined) /// Set to allow resizable window
/// </summary> /// </summary>
public enum BlendMode FLAG_WINDOW_RESIZABLE = 0x00000004,
{
/// <summary>
/// Blend textures considering alpha (default)
/// </summary>
BLEND_ALPHA = 0,
/// <summary> /// <summary>
/// Blend textures adding colors /// Set to disable window decoration (frame and buttons)
/// </summary> /// </summary>
BLEND_ADDITIVE, FLAG_WINDOW_UNDECORATED = 0x00000008,
/// <summary> /// <summary>
/// Blend textures multiplying colors /// Set to hide window
/// </summary> /// </summary>
BLEND_MULTIPLIED, FLAG_WINDOW_HIDDEN = 0x00000080,
/// <summary> /// <summary>
/// Blend textures adding colors (alternative) /// Set to minimize window (iconify)
/// </summary> /// </summary>
BLEND_ADD_COLORS, FLAG_WINDOW_MINIMIZED = 0x00000200,
/// <summary> /// <summary>
/// Blend textures subtracting colors (alternative) /// Set to maximize window (expanded to monitor)
/// </summary> /// </summary>
BLEND_SUBTRACT_COLORS, FLAG_WINDOW_MAXIMIZED = 0x00000400,
/// <summary> /// <summary>
/// Blend premultiplied textures considering alpha /// Set to window non focused
/// </summary> /// </summary>
BLEND_ALPHA_PREMULTIPLY, FLAG_WINDOW_UNFOCUSED = 0x00000800,
/// <summary> /// <summary>
/// Blend textures using custom src/dst factors (use rlSetBlendFactors()) /// Set to window always on top
/// </summary> /// </summary>
BLEND_CUSTOM, FLAG_WINDOW_TOPMOST = 0x00001000,
/// <summary> /// <summary>
/// Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate()) /// Set to allow windows running while minimized
/// </summary> /// </summary>
BLEND_CUSTOM_SEPARATE FLAG_WINDOW_ALWAYS_RUN = 0x00000100,
}
/// <summary>
/// Set to allow transparent framebuffer
/// </summary>
FLAG_WINDOW_TRANSPARENT = 0x00000010,
/// <summary>
/// Set to support HighDPI
/// </summary>
FLAG_WINDOW_HIGHDPI = 0x00002000,
/// <summary>
/// Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED
/// </summary>
FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000,
/// <summary>
/// Set to try enabling MSAA 4X
/// </summary>
FLAG_MSAA_4X_HINT = 0x00000020,
/// <summary>
/// Set to try enabling interlaced video format (for V3D)
/// </summary>
FLAG_INTERLACED_HINT = 0x00010000,
}
/// <summary>
/// Trace log level<br/>
/// NOTE: Organized by priority level
/// </summary>
public enum TraceLogLevel
{
/// <summary>
/// Display all logs
/// </summary>
LOG_ALL = 0,
/// <summary>
/// Trace logging, intended for internal use only
/// </summary>
LOG_TRACE,
/// <summary>
/// Debug logging, used for internal debugging, it should be disabled on release builds
/// </summary>
LOG_DEBUG,
/// <summary>
/// Info logging, used for program execution info
/// </summary>
LOG_INFO,
/// <summary>
/// Warning logging, used on recoverable failures
/// </summary>
LOG_WARNING,
/// <summary>
/// Error logging, used on unrecoverable failures
/// </summary>
LOG_ERROR,
/// <summary>
/// Fatal logging, used to abort program: exit(EXIT_FAILURE)
/// </summary>
LOG_FATAL,
/// <summary>
/// Disable logging
/// </summary>
LOG_NONE
}
/// <summary>
/// Color blending modes (pre-defined)
/// </summary>
public enum BlendMode
{
/// <summary>
/// Blend textures considering alpha (default)
/// </summary>
BLEND_ALPHA = 0,
/// <summary>
/// Blend textures adding colors
/// </summary>
BLEND_ADDITIVE,
/// <summary>
/// Blend textures multiplying colors
/// </summary>
BLEND_MULTIPLIED,
/// <summary>
/// Blend textures adding colors (alternative)
/// </summary>
BLEND_ADD_COLORS,
/// <summary>
/// Blend textures subtracting colors (alternative)
/// </summary>
BLEND_SUBTRACT_COLORS,
/// <summary>
/// Blend premultiplied textures considering alpha
/// </summary>
BLEND_ALPHA_PREMULTIPLY,
/// <summary>
/// Blend textures using custom src/dst factors (use rlSetBlendFactors())
/// </summary>
BLEND_CUSTOM,
/// <summary>
/// Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate())
/// </summary>
BLEND_CUSTOM_SEPARATE
} }

View File

@ -1,94 +1,93 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Font type, defines generation method
/// </summary>
public enum FontType
{ {
/// <summary> /// <summary>
/// Font type, defines generation method /// Default font generation, anti-aliased
/// </summary> /// </summary>
public enum FontType FONT_DEFAULT = 0,
{
/// <summary>
/// Default font generation, anti-aliased
/// </summary>
FONT_DEFAULT = 0,
/// <summary>
/// Bitmap font generation, no anti-aliasing
/// </summary>
FONT_BITMAP,
/// <summary>
/// SDF font generation, requires external shader
/// </summary>
FONT_SDF
}
/// <summary> /// <summary>
/// GlyphInfo, font characters glyphs info /// Bitmap font generation, no anti-aliasing
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] FONT_BITMAP,
public partial struct GlyphInfo
{
/// <summary>
/// Character value (Unicode)
/// </summary>
public int Value;
/// <summary>
/// Character offset X when drawing
/// </summary>
public int OffsetX;
/// <summary>
/// Character offset Y when drawing
/// </summary>
public int OffsetY;
/// <summary>
/// Character advance position X
/// </summary>
public int AdvanceX;
/// <summary>
/// Character image data
/// </summary>
public Image Image;
}
/// <summary> /// <summary>
/// Font, font texture and GlyphInfo array data /// SDF font generation, requires external shader
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] FONT_SDF
public unsafe partial struct Font }
{
/// <summary> /// <summary>
/// Base size (default chars height) /// GlyphInfo, font characters glyphs info
/// </summary> /// </summary>
public int BaseSize; [StructLayout(LayoutKind.Sequential)]
public partial struct GlyphInfo
/// <summary> {
/// Number of characters /// <summary>
/// </summary> /// Character value (Unicode)
public int GlyphCount; /// </summary>
public int Value;
/// <summary>
/// Padding around the glyph characters /// <summary>
/// </summary> /// Character offset X when drawing
public int GlyphPadding; /// </summary>
public int OffsetX;
/// <summary>
/// Texture atlas containing the glyphs /// <summary>
/// </summary> /// Character offset Y when drawing
public Texture2D Texture; /// </summary>
public int OffsetY;
/// <summary>
/// Rectangles in texture for the glyphs /// <summary>
/// </summary> /// Character advance position X
public Rectangle* Recs; /// </summary>
public int AdvanceX;
/// <summary>
/// Glyphs info data /// <summary>
/// </summary> /// Character image data
public GlyphInfo* Glyphs; /// </summary>
} public Image Image;
}
/// <summary>
/// Font, font texture and GlyphInfo array data
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Font
{
/// <summary>
/// Base size (default chars height)
/// </summary>
public int BaseSize;
/// <summary>
/// Number of characters
/// </summary>
public int GlyphCount;
/// <summary>
/// Padding around the glyph characters
/// </summary>
public int GlyphPadding;
/// <summary>
/// Texture atlas containing the glyphs
/// </summary>
public Texture2D Texture;
/// <summary>
/// Rectangles in texture for the glyphs
/// </summary>
public Rectangle* Recs;
/// <summary>
/// Glyphs info data
/// </summary>
public GlyphInfo* Glyphs;
} }

View File

@ -1,148 +1,147 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Pixel formats<br/>
/// NOTE: Support depends on OpenGL version and platform
/// </summary>
public enum PixelFormat
{ {
/// <summary> /// <summary>
/// Pixel formats<br/> /// 8 bit per pixel (no alpha)
/// NOTE: Support depends on OpenGL version and platform
/// </summary> /// </summary>
public enum PixelFormat PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1,
{
/// <summary>
/// 8 bit per pixel (no alpha)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1,
/// <summary>
/// 8*2 bpp (2 channels)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA,
/// <summary>
/// 16 bpp
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R5G6B5,
/// <summary>
/// 24 bpp
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R8G8B8,
/// <summary>
/// 16 bpp (1 bit alpha)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R5G5B5A1,
/// <summary>
/// 16 bpp (4 bit alpha)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R4G4B4A4,
/// <summary>
/// 32 bpp
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
/// <summary>
/// 32 bpp (1 channel - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32,
/// <summary>
/// 32*3 bpp (3 channels - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32G32B32,
/// <summary>
/// 32*4 bpp (4 channels - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32G32B32A32,
/// <summary>
/// 4 bpp (no alpha)
/// </summary>
PIXELFORMAT_COMPRESSED_DXT1_RGB,
/// <summary>
/// 4 bpp (1 bit alpha)
/// </summary>
PIXELFORMAT_COMPRESSED_DXT1_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_DXT3_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_DXT5_RGBA,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC1_RGB,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC2_RGB,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_PVRT_RGB,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_PVRT_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA,
/// <summary>
/// 2 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA
}
/// <summary> /// <summary>
/// Image, pixel data stored in CPU memory (RAM) /// 8*2 bpp (2 channels)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA,
public unsafe partial struct Image
{
/// <summary>
/// Image raw data
/// </summary>
public void* Data;
/// <summary> /// <summary>
/// Image base width /// 16 bpp
/// </summary> /// </summary>
public int Width; PIXELFORMAT_UNCOMPRESSED_R5G6B5,
/// <summary> /// <summary>
/// Image base height /// 24 bpp
/// </summary> /// </summary>
public int Height; PIXELFORMAT_UNCOMPRESSED_R8G8B8,
/// <summary> /// <summary>
/// Mipmap levels, 1 by default /// 16 bpp (1 bit alpha)
/// </summary> /// </summary>
public int Mipmaps; PIXELFORMAT_UNCOMPRESSED_R5G5B5A1,
/// <summary> /// <summary>
/// Data format (PixelFormat type) /// 16 bpp (4 bit alpha)
/// </summary> /// </summary>
public PixelFormat Format; PIXELFORMAT_UNCOMPRESSED_R4G4B4A4,
}
/// <summary>
/// 32 bpp
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
/// <summary>
/// 32 bpp (1 channel - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32,
/// <summary>
/// 32*3 bpp (3 channels - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32G32B32,
/// <summary>
/// 32*4 bpp (4 channels - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32G32B32A32,
/// <summary>
/// 4 bpp (no alpha)
/// </summary>
PIXELFORMAT_COMPRESSED_DXT1_RGB,
/// <summary>
/// 4 bpp (1 bit alpha)
/// </summary>
PIXELFORMAT_COMPRESSED_DXT1_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_DXT3_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_DXT5_RGBA,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC1_RGB,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC2_RGB,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_PVRT_RGB,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_PVRT_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA,
/// <summary>
/// 2 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA
}
/// <summary>
/// Image, pixel data stored in CPU memory (RAM)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Image
{
/// <summary>
/// Image raw data
/// </summary>
public void* Data;
/// <summary>
/// Image base width
/// </summary>
public int Width;
/// <summary>
/// Image base height
/// </summary>
public int Height;
/// <summary>
/// Mipmap levels, 1 by default
/// </summary>
public int Mipmaps;
/// <summary>
/// Data format (PixelFormat type)
/// </summary>
public PixelFormat Format;
} }

File diff suppressed because it is too large Load Diff

View File

@ -4,161 +4,160 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
internal readonly struct Native
{ {
internal readonly struct Native internal const string Msvcrt = "msvcrt";
internal const string Libc = "libc";
internal const string LibSystem = "libSystem";
[DllImport(LibSystem, EntryPoint = "vasprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VasPrintfApple(ref IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Libc, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsPrintfLinux(IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Msvcrt, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsPrintfWindows(IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Libc, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsnPrintfLinux(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args);
[DllImport(Msvcrt, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsnPrintfWindows(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args);
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
struct VaListLinuxX64
{
uint _gpOffset;
uint _fpOffset;
IntPtr _overflowArgArea;
IntPtr _regSaveArea;
}
/// <summary>
/// Logging workaround for formatting strings from native code
/// </summary>
public static unsafe class Logging
{
[UnmanagedCallersOnly(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static unsafe void LogConsole(int msgType, sbyte* text, sbyte* args)
{ {
internal const string Msvcrt = "msvcrt"; var message = GetLogMessage(new IntPtr(text), new IntPtr(args));
internal const string Libc = "libc"; Console.WriteLine(message);
internal const string LibSystem = "libSystem";
[DllImport(LibSystem, EntryPoint = "vasprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VasPrintfApple(ref IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Libc, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsPrintfLinux(IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Msvcrt, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsPrintfWindows(IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Libc, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsnPrintfLinux(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args);
[DllImport(Msvcrt, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsnPrintfWindows(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args);
} }
[StructLayout(LayoutKind.Sequential, Pack = 4)] public static string GetLogMessage(IntPtr format, IntPtr args)
struct VaListLinuxX64
{ {
uint _gpOffset; if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
uint _fpOffset;
IntPtr _overflowArgArea;
IntPtr _regSaveArea;
}
/// <summary>
/// Logging workaround for formatting strings from native code
/// </summary>
public static unsafe class Logging
{
[UnmanagedCallersOnly(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static unsafe void LogConsole(int msgType, sbyte* text, sbyte* args)
{ {
var message = GetLogMessage(new IntPtr(text), new IntPtr(args)); return AppleLogCallback(format, args);
Console.WriteLine(message);
} }
public static string GetLogMessage(IntPtr format, IntPtr args) // Special marshalling is needed on Linux desktop 64 bits.
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && IntPtr.Size == 8)
{ {
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) return LinuxX64LogCallback(format, args);
{ }
return AppleLogCallback(format, args);
}
// Special marshalling is needed on Linux desktop 64 bits. var byteLength = VsnPrintf(IntPtr.Zero, UIntPtr.Zero, format, args) + 1;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && IntPtr.Size == 8) if (byteLength <= 1)
{ {
return LinuxX64LogCallback(format, args); return string.Empty;
} }
var byteLength = VsnPrintf(IntPtr.Zero, UIntPtr.Zero, format, args) + 1; var buffer = Marshal.AllocHGlobal(byteLength);
if (byteLength <= 1) VsPrintf(buffer, format, args);
string result = Marshal.PtrToStringUTF8(buffer);
Marshal.FreeHGlobal(buffer);
return result;
}
static string AppleLogCallback(IntPtr format, IntPtr args)
{
IntPtr buffer = IntPtr.Zero;
try
{
var count = Native.VasPrintfApple(ref buffer, format, args);
if (count == -1)
{ {
return string.Empty; return string.Empty;
} }
return Marshal.PtrToStringUTF8(buffer) ?? string.Empty;
var buffer = Marshal.AllocHGlobal(byteLength); }
VsPrintf(buffer, format, args); finally
{
string result = Marshal.PtrToStringUTF8(buffer);
Marshal.FreeHGlobal(buffer); Marshal.FreeHGlobal(buffer);
return result;
}
static string AppleLogCallback(IntPtr format, IntPtr args)
{
IntPtr buffer = IntPtr.Zero;
try
{
var count = Native.VasPrintfApple(ref buffer, format, args);
if (count == -1)
{
return string.Empty;
}
return Marshal.PtrToStringUTF8(buffer) ?? string.Empty;
}
finally
{
Marshal.FreeHGlobal(buffer);
}
}
static string LinuxX64LogCallback(IntPtr format, IntPtr args)
{
// The args pointer cannot be reused between two calls. We need to make a copy of the underlying structure.
var listStructure = Marshal.PtrToStructure<VaListLinuxX64>(args);
IntPtr listPointer = IntPtr.Zero;
int byteLength = 0;
string result = "";
// Get length of args
listPointer = Marshal.AllocHGlobal(Marshal.SizeOf(listStructure));
Marshal.StructureToPtr(listStructure, listPointer, false);
byteLength = Native.VsnPrintfLinux(IntPtr.Zero, UIntPtr.Zero, format, listPointer) + 1;
// Allocate buffer for result
Marshal.StructureToPtr(listStructure, listPointer, false);
IntPtr utf8Buffer = IntPtr.Zero;
utf8Buffer = Marshal.AllocHGlobal(byteLength);
// Print result into buffer
Native.VsPrintfLinux(utf8Buffer, format, listPointer);
result = Marshal.PtrToStringUTF8(utf8Buffer);
Marshal.FreeHGlobal(listPointer);
Marshal.FreeHGlobal(utf8Buffer);
return result;
}
// https://github.com/dotnet/runtime/issues/51052
static int VsnPrintf(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args)
{
var os = Environment.OSVersion;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Native.VsnPrintfWindows(buffer, size, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return Native.VsnPrintfLinux(buffer, size, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
{
return Native.VsPrintfLinux(buffer, format, args);
}
return -1;
}
// https://github.com/dotnet/runtime/issues/51052
static int VsPrintf(IntPtr buffer, IntPtr format, IntPtr args)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Native.VsPrintfWindows(buffer, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return Native.VsPrintfLinux(buffer, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
{
return Native.VsPrintfLinux(buffer, format, args);
}
return -1;
} }
} }
static string LinuxX64LogCallback(IntPtr format, IntPtr args)
{
// The args pointer cannot be reused between two calls. We need to make a copy of the underlying structure.
var listStructure = Marshal.PtrToStructure<VaListLinuxX64>(args);
IntPtr listPointer = IntPtr.Zero;
int byteLength = 0;
string result = "";
// Get length of args
listPointer = Marshal.AllocHGlobal(Marshal.SizeOf(listStructure));
Marshal.StructureToPtr(listStructure, listPointer, false);
byteLength = Native.VsnPrintfLinux(IntPtr.Zero, UIntPtr.Zero, format, listPointer) + 1;
// Allocate buffer for result
Marshal.StructureToPtr(listStructure, listPointer, false);
IntPtr utf8Buffer = IntPtr.Zero;
utf8Buffer = Marshal.AllocHGlobal(byteLength);
// Print result into buffer
Native.VsPrintfLinux(utf8Buffer, format, listPointer);
result = Marshal.PtrToStringUTF8(utf8Buffer);
Marshal.FreeHGlobal(listPointer);
Marshal.FreeHGlobal(utf8Buffer);
return result;
}
// https://github.com/dotnet/runtime/issues/51052
static int VsnPrintf(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args)
{
var os = Environment.OSVersion;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Native.VsnPrintfWindows(buffer, size, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return Native.VsnPrintfLinux(buffer, size, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
{
return Native.VsPrintfLinux(buffer, format, args);
}
return -1;
}
// https://github.com/dotnet/runtime/issues/51052
static int VsPrintf(IntPtr buffer, IntPtr format, IntPtr args)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Native.VsPrintfWindows(buffer, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return Native.VsPrintfLinux(buffer, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
{
return Native.VsPrintfLinux(buffer, format, args);
}
return -1;
}
} }

View File

@ -1,91 +1,90 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Material map index
/// </summary>
public enum MaterialMapIndex
{ {
/// <summary> /// <summary>
/// Material map index /// NOTE: Same as MATERIAL_MAP_DIFFUSE
/// </summary> /// </summary>
public enum MaterialMapIndex MATERIAL_MAP_ALBEDO = 0,
{
/// <summary>
/// NOTE: Same as MATERIAL_MAP_DIFFUSE
/// </summary>
MATERIAL_MAP_ALBEDO = 0,
/// <summary>
/// NOTE: Same as MATERIAL_MAP_SPECULAR
/// </summary>
MATERIAL_MAP_METALNESS,
MATERIAL_MAP_NORMAL,
MATERIAL_MAP_ROUGHNESS,
MATERIAL_MAP_OCCLUSION,
MATERIAL_MAP_EMISSION,
MATERIAL_MAP_HEIGHT,
/// <summary>
/// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary>
MATERIAL_MAP_CUBEMAP,
/// <summary>
/// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary>
MATERIAL_MAP_IRRADIANCE,
/// <summary>
/// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary>
MATERIAL_MAP_PREFILTER,
MATERIAL_MAP_BRDF,
MATERIAL_MAP_DIFFUSE = MATERIAL_MAP_ALBEDO,
MATERIAL_MAP_SPECULAR = MATERIAL_MAP_METALNESS,
}
/// <summary> /// <summary>
/// Material texture map /// NOTE: Same as MATERIAL_MAP_SPECULAR
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] MATERIAL_MAP_METALNESS,
public partial struct MaterialMap
{
/// <summary>
/// Material map texture
/// </summary>
public Texture2D Texture;
/// <summary> MATERIAL_MAP_NORMAL,
/// Material map color MATERIAL_MAP_ROUGHNESS,
/// </summary> MATERIAL_MAP_OCCLUSION,
public Color Color; MATERIAL_MAP_EMISSION,
MATERIAL_MAP_HEIGHT,
/// <summary>
/// Material map value
/// </summary>
public float Value;
}
/// <summary> /// <summary>
/// Material type (generic) /// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] MATERIAL_MAP_CUBEMAP,
public unsafe partial struct Material
{
/// <summary>
/// Material shader
/// </summary>
public Shader Shader;
//TODO: convert /// <summary>
/// <summary> /// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// Material maps /// </summary>
/// </summary> MATERIAL_MAP_IRRADIANCE,
public MaterialMap* Maps;
/// <summary> /// <summary>
/// Material generic parameters (if required) /// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary> /// </summary>
public fixed float Param[4]; MATERIAL_MAP_PREFILTER,
}
MATERIAL_MAP_BRDF,
MATERIAL_MAP_DIFFUSE = MATERIAL_MAP_ALBEDO,
MATERIAL_MAP_SPECULAR = MATERIAL_MAP_METALNESS,
}
/// <summary>
/// Material texture map
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct MaterialMap
{
/// <summary>
/// Material map texture
/// </summary>
public Texture2D Texture;
/// <summary>
/// Material map color
/// </summary>
public Color Color;
/// <summary>
/// Material map value
/// </summary>
public float Value;
}
/// <summary>
/// Material type (generic)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Material
{
/// <summary>
/// Material shader
/// </summary>
public Shader Shader;
//TODO: convert
/// <summary>
/// Material maps
/// </summary>
public MaterialMap* Maps;
/// <summary>
/// Material generic parameters (if required)
/// </summary>
public fixed float Param[4];
} }

View File

@ -1,99 +1,98 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Vertex data definning a mesh<br/>
/// NOTE: Data stored in CPU memory (and GPU)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Mesh
{ {
/// <summary> /// <summary>
/// Vertex data definning a mesh<br/> /// Number of vertices stored in arrays
/// NOTE: Data stored in CPU memory (and GPU)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public int VertexCount;
public unsafe partial struct Mesh
{
/// <summary>
/// Number of vertices stored in arrays
/// </summary>
public int VertexCount;
/// <summary> /// <summary>
/// Number of triangles stored (indexed or not) /// Number of triangles stored (indexed or not)
/// </summary> /// </summary>
public int TriangleCount; public int TriangleCount;
#region Default vertex data #region Default vertex data
/// <summary> /// <summary>
/// Vertex position (XYZ - 3 components per vertex) (shader-location = 0) /// Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
/// </summary> /// </summary>
public float* Vertices; public float* Vertices;
/// <summary> /// <summary>
/// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) /// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
/// </summary> /// </summary>
public float* TexCoords; public float* TexCoords;
/// <summary> /// <summary>
/// Vertex second texture coordinates (useful for lightmaps) (shader-location = 5) /// Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
/// </summary> /// </summary>
public float* TexCoords2; public float* TexCoords2;
/// <summary> /// <summary>
/// Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) /// Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
/// </summary> /// </summary>
public float* Normals; public float* Normals;
/// <summary> /// <summary>
/// Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) /// Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
/// </summary> /// </summary>
public float* Tangents; public float* Tangents;
/// <summary> /// <summary>
/// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) /// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
/// </summary> /// </summary>
public byte* Colors; public byte* Colors;
/// <summary> /// <summary>
/// Vertex indices (in case vertex data comes indexed) /// Vertex indices (in case vertex data comes indexed)
/// </summary> /// </summary>
public ushort* Indices; public ushort* Indices;
#endregion #endregion
#region Animation vertex data #region Animation vertex data
/// <summary> /// <summary>
/// Animated vertex positions (after bones transformations) /// Animated vertex positions (after bones transformations)
/// </summary> /// </summary>
public float* AnimVertices; public float* AnimVertices;
/// <summary> /// <summary>
/// Animated normals (after bones transformations) /// Animated normals (after bones transformations)
/// </summary> /// </summary>
public float* AnimNormals; public float* AnimNormals;
/// <summary> /// <summary>
/// Vertex bone ids, up to 4 bones influence by vertex (skinning) /// Vertex bone ids, up to 4 bones influence by vertex (skinning)
/// </summary> /// </summary>
public byte* BoneIds; public byte* BoneIds;
/// <summary> /// <summary>
/// Vertex bone weight, up to 4 bones influence by vertex (skinning) /// Vertex bone weight, up to 4 bones influence by vertex (skinning)
/// </summary> /// </summary>
public float* BoneWeights; public float* BoneWeights;
#endregion #endregion
#region OpenGL identifiers #region OpenGL identifiers
/// <summary> /// <summary>
/// OpenGL Vertex Array Object id /// OpenGL Vertex Array Object id
/// </summary> /// </summary>
public uint VaoId; public uint VaoId;
/// <summary> /// <summary>
/// OpenGL Vertex Buffer Objects id (default vertex data, uint[]) /// OpenGL Vertex Buffer Objects id (default vertex data, uint[])
/// </summary> /// </summary>
public uint* VboId; public uint* VboId;
#endregion #endregion
}
} }

View File

@ -2,144 +2,143 @@ using System;
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Bone information
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct BoneInfo
{ {
/// <summary> /// <summary>
/// Bone information /// Bone name (char[32])
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public fixed sbyte Name[32];
public unsafe partial struct BoneInfo
{
/// <summary>
/// Bone name (char[32])
/// </summary>
public fixed sbyte Name[32];
/// <summary>
/// Bone parent
/// </summary>
public int Parent;
}
/// <summary> /// <summary>
/// Model type /// Bone parent
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public int Parent;
public unsafe partial struct Model }
{
/// <summary>
/// Local transform matrix
/// </summary>
public Matrix4x4 Transform;
/// <summary> /// <summary>
/// Number of meshes /// Model type
/// </summary> /// </summary>
public int MeshCount; [StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Model
/// <summary> {
/// Number of materials /// <summary>
/// </summary> /// Local transform matrix
public int MaterialCount; /// </summary>
public Matrix4x4 Transform;
/// <summary>
/// Meshes array (Mesh *)
/// </summary>
public Mesh* Meshes;
/// <summary>
/// Materials array (Material *)
/// </summary>
public Material* Materials;
/// <summary>
/// Mesh material number (int *)
/// </summary>
public int* MeshMaterial;
/// <summary>
/// Number of bones
/// </summary>
public int BoneCount;
//TODO: Span
/// <summary>
/// Bones information (skeleton, BoneInfo *)
/// </summary>
public BoneInfo* Bones;
//TODO: Span
/// <summary>
/// Bones base transformation (pose, Transform *)
/// </summary>
public Transform* BindPose;
}
/// <summary> /// <summary>
/// Model animation /// Number of meshes
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public int MeshCount;
public readonly unsafe partial struct ModelAnimation
/// <summary>
/// Number of materials
/// </summary>
public int MaterialCount;
/// <summary>
/// Meshes array (Mesh *)
/// </summary>
public Mesh* Meshes;
/// <summary>
/// Materials array (Material *)
/// </summary>
public Material* Materials;
/// <summary>
/// Mesh material number (int *)
/// </summary>
public int* MeshMaterial;
/// <summary>
/// Number of bones
/// </summary>
public int BoneCount;
//TODO: Span
/// <summary>
/// Bones information (skeleton, BoneInfo *)
/// </summary>
public BoneInfo* Bones;
//TODO: Span
/// <summary>
/// Bones base transformation (pose, Transform *)
/// </summary>
public Transform* BindPose;
}
/// <summary>
/// Model animation
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public readonly unsafe partial struct ModelAnimation
{
/// <summary>
/// Number of bones
/// </summary>
public readonly int BoneCount;
/// <summary>
/// Number of animation frames
/// </summary>
public readonly int FrameCount;
/// <summary>
/// Bones information (skeleton, BoneInfo *)
/// </summary>
public readonly BoneInfo* Bones;
/// <inheritdoc cref="Bones"/>
public ReadOnlySpan<BoneInfo> BoneInfo => new(Bones, BoneCount);
/// <summary>
/// Poses array by frame (Transform **)
/// </summary>
public readonly Transform** FramePoses;
/// <inheritdoc cref="FramePoses"/>
public FramePosesCollection FramePosesColl => new(FramePoses, FrameCount, BoneCount);
public struct FramePosesCollection
{ {
/// <summary> readonly Transform** _framePoses;
/// Number of bones
/// </summary>
public readonly int BoneCount;
/// <summary> readonly int _frameCount;
/// Number of animation frames
/// </summary>
public readonly int FrameCount;
/// <summary> readonly int _boneCount;
/// Bones information (skeleton, BoneInfo *)
/// </summary>
public readonly BoneInfo* Bones;
/// <inheritdoc cref="Bones"/> public FramePoses this[int index] => new(_framePoses[index], _boneCount);
public ReadOnlySpan<BoneInfo> BoneInfo => new(Bones, BoneCount);
/// <summary> public Transform this[int index1, int index2] => new FramePoses(_framePoses[index1], _boneCount)[index2];
/// Poses array by frame (Transform **)
/// </summary>
public readonly Transform** FramePoses;
/// <inheritdoc cref="FramePoses"/> internal FramePosesCollection(Transform** framePoses, int frameCount, int boneCount)
public FramePosesCollection FramePosesColl => new(FramePoses, FrameCount, BoneCount);
public struct FramePosesCollection
{ {
readonly Transform** _framePoses; this._framePoses = framePoses;
this._frameCount = frameCount;
readonly int _frameCount; this._boneCount = boneCount;
readonly int _boneCount;
public FramePoses this[int index] => new(_framePoses[index], _boneCount);
public Transform this[int index1, int index2] => new FramePoses(_framePoses[index1], _boneCount)[index2];
internal FramePosesCollection(Transform** framePoses, int frameCount, int boneCount)
{
this._framePoses = framePoses;
this._frameCount = frameCount;
this._boneCount = boneCount;
}
}
}
public unsafe struct FramePoses
{
readonly Transform* _poses;
readonly int _count;
public ref Transform this[int index] => ref _poses[index];
internal FramePoses(Transform* poses, int count)
{
this._poses = poses;
this._count = count;
} }
} }
} }
public unsafe struct FramePoses
{
readonly Transform* _poses;
readonly int _count;
public ref Transform this[int index] => ref _poses[index];
internal FramePoses(Transform* poses, int count)
{
this._poses = poses;
this._count = count;
}
}

View File

@ -1,62 +1,61 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// N-patch layout
/// </summary>
public enum NPatchLayout
{ {
/// <summary> /// <summary>
/// N-patch layout /// Npatch defined by 3x3 tiles
/// </summary> /// </summary>
public enum NPatchLayout NPATCH_NINE_PATCH = 0,
{
/// <summary>
/// Npatch defined by 3x3 tiles
/// </summary>
NPATCH_NINE_PATCH = 0,
/// <summary>
/// Npatch defined by 1x3 tiles
/// </summary>
NPATCH_THREE_PATCH_VERTICAL,
/// <summary>
/// Npatch defined by 3x1 tiles
/// </summary>
NPATCH_THREE_PATCH_HORIZONTAL
}
/// <summary> /// <summary>
/// N-Patch layout info /// Npatch defined by 1x3 tiles
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] NPATCH_THREE_PATCH_VERTICAL,
public partial struct NPatchInfo
{
/// <summary>
/// Texture source rectangle
/// </summary>
public Rectangle Source;
/// <summary> /// <summary>
/// Left border offset /// Npatch defined by 3x1 tiles
/// </summary> /// </summary>
public int Left; NPATCH_THREE_PATCH_HORIZONTAL
}
/// <summary>
/// Top border offset /// <summary>
/// </summary> /// N-Patch layout info
public int Top; /// </summary>
[StructLayout(LayoutKind.Sequential)]
/// <summary> public partial struct NPatchInfo
/// Right border offset {
/// </summary> /// <summary>
public int Right; /// Texture source rectangle
/// </summary>
/// <summary> public Rectangle Source;
/// Bottom border offset
/// </summary> /// <summary>
public int Bottom; /// Left border offset
/// </summary>
/// <summary> public int Left;
/// Layout of the n-patch: 3x3, 1x3 or 3x1
/// </summary> /// <summary>
public NPatchLayout Layout; /// Top border offset
} /// </summary>
public int Top;
/// <summary>
/// Right border offset
/// </summary>
public int Right;
/// <summary>
/// Bottom border offset
/// </summary>
public int Bottom;
/// <summary>
/// Layout of the n-patch: 3x3, 1x3 or 3x1
/// </summary>
public NPatchLayout Layout;
} }

View File

@ -1,55 +1,54 @@
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Ray, ray for raycasting
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Ray
{ {
/// <summary> /// <summary>
/// Ray, ray for raycasting /// Ray position (origin)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public Vector3 Position;
public partial struct Ray
{
/// <summary>
/// Ray position (origin)
/// </summary>
public Vector3 Position;
/// <summary>
/// Ray direction
/// </summary>
public Vector3 Direction;
public Ray(Vector3 position, Vector3 direction)
{
this.Position = position;
this.Direction = direction;
}
}
/// <summary> /// <summary>
/// Raycast hit information /// Ray direction
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public Vector3 Direction;
public partial struct RayCollision
public Ray(Vector3 position, Vector3 direction)
{ {
/// <summary> this.Position = position;
/// Did the ray hit something? this.Direction = direction;
/// </summary>
public CBool Hit;
/// <summary>
/// Distance to the nearest hit
/// </summary>
public float Distance;
/// <summary>
/// Point of the nearest hit
/// </summary>
public Vector3 Point;
/// <summary>
/// Surface normal of hit
/// </summary>
public Vector3 Normal;
} }
} }
/// <summary>
/// Raycast hit information
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct RayCollision
{
/// <summary>
/// Did the ray hit something?
/// </summary>
public CBool Hit;
/// <summary>
/// Distance to the nearest hit
/// </summary>
public float Distance;
/// <summary>
/// Point of the nearest hit
/// </summary>
public Vector3 Point;
/// <summary>
/// Surface normal of hit
/// </summary>
public Vector3 Normal;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +1,28 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Rectangle type
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Rectangle
{ {
/// <summary> public float X;
/// Rectangle type public float Y;
/// </summary> public float Width;
[StructLayout(LayoutKind.Sequential)] public float Height;
public partial struct Rectangle
public Rectangle(float x, float y, float width, float height)
{ {
public float X; this.X = x;
public float Y; this.Y = y;
public float Width; this.Width = width;
public float Height; this.Height = height;
}
public Rectangle(float x, float y, float width, float height) public override string ToString()
{ {
this.X = x; return $"{{X:{X} Y:{Y} Width:{Width} Height:{Height}}}";
this.Y = y;
this.Width = width;
this.Height = height;
}
public override string ToString()
{
return $"{{X:{X} Y:{Y} Width:{Width} Height:{Height}}}";
}
} }
} }

View File

@ -1,271 +1,270 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// RenderBatch type
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct RenderBatch
{ {
/// <summary> /// <summary>
/// RenderBatch type /// Number of vertex buffers (multi-buffering support)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] int _buffersCount;
public unsafe partial struct RenderBatch
{
/// <summary>
/// Number of vertex buffers (multi-buffering support)
/// </summary>
int _buffersCount;
/// <summary>
/// Current buffer tracking in case of multi-buffering
/// </summary>
int _currentBuffer;
/// <summary>
/// Dynamic buffer(s) for vertex data
/// </summary>
VertexBuffer* _vertexBuffer;
/// <summary>
/// Draw calls array, depends on textureId
/// </summary>
DrawCall* _draws;
/// <summary>
/// Draw calls counter
/// </summary>
int _drawsCounter;
/// <summary>
/// Current depth value for next draw
/// </summary>
float _currentDepth;
}
/// <summary> /// <summary>
/// Dynamic vertex buffers (position + texcoords + colors + indices arrays) /// Current buffer tracking in case of multi-buffering
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] int _currentBuffer;
public unsafe partial struct VertexBuffer
{
/// <summary>
/// Number of elements in the buffer (QUADS)
/// </summary>
public int ElementCount;
/// <summary>
/// Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
/// </summary>
public float* Vertices;
/// <summary>
/// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
/// </summary>
public float* TexCoords;
/// <summary>
/// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
/// </summary>
public byte* Colors;
/// <summary>
/// Vertex indices (in case vertex data comes indexed) (6 indices per quad)<br/>
/// unsigned int* for GRAPHICS_API_OPENGL_11 or GRAPHICS_API_OPENGL_33<br/>
/// unsigned short* for GRAPHICS_API_OPENGL_ES2
/// </summary>
public void* Indices;
/// <summary>
/// OpenGL Vertex Array Object id
/// </summary>
public uint VaoId;
/// <summary>
/// OpenGL Vertex Buffer Objects id (4 types of vertex data)
/// </summary>
public fixed uint VboId[4];
}
/// <summary> /// <summary>
/// Dynamic vertex buffers (position + texcoords + colors + indices arrays) /// Dynamic buffer(s) for vertex data
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] VertexBuffer* _vertexBuffer;
public partial struct DrawCall
{
/// <summary>
/// Drawing mode: LINES, TRIANGLES, QUADS
/// </summary>
int _mode;
/// <summary>
/// Number of vertices for the draw call
/// </summary>
int _vertexCount;
/// <summary>
/// Number of vertices required for index alignment (LINES, TRIANGLES)
/// </summary>
int _vertexAlignment;
/// <summary>
/// Texture id to be used on the draw -> Use to create new draw call if changes
/// </summary>
uint _textureId;
}
public enum GlVersion
{
OPENGL_11 = 1,
OPENGL_21,
OPENGL_33,
OPENGL_43,
OPENGL_ES_20
}
public enum FramebufferAttachType
{
RL_ATTACHMENT_COLOR_CHANNEL0 = 0,
RL_ATTACHMENT_COLOR_CHANNEL1,
RL_ATTACHMENT_COLOR_CHANNEL2,
RL_ATTACHMENT_COLOR_CHANNEL3,
RL_ATTACHMENT_COLOR_CHANNEL4,
RL_ATTACHMENT_COLOR_CHANNEL5,
RL_ATTACHMENT_COLOR_CHANNEL6,
RL_ATTACHMENT_COLOR_CHANNEL7,
RL_ATTACHMENT_DEPTH = 100,
RL_ATTACHMENT_STENCIL = 200,
}
public enum FramebufferAttachTextureType
{
RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_X,
RL_ATTACHMENT_CUBEMAP_POSITIVE_Y,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y,
RL_ATTACHMENT_CUBEMAP_POSITIVE_Z,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z,
RL_ATTACHMENT_TEXTURE2D = 100,
RL_ATTACHMENT_RENDERBUFFER = 200,
}
/// <summary> /// <summary>
/// Matrix Modes (equivalent to OpenGL) /// Draw calls array, depends on textureId
/// </summary> /// </summary>
public enum MatrixMode DrawCall* _draws;
{
/// <summary>
/// GL_MODELVIEW
/// </summary>
MODELVIEW = 0x1700,
/// <summary>
/// GL_PROJECTION
/// </summary>
PROJECTION = 0x1701,
/// <summary>
/// GL_TEXTURE
/// </summary>
TEXTURE = 0x1702
}
/// <summary> /// <summary>
/// Primitive assembly draw modes /// Draw calls counter
/// </summary> /// </summary>
public enum DrawMode int _drawsCounter;
{
/// <summary>
/// GL_LINES
/// </summary>
LINES = 0x0001,
/// <summary>
/// GL_TRIANGLES
/// </summary>
TRIANGLES = 0x0004,
/// <summary>
/// GL_QUADS
/// </summary>
QUADS = 0x0007
}
/// <summary> /// <summary>
/// Texture parameters (equivalent to OpenGL defines) /// Current depth value for next draw
/// </summary> /// </summary>
public enum TextureFilters float _currentDepth;
{ }
/// <summary>
/// RL_TEXTURE_FILTER_NEAREST /// <summary>
/// <br/> /// Dynamic vertex buffers (position + texcoords + colors + indices arrays)
/// GL_NEAREST /// </summary>
/// </summary> [StructLayout(LayoutKind.Sequential)]
NEAREST = 0x2600, public unsafe partial struct VertexBuffer
{
/// <summary> /// <summary>
/// RL_TEXTURE_FILTER_LINEAR /// Number of elements in the buffer (QUADS)
/// <br/> /// </summary>
/// GL_LINEAR public int ElementCount;
/// </summary>
LINEAR = 0x2601, /// <summary>
/// Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
/// <summary> /// </summary>
/// RL_TEXTURE_FILTER_MIP_NEAREST public float* Vertices;
/// <br/>
/// GL_NEAREST_MIPMAP_NEAREST /// <summary>
/// </summary> /// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
MIP_NEAREST = 0x2700, /// </summary>
public float* TexCoords;
/// <summary>
/// RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR /// <summary>
/// <br/> /// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
/// GL_NEAREST_MIPMAP_LINEAR /// </summary>
/// </summary> public byte* Colors;
NEAREST_MIP_LINEAR = 0x2702,
/// <summary>
/// <summary> /// Vertex indices (in case vertex data comes indexed) (6 indices per quad)<br/>
/// RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST /// unsigned int* for GRAPHICS_API_OPENGL_11 or GRAPHICS_API_OPENGL_33<br/>
/// <br/> /// unsigned short* for GRAPHICS_API_OPENGL_ES2
/// GL_LINEAR_MIPMAP_NEAREST /// </summary>
/// </summary> public void* Indices;
LINEAR_MIP_NEAREST = 0x2701,
/// <summary>
/// <summary> /// OpenGL Vertex Array Object id
/// RL_TEXTURE_FILTER_MIP_LINEAR /// </summary>
/// <br/> public uint VaoId;
/// GL_LINEAR_MIPMAP_LINEAR
/// </summary> /// <summary>
MIP_LINEAR = 0x2703, /// OpenGL Vertex Buffer Objects id (4 types of vertex data)
/// </summary>
/// <summary> public fixed uint VboId[4];
/// RL_TEXTURE_FILTER_ANISOTROPIC }
/// <br/>
/// Anisotropic filter (custom identifier) /// <summary>
/// </summary> /// Dynamic vertex buffers (position + texcoords + colors + indices arrays)
ANISOTROPIC = 0x3000 /// </summary>
} [StructLayout(LayoutKind.Sequential)]
public partial struct DrawCall
/// <summary> {
/// GL Shader type /// <summary>
/// </summary> /// Drawing mode: LINES, TRIANGLES, QUADS
public enum ShaderType /// </summary>
{ int _mode;
/// <summary>
/// RL_FRAGMENT_SHADER /// <summary>
/// <br/> /// Number of vertices for the draw call
/// GL_FRAGMENT_SHADER /// </summary>
/// </summary> int _vertexCount;
FRAGMENT = 0x8B30,
/// <summary>
/// <summary> /// Number of vertices required for index alignment (LINES, TRIANGLES)
/// RL_VERTEX_SHADER /// </summary>
/// <br/> int _vertexAlignment;
/// GL_VERTEX_SHADER
/// </summary> /// <summary>
VERTEX = 0x8B31, /// Texture id to be used on the draw -> Use to create new draw call if changes
/// </summary>
/// <summary> uint _textureId;
/// RL_COMPUTE_SHADER }
/// <br/>
/// GL_COMPUTE_SHADER public enum GlVersion
/// </summary> {
COMPUTE = 0x91b9 OPENGL_11 = 1,
} OPENGL_21,
OPENGL_33,
OPENGL_43,
OPENGL_ES_20
}
public enum FramebufferAttachType
{
RL_ATTACHMENT_COLOR_CHANNEL0 = 0,
RL_ATTACHMENT_COLOR_CHANNEL1,
RL_ATTACHMENT_COLOR_CHANNEL2,
RL_ATTACHMENT_COLOR_CHANNEL3,
RL_ATTACHMENT_COLOR_CHANNEL4,
RL_ATTACHMENT_COLOR_CHANNEL5,
RL_ATTACHMENT_COLOR_CHANNEL6,
RL_ATTACHMENT_COLOR_CHANNEL7,
RL_ATTACHMENT_DEPTH = 100,
RL_ATTACHMENT_STENCIL = 200,
}
public enum FramebufferAttachTextureType
{
RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_X,
RL_ATTACHMENT_CUBEMAP_POSITIVE_Y,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y,
RL_ATTACHMENT_CUBEMAP_POSITIVE_Z,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z,
RL_ATTACHMENT_TEXTURE2D = 100,
RL_ATTACHMENT_RENDERBUFFER = 200,
}
/// <summary>
/// Matrix Modes (equivalent to OpenGL)
/// </summary>
public enum MatrixMode
{
/// <summary>
/// GL_MODELVIEW
/// </summary>
MODELVIEW = 0x1700,
/// <summary>
/// GL_PROJECTION
/// </summary>
PROJECTION = 0x1701,
/// <summary>
/// GL_TEXTURE
/// </summary>
TEXTURE = 0x1702
}
/// <summary>
/// Primitive assembly draw modes
/// </summary>
public enum DrawMode
{
/// <summary>
/// GL_LINES
/// </summary>
LINES = 0x0001,
/// <summary>
/// GL_TRIANGLES
/// </summary>
TRIANGLES = 0x0004,
/// <summary>
/// GL_QUADS
/// </summary>
QUADS = 0x0007
}
/// <summary>
/// Texture parameters (equivalent to OpenGL defines)
/// </summary>
public enum TextureFilters
{
/// <summary>
/// RL_TEXTURE_FILTER_NEAREST
/// <br/>
/// GL_NEAREST
/// </summary>
NEAREST = 0x2600,
/// <summary>
/// RL_TEXTURE_FILTER_LINEAR
/// <br/>
/// GL_LINEAR
/// </summary>
LINEAR = 0x2601,
/// <summary>
/// RL_TEXTURE_FILTER_MIP_NEAREST
/// <br/>
/// GL_NEAREST_MIPMAP_NEAREST
/// </summary>
MIP_NEAREST = 0x2700,
/// <summary>
/// RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR
/// <br/>
/// GL_NEAREST_MIPMAP_LINEAR
/// </summary>
NEAREST_MIP_LINEAR = 0x2702,
/// <summary>
/// RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST
/// <br/>
/// GL_LINEAR_MIPMAP_NEAREST
/// </summary>
LINEAR_MIP_NEAREST = 0x2701,
/// <summary>
/// RL_TEXTURE_FILTER_MIP_LINEAR
/// <br/>
/// GL_LINEAR_MIPMAP_LINEAR
/// </summary>
MIP_LINEAR = 0x2703,
/// <summary>
/// RL_TEXTURE_FILTER_ANISOTROPIC
/// <br/>
/// Anisotropic filter (custom identifier)
/// </summary>
ANISOTROPIC = 0x3000
}
/// <summary>
/// GL Shader type
/// </summary>
public enum ShaderType
{
/// <summary>
/// RL_FRAGMENT_SHADER
/// <br/>
/// GL_FRAGMENT_SHADER
/// </summary>
FRAGMENT = 0x8B30,
/// <summary>
/// RL_VERTEX_SHADER
/// <br/>
/// GL_VERTEX_SHADER
/// </summary>
VERTEX = 0x8B31,
/// <summary>
/// RL_COMPUTE_SHADER
/// <br/>
/// GL_COMPUTE_SHADER
/// </summary>
COMPUTE = 0x91b9
} }

View File

@ -1,26 +1,25 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// RenderTexture2D type, for texture rendering
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct RenderTexture2D
{ {
/// <summary> /// <summary>
/// RenderTexture2D type, for texture rendering /// OpenGL Framebuffer Object (FBO) id
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public uint Id;
public partial struct RenderTexture2D
{
/// <summary>
/// OpenGL Framebuffer Object (FBO) id
/// </summary>
public uint Id;
/// <summary> /// <summary>
/// Color buffer attachment texture /// Color buffer attachment texture
/// </summary> /// </summary>
public Texture2D Texture; public Texture2D Texture;
/// <summary> /// <summary>
/// Depth buffer attachment texture /// Depth buffer attachment texture
/// </summary> /// </summary>
public Texture2D Depth; public Texture2D Depth;
}
} }

View File

@ -1,84 +1,83 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Shader location index
/// </summary>
public enum ShaderLocationIndex
{
SHADER_LOC_VERTEX_POSITION = 0,
SHADER_LOC_VERTEX_TEXCOORD01,
SHADER_LOC_VERTEX_TEXCOORD02,
SHADER_LOC_VERTEX_NORMAL,
SHADER_LOC_VERTEX_TANGENT,
SHADER_LOC_VERTEX_COLOR,
SHADER_LOC_MATRIX_MVP,
SHADER_LOC_MATRIX_VIEW,
SHADER_LOC_MATRIX_PROJECTION,
SHADER_LOC_MATRIX_MODEL,
SHADER_LOC_MATRIX_NORMAL,
SHADER_LOC_VECTOR_VIEW,
SHADER_LOC_COLOR_DIFFUSE,
SHADER_LOC_COLOR_SPECULAR,
SHADER_LOC_COLOR_AMBIENT,
SHADER_LOC_MAP_ALBEDO,
SHADER_LOC_MAP_METALNESS,
SHADER_LOC_MAP_NORMAL,
SHADER_LOC_MAP_ROUGHNESS,
SHADER_LOC_MAP_OCCLUSION,
SHADER_LOC_MAP_EMISSION,
SHADER_LOC_MAP_HEIGHT,
SHADER_LOC_MAP_CUBEMAP,
SHADER_LOC_MAP_IRRADIANCE,
SHADER_LOC_MAP_PREFILTER,
SHADER_LOC_MAP_BRDF,
SHADER_LOC_MAP_DIFFUSE = SHADER_LOC_MAP_ALBEDO,
SHADER_LOC_MAP_SPECULAR = SHADER_LOC_MAP_METALNESS,
}
/// <summary>
/// Shader attribute data types
/// </summary>
public enum ShaderAttributeDataType
{
SHADER_ATTRIB_FLOAT = 0,
SHADER_ATTRIB_VEC2,
SHADER_ATTRIB_VEC3,
SHADER_ATTRIB_VEC4
}
/// <summary>
/// Shader uniform data type
/// </summary>
public enum ShaderUniformDataType
{
SHADER_UNIFORM_FLOAT = 0,
SHADER_UNIFORM_VEC2,
SHADER_UNIFORM_VEC3,
SHADER_UNIFORM_VEC4,
SHADER_UNIFORM_INT,
SHADER_UNIFORM_IVEC2,
SHADER_UNIFORM_IVEC3,
SHADER_UNIFORM_IVEC4,
SHADER_UNIFORM_SAMPLER2D
}
/// <summary>
/// Shader type (generic)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Shader
{ {
/// <summary> /// <summary>
/// Shader location index /// Shader program id
/// </summary> /// </summary>
public enum ShaderLocationIndex public uint Id;
{
SHADER_LOC_VERTEX_POSITION = 0,
SHADER_LOC_VERTEX_TEXCOORD01,
SHADER_LOC_VERTEX_TEXCOORD02,
SHADER_LOC_VERTEX_NORMAL,
SHADER_LOC_VERTEX_TANGENT,
SHADER_LOC_VERTEX_COLOR,
SHADER_LOC_MATRIX_MVP,
SHADER_LOC_MATRIX_VIEW,
SHADER_LOC_MATRIX_PROJECTION,
SHADER_LOC_MATRIX_MODEL,
SHADER_LOC_MATRIX_NORMAL,
SHADER_LOC_VECTOR_VIEW,
SHADER_LOC_COLOR_DIFFUSE,
SHADER_LOC_COLOR_SPECULAR,
SHADER_LOC_COLOR_AMBIENT,
SHADER_LOC_MAP_ALBEDO,
SHADER_LOC_MAP_METALNESS,
SHADER_LOC_MAP_NORMAL,
SHADER_LOC_MAP_ROUGHNESS,
SHADER_LOC_MAP_OCCLUSION,
SHADER_LOC_MAP_EMISSION,
SHADER_LOC_MAP_HEIGHT,
SHADER_LOC_MAP_CUBEMAP,
SHADER_LOC_MAP_IRRADIANCE,
SHADER_LOC_MAP_PREFILTER,
SHADER_LOC_MAP_BRDF,
SHADER_LOC_MAP_DIFFUSE = SHADER_LOC_MAP_ALBEDO,
SHADER_LOC_MAP_SPECULAR = SHADER_LOC_MAP_METALNESS,
}
/// <summary> /// <summary>
/// Shader attribute data types /// Shader locations array (MAX_SHADER_LOCATIONS, int *)
/// </summary> /// </summary>
public enum ShaderAttributeDataType public int* Locs;
{
SHADER_ATTRIB_FLOAT = 0,
SHADER_ATTRIB_VEC2,
SHADER_ATTRIB_VEC3,
SHADER_ATTRIB_VEC4
}
/// <summary>
/// Shader uniform data type
/// </summary>
public enum ShaderUniformDataType
{
SHADER_UNIFORM_FLOAT = 0,
SHADER_UNIFORM_VEC2,
SHADER_UNIFORM_VEC3,
SHADER_UNIFORM_VEC4,
SHADER_UNIFORM_INT,
SHADER_UNIFORM_IVEC2,
SHADER_UNIFORM_IVEC3,
SHADER_UNIFORM_IVEC4,
SHADER_UNIFORM_SAMPLER2D
}
/// <summary>
/// Shader type (generic)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Shader
{
/// <summary>
/// Shader program id
/// </summary>
public uint Id;
/// <summary>
/// Shader locations array (MAX_SHADER_LOCATIONS, int *)
/// </summary>
public int* Locs;
}
} }

View File

@ -1,137 +1,136 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Texture parameters: filter mode<br/>
/// NOTE 1: Filtering considers mipmaps if available in the texture<br/>
/// NOTE 2: Filter is accordingly set for minification and magnification
/// </summary>
public enum TextureFilter
{ {
/// <summary> /// <summary>
/// Texture parameters: filter mode<br/> /// No filter, just pixel aproximation
/// NOTE 1: Filtering considers mipmaps if available in the texture<br/>
/// NOTE 2: Filter is accordingly set for minification and magnification
/// </summary> /// </summary>
public enum TextureFilter TEXTURE_FILTER_POINT = 0,
{
/// <summary>
/// No filter, just pixel aproximation
/// </summary>
TEXTURE_FILTER_POINT = 0,
/// <summary>
/// Linear filtering
/// </summary>
TEXTURE_FILTER_BILINEAR,
/// <summary>
/// Trilinear filtering (linear with mipmaps)
/// </summary>
TEXTURE_FILTER_TRILINEAR,
/// <summary>
/// Anisotropic filtering 4x
/// </summary>
TEXTURE_FILTER_ANISOTROPIC_4X,
/// <summary>
/// Anisotropic filtering 8x
/// </summary>
TEXTURE_FILTER_ANISOTROPIC_8X,
/// <summary>
/// Anisotropic filtering 16x
/// </summary>
TEXTURE_FILTER_ANISOTROPIC_16X,
}
/// <summary> /// <summary>
/// Texture parameters: wrap mode /// Linear filtering
/// </summary> /// </summary>
public enum TextureWrap TEXTURE_FILTER_BILINEAR,
{
/// <summary>
/// Repeats texture in tiled mode
/// </summary>
TEXTURE_WRAP_REPEAT = 0,
/// <summary>
/// Clamps texture to edge pixel in tiled mode
/// </summary>
TEXTURE_WRAP_CLAMP,
/// <summary>
/// Mirrors and repeats the texture in tiled mode
/// </summary>
TEXTURE_WRAP_MIRROR_REPEAT,
/// <summary>
/// Mirrors and clamps to border the texture in tiled mode
/// </summary>
TEXTURE_WRAP_MIRROR_CLAMP
}
/// <summary> /// <summary>
/// Cubemap layouts /// Trilinear filtering (linear with mipmaps)
/// </summary> /// </summary>
public enum CubemapLayout TEXTURE_FILTER_TRILINEAR,
{
/// <summary>
/// Automatically detect layout type
/// </summary>
CUBEMAP_LAYOUT_AUTO_DETECT = 0,
/// <summary>
/// Layout is defined by a vertical line with faces
/// </summary>
CUBEMAP_LAYOUT_LINE_VERTICAL,
/// <summary>
/// Layout is defined by a horizontal line with faces
/// </summary>
CUBEMAP_LAYOUT_LINE_HORIZONTAL,
/// <summary>
/// Layout is defined by a 3x4 cross with cubemap faces
/// </summary>
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR,
/// <summary>
/// Layout is defined by a 4x3 cross with cubemap faces
/// </summary>
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE,
/// <summary>
/// Layout is defined by a panorama image (equirectangular map)
/// </summary>
CUBEMAP_LAYOUT_PANORAMA
}
/// <summary> /// <summary>
/// Texture2D type<br/> /// Anisotropic filtering 4x
/// NOTE: Data stored in GPU memory
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] TEXTURE_FILTER_ANISOTROPIC_4X,
public partial struct Texture2D
{
/// <summary>
/// OpenGL texture id
/// </summary>
public uint Id;
/// <summary> /// <summary>
/// Texture base width /// Anisotropic filtering 8x
/// </summary> /// </summary>
public int Width; TEXTURE_FILTER_ANISOTROPIC_8X,
/// <summary> /// <summary>
/// Texture base height /// Anisotropic filtering 16x
/// </summary> /// </summary>
public int Height; TEXTURE_FILTER_ANISOTROPIC_16X,
}
/// <summary>
/// Mipmap levels, 1 by default /// <summary>
/// </summary> /// Texture parameters: wrap mode
public int Mipmaps; /// </summary>
public enum TextureWrap
/// <summary> {
/// Data format (PixelFormat type) /// <summary>
/// </summary> /// Repeats texture in tiled mode
public PixelFormat Format; /// </summary>
} TEXTURE_WRAP_REPEAT = 0,
/// <summary>
/// Clamps texture to edge pixel in tiled mode
/// </summary>
TEXTURE_WRAP_CLAMP,
/// <summary>
/// Mirrors and repeats the texture in tiled mode
/// </summary>
TEXTURE_WRAP_MIRROR_REPEAT,
/// <summary>
/// Mirrors and clamps to border the texture in tiled mode
/// </summary>
TEXTURE_WRAP_MIRROR_CLAMP
}
/// <summary>
/// Cubemap layouts
/// </summary>
public enum CubemapLayout
{
/// <summary>
/// Automatically detect layout type
/// </summary>
CUBEMAP_LAYOUT_AUTO_DETECT = 0,
/// <summary>
/// Layout is defined by a vertical line with faces
/// </summary>
CUBEMAP_LAYOUT_LINE_VERTICAL,
/// <summary>
/// Layout is defined by a horizontal line with faces
/// </summary>
CUBEMAP_LAYOUT_LINE_HORIZONTAL,
/// <summary>
/// Layout is defined by a 3x4 cross with cubemap faces
/// </summary>
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR,
/// <summary>
/// Layout is defined by a 4x3 cross with cubemap faces
/// </summary>
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE,
/// <summary>
/// Layout is defined by a panorama image (equirectangular map)
/// </summary>
CUBEMAP_LAYOUT_PANORAMA
}
/// <summary>
/// Texture2D type<br/>
/// NOTE: Data stored in GPU memory
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Texture2D
{
/// <summary>
/// OpenGL texture id
/// </summary>
public uint Id;
/// <summary>
/// Texture base width
/// </summary>
public int Width;
/// <summary>
/// Texture base height
/// </summary>
public int Height;
/// <summary>
/// Mipmap levels, 1 by default
/// </summary>
public int Mipmaps;
/// <summary>
/// Data format (PixelFormat type)
/// </summary>
public PixelFormat Format;
} }

View File

@ -1,27 +1,26 @@
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Transform, vectex transformation data
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Transform
{ {
/// <summary> /// <summary>
/// Transform, vectex transformation data /// Translation
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public Vector3 Translation;
public partial struct Transform
{
/// <summary>
/// Translation
/// </summary>
public Vector3 Translation;
/// <summary> /// <summary>
/// Rotation /// Rotation
/// </summary> /// </summary>
public Quaternion Rotation; public Quaternion Rotation;
/// <summary> /// <summary>
/// Scale /// Scale
/// </summary> /// </summary>
public Vector3 Scale; public Vector3 Scale;
}
} }

View File

@ -1,36 +1,35 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Converts text to a Ansi buffer for passing to native code
/// </summary>
public readonly ref struct AnsiBuffer
{ {
/// <summary> private readonly IntPtr _data;
/// Converts text to a Ansi buffer for passing to native code
/// </summary> public AnsiBuffer(string text)
public readonly ref struct AnsiBuffer
{ {
private readonly IntPtr _data; _data = Marshal.StringToHGlobalAnsi(text);
public AnsiBuffer(string text)
{
_data = Marshal.StringToHGlobalAnsi(text);
}
public unsafe sbyte* AsPointer()
{
return (sbyte*)_data.ToPointer();
}
public void Dispose()
{
Marshal.FreeHGlobal(_data);
}
} }
public static class AnsiStringUtils public unsafe sbyte* AsPointer()
{ {
public static AnsiBuffer ToAnsiBuffer(this string text) return (sbyte*)_data.ToPointer();
{ }
return new AnsiBuffer(text);
} public void Dispose()
{
Marshal.FreeHGlobal(_data);
}
}
public static class AnsiStringUtils
{
public static AnsiBuffer ToAnsiBuffer(this string text)
{
return new AnsiBuffer(text);
} }
} }

View File

@ -1,87 +1,89 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
[StructLayout(LayoutKind.Sequential)]
public readonly struct CBool
{ {
[StructLayout(LayoutKind.Sequential)] /* The values of booleans in C++ are stored in a single byte, which means it
public readonly struct CBool * only supports values from -128 to 127. It is possible to argument that
* they only support a single bit, yes, but the minimum storage unit of a
* computer is a sbyte, so that's what we'll be using when doing operations,
* which can be later implicitely cast onto any type during usage.
*
* It is wise to note that C booleans are any numeric value, but allocating an
* Int64 for every CBool instance is.. well, wildly memory-inefficient. Yes, the
* process is basically treated as a 0-cost instantiation, but it's better to rely
* on explicit motivation than to blindly trust the runtime judgement on its memory
* management.
*
* 'value' is visible and constructable (if necessary), but impossible to modify or access.
*/
public sbyte Value
{ {
/* The values of booleans in C++ are stored in a single byte, which means it init; private get;
* only supports values from -128 to 127. It is possible to argument that }
* they only support a single bit, yes, but the minimum storage unit of a
* computer is a sbyte, so that's what we'll be using when doing operations,
* which can be later implicitely cast onto any type during usage.
*
* It is wise to note that C booleans are any numeric value, but allocating an
* Int64 for every CBool instance is.. well, wildly memory-inefficient. Yes, the
* process is basically treated as a 0-cost instantiation, but it's better to rely
* on explicit motivation than to blindly trust the runtime judgement on its memory
* management.
*
* 'value' is visible and constructable (if necessary), but impossible to modify or access.
*/
public sbyte Value { init; private get; }
// Constructors for easier usage. // Constructors for easier usage.
public CBool(bool value) public CBool(bool value)
{ {
this.Value = (sbyte)(value ? 1 : 0); this.Value = (sbyte)(value ? 1 : 0);
} }
public CBool(Int64 value) public CBool(Int64 value)
{ {
this.Value = (sbyte)(value != 0 ? 1 : 0); this.Value = (sbyte)(value != 0 ? 1 : 0);
} }
// CBool -> Native // CBool -> Native
// Allows for arithmetic between CBools and for assignment to greater integer variables. // Allows for arithmetic between CBools and for assignment to greater integer variables.
public static implicit operator sbyte(CBool x) public static implicit operator sbyte(CBool x)
{ {
return x.Value; return x.Value;
} }
// Allows for CBools to be implicitely assigned to a native boolean variable. // Allows for CBools to be implicitely assigned to a native boolean variable.
public static implicit operator bool(CBool x) public static implicit operator bool(CBool x)
{ {
return x.Value != 0 ? true : false; return x.Value != 0 ? true : false;
} }
// Native -> CBool // Native -> CBool
// Allows native booleans to be implicitely constructed into CBools while passing parameters. // Allows native booleans to be implicitely constructed into CBools while passing parameters.
public static implicit operator CBool(bool x) public static implicit operator CBool(bool x)
{ {
return new CBool { Value = (sbyte)(x ? 1 : 0) }; return new CBool { Value = (sbyte)(x ? 1 : 0) };
} }
// Same goes for integer numeric values (any value, so an Int64 is used). // Same goes for integer numeric values (any value, so an Int64 is used).
public static implicit operator CBool(Int64 x) public static implicit operator CBool(Int64 x)
{ {
return new CBool { Value = (sbyte)(x != 0 ? 1 : 0) }; return new CBool { Value = (sbyte)(x != 0 ? 1 : 0) };
} }
/* Arithmetic overloads /* Arithmetic overloads
* Operations between CBools and integers are already covered by the implicit * Operations between CBools and integers are already covered by the implicit
* sbyte cast. So no need to worry about those. * sbyte cast. So no need to worry about those.
* *
* All casts return CBool, since there is no way to know if the assignment is * All casts return CBool, since there is no way to know if the assignment is
* to a native boolean or integer, or a CBool. * to a native boolean or integer, or a CBool.
*/ */
// Addition // Addition
public static CBool operator +(CBool left, CBool right) public static CBool operator +(CBool left, CBool right)
{ {
return new CBool { Value = (sbyte)(left.Value + right.Value) }; return new CBool { Value = (sbyte)(left.Value + right.Value) };
} }
// Subtraction // Subtraction
public static CBool operator -(CBool left, CBool right) public static CBool operator -(CBool left, CBool right)
{ {
return new CBool { Value = (sbyte)(left.Value - right.Value) }; return new CBool { Value = (sbyte)(left.Value - right.Value) };
} }
// ToString override // ToString override
public override string ToString() public override string ToString()
{ {
return ((bool)this).ToString(); return ((bool)this).ToString();
}
} }
} }

View File

@ -1,26 +1,25 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// File path list
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe struct FilePathList
{ {
/// <summary> /// <summary>
/// File path list /// Filepaths max entries
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public uint Capacity;
public unsafe struct FilePathList
{
/// <summary>
/// Filepaths max entries
/// </summary>
public uint Capacity;
/// <summary> /// <summary>
/// Filepaths entries count /// Filepaths entries count
/// </summary> /// </summary>
public uint Count; public uint Count;
/// <summary> /// <summary>
/// Filepaths entries /// Filepaths entries
/// </summary> /// </summary>
public byte** Paths; public byte** Paths;
}
} }

View File

@ -1,63 +1,62 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Converts text to a UTF8 buffer for passing to native code
/// </summary>
public readonly ref struct Utf8Buffer
{ {
/// <summary> private readonly IntPtr _data;
/// Converts text to a UTF8 buffer for passing to native code
/// </summary> public Utf8Buffer(string text)
public readonly ref struct Utf8Buffer
{ {
private readonly IntPtr _data; _data = Marshal.StringToCoTaskMemUTF8(text);
public Utf8Buffer(string text)
{
_data = Marshal.StringToCoTaskMemUTF8(text);
}
public unsafe sbyte* AsPointer()
{
return (sbyte*)_data.ToPointer();
}
public void Dispose()
{
Marshal.ZeroFreeCoTaskMemUTF8(_data);
}
} }
public static class Utf8StringUtils public unsafe sbyte* AsPointer()
{ {
public static Utf8Buffer ToUtf8Buffer(this string text) return (sbyte*)_data.ToPointer();
{ }
return new Utf8Buffer(text);
}
public static byte[] ToUtf8String(this string text) public void Dispose()
{ {
if (text == null) Marshal.ZeroFreeCoTaskMemUTF8(_data);
{ }
return null; }
}
public static class Utf8StringUtils
var length = Encoding.UTF8.GetByteCount(text); {
public static Utf8Buffer ToUtf8Buffer(this string text)
var byteArray = new byte[length + 1]; {
var wrote = Encoding.UTF8.GetBytes(text, 0, text.Length, byteArray, 0); return new Utf8Buffer(text);
byteArray[wrote] = 0; }
return byteArray; public static byte[] ToUtf8String(this string text)
} {
if (text == null)
public static unsafe string GetUTF8String(sbyte* bytes) {
{ return null;
return Marshal.PtrToStringUTF8((IntPtr)bytes); }
}
var length = Encoding.UTF8.GetByteCount(text);
public static byte[] GetUTF8Bytes(this string text)
{ var byteArray = new byte[length + 1];
return Encoding.UTF8.GetBytes(text); var wrote = Encoding.UTF8.GetBytes(text, 0, text.Length, byteArray, 0);
} byteArray[wrote] = 0;
return byteArray;
}
public static unsafe string GetUTF8String(sbyte* bytes)
{
return Marshal.PtrToStringUTF8((IntPtr)bytes);
}
public static byte[] GetUTF8Bytes(this string text)
{
return Encoding.UTF8.GetBytes(text);
} }
} }