[Plib-cvs] plib/src/ssg ssgLoadMDL_BGLTexture.cxx,1.2,1.3 ssgLoadBGL.cxx,1.2,1.3 ssgDList.cxx,1.9,1.
Brought to you by:
sjbaker
From: J?rgen M. <j_m...@us...> - 2002-06-09 11:29:57
|
Update of /cvsroot/plib/plib/src/ssg In directory usw-pr-cvs1:/tmp/cvs-serv9372/src/ssg Modified Files: ssgDList.cxx ssgLoadBMP.cxx ssgLoadMDL.cxx ssgLoadMDL.h ssgconf.h Added Files: ssgLoadMDL_BGLTexture.cxx ssgLoadBGL.cxx Log Message: BGL Loader added; should complie now under MSVC Index: ssgDList.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssgDList.cxx,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- ssgDList.cxx 8 Jun 2002 22:49:07 -0000 1.9 +++ ssgDList.cxx 9 Jun 2002 11:29:54 -0000 1.10 @@ -125,7 +125,8 @@ } ; -#define MAX_DLIST 4096 +#define MAX_DLIST 8192 +//4096 //2048 static int next_dlist = 0 ; Index: ssgLoadBMP.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssgLoadBMP.cxx,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- ssgLoadBMP.cxx 8 Jun 2002 22:49:08 -0000 1.12 +++ ssgLoadBMP.cxx 9 Jun 2002 11:29:54 -0000 1.13 @@ -123,6 +123,8 @@ bool ssgLoadBMP ( const char *fname, ssgTextureInfo* info ) { int w, h, bpp ; + int index=0; + bool old_format = false; RGBA pal [ 256 ] ; BMPHeader bmphdr ; @@ -133,9 +135,25 @@ if ( ( curr_image_fd = fopen ( curr_image_fname, "rb" ) ) == NULL ) { - perror ( "ssgLoadTexture" ) ; - ulSetError ( UL_WARNING, "ssgLoadTexture: Failed to open '%s' for reading.", curr_image_fname ) ; - return false ; + char *p = strrchr(curr_image_fname,'_'); + if (p != 0) { + *p = '\0'; + p++; + index = atoi (p); + old_format = true; + if ( ( curr_image_fd = fopen(curr_image_fname, "rb")) == NULL) { + perror ( "ssgLoadTexture" ) ; + ulSetError( UL_WARNING, "ssgLoadTexture: Failed to load '%s' for reading.", curr_image_fname ); + return false ; + } + p--; + *p = '_'; + } + else { + perror ( "ssgLoadTexture" ) ; + ulSetError( UL_WARNING, "ssgLoadTexture: Failed to open '%s' for reading.", curr_image_fname ); + return false ; + } } /* @@ -210,7 +228,10 @@ /* According to BMP specs, this fourth value is not really alpha value but just a filler byte, so it is ignored for now. */ pal[i].a = readByte () ; - //if ( pal[i].a != 255 ) isOpaque = FALSE ; + if (old_format == true) { + pal[i].a = (i<index)?0:255; + + } if ( pal[i].r != pal[i].g || pal[i].g != pal[i].b ) isMonochrome = FALSE ; @@ -243,6 +264,15 @@ if ( bpp == 8 ) { + // check for diffrent alpha values in the bitmap + // assume blending if that's the case + for ( int i = 1 ; i < w * h ; i++ ) { + if (pal[data[i]].a != pal[data[i-1]].a) { + isOpaque = FALSE ; + break; + } + } + if ( isMonochrome ) z = isOpaque ? 1 : 2 ; else @@ -309,7 +339,7 @@ info -> width = w ; info -> height = h ; info -> depth = z ; - info -> alpha = ( z == 4 ) ; + info -> alpha = ( isOpaque == FALSE ) ; } return ssgMakeMipMaps ( image, w, h, z ) ; Index: ssgLoadMDL.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssgLoadMDL.cxx,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- ssgLoadMDL.cxx 8 Jun 2002 22:49:08 -0000 1.37 +++ ssgLoadMDL.cxx 9 Jun 2002 11:29:54 -0000 1.38 @@ -42,7 +42,6 @@ #ifdef SSG_LOAD_MDL_SUPPORTED #include "ssgLoadMDL.h" -#include "ssgMSFSPalette.h" #define DEF_SHININESS 50 @@ -1477,65 +1476,11 @@ delete curr_norm_; DEBUGPRINT("\n" << vertex_array_->getNum() << " vertices\n"); - - return model_; -} -// This really simple (raw paletted) format is used by older MSFS for textures -bool ssgLoadMDLTexture ( const char *fname, ssgTextureInfo* info ) -{ - FILE *tfile; - if ( (tfile = fopen(fname, "rb")) == NULL) { - ulSetError( UL_WARNING, "ssgLoadTexture: Failed to load '%s'.", fname ); - return false ; - } - - fseek(tfile, 0, SEEK_END); - unsigned long file_length = ftell(tfile); - - if (file_length != 65536) { - // this is not a MSFS-formatted texture, so it's probably a BMP - fclose(tfile); - return ssgLoadBMP( fname, info ); - } else { - fseek(tfile, 0, SEEK_SET); - - unsigned char *texels = new unsigned char[256 * 256 * 4]; - int c = 0; - for (int y = 0; y < 256; y++) { - for (int x = 0; x < 256; x++) { - unsigned char b; - fread(&b, 1, 1, tfile); - texels[c++] = fsTexPalette[b*4 ]; - texels[c++] = fsTexPalette[b*4 + 1]; - texels[c++] = fsTexPalette[b*4 + 2]; - texels[c++] = fsTexPalette[b*4 + 3]; - } - } - - fclose(tfile); - - if ( info != NULL ) - { - info -> width = 256 ; - info -> height = 256 ; - info -> depth = 4 ; - info -> alpha = FALSE ; //?? - } - - return ssgMakeMipMaps ( texels, 256, 256, 4 ) ; - } + return model_; } - #else - - -ssgEntity *ssgLoadMDL(const char *fname, const ssgLoaderOptions *options) -{ - return NULL ; -} - bool ssgLoadMDLTexture ( const char *fname, ssgTextureInfo* info ) { Index: ssgLoadMDL.h =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssgLoadMDL.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ssgLoadMDL.h 8 Jun 2002 22:49:08 -0000 1.6 +++ ssgLoadMDL.h 9 Jun 2002 11:29:54 -0000 1.7 @@ -240,262 +240,262 @@ }; static const _ssgBGLOpCode opcodes[] = { - { 0x00, "BGL_EOF" , 2 }, - { 0x01, "OBSOLETE 0x01" , 2 }, - { 0x02, "BGL_NOOP" , 2 }, - { 0x03, "BGL_CASE" , -1 }, - { 0x04, "RESERVED 0x04" , 2 }, - { 0x05, "BGL_SURFACE" , 2 }, - { 0x06, "BGL_SPNT" , 8 }, - { 0x07, "BGL_CPNT" , 8 }, [...487 lines suppressed...] + { 0xef, "UNKNOWN 0xEF" , -1 }, + { 0xf0, "UNKNOWN 0xF0" , -1 }, + { 0xf1, "UNKNOWN 0xF1" , -1 }, + { 0xf2, "UNKNOWN 0xF2" , -1 }, + { 0xf3, "UNKNOWN 0xF3" , -1 }, + { 0xf4, "UNKNOWN 0xF4" , -1 }, + { 0xf5, "UNKNOWN 0xF5" , -1 }, + { 0xf6, "UNKNOWN 0xF6" , -1 }, + { 0xf7, "UNKNOWN 0xF7" , -1 }, + { 0xf8, "UNKNOWN 0xF8" , -1 }, + { 0xf9, "UNKNOWN 0xF9" , -1 }, + { 0xfa, "UNKNOWN 0xFA" , -1 }, + { 0xfb, "UNKNOWN 0xFB" , -1 }, + { 0xfc, "UNKNOWN 0xFC" , -1 }, + { 0xfd, "UNKNOWN 0xFD" , -1 }, + { 0xfe, "UNKNOWN 0xFE" , -1 }, + { 0xff, "UNKNOWN 0xFF" , -1 } }; //=========================================================================== Index: ssgconf.h =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssgconf.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- ssgconf.h 8 Jun 2002 22:49:08 -0000 1.7 +++ ssgconf.h 9 Jun 2002 11:29:54 -0000 1.8 @@ -49,5 +49,6 @@ #define SSG_LOAD_TGA_SUPPORTED #define SSG_LOAD_BMP_SUPPORTED #define SSG_LOAD_MDL_SUPPORTED - +#define SSG_LOAD_BGL_SUPPORTED +#define SSG_LOAD_MDL_BGL_TEXTURE_SUPPORTED #endif |