2024-10-30 17:36:53 -06:00
|
|
|
#ifndef HEX_H
|
|
|
|
#define HEX_H
|
|
|
|
|
|
|
|
#include "gpu.h"
|
|
|
|
|
2024-11-02 23:25:21 -06:00
|
|
|
#define REGION_SIZE (10)
|
2024-11-01 17:34:41 -06:00
|
|
|
#define REGION_HEX_COUNT (3*REGION_SIZE*(REGION_SIZE-1)+1)
|
2024-11-04 21:07:43 -07:00
|
|
|
#define MAX_LOADED_REGIONS (51*51)
|
2024-10-30 21:24:03 -06:00
|
|
|
|
2024-11-01 17:34:41 -06:00
|
|
|
typedef struct GPUHexStruct {
|
|
|
|
float height[6];
|
2024-11-02 22:02:32 -06:00
|
|
|
uint32_t color[7];
|
2024-11-01 17:34:41 -06:00
|
|
|
} GPUHex;
|
|
|
|
|
|
|
|
typedef struct GPUHexRegionStruct {
|
2024-11-02 12:07:11 -06:00
|
|
|
int32_t q;
|
|
|
|
int32_t r;
|
2024-11-04 21:02:48 -07:00
|
|
|
int32_t y;
|
|
|
|
uint32_t map;
|
2024-11-01 17:34:41 -06:00
|
|
|
|
|
|
|
GPUHex hexes[REGION_HEX_COUNT];
|
|
|
|
} GPUHexRegion;
|
|
|
|
|
|
|
|
typedef struct HexRegionStruct {
|
|
|
|
VkDeviceAddress address;
|
|
|
|
VkBuffer region;
|
|
|
|
VmaAllocation region_memory;
|
2024-11-02 23:25:21 -06:00
|
|
|
|
2024-11-04 17:51:10 -07:00
|
|
|
GPUHexRegion data;
|
2024-11-01 17:34:41 -06:00
|
|
|
} HexRegion;
|
2024-10-30 17:36:53 -06:00
|
|
|
|
2024-11-01 15:46:27 -06:00
|
|
|
typedef struct GPUHexContextStruct {
|
|
|
|
mat4 proj;
|
|
|
|
mat4 view;
|
2024-11-04 17:51:10 -07:00
|
|
|
vec4 click_start;
|
|
|
|
vec4 click_end;
|
|
|
|
vec4 hover_start;
|
|
|
|
vec4 hover_end;
|
2024-11-04 21:04:51 -07:00
|
|
|
uint32_t current_map;
|
2024-11-04 20:42:58 -07:00
|
|
|
uint32_t clicked_region;
|
|
|
|
int32_t clicked_hex;
|
|
|
|
uint32_t hovered_region;
|
|
|
|
int32_t hovered_hex;
|
2024-11-01 17:34:41 -06:00
|
|
|
VkDeviceAddress regions[MAX_LOADED_REGIONS];
|
2024-11-01 15:46:27 -06:00
|
|
|
} GPUHexContext;
|
|
|
|
|
|
|
|
typedef struct HexContextStruct {
|
|
|
|
VkDeviceAddress address;
|
|
|
|
VkBuffer context;
|
2024-11-04 17:51:10 -07:00
|
|
|
VmaAllocation context_memory;
|
2024-11-01 15:46:27 -06:00
|
|
|
|
|
|
|
GraphicsPipeline graphics;
|
2024-11-04 17:51:10 -07:00
|
|
|
GraphicsPipeline ray_pipeline;
|
2024-11-04 20:42:58 -07:00
|
|
|
GraphicsPipeline highlight_pipeline;
|
2024-11-01 15:46:27 -06:00
|
|
|
|
2024-11-01 17:34:41 -06:00
|
|
|
HexRegion regions[MAX_LOADED_REGIONS];
|
|
|
|
|
2024-11-01 15:46:27 -06:00
|
|
|
GPUHexContext data;
|
|
|
|
} HexContext;
|
|
|
|
|
2024-11-01 17:34:41 -06:00
|
|
|
typedef struct HexPushConstantStruct {
|
|
|
|
VkDeviceAddress context;
|
|
|
|
double time;
|
|
|
|
} HexPushConstant;
|
2024-11-01 15:46:27 -06:00
|
|
|
|
|
|
|
VkResult create_hex_context(
|
|
|
|
RenderContext* gpu,
|
|
|
|
HexContext* context);
|
|
|
|
|
2024-11-04 21:02:48 -07:00
|
|
|
VkResult set_hex_region(
|
|
|
|
int32_t q, int32_t r, int32_t y,
|
|
|
|
uint32_t map,
|
2024-11-01 17:34:41 -06:00
|
|
|
HexRegion** region,
|
|
|
|
HexContext* hex,
|
2024-11-01 15:46:27 -06:00
|
|
|
RenderContext* gpu);
|
2024-10-30 17:36:53 -06:00
|
|
|
|
|
|
|
#endif
|