fixed windoof flip-problem;

git-svn-id: svn://ammerhai.com/home/mike/pokemon_repo@5 24008968-59e6-ed4c-a10b-0b2c954b24ab
This commit is contained in:
mikeb 2021-02-25 15:21:21 +00:00
parent 7a8abc6af9
commit c337d52774
6 changed files with 22 additions and 6 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -85,6 +85,13 @@ struct TGA_Image_Specification {
uint8_t image_descriptor; 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) { BMP_Texture load_tga_file(const char* path) {
auto file = load_entire_file(path); auto file = load_entire_file(path);
auto start_file = file; auto start_file = file;
@ -110,7 +117,10 @@ BMP_Texture load_tga_file(const char* path) {
auto descriptor_mask = 0x30; auto descriptor_mask = 0x30;
auto image_origin = image_specification.image_descriptor & descriptor_mask; 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 //TODO: y-achse flippen, weil microsoft, spaeter beide faelle implementieren
advance(file, id_length); 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 };
}

View File

@ -53,8 +53,8 @@ ID3D11PixelShader* pixel_shader;
bool Running = true; bool Running = true;
// //
#define view_width 16 #define view_width 17
#define view_height 12 #define view_height 13
struct Vertex { struct Vertex {
V4 pos; V4 pos;
@ -427,7 +427,7 @@ int main() {
} }
ID3D11ShaderResourceView* player_texture = 0; 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."); log_error("CreateShaderTexture has failed.");
return 1; return 1;
} }