Working on math libraries

This commit is contained in:
Krzosa Karol
2022-10-13 12:33:16 +02:00
parent 6e8acf7dc8
commit 022f874c32
8 changed files with 58 additions and 42 deletions

View File

@@ -1,6 +1,6 @@
#import "Math.core"
V3 :: #import "MathVec3.core"
Vec3 :: V3.Vec3
F :: #import "MathF32.core"
V3 :: #import "MathVec3.core"; Vec3 :: V3.Vec3
V2 :: #import "MathVec2.core"; Vec2 :: V2.Vec2
Epsilon :: 0.00001
Screen : *U32
@@ -18,8 +18,8 @@ Raymarcher_Update :: ()
forward := Vec3{0, 0, -1}
side := V3.Normalize(V3.Cross(forward, up))
LightPos.x = cosf(TotalTime->F32)*4
LightPos.y = sinf(TotalTime->F32)*4
LightPos.x = F.Cos(TotalTime->F32)*4
LightPos.y = F.Sin(TotalTime->F32)*4
ambient_color := Vec3{0.2,0.2,0.2}
diffuse_color := Vec3{0.7,0.2,0.2}
@@ -77,9 +77,9 @@ Raymarcher_Update :: ()
color = color * light_intensity
// Gamma correction
color.x = sqrtf(color.x)
color.y = sqrtf(color.y)
color.z = sqrtf(color.z)
color.x = F.SquareRoot(color.x)
color.y = F.SquareRoot(color.y)
color.z = F.SquareRoot(color.z)
Screen[x + y*X] = V3.ConvertToARGB(color)
else;; Screen[x + y*X] = 0
@@ -126,7 +126,7 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
}
Assert(RegisterClassW(&w) != 0)
screen_size: Vec2I = {1280, 720}
screen_size: V2.Vec2I = {1280, 720}
window := CreateWindowExW(
dwExStyle = 0, hWndParent = 0, hMenu = 0, lpParam = 0,
X = CW_USEDEFAULT, Y = CW_USEDEFAULT, nWidth = screen_size.x->int, nHeight = screen_size.y->int,
@@ -179,12 +179,12 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
Windows_Bitmap :: struct
size: Vec2I
size: V2.Vec2I
data: *U32
hdc: HDC
dib: HBITMAP
CreateBitmap :: (size: Vec2I, bottom_up: Bool = true): Windows_Bitmap
CreateBitmap :: (size: V2.Vec2I, bottom_up: Bool = true): Windows_Bitmap
result: Windows_Bitmap = {size = size}
if bottom_up == false
result.size.y = -result.size.y