From 91c20a18fc83950373d7afe5e298125faf2b354d Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 13 May 1999 19:01:29 +0000 Subject: [PATCH] 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. --- Simulator/Objects/material.cxx | 27 ++++++++++++--------------- Simulator/Objects/obj.cxx | 4 +++- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Simulator/Objects/material.cxx b/Simulator/Objects/material.cxx index 0f1a2e0a8..98ae62864 100644 --- a/Simulator/Objects/material.cxx +++ b/Simulator/Objects/material.cxx @@ -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 diff --git a/Simulator/Objects/obj.cxx b/Simulator/Objects/obj.cxx index cb9e379f7..6ac92a53d 100644 --- a/Simulator/Objects/obj.cxx +++ b/Simulator/Objects/obj.cxx @@ -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++ ) {