Fix the world being scaled down
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user