54 lines
956 B
Odin
54 lines
956 B
Odin
package debug
|
|
|
|
import rl "vendor:raylib"
|
|
import "vendor:raylib/rlgl"
|
|
|
|
int_to_color :: proc(num: i32) -> (color: rl.Color) {
|
|
x := int_hash(num)
|
|
|
|
color.r = u8(x % 256)
|
|
color.g = u8((x / 256) % 256)
|
|
color.b = u8((x / 256 / 256) % 256)
|
|
color.a = 255
|
|
return
|
|
}
|
|
|
|
int_hash :: proc(num: i32) -> u32 {
|
|
x := cast(u32)num
|
|
|
|
x = ((x >> 16) ~ x) * 0x45d9f3b
|
|
x = ((x >> 16) ~ x) * 0x45d9f3b
|
|
x = (x >> 16) ~ x
|
|
|
|
return x
|
|
}
|
|
|
|
rlgl_color :: proc(color: rl.Color) {
|
|
rlgl.Color4ub(color.r, color.g, color.b, color.a)
|
|
}
|
|
|
|
rlgl_color3v :: proc(v: rl.Vector3) {
|
|
rlgl.Color3f(v.r, v.g, v.b)
|
|
}
|
|
|
|
rlgl_vertex3v :: proc(v: rl.Vector3) {
|
|
rlgl.Vertex3f(v.x, v.y, v.z)
|
|
}
|
|
|
|
rlgl_vertex3v2 :: proc(v1, v2: rl.Vector3) {
|
|
rlgl_vertex3v(v1)
|
|
rlgl_vertex3v(v2)
|
|
}
|
|
|
|
@(deferred_none = rlgl_transform_scope_end)
|
|
rlgl_transform_scope :: proc(mat: rl.Matrix) {
|
|
mat := mat
|
|
rlgl.PushMatrix()
|
|
|
|
rlgl.MultMatrixf(cast([^]f32)&mat)
|
|
}
|
|
|
|
rlgl_transform_scope_end :: proc() {
|
|
rlgl.PopMatrix()
|
|
}
|