From 0d671d4364fa0db76fca6584a97c51de02b9e220 Mon Sep 17 00:00:00 2001 From: A404M Date: Wed, 28 May 2025 13:52:10 +0330 Subject: add more stuff to lib fix use after free --- code/main.felan | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'code/main.felan') diff --git a/code/main.felan b/code/main.felan index 6d83f56..9f49f01 100644 --- a/code/main.felan +++ b/code/main.felan @@ -12,8 +12,10 @@ WindowShouldClose :: @c_function(raylib,"WindowShouldClose",()->bool); BeginDrawing :: @c_function(raylib,"BeginDrawing",()->void); EndDrawing :: @c_function(raylib,"EndDrawing",()->void); CloseWindow :: @c_function(raylib,"CloseWindow",()->void); -ClearBackground :: @c_function(raylib,"ClearBackground",(color:Color)->void); -DrawText :: @c_function(raylib,"DrawText",(*u8,i32,i32,i32,u32)->void); +ClearBackground :: @c_function(raylib,"ClearBackground",(Color)->void); +DrawText :: @c_function(raylib,"DrawText",(*u8,i32,i32,i32,Color)->void); +// void DrawRectangle(int posX, int posY, int width, int height, Color color); +DrawRectangle :: @c_function(raylib,"DrawRectangle",(posX:i32,posY:i32,width:i32,height:i32,color:Color)->void); Color :: struct { r:u8; @@ -23,6 +25,8 @@ Color :: struct { }; main :: ()->void{ + print(1236); + return; b := "raylib [core] example - basic window\0"; c := "Congrats! You created your first window!\0"; str := &b[0]; @@ -31,14 +35,21 @@ main :: ()->void{ screenHeight :i32: 450; a : u8 : 255; b : u8 : 0; - white :: color(a,a,a,a); - black :u32= 0xff000000; + WHITE :: color(a,a,a,a); + BLACK :: color(@cast(0xff0000ff,u32)); InitWindow(screenWidth,screenHeight,str); + rect_posx :i32= 0; + rect_posy :i32= 0; while !WindowShouldClose() { BeginDrawing(); - ClearBackground(white); - DrawText(str2,@cast(190,i32),@cast(200,i32),@cast(20,i32),black); + ClearBackground(WHITE); + DrawRectangle(rect_posx,rect_posy,@cast(200,i32),@cast(40,i32),color(@cast(0x00ffff,u32))); + DrawText(str2,@cast(190,i32),@cast(200,i32),@cast(20,i32),BLACK); EndDrawing(); + /* + rect_posx += @cast(1,i32); + rect_posy += @cast(1,i32); + */ } CloseWindow(); }; @@ -51,3 +62,12 @@ color :: (a:u8,r:u8,g:u8,b:u8)->Color{ c.a = a; return c; }; + +color :: (value:u32)->Color{ + c : Color = undefined; + c.r = @cast((value&@cast(0xff000000,u32))>>@cast(6*4,u32),u8); + c.g = @cast((value&@cast(0x00ff0000,u32))>>@cast(4*4,u32),u8); + c.b = @cast((value&@cast(0x0000ff00,u32))>>@cast(2*4,u32),u8); + c.a = @cast((value&@cast(0x000000ff,u32))>>@cast(0*4,u32),u8); + return c; +}; -- cgit v1.2.3