Change Color struct in example
Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
parent
81b0c139ef
commit
3dbe9b6915
5
.gitignore
vendored
5
.gitignore
vendored
@ -4,4 +4,7 @@ speedcat.pdb
|
||||
test.exe
|
||||
hello.ll
|
||||
*.ll
|
||||
*.exe
|
||||
*.exe
|
||||
*.dSYM
|
||||
.DS_Store
|
||||
raylib
|
||||
|
4
build_test.sh
Executable file
4
build_test.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
odin run src -o:none -debug -out:speedcat '-extra-linker-flags:-L/opt/homebrew/opt/llvm/lib' -- test_type_checker.cat
|
||||
clang -I/opt/homebrew/include /opt/homebrew/lib/libraylib.a -lm -framework Cocoa -framework OpenGL -framework IOKit test_type_checker.ll test.c -o raylib
|
25
test.c
25
test.c
@ -1,7 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int32_t meow(int32_t x) {
|
||||
printf("%d\n", x);
|
||||
return 500;
|
||||
void ClearBackground(uint64_t rgba);
|
||||
void ClearBackgroundWrap(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
||||
ClearBackground((uint64_t)r << 24 | (uint64_t)g << 16 | (uint64_t)b << 8 |
|
||||
(uint64_t)a);
|
||||
}
|
||||
|
||||
void DrawRectangle(uint32_t x, uint32_t y, uint32_t width, uint32_t height,
|
||||
uint64_t rgba);
|
||||
void DrawRectangleWrap(uint32_t x, uint32_t y, uint32_t width, uint32_t height,
|
||||
uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
||||
DrawRectangle(x, y, width, height,
|
||||
(uint64_t)r << 24 | (uint64_t)g << 16 | (uint64_t)b << 8 |
|
||||
(uint64_t)a);
|
||||
}
|
||||
|
||||
void DrawCircle(uint32_t x, uint32_t y, float radius, uint64_t rgba);
|
||||
void DrawCircleWrap(uint32_t x, uint32_t y, float radius, uint8_t r, uint8_t g,
|
||||
uint8_t b, uint8_t a) {
|
||||
DrawCircle(x, y, radius,
|
||||
(uint64_t)r << 24 | (uint64_t)g << 16 | (uint64_t)b << 8 |
|
||||
(uint64_t)a);
|
||||
}
|
||||
|
@ -40,31 +40,31 @@
|
||||
\
|
||||
\(meow (add 60 9)) -> meow
|
||||
|
||||
struct Color "packed" {
|
||||
r g b a: u8,
|
||||
struct Color {
|
||||
a b g r: u8,
|
||||
}
|
||||
|
||||
fn InitWindow(w h: i32, title: i32)
|
||||
fn CloseWindow
|
||||
fn ClearBackground(c: Color)
|
||||
fn ClearBackgroundWrap(c: Color)
|
||||
fn BeginDrawing
|
||||
fn EndDrawing
|
||||
fn DrawFPS(x y: i32)
|
||||
fn DrawRectangle(x y w h: i32, c: Color)
|
||||
fn DrawCircle(x y: i32, r: f32, c: Color)
|
||||
fn DrawRectangleWrap(x y w h: i32, c: Color)
|
||||
fn DrawCircleWrap(x y: i32, r: f32, c: Color)
|
||||
fn WindowShouldClose i32
|
||||
|
||||
let white :: .Color{255 255 255 255}
|
||||
let white :: .Color{255 69 69 69}
|
||||
let red :: .Color{255 0 0 255}
|
||||
let blue :: .Color{0 0 255 255}
|
||||
let blue :: .Color{255 0 255 255}
|
||||
|
||||
InitWindow 640 480 0
|
||||
for WindowShouldClose == 0 {
|
||||
BeginDrawing
|
||||
ClearBackground white
|
||||
ClearBackgroundWrap white
|
||||
DrawFPS 20 20
|
||||
\DrawRectangle 80 80 100 200 red
|
||||
\DrawCircle 90 90 100.0 blue
|
||||
DrawRectangleWrap 80 80 100 200 red
|
||||
DrawCircleWrap 200 200 100.0 blue
|
||||
EndDrawing
|
||||
}
|
||||
CloseWindow
|
||||
|
Loading…
x
Reference in New Issue
Block a user