build 180202. tga texture origin bit recognition, audio file load failure crash fix, cab controls positioning fix,

This commit is contained in:
tmj-fstate
2018-02-02 15:49:13 +01:00
parent 23761dc665
commit b3e7b88bbc
11 changed files with 115 additions and 131 deletions

View File

@@ -484,6 +484,12 @@ opengl_texture::load_TGA() {
return;
}
if( ( tgaheader[ 17 ] & 0x20 ) != 0 ) {
// normally origin is bottom-left
// if byte 17 bit 5 is set, it is top-left and needs flip
flip_vertical();
}
downsize( GL_BGRA );
if( ( data_width > Global.iMaxTextureSize ) || ( data_height > Global.iMaxTextureSize ) ) {
// for non-square textures there's currently possibility the scaling routine will have to abort
@@ -702,6 +708,21 @@ opengl_texture::downsize( GLuint const Format ) {
};
}
void
opengl_texture::flip_vertical() {
auto const swapsize { data_width * 4 };
auto destination { data.begin() + ( data_height - 1 ) * swapsize };
auto sampler { data.begin() };
for( auto row = 0; row < data_height / 2; ++row ) {
std::swap_ranges( sampler, sampler + swapsize, destination );
sampler += swapsize;
destination -= swapsize;
}
}
void
texture_manager::assign_units( GLint const Helper, GLint const Shadows, GLint const Normals, GLint const Diffuse ) {