00001 /********************************************************************** 00002 * solid_color.C 00003 **********************************************************************/ 00004 00005 #include "solid_color.H" 00006 00007 /********************************************************************** 00008 * SolidColorTexture: 00009 **********************************************************************/ 00010 00011 TAGlist* SolidColorTexture::_solid_color_texture_tags = NULL; 00012 00013 CTAGlist & 00014 SolidColorTexture::tags() const 00015 { 00016 if (!_solid_color_texture_tags) { 00017 _solid_color_texture_tags = new TAGlist; 00018 00019 *_solid_color_texture_tags += OGLTexture::tags(); 00020 00021 *_solid_color_texture_tags += new TAG_val<SolidColorTexture,COLOR>( 00022 "color", 00023 &SolidColorTexture::color_); 00024 } 00025 return *_solid_color_texture_tags; 00026 } 00027 int 00028 SolidColorTexture::draw(CVIEWptr& v) 00029 { 00030 if (_ctrl) 00031 return _ctrl->draw(v); 00032 00033 // push GL state before changing things 00034 glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT); 00035 00036 // Set the color 00037 if (_track_view_color) 00038 GL_COL(v->color(), _alpha*alpha()); 00039 else 00040 GL_COL(_color, _alpha*alpha()); 00041 00042 // try it with the display list: 00043 if (BasicTexture::draw(v)) 00044 return _patch->num_faces(); 00045 00046 // ensure this never happens again! get a display list: 00047 int dl = _dl.get_dl(v, 1, _patch->stamp()); 00048 if (dl) 00049 glNewList(dl, GL_COMPILE); 00050 00051 glDisable(GL_LIGHTING); // GL_ENABLE_BIT 00052 00053 // set up face culling for closed surfaces 00054 set_face_culling(); // GL_ENABLE_BIT 00055 00056 // draw the triangle strips 00057 _patch->draw_tri_strips(_cb); 00058 00059 // restore gl state: 00060 glPopAttrib(); 00061 00062 // end the display list here 00063 if (_dl.dl(v)) { 00064 _dl.close_dl(v); 00065 00066 // the display list is built; now execute it 00067 BasicTexture::draw(v); 00068 } 00069 00070 return _patch->num_faces(); 00071 } 00072 00073 int 00074 SolidColorTexture::write_stream(ostream& os) const 00075 { 00076 os << _begin_tag << class_name() << endl << _color << endl << _end_tag; 00077 return 1; 00078 } 00079 00080 int 00081 SolidColorTexture::read_stream(istream& is, str_list &leftover) 00082 { 00083 leftover.clear(); 00084 COLOR col; 00085 is >> col; 00086 set_color(col); 00087 00088 return 1; 00089 } 00090 00091 /* end of file solid_color.C */