-(right + left) / (right - left), -(top + bottom) / (top - bottom), -(far + near) / (far - near), 1,
};
+ glViewport(0, 0, width, height);
glUniformMatrix4fv(ir->simple_shader.view_uniform, 1, false, camera_matrix);
}
\ No newline at end of file
#define HEARTBREAK_MODULE_NAME system
+static void __glfw_window_size_callback(GLFWwindow *w, i32 new_width, i32 new_height) {
+ gfx_immediate_renderer_update_window_size(&renderer, (f32) new_width, (f32) new_height);
+}
+
HEARTBREAK_DEF(init, (), (WASM_I32)) {
if (!glfwInit()) {
bh_printf("Failed to initialize GLFW.\n");
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwMakeContextCurrent(glfw_window);
+ glfwSetWindowSizeCallback(glfw_window, __glfw_window_size_callback);
glfwSwapInterval(1);
i32 width, height;
glfwGetWindowSize(glfw_window, &width, &height);
- glViewport(0, 0, width, height);
gfx_immediate_renderer_update_window_size(&renderer, (f32) width, (f32) height);
results->data[0] = WASM_I32_VAL(1);
}
draw :: () {
- hb.graphics.setClearColor(math.sin(t), 0, math.cos(t), 1);
+ hb.graphics.setClearColor(0.1, 0.1, 0.1, 1);
hb.graphics.clear();
hb.graphics.setColor(0, 1, 0);
hb.graphics.rectangle(.Fill, 0, 0, 100, 100);
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);
+
+ w := cast(f32) hb.window.getWidth();
+ h := cast(f32) hb.window.getHeight();
hb.graphics.setColor(1, 1, 1);
- hb.graphics.rectangle(.Fill, 700, 500, 100, 100);
+ hb.graphics.rectangle(.Fill, w - 100, h - 100, 100, 100);
}
main :: (_) => hb.run(.{ init, update, draw });
\ No newline at end of file