}
font_make :: (fd: FontDescriptor) -> Font {
- texture_size :: 512;
+ texture_size :: 256;
char_data := memory.make_slice(stbtt_packedchar, 96);
font_print :: (font: Font, x, y: f32, format: str, va: ..any) {
buf: [1024] u8;
- msg := conv.str_format_va(buf, format, va);
+ msg := conv.format_va(buf, format, va);
font_draw(font, x, y, msg);
}
world = world_make();
__initialize(^camera);
- camera.position = .{5,5,5};
+ camera.position = .{0,0,0};
camera_set_fov(^camera, 75);
ww, wh: i32;
glfwGetWindowSize(window, ^ww, ^wh);
}
draw :: () {
- // glClearColor(.7, .7, .9, 1);
- glClearColor(0.1, 0.1, 0.1, 1);
+ glClearColor(.7, .7, .9, 1);
+ // glClearColor(0.1, 0.1, 0.1, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shader_use(world_shader);
-Vector2 :: struct {
+Vector2 :: struct [conv.Custom_Format.{format_vector2}] {
x, y: f32;
}
-Vector3i :: struct {
+Vector3i :: struct [conv.Custom_Format.{format_vector3i}] {
x, y, z: i32;
}
-Vector3 :: struct {
+Vector3 :: struct [conv.Custom_Format.{format_vector3}] {
x, y, z: f32;
mag :: macro (v: Vector3) => math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
#operator + macro (v1, v2: Vector3) => Vector3.{ v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };
#operator - macro (v1, v2: Vector3) => Vector3.{ v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };
#operator * macro (v: Vector3, s: f32) => Vector3.{ v.x * s, v.y * s, v.z * s };
+
+#local {
+ conv :: package core.conv
+
+ format_vector2 :: (output: ^conv.Format_Output, format: ^conv.Format, v: ^Vector2) {
+ output->write("(");
+ conv.format_any(output, format, .{^v.x, f32});
+ output->write(", ");
+ conv.format_any(output, format, .{^v.y, f32});
+ output->write(")");
+ }
+
+ format_vector3 :: (output: ^conv.Format_Output, format: ^conv.Format, v: ^Vector3) {
+ output->write("(");
+ conv.format_any(output, format, .{^v.x, f32});
+ output->write(", ");
+ conv.format_any(output, format, .{^v.y, f32});
+ output->write(", ");
+ conv.format_any(output, format, .{^v.z, f32});
+ output->write(")");
+ }
+
+ format_vector3i :: (output: ^conv.Format_Output, format: ^conv.Format, v: ^Vector3i) {
+ output->write("(");
+ conv.format_any(output, format, .{^v.x, i32});
+ output->write(", ");
+ conv.format_any(output, format, .{^v.y, i32});
+ output->write(", ");
+ conv.format_any(output, format, .{^v.z, i32});
+ output->write(")");
+ }
+}
\ No newline at end of file