~evantj/hare-raylib

448c6b73278870abd2434a27ef028b062c341d9e — Evan Johnston 1 year, 4 months ago 7076bf6
update raylib/
2 files changed, 303 insertions(+), 20 deletions(-)

M raylib/raylib.ha
A raylib/raymath.ha
M raylib/raylib.ha => raylib/raylib.ha +20 -20
@@ 1390,7 1390,7 @@ export @symbol("GetWindowScaleDPI") fn GetWindowScaleDPI() Vector2;

// Get the human-readable, UTF-8 encoded name of the primary monitor
export fn GetMonitorName(monitor: int) const str = {
	return strings::fromc(_GetMonitorName(monitor));
	return strings::fromc(_GetMonitorName(monitor))!;
};

@symbol("SetClipboardText") fn _SetClipboardText(text: const *char) void;


@@ 1406,7 1406,7 @@ export fn SetClipboardText(text: const str) void = {

// Get clipboard text content
export fn GetClipboardText() const str = {
	return strings::fromc(_GetClipboardText());
	return strings::fromc(_GetClipboardText())!;
};

// Swap back buffer with front buffer (screen drawing)


@@ 1664,7 1664,7 @@ export fn SaveFileData(fileName: const str, data: *void, bytesToWrite: uint) boo
export fn LoadFileText(fileName: const str) str = {
	let fileName_cstring: *char = strings::to_c(fileName);
	defer free(fileName_cstring);
	return strings::fromc(_LoadFileText(fileName_cstring));
	return strings::fromc(_LoadFileText(fileName_cstring))!;
};

@symbol("UnloadFileText") fn _UnloadFileText(text: *char) void;


@@ 1722,7 1722,7 @@ export fn IsFileExtension(fileName: const str, ext: const str) bool = {
export fn GetFileExtension(fileName: const str) const str = {
	let fileName_cstring: *char = strings::to_c(fileName);
	defer free(fileName_cstring);
	return strings::fromc(_GetFileExtension(fileName_cstring));
	return strings::fromc(_GetFileExtension(fileName_cstring))!;
};

@symbol("GetFileName") fn _GetFileName(filePath: const *char) const *char;


@@ 1731,7 1731,7 @@ export fn GetFileExtension(fileName: const str) const str = {
export fn GetFileName(filePath: const str) const str = {
	let filePath_cstring: *char = strings::to_c(filePath);
	defer free(filePath_cstring);
	return strings::fromc(_GetFileName(filePath_cstring));
	return strings::fromc(_GetFileName(filePath_cstring))!;
};

@symbol("GetFileNameWithoutExt") fn _GetFileNameWithoutExt(filePath: const *char) const *char;


@@ 1740,7 1740,7 @@ export fn GetFileName(filePath: const str) const str = {
export fn GetFileNameWithoutExt(filePath: const str) const str = {
	let filePath_cstring: *char = strings::to_c(filePath);
	defer free(filePath_cstring);
	return strings::fromc(_GetFileNameWithoutExt(filePath_cstring));
	return strings::fromc(_GetFileNameWithoutExt(filePath_cstring))!;
};

@symbol("GetDirectoryPath") fn _GetDirectoryPath(filePath: const *char) const *char;


@@ 1749,7 1749,7 @@ export fn GetFileNameWithoutExt(filePath: const str) const str = {
export fn GetDirectoryPath(filePath: const str) const str = {
	let filePath_cstring: *char = strings::to_c(filePath);
	defer free(filePath_cstring);
	return strings::fromc(_GetDirectoryPath(filePath_cstring));
	return strings::fromc(_GetDirectoryPath(filePath_cstring))!;
};

@symbol("GetPrevDirectoryPath") fn _GetPrevDirectoryPath(dirPath: const *char) const *char;


@@ 1758,14 1758,14 @@ export fn GetDirectoryPath(filePath: const str) const str = {
export fn GetPrevDirectoryPath(dirPath: const str) const str = {
	let dirPath_cstring: *char = strings::to_c(dirPath);
	defer free(dirPath_cstring);
	return strings::fromc(_GetPrevDirectoryPath(dirPath_cstring));
	return strings::fromc(_GetPrevDirectoryPath(dirPath_cstring))!;
};

@symbol("GetWorkingDirectory") fn _GetWorkingDirectory() const *char;

// Get current working directory (uses static string)
export fn GetWorkingDirectory() const str = {
	return strings::fromc(_GetWorkingDirectory());
	return strings::fromc(_GetWorkingDirectory())!;
};

@symbol("GetDirectoryFiles") fn _GetDirectoryFiles(dirPath: const *char, count: *int) **char;


@@ 1821,7 1821,7 @@ export @symbol("DecompressData") fn DecompressData(compData: *char, compDataLeng

// Encode data to Base64 string
export fn EncodeDataBase64(data: const *char, dataLength: int, outputLength: *int) str = {
	return strings::fromc(_EncodeDataBase64(data, dataLength, outputLength));
	return strings::fromc(_EncodeDataBase64(data, dataLength, outputLength))!;
};

// Decode Base64 string data


@@ 1894,7 1894,7 @@ export fn IsGamepadAvailable(gamepad: int) bool = {

// Get gamepad internal name id
export fn GetGamepadName(gamepad: int) const str = {
	return strings::fromc(_GetGamepadName(gamepad));
	return strings::fromc(_GetGamepadName(gamepad))!;
};

@symbol("IsGamepadButtonPressed") fn _IsGamepadButtonPressed(gamepad: int, button: int) c_bool;


@@ 2719,14 2719,14 @@ export fn GetCodepoint(text: const str, bytesProcessed: *int) int = {

// Encode one codepoint into UTF-8 byte array (array length returned as parameter)
export fn CodepointToUTF8(codepoint: int, byteSize: *int) const str = {
	return strings::fromc(_CodepointToUTF8(codepoint, byteSize));
	return strings::fromc(_CodepointToUTF8(codepoint, byteSize))!;
};

@symbol("TextCodepointsToUTF8") fn _TextCodepointsToUTF8(codepoints: *int, length: int) *char;

// Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!)
export fn TextCodepointsToUTF8(codepoints: *int, length: int) str = {
	return strings::fromc(_TextCodepointsToUTF8(codepoints, length));
	return strings::fromc(_TextCodepointsToUTF8(codepoints, length))!;
};

@symbol("TextCopy") fn _TextCopy(dst: *char, src: const *char) int;


@@ 2769,7 2769,7 @@ export @symbol("TextFormat") fn TextFormat(text: const *char, ...) const *char;
export fn TextSubtext(text: const str, position: int, length: int) const str = {
	let text_cstring: *char = strings::to_c(text);
	defer free(text_cstring);
	return strings::fromc(_TextSubtext(text_cstring, position, length));
	return strings::fromc(_TextSubtext(text_cstring, position, length))!;
};

@symbol("TextReplace") fn _TextReplace(text: *char, replace: const *char, by: const *char) *char;


@@ 2782,7 2782,7 @@ export fn TextReplace(text: str, replace: const str, by: const str) str = {
	defer free(replace_cstring);
	let by_cstring: *char = strings::to_c(by);
	defer free(by_cstring);
	return strings::fromc(_TextReplace(text_cstring, replace_cstring, by_cstring));
	return strings::fromc(_TextReplace(text_cstring, replace_cstring, by_cstring))!;
};

@symbol("TextInsert") fn _TextInsert(text: const *char, _insert: const *char, position: int) *char;


@@ 2793,7 2793,7 @@ export fn TextInsert(text: const str, _insert: const str, position: int) str = {
	defer free(text_cstring);
	let _insert_cstring: *char = strings::to_c(_insert);
	defer free(_insert_cstring);
	return strings::fromc(_TextInsert(text_cstring, _insert_cstring, position));
	return strings::fromc(_TextInsert(text_cstring, _insert_cstring, position))!;
};

@symbol("TextJoin") fn _TextJoin(textList: const **char, count: int, delimiter: const *char) const *char;


@@ 2802,7 2802,7 @@ export fn TextInsert(text: const str, _insert: const str, position: int) str = {
export fn TextJoin(textList: const **char, count: int, delimiter: const str) const str = {
	let delimiter_cstring: *char = strings::to_c(delimiter);
	defer free(delimiter_cstring);
	return strings::fromc(_TextJoin(textList, count, delimiter_cstring));
	return strings::fromc(_TextJoin(textList, count, delimiter_cstring))!;
};

@symbol("TextSplit") fn _TextSplit(text: const *char, delimiter: char, count: *int) const **char;


@@ 2842,7 2842,7 @@ export fn TextFindIndex(text: const str, find: const str) int = {
export fn TextToUpper(text: const str) const str = {
	let text_cstring: *char = strings::to_c(text);
	defer free(text_cstring);
	return strings::fromc(_TextToUpper(text_cstring));
	return strings::fromc(_TextToUpper(text_cstring))!;
};

@symbol("TextToLower") fn _TextToLower(text: const *char) const *char;


@@ 2851,7 2851,7 @@ export fn TextToUpper(text: const str) const str = {
export fn TextToLower(text: const str) const str = {
	let text_cstring: *char = strings::to_c(text);
	defer free(text_cstring);
	return strings::fromc(_TextToLower(text_cstring));
	return strings::fromc(_TextToLower(text_cstring))!;
};

@symbol("TextToPascal") fn _TextToPascal(text: const *char) const *char;


@@ 2860,7 2860,7 @@ export fn TextToLower(text: const str) const str = {
export fn TextToPascal(text: const str) const str = {
	let text_cstring: *char = strings::to_c(text);
	defer free(text_cstring);
	return strings::fromc(_TextToPascal(text_cstring));
	return strings::fromc(_TextToPascal(text_cstring))!;
};

@symbol("TextToInteger") fn _TextToInteger(text: const *char) int;

A raylib/raymath.ha => raylib/raymath.ha +283 -0
@@ 0,0 1,283 @@

use strings;

// c boolean
export type c_bool = enum u8 {
	FALSE = 0,
	TRUE = 1,
};

// internal to raudio
export type rAudioProcessor = void;

// internal to raudio
export type rAudioBuffer = void;


export def PI: f64 = 3.141592653589793;

export def DEG2RAD: f64 = (PI/180.0);

export def RAD2DEG: f64 = (180.0/PI);

// Vector2 type
export type Vector2 = struct {
	x: f32,
	y: f32,
};

// Vector3 type
export type Vector3 = struct {
	x: f32,
	y: f32,
	z: f32,
};

// Vector4 type
export type Vector4 = struct {
	x: f32,
	y: f32,
	z: f32,
	w: f32,
};

// Matrix type (OpenGL style 4x4 - right handed, column major)
export type Matrix = struct {
	// Matrix first row (4 components)
	m0: f32,
	// Matrix first row (4 components)
	m4: f32,
	// Matrix first row (4 components)
	m8: f32,
	// Matrix first row (4 components)
	m12: f32,
	// Matrix second row (4 components)
	m1: f32,
	// Matrix second row (4 components)
	m5: f32,
	// Matrix second row (4 components)
	m9: f32,
	// Matrix second row (4 components)
	m13: f32,
	// Matrix third row (4 components)
	m2: f32,
	// Matrix third row (4 components)
	m6: f32,
	// Matrix third row (4 components)
	m10: f32,
	// Matrix third row (4 components)
	m14: f32,
	// Matrix fourth row (4 components)
	m3: f32,
	// Matrix fourth row (4 components)
	m7: f32,
	// Matrix fourth row (4 components)
	m11: f32,
	// Matrix fourth row (4 components)
	m15: f32,
};

// NOTE: Helper types to be used instead of array return types for *ToFloat functions
export type float3 = struct {
	v: [3]f32,
};

export type float16 = struct {
	v: [16]f32,
};

// Quaternion type
export type Quaternion = Vector4;

export @symbol("Clamp") fn Clamp(value: f32, min: f32, max: f32) f32;

export @symbol("Lerp") fn Lerp(start: f32, end: f32, amount: f32) f32;

export @symbol("Normalize") fn Normalize(value: f32, start: f32, end: f32) f32;

export @symbol("Remap") fn Remap(value: f32, inputStart: f32, inputEnd: f32, outputStart: f32, outputEnd: f32) f32;

export @symbol("Vector2Zero") fn Vector2Zero() Vector2;

export @symbol("Vector2One") fn Vector2One() Vector2;

export @symbol("Vector2Add") fn Vector2Add(v1: Vector2, v2: Vector2) Vector2;

export @symbol("Vector2AddValue") fn Vector2AddValue(v: Vector2, add: f32) Vector2;

export @symbol("Vector2Subtract") fn Vector2Subtract(v1: Vector2, v2: Vector2) Vector2;

export @symbol("Vector2SubtractValue") fn Vector2SubtractValue(v: Vector2, sub: f32) Vector2;

export @symbol("Vector2Length") fn Vector2Length(v: Vector2) f32;

export @symbol("Vector2LengthSqr") fn Vector2LengthSqr(v: Vector2) f32;

export @symbol("Vector2DotProduct") fn Vector2DotProduct(v1: Vector2, v2: Vector2) f32;

export @symbol("Vector2Distance") fn Vector2Distance(v1: Vector2, v2: Vector2) f32;

export @symbol("Vector2Angle") fn Vector2Angle(v1: Vector2, v2: Vector2) f32;

export @symbol("Vector2Scale") fn Vector2Scale(v: Vector2, scale: f32) Vector2;

export @symbol("Vector2Multiply") fn Vector2Multiply(v1: Vector2, v2: Vector2) Vector2;

export @symbol("Vector2Negate") fn Vector2Negate(v: Vector2) Vector2;

export @symbol("Vector2Divide") fn Vector2Divide(v1: Vector2, v2: Vector2) Vector2;

export @symbol("Vector2Normalize") fn Vector2Normalize(v: Vector2) Vector2;

export @symbol("Vector2Lerp") fn Vector2Lerp(v1: Vector2, v2: Vector2, amount: f32) Vector2;

export @symbol("Vector2Reflect") fn Vector2Reflect(v: Vector2, normal: Vector2) Vector2;

export @symbol("Vector2Rotate") fn Vector2Rotate(v: Vector2, angle: f32) Vector2;

export @symbol("Vector2MoveTowards") fn Vector2MoveTowards(v: Vector2, target: Vector2, maxDistance: f32) Vector2;

export @symbol("Vector3Zero") fn Vector3Zero() Vector3;

export @symbol("Vector3One") fn Vector3One() Vector3;

export @symbol("Vector3Add") fn Vector3Add(v1: Vector3, v2: Vector3) Vector3;

export @symbol("Vector3AddValue") fn Vector3AddValue(v: Vector3, add: f32) Vector3;

export @symbol("Vector3Subtract") fn Vector3Subtract(v1: Vector3, v2: Vector3) Vector3;

export @symbol("Vector3SubtractValue") fn Vector3SubtractValue(v: Vector3, sub: f32) Vector3;

export @symbol("Vector3Scale") fn Vector3Scale(v: Vector3, scalar: f32) Vector3;

export @symbol("Vector3Multiply") fn Vector3Multiply(v1: Vector3, v2: Vector3) Vector3;

export @symbol("Vector3CrossProduct") fn Vector3CrossProduct(v1: Vector3, v2: Vector3) Vector3;

export @symbol("Vector3Perpendicular") fn Vector3Perpendicular(v: Vector3) Vector3;

export @symbol("Vector3Length") fn Vector3Length(v: const Vector3) f32;

export @symbol("Vector3LengthSqr") fn Vector3LengthSqr(v: const Vector3) f32;

export @symbol("Vector3DotProduct") fn Vector3DotProduct(v1: Vector3, v2: Vector3) f32;

export @symbol("Vector3Distance") fn Vector3Distance(v1: Vector3, v2: Vector3) f32;

export @symbol("Vector3Angle") fn Vector3Angle(v1: Vector3, v2: Vector3) Vector2;

export @symbol("Vector3Negate") fn Vector3Negate(v: Vector3) Vector3;

export @symbol("Vector3Divide") fn Vector3Divide(v1: Vector3, v2: Vector3) Vector3;

export @symbol("Vector3Normalize") fn Vector3Normalize(v: Vector3) Vector3;

export @symbol("Vector3OrthoNormalize") fn Vector3OrthoNormalize(v1: *Vector3, v2: *Vector3) void;

export @symbol("Vector3Transform") fn Vector3Transform(v: Vector3, mat: Matrix) Vector3;

export @symbol("Vector3RotateByQuaternion") fn Vector3RotateByQuaternion(v: Vector3, q: Quaternion) Vector3;

export @symbol("Vector3Lerp") fn Vector3Lerp(v1: Vector3, v2: Vector3, amount: f32) Vector3;

export @symbol("Vector3Reflect") fn Vector3Reflect(v: Vector3, normal: Vector3) Vector3;

export @symbol("Vector3Min") fn Vector3Min(v1: Vector3, v2: Vector3) Vector3;

export @symbol("Vector3Max") fn Vector3Max(v1: Vector3, v2: Vector3) Vector3;

export @symbol("Vector3Barycenter") fn Vector3Barycenter(p: Vector3, a: Vector3, b: Vector3, c: Vector3) Vector3;

export @symbol("Vector3Unproject") fn Vector3Unproject(source: Vector3, projection: Matrix, view: Matrix) Vector3;

export @symbol("Vector3ToFloatV") fn Vector3ToFloatV(v: Vector3) float3;

export @symbol("MatrixDeterminant") fn MatrixDeterminant(mat: Matrix) f32;

export @symbol("MatrixTrace") fn MatrixTrace(mat: Matrix) f32;

export @symbol("MatrixTranspose") fn MatrixTranspose(mat: Matrix) Matrix;

export @symbol("MatrixInvert") fn MatrixInvert(mat: Matrix) Matrix;

export @symbol("MatrixNormalize") fn MatrixNormalize(mat: Matrix) Matrix;

export @symbol("MatrixIdentity") fn MatrixIdentity() Matrix;

export @symbol("MatrixAdd") fn MatrixAdd(left: Matrix, right: Matrix) Matrix;

export @symbol("MatrixSubtract") fn MatrixSubtract(left: Matrix, right: Matrix) Matrix;

export @symbol("MatrixMultiply") fn MatrixMultiply(left: Matrix, right: Matrix) Matrix;

export @symbol("MatrixTranslate") fn MatrixTranslate(x: f32, y: f32, z: f32) Matrix;

export @symbol("MatrixRotate") fn MatrixRotate(axis: Vector3, angle: f32) Matrix;

export @symbol("MatrixRotateX") fn MatrixRotateX(angle: f32) Matrix;

export @symbol("MatrixRotateY") fn MatrixRotateY(angle: f32) Matrix;

export @symbol("MatrixRotateZ") fn MatrixRotateZ(angle: f32) Matrix;

export @symbol("MatrixRotateXYZ") fn MatrixRotateXYZ(ang: Vector3) Matrix;

export @symbol("MatrixRotateZYX") fn MatrixRotateZYX(ang: Vector3) Matrix;

export @symbol("MatrixScale") fn MatrixScale(x: f32, y: f32, z: f32) Matrix;

export @symbol("MatrixFrustum") fn MatrixFrustum(left: f64, right: f64, bottom: f64, top: f64, near: f64, far: f64) Matrix;

export @symbol("MatrixPerspective") fn MatrixPerspective(fovy: f64, aspect: f64, near: f64, far: f64) Matrix;

export @symbol("MatrixOrtho") fn MatrixOrtho(left: f64, right: f64, bottom: f64, top: f64, near: f64, far: f64) Matrix;

export @symbol("MatrixLookAt") fn MatrixLookAt(eye: Vector3, target: Vector3, up: Vector3) Matrix;

export @symbol("MatrixToFloatV") fn MatrixToFloatV(mat: Matrix) float16;

export @symbol("QuaternionAdd") fn QuaternionAdd(q1: Quaternion, q2: Quaternion) Quaternion;

export @symbol("QuaternionAddValue") fn QuaternionAddValue(q: Quaternion, add: f32) Quaternion;

export @symbol("QuaternionSubtract") fn QuaternionSubtract(q1: Quaternion, q2: Quaternion) Quaternion;

export @symbol("QuaternionSubtractValue") fn QuaternionSubtractValue(q: Quaternion, sub: f32) Quaternion;

export @symbol("QuaternionIdentity") fn QuaternionIdentity() Quaternion;

export @symbol("QuaternionLength") fn QuaternionLength(q: Quaternion) f32;

export @symbol("QuaternionNormalize") fn QuaternionNormalize(q: Quaternion) Quaternion;

export @symbol("QuaternionInvert") fn QuaternionInvert(q: Quaternion) Quaternion;

export @symbol("QuaternionMultiply") fn QuaternionMultiply(q1: Quaternion, q2: Quaternion) Quaternion;

export @symbol("QuaternionScale") fn QuaternionScale(q: Quaternion, mul: f32) Quaternion;

export @symbol("QuaternionDivide") fn QuaternionDivide(q1: Quaternion, q2: Quaternion) Quaternion;

export @symbol("QuaternionLerp") fn QuaternionLerp(q1: Quaternion, q2: Quaternion, amount: f32) Quaternion;

export @symbol("QuaternionNlerp") fn QuaternionNlerp(q1: Quaternion, q2: Quaternion, amount: f32) Quaternion;

export @symbol("QuaternionSlerp") fn QuaternionSlerp(q1: Quaternion, q2: Quaternion, amount: f32) Quaternion;

export @symbol("QuaternionFromVector3ToVector3") fn QuaternionFromVector3ToVector3(from: Vector3, to: Vector3) Quaternion;

export @symbol("QuaternionFromMatrix") fn QuaternionFromMatrix(mat: Matrix) Quaternion;

export @symbol("QuaternionToMatrix") fn QuaternionToMatrix(q: Quaternion) Matrix;

export @symbol("QuaternionFromAxisAngle") fn QuaternionFromAxisAngle(axis: Vector3, angle: f32) Quaternion;

export @symbol("QuaternionToAxisAngle") fn QuaternionToAxisAngle(q: Quaternion, outAxis: *Vector3, outAngle: *f32) void;

export @symbol("QuaternionFromEuler") fn QuaternionFromEuler(pitch: f32, yaw: f32, roll: f32) Quaternion;

export @symbol("QuaternionToEuler") fn QuaternionToEuler(q: Quaternion) Vector3;

export @symbol("QuaternionTransform") fn QuaternionTransform(q: Quaternion, mat: Matrix) Quaternion;