]> git.mxchange.org Git - flightgear.git/blobdiff - Objects/material.cxx
Converted to new logstream debugging facility. This allows release
[flightgear.git] / Objects / material.cxx
index a921dc7ecd75bbaa0d1e0f9f8fa8e8f1977cd830..a2dc6543e7f7f825bbd9e4ebd2b7a04473344e6a 100644 (file)
@@ -37,7 +37,7 @@
 #include <string>
 
 #include "Include/fg_stl_config.h"
-#include <Debug/fg_debug.h>
+#include <Debug/logstream.hxx>
 #include <Main/options.hxx>
 #include <Misc/fgstream.hxx>
 #include <Main/views.hxx>
@@ -55,8 +55,8 @@ fgMATERIAL_MGR material_mgr;
 // Constructor
 fgMATERIAL::fgMATERIAL ( void )
     : texture_name(""),
-      alpha(0),
-      list_size(0)
+      alpha(0)
+      // , list_size(0)
 {
     ambient[0]  = ambient[1]  = ambient[2]  = ambient[3]  = 0.0;
     diffuse[0]  = diffuse[1]  = diffuse[2]  = diffuse[3]  = 0.0;
@@ -64,7 +64,7 @@ fgMATERIAL::fgMATERIAL ( void )
     emissive[0] = emissive[1] = emissive[2] = emissive[3] = 0.0;
 }
 
-
+/*
 int
 fgMATERIAL::append_sort_list( fgFRAGMENT *object )
 {
@@ -75,6 +75,7 @@ fgMATERIAL::append_sort_list( fgFRAGMENT *object )
        return 0;
     }
 }
+*/
 
 istream&
 operator >> ( istream& in, fgMATERIAL& m )
@@ -116,8 +117,7 @@ operator >> ( istream& in, fgMATERIAL& m )
                m.alpha = 0;
            else
            {
-               fgPrintf( FG_TERRAIN, FG_INFO,
-                         "Bad alpha value '%s'\n", token.c_str() );
+               FG_LOG( FG_TERRAIN, FG_INFO, "Bad alpha value " << token );
            }
        }
        else if ( token[0] == '}' )
@@ -176,10 +176,9 @@ fgMATERIAL::load_texture()
                      read_rgb_texture(fg_tpath.c_str(), &width, &height)) 
                     == NULL )
                {
-                   fgPrintf( FG_GENERAL, FG_EXIT, 
-                             "Error in loading texture %s\n", 
-                             tpath.c_str() );
-                   return;
+                   FG_LOG( FG_GENERAL, FG_ALERT, 
+                           "Error in loading texture " << tpath );
+                   exit(-1);
                } 
            } 
 
@@ -201,10 +200,9 @@ fgMATERIAL::load_texture()
                     read_alpha_texture(fg_tpath.c_str(), &width, &height))
                    == NULL )
                {
-                   fgPrintf( FG_GENERAL, FG_EXIT, 
-                             "Error in loading texture %s\n",
-                             tpath.c_str() );
-                   return;
+                   FG_LOG( FG_GENERAL, FG_ALERT, 
+                           "Error in loading texture " << tpath );
+                   exit(-1);
                } 
            } 
 
@@ -248,9 +246,11 @@ fgMATERIAL::render_fragments()
     }
 
     fgTILE* last_tile_ptr = NULL;
-    for ( size_t i = 0; i < list_size; ++i )
-    {
-       fgFRAGMENT* frag_ptr = list[i];
+    frag_list_iterator current = list.begin();
+    frag_list_iterator last = list.end();
+
+    for ( ; current != last; ++current ) {
+       fgFRAGMENT* frag_ptr = *current;
        current_view.tris_rendered += frag_ptr->num_faces();
        if ( frag_ptr->tile_ptr != last_tile_ptr )
        {
@@ -275,26 +275,27 @@ fgMATERIAL_MGR::load_lib ( void )
     // build the path name to the material db
     string mpath = current_options.get_fg_root() + "/materials";
     fg_gzifstream in( mpath );
-    if ( ! in )
-       fgPrintf( FG_GENERAL, FG_EXIT, "Cannot open file: %s\n", 
-                 mpath.c_str() );
+    if ( ! in ) {
+       FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << mpath );
+       exit(-1);
+    }
 
     while ( ! in.eof() ) {
         // printf("%s", line);
 
        // strip leading white space and comments
-       in.eat_comments();
+       in >> skipcomment;
 
        // set to zero to prevent its value accidently being '{'
        // after a failed >> operation.
        char token = 0;
 
-       in.stream() >> material_name >> token;
+       in >> material_name >> token;
 
        if ( token == '{' ) {
            printf( "  Loading material %s\n", material_name.c_str() );
            fgMATERIAL m;
-           in.stream() >> m;
+           in >> m;
 
            if ( current_options.get_textures() ) {
                m.load_texture();
@@ -354,6 +355,17 @@ fgMATERIAL_MGR::render_fragments()
 
 
 // $Log$
+// Revision 1.10  1998/11/06 21:18:17  curt
+// Converted to new logstream debugging facility.  This allows release
+// builds with no messages at all (and no performance impact) by using
+// the -DFG_NDEBUG flag.
+//
+// Revision 1.9  1998/11/06 14:47:05  curt
+// Changes to track Bernie's updates to fgstream.
+//
+// Revision 1.8  1998/10/12 23:49:17  curt
+// Changes from NHV to make the code more dynamic with fewer hard coded limits.
+//
 // Revision 1.7  1998/09/17 18:35:52  curt
 // Tweaks and optimizations by Norman Vine.
 //