convert assets to png and switch to srgb color loading
BIN
assets/std_person.png
Normal file
|
After Width: | Height: | Size: 164 B |
BIN
assets/std_tile.png
Normal file
|
After Width: | Height: | Size: 160 B |
BIN
assets/strawberry.png
Normal file
|
After Width: | Height: | Size: 601 B |
BIN
assets/strawberry_paintnet.png
Normal file
|
After Width: | Height: | Size: 546 B |
BIN
assets/tile_dirt.png
Normal file
|
After Width: | Height: | Size: 344 B |
BIN
assets/tile_empty.png
Normal file
|
After Width: | Height: | Size: 172 B |
BIN
assets/tile_error.png
Normal file
|
After Width: | Height: | Size: 284 B |
BIN
assets/tile_grass_1.png
Normal file
|
After Width: | Height: | Size: 308 B |
BIN
assets/tile_grass_2.png
Normal file
|
After Width: | Height: | Size: 427 B |
BIN
assets/tile_grass_ground_1.png
Normal file
|
After Width: | Height: | Size: 357 B |
|
Before Width: | Height: | Size: 4.0 KiB |
BIN
assets/tile_stone_ground.png
Normal file
|
After Width: | Height: | Size: 486 B |
|
Before Width: | Height: | Size: 4.0 KiB |
BIN
assets/tile_tall_grass.png
Normal file
|
After Width: | Height: | Size: 528 B |
BIN
assets/tile_water.png
Normal file
|
After Width: | Height: | Size: 295 B |
BIN
assets/tile_water_2.png
Normal file
|
After Width: | Height: | Size: 176 B |
34
src/main.cpp
@ -31,7 +31,7 @@ SDL_GPUShader *basic_vertex_shader;
|
|||||||
SDL_GPUShader *basic_pixel_shader;
|
SDL_GPUShader *basic_pixel_shader;
|
||||||
|
|
||||||
SDL_GPUGraphicsPipeline *basic_graphics_pipeline;
|
SDL_GPUGraphicsPipeline *basic_graphics_pipeline;
|
||||||
SDL_GPUSampler *trilinear_sampler;
|
SDL_GPUSampler *point_sampler;
|
||||||
|
|
||||||
SDL_GPUBuffer *vertex_buffer;
|
SDL_GPUBuffer *vertex_buffer;
|
||||||
SDL_GPUBuffer *index_buffer;
|
SDL_GPUBuffer *index_buffer;
|
||||||
@ -322,8 +322,7 @@ SDL_GPUTexture *create_shader_texture(const char *path) {
|
|||||||
|
|
||||||
SDL_GPUTextureFormat format = SDL_GPU_TEXTUREFORMAT_INVALID;
|
SDL_GPUTextureFormat format = SDL_GPU_TEXTUREFORMAT_INVALID;
|
||||||
if (channels == 1) format = SDL_GPU_TEXTUREFORMAT_A8_UNORM;
|
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) {
|
if (format == SDL_GPU_TEXTUREFORMAT_INVALID) {
|
||||||
log_error("Failed to find texture format for texture (\"%s\").", path);
|
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 = {
|
SDL_GPUTextureCreateInfo texture_info = {
|
||||||
.type = SDL_GPU_TEXTURETYPE_2D_ARRAY,
|
.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,
|
.usage = SDL_GPU_TEXTUREUSAGE_SAMPLER,
|
||||||
.width = (Uint32)width,
|
.width = (Uint32)width,
|
||||||
.height = (Uint32)height,
|
.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");
|
SDL_GPUTexture *player_texture = create_shader_texture_array(SDL_arraysize(player_texture_array), player_texture_array, "player_textures");
|
||||||
if (!player_texture) {
|
if (!player_texture) {
|
||||||
log_error("Failed to create shader texture. Exiting.");
|
log_error("Failed to create shader texture. Exiting.");
|
||||||
return 1;
|
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) {
|
if (!player_texture) {
|
||||||
log_error("Failed to create shader texture. Exiting.");
|
log_error("Failed to create shader texture. Exiting.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GPUTexture *glyph_texture = create_shader_texture("../assets/fonts/glyph_atlas_lexend.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" };
|
||||||
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" };
|
|
||||||
SDL_GPUTexture *tile_texture = create_shader_texture_array(SDL_arraysize(tile_texture_array), tile_texture_array, "tile_textures");
|
SDL_GPUTexture *tile_texture = create_shader_texture_array(SDL_arraysize(tile_texture_array), tile_texture_array, "tile_textures");
|
||||||
if (!player_texture) {
|
if (!player_texture) {
|
||||||
log_error("Failed to create shader texture array. Exiting.");
|
log_error("Failed to create shader texture array. Exiting.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GPUSamplerCreateInfo trilinear_sampler_info = {
|
SDL_GPUSamplerCreateInfo point_sampler_info = {
|
||||||
.min_filter = SDL_GPU_FILTER_LINEAR,
|
.min_filter = SDL_GPU_FILTER_NEAREST,
|
||||||
.mag_filter = SDL_GPU_FILTER_LINEAR,
|
.mag_filter = SDL_GPU_FILTER_NEAREST,
|
||||||
.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR,
|
.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST,
|
||||||
|
|
||||||
.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
|
.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
|
||||||
.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
|
.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
|
||||||
.address_mode_w = 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");
|
vertex_buffer = create_buffer(SDL_GPU_BUFFERUSAGE_VERTEX, sizeof(vertices), vertices, "vertex_buffer");
|
||||||
if (!vertex_buffer) {
|
if (!vertex_buffer) {
|
||||||
@ -960,7 +952,7 @@ int main(int argc, char **argv) {
|
|||||||
{ .buffer = tiles_instance_buffer, .offset = 0 },
|
{ .buffer = tiles_instance_buffer, .offset = 0 },
|
||||||
};
|
};
|
||||||
SDL_GPUTextureSamplerBinding texture_bindings[] = {
|
SDL_GPUTextureSamplerBinding texture_bindings[] = {
|
||||||
{ .texture = tile_texture, .sampler = trilinear_sampler },
|
{ .texture = tile_texture, .sampler = point_sampler },
|
||||||
};
|
};
|
||||||
|
|
||||||
SDL_BindGPUGraphicsPipeline(render_pass, basic_graphics_pipeline);
|
SDL_BindGPUGraphicsPipeline(render_pass, basic_graphics_pipeline);
|
||||||
@ -976,7 +968,7 @@ int main(int argc, char **argv) {
|
|||||||
{ .buffer = player_instance_buffer, .offset = 0 },
|
{ .buffer = player_instance_buffer, .offset = 0 },
|
||||||
};
|
};
|
||||||
SDL_GPUTextureSamplerBinding texture_bindings[] = {
|
SDL_GPUTextureSamplerBinding texture_bindings[] = {
|
||||||
{ .texture = player_texture, .sampler = trilinear_sampler },
|
{ .texture = player_texture, .sampler = point_sampler },
|
||||||
};
|
};
|
||||||
SDL_BindGPUGraphicsPipeline(render_pass, basic_graphics_pipeline);
|
SDL_BindGPUGraphicsPipeline(render_pass, basic_graphics_pipeline);
|
||||||
SDL_BindGPUVertexBuffers(render_pass, 0, vertex_buffers, SDL_arraysize(vertex_buffers));
|
SDL_BindGPUVertexBuffers(render_pass, 0, vertex_buffers, SDL_arraysize(vertex_buffers));
|
||||||
|
|||||||