summaryrefslogtreecommitdiff
path: root/include/vlkn.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/vlkn.h')
-rw-r--r--include/vlkn.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/include/vlkn.h b/include/vlkn.h
new file mode 100644
index 0000000..a03ca9f
--- /dev/null
+++ b/include/vlkn.h
@@ -0,0 +1,75 @@
+#ifndef _VLKN_H_
+#define _VLKN_H_
+
+#include <vulkan/vulkan.h>
+#include <stdbool.h>
+
+struct vlkn_window;
+struct vlkn_renderer;
+struct vlkn_pipeline;
+
+struct vlkn_buffer {
+ VkBuffer buffer;
+ VkDeviceSize size;
+ VkDeviceMemory memory;
+};
+
+struct vec3 {
+ float x, y, z;
+};
+
+struct vec4 {
+ float x, y, z, w;
+};
+
+struct vlkn_vertex {
+ struct vec3 position;
+ struct vec3 normal;
+ struct vec4 color;
+};
+
+struct vlkn_mesh {
+ struct vlkn_buffer vertex;
+ struct vlkn_buffer index;
+ size_t index_count;
+ struct vec3 position;
+};
+
+struct vlkn_window *vlkn_window_init(const char *title);
+void vlkn_window_destroy(struct vlkn_window *win);
+
+struct vlkn_renderer *vlkn_renderer_init(struct vlkn_window *win);
+void vlkn_renderer_destroy(struct vlkn_renderer *renderer);
+void vlkn_render(struct vlkn_renderer *renderer);
+void vlkn_draw(struct vlkn_renderer *renderer, struct vlkn_pipeline *pipeline,
+ size_t mesh_len, struct vlkn_mesh meshes[mesh_len]);
+void vlkn_present(struct vlkn_renderer *renderer);
+
+struct vlkn_shader {
+ VkShaderStageFlagBits stages;
+ VkShaderModule module;
+};
+
+// TODO: error enum
+bool vlkn_shader_load(struct vlkn_renderer *renderer,
+ const char *path, VkShaderStageFlagBits stage, struct vlkn_shader *shader);
+void vlkn_shader_unload(struct vlkn_renderer *renderer, struct vlkn_shader *shader);
+
+struct vlkn_pipeline_opts {
+ size_t shader_len;
+ struct vlkn_shader *shaders;
+ size_t attrs_len;
+ VkVertexInputAttributeDescription *attrs;
+ VkVertexInputBindingDescription attrs_desc;
+ size_t descriptors_len;
+ VkDescriptorSetLayoutBinding *descriptors;
+ size_t push_contant_len;
+ VkPushConstantRange *push_constants;
+};
+
+struct vlkn_pipeline *vlkn_pipeline_init(struct vlkn_renderer *renderer, struct vlkn_pipeline_opts *opts);
+
+struct vlkn_mesh vlkn_mesh_upload(struct vlkn_renderer *renderer, size_t vertex_count, struct vlkn_vertex vertices[vertex_count],
+ size_t index_count, uint32_t indices[index_count], struct vec3 position);
+
+#endif