00001 /* -*- C++ -*- */ 00002 00003 /* COPYRIGHT 00004 * 00005 * This file is part of the Visual Effects Engine - VEE 00006 * 00007 * Read the "VEE-LICENSE" file for the license. 00008 * 00009 * Authors & Copyright: 00010 * 00011 * Tommi Ilmonen, Tuukka Heikura, Marko Myllymaa and 00012 * Janne Kontkanen 2001-2004 00013 * 00014 * Additional copyrights: Tekes 2003-2004 00015 * 00016 * firstname.lastname@hut.fi 00017 * 00018 */ 00019 00020 #ifndef _VEE_GL_MATERIAL_H_ 00021 #define _VEE_GL_MATERIAL_H_ 00022 00023 #include <GL/gl.h> 00024 00025 #include <map> 00026 // #include <string> 00027 00028 class VEE_GlMaterial 00029 { 00030 public: 00031 00032 enum Flag { 00033 BLEND = 0x1 00034 }; 00035 00036 VEE_GlMaterial(GLuint texId = (GLuint) -1, int flags = BLEND) 00037 : m_textureId(texId), m_flags(flags) {} 00038 00039 ~VEE_GlMaterial() {} 00040 00041 bool hasTexture() const { return m_textureId != (GLuint) -1; } 00042 00043 GLuint textureId() const { return m_textureId; } 00044 00045 void useTexture() const 00046 { 00047 if(m_textureId == (GLuint) -1) 00048 glDisable(GL_TEXTURE_2D); 00049 else { 00050 glBindTexture(GL_TEXTURE_2D, m_textureId); 00051 glEnable(GL_TEXTURE_2D); 00052 } 00053 } 00054 00055 int flags() const { return m_flags; } 00056 00057 protected: 00058 GLuint m_textureId; 00059 int m_flags; 00060 }; 00061 00064 00066 class VEE_GlMaterialBank 00067 { 00068 public: 00069 VEE_GlMaterialBank() {} 00070 ~VEE_GlMaterialBank() {} 00071 00072 void addMaterial(int, const VEE_GlMaterial &); 00073 00074 const VEE_GlMaterial & getMaterial(int); 00075 00076 static void setDefaultMaterial(const VEE_GlMaterial &m) 00077 { m_default = m; } 00078 00079 protected: 00080 00081 static VEE_GlMaterial m_default; 00082 00083 std::map<int, VEE_GlMaterial> m_materials; 00084 }; 00085 00086 #endif