summaryrefslogtreecommitdiff
path: root/src/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c
new file mode 100644
index 0000000..735036e
--- /dev/null
+++ b/src/command.c
@@ -0,0 +1,41 @@
+#include "rgl.h"
+
+void RGL_Rect(RGL_Context *ctx, unsigned int x, unsigned int y,
+ unsigned int width, unsigned int height) {
+ RGL_Command *rectCommand =
+ (RGL_Command *)RGL_ArenaAlloc(&ctx->queue.arena, sizeof(RGL_Command));
+
+ rectCommand->type = Rect;
+ rectCommand->data.rect.x = x;
+ rectCommand->data.rect.y = y;
+ rectCommand->data.rect.width = width;
+ rectCommand->data.rect.height = height;
+ rectCommand->data.rect.color = ctx->color;
+
+ ctx->queue.size += 1;
+}
+
+void RGL_BeginPath(RGL_Context *ctx, RGL_PathVerb verb) {
+ ctx->current =
+ (RGL_Command *)RGL_ArenaAlloc(&ctx->queue.arena, sizeof(RGL_Command));
+
+ ctx->current->type = Path;
+ ctx->current->data.path.color = ctx->color;
+ ctx->current->data.path.size = 0;
+ ctx->current->data.path.verb = verb;
+}
+
+void RGL_PathMoveTo(RGL_Context *ctx, int x, int y) {
+ RGL_Point *p =
+ (RGL_Point *)RGL_ArenaAlloc(&ctx->queue.arena, sizeof(RGL_Point));
+ p->x = RGL_GetFixedI(x);
+ p->y = RGL_GetFixedI(y);
+
+ ctx->current->data.path.size += 1;
+}
+
+void RGL_EndPath(RGL_Context *ctx) {
+ ctx->current->data.path.color = ctx->color;
+ ctx->current = 0;
+ ctx->queue.size += 1;
+}