Fix indice order that skewed mesh

This commit is contained in:
2025-06-01 19:54:01 +02:00
parent 983117fa9b
commit f6efad02a6
5 changed files with 9 additions and 9 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

+2 -2
View File
@@ -23,8 +23,8 @@ Chunk_noise (Chunk *chunk, int xoffset, int yoffset)
(void) xoffset; (void) yoffset;
float val = sinf (x) + sinf (y);
(void) val;
chunk->heightmap[INDEX (x, y)] = val;
chunk->materialmap[INDEX (x, y)] = (int) val;
chunk->heightmap[INDEX (x, y)] = 0;
chunk->materialmap[INDEX (x, y)] = rand () % 2;
}
}
}
+1 -1
View File
@@ -62,9 +62,9 @@ ChunkMesh_from_Chunk_and_neighbors (Chunk *chunk, Chunk *nd, Chunk *nr, Chunk *n
indices[i_i++] = i0;
indices[i_i++] = i2;
indices[i_i++] = i3;
indices[i_i++] = i0;
indices[i_i++] = i3;
indices[i_i++] = i1;
indices[i_i++] = i0;
}
}
}
+2
View File
@@ -214,6 +214,8 @@ SDL_AppIterate (void *appstate)
program_set_mat4 (resources.programs[1], "view", view);
program_set_mat4 (resources.programs[1], "projection", projection);
ChunkMesh_render (&test_chunkmesh);
glBindTexture (GL_TEXTURE_2D, 0);
SDL_GL_SwapWindow (window);
+4 -6
View File
@@ -5,9 +5,8 @@ Resources resources;
void
Resources_add_program (const char *v_src, const char *f_src)
{
resources.programs_len++;
resources.programs = realloc (resources.programs, sizeof (unsigned int) * resources.programs_len);
resources.programs[resources.programs_len - 1] = program_create (v_src, f_src);
resources.programs = realloc (resources.programs, sizeof (unsigned int) * resources.programs_len + 1);
resources.programs[resources.programs_len++] = program_create (v_src, f_src);
}
void
@@ -50,9 +49,8 @@ Resources_load_program (const char *v_path, const char *f_path)
void
Resources_add_texture (int width, int height, unsigned char *data)
{
resources.textures_len++;
resources.textures = realloc (resources.textures, sizeof (unsigned int) * resources.textures_len);
resources.textures[resources.textures_len - 1] = texture_create (width, height, data);
resources.textures = realloc (resources.textures, sizeof (unsigned int) * resources.textures_len + 1);
resources.textures[resources.textures_len++] = texture_create (width, height, data);
}
void