Made window resizing change framebuffer size

This commit is contained in:
Eric-Paul Ickhorn 2023-10-13 14:00:49 +02:00
parent 3e700bda2c
commit 4ae08a432b
4 changed files with 11 additions and 5 deletions

View File

@ -72,8 +72,6 @@ tc_chunk_s * tc_load_chunk_of_loader(tc_chunkloader_s *loader, tc_vec3i_s coord)
if(chunk == NULL)
{
printf("Creating chunk at: %d %d %d\n", coord.x, coord.y, coord.z);
chunk = tc_allocate_chunk(loader->world);
chunk->position = coord;

View File

@ -28,6 +28,9 @@ bool tc_generate_default_terrain_chunk(tc_worldgen_s *gen, tc_chunk_s *chunk)
}
++x_in_chunk;
}
tc_block_s air;
block.type_identifier = 0;
tc_set_block_in_chunk(chunk, 6, 8, 14, air);
return true;
}

View File

@ -110,7 +110,12 @@ void render()
float depth = 10000000.0f;
glClearBufferfv(GL_DEPTH, 0, &depth);
mat4x4_perspective(projection_matrix, 120, 1200 / 800, 0.0001f, 1000.0f);
int fb_width = 0;
int fb_height = 0;
SDL_GetWindowSize(tc_game_state_g.renderer.window, &fb_width, &fb_height);
glViewport(0, 0, fb_width, fb_height);
mat4x4_perspective(projection_matrix, 120, ((float) fb_width) / ((float) fb_height), 0.0001f, 1000.0f);
mat4x4_identity(view_matrix);
mat4x4_rotate_X(view_matrix, view_matrix, tc_camera_rotation.x);
@ -160,7 +165,7 @@ bool update()
{
if(event.window.event == SDL_WINDOWEVENT_RESIZED)
{
puts("RESIZED");
}
} break;
case SDL_KEYDOWN:

View File

@ -158,7 +158,7 @@ tc_world_s * tc_new_world(tc_worldgen_s *generator)
world->pool = tc_new_chunk_pool(128);
world->worldgen = &tc_default_terrain_generator_g;
// world->center_chunk = tc_new_chunk(world, 0, 0, 0);
world->load_radius = 1;
world->load_radius = 3;
world->num_loaders = 1;
world->loaders = malloc(sizeof(tc_chunkloader_s) * world->num_loaders);
world->loaders[0] = tc_create_spawn_loader(world);