Allow for multiple maps to be loaded into memory and only draw one

main
noah metz 2024-11-04 21:04:51 -07:00
parent 9eca26db4e
commit edb587334a
4 changed files with 4 additions and 2 deletions

@ -36,6 +36,7 @@ typedef struct GPUHexContextStruct {
vec4 click_end; vec4 click_end;
vec4 hover_start; vec4 hover_start;
vec4 hover_end; vec4 hover_end;
uint32_t current_map;
uint32_t clicked_region; uint32_t clicked_region;
int32_t clicked_hex; int32_t clicked_hex;
uint32_t hovered_region; uint32_t hovered_region;

@ -16,7 +16,7 @@ vec4 int2color(uint color_int) {
void main() { void main() {
int region_index = gl_InstanceIndex/region_hex_count; int region_index = gl_InstanceIndex/region_hex_count;
Region region = pc.context.regions[region_index]; 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); gl_Position = vec4(0, 0, 0, 0);
return; return;
} }

@ -18,6 +18,7 @@ layout(std430, buffer_reference) readonly buffer HexContext {
vec4 click_end; vec4 click_end;
vec4 hover_start; vec4 hover_start;
vec4 hover_end; vec4 hover_end;
uint current_map;
uint clicked_region; uint clicked_region;
int clicked_hex; int clicked_hex;
uint hovered_region; uint hovered_region;

@ -103,7 +103,7 @@ VkResult main_thread(ClientContext* context) {
for(int32_t y = -2; y < 2; y++) { for(int32_t y = -2; y < 2; y++) {
for(int32_t q = -5; q < 5; q++) { for(int32_t q = -5; q < 5; q++) {
for(int32_t r = -5; r < 5; r++) { for(int32_t r = -5; r < 5; r++) {
VK_RESULT(set_hex_region(q, r, y, 0x01, &regions[region], context->hex, context->render)); VK_RESULT(set_hex_region(q, r, y, 0x00, &regions[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++) {
regions[region]->data.hexes[i].color[h] = colors[(q+r+50) % (sizeof(colors)/sizeof(uint32_t))]; regions[region]->data.hexes[i].color[h] = colors[(q+r+50) % (sizeof(colors)/sizeof(uint32_t))];