mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
build 180202. tga texture origin bit recognition, audio file load failure crash fix, cab controls positioning fix,
This commit is contained in:
21
Texture.cpp
21
Texture.cpp
@@ -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 ) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user