From edb587334ad687093777c57083f0fac487a435fe Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Mon, 4 Nov 2024 21:04:51 -0700 Subject: [PATCH] Allow for multiple maps to be loaded into memory and only draw one --- client/include/hex.h | 1 + client/shader/hex.vert | 2 +- client/shader/hex_common.glsl | 1 + client/src/main.c | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/include/hex.h b/client/include/hex.h index fdd35f1..f6f0f21 100644 --- a/client/include/hex.h +++ b/client/include/hex.h @@ -36,6 +36,7 @@ typedef struct GPUHexContextStruct { vec4 click_end; vec4 hover_start; vec4 hover_end; + uint32_t current_map; uint32_t clicked_region; int32_t clicked_hex; uint32_t hovered_region; diff --git a/client/shader/hex.vert b/client/shader/hex.vert index 1e566f8..036886d 100644 --- a/client/shader/hex.vert +++ b/client/shader/hex.vert @@ -16,7 +16,7 @@ vec4 int2color(uint color_int) { void main() { int region_index = gl_InstanceIndex/region_hex_count; Region region = pc.context.regions[region_index]; - if(region.map == 0) { + if(region.map != pc.context.current_map) { gl_Position = vec4(0, 0, 0, 0); return; } diff --git a/client/shader/hex_common.glsl b/client/shader/hex_common.glsl index eb56d1e..6e19dca 100644 --- a/client/shader/hex_common.glsl +++ b/client/shader/hex_common.glsl @@ -18,6 +18,7 @@ layout(std430, buffer_reference) readonly buffer HexContext { vec4 click_end; vec4 hover_start; vec4 hover_end; + uint current_map; uint clicked_region; int clicked_hex; uint hovered_region; diff --git a/client/src/main.c b/client/src/main.c index 3165d2a..96ac285 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -103,7 +103,7 @@ VkResult main_thread(ClientContext* context) { for(int32_t y = -2; y < 2; y++) { for(int32_t q = -5; q < 5; q++) { for(int32_t r = -5; r < 5; r++) { - VK_RESULT(set_hex_region(q, r, y, 0x01, ®ions[region], context->hex, context->render)); + VK_RESULT(set_hex_region(q, r, y, 0x00, ®ions[region], context->hex, context->render)); for(uint32_t i = 0; i < REGION_HEX_COUNT; i++) { for(uint32_t h = 0; h < 6; h++) { regions[region]->data.hexes[i].color[h] = colors[(q+r+50) % (sizeof(colors)/sizeof(uint32_t))];