mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Win32 Demo - Minor math tests
This commit is contained in:
+1
-1
@@ -414,7 +414,7 @@ extern "C" {
|
|||||||
#ifdef STB_IMAGE_STATIC
|
#ifdef STB_IMAGE_STATIC
|
||||||
#define STBIDEF static
|
#define STBIDEF static
|
||||||
#else
|
#else
|
||||||
#define STBIDEF extern
|
#define STBIDEF extern "C" __declspec(dllexport)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
+933
-69
File diff suppressed because it is too large
Load Diff
@@ -1,20 +1,4 @@
|
|||||||
#load "basic.odin"
|
#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 "win32.odin"
|
||||||
#load "opengl.odin"
|
#load "opengl.odin"
|
||||||
#load "stb_image.odin"
|
#load "stb_image.odin"
|
||||||
@@ -173,12 +157,6 @@ main :: proc() {
|
|||||||
}
|
}
|
||||||
defer destroy_window(^window);
|
defer destroy_window(^window);
|
||||||
|
|
||||||
{
|
|
||||||
v := Vec2{1, 2};
|
|
||||||
c := v * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
prev_time := time_now();
|
prev_time := time_now();
|
||||||
running := true;
|
running := true;
|
||||||
for running {
|
for running {
|
||||||
@@ -215,4 +193,3 @@ main :: proc() {
|
|||||||
display_window(^window);
|
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)); }
|
||||||
|
|
||||||
+3
-2
@@ -84,8 +84,9 @@ int main(int argc, char **argv) {
|
|||||||
if (exit_code == 0) {
|
if (exit_code == 0) {
|
||||||
win32_exec_command_line_app(
|
win32_exec_command_line_app(
|
||||||
"clang -o %.*s.exe %.*s.bc -Wno-override-module "
|
"clang -o %.*s.exe %.*s.bc -Wno-override-module "
|
||||||
"-lkernel32.lib -luser32.lib -lgdi32.lib -lopengl32.lib "
|
"-lKernel32.lib -lUser32.lib -lGdi32.lib -lOpengl32.lib "
|
||||||
"-l../c_libs/stb_image.lib",
|
"-l../c_libs/stb_image.lib"
|
||||||
|
,
|
||||||
cast(int)base_name_len, output_name,
|
cast(int)base_name_len, output_name,
|
||||||
cast(int)base_name_len, output_name);
|
cast(int)base_name_len, output_name);
|
||||||
if (run_output) {
|
if (run_output) {
|
||||||
|
|||||||
Reference in New Issue
Block a user