diff --git a/game/res/textures/rock_cement.png b/game/res/textures/rock_cement.png new file mode 100644 index 0000000..a49d952 Binary files /dev/null and b/game/res/textures/rock_cement.png differ diff --git a/game/src/chunk/chunk.c b/game/src/chunk/chunk.c index ce8e310..6147786 100644 --- a/game/src/chunk/chunk.c +++ b/game/src/chunk/chunk.c @@ -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; } } } diff --git a/game/src/chunk/chunkmesh.c b/game/src/chunk/chunkmesh.c index 291f9aa..29a1cd7 100644 --- a/game/src/chunk/chunkmesh.c +++ b/game/src/chunk/chunkmesh.c @@ -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; } } } diff --git a/game/src/main.c b/game/src/main.c index 4169b2d..179c058 100644 --- a/game/src/main.c +++ b/game/src/main.c @@ -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); diff --git a/game/src/resources.c b/game/src/resources.c index b5f1163..4800ed6 100644 --- a/game/src/resources.c +++ b/game/src/resources.c @@ -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