mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-14 07:01:25 -07:00
Win32 Demo - Minor math tests
This commit is contained in:
+933
-69
File diff suppressed because it is too large
Load Diff
@@ -1,20 +1,4 @@
|
||||
#load "basic.odin"
|
||||
main :: proc() {
|
||||
a := {4}f32{1}; // {1, 1, 1, 1} broadcasts to all
|
||||
a = swizzle({4}f32{1, 2, 3, 4}, 1, 3, 2, 0);
|
||||
|
||||
for i := 0; i < len(a); i++ {
|
||||
if i > 0 {
|
||||
print_string(", ");
|
||||
}
|
||||
|
||||
print_int(a[i] as int);
|
||||
}
|
||||
print_string("\n");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
#load "win32.odin"
|
||||
#load "opengl.odin"
|
||||
#load "stb_image.odin"
|
||||
@@ -173,12 +157,6 @@ main :: proc() {
|
||||
}
|
||||
defer destroy_window(^window);
|
||||
|
||||
{
|
||||
v := Vec2{1, 2};
|
||||
c := v * 2;
|
||||
}
|
||||
|
||||
|
||||
prev_time := time_now();
|
||||
running := true;
|
||||
for running {
|
||||
@@ -215,4 +193,3 @@ main :: proc() {
|
||||
display_window(^window);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
type Vec2: {2}f32
|
||||
type Vec3: {3}f32
|
||||
type Vec4: {4}f32
|
||||
type Mat2: {4}f32
|
||||
|
||||
|
||||
|
||||
sqrt_f32 :: proc(x: f32) -> f32 #foreign "llvm.sqrt.f32"
|
||||
sqrt_f64 :: proc(x: f64) -> f64 #foreign "llvm.sqrt.f64"
|
||||
|
||||
vec2_dot :: proc(a, b: Vec2) -> f32 { c := a*b; return c[0] + c[1]; }
|
||||
vec3_dot :: proc(a, b: Vec3) -> f32 { c := a*b; return c[0] + c[1] + c[2]; }
|
||||
|
||||
lerp :: proc(a, b, t: f32) -> f32 { return a*(1-t) + b*t; }
|
||||
|
||||
vec2_mag :: proc(a: Vec2) -> f32 { return sqrt_f32(vec2_dot(a, a)); }
|
||||
vec3_mag :: proc(a: Vec3) -> f32 { return sqrt_f32(vec3_dot(a, a)); }
|
||||
|
||||
Reference in New Issue
Block a user