mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
static linking, largeaddressaware, basic tga texture downsampling
This commit is contained in:
33
Texture.cpp
33
Texture.cpp
@@ -480,6 +480,14 @@ opengl_texture::load_TGA() {
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
// before it gets all work done
|
||||
data_state = resource_state::failed;
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: add horizontal/vertical data flip, based on the descriptor (18th) header byte
|
||||
|
||||
// fill remaining data info
|
||||
@@ -656,6 +664,31 @@ opengl_texture::set_filtering() {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
opengl_texture::downsize( GLuint const Format ) {
|
||||
|
||||
while( ( data_width > Global::iMaxTextureSize ) || ( data_height > Global::iMaxTextureSize ) ) {
|
||||
// scale down the base texture, if it's larger than allowed maximum
|
||||
// NOTE: scaling is uniform along both axes, meaning non-square textures can drop below the maximum
|
||||
// TODO: replace with proper scaling function once we have image middleware in place
|
||||
if( ( data_width < 2 ) || ( data_height < 2 ) ) {
|
||||
// can't go any smaller
|
||||
break;
|
||||
}
|
||||
|
||||
switch( Format ) {
|
||||
|
||||
case GL_RGB: { downsample< glm::tvec3<std::uint8_t> >( data_width, data_height, data.data() ); break; }
|
||||
case GL_BGRA:
|
||||
case GL_RGBA: { downsample< glm::tvec4<std::uint8_t> >( data_width, data_height, data.data() ); break; }
|
||||
default: { break; }
|
||||
}
|
||||
data_width /= 2;
|
||||
data_height /= 2;
|
||||
data.resize( data.size() / 4 ); // not strictly needed, but, eh
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
texture_manager::Init() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user