]> git.mxchange.org Git - flightgear.git/blob - Scenery/material.hxx
Incremental additions to material.cxx (not fully functional)
[flightgear.git] / Scenery / material.hxx
1 // material.hxx -- class to handle material properties
2 //
3 // Written by Curtis Olson, started May 1998.
4 //
5 // Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
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 // (Log is kept at end of this file)
23
24
25 #ifndef _MATERIAL_HXX
26 #define _MATERIAL_HXX
27
28
29 #ifndef __cplusplus                                                          
30 # error This library requires C++
31 #endif                                   
32
33 #ifdef HAVE_CONFIG_H
34 #  include <config.h>
35 #endif
36
37 #ifdef HAVE_WINDOWS_H
38 #  include <windows.h>
39 #endif
40
41 #include <GL/glut.h>
42 #include <XGL/xgl.h>
43
44 #include <map.h>           // STL associative "array"
45
46 #if defined(__CYGWIN32__)
47 #  include <string>        // Standard C++ string library
48 #elif defined(WIN32)
49 #  include <string.h>      // Standard C++ string library
50 #else
51 #  include <std/string.h>  // Standard C++ string library
52 #endif
53
54 #include "tile.hxx"
55
56
57 #define FG_MAX_MATERIAL_FRAGS 100
58
59
60 // Material property class
61 class fgMATERIAL {
62
63 public:
64
65     // material properties
66     GLfloat ambient[4], diffuse[4], specular[4];
67     GLint texture_ptr;
68
69     // transient list of objects with this material type (used for sorting
70     // by material to reduce GL state changes when rendering the scene
71     fgFRAGMENT * list[FG_MAX_MATERIAL_FRAGS];
72     int list_size;
73
74     // Constructor
75     fgMATERIAL ( void );
76
77     // Sorting routines
78     void init_sort_list( void );
79     int append_sort_list( fgFRAGMENT *object );
80
81     // Destructor
82     ~fgMATERIAL ( void );
83 };
84
85
86 // Material management class
87 class fgMATERIAL_MGR {
88
89 public:
90
91     // associative array of materials
92     map < string, fgMATERIAL, less<string> > materials;
93
94     // Constructor
95     fgMATERIAL_MGR ( void );
96
97     // Load a library of material properties
98     int load_lib ( void );
99
100     // Destructor
101     ~fgMATERIAL_MGR ( void );
102 };
103
104
105 #endif // _MATERIAL_HXX 
106
107
108 // $Log$
109 // Revision 1.2  1998/06/01 17:56:20  curt
110 // Incremental additions to material.cxx (not fully functional)
111 // Tweaked vfc_ratio math to avoid divide by zero.
112 //
113 // Revision 1.1  1998/05/30 01:56:45  curt
114 // Added material.cxx material.hxx
115 //