aboutsummaryrefslogtreecommitdiff
path: root/src/draw.odin
diff options
context:
space:
mode:
authoriamcheeseman <[hidden email]>2026-02-03 22:25:00 -0500
committeriamcheeseman <[hidden email]>2026-02-03 22:25:00 -0500
commit3d1d31538d30a7f161f9f2b6d5e075ec69d3b860 (patch)
tree8b0deceb38c288dbef361bb4f77bb681b5566525 /src/draw.odin
parent1c605da3ff8dc4295d2f9a85f5b7c8891ca84464 (diff)
ditch raylib (icky, and for loser BEGINNERS)
Diffstat (limited to 'src/draw.odin')
-rw-r--r--src/draw.odin151
1 files changed, 0 insertions, 151 deletions
diff --git a/src/draw.odin b/src/draw.odin
deleted file mode 100644
index 0c21c80..0000000
--- a/src/draw.odin
+++ /dev/null
@@ -1,151 +0,0 @@
-package demonchime
-
-import "core:c"
-import "core:math"
-import "core:math/linalg"
-
-import rl "vendor:raylib"
-import rlgl "vendor:raylib/rlgl"
-
-Color :: [4]f32
-
-SCREEN_WIDTH :: 320
-SCREEN_HEIGHT :: 320
-SCREEN_SIZE :: Vec2{SCREEN_WIDTH, SCREEN_HEIGHT}
-
-// @(default_calling_convention = "c")
-// foreign lib {
-// DrawTexturePoly :: proc(texture: rl.Texture2D, center: rl.Vector2, points: [^]rl.Vector2, textcoords: [^]rl.Vector2, point_count: c.int, color: Color) --- // Draw a regular polygon (Vector version)
-// }
-
-renderer: struct {
- screen: rl.RenderTexture2D,
- tint: Color,
-}
-
-@(private = "file")
-_color_to_rl :: proc(col: Color) -> rl.Color {
- return rl.Color {
- u8(col.r * 255),
- u8(col.g * 255),
- u8(col.b * 255),
- u8(col.a * 255),
- }
-}
-
-init_draw :: proc() {
- renderer.screen = rl.LoadRenderTexture(SCREEN_WIDTH, SCREEN_HEIGHT)
- renderer.tint = Color{1, 1, 1, 1}
-}
-
-deinit_draw :: proc() {
- rl.UnloadRenderTexture(renderer.screen)
-}
-
-draw_new_frame :: proc() {
- rl.BeginTextureMode(renderer.screen)
- rl.ClearBackground(rl.BLACK)
- // rl.ClearBackground(rl.GRAY)
-}
-
-draw_end_frame :: proc() {
- rl.EndTextureMode()
-
- rl.BeginDrawing()
- {
- rl.ClearBackground(_color_to_rl(Color{0, 0, 0, 1}))
- scale := math.min(
- f32(rl.GetScreenWidth()) / f32(SCREEN_WIDTH),
- f32(rl.GetScreenHeight()) / f32(SCREEN_HEIGHT),
- )
- screen_start := Vec2 {
- (f32(rl.GetScreenWidth()) - (SCREEN_WIDTH * scale)) / 2,
- (f32(rl.GetScreenHeight()) - (SCREEN_HEIGHT * scale)) / 2,
- }
-
- draw_texture(
- renderer.screen.texture,
- screen_start,
- scale = Vec2{scale, -scale},
- )
- }
- rl.EndDrawing()
-}
-
-draw_circle :: proc(pos: Vec2, rad: f32) {
- rl.DrawCircle(i32(pos.x), i32(pos.y), rad, _color_to_rl(renderer.tint))
-}
-
-draw_rect :: proc(rect: Rect) {
- assert(rect.size.x > 0 && rect.size.y > 0)
-
- rl.DrawRectangle(
- c.int(rect.start.x),
- c.int(rect.start.y),
- c.int(rect.size.x),
- c.int(rect.size.y),
- _color_to_rl(renderer.tint),
- )
-}
-
-draw_linerect :: proc(rect: Rect) {
- assert(rect.size.x > 0 && rect.size.y > 0)
-
- rl.DrawRectangleLines(
- c.int(rect.start.x),
- c.int(rect.start.y),
- c.int(rect.size.x),
- c.int(rect.size.y),
- _color_to_rl(renderer.tint),
- )
-}
-
-draw_texture :: proc {
- draw_texture_full,
- draw_texture_quad,
-}
-
-draw_texture_quad :: proc(
- img: rl.Texture2D,
- quad: Rect,
- position: Vec2,
- offset := Vec2{0, 0},
- rotation: f32 = 0,
- scale := Vec2{1, 1},
-) {
- quad := quad
- if scale.x < 0 {
- quad.size.x *= -1
- }
- if scale.y < 0 {
- quad.size.y *= -1
- }
-
- position := linalg.round(position)
-
- rl.DrawTexturePro(
- img,
- transmute(rl.Rectangle)quad,
- rl.Rectangle {
- position.x,
- position.y,
- quad.size.x * scale.x,
- quad.size.y * scale.y,
- },
- offset,
- math.round(rotation / 5) * 5,
- _color_to_rl(renderer.tint),
- )
-}
-
-draw_texture_full :: proc(
- img: rl.Texture2D,
- position: Vec2,
- offset := Vec2{0, 0},
- rotation: f32 = 0,
- scale := Vec2{1, 1},
-) {
- size := Vec2{f32(img.width), f32(img.height)}
-
- draw_texture_quad(img, Rect{Vec2{0, 0}, size}, position, offset, rotation, scale)
-}