diff --git a/game/res/shaders/chunk.vert b/game/res/shaders/chunk.vert index 1e40989..869b992 100644 --- a/game/res/shaders/chunk.vert +++ b/game/res/shaders/chunk.vert @@ -9,7 +9,7 @@ varying float f_height; uniform mat4 view; uniform mat4 projection; -uniform vec4 chunk_position; +uniform vec3 chunk_position; void main () { @@ -17,5 +17,5 @@ void main () f_material = material; f_height = position.y; - gl_Position = projection * view * (position + chunk_position); + gl_Position = projection * view * (position + vec4(chunk_position, 0.0)); } diff --git a/game/src/chunk/manager.c b/game/src/chunk/manager.c index fe0a0b2..70c550b 100644 --- a/game/src/chunk/manager.c +++ b/game/src/chunk/manager.c @@ -31,10 +31,8 @@ void ChunkManager_update (float px, float py) /* x = camera's X position, y = camera's Y position */ { - (void) px; (void) py; int cx = 0, cy = 0; - - /* cm_get_chunk_pos (px, py, &cx, &cy); */ + cm_get_chunk_pos (px, py, &cx, &cy); for (int y = cy - RENDER_DISTANCE - 1; y <= cy + RENDER_DISTANCE + 1; ++y) { @@ -62,9 +60,8 @@ ChunkManager_update (float px, float py) void ChunkManager_render (float px, float py, int program) { - (void) px; (void) py; int cx = 0, cy = 0; - /* cm_get_chunk_pos (px, py, &cx, &cy); */ + cm_get_chunk_pos (px, py, &cx, &cy); for (int y = cy - RENDER_DISTANCE; y <= cy + RENDER_DISTANCE; ++y) { @@ -73,7 +70,7 @@ ChunkManager_render (float px, float py, int program) ChunkMesh *mesh = ChunkManager_get_chunk_mesh_at (x, y); if (mesh != NULL) { - program_set_vec4 (program, "chunk_position", x * CHUNKMESH_DIM, 0.0, y * CHUNKMESH_DIM, 1.0); + program_set_vec3 (program, "chunk_position", x * CHUNK_DIM, 0.0, y * CHUNK_DIM); ChunkMesh_render (mesh); } } diff --git a/game/src/chunk/mesh.c b/game/src/chunk/mesh.c index 43b3635..a379832 100644 --- a/game/src/chunk/mesh.c +++ b/game/src/chunk/mesh.c @@ -82,7 +82,7 @@ ChunkMesh_from_Chunk_and_neighbors (Chunk *chunk, Chunk *nr, Chunk *nd, Chunk *n glVertexAttribPointer (1, 4, GL_FLOAT, GL_FALSE, sizeof (float) * 4, 0); glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, mesh->ebo); - glBufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (unsigned int) * CHUNKMESH_SIZE * 6, indices, GL_STATIC_DRAW); + glBufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (unsigned int) * CHUNK_SIZE * 6, indices, GL_STATIC_DRAW); glBindBuffer (GL_ARRAY_BUFFER, 0); glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0); diff --git a/game/src/program.c b/game/src/program.c index b2adf9b..f3954cc 100644 --- a/game/src/program.c +++ b/game/src/program.c @@ -73,9 +73,9 @@ program_create (const char *v_src, const char *f_src) } void -program_set_vec4 (int program, const char *name, float x, float y, float z, float w) +program_set_vec3 (int program, const char *name, float x, float y, float z) { - glUniform4f (glGetUniformLocation (program, name), x, y, z, w); + glUniform3f (glGetUniformLocation (program, name), x, y, z); } void diff --git a/game/src/program.h b/game/src/program.h index c34f206..b7a08a2 100644 --- a/game/src/program.h +++ b/game/src/program.h @@ -12,6 +12,6 @@ void shader_fail (int shader); void program_fail (int program); int program_create (const char *v_src, const char *f_src); void program_set_int_array (int program, const char *name, size_t count, int *value); -void program_set_vec4 (int program, const char *name, float x, float y, float z, float w); +void program_set_vec3 (int program, const char *name, float x, float y, float z); void program_set_mat4 (int program, const char *name, mat4_t value); void program_print (int program);