This commit is contained in:
2025-06-03 10:51:21 +02:00
parent b7072568b4
commit 354d11acf8
4 changed files with 10 additions and 14 deletions
+5 -5
View File
@@ -44,10 +44,10 @@ ChunkManager_init ()
}
void
ChunkManager_update (float camera_x, float camera_z)
ChunkManager_update (vec3 camera_position)
{
int cx = 0, cz = 0;
cm_world_to_chunk (camera_x, camera_z, &cx, &cz);
int cx, cz;
cm_world_to_chunk (camera_position[0], camera_position[2], &cx, &cz);
for (int z = cz - RENDER_DISTANCE - 1; z <= cz + RENDER_DISTANCE + 1; ++z)
{
@@ -73,10 +73,10 @@ ChunkManager_update (float camera_x, float camera_z)
}
void
ChunkManager_render (float camera_x, float camera_z, int program)
ChunkManager_render (vec3 camera_position, int program)
{
int cx = 0, cz = 0;
cm_world_to_chunk (camera_x, camera_z, &cx, &cz);
cm_world_to_chunk (camera_position[0], camera_position[2], &cx, &cz);
for (int z = cz - RENDER_DISTANCE; z <= cz + RENDER_DISTANCE; ++z)
{
+2 -2
View File
@@ -19,8 +19,8 @@ typedef struct ChunkManager
} ChunkManager;
void ChunkManager_init ();
void ChunkManager_update (float px, float py);
void ChunkManager_render (float px, float py, int program);
void ChunkManager_update (vec3 camera_position);
void ChunkManager_render (vec3 camera_position, int program);
Chunk *ChunkManager_get_Chunk_at (int x, int z);
void ChunkManager_get_Chunk_neighbors_at (int x, int z, Chunk **nr, Chunk **nd, Chunk **nc);
+1 -1
View File
@@ -69,7 +69,7 @@ GraphicsContext_render ()
glBindTexture (GL_TEXTURE_2D, resources.textures[i]);
}
ChunkManager_render (game_state.camera.position[0], game_state.camera.position[2], resources.programs[1]);
ChunkManager_render (game_state.camera.position, resources.programs[1]);
glBindTexture (GL_TEXTURE_2D, 0);
+2 -6
View File
@@ -12,17 +12,13 @@
extern GameState game_state;
extern GameFlags game_flags;
extern EventManager event_manager;
extern GraphicsContext gfx;
extern Resources resources;
extern ChunkManager chunk_manager;
SDL_AppResult
SDL_AppInit (void **appstate, int argc, char **argv)
{
UNUSED (appstate, argc, argv);
SDL_SetAppMetadata (GAME_NAME, GAME_VERSION, "eur.chopininteractive.wschod-game");
GraphicsContext_init ();
handlers_init ();
Resources_init ();
@@ -54,7 +50,7 @@ SDL_AppIterate (void *appstate)
{
UNUSED (appstate);
ChunkManager_update (game_state.camera.position[0], game_state.camera.position[2]);
ChunkManager_update (game_state.camera.position);
GameState_tick (SDL_GetTicks ());
GraphicsContext_render ();