diff --git a/assets/std_tile.tga b/assets/std_tile.tga index 8adfc43..ed5d815 100644 Binary files a/assets/std_tile.tga and b/assets/std_tile.tga differ diff --git a/assets/strawberry.tga b/assets/strawberry.tga index 38a5641..4f57135 100644 Binary files a/assets/strawberry.tga and b/assets/strawberry.tga differ diff --git a/bin/pokemon.exe b/bin/pokemon.exe index bd8ad54..7a94c8d 100644 Binary files a/bin/pokemon.exe and b/bin/pokemon.exe differ diff --git a/bin/pokemon.pdb b/bin/pokemon.pdb index 7900470..e198050 100644 Binary files a/bin/pokemon.pdb and b/bin/pokemon.pdb differ diff --git a/src/load_tga_file.cpp b/src/load_tga_file.cpp index 12b32a4..cba17eb 100644 --- a/src/load_tga_file.cpp +++ b/src/load_tga_file.cpp @@ -85,6 +85,13 @@ struct TGA_Image_Specification { uint8_t image_descriptor; }; +void swap(uint32_t& a, uint32_t& b) { + uint32_t h; + h = a; + a = b; + b = h; +} + BMP_Texture load_tga_file(const char* path) { auto file = load_entire_file(path); auto start_file = file; @@ -110,7 +117,10 @@ BMP_Texture load_tga_file(const char* path) { auto descriptor_mask = 0x30; auto image_origin = image_specification.image_descriptor & descriptor_mask; - expect(image_origin, 0, "wrong image origin"); + if (image_origin != 0 && image_origin != 32) { + log_error("wrong image origin"); + return{ 0, 0 }; + } //TODO: y-achse flippen, weil microsoft, spaeter beide faelle implementieren advance(file, id_length); @@ -149,6 +159,12 @@ BMP_Texture load_tga_file(const char* path) { } } - return { image_specification.width, image_specification.height, start_pixel }; -} + if (image_origin == 32) { + for (int y = 0; y < (image_specification.height / 2); y++) { + for (int x = 0; x < image_specification.width; x++) + swap(start_pixel[y * image_specification.width + x], start_pixel[image_specification.width * (image_specification.height - y - 1) + x]); + } + } + return { image_specification.width, image_specification.height, start_pixel }; +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 5c50006..da277aa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -53,8 +53,8 @@ ID3D11PixelShader* pixel_shader; bool Running = true; // -#define view_width 16 -#define view_height 12 +#define view_width 17 +#define view_height 13 struct Vertex { V4 pos; @@ -427,7 +427,7 @@ int main() { } ID3D11ShaderResourceView* player_texture = 0; - if (!(player_texture = create_shader_texture("../assets/strawberry_paintnet.tga"))) { + if (!(player_texture = create_shader_texture("../assets/strawberry.tga"))) { log_error("CreateShaderTexture has failed."); return 1; }