]> git.mxchange.org Git - simgear.git/blob - simgear/scene/material/matlib.hxx
A real MSVC fix this time
[simgear.git] / simgear / scene / material / matlib.hxx
1 // matlib.hxx -- class to handle material properties
2 //
3 // Written by Curtis Olson, started May 1998.
4 //
5 // Copyright (C) 1998 - 2000  Curtis L. Olson  - curt@flightgear.org
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _MATLIB_HXX
25 #define _MATLIB_HXX
26
27
28 #ifndef __cplusplus                                                          
29 # error This library requires C++
30 #endif                                   
31
32 #include <simgear/compiler.h>
33
34 #include STL_STRING             // Standard C++ string library
35 #include <map>                  // STL associative "array"
36 #include <vector>               // STL "array"
37
38 #include <plib/ssg.h>           // plib include
39
40
41 class SGMaterial;
42
43 SG_USING_STD(string);
44 SG_USING_STD(map);
45 SG_USING_STD(vector);
46 SG_USING_STD(less);
47
48
49 // Material management class
50 class SGMaterialLib {
51
52 private:
53
54     // associative array of materials
55     typedef map < string, SGMaterial *, less<string> > material_map;
56     typedef material_map::iterator material_map_iterator;
57     typedef material_map::const_iterator const_material_map_iterator;
58
59     material_map matlib;
60
61 public:
62
63     // Constructor
64     SGMaterialLib ( void );
65
66     // Load a library of material properties
67     bool load( const string &fg_root, const string& mpath );
68
69     // Add the named texture with default properties
70     bool add_item( const string &tex_path );
71     bool add_item( const string &mat_name, const string &tex_path );
72     bool add_item( const string &mat_name, ssgSimpleState *state );
73
74     // find a material record by material name
75     SGMaterial *find( const string& material );
76
77     /**
78      * Load the next deferred texture, if there is any.
79      */
80     void load_next_deferred();
81
82     material_map_iterator begin() { return matlib.begin(); }
83     const_material_map_iterator begin() const { return matlib.begin(); }
84
85     material_map_iterator end() { return matlib.end(); }
86     const_material_map_iterator end() const { return matlib.end(); }
87
88     // Destructor
89     ~SGMaterialLib ( void );
90 };
91
92
93 #endif // _MATLIB_HXX