mirror of
https://github.com/raylib-cs/raylib-cs
synced 2025-04-03 11:09:40 -04:00
Fix usage of uint in bindings (#246)
This commit is contained in:
parent
5949934932
commit
383ec91e95
@ -93,13 +93,13 @@ public class StorageValues
|
||||
|
||||
// Save integer value to storage file (to defined position)
|
||||
// NOTE: Storage positions is directly related to file memory layout (4 bytes each integer)
|
||||
private static unsafe bool SaveStorageValue(string fileName, uint position, int value)
|
||||
private static unsafe bool SaveStorageValue(string fileName, int position, int value)
|
||||
{
|
||||
using var fileNameBuffer = fileName.ToUtf8Buffer();
|
||||
|
||||
bool success = false;
|
||||
uint dataSize = 0;
|
||||
uint newDataSize = 0;
|
||||
int dataSize = 0;
|
||||
int newDataSize = 0;
|
||||
|
||||
byte* fileData = LoadFileData(fileNameBuffer.AsPointer(), &dataSize);
|
||||
byte* newFileData = null;
|
||||
@ -110,7 +110,7 @@ public class StorageValues
|
||||
{
|
||||
// Increase data size up to position and store value
|
||||
newDataSize = (position + 1) * sizeof(int);
|
||||
newFileData = (byte*)MemRealloc(fileData, (int)newDataSize);
|
||||
newFileData = (byte*)MemRealloc(fileData, (uint)newDataSize);
|
||||
|
||||
if (newFileData != null)
|
||||
{
|
||||
@ -121,7 +121,7 @@ public class StorageValues
|
||||
else
|
||||
{
|
||||
// RL_REALLOC failed
|
||||
uint positionInBytes = position * sizeof(int);
|
||||
int positionInBytes = position * sizeof(int);
|
||||
TraceLog(
|
||||
TraceLogLevel.Warning,
|
||||
@$"FILEIO: [{fileName}] Failed to realloc data ({dataSize}),
|
||||
@ -154,7 +154,7 @@ public class StorageValues
|
||||
TraceLog(TraceLogLevel.Info, $"FILEIO: [{fileName}] File created successfully");
|
||||
|
||||
dataSize = (position + 1) * sizeof(int);
|
||||
fileData = (byte*)MemAlloc((int)dataSize);
|
||||
fileData = (byte*)MemAlloc((uint)dataSize);
|
||||
int* dataPtr = (int*)fileData;
|
||||
dataPtr[position] = value;
|
||||
|
||||
@ -174,7 +174,7 @@ public class StorageValues
|
||||
using var fileNameBuffer = fileName.ToUtf8Buffer();
|
||||
|
||||
int value = 0;
|
||||
uint dataSize = 0;
|
||||
int dataSize = 0;
|
||||
byte* fileData = LoadFileData(fileNameBuffer.AsPointer(), &dataSize);
|
||||
|
||||
if (fileData != null)
|
||||
|
@ -47,7 +47,7 @@ public class AnimationDemo
|
||||
|
||||
Vector3 position = new(0.0f, 0.0f, 0.0f);
|
||||
// Load animation data
|
||||
uint animsCount = 0;
|
||||
int animsCount = 0;
|
||||
var anims = LoadModelAnimations("resources/models/iqm/guyanim.iqm", ref animsCount);
|
||||
int animFrameCounter = 0;
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class FontSdf
|
||||
string msg = "Signed Distance Fields";
|
||||
|
||||
// Loading file to memory
|
||||
uint fileSize = 0;
|
||||
int fileSize = 0;
|
||||
byte* fileData = LoadFileData("resources/fonts/anonymous_pro_bold.ttf", ref fileSize);
|
||||
|
||||
// Default font generation from TTF font
|
||||
|
@ -44,7 +44,7 @@ public class RawData
|
||||
int height = 480;
|
||||
|
||||
// Store pixel data
|
||||
Color* pixels = (Color*)Raylib.MemAlloc(width * height * sizeof(Color));
|
||||
Color* pixels = (Color*)Raylib.MemAlloc((uint)(width * height * sizeof(Color)));
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
|
@ -464,7 +464,7 @@ public static unsafe partial class Raylib
|
||||
|
||||
/// <summary>Load random values sequence, no values repeated</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int* LoadRandomSequence(int count, int min, int max);
|
||||
public static extern int* LoadRandomSequence(uint count, int min, int max);
|
||||
|
||||
/// <summary>Unload random values sequence</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -488,11 +488,11 @@ public static unsafe partial class Raylib
|
||||
|
||||
/// <summary>Internal memory allocator</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void* MemAlloc(int size);
|
||||
public static extern void* MemAlloc(uint size);
|
||||
|
||||
/// <summary>Internal memory reallocator</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void* MemRealloc(void* ptr, int size);
|
||||
public static extern void* MemRealloc(void* ptr, uint size);
|
||||
|
||||
/// <summary>Internal memory free</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -508,12 +508,12 @@ public static unsafe partial class Raylib
|
||||
|
||||
/// <summary>Set custom file binary data loader</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetLoadFileDataCallback(delegate* unmanaged[Cdecl]<sbyte*, uint*, byte*> callback);
|
||||
public static extern void SetLoadFileDataCallback(delegate* unmanaged[Cdecl]<sbyte*, int*, byte*> callback);
|
||||
|
||||
/// <summary>Set custom file binary data saver</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetSaveFileDataCallback(
|
||||
delegate* unmanaged[Cdecl]<sbyte*, void*, uint, CBool> callback
|
||||
delegate* unmanaged[Cdecl]<sbyte*, void*, int, CBool> callback
|
||||
);
|
||||
|
||||
/// <summary>Set custom file text data loader</summary>
|
||||
@ -529,7 +529,7 @@ public static unsafe partial class Raylib
|
||||
|
||||
/// <summary>Load file data as byte array (read)</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern byte* LoadFileData(sbyte* fileName, uint* bytesRead);
|
||||
public static extern byte* LoadFileData(sbyte* fileName, int* dataSize);
|
||||
|
||||
/// <summary>Unload file data allocated by LoadFileData()</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -537,11 +537,11 @@ public static unsafe partial class Raylib
|
||||
|
||||
/// <summary>Save data to file from byte array (write), returns true on success</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern CBool SaveFileData(sbyte* fileName, void* data, uint bytesToWrite);
|
||||
public static extern CBool SaveFileData(sbyte* fileName, void* data, int dataSize);
|
||||
|
||||
/// <summary>Export data to code (.h), returns true on success</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern CBool ExportDataAsCode(byte* data, uint size, sbyte* fileName);
|
||||
public static extern CBool ExportDataAsCode(byte* data, int dataSize, sbyte* fileName);
|
||||
|
||||
// Load text data from file (read), returns a '\0' terminated string
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -2452,7 +2452,7 @@ public static unsafe partial class Raylib
|
||||
|
||||
/// <summary>Load model animations from file</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern ModelAnimation* LoadModelAnimations(sbyte* fileName, uint* animCount);
|
||||
public static extern ModelAnimation* LoadModelAnimations(sbyte* fileName, int* animCount);
|
||||
|
||||
/// <summary>Update model animation pose</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
@ -2464,7 +2464,7 @@ public static unsafe partial class Raylib
|
||||
|
||||
/// <summary>Unload animation array data</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void UnloadModelAnimations(ModelAnimation* animations, uint animCount);
|
||||
public static extern void UnloadModelAnimations(ModelAnimation* animations, int animCount);
|
||||
|
||||
/// <summary>Check model animation skeleton match</summary>
|
||||
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||
|
@ -613,9 +613,9 @@ public static unsafe partial class Rlgl
|
||||
[DllImport(NativeLibName, EntryPoint = "rlGetGlTextureFormats", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void GetGlTextureFormats(
|
||||
PixelFormat format,
|
||||
int* glInternalFormat,
|
||||
int* glFormat,
|
||||
int* glType
|
||||
uint* glInternalFormat,
|
||||
uint* glFormat,
|
||||
uint* glType
|
||||
);
|
||||
|
||||
/// <summary>Get OpenGL internal formats</summary>
|
||||
|
@ -71,7 +71,7 @@ public unsafe partial struct Mesh
|
||||
/// </summary>
|
||||
public void AllocVertices()
|
||||
{
|
||||
Vertices = Raylib.New<float>(3 * VertexCount);
|
||||
Vertices = Raylib.New<float>(3 * (uint)VertexCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -79,7 +79,7 @@ public unsafe partial struct Mesh
|
||||
/// </summary>
|
||||
public void AllocTexCoords()
|
||||
{
|
||||
TexCoords = Raylib.New<float>(2 * VertexCount);
|
||||
TexCoords = Raylib.New<float>(2 * (uint)VertexCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -87,7 +87,7 @@ public unsafe partial struct Mesh
|
||||
/// </summary>
|
||||
public void AllocTexCoords2()
|
||||
{
|
||||
TexCoords2 = Raylib.New<float>(2 * VertexCount);
|
||||
TexCoords2 = Raylib.New<float>(2 * (uint)VertexCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -95,7 +95,7 @@ public unsafe partial struct Mesh
|
||||
/// </summary>
|
||||
public void AllocNormals()
|
||||
{
|
||||
Normals = Raylib.New<float>(3 * VertexCount);
|
||||
Normals = Raylib.New<float>(3 * (uint)VertexCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -103,7 +103,7 @@ public unsafe partial struct Mesh
|
||||
/// </summary>
|
||||
public void AllocTangents()
|
||||
{
|
||||
Tangents = Raylib.New<float>(4 * VertexCount);
|
||||
Tangents = Raylib.New<float>(4 * (uint)VertexCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -111,7 +111,7 @@ public unsafe partial struct Mesh
|
||||
/// </summary>
|
||||
public void AllocColors()
|
||||
{
|
||||
Colors = Raylib.New<byte>(4 * VertexCount);
|
||||
Colors = Raylib.New<byte>(4 * (uint)VertexCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -119,7 +119,7 @@ public unsafe partial struct Mesh
|
||||
/// </summary>
|
||||
public void AllocIndices()
|
||||
{
|
||||
Indices = Raylib.New<ushort>(3 * TriangleCount);
|
||||
Indices = Raylib.New<ushort>(3 * (uint)TriangleCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -230,16 +230,16 @@ public static unsafe partial class Raylib
|
||||
}
|
||||
|
||||
/// <summary>C++ style memory allocator</summary>
|
||||
public static T* New<T>(int count) where T : unmanaged
|
||||
public static T* New<T>(uint count) where T : unmanaged
|
||||
{
|
||||
return (T*)MemAlloc(count * sizeof(T));
|
||||
return (T*)MemAlloc(count * (uint)sizeof(T));
|
||||
}
|
||||
|
||||
/// <summary>Load file data as byte array (read)</summary>
|
||||
public static byte* LoadFileData(string fileName, ref uint bytesRead)
|
||||
public static byte* LoadFileData(string fileName, ref int bytesRead)
|
||||
{
|
||||
using var str1 = fileName.ToAnsiBuffer();
|
||||
fixed (uint* p = &bytesRead)
|
||||
fixed (int* p = &bytesRead)
|
||||
{
|
||||
return LoadFileData(str1.AsPointer(), p);
|
||||
}
|
||||
@ -930,10 +930,10 @@ public static unsafe partial class Raylib
|
||||
}
|
||||
|
||||
/// <summary>Load model animations from file</summary>
|
||||
public static ModelAnimation* LoadModelAnimations(string fileName, ref uint animCount)
|
||||
public static ModelAnimation* LoadModelAnimations(string fileName, ref int animCount)
|
||||
{
|
||||
using var str1 = fileName.ToAnsiBuffer();
|
||||
fixed (uint* p = &animCount)
|
||||
fixed (int* p = &animCount)
|
||||
{
|
||||
return LoadModelAnimations(str1.AsPointer(), p);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user