00001 00002 /* 00003 TEDDY - General graphics application library 00004 Copyright (C) 1999-2002 Timo Suoranta 00005 tksuoran@cc.helsinki.fi 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 $Id: Features.cpp,v 1.4 2002/01/11 14:34:59 tksuoran Exp $ 00022 */ 00023 00024 00025 #include "Teddy/Graphics/View.h" 00026 #include "Teddy/Graphics/Device.h" 00027 #include "Teddy/SysSupport/Messages.h" 00028 using namespace Teddy::SysSupport; 00029 00030 00031 namespace Teddy { 00032 namespace Graphics { 00033 00034 00035 /*static*/ const unsigned long View::CULL_FACE = 1; 00036 /*static*/ const unsigned long View::BLEND = 2; 00037 /*static*/ const unsigned long View::FOG = 3; 00038 /*static*/ const unsigned long View::NORMALIZE = 4; 00039 /*static*/ const unsigned long View::ALPHA_TEST = 5; 00040 /*static*/ const unsigned long View::DEPTH_TEST = 6; 00041 /*static*/ const unsigned long View::STENCIL_TEST = 7; 00042 /*static*/ const unsigned long View::SCISSOR_TEST = 8; 00043 /*static*/ const unsigned long View::TEXTURE_1D = 9; 00044 /*static*/ const unsigned long View::TEXTURE_2D = 10; 00045 /*static*/ const unsigned long View::POINT_SMOOTH = 11; 00046 /*static*/ const unsigned long View::LINE_SMOOTH = 12; 00047 /*static*/ const unsigned long View::POLYGON_SMOOTH = 13; 00048 /*static*/ const unsigned long View::POINT_OFFSET = 14; 00049 /*static*/ const unsigned long View::LINE_OFFSET = 15; 00050 /*static*/ const unsigned long View::POLYGON_OFFSET = 16; 00051 /*static*/ const unsigned long View::LIGHTING = 19; 00052 /*static*/ const unsigned long View::LIGHT0 = 20; 00053 /*static*/ const unsigned long View::LIGHT1 = 21; 00054 /*static*/ const unsigned long View::LIGHT2 = 22; 00055 /*static*/ const unsigned long View::LIGHT3 = 23; 00056 /*static*/ const unsigned long View::LIGHT4 = 24; 00057 /*static*/ const unsigned long View::LIGHT5 = 25; 00058 /*static*/ const unsigned long View::LIGHT6 = 26; 00059 /*static*/ const unsigned long View::LIGHT7 = 27; 00060 /*static*/ const unsigned long View::COLOR_MATERIAL = 28; 00061 00062 00063 /*static*/ unsigned int View::feature_to_code[256]; 00064 00065 00067 /*static*/ void View::init(){ 00068 dmsg( M_INIT, "init_graphics_device..." ); 00069 feature_to_code[CULL_FACE ] = GL_CULL_FACE ; 00070 feature_to_code[BLEND ] = GL_BLEND ; 00071 feature_to_code[FOG ] = GL_FOG ; 00072 feature_to_code[NORMALIZE ] = GL_NORMALIZE ; 00073 feature_to_code[ALPHA_TEST ] = GL_ALPHA_TEST ; 00074 feature_to_code[DEPTH_TEST ] = GL_DEPTH_TEST ; 00075 feature_to_code[STENCIL_TEST ] = GL_STENCIL_TEST ; 00076 feature_to_code[SCISSOR_TEST ] = GL_SCISSOR_TEST ; 00077 feature_to_code[TEXTURE_1D ] = GL_TEXTURE_1D ; 00078 feature_to_code[TEXTURE_2D ] = GL_TEXTURE_2D ; 00079 feature_to_code[POINT_SMOOTH ] = GL_POINT_SMOOTH ; 00080 feature_to_code[LINE_SMOOTH ] = GL_LINE_SMOOTH ; 00081 feature_to_code[POLYGON_SMOOTH] = GL_POLYGON_SMOOTH; 00082 feature_to_code[POINT_OFFSET ] = GL_POLYGON_OFFSET_POINT; 00083 feature_to_code[LINE_OFFSET ] = GL_POLYGON_OFFSET_LINE; 00084 feature_to_code[POLYGON_OFFSET] = GL_POLYGON_OFFSET_FILL; 00085 feature_to_code[LIGHTING ] = GL_LIGHTING ; 00086 feature_to_code[LIGHT0 ] = GL_LIGHT0 ; 00087 feature_to_code[LIGHT1 ] = GL_LIGHT1 ; 00088 feature_to_code[LIGHT2 ] = GL_LIGHT2 ; 00089 feature_to_code[LIGHT3 ] = GL_LIGHT3 ; 00090 feature_to_code[LIGHT4 ] = GL_LIGHT4 ; 00091 feature_to_code[LIGHT5 ] = GL_LIGHT5 ; 00092 feature_to_code[LIGHT6 ] = GL_LIGHT6 ; 00093 feature_to_code[LIGHT7 ] = GL_LIGHT7 ; 00094 feature_to_code[COLOR_MATERIAL] = GL_COLOR_MATERIAL; 00095 } 00096 00097 //#define getCode(a) feature_to_code[a] 00098 /*static*/ unsigned int View::getCode( unsigned int a ){ 00099 return feature_to_code[a]; 00100 } 00101 00102 00104 /*static*/ char *View::feature_to_str( int a ){ 00105 switch( a ){ 00106 case CULL_FACE : return "CULL_FACE "; 00107 case BLEND : return "BLEND "; 00108 case FOG : return "FOG "; 00109 case NORMALIZE : return "NORMALIZE "; 00110 case ALPHA_TEST : return "ALPHA_TEST "; 00111 case DEPTH_TEST : return "DEPTH_TEST "; 00112 case STENCIL_TEST : return "STENCIL_TEST "; 00113 case SCISSOR_TEST : return "SCISSOR_TEST "; 00114 case TEXTURE_1D : return "TEXTURE_1D "; 00115 case TEXTURE_2D : return "TEXTURE_2D "; 00116 case POINT_SMOOTH : return "POINT_SMOOTH "; 00117 case LINE_SMOOTH : return "LINE_SMOOTH "; 00118 case POLYGON_SMOOTH: return "POLYGON_SMOOTH"; 00119 case POINT_OFFSET : return "POINT_OFFSET "; 00120 case LINE_OFFSET : return "LINE_OFFSET "; 00121 case POLYGON_OFFSET: return "POLYGON_OFFSET"; 00122 case LIGHTING : return "LIGHTING "; 00123 case LIGHT0 : return "LIGHT0 "; 00124 case LIGHT1 : return "LIGHT1 "; 00125 case LIGHT2 : return "LIGHT2 "; 00126 case LIGHT3 : return "LIGHT3 "; 00127 case LIGHT4 : return "LIGHT4 "; 00128 case LIGHT5 : return "LIGHT5 "; 00129 case LIGHT6 : return "LIGHT6 "; 00130 case LIGHT7 : return "LIGHT7 "; 00131 case COLOR_MATERIAL: return "COLOR_MATERIAL"; 00132 default: 00133 return "unknown"; 00134 break; 00135 } 00136 } 00137 00138 00139 }; // namespace Graphics 00140 }; // namespace Teddy 00141