Automatic closing of examples, revise drawing example
This commit is contained in:
@@ -264,7 +264,7 @@ compile_file(String filename, U32 compile_flags = COMPILE_NULL){
|
||||
}
|
||||
|
||||
if(is_flag_set(compile_flags, COMPILE_AND_RUN)){
|
||||
int result = system("a.exe");
|
||||
int result = system("a.exe testing");
|
||||
assert(result != -1);
|
||||
if(result == 0){
|
||||
log_info(PRINTF_GREEN "OK!" PRINTF_RESET);
|
||||
|
||||
@@ -1076,14 +1076,12 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){
|
||||
|
||||
node->index_original_type = left.type;
|
||||
node->resolved_type = left.type->arr.base;
|
||||
if(is_string(left.type)){
|
||||
if(left.type == type_pointer_to_char){
|
||||
node->resolved_type = type_char;
|
||||
}
|
||||
else {
|
||||
else if(is_string(left.type)) {
|
||||
node->resolved_type = type_u8;
|
||||
}
|
||||
}
|
||||
|
||||
// @todo: type_architecture?
|
||||
// we only try to convert the index cause array can't be const
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#import "base.kl"
|
||||
Arena :: #import "arena.kl"
|
||||
#import "arena.kl"
|
||||
#import "os_windows.kl"
|
||||
#import "kernel32.kl"
|
||||
#import "gdi32.kl"
|
||||
@@ -9,6 +9,8 @@ Arena :: #import "arena.kl"
|
||||
Vec2I :: struct;; x: S64; y: S64
|
||||
Vec2 :: struct;; x: F32; y: F32
|
||||
|
||||
AppIsRunning := true
|
||||
|
||||
Windows_Bitmap :: struct
|
||||
size: Vec2I
|
||||
data: *U32
|
||||
@@ -44,8 +46,6 @@ CreateBitmap :: (size: Vec2I, bottom_up: Bool = true): Windows_Bitmap
|
||||
result.hdc = CreateCompatibleDC(hdc)
|
||||
return result
|
||||
|
||||
|
||||
AppIsRunning := true
|
||||
WindowProc :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRESULT
|
||||
if msg == WM_DESTROY
|
||||
PostQuitMessage(0)
|
||||
@@ -57,7 +57,7 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
|
||||
if good_scheduling := false, timeBeginPeriod(1) == TIMERR_NOERROR
|
||||
good_scheduling = true
|
||||
|
||||
arena: Arena.Arena
|
||||
arena: Arena
|
||||
|
||||
window_name := StringToString16(&arena, "Have a wonderful day! 你好世界 ")
|
||||
w := WNDCLASSW{
|
||||
@@ -98,21 +98,7 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
|
||||
|
||||
SelectObject(bitmap.hdc, bitmap.dib)
|
||||
BitBlt(window_dc, 0, 0, (bitmap.size.x)->int, (bitmap.size.y)->int, bitmap.hdc, 0, 0, SRCCOPY)
|
||||
Sleep(100)
|
||||
|
||||
|
||||
frame_time := Time() - frame_start_time
|
||||
if frame_time < requested_time_per_frame
|
||||
if good_scheduling
|
||||
time_to_sleep := (requested_time_per_frame - frame_time) * 1000
|
||||
if time_to_sleep > 0
|
||||
time_to_sleep_dword := time_to_sleep->DWORD
|
||||
// @check if time_to_sleep_dword truncates down
|
||||
Sleep(time_to_sleep_dword)
|
||||
|
||||
new_frame_time := Time()
|
||||
for new_frame_time < requested_time_per_frame
|
||||
new_frame_time = Time() - frame_start_time
|
||||
|
||||
frame_time = new_frame_time
|
||||
frame_number += 1
|
||||
total_time += frame_time
|
||||
if CStringCompare(lpCmdLine, "testing")
|
||||
ExitProcess(0)
|
||||
|
||||
@@ -182,11 +182,9 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
|
||||
Screen = bitmap.data; X = bitmap.size.x; Y = bitmap.size.y
|
||||
Raymarcher_Update()
|
||||
|
||||
|
||||
SelectObject(bitmap.hdc, bitmap.dib)
|
||||
BitBlt(window_dc, 0, 0, (bitmap.size.x)->int, (bitmap.size.y)->int, bitmap.hdc, 0, 0, SRCCOPY)
|
||||
|
||||
|
||||
frame_time := Time() - frame_start_time
|
||||
frame_number += 1
|
||||
TotalTime += frame_time
|
||||
@@ -203,3 +201,6 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
|
||||
new_frame_time = Time() - frame_start_time
|
||||
|
||||
frame_time = new_frame_time
|
||||
|
||||
if CStringCompare(lpCmdLine, "testing")
|
||||
ExitProcess(0)
|
||||
@@ -94,6 +94,16 @@ StringToString16 :: (arena: *Arena, in: String): String16
|
||||
result.str[result.len] = 0
|
||||
return result
|
||||
|
||||
CStringCompare :: (a: *char, b: *char): Bool
|
||||
i := 0
|
||||
for , a[i] != 0, i+=1
|
||||
if a[i] != b[i]
|
||||
return false
|
||||
if a[i] != b[i]
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
TestUnicode :: (arena: *Arena)
|
||||
string := " 豈 更 車 賈 滑 串 句 龜 龜 契 金 喇 奈 懶 癩 羅 蘿 螺 裸 邏 樂 洛 烙 珞 落 酪 駱 亂 卵 欄 爛 蘭 鸞 嵐 濫 藍 襤 拉 臘 蠟 廊 朗 浪 狼 郎 來 冷 勞 擄 櫓 爐 盧 老 蘆 虜 路 露 魯 鷺 碌 祿 綠 菉 錄 鹿 論 壟 弄 籠 聾 牢 磊 賂 雷 壘 屢 樓 淚 漏 累 縷 陋 勒 肋 凜 凌 稜 綾 菱 陵 讀 拏 樂 諾 丹 寧 怒 率 異 北 磻 便 復 不 泌 數 索 參 塞 省 葉 說 殺 辰 沈 拾 若 掠 略 亮 兩 凉 梁 糧 良 諒 量 勵 ..."
|
||||
string_result := StringToString16(arena, string)
|
||||
|
||||
@@ -54,6 +54,7 @@ WriteConsoleA :: #foreign (hConsoleOutput: HANDLE,lpBuffer: *VOID,nNumberOfChars
|
||||
WriteConsoleW :: #foreign (hConsoleOutput: HANDLE,lpBuffer: *VOID,nNumberOfCharsToWrite: DWORD,lpNumberOfCharsWritten: LPDWORD,lpReserve: LPVOID): BOOL
|
||||
__debugbreak :: #foreign ()
|
||||
|
||||
ExitProcess :: #foreign (uExitCode: UINT)
|
||||
GetLastError :: #foreign (): DWORD
|
||||
QueryPerformanceFrequency :: #foreign (lpFrequency: *LARGE_INTEGER): BOOL
|
||||
QueryPerformanceCounter :: #foreign (lpFrequency: *LARGE_INTEGER): BOOL
|
||||
|
||||
Reference in New Issue
Block a user