00001 // This is core/vgui/vgui_color.cxx 00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00003 #pragma implementation 00004 #endif 00005 //: 00006 // \file 00007 // \author fsm 00008 // \brief See vgui_color.h for a description of this file. 00009 00010 #include "vgui_color.h" 00011 #include <vgui/vgui_gl.h> 00012 #include <vgui/vgui_macro.h> 00013 00014 // This assumes someone has set up the color map so that the 00015 // first 8 indices (viewed as binary) correspond to rgb. 00016 // Ideally, the mapping from colour to index should be 00017 // determined at run-time and cached for each adaptor in the 00018 // program. 00019 static 00020 void macro(int a, int b, int c) // cunningly, this is no longer a macro. 00021 { 00022 GLboolean is_index_mode; 00023 vgui_macro_report_errors; 00024 glGetBooleanv(GL_INDEX_MODE, &is_index_mode); 00025 vgui_macro_report_errors; 00026 if (is_index_mode) 00027 glIndexi(4*(a) + 2*(b) + (c)); 00028 else 00029 glColor3f(a, b, c); 00030 vgui_macro_report_errors; 00031 } 00032 00033 void vgui_color_white() { macro(vgui_color_WHITE); } 00034 void vgui_color_yellow(){ macro(vgui_color_YELLOW); } 00035 void vgui_color_purple(){ macro(vgui_color_PURPLE); } 00036 void vgui_color_red() { macro(vgui_color_RED); } 00037 void vgui_color_cyan() { macro(vgui_color_CYAN); } 00038 void vgui_color_green() { macro(vgui_color_GREEN); } 00039 void vgui_color_blue() { macro(vgui_color_BLUE); } 00040 void vgui_color_black() { macro(vgui_color_BLACK); }