|
|
@ -122,7 +122,7 @@ VkResult main_thread(ClientContext* context) {
|
|
|
|
4*sizeof(uint32_t),
|
|
|
|
4*sizeof(uint32_t),
|
|
|
|
&context->render));
|
|
|
|
&context->render));
|
|
|
|
|
|
|
|
|
|
|
|
HexRegion* regions[19];
|
|
|
|
HexRegion* regions[MAX_LOADED_REGIONS];
|
|
|
|
uint32_t colors[] = {
|
|
|
|
uint32_t colors[] = {
|
|
|
|
0xFF0000FF,
|
|
|
|
0xFF0000FF,
|
|
|
|
0x00FF00FF,
|
|
|
|
0x00FF00FF,
|
|
|
@ -145,37 +145,21 @@ VkResult main_thread(ClientContext* context) {
|
|
|
|
0x0000FFFF,
|
|
|
|
0x0000FFFF,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 0, 0, ®ions[0], &context->hex, &context->render));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 1, -1, ®ions[1], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 1, 0, ®ions[2], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 0, 1, ®ions[3], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region(-1, 1, ®ions[4], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region(-1, 0, ®ions[5], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 0, -1, ®ions[6], &context->hex, &context->render));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 0, -2, ®ions[7], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 1, -2, ®ions[8], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 2, -2, ®ions[9], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 2, -1, ®ions[10], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 2, 0, ®ions[11], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 1, 1, ®ions[12], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region( 0, 2, ®ions[13], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region(-1, 2, ®ions[14], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region(-2, 2, ®ions[15], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region(-2, 1, ®ions[16], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region(-2, 0, ®ions[17], &context->hex, &context->render));
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region(-1, -1, ®ions[18], &context->hex, &context->render));
|
|
|
|
|
|
|
|
GPUHex* temp_hexes = malloc(sizeof(GPUHex)*REGION_HEX_COUNT);
|
|
|
|
GPUHex* temp_hexes = malloc(sizeof(GPUHex)*REGION_HEX_COUNT);
|
|
|
|
|
|
|
|
uint32_t region = 0;
|
|
|
|
for(uint32_t r = 0; r < sizeof(regions)/sizeof(HexRegion*); r++) {
|
|
|
|
for(int32_t q = -5; q < 5; q++) {
|
|
|
|
|
|
|
|
for(int32_t r = -5; r < 5; r++) {
|
|
|
|
|
|
|
|
VK_RESULT(create_hex_region(q, r, ®ions[region], &context->hex, &context->render));
|
|
|
|
for(uint32_t i = 0; i < REGION_HEX_COUNT; i++) {
|
|
|
|
for(uint32_t i = 0; i < REGION_HEX_COUNT; i++) {
|
|
|
|
for(uint32_t h = 0; h < 6; h++) {
|
|
|
|
for(uint32_t h = 0; h < 6; h++) {
|
|
|
|
temp_hexes[i].color[h] = colors[r % (sizeof(colors)/sizeof(uint32_t))];
|
|
|
|
temp_hexes[i].color[h] = colors[r % (sizeof(colors)/sizeof(uint32_t))];
|
|
|
|
temp_hexes[i].height[h] = 0;
|
|
|
|
temp_hexes[i].height[h] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
temp_hexes[i].color[6] = colors[r % (sizeof(colors)/sizeof(uint32_t))];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
VK_RESULT(add_transfer(temp_hexes, regions[region]->region, offsetof(GPUHexRegion, hexes), sizeof(GPUHex)*REGION_HEX_COUNT, 0, &context->render));
|
|
|
|
|
|
|
|
region++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VK_RESULT(add_transfer(temp_hexes, regions[r]->region, offsetof(GPUHexRegion, hexes), sizeof(GPUHex)*REGION_HEX_COUNT, 0, &context->render));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -186,7 +170,7 @@ VkResult main_thread(ClientContext* context) {
|
|
|
|
context->position[2] = 0;
|
|
|
|
context->position[2] = 0;
|
|
|
|
|
|
|
|
|
|
|
|
context->rotation[0] = 3*M_PI/2;
|
|
|
|
context->rotation[0] = 3*M_PI/2;
|
|
|
|
context->rotation[1] = 0;
|
|
|
|
context->rotation[1] = M_PI/4;
|
|
|
|
context->cur_spin[0] = 0;
|
|
|
|
context->cur_spin[0] = 0;
|
|
|
|
context->cur_spin[1] = 0;
|
|
|
|
context->cur_spin[1] = 0;
|
|
|
|
|
|
|
|
|
|
|
@ -194,7 +178,7 @@ VkResult main_thread(ClientContext* context) {
|
|
|
|
context->key_spin[1] = 0;
|
|
|
|
context->key_spin[1] = 0;
|
|
|
|
context->cur_spin[0] = 0;
|
|
|
|
context->cur_spin[0] = 0;
|
|
|
|
context->cur_spin[1] = 0;
|
|
|
|
context->cur_spin[1] = 0;
|
|
|
|
context->distance = 10;
|
|
|
|
context->distance = 50;
|
|
|
|
context->zoom = 0;
|
|
|
|
context->zoom = 0;
|
|
|
|
context->camera_mode = false;
|
|
|
|
context->camera_mode = false;
|
|
|
|
context->key_spin_speed = 1.0;
|
|
|
|
context->key_spin_speed = 1.0;
|
|
|
@ -206,7 +190,7 @@ VkResult main_thread(ClientContext* context) {
|
|
|
|
GPUString* mapped_string = context->ui.containers[0].layers[0].strings_buffer;
|
|
|
|
GPUString* mapped_string = context->ui.containers[0].layers[0].strings_buffer;
|
|
|
|
char str[21];
|
|
|
|
char str[21];
|
|
|
|
|
|
|
|
|
|
|
|
double last_frame_time = glfwGetTime();
|
|
|
|
double last_frame_time = 0;
|
|
|
|
while(glfwWindowShouldClose(context->window) == 0) {
|
|
|
|
while(glfwWindowShouldClose(context->window) == 0) {
|
|
|
|
double frame_time = glfwGetTime();
|
|
|
|
double frame_time = glfwGetTime();
|
|
|
|
double delta_time = (frame_time - last_frame_time);
|
|
|
|
double delta_time = (frame_time - last_frame_time);
|
|
|
@ -221,7 +205,8 @@ VkResult main_thread(ClientContext* context) {
|
|
|
|
|
|
|
|
|
|
|
|
if(context->key_spin[0] != 0 || context->key_spin[1] != 0 ||
|
|
|
|
if(context->key_spin[0] != 0 || context->key_spin[1] != 0 ||
|
|
|
|
context->zoom != 0 ||
|
|
|
|
context->zoom != 0 ||
|
|
|
|
context->cur_spin[0] != 0 || context->cur_spin[1] != 0) {
|
|
|
|
context->cur_spin[0] != 0 || context->cur_spin[1] != 0 ||
|
|
|
|
|
|
|
|
last_frame_time == 0) {
|
|
|
|
|
|
|
|
|
|
|
|
context->rotation[0] += (float)context->key_spin[0]*delta_time*context->key_spin_speed;
|
|
|
|
context->rotation[0] += (float)context->key_spin[0]*delta_time*context->key_spin_speed;
|
|
|
|
context->rotation[0] += (float)context->cur_spin[0]*delta_time*context->cur_spin_speed;
|
|
|
|
context->rotation[0] += (float)context->cur_spin[0]*delta_time*context->cur_spin_speed;
|
|
|
@ -244,12 +229,21 @@ VkResult main_thread(ClientContext* context) {
|
|
|
|
context->distance = 1;
|
|
|
|
context->distance = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vec3 camera;
|
|
|
|
vec3 camera = {};
|
|
|
|
camera[0] = context->position[0] + context->distance*cos(context->rotation[1])*cos(context->rotation[0]);
|
|
|
|
camera[0] = context->position[0] + context->distance*cos(context->rotation[1])*cos(context->rotation[0]);
|
|
|
|
camera[1] = context->position[1] + context->distance*sin(context->rotation[1]);
|
|
|
|
camera[1] = context->position[1] + context->distance*sin(context->rotation[1]);
|
|
|
|
camera[2] = context->position[2] + context->distance*cos(context->rotation[1])*sin(context->rotation[0]);
|
|
|
|
camera[2] = context->position[2] + context->distance*cos(context->rotation[1])*sin(context->rotation[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vec2 hex_pos = {};
|
|
|
|
|
|
|
|
vec2 hex_forward = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hex_pos[0] = camera[0];
|
|
|
|
|
|
|
|
hex_pos[1] = camera[2] - camera[0]/2;
|
|
|
|
|
|
|
|
|
|
|
|
glm_lookat(camera, context->position, up, context->hex.data.view);
|
|
|
|
glm_lookat(camera, context->position, up, context->hex.data.view);
|
|
|
|
add_transfer(&context->hex.data, context->hex.context, 0, 2*sizeof(mat4), context->render.current_frame, &context->render);
|
|
|
|
add_transfer(&context->hex.data, context->hex.context, 0, 2*sizeof(mat4), context->render.current_frame, &context->render);
|
|
|
|
|
|
|
|
add_transfer(hex_pos, context->hex.context, offsetof(GPUHexContext, camera), sizeof(vec2), context->render.current_frame, &context->render);
|
|
|
|
|
|
|
|
add_transfer(hex_forward, context->hex.context, offsetof(GPUHexContext, forward), sizeof(vec2), context->render.current_frame, &context->render);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(context->clicked_container != 0) {
|
|
|
|
if(context->clicked_container != 0) {
|
|
|
|