Fixed a problem with texture loading and mipmap building where the lower
mipmap levels were coming out hosed. Adding a call to xglPixelStorei(GL_UNPACK_ALIGNMENT, 4); restores it to the default setting which was getting set to something else in other parts of the code.
This commit is contained in:
parent
8407c3f47b
commit
91c20a18fc
2 changed files with 15 additions and 16 deletions
|
@ -127,12 +127,10 @@ FGMaterial::load_texture( const string& root )
|
|||
#endif
|
||||
|
||||
// set the texture parameters for this texture
|
||||
xglPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ) ;
|
||||
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) ;
|
||||
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
GL_LINEAR );
|
||||
// xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
// GL_NEAREST_MIPMAP_NEAREST );
|
||||
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
/* GL_LINEAR */
|
||||
/* GL_NEAREST_MIPMAP_LINEAR */
|
||||
|
@ -203,18 +201,17 @@ FGMaterial::load_texture( const string& root )
|
|||
read_r8_texture(fg_oav_tpath.c_str(), &width, &height))
|
||||
!= NULL )
|
||||
;
|
||||
else
|
||||
{
|
||||
FG_LOG( FG_GENERAL, FG_ALERT,
|
||||
"Error in loading texture " << tpath.str() );
|
||||
exit(-1);
|
||||
}
|
||||
else {
|
||||
FG_LOG( FG_GENERAL, FG_ALERT,
|
||||
"Error in loading texture " << tpath.str() );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* xglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, texbuf); */
|
||||
|
||||
gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, width, height,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, texbuf );
|
||||
if ( gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, width, height,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, texbuf ) != 0 )
|
||||
FG_LOG( FG_GENERAL, FG_ALERT, "Error building mipmaps");
|
||||
exit(-1);
|
||||
}
|
||||
} else if ( alpha == 1 ) {
|
||||
// load rgba (alpha) texture
|
||||
|
||||
|
|
|
@ -249,7 +249,9 @@ int fgObjLoad( const string& path, fgTILE *t) {
|
|||
FGMaterial m = fragment.material_ptr->get_m();
|
||||
tex_width = m.get_xsize();
|
||||
tex_height = m.get_ysize();
|
||||
cout << "(w) = " << tex_width << " (h) = " << tex_width << endl;
|
||||
// cout << "(w) = " << tex_width << " (h) = "
|
||||
// << tex_width << endl;
|
||||
|
||||
// initialize the fragment transformation matrix
|
||||
/*
|
||||
for ( i = 0; i < 16; i++ ) {
|
||||
|
|
Loading…
Reference in a new issue