Adding missed compiler errors, some work on modules

This commit is contained in:
Krzosa Karol
2022-10-13 11:43:15 +02:00
parent de0d2181f5
commit 6e8acf7dc8
5 changed files with 44 additions and 5 deletions

View File

@@ -1,8 +1,11 @@
sqrtf :: #foreign (value: F32): F32
cosf :: #foreign (value: F32): F32
sinf :: #foreign (value: F32): F32
floorf :: #foreign (value: F32): F32
roundf :: #foreign (value: F32): F32
ceilf :: #foreign (value: F32): F32
Vec2I :: struct;; x: S64; y: S64
Vec2 :: struct;; x: F32; y: F32
@@ -19,6 +22,22 @@ Vec2 :: struct;; x: F32; y: F32
"/" :: (a: Vec2, b: F32) : Vec2 ;; return {a.x/b, a.y/b}
"/" :: (a: F32, b: Vec2) : Vec2 ;; return {a/b.x, a/b.y}
"*" :: (a: Vec2I, b: Vec2I): Vec2I ;; return {a.x*b.x, a.y*b.y}
"*" :: (a: Vec2I, b: S64) : Vec2I ;; return {a.x*b, a.y*b}
"*" :: (a: S64, b: Vec2I) : Vec2I ;; return {a*b.x, a*b.y}
"-" :: (a: Vec2I, b: Vec2I): Vec2I ;; return {a.x-b.x, a.y-b.y}
"-" :: (a: Vec2I, b: S64) : Vec2I ;; return {a.x-b, a.y-b}
"-" :: (a: S64, b: Vec2I) : Vec2I ;; return {a-b.x, a-b.y}
"+" :: (a: Vec2I, b: Vec2I): Vec2I ;; return {a.x+b.x, a.y+b.y}
"+" :: (a: Vec2I, b: S64) : Vec2I ;; return {a.x+b, a.y+b}
"+" :: (a: S64, b: Vec2I) : Vec2I ;; return {a+b.x, a+b.y}
"/" :: (a: Vec2I, b: Vec2I): Vec2I ;; return {a.x/b.x, a.y/b.y}
"/" :: (a: Vec2I, b: S64) : Vec2I ;; return {a.x/b, a.y/b}
"/" :: (a: S64, b: Vec2I) : Vec2I ;; return {a/b.x, a/b.y}
FloorVec2ToVec2I :: (a: Vec2): Vec2I ;; return {floorf(a.x)->S64, floorf(a.y)->S64}
CastVec2ToVec2I :: (a: Vec2): Vec2I ;; return {a.x->S64, a.y->S64}
F32_Clamp :: (min: F32, value: F32, max: F32): F32
if value > max;; return max
if value < min;; return min
@@ -31,3 +50,8 @@ F32_ClampBottom :: (min: F32, value: F32): F32
F32_Absolute :: (val: F32): F32
if val < 0;; return -val
return val
F32_Min :: (a: F32, b: F32): F32
if a > b ;; return b ; return a
F32_Max :: (a: F32, b: F32): F32
if a > b ;; return a ; return b

View File

@@ -29,6 +29,8 @@ MUWindow :: struct
x: S64
y: S64
sizef: Vec2
size: Vec2I
resizable: Bool
MUTime :: struct
total : F64

View File

@@ -93,7 +93,12 @@ SetWindowPosition :: (window: HWND, style: DWORD, pos: Vec2I): void
AdjustWindowRect(window, style, &rect)
SetWindowPos(window, 0, rect.left, rect.top, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE)
StartMultimedia :: (x: S64 = 1280, y: S64 = 720, title: String = "Hello people!", target_ms: F64 = 0.0166666)
StartMultimedia :: (
x: S64 = 1280, y: S64 = 720,
title: String = "Hello people!",
window_resizable: Bool = false,
target_ms: F64 = 0.0166666
)
Mu.time.delta = target_ms
if timeBeginPeriod(1) == TIMERR_NOERROR
Mu.os.good_scheduling = true
@@ -113,7 +118,7 @@ StartMultimedia :: (x: S64 = 1280, y: S64 = 720, title: String = "Hello people!"
}
Assert(RegisterClassW(&w) != 0)
style: DWORD = GetWindowStyle(false)
style: DWORD = GetWindowStyle(window_resizable)
Mu.os.window = CreateWindowExW(
dwExStyle = 0, hWndParent = 0, hMenu = 0, lpParam = 0,
X = CW_USEDEFAULT, Y = CW_USEDEFAULT, nWidth = x->int, nHeight = y->int,
@@ -132,9 +137,11 @@ StartMultimedia :: (x: S64 = 1280, y: S64 = 720, title: String = "Hello people!"
Mu.os.window_dc = GetDC(Mu.os.window)
Mu.os.bitmap = CreateBitmap(Mu.os.window_dc, size)
Mu.window.resizable = window_resizable
Mu.screen = Mu.os.bitmap.data
Mu.window.x = size.x
Mu.window.y = size.y
Mu.window.size = size
Mu.window.sizef.x = Mu.window.x->F32
Mu.window.sizef.y = Mu.window.y->F32
@@ -149,7 +156,7 @@ UpdateMultimedia :: (): Bool
size := GetWindowSize(Mu.os.window)
if size.x != Mu.window.x || size.y != Mu.window.y
DestroyBitmap(&Mu.os.bitmap)
CreateBitmap(Mu.os.window_dc, size)
Mu.os.bitmap = CreateBitmap(Mu.os.window_dc, size)
Mu.screen = Mu.os.bitmap.data
Mu.window.x = size.x