]> git.mxchange.org Git - flightgear.git/blob - Simulator/Objects/material.hxx
Updated for 0.6.2
[flightgear.git] / Simulator / Objects / 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
23
24 #ifndef _MATERIAL_HXX
25 #define _MATERIAL_HXX
26
27
28 #ifndef __cplusplus                                                          
29 # error This library requires C++
30 #endif                                   
31
32 #ifdef HAVE_CONFIG_H
33 #  include <config.h>
34 #endif
35
36 #ifdef HAVE_WINDOWS_H
37 #  include <windows.h>
38 #endif
39
40 #include "Include/compiler.h"
41
42 #include <GL/glut.h>
43 #include <XGL/xgl.h>
44
45 #include STL_STRING      // Standard C++ string library
46
47 FG_USING_STD(string);
48
49
50 // MSVC++ 6.0 kuldge - Need forward declaration of friends.
51 class fgMATERIAL;
52 istream& operator >> ( istream& in, fgMATERIAL& m );
53
54 // Material property class
55 class FGMaterial {
56
57 private:
58     // texture loaded
59     bool loaded;
60
61     // OpenGL texture name
62     GLuint texture_id;
63
64     // file name of texture
65     string texture_name;
66
67     // alpha texture?
68     int alpha;
69
70     // texture size
71     double xsize, ysize;
72
73     // material properties
74     GLfloat ambient[4], diffuse[4], specular[4], emissive[4];
75     GLint texture_ptr;
76
77 public:
78
79     // Constructor
80     FGMaterial ( void );
81
82     // Destructor
83     ~FGMaterial ( void );
84
85     void load_texture( const string& root );
86
87     friend istream& operator >> ( istream& in, FGMaterial& m );
88
89     inline bool is_loaded() const { return loaded; }
90     inline GLuint get_texture_id() const { return texture_id; }
91     inline double get_xsize() const { return xsize; }
92     inline double get_ysize() const { return ysize; }
93     inline GLfloat *get_ambient() { return ambient; }
94     inline GLfloat *get_diffuse() { return diffuse; }
95     inline GLfloat *get_specular() { return specular; }
96     inline GLfloat *get_emissive() { return emissive; }
97
98 };
99
100
101 #endif // _MATERIAL_HXX 
102
103