1
0
Fork 0

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:
curt 1999-05-13 19:01:29 +00:00
parent 8407c3f47b
commit 91c20a18fc
2 changed files with 15 additions and 16 deletions

View file

@ -127,12 +127,10 @@ FGMaterial::load_texture( const string& root )
#endif #endif
// set the texture parameters for this texture // 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_S, GL_REPEAT ) ;
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) ; xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) ;
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
GL_LINEAR );
// xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
// GL_NEAREST_MIPMAP_NEAREST );
xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
/* GL_LINEAR */ /* GL_LINEAR */
/* GL_NEAREST_MIPMAP_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)) read_r8_texture(fg_oav_tpath.c_str(), &width, &height))
!= NULL ) != NULL )
; ;
else else {
{
FG_LOG( FG_GENERAL, FG_ALERT, FG_LOG( FG_GENERAL, FG_ALERT,
"Error in loading texture " << tpath.str() ); "Error in loading texture " << tpath.str() );
exit(-1); exit(-1);
} }
/* xglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, if ( gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, width, height,
GL_RGB, GL_UNSIGNED_BYTE, texbuf); */ GL_RGB, GL_UNSIGNED_BYTE, texbuf ) != 0 )
FG_LOG( FG_GENERAL, FG_ALERT, "Error building mipmaps");
gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, width, height, exit(-1);
GL_RGB, GL_UNSIGNED_BYTE, texbuf ); }
} else if ( alpha == 1 ) { } else if ( alpha == 1 ) {
// load rgba (alpha) texture // load rgba (alpha) texture

View file

@ -249,7 +249,9 @@ int fgObjLoad( const string& path, fgTILE *t) {
FGMaterial m = fragment.material_ptr->get_m(); FGMaterial m = fragment.material_ptr->get_m();
tex_width = m.get_xsize(); tex_width = m.get_xsize();
tex_height = m.get_ysize(); 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 // initialize the fragment transformation matrix
/* /*
for ( i = 0; i < 16; i++ ) { for ( i = 0; i < 16; i++ ) {