diff options
Diffstat (limited to 'src/systems')
-rw-r--r-- | src/systems/terrain.c | 13 | ||||
-rw-r--r-- | src/systems/terrain.h | 5 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/systems/terrain.c b/src/systems/terrain.c index 3743a9b..d2a9300 100644 --- a/src/systems/terrain.c +++ b/src/systems/terrain.c @@ -39,7 +39,7 @@ bool Terrain_Init(Terrain_Storage* storage) { } ShaderData camera_data = { .get_layout = &Binding_Camera_GetLayout }; - ShaderData terrain_data = { .get_layout = &TerrainUniforms_GetLayout}; + ShaderData terrain_data = { .get_layout = &TerrainUniforms_GetLayout }; GraphicsPipelineDesc pipeline_desc = { .debug_name = "terrain rendering pipeline", @@ -97,8 +97,8 @@ void Terrain_LoadHeightmap(Terrain_Storage* storage, Heightmap hmap, f32 grid_sc Vec3 v_pos = vec3_create(i * grid_scale, height, j * grid_scale); Vec3 v_normal = VEC3_Y; float tiling_factor = 505.0f; - Vec2 v_uv = vec2((f32)i / width * tiling_factor , (f32)j / height * tiling_factor); - Vertex v = { .static_3d = {.position = v_pos, .normal = v_normal, .tex_coords = v_uv} }; + Vec2 v_uv = vec2((f32)i / width * tiling_factor, (f32)j / height * tiling_factor); + Vertex v = { .static_3d = { .position = v_pos, .normal = v_normal, .tex_coords = v_uv } }; Vertex_darray_push(vertices, v); index++; } @@ -169,13 +169,10 @@ void Terrain_Draw(Terrain_Storage* storage) { GPU_EncodeBindShaderData( enc, 0, (ShaderData){ .data = &camera_data, .get_layout = &Binding_Camera_GetLayout }); - TerrainUniforms uniforms = { - .tex_slot_1 = storage->texture - }; - ShaderData terrain_data = { .data = &uniforms, .get_layout = &TerrainUniforms_GetLayout}; + TerrainUniforms uniforms = { .tex_slot_1 = storage->texture }; + ShaderData terrain_data = { .data = &uniforms, .get_layout = &TerrainUniforms_GetLayout }; GPU_EncodeBindShaderData(enc, 1, terrain_data); - GPU_EncodeSetVertexBuffer(enc, storage->vertex_buffer); GPU_EncodeSetIndexBuffer(enc, storage->index_buffer); diff --git a/src/systems/terrain.h b/src/systems/terrain.h index 664aa8e..4399e6b 100644 --- a/src/systems/terrain.h +++ b/src/systems/terrain.h @@ -27,7 +27,7 @@ typedef struct Heightmap { bool is_uploaded; } Heightmap; - typedef struct Terrain_Storage { +typedef struct Terrain_Storage { // arena terrain_allocator; u32x2 grid_dimensions; f32 grid_scale; @@ -50,7 +50,8 @@ PUB void Terrain_Draw( Terrain_Storage* storage); // NOTE: For now it renders directly to main framebuffer /** @brief Sets the active heightmap to be rendered and collided against. */ -PUB void Terrain_LoadHeightmap(Terrain_Storage* storage, Heightmap hmap, f32 grid_scale, bool free_on_upload); +PUB void Terrain_LoadHeightmap(Terrain_Storage* storage, Heightmap hmap, f32 grid_scale, + bool free_on_upload); PUB Heightmap Heightmap_FromImage(Str8 filepath); PUB Heightmap Heightmap_FromPerlin(/* TODO: perlin noise generation parameters */); |