Re: [Plib-devel] Texture loading problems (bmp/rgb)
Brought to you by:
sjbaker
From: Jan R. <slo...@gm...> - 2006-11-20 19:35:48
|
Am Sun, 19 Nov 2006 18:12:49 +0100 schrieb p.l...@ci...: > Scrive Jan Reucker <slo...@gm...>: > > > Am Sun, 19 Nov 2006 09:47:37 +0100 schrieb p.l...@ci...: > > > > > I also use BMP along with the 3DS loader and it works fine (the loader > > manages > > > the y-flipping so to resemble the other serious image format habit). > > > > Hmm, as far as I could see in the BMP loader source code it *always* > > flips the image. So it might depend on the program that you create > > the BMP's with if the texture loads correctly. > > No, it doesn't - look at the ssgLoad3ds.cxx code off the SVN: > > line 891: > /* flip textures y-coord if texture is a BMP */ > char *texture_extension = > material->tex_name + strlen(material->tex_name) - 3; > > flip_texture_y = ulStrEqual( texture_extension, "BMP" ); Hello Paolo, I was just referring to the BMP loader (ssgLoadBMP.cxx, line 246): /* read and flip image */ { int row_size = w * (bpp / 8) ; for ( int y = h-1 ; y >= 0 ; y-- ) { GLubyte *row_ptr = &data [ y * row_size ] ; if ( fread ( row_ptr, 1, row_size, curr_image_fd ) != (unsigned)row_size ) { ulSetError ( UL_WARNING, "Premature EOF in '%s'", curr_image_fname ) ; return false ; } } } So this loader code *always* flips the image, and the 3ds model loader *always* flips it back. Does this make sense? No. And other model loaders don't do this. If I model something in AC3D using a bmp texture and then load it into an SSG application, the texture is always flipped while it looks right in AC3D. And if I export the model from AC3D to the 3ds format it loads correctly in SSG! This is definitely inconsistent, and I'd highly recommend to fix this behaviour. IMHO it would make sense to remove the pixel row flipping from ssgLoadBMP.cxx AND the texture flipping code from ssgLoad3ds.cxx. I'm willing to do this fix and submit a patch. But if someone can dig up a document describing the full details of BMP, especially regarding pixel row orientation, this would definitely help in this discussion. The documents on wotsit.org didn't help me much. Kind regards, Jan R. -- Jan Reucker email: jan dot reucker at web dot de web: http://www.reucker-online.de |