Release v0.0.1a
Additions:
+* graphics_circle(FillMode mode, f32 x, f32 y, f32 r, i32 segments)
+* graphics_clear()
+* graphics_rectangle(FillMode mode, f32 x, f32 y, f32 w, f32 h)
+* graphics_set_color(f32 r, f32 g, f32 b, f32 a)
+* graphics_set_clear_color(f32 r, f32 g, f32 b, f32 a)
+* input_key_is_down(KeyConstant key) -> bool
+* input_mouse_get_x() -> i32
+* input_mouse_get_y() -> i32
+* input_mouse_is_down(ButtonConstant button) -> bool
+* system_destroy()
+* system_end_frame() -> bool
+* system_init()
+* window_get_height() -> i32
+* window_get_width() -> i32
+* window_set_dimensions(i32 width, i32 height) -> i32
+* window_set_should_close(bool close)
Removals:
CC=gcc
WARNINGS=-Wimplicit -Wmisleading-indentation -Wparentheses -Wsequence-point -Wreturn-type -Wshift-negative-value -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-function -Wunused-label -Wmaybe-uninitialized -Wsign-compare -Wstrict-overflow -Wduplicated-branches -Wduplicated-cond -Wtrigraphs -Waddress -Wlogical-op
-FLAGS=$(WARNINGS) -g3
+FLAGS=$(WARNINGS) -g3 -O2
INCLUDES=-I./include -I./lib/linux_x86_64/include
LIBS=-L./lib/linux_x86_64/lib -lwasmer -Wl,-rpath=./lib/linux_x86_64/lib -lglfw -lGL -lm
--- /dev/null
+# Heartbreak API Reference
+
+This document describes all functions that are available to the WebAssembly program to
+interact with Heartbreak. All functions are under the WebAssembly Module named "heartbreak".
+Below only lists the _name_ of the function.
+
+`graphics` module
+* `graphics_circle(FillMode mode, f32 x, f32 y, f32 r, i32 segments)`
+* `graphics_clear()`
+* `graphics_rectangle(FillMode mode, f32 x, f32 y, f32 w, f32 h)`
+* `graphics_set_color(f32 r, f32 g, f32 b, f32 a)`
+* `graphics_set_clear_color(f32 r, f32 g, f32 b, f32 a)`
+
+`input` module
+* `input_key_is_down(KeyConstant key) -> bool`
+* `input_mouse_get_x() -> i32`
+* `input_mouse_get_y() -> i32`
+* `input_mouse_is_down(ButtonConstant button) -> bool`
+
+`system` module
+* `system_destroy()`
+* `system_end_frame() -> bool`
+* `system_init()`
+
+`window` module
+* `window_get_height() -> i32`
+* `window_get_width() -> i32`
+* `window_set_dimensions(i32 width, i32 height) -> i32`
+* `window_set_should_close(bool close)`
+
+
+
+
+
+
setColor :: (r, g, b: f32, a: f32 = 1) -> void #foreign "heartbreak" "graphics_set_color" ---
rectangle :: (mode: FillMode, x, y, w, h: f32) -> void #foreign "heartbreak" "graphics_rectangle" ---
+circle :: (mode: FillMode, x, y, r: f32, segments: i32 = 24) -> void #foreign "heartbreak" "graphics_circle" ---
\ No newline at end of file
}
keyIsDown :: (key: KeyConstant) -> bool #foreign "heartbreak" "input_key_is_down" ---
+
mouseGetX :: () -> i32 #foreign "heartbreak" "input_mouse_get_x" ---
mouseGetY :: () -> i32 #foreign "heartbreak" "input_mouse_get_y" ---
+mouseGetPos :: () => mouseGetX(), mouseGetY();
+
mouseIsDown :: (button: ButtonConstant) -> bool #foreign "heartbreak" "input_mouse_is_down" ---
--- /dev/null
+// 'Quick Heartbreak'
+// Include this to quickly get access to Heartbreak in your Onyx program.
+
+package main
+
+#load "core/std"
+#load "./heartbreak"
+
+#private hb :: package heartbreak
+
+#if !#defined((package main).init) {
+ init :: () {}
+}
+
+#if !#defined((package main).update) {
+ update :: (dt: f32) {}
+}
+
+#if !#defined((package main).draw) {
+ draw :: () {}
+}
+
+main :: (_) => hb.run(.{ init, update, draw });
\ No newline at end of file
#include "heartbreak.h"
#include "gfx.h"
+#include <math.h>
+#define PI 3.14159365
+
static f32 clear_r, clear_g, clear_b, clear_a;
HEARTBREAK_DEF(set_clear_color, (WASM_F32,WASM_F32,WASM_F32,WASM_F32), ()) {
}
HEARTBREAK_DEF(rectangle, (WASM_I32,WASM_F32,WASM_F32,WASM_F32,WASM_F32), ()) {
+ // @TODO: Use fill mode
+
f32 x = params->data[1].of.f32;
f32 y = params->data[2].of.f32;
f32 w = params->data[3].of.f32;
return NULL;
}
+HEARTBREAK_DEF(circle, (WASM_I32, WASM_F32, WASM_F32, WASM_F32, WASM_I32), ()) {
+ // @TODO: Use fill mode
+
+ f32 x = params->data[1].of.f32;
+ f32 y = params->data[2].of.f32;
+ f32 r = params->data[3].of.f32;
+ i32 segments = params->data[4].of.i32;
+
+ f32 cx1 = x + r;
+ f32 cy1 = y;
+ f32 cx2 = x + cos(PI * 2 / segments) * r;
+ f32 cy2 = y + sin(PI * 2 / segments) * r;
+ f32 cx3, cy3;
+
+ fori (i, 2, segments) {
+ cx3 = x + cos(i * PI * 2 / segments) * r;
+ cy3 = y + sin(i * PI * 2 / segments) * r;
+
+ gfx_immediate_renderer_push_triangle(&renderer,
+ cx1, cy1, 0, 0,
+ cx2, cy2, 0, 0,
+ cx3, cy3, 0, 0);
+
+ cx2 = cx3;
+ cy2 = cy3;
+ }
+
+ return NULL;
+}
+
HEARTBREAK_MODULE {
HEARTBREAK_FUNC(set_clear_color)
HEARTBREAK_FUNC(clear)
HEARTBREAK_FUNC(set_color)
HEARTBREAK_FUNC(rectangle)
+ HEARTBREAK_FUNC(circle)
{ NULL }
};
\ No newline at end of file
glfwSetWindowSizeCallback(glfw_window, __glfw_window_size_callback);
glfwSwapInterval(1);
+ // glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
gfx_immediate_renderer_init(&renderer);
-#load "core/std"
-#load "./../misc/onyx/heartbreak"
+#load "./../misc/onyx/qhb"
use package core
-hb :: package heartbreak
init :: () {
w := hb.window.getWidth();
hb.graphics.setColor(1, 1, 0);
hb.graphics.rectangle(.Fill, 100, 100, 200, 100);
- mx := hb.input.mouseGetX();
- my := hb.input.mouseGetY();
- hb.graphics.rectangle(.Fill, ~~mx, ~~my, 100, 100);
+ mx, my := hb.input.mouseGetPos();
+ hb.graphics.setColor(1, 0, 0);
+ hb.graphics.circle(.Fill, ~~mx, ~~my, 25);
w := cast(f32) hb.window.getWidth();
h := cast(f32) hb.window.getHeight();
hb.graphics.setColor(1, 1, 1);
hb.graphics.rectangle(.Fill, w - 100, h - 100, 100, 100);
-}
-
-main :: (_) => hb.run(.{ init, update, draw });
\ No newline at end of file
+}
\ No newline at end of file