|
|
@ -32,50 +32,103 @@ VkResult render_thread(GLFWwindow* window, RenderContext* render) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(load_font("test.ttf", 16, VK_TRUE, library, render, &ui, &font_index));
|
|
|
|
VK_RESULT(load_font("test.ttf", 16, VK_TRUE, library, render, &ui, &font_index));
|
|
|
|
VK_RESULT(load_texture("background.png", render, &ui, &background_index));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIDrawable rects[] = {
|
|
|
|
vec2 map_size = {250, 200};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIDrawable map_rects[] = {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.pos = {0.0, 0.0},
|
|
|
|
.pos = {0.0, 0.0},
|
|
|
|
.size = {WINDOW_WIDTH, WINDOW_HEIGHT},
|
|
|
|
.size = {map_size[0], map_size[1]},
|
|
|
|
.color = {1.0, 1.0, 1.0, 1.0},
|
|
|
|
.color = {0.0, 0.5, 0.8, 1.0},
|
|
|
|
.type = 2,
|
|
|
|
.type = 0,
|
|
|
|
.code = background_index,
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UILayerInput map_layers[] = {
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
.num_drawables = sizeof(map_rects)/sizeof(UIDrawable),
|
|
|
|
|
|
|
|
.drawables = map_rects,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIContainerInput map_info = {
|
|
|
|
|
|
|
|
.id = 0x01,
|
|
|
|
|
|
|
|
.offset = {WINDOW_WIDTH-map_size[0], 0.0},
|
|
|
|
|
|
|
|
.size = {map_size[0], map_size[1]},
|
|
|
|
|
|
|
|
.layer_count = sizeof(map_layers)/sizeof(UILayerInput),
|
|
|
|
|
|
|
|
.layers = map_layers,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vec2 inventory_size = {map_size[0], WINDOW_HEIGHT-map_size[1]};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIDrawable inventory_rects[] = {
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
.pos = {0, 0},
|
|
|
|
|
|
|
|
.size = {inventory_size[0], inventory_size[1]},
|
|
|
|
|
|
|
|
.color = {0.5, 0.8, 0.0, 1.0},
|
|
|
|
|
|
|
|
.type = 0,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UILayerInput inventory_layers[] = {
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
.num_drawables = sizeof(inventory_rects)/sizeof(UIDrawable),
|
|
|
|
|
|
|
|
.drawables = inventory_rects,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIContainerInput inventory_info = {
|
|
|
|
|
|
|
|
.id = 0x02,
|
|
|
|
|
|
|
|
.offset = {WINDOW_WIDTH-inventory_size[0], WINDOW_HEIGHT-inventory_size[1]},
|
|
|
|
|
|
|
|
.size = {inventory_size[0], inventory_size[1]},
|
|
|
|
|
|
|
|
.layer_count = sizeof(inventory_layers)/sizeof(UILayerInput),
|
|
|
|
|
|
|
|
.layers = inventory_layers,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vec2 chat_size = {WINDOW_WIDTH-inventory_size[0], 200};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIDrawable chat_rects[] = {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.pos = {150.0, 100.0},
|
|
|
|
.pos = {0, 0},
|
|
|
|
.size = {500.0, 300.0},
|
|
|
|
.size = {chat_size[0], chat_size[1]},
|
|
|
|
.color = {1.0, 1.0, 1.0, 1.0},
|
|
|
|
.color = {0.8, 0.0, 0.5, 1.0},
|
|
|
|
|
|
|
|
.type = 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
UILayerInput layers[] = {
|
|
|
|
UILayerInput chat_layers[] = {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
.num_drawables = sizeof(rects)/sizeof(UIDrawable),
|
|
|
|
.num_drawables = sizeof(chat_rects)/sizeof(UIDrawable),
|
|
|
|
.drawables = rects,
|
|
|
|
.drawables = chat_rects,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
UIContainerInput container_info = {
|
|
|
|
UIContainerInput chat_info = {
|
|
|
|
.id = 0xDEADBEEF,
|
|
|
|
.id = 0x02,
|
|
|
|
.pos = {0.0, 0.0},
|
|
|
|
.offset = {0, WINDOW_HEIGHT-chat_size[1]},
|
|
|
|
.size = {WINDOW_WIDTH, WINDOW_HEIGHT},
|
|
|
|
.size = {chat_size[0], chat_size[1]},
|
|
|
|
.layer_count = sizeof(layers)/sizeof(UILayerInput),
|
|
|
|
.layer_count = sizeof(chat_layers)/sizeof(UILayerInput),
|
|
|
|
.layers = layers,
|
|
|
|
.layers = chat_layers,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_container(&container_info, render, &ui));
|
|
|
|
VK_RESULT(create_container(&map_info, render, &ui));
|
|
|
|
|
|
|
|
VK_RESULT(create_container(&inventory_info, render, &ui));
|
|
|
|
|
|
|
|
VK_RESULT(create_container(&chat_info, render, &ui));
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(record_draw_commands(render, &ui));
|
|
|
|
VK_RESULT(record_draw_commands(render, &ui));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double last_frame_time = glfwGetTime();
|
|
|
|
while(glfwWindowShouldClose(window) == 0) {
|
|
|
|
while(glfwWindowShouldClose(window) == 0) {
|
|
|
|
glfwPollEvents();
|
|
|
|
glfwPollEvents();
|
|
|
|
|
|
|
|
|
|
|
|
result = draw_frame(render);
|
|
|
|
double frame_time = glfwGetTime();
|
|
|
|
|
|
|
|
double delta_time = frame_time - last_frame_time;
|
|
|
|
|
|
|
|
result = draw_frame(render, frame_time);
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
fprintf(stderr, "draw_frame error: %s\n", string_VkResult(result));
|
|
|
|
fprintf(stderr, "draw_frame error: %s\n", string_VkResult(result));
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
last_frame_time = frame_time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -88,12 +141,47 @@ int network_thread() {
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) {
|
|
|
|
|
|
|
|
switch(button) {
|
|
|
|
|
|
|
|
// Handle camera hover
|
|
|
|
|
|
|
|
case GLFW_MOUSE_BUTTON_MIDDLE:
|
|
|
|
|
|
|
|
if(action == GLFW_PRESS) {
|
|
|
|
|
|
|
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GLFW_MOUSE_BUTTON_LEFT:
|
|
|
|
|
|
|
|
if(action == GLFW_PRESS) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GLFW_MOUSE_BUTTON_RIGHT:
|
|
|
|
|
|
|
|
if(action == GLFW_PRESS) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cursor_pos_callback(GLFWwindow* window, double xpos, double ypos) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
int main() {
|
|
|
|
GLFWwindow* window = init_window();
|
|
|
|
GLFWwindow* window = init_window();
|
|
|
|
if(window == NULL) {
|
|
|
|
if(window == NULL) {
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glfwSetKeyCallback(window, key_callback);
|
|
|
|
|
|
|
|
glfwSetMouseButtonCallback(window, mouse_button_callback);
|
|
|
|
|
|
|
|
glfwSetScrollCallback(window, scroll_callback);
|
|
|
|
|
|
|
|
glfwSetCursorPosCallback(window, cursor_pos_callback);
|
|
|
|
|
|
|
|
|
|
|
|
RenderContext render = {};
|
|
|
|
RenderContext render = {};
|
|
|
|
if(init_vulkan(window, &render) != VK_SUCCESS) {
|
|
|
|
if(init_vulkan(window, &render) != VK_SUCCESS) {
|
|
|
|
return 2;
|
|
|
|
return 2;
|
|
|
|