|
|
|
@ -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_texture("background.png", render, &ui, &background_index));
|
|
|
|
|
|
|
|
|
|
UIDrawable rects[] = {
|
|
|
|
|
vec2 map_size = {250, 200};
|
|
|
|
|
|
|
|
|
|
UIDrawable map_rects[] = {
|
|
|
|
|
{
|
|
|
|
|
.pos = {0.0, 0.0},
|
|
|
|
|
.size = {WINDOW_WIDTH, WINDOW_HEIGHT},
|
|
|
|
|
.color = {1.0, 1.0, 1.0, 1.0},
|
|
|
|
|
.type = 2,
|
|
|
|
|
.code = background_index,
|
|
|
|
|
.size = {map_size[0], map_size[1]},
|
|
|
|
|
.color = {0.0, 0.5, 0.8, 1.0},
|
|
|
|
|
.type = 0,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
UILayerInput map_layers[] = {
|
|
|
|
|
{
|
|
|
|
|
.pos = {150.0, 100.0},
|
|
|
|
|
.size = {500.0, 300.0},
|
|
|
|
|
.color = {1.0, 1.0, 1.0, 1.0},
|
|
|
|
|
.num_drawables = sizeof(map_rects)/sizeof(UIDrawable),
|
|
|
|
|
.drawables = map_rects,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
UILayerInput layers[] = {
|
|
|
|
|
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[] = {
|
|
|
|
|
{
|
|
|
|
|
.num_drawables = sizeof(rects)/sizeof(UIDrawable),
|
|
|
|
|
.drawables = rects,
|
|
|
|
|
.pos = {0, 0},
|
|
|
|
|
.size = {inventory_size[0], inventory_size[1]},
|
|
|
|
|
.color = {0.5, 0.8, 0.0, 1.0},
|
|
|
|
|
.type = 0,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
UIContainerInput container_info = {
|
|
|
|
|
.id = 0xDEADBEEF,
|
|
|
|
|
.pos = {0.0, 0.0},
|
|
|
|
|
.size = {WINDOW_WIDTH, WINDOW_HEIGHT},
|
|
|
|
|
.layer_count = sizeof(layers)/sizeof(UILayerInput),
|
|
|
|
|
.layers = layers,
|
|
|
|
|
UILayerInput inventory_layers[] = {
|
|
|
|
|
{
|
|
|
|
|
.num_drawables = sizeof(inventory_rects)/sizeof(UIDrawable),
|
|
|
|
|
.drawables = inventory_rects,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_container(&container_info, render, &ui));
|
|
|
|
|
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 = {0, 0},
|
|
|
|
|
.size = {chat_size[0], chat_size[1]},
|
|
|
|
|
.color = {0.8, 0.0, 0.5, 1.0},
|
|
|
|
|
.type = 0,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
UILayerInput chat_layers[] = {
|
|
|
|
|
{
|
|
|
|
|
.num_drawables = sizeof(chat_rects)/sizeof(UIDrawable),
|
|
|
|
|
.drawables = chat_rects,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
UIContainerInput chat_info = {
|
|
|
|
|
.id = 0x02,
|
|
|
|
|
.offset = {0, WINDOW_HEIGHT-chat_size[1]},
|
|
|
|
|
.size = {chat_size[0], chat_size[1]},
|
|
|
|
|
.layer_count = sizeof(chat_layers)/sizeof(UILayerInput),
|
|
|
|
|
.layers = chat_layers,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
double last_frame_time = glfwGetTime();
|
|
|
|
|
while(glfwWindowShouldClose(window) == 0) {
|
|
|
|
|
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) {
|
|
|
|
|
fprintf(stderr, "draw_frame error: %s\n", string_VkResult(result));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
last_frame_time = frame_time;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -88,12 +141,47 @@ int network_thread() {
|
|
|
|
|
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() {
|
|
|
|
|
GLFWwindow* window = init_window();
|
|
|
|
|
if(window == NULL) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glfwSetKeyCallback(window, key_callback);
|
|
|
|
|
glfwSetMouseButtonCallback(window, mouse_button_callback);
|
|
|
|
|
glfwSetScrollCallback(window, scroll_callback);
|
|
|
|
|
glfwSetCursorPosCallback(window, cursor_pos_callback);
|
|
|
|
|
|
|
|
|
|
RenderContext render = {};
|
|
|
|
|
if(init_vulkan(window, &render) != VK_SUCCESS) {
|
|
|
|
|
return 2;
|
|
|
|
|