wip zig orca bindings

This commit is contained in:
Reuben Dunnington 2023-09-15 23:16:52 -07:00
parent 5999429838
commit e06e735902
Signed by: rdunnington
GPG Key ID: 3D57C8938EA08E90
5 changed files with 977 additions and 167 deletions

View File

@ -0,0 +1,29 @@
T E P I D M O N K E Y F O N T S
freeware fonts for a freeware world
Site: http://www.tepidmonkey.com/
E-mail: brandon@tepidmonkey.com
Thanks for your interest in my fonts!
For help on how to unzip, unstuff or install one of my
fonts, please visit my site at
www.tepidmonkey.com and go to the Help section.
If you have any comments or questions, you can e-mail
me at brandon@tepidmonkey.com and I'll try to reply as
soon as possible.
Every week, I present a brand new original font for
your downloading pleasure, so be sure to visit my web
site every Sunday.
You may use this font(s) for non-commercial and
commercial purposes. You are not allowed to sell this
font for any fee at all. You are allowed to
redistribute it as long as you don't charge ANYTHING
for it (at all) and if you include this unaltered
Read Me file. You may not change any aspect of the font
file or this file.
For the full set of terms of use (which override what
is listed here), go to www.tepidmonkey.com
and visit the Terms section.

Binary file not shown.

Binary file not shown.

View File

@ -1,39 +1,50 @@
const std = @import("std");
const oc = @import("orca");
const Vec2 = oc.Vec2;
var surface: oc.Surface = undefined;
var canvas: oc.Canvas = undefined;
var counter: u32 = 0;
var lastSeconds: f64 = 0;
export fn oc_on_init() void {
oc.logInfo("platform: {}", .{oc.getHostPlatform()}, @src());
oc.windowSetTitle("zig calc");
oc.windowSetSize(oc.vec2{ .x = 480, .y = 640 });
oc.windowSetSize(Vec2{ .x = 480, .y = 640 });
oc.logInfo("current platform: {}", .{oc.getHostPlatform()}, @src());
surface = oc.Surface.canvas();
canvas = oc.Canvas.create();
oc.assert(oc.Canvas.nil().isNil() == true, "nil canvas should be nil", .{}, @src());
oc.assert(canvas.isNil() == false, "created canvas should not be nil", .{}, @src());
}
export fn oc_on_resize(width: u32, height: u32) void {
oc.logInfo("frame resize: {}, {}", .{ width, height }, @src());
}
export fn oc_on_mouse_down(button: c_int) void {
export fn oc_on_mouse_down(button: oc.MouseButton) void {
oc.logInfo("mouse down! {}", .{button}, @src());
}
export fn oc_on_mouse_up(button: c_int) void {
export fn oc_on_mouse_up(button: oc.MouseButton) void {
oc.logInfo("mouse up! {}", .{button}, @src());
}
export fn oc_on_key_down(key: c_int) void {
export fn oc_on_key_down(key: oc.KeyCode) void {
oc.logInfo("key down: {}", .{key}, @src());
}
export fn oc_on_key_up(key: c_int) void {
export fn oc_on_key_up(key: oc.KeyCode) void {
oc.logInfo("key up: {}", .{key}, @src());
switch (key) {
oc.KeyCodes.escape => oc.requestQuit(),
oc.KeyCodes.b => oc.abort("aborting", .{}, @src()),
oc.KeyCodes.a => oc.assert(false, "test assert failed", .{}, @src()),
oc.KeyCode.Escape => oc.requestQuit(),
oc.KeyCode.B => oc.abort("aborting", .{}, @src()),
oc.KeyCode.A => oc.assert(false, "test assert failed", .{}, @src()),
else => {},
}
}
@ -41,12 +52,48 @@ export fn oc_on_key_up(key: c_int) void {
export fn oc_on_frame_refresh() void {
counter += 1;
const secs: f64 = oc.clockTime(oc.Clock.Date);
const secs: f64 = oc.clockTime(oc.ClockKind.Date);
if (lastSeconds != @floor(secs)) {
lastSeconds = @floor(secs);
oc.logInfo("seconds since Jan 1, 1970: {d:.0}", .{secs}, @src());
}
_ = canvas.setCurrent();
surface.select();
oc.setColorRgba(0.05, 0.05, 0.05, 1.0);
oc.clear();
oc.setColorRgba(1.0, 0.05, 0.05, 1.0);
{
const translation: oc.Mat2x3 = .{ .m = [_]f32{ 1, 0, 50, 0, 1, 50 } };
oc.matrixPush(translation);
defer oc.matrixPop();
oc.assert(std.meta.eql(oc.matrixTop(), translation), "top of matrix stack should be what we pushed", .{}, @src());
oc.setWidth(1);
oc.rectangleFill(50, 50, 10, 10);
oc.rectangleStroke(70, 50, 10, 10);
oc.roundedRectangleFill(90, 50, 10, 10, 3);
oc.roundedRectangleStroke(110, 50, 10, 10, 3);
const green = oc.Color{ .Flat = .{ .r = 0.05, .g = 1, .b = 0.05, .a = 1 } };
oc.setColor(green);
oc.assert(std.meta.eql(oc.getColor().Flat, green.Flat), "color should be green", .{}, @src());
oc.setTolerance(1);
oc.setJoint(.Bevel);
oc.ellipseFill(140, 55, 10, 5);
oc.ellipseStroke(170, 55, 10, 5);
oc.circleFill(195, 55, 5);
oc.circleStroke(215, 55, 5);
oc.arc(230, 55, 5, 0, std.math.pi);
}
surface.render(canvas);
surface.present();
}
export fn oc_on_terminate() void {

File diff suppressed because it is too large Load Diff