mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-14 15:23:15 +00:00
Win32 Demo - Minor math tests
This commit is contained in:
@@ -414,7 +414,7 @@ extern "C" {
|
||||
#ifdef STB_IMAGE_STATIC
|
||||
#define STBIDEF static
|
||||
#else
|
||||
#define STBIDEF extern
|
||||
#define STBIDEF extern "C" __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
1002
examples/main.ll
1002
examples/main.ll
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);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
18
examples/math.odin
Normal file
18
examples/math.odin
Normal file
@@ -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)); }
|
||||
|
||||
@@ -84,8 +84,9 @@ int main(int argc, char **argv) {
|
||||
if (exit_code == 0) {
|
||||
win32_exec_command_line_app(
|
||||
"clang -o %.*s.exe %.*s.bc -Wno-override-module "
|
||||
"-lkernel32.lib -luser32.lib -lgdi32.lib -lopengl32.lib "
|
||||
"-l../c_libs/stb_image.lib",
|
||||
"-lKernel32.lib -lUser32.lib -lGdi32.lib -lOpengl32.lib "
|
||||
"-l../c_libs/stb_image.lib"
|
||||
,
|
||||
cast(int)base_name_len, output_name,
|
||||
cast(int)base_name_len, output_name);
|
||||
if (run_output) {
|
||||
|
||||
Reference in New Issue
Block a user