vulkan_test2

view src/main.c @ 13:d34f84bede17

pipeline madness
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 25 Jun 2018 08:00:57 +0300
parents 20eb42197ab8
children 196122a2b8c2
line source
1 #include <stdio.h>
2 #include "wsys.h"
3 #include "vku.h"
4 #include "vkpipe.h"
5 #include "vkgl.h"
7 static void display(void);
8 static void reshape(int x, int y);
9 static void keyboard(int key, int pressed);
11 static struct vku_pipeline pipeline;
12 static VkShaderModule vsdr, psdr;
14 int main(void)
15 {
16 if(vku_create_dev() == -1) {
17 return 1;
18 }
20 if(wsys_create_window(800, 600) == -1) {
21 return 1;
22 }
23 wsys_set_window_title("Vulkan test 2");
25 wsys_display_callback(display);
26 wsys_reshape_callback(reshape);
27 wsys_keyboard_callback(keyboard);
29 wsys_process_events(WSYS_NONBLOCK);
31 if(!(vsdr = vku_load_shader("sdr/vertex.spv")) ||
32 !(psdr = vku_load_shader("sdr/pixel.spv"))) {
33 return 1;
34 }
36 vku_init_pipeline(&pipeline);
37 vku_pipeline_shader(&pipeline, vsdr, VK_SHADER_STAGE_VERTEX_BIT);
38 vku_pipeline_shader(&pipeline, psdr, VK_SHADER_STAGE_FRAGMENT_BIT);
39 vku_pipeline_viewport(&pipeline, 0, 0, 800, 600);
40 vku_pipeline_renderpass(&pipeline, vkrpass);
41 if(!vku_create_pipeline(&pipeline)) {
42 return 1;
43 }
46 while(wsys_process_events(WSYS_BLOCKING) != -1);
48 wsys_destroy_window();
49 vku_cleanup();
50 return 0;
51 }
53 static void display(void)
54 {
55 vkgl_clear_color(1, 0, 0, 1);
56 vkgl_clear(VKGL_COLOR_BUFFER_BIT);
58 wsys_swap_buffers();
59 }
61 static void reshape(int x, int y)
62 {
63 }
65 static void keyboard(int key, int pressed)
66 {
67 if(key == 27) {
68 wsys_quit();
69 }
70 }