diff --git a/assets/std_person.png b/assets/std_person.png new file mode 100644 index 0000000..8a6ae9b Binary files /dev/null and b/assets/std_person.png differ diff --git a/assets/std_person.tga b/assets/std_person.tga deleted file mode 100644 index 3196e42..0000000 Binary files a/assets/std_person.tga and /dev/null differ diff --git a/assets/std_tile.png b/assets/std_tile.png new file mode 100644 index 0000000..c043eaf Binary files /dev/null and b/assets/std_tile.png differ diff --git a/assets/std_tile.tga b/assets/std_tile.tga deleted file mode 100644 index ed5d815..0000000 Binary files a/assets/std_tile.tga and /dev/null differ diff --git a/assets/strawberry.png b/assets/strawberry.png new file mode 100644 index 0000000..98c638f Binary files /dev/null and b/assets/strawberry.png differ diff --git a/assets/strawberry.tga b/assets/strawberry.tga deleted file mode 100644 index 4f57135..0000000 Binary files a/assets/strawberry.tga and /dev/null differ diff --git a/assets/strawberry_paintnet.png b/assets/strawberry_paintnet.png new file mode 100644 index 0000000..aa2b9a2 Binary files /dev/null and b/assets/strawberry_paintnet.png differ diff --git a/assets/strawberry_paintnet.tga b/assets/strawberry_paintnet.tga deleted file mode 100644 index e5a314f..0000000 Binary files a/assets/strawberry_paintnet.tga and /dev/null differ diff --git a/assets/tile_dirt.png b/assets/tile_dirt.png new file mode 100644 index 0000000..6146edf Binary files /dev/null and b/assets/tile_dirt.png differ diff --git a/assets/tile_dirt.tga b/assets/tile_dirt.tga deleted file mode 100644 index 2273bf2..0000000 Binary files a/assets/tile_dirt.tga and /dev/null differ diff --git a/assets/tile_empty.png b/assets/tile_empty.png new file mode 100644 index 0000000..ab90dcf Binary files /dev/null and b/assets/tile_empty.png differ diff --git a/assets/tile_empty.tga b/assets/tile_empty.tga deleted file mode 100644 index 6990404..0000000 Binary files a/assets/tile_empty.tga and /dev/null differ diff --git a/assets/tile_error.png b/assets/tile_error.png new file mode 100644 index 0000000..d6b78e7 Binary files /dev/null and b/assets/tile_error.png differ diff --git a/assets/tile_error.tga b/assets/tile_error.tga deleted file mode 100644 index 36d77ce..0000000 Binary files a/assets/tile_error.tga and /dev/null differ diff --git a/assets/tile_grass_1.png b/assets/tile_grass_1.png new file mode 100644 index 0000000..0163aa3 Binary files /dev/null and b/assets/tile_grass_1.png differ diff --git a/assets/tile_grass_1.tga b/assets/tile_grass_1.tga deleted file mode 100644 index b175b7f..0000000 Binary files a/assets/tile_grass_1.tga and /dev/null differ diff --git a/assets/tile_grass_2.png b/assets/tile_grass_2.png new file mode 100644 index 0000000..3bc4a21 Binary files /dev/null and b/assets/tile_grass_2.png differ diff --git a/assets/tile_grass_2.tga b/assets/tile_grass_2.tga deleted file mode 100644 index 76cd244..0000000 Binary files a/assets/tile_grass_2.tga and /dev/null differ diff --git a/assets/tile_grass_ground_1.png b/assets/tile_grass_ground_1.png new file mode 100644 index 0000000..843f1ba Binary files /dev/null and b/assets/tile_grass_ground_1.png differ diff --git a/assets/tile_grass_ground_1.tga b/assets/tile_grass_ground_1.tga deleted file mode 100644 index e1c1246..0000000 Binary files a/assets/tile_grass_ground_1.tga and /dev/null differ diff --git a/assets/tile_stone_ground.png b/assets/tile_stone_ground.png new file mode 100644 index 0000000..8042331 Binary files /dev/null and b/assets/tile_stone_ground.png differ diff --git a/assets/tile_stone_ground.tga b/assets/tile_stone_ground.tga deleted file mode 100644 index 0930bbd..0000000 Binary files a/assets/tile_stone_ground.tga and /dev/null differ diff --git a/assets/tile_tall_grass.png b/assets/tile_tall_grass.png new file mode 100644 index 0000000..cd94657 Binary files /dev/null and b/assets/tile_tall_grass.png differ diff --git a/assets/tile_tall_grass.tga b/assets/tile_tall_grass.tga deleted file mode 100644 index 9c2ea8d..0000000 Binary files a/assets/tile_tall_grass.tga and /dev/null differ diff --git a/assets/tile_water.png b/assets/tile_water.png new file mode 100644 index 0000000..2cd5535 Binary files /dev/null and b/assets/tile_water.png differ diff --git a/assets/tile_water.tga b/assets/tile_water.tga deleted file mode 100644 index 39c089e..0000000 Binary files a/assets/tile_water.tga and /dev/null differ diff --git a/assets/tile_water_2.png b/assets/tile_water_2.png new file mode 100644 index 0000000..d214a5b Binary files /dev/null and b/assets/tile_water_2.png differ diff --git a/assets/tile_water_2.tga b/assets/tile_water_2.tga deleted file mode 100644 index b7c5f2d..0000000 Binary files a/assets/tile_water_2.tga and /dev/null differ diff --git a/src/main.cpp b/src/main.cpp index b43b223..7cb09e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,7 @@ SDL_GPUShader *basic_vertex_shader; SDL_GPUShader *basic_pixel_shader; SDL_GPUGraphicsPipeline *basic_graphics_pipeline; -SDL_GPUSampler *trilinear_sampler; +SDL_GPUSampler *point_sampler; SDL_GPUBuffer *vertex_buffer; SDL_GPUBuffer *index_buffer; @@ -322,8 +322,7 @@ SDL_GPUTexture *create_shader_texture(const char *path) { SDL_GPUTextureFormat format = SDL_GPU_TEXTUREFORMAT_INVALID; if (channels == 1) format = SDL_GPU_TEXTUREFORMAT_A8_UNORM; - if (channels == 4) format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM; - // if (channels == 4) format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB; + if (channels == 4) format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB; if (format == SDL_GPU_TEXTUREFORMAT_INVALID) { log_error("Failed to find texture format for texture (\"%s\").", path); @@ -432,8 +431,7 @@ SDL_GPUTexture* create_shader_texture_array(Uint32 num_textures, const char **te SDL_GPUTextureCreateInfo texture_info = { .type = SDL_GPU_TEXTURETYPE_2D_ARRAY, - .format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM, - // .format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB, + .format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB, .usage = SDL_GPU_TEXTUREUSAGE_SAMPLER, .width = (Uint32)width, .height = (Uint32)height, @@ -696,43 +694,37 @@ int main(int argc, char **argv) { } } - const char *player_texture_array[] = { "../assets/strawberry.tga" }; + const char *player_texture_array[] = { "../assets/strawberry.png" }; SDL_GPUTexture *player_texture = create_shader_texture_array(SDL_arraysize(player_texture_array), player_texture_array, "player_textures"); if (!player_texture) { log_error("Failed to create shader texture. Exiting."); return 1; } - SDL_GPUTexture *quad_texture = create_shader_texture("../assets/tile_grass_2.tga"); + SDL_GPUTexture *quad_texture = create_shader_texture("../assets/tile_grass_2.png"); if (!player_texture) { log_error("Failed to create shader texture. Exiting."); return 1; } - SDL_GPUTexture *glyph_texture = create_shader_texture("../assets/fonts/glyph_atlas_lexend.tga"); - if (!player_texture) { - log_error("Failed to create shader texture. Exiting."); - return 1; - } - - const char *tile_texture_array[] = { "../assets/tile_empty.tga", "../assets/tile_grass_2.tga" , "../assets/tile_dirt.tga" , "../assets/tile_water.tga", "../assets/tile_error.tga" }; + const char *tile_texture_array[] = { "../assets/tile_empty.png", "../assets/tile_grass_2.png" , "../assets/tile_dirt.png" , "../assets/tile_water.png", "../assets/tile_error.png" }; SDL_GPUTexture *tile_texture = create_shader_texture_array(SDL_arraysize(tile_texture_array), tile_texture_array, "tile_textures"); if (!player_texture) { log_error("Failed to create shader texture array. Exiting."); return 1; } - SDL_GPUSamplerCreateInfo trilinear_sampler_info = { - .min_filter = SDL_GPU_FILTER_LINEAR, - .mag_filter = SDL_GPU_FILTER_LINEAR, - .mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR, + SDL_GPUSamplerCreateInfo point_sampler_info = { + .min_filter = SDL_GPU_FILTER_NEAREST, + .mag_filter = SDL_GPU_FILTER_NEAREST, + .mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST, .address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE, .address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE, .address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE, }; - trilinear_sampler = SDL_CreateGPUSampler(device, &trilinear_sampler_info); + point_sampler = SDL_CreateGPUSampler(device, &point_sampler_info); vertex_buffer = create_buffer(SDL_GPU_BUFFERUSAGE_VERTEX, sizeof(vertices), vertices, "vertex_buffer"); if (!vertex_buffer) { @@ -960,7 +952,7 @@ int main(int argc, char **argv) { { .buffer = tiles_instance_buffer, .offset = 0 }, }; SDL_GPUTextureSamplerBinding texture_bindings[] = { - { .texture = tile_texture, .sampler = trilinear_sampler }, + { .texture = tile_texture, .sampler = point_sampler }, }; SDL_BindGPUGraphicsPipeline(render_pass, basic_graphics_pipeline); @@ -976,7 +968,7 @@ int main(int argc, char **argv) { { .buffer = player_instance_buffer, .offset = 0 }, }; SDL_GPUTextureSamplerBinding texture_bindings[] = { - { .texture = player_texture, .sampler = trilinear_sampler }, + { .texture = player_texture, .sampler = point_sampler }, }; SDL_BindGPUGraphicsPipeline(render_pass, basic_graphics_pipeline); SDL_BindGPUVertexBuffers(render_pass, 0, vertex_buffers, SDL_arraysize(vertex_buffers));