Files Classes Functions Hierarchy
00001 00002 #include <gobj.h> 00003 #include <stringconvert.h> 00004 #include <stringspace.h> 00005 #include <tokenizer.h> 00006 00007 00008 00009 gobjglutSolidCube::gobjglutSolidCube(GLdouble size_) 00010 : size(size_) 00011 {} 00012 00013 void gobjglutSolidCube::draw() 00014 { 00015 GOBJDEBUGCODE 00016 glutSolidCube(size); 00017 } 00018 00019 gobjglutWireCube::gobjglutWireCube(GLdouble size_) 00020 : size(size_) 00021 {} 00022 00023 void gobjglutWireCube::draw() 00024 { 00025 GOBJDEBUGCODE 00026 glutWireCube(size); 00027 } 00028 00029 gobjglutSolidCone::gobjglutSolidCone 00030 ( 00031 GLdouble base_, 00032 GLdouble height_, 00033 GLint slices_, 00034 GLint stacks_ 00035 ) 00036 : base(base_), height(height_), slices(slices_), 00037 stacks(stacks_) 00038 { 00039 } 00040 00041 void gobjglutSolidCone::draw() 00042 { 00043 GOBJDEBUGCODE 00044 glutSolidCone(base,height,slices,stacks); 00045 } 00046 00047 gobjglutWireCone::gobjglutWireCone 00048 ( 00049 GLdouble base_, 00050 GLdouble height_, 00051 GLint slices_, 00052 GLint stacks_ 00053 ) 00054 : base(base_), height(height_), slices(slices_), 00055 stacks(stacks_) 00056 { 00057 } 00058 00059 void gobjglutWireCone::draw() 00060 { 00061 GOBJDEBUGCODE 00062 glutWireCone(base,height,slices,stacks); 00063 } 00064 00065 00066 gobjglutSolidTeapot::gobjglutSolidTeapot(GLdouble size_) 00067 : size(size_) 00068 {} 00069 00070 void gobjglutSolidTeapot::draw() 00071 { 00072 GOBJDEBUGCODE 00073 glutSolidTeapot(size); 00074 } 00075 00076 gobjglutWireTeapot::gobjglutWireTeapot(GLdouble size_) 00077 : size(size_) 00078 {} 00079 00080 void gobjglutWireTeapot::draw() 00081 { 00082 GOBJDEBUGCODE 00083 glutWireTeapot(size); 00084 } 00085 00086 00087 gobjglutSolidSphere::gobjglutSolidSphere 00088 ( 00089 GLdouble radius_, 00090 GLint slices_, 00091 GLint stacks_ 00092 ) 00093 : radius(radius_), slices(slices_), stacks(stacks_) 00094 { 00095 } 00096 00097 void gobjglutSolidSphere::draw() 00098 { 00099 GOBJDEBUGCODE 00100 glutSolidSphere(radius,slices,stacks); 00101 } 00102 00103 00104 gobjglutWireSphere::gobjglutWireSphere 00105 ( 00106 GLdouble radius_, 00107 GLint slices_, 00108 GLint stacks_ 00109 ) 00110 : radius(radius_), slices(slices_), stacks(stacks_) 00111 { 00112 } 00113 00114 void gobjglutWireSphere::draw() 00115 { 00116 GOBJDEBUGCODE 00117 glutWireSphere(radius,slices,stacks); 00118 } 00119 00120 gobjglutSolidTorus::gobjglutSolidTorus 00121 ( 00122 GLdouble innerRadius_, 00123 GLdouble outerRadius_, 00124 GLint nsides_, 00125 GLint rings_ 00126 ) 00127 : innerRadius(innerRadius_), outerRadius(outerRadius_), 00128 nsides(nsides_), rings(rings_) {} 00129 00130 void gobjglutSolidTorus::draw() 00131 { 00132 GOBJDEBUGCODE 00133 glutSolidTorus(innerRadius,outerRadius,nsides,rings); 00134 } 00135 00136 gobjglutWireTorus::gobjglutWireTorus 00137 ( 00138 GLdouble innerRadius_, 00139 GLdouble outerRadius_, 00140 GLint nsides_, 00141 GLint rings_ 00142 ) 00143 : innerRadius(innerRadius_), outerRadius(outerRadius_), 00144 nsides(nsides_), rings(rings_) {} 00145 00146 void gobjglutWireTorus::draw() 00147 { 00148 GOBJDEBUGCODE 00149 glutWireTorus(innerRadius,outerRadius,nsides,rings); 00150 } 00151 00152 00153 00154 00155 gobjGlobal::gobjGlobal(gobjContainer * const globalnew_) 00156 : globalnew(globalnew_) 00157 { 00158 assert(globalnew); 00159 globalnew->globalpush(); 00160 } 00161 00162 gobjGlobal::~gobjGlobal() 00163 { 00164 globalnew->globalpop(); 00165 } 00166 00167 boolc gobjglPushAttrib::serializeInverse(stringc & arg) 00168 { 00169 string s1(arg); 00170 spacertrim<>()(s1); 00171 if (s1=="GL_CURRENT_BIT") 00172 { 00173 mask = GL_CURRENT_BIT; 00174 return true; 00175 } 00176 if (s1=="GL_LIGHTING_BIT") 00177 { 00178 mask = GL_LIGHTING_BIT; 00179 return true; 00180 } 00181 00182 cout << "error: gobjglPushAttrib(" << arg << ");" << endl; 00183 assert(false); 00184 00185 return false; 00186 } 00187 00188 gobjglPushAttrib::gobjglPushAttrib(stringc & arg) 00189 { 00190 asserteval(serializeInverse(arg)); 00191 } 00192 00193 boolc gobjglVertex3f::serializeInverse(stringc & arg) 00194 { 00195 tokenizer ss(arg); 00196 ss.tokenize(); 00197 if (ss.seq.size()!=3) 00198 return false; 00199 00200 ss.reset(); 00201 stringfrom(x,ss()); 00202 ++ss; 00203 stringfrom(y,ss()); 00204 ++ss; 00205 stringfrom(z,ss()); 00206 00207 return true; 00208 } 00209 00210 gobjglVertex3f::gobjglVertex3f(stringc & arg) 00211 { 00212 asserteval(serializeInverse(arg)); 00213 } 00214 00215 00216 00217 00218 boolc gobjglColor3f::serializeInverse(stringc & arg) 00219 { 00220 tokenizer ss(arg); 00221 ss.tokenize(); 00222 if (ss.seq.size()!=3) 00223 return false; 00224 00225 ss.reset(); 00226 stringfrom(x,ss()); 00227 ++ss; 00228 stringfrom(y,ss()); 00229 ++ss; 00230 stringfrom(z,ss()); 00231 00232 return true; 00233 } 00234 00235 gobjglColor3f::gobjglColor3f(stringc & arg) 00236 { 00237 asserteval(serializeInverse(arg)); 00238 } 00239 00240 00241 00242 #define gobjglenabledisable(arg)\ 00243 { if (s1=="arg") { capability = arg; return true; } } 00244 00245 00246 boolc gobjglDisable::serializeInverse(stringc & arg) 00247 { 00248 string s1(arg); 00249 spacertrim<>()(s1); 00250 00251 gobjglenabledisable(GL_ALPHA); 00252 gobjglenabledisable(GL_AUTO_NORMAL); 00253 gobjglenabledisable(GL_BLEND); 00254 //gobjglenabledisable(GL_CLIP_PLANEi); 00255 gobjglenabledisable(GL_COLOR_LOGIC_OP); 00256 gobjglenabledisable(GL_COLOR_MATERIAL); 00257 gobjglenabledisable(GL_COLOR_TABLE); 00258 gobjglenabledisable(GL_CONVOLUTION_1D); 00259 gobjglenabledisable(GL_CONVOLUTION_2D); 00260 gobjglenabledisable(GL_CULL_FACE); 00261 gobjglenabledisable(GL_DEPTH_TEST); 00262 gobjglenabledisable(GL_DITHER); 00263 gobjglenabledisable(GL_FOG); 00264 gobjglenabledisable(GL_HISTOGRAM); 00265 gobjglenabledisable(GL_INDEX_LOGIC_OP); 00266 //gobjglenabledisable(GL_LIGHTi); 00267 gobjglenabledisable(GL_LIGHTING); 00268 gobjglenabledisable(GL_LINE_SMOOTH); 00269 gobjglenabledisable(GL_LINE_STIPPLE); 00270 gobjglenabledisable(GL_MAP1_COLOR_4); 00271 gobjglenabledisable(GL_MAP1_INDEX); 00272 00273 /* 00274 if (s1=="GL_LIGHTING") 00275 { 00276 capability = GL_LIGHTING; 00277 return true; 00278 } 00279 */ 00280 00281 cout << "error: gobjglDisable(" << arg << ");" << endl; 00282 assert(false); 00283 00284 return false; 00285 } 00286 00287 gobjglDisable::gobjglDisable(stringc & arg) 00288 { 00289 asserteval(serializeInverse(arg)); 00290 } 00291 00292 00293 00294 00295 00296 boolc gobjglBegin::serializeInverse(stringc & arg) 00297 { 00298 string s1(arg); 00299 spacertrim<>()(s1); 00300 00301 if (s1=="GL_POINTS") 00302 { 00303 mode = GL_POINTS; 00304 return true; 00305 } 00306 00307 if (s1=="GL_LINES") 00308 { 00309 mode = GL_LINES; 00310 return true; 00311 } 00312 00313 if (s1=="GL_LINE_STRIP") 00314 { 00315 mode = GL_LINE_STRIP; 00316 return true; 00317 } 00318 00319 if (s1=="GL_LINE_LOOP") 00320 { 00321 mode = GL_LINE_LOOP; 00322 return true; 00323 } 00324 00325 if (s1=="GL_TRIANGLES") 00326 { 00327 mode = GL_TRIANGLES; 00328 return true; 00329 } 00330 00331 if (s1=="GL_TRIANGLE_STRIP") 00332 { 00333 mode = GL_TRIANGLE_STRIP; 00334 return true; 00335 } 00336 00337 if (s1=="GL_TRIANGLE_FAN") 00338 { 00339 mode = GL_TRIANGLE_FAN; 00340 return true; 00341 } 00342 if (s1=="GL_QUADS") 00343 { 00344 mode = GL_QUADS; 00345 return true; 00346 } 00347 00348 if (s1=="GL_QUAD_STRIP") 00349 { 00350 mode = GL_QUAD_STRIP; 00351 return true; 00352 } 00353 00354 if (s1=="GL_POLYGON") 00355 { 00356 mode = GL_POLYGON; 00357 return true; 00358 } 00359 00360 cout << "error: gobjglBegin(" << arg << ");" << endl; 00361 assert(false); 00362 00363 return false; 00364 } 00365 00366 gobjglBegin::gobjglBegin(stringc & arg) 00367 { 00368 asserteval(serializeInverse(arg)); 00369 } 00370 00371 00372 00373
1.5.8