1 /* 2 ----------------------------------------------------------------------------- 3 This source file is part of OGRE 4 (Object-oriented Graphics Rendering Engine) 5 For the latest info, see http://www.ogre3d.org/ 6 7 Copyright (c) 2000-2014 Torus Knot Software Ltd 8 9 Permission is hereby granted, free of charge, to any person obtaining a copy 10 of this software and associated documentation files (the "Software"), to deal 11 in the Software without restriction, including without limitation the rights 12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 copies of the Software, and to permit persons to whom the Software is 14 furnished to do so, subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be included in 17 all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 THE SOFTWARE. 26 ----------------------------------------------------------------------------- 27 */ 28 #include "OgreCgFxScriptLoader.h" 29 #include "OgreResourceGroupManager.h" 30 #include "OgreMaterialManager.h" 31 #include "OgreTechnique.h" 32 #include "OgrePass.h" 33 #include "OgreHighLevelGpuProgramManager.h" 34 #include "OgreCgProgram.h" 35 36 namespace Ogre { 37 38 //--------------------------------------------------------------------- 39 //--------------------------------------------------------------------- 40 //--------------------------------------------------------------------- Vector1b()41 CgFxScriptLoader::Vector1b::Vector1b() : x(false) 42 { 43 44 } 45 //--------------------------------------------------------------------- Vector1b(bool iX)46 CgFxScriptLoader::Vector1b::Vector1b( bool iX ) : x( iX ) 47 { 48 49 } 50 //--------------------------------------------------------------------- Vector1b(CGstateassignment cgStateAssignment)51 CgFxScriptLoader::Vector1b::Vector1b( CGstateassignment cgStateAssignment ) : x( false ) 52 { 53 int nValsDummy[1]; 54 const CGbool * values; 55 values = cgGetBoolStateAssignmentValues(cgStateAssignment, nValsDummy); 56 assert(nValsDummy[0] == 1); 57 58 #if ( OGRE_COMPILER == OGRE_COMPILER_MSVC ) 59 #pragma warning(push) 60 #pragma warning(disable: 4800) // warning C4800: 'const CGbool' : forcing value to bool 'true' or 'false' (performance warning) 61 #endif 62 x = static_cast<bool>(values[0]); 63 #if ( OGRE_COMPILER == OGRE_COMPILER_MSVC ) 64 #pragma warning(pop) 65 #endif 66 } 67 //--------------------------------------------------------------------- operator bool() const68 CgFxScriptLoader::Vector1b::operator bool() const 69 { 70 return x; 71 } 72 //--------------------------------------------------------------------- 73 //--------------------------------------------------------------------- 74 //--------------------------------------------------------------------- Vector2b()75 CgFxScriptLoader::Vector2b::Vector2b() : x( false ), y( false ) 76 { 77 78 } 79 //--------------------------------------------------------------------- Vector2b(bool iX,bool iY,bool iZ,bool iW)80 CgFxScriptLoader::Vector2b::Vector2b( bool iX, bool iY , bool iZ, bool iW ) : x( iX ), y( iY ) 81 { 82 83 } 84 //--------------------------------------------------------------------- Vector2b(CGstateassignment cgStateAssignment)85 CgFxScriptLoader::Vector2b::Vector2b( CGstateassignment cgStateAssignment ) : x( false ), y( false ) 86 { 87 int nValsDummy[1]; 88 const CGbool * values; 89 values = cgGetBoolStateAssignmentValues(cgStateAssignment, nValsDummy); 90 assert(nValsDummy[0] == 2); 91 92 #if ( OGRE_COMPILER == OGRE_COMPILER_MSVC ) 93 #pragma warning(push) 94 #pragma warning(disable: 4800) // warning C4800: 'const CGbool' : forcing value to bool 'true' or 'false' (performance warning) 95 #endif 96 x = static_cast<bool>(values[0]); 97 y = static_cast<bool>(values[1]); 98 #if ( OGRE_COMPILER == OGRE_COMPILER_MSVC ) 99 #pragma warning(pop) 100 #endif 101 } 102 //--------------------------------------------------------------------- 103 //--------------------------------------------------------------------- 104 //-------------------------------------------------------------------- Vector3b()105 CgFxScriptLoader::Vector3b::Vector3b() : x( false ), y( false ), z( false ) 106 { 107 108 } 109 //--------------------------------------------------------------------- Vector3b(bool iX,bool iY,bool iZ,bool iW)110 CgFxScriptLoader::Vector3b::Vector3b( bool iX, bool iY , bool iZ, bool iW ) : x( iX ), y( iY ), z( iZ ) 111 { 112 113 } 114 //--------------------------------------------------------------------- Vector3b(CGstateassignment cgStateAssignment)115 CgFxScriptLoader::Vector3b::Vector3b( CGstateassignment cgStateAssignment ) : x( false ), y( false ), z( false ) 116 { 117 int nValsDummy[1]; 118 const CGbool * values; 119 values = cgGetBoolStateAssignmentValues(cgStateAssignment, nValsDummy); 120 assert(nValsDummy[0] == 3); 121 122 #if ( OGRE_COMPILER == OGRE_COMPILER_MSVC ) 123 #pragma warning(push) 124 #pragma warning(disable: 4800) // warning C4800: 'const CGbool' : forcing value to bool 'true' or 'false' (performance warning) 125 #endif 126 x = static_cast<bool>(values[0]); 127 y = static_cast<bool>(values[1]); 128 z = static_cast<bool>(values[2]); 129 #if ( OGRE_COMPILER == OGRE_COMPILER_MSVC ) 130 #pragma warning(pop) 131 #endif 132 } 133 //--------------------------------------------------------------------- 134 //--------------------------------------------------------------------- 135 //--------------------------------------------------------------------- Vector4b()136 CgFxScriptLoader::Vector4b::Vector4b() : x( false ), y( false ), z( false ), w( false ) 137 { 138 139 } 140 //--------------------------------------------------------------------- Vector4b(bool iX,bool iY,bool iZ,bool iW)141 CgFxScriptLoader::Vector4b::Vector4b( bool iX, bool iY , bool iZ, bool iW ) : x( iX ), y( iY ), z( iZ ), w( iW ) 142 { 143 144 } 145 //--------------------------------------------------------------------- Vector4b(CGstateassignment cgStateAssignment)146 CgFxScriptLoader::Vector4b::Vector4b( CGstateassignment cgStateAssignment ) : x( false ), y( false ), z( false ), w( false ) 147 { 148 int nValsDummy[1]; 149 const CGbool * values; 150 values = cgGetBoolStateAssignmentValues(cgStateAssignment, nValsDummy); 151 assert(nValsDummy[0] == 4); 152 153 #if ( OGRE_COMPILER == OGRE_COMPILER_MSVC ) 154 #pragma warning(push) 155 #pragma warning(disable: 4800) // warning C4800: 'const CGbool' : forcing value to bool 'true' or 'false' (performance warning) 156 #endif 157 x = static_cast<bool>(values[0]); 158 y = static_cast<bool>(values[1]); 159 z = static_cast<bool>(values[2]); 160 w = static_cast<bool>(values[3]); 161 #if ( OGRE_COMPILER == OGRE_COMPILER_MSVC ) 162 #pragma warning(pop) 163 #endif 164 } 165 //--------------------------------------------------------------------- 166 //--------------------------------------------------------------------- 167 //--------------------------------------------------------------------- Vector1i()168 CgFxScriptLoader::Vector1i::Vector1i() : x( 0 ) 169 { 170 171 } 172 //--------------------------------------------------------------------- Vector1i(int iX)173 CgFxScriptLoader::Vector1i::Vector1i( int iX ) : x( iX ) 174 { 175 176 } 177 //--------------------------------------------------------------------- Vector1i(CGstateassignment cgStateAssignment)178 CgFxScriptLoader::Vector1i::Vector1i( CGstateassignment cgStateAssignment ) : x( 0 ) 179 { 180 int nValsDummy[1]; 181 const int * values; 182 values = cgGetIntStateAssignmentValues(cgStateAssignment, nValsDummy); 183 assert( nValsDummy[0] == 1); 184 185 x = values[0]; 186 } 187 //--------------------------------------------------------------------- operator int() const188 CgFxScriptLoader::Vector1i::operator int() const 189 { 190 return x; 191 } 192 //--------------------------------------------------------------------- 193 //--------------------------------------------------------------------- 194 //--------------------------------------------------------------------- Vector2i()195 CgFxScriptLoader::Vector2i::Vector2i() : x( 0 ), y( 0 ) 196 { 197 198 } 199 //--------------------------------------------------------------------- Vector2i(int iX,int iY)200 CgFxScriptLoader::Vector2i::Vector2i( int iX, int iY ) : x( iX ), y( iY ) 201 { 202 203 } 204 //--------------------------------------------------------------------- Vector2i(CGstateassignment cgStateAssignment)205 CgFxScriptLoader::Vector2i::Vector2i( CGstateassignment cgStateAssignment ) : x( 0 ), y( 0 ) 206 { 207 int nValsDummy[1]; 208 const int * values; 209 values = cgGetIntStateAssignmentValues(cgStateAssignment, nValsDummy); 210 assert( nValsDummy[0] == 2); 211 212 x = values[0]; 213 y = values[1]; 214 } 215 //--------------------------------------------------------------------- 216 //--------------------------------------------------------------------- 217 //--------------------------------------------------------------------- Vector3i()218 CgFxScriptLoader::Vector3i::Vector3i() : x( 0 ), y( 0 ), z( 0 ) 219 { 220 221 } 222 //--------------------------------------------------------------------- Vector3i(int iX,int iY,int iZ)223 CgFxScriptLoader::Vector3i::Vector3i( int iX, int iY, int iZ ) : x( iX ), y( iY ) , z( iZ ) 224 { 225 226 } 227 //--------------------------------------------------------------------- Vector3i(CGstateassignment cgStateAssignment)228 CgFxScriptLoader::Vector3i::Vector3i( CGstateassignment cgStateAssignment ) : x( 0 ), y( 0 ), z( 0 ) 229 { 230 int nValsDummy[1]; 231 const int * values; 232 values = cgGetIntStateAssignmentValues(cgStateAssignment, nValsDummy); 233 assert( nValsDummy[0] == 3); 234 235 x = values[0]; 236 y = values[1]; 237 z = values[2]; 238 } 239 //--------------------------------------------------------------------- 240 //--------------------------------------------------------------------- 241 //--------------------------------------------------------------------- Vector4i()242 CgFxScriptLoader::Vector4i::Vector4i() : x( 0 ), y( 0 ), z( 0 ), w( 0 ) 243 { 244 245 } 246 //--------------------------------------------------------------------- Vector4i(int iX,int iY,int iZ,int iW)247 CgFxScriptLoader::Vector4i::Vector4i( int iX, int iY, int iZ, int iW ) : x( iX ), y( iY ), z( iZ ), w( iW ) 248 { 249 250 } 251 //--------------------------------------------------------------------- Vector4i(CGstateassignment cgStateAssignment)252 CgFxScriptLoader::Vector4i::Vector4i( CGstateassignment cgStateAssignment ) : x( 0 ), y( 0 ), z( 0 ), w( 0 ) 253 { 254 int nValsDummy[1]; 255 const int * values; 256 values = cgGetIntStateAssignmentValues(cgStateAssignment, nValsDummy); 257 assert( nValsDummy[0] == 4 ); 258 259 x = values[0]; 260 y = values[1]; 261 z = values[2]; 262 w = values[3]; 263 } 264 //--------------------------------------------------------------------- 265 //--------------------------------------------------------------------- 266 //--------------------------------------------------------------------- Vector1f()267 CgFxScriptLoader::Vector1f::Vector1f() : x( 0.0f ) 268 { 269 270 } 271 //--------------------------------------------------------------------- Vector1f(float iX,float iY,float iZ)272 CgFxScriptLoader::Vector1f::Vector1f( float iX, float iY, float iZ ) : x( iX ) 273 { 274 275 } 276 //--------------------------------------------------------------------- Vector1f(CGstateassignment cgStateAssignment)277 CgFxScriptLoader::Vector1f::Vector1f( CGstateassignment cgStateAssignment ) : x( 0.0f ) 278 { 279 int nValsDummy[1]; 280 const float * values; 281 values = cgGetFloatStateAssignmentValues(cgStateAssignment, nValsDummy); 282 assert( nValsDummy[0] == 1 ); 283 284 x = values[0]; 285 } 286 //--------------------------------------------------------------------- operator float() const287 CgFxScriptLoader::Vector1f::operator float() const 288 { 289 return x; 290 } 291 //--------------------------------------------------------------------- 292 //--------------------------------------------------------------------- 293 //--------------------------------------------------------------------- Vector2f()294 CgFxScriptLoader::Vector2f::Vector2f() : x( 0.0f ), y( 0.0f ) 295 { 296 297 } 298 //--------------------------------------------------------------------- Vector2f(float iX,float iY,float iZ)299 CgFxScriptLoader::Vector2f::Vector2f( float iX, float iY, float iZ ) : x( iX ), y( iY ) 300 { 301 302 } 303 //--------------------------------------------------------------------- Vector2f(CGstateassignment cgStateAssignment)304 CgFxScriptLoader::Vector2f::Vector2f( CGstateassignment cgStateAssignment ) : x( 0.0f ), y( 0.0f ) 305 { 306 int nValsDummy[1]; 307 const float * values; 308 values = cgGetFloatStateAssignmentValues(cgStateAssignment, nValsDummy); 309 assert( nValsDummy[0] == 2 ); 310 311 x = values[0]; 312 y = values[1]; 313 } 314 //--------------------------------------------------------------------- 315 //--------------------------------------------------------------------- 316 //--------------------------------------------------------------------- Vector3f()317 CgFxScriptLoader::Vector3f::Vector3f() : x( 0.0f ), y( 0.0f ), z( 0.0f ) 318 { 319 320 } 321 //--------------------------------------------------------------------- Vector3f(float iX,float iY,float iZ)322 CgFxScriptLoader::Vector3f::Vector3f( float iX, float iY, float iZ ) : x( iX ), y( iY ), z( iZ ) 323 { 324 325 } 326 //--------------------------------------------------------------------- Vector3f(CGstateassignment cgStateAssignment)327 CgFxScriptLoader::Vector3f::Vector3f( CGstateassignment cgStateAssignment ) : x( 0.0f ), y( 0.0f ), z( 0.0f ) 328 { 329 int nValsDummy[1]; 330 const float * values; 331 values = cgGetFloatStateAssignmentValues(cgStateAssignment, nValsDummy); 332 assert( nValsDummy[0] == 3 ); 333 334 x = values[0]; 335 y = values[1]; 336 z = values[2]; 337 } 338 //--------------------------------------------------------------------- 339 //--------------------------------------------------------------------- 340 //--------------------------------------------------------------------- Vector4f()341 CgFxScriptLoader::Vector4f::Vector4f() : x( 0.0f ), y( 0.0f ), z( 0.0f ), w( 0.0f ) 342 { 343 344 } 345 //--------------------------------------------------------------------- Vector4f(float iX,float iY,float iZ,float iW)346 CgFxScriptLoader::Vector4f::Vector4f( float iX, float iY, float iZ, float iW ) : x( iX ), y( iY ), z( iZ ), w( iW ) 347 { 348 349 } 350 //--------------------------------------------------------------------- Vector4f(CGstateassignment cgStateAssignment)351 CgFxScriptLoader::Vector4f::Vector4f( CGstateassignment cgStateAssignment ) : x( 0.0f ), y( 0.0f ), z( 0.0f ), w( 0.0f ) 352 { 353 int nValsDummy[1]; 354 const float * values; 355 values = cgGetFloatStateAssignmentValues(cgStateAssignment, nValsDummy); 356 assert( nValsDummy[0] == 4 ); 357 358 x = values[0]; 359 y = values[1]; 360 z = values[2]; 361 w = values[3]; 362 } 363 //--------------------------------------------------------------------- 364 //--------------------------------------------------------------------- 365 //--------------------------------------------------------------------- CgStateListener(CGtype cgType)366 CgFxScriptLoader::CgStateListener::CgStateListener(CGtype cgType) 367 : mCgState(0), 368 mCgType(cgType), 369 mCgContext(CgFxScriptLoader::getSingleton().getCgContext()) 370 371 372 { 373 } 374 //--------------------------------------------------------------------- ~CgStateListener()375 CgFxScriptLoader::CgStateListener::~CgStateListener() 376 { 377 378 } 379 //--------------------------------------------------------------------- cgCallBackSet(const CGstateassignment cgStateAssignment)380 CGbool CgFxScriptLoader::CgStateListener::cgCallBackSet( const CGstateassignment cgStateAssignment ) 381 { 382 return CG_TRUE; 383 } 384 //--------------------------------------------------------------------- cgCallBackReset(CGstateassignment cgStateAssignment)385 CGbool CgFxScriptLoader::CgStateListener::cgCallBackReset( CGstateassignment cgStateAssignment ) 386 { 387 return CG_TRUE; 388 } 389 //--------------------------------------------------------------------- cgCallBackValidate(CGstateassignment cgStateAssignment)390 CGbool CgFxScriptLoader::CgStateListener::cgCallBackValidate( CGstateassignment cgStateAssignment ) 391 { 392 return CG_TRUE; 393 } 394 //--------------------------------------------------------------------- init()395 void CgFxScriptLoader::CgStateListener::init() 396 { 397 createState(); 398 checkForCgError("CgFxScriptLoader::CgStateListener::init", 399 "Unable to Set create State: ", mCgContext); 400 401 cgSetStateCallbacks( mCgState, getCgCallBackSet(), getCgCallBackReset(), getCgCallBackValidate() ); 402 checkForCgError("CgFxScriptLoader::CgStateListener::init", 403 "Unable to Set State Callbacks: ", mCgContext); 404 } 405 //--------------------------------------------------------------------- addStateEnumerant(int value,const char * name)406 void CgFxScriptLoader::CgStateListener::addStateEnumerant( int value, const char *name ) 407 { 408 cgAddStateEnumerant(mCgState, name, value); 409 410 checkForCgError("CgFxScriptLoader::CgMinFilterSamplerStateListener::createState", 411 "Unable to Add State Enumerants: ", mCgContext); 412 413 } 414 //--------------------------------------------------------------------- getCgCallBackSet()415 CGstatecallback CgFxScriptLoader::CgStateListener::getCgCallBackSet() 416 { 417 return cgCallBackSet; 418 } 419 //--------------------------------------------------------------------- getCgCallBackReset()420 CGstatecallback CgFxScriptLoader::CgStateListener::getCgCallBackReset() 421 { 422 return cgCallBackReset; 423 } 424 //--------------------------------------------------------------------- getCgCallBackValidate()425 CGstatecallback CgFxScriptLoader::CgStateListener::getCgCallBackValidate() 426 { 427 return cgCallBackValidate; 428 } 429 //--------------------------------------------------------------------- getCgState() const430 CGstate CgFxScriptLoader::CgStateListener::getCgState() const 431 { 432 return mCgState; 433 } 434 //--------------------------------------------------------------------- getCgParameter(CGstateassignment cgStateAssignment)435 CGparameter CgFxScriptLoader::CgStateListener::getCgParameter( CGstateassignment cgStateAssignment ) 436 { 437 return cgGetTextureStateAssignmentValue(cgStateAssignment); 438 } 439 //--------------------------------------------------------------------- 440 //--------------------------------------------------------------------- 441 //--------------------------------------------------------------------- CgGlobalStateListener(const GlobalStateType globalStateType,CGtype cgType)442 CgFxScriptLoader::CgGlobalStateListener::CgGlobalStateListener( const GlobalStateType globalStateType, CGtype cgType ) 443 : CgStateListener(cgType), 444 mGlobalStateType(globalStateType) 445 { 446 447 } 448 //--------------------------------------------------------------------- ~CgGlobalStateListener()449 CgFxScriptLoader::CgGlobalStateListener::~CgGlobalStateListener() 450 { 451 452 } 453 //--------------------------------------------------------------------- createState()454 void CgFxScriptLoader::CgGlobalStateListener::createState() 455 { 456 const char * typeNameAsString = CgFxScriptLoader::getSingleton().getGlobalStateNameTypeToString(mGlobalStateType); 457 mCgState = cgCreateState( mCgContext, typeNameAsString, mCgType ); 458 459 } 460 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)461 void CgFxScriptLoader::CgGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 462 { 463 // todo - error 464 } 465 //--------------------------------------------------------------------- 466 //--------------------------------------------------------------------- 467 //--------------------------------------------------------------------- CgBoolGlobalStateListener(const GlobalStateType globalStateType)468 CgFxScriptLoader::CgBoolGlobalStateListener::CgBoolGlobalStateListener( const GlobalStateType globalStateType ) 469 : CgGlobalStateListener(globalStateType, CG_BOOL) 470 { 471 472 } 473 //--------------------------------------------------------------------- getValue(CGstateassignment cgStateAssignment)474 const CgFxScriptLoader::Vector1b CgFxScriptLoader::CgBoolGlobalStateListener::getValue( CGstateassignment cgStateAssignment ) 475 { 476 return Vector1b(cgStateAssignment); 477 } 478 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)479 void CgFxScriptLoader::CgBoolGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 480 { 481 const bool value = getValue(cgStateAssignment); 482 switch( mGlobalStateType ) 483 { 484 case GST_ALPHABLENDENABLE: 485 break; 486 case GST_COLORVERTEX: 487 break; 488 case GST_DEPTHMASK: 489 break; 490 case GST_ZWRITEENABLE: 491 break; 492 case GST_INDEXEDVERTEXBLENDENABLE: 493 break; 494 case GST_LIGHTINGENABLE: 495 break; 496 case GST_LIGHTENABLE: 497 case GST_LIGHTING: 498 ogrePass->setLightingEnabled(value); 499 break; 500 case GST_LOCALVIEWER: 501 break; 502 case GST_MULTISAMPLEANTIALIAS: 503 break; 504 case GST_POINTSCALEENABLE: 505 break; 506 case GST_RANGEFOGENABLE: 507 break; 508 case GST_SPECULARENABLE: 509 break; 510 case GST_CLIPPING: 511 break; 512 case GST_POINTSPRITECOORDREPLACE: 513 break; 514 case GST_LASTPIXEL: 515 break; 516 case GST_TEXTURE1DENABLE: 517 break; 518 case GST_TEXTURE2DENABLE: 519 break; 520 case GST_TEXTURE3DENABLE: 521 break; 522 case GST_TEXTURERECTANGLEENABLE: 523 break; 524 case GST_TEXTURECUBEMAPENABLE: 525 break; 526 case GST_ALPHATESTENABLE: 527 break; 528 case GST_AUTONORMALENABLE: 529 break; 530 case GST_BLENDENABLE: 531 break; 532 case GST_COLORLOGICOPENABLE: 533 break; 534 case GST_CULLFACEENABLE: 535 break; 536 case GST_DEPTHBOUNDSENABLE: 537 break; 538 case GST_DEPTHCLAMPENABLE: 539 break; 540 case GST_DEPTHTESTENABLE: 541 break; 542 case GST_ZENABLE: 543 ogrePass->setDepthCheckEnabled(value); 544 break; 545 case GST_DITHERENABLE: 546 break; 547 case GST_FOGENABLE: 548 break; 549 case GST_LIGHTMODELLOCALVIEWERENABLE: 550 break; 551 case GST_LIGHTMODELTWOSIDEENABLE: 552 break; 553 case GST_LINESMOOTHENABLE: 554 break; 555 case GST_LINESTIPPLEENABLE: 556 break; 557 case GST_LOGICOPENABLE: 558 break; 559 case GST_MULTISAMPLEENABLE: 560 break; 561 case GST_NORMALIZEENABLE: 562 break; 563 case GST_NORMALIZENORMALS: 564 break; 565 case GST_POINTSMOOTHENABLE: 566 break; 567 case GST_POINTSPRITEENABLE: 568 break; 569 case GST_POLYGONOFFSETFILLENABLE: 570 break; 571 case GST_POLYGONOFFSETLINEENABLE: 572 break; 573 case GST_POLYGONOFFSETPOINTENABLE: 574 break; 575 case GST_POLYGONSMOOTHENABLE: 576 break; 577 case GST_POLYGONSTIPPLEENABLE: 578 break; 579 case GST_RESCALENORMALENABLE: 580 break; 581 case GST_SAMPLEALPHATOCOVERAGEENABLE: 582 break; 583 case GST_SAMPLEALPHATOONEENABLE: 584 break; 585 case GST_SAMPLECOVERAGEENABLE: 586 break; 587 case GST_SCISSORTESTENABLE: 588 break; 589 case GST_STENCILTESTENABLE: 590 break; 591 case GST_STENCILENABLE: 592 break; 593 case GST_STENCILTESTTWOSIDEENABLE: 594 break; 595 case GST_TEXGENSENABLE: 596 break; 597 case GST_TEXGENTENABLE: 598 break; 599 case GST_TEXGENRENABLE: 600 break; 601 case GST_TEXGENQENABLE: 602 break; 603 case GST_TWOSIDEDSTENCILMODE: 604 break; 605 case GST_SEPARATEALPHABLENDENABLE: 606 break; 607 case GST_VERTEXPROGRAMPOINTSIZEENABLE: 608 break; 609 case GST_VERTEXPROGRAMTWOSIDEENABLE: 610 break; 611 default: 612 // todo - error 613 break; 614 } 615 } 616 //--------------------------------------------------------------------- 617 //--------------------------------------------------------------------- 618 //--------------------------------------------------------------------- CgBool4GlobalStateListener(const GlobalStateType globalStateType)619 CgFxScriptLoader::CgBool4GlobalStateListener::CgBool4GlobalStateListener( const GlobalStateType globalStateType ) 620 : CgGlobalStateListener(globalStateType, CG_BOOL4) 621 { 622 623 } 624 //--------------------------------------------------------------------- getValue(CGstateassignment cgStateAssignment)625 const CgFxScriptLoader::Vector4b CgFxScriptLoader::CgBool4GlobalStateListener::getValue( CGstateassignment cgStateAssignment ) 626 { 627 return Vector4b( cgStateAssignment ); 628 } 629 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)630 void CgFxScriptLoader::CgBool4GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 631 { 632 switch( mGlobalStateType ) 633 { 634 case GST_COLORWRITEENABLE: 635 case GST_COLORMASK: 636 case GST_PIXELSHADERCONSTANTB: 637 case GST_VERTEXSHADERCONSTANTB: 638 case GST_COLORWRITEENABLE1: 639 case GST_COLORWRITEENABLE2: 640 case GST_COLORWRITEENABLE3: 641 default: 642 // todo - error 643 break; 644 } 645 } 646 //--------------------------------------------------------------------- 647 //--------------------------------------------------------------------- 648 //--------------------------------------------------------------------- CgFloatGlobalStateListener(const GlobalStateType globalStateType)649 CgFxScriptLoader::CgFloatGlobalStateListener::CgFloatGlobalStateListener( const GlobalStateType globalStateType ) 650 : CgGlobalStateListener(globalStateType, CG_FLOAT) 651 { 652 653 } 654 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)655 void CgFxScriptLoader::CgFloatGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 656 { 657 switch( mGlobalStateType ) 658 { 659 case GST_ALPHAREF: 660 case GST_CLEARDEPTH: 661 case GST_DEPTHBIAS: 662 case GST_FOGDENSITY: 663 case GST_FOGSTART: 664 case GST_FOGEND: 665 case GST_LIGHTCONSTANTATTENUATION: 666 case GST_LIGHTATTENUATION0: 667 case GST_LIGHTLINEARATTENUATION: 668 case GST_LIGHTATTENUATION1: 669 case GST_LIGHTQUADRATICATTENUATION: 670 case GST_LIGHTATTENUATION2: 671 case GST_LIGHTSPOTCUTOFF: 672 case GST_LIGHTFALLOFF: 673 case GST_LIGHTPHI: 674 case GST_LIGHTRANGE: 675 case GST_LIGHTTHETA: 676 case GST_PATCHSEGMENTS: 677 case GST_POINTSCALE_A: 678 case GST_POINTSCALE_B: 679 case GST_POINTSCALE_C: 680 case GST_TWEENFACTOR: 681 case GST_LINEWIDTH: 682 case GST_MATERIALSHININESS: 683 case GST_MATERIALPOWER: 684 case GST_POINTFADETHRESHOLDSIZE: 685 case GST_POINTSIZE: 686 case GST_POINTSIZEMIN: 687 case GST_POINTSIZEMAX: 688 case GST_SLOPSCALEDEPTHBIAS: 689 case GST_BUMPENVLSCALE: 690 case GST_BUMPENVLOFFSET: 691 case GST_BUMPENVMAT00: 692 case GST_BUMPENVMAT01: 693 case GST_BUMPENVMAT10: 694 case GST_BUMPENVMAT11: 695 case GST_LIGHTSPOTEXPONENT: 696 default: 697 // todo - error 698 break; 699 } 700 } 701 //--------------------------------------------------------------------- getValue(CGstateassignment cgStateAssignment)702 const CgFxScriptLoader::Vector1f CgFxScriptLoader::CgFloatGlobalStateListener::getValue( CGstateassignment cgStateAssignment ) 703 { 704 return Vector1f( cgStateAssignment ); 705 } 706 //--------------------------------------------------------------------- 707 //--------------------------------------------------------------------- 708 //--------------------------------------------------------------------- CgFloat2GlobalStateListener(const GlobalStateType globalStateType)709 CgFxScriptLoader::CgFloat2GlobalStateListener::CgFloat2GlobalStateListener( const GlobalStateType globalStateType ) 710 : CgGlobalStateListener(globalStateType, CG_FLOAT2) 711 { 712 713 } 714 //--------------------------------------------------------------------- getValue(CGstateassignment cgStateAssignment)715 const CgFxScriptLoader::Vector2f CgFxScriptLoader::CgFloat2GlobalStateListener::getValue( CGstateassignment cgStateAssignment ) 716 { 717 return Vector2f( cgStateAssignment ); 718 } 719 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)720 void CgFxScriptLoader::CgFloat2GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 721 { 722 switch( mGlobalStateType ) 723 { 724 case GST_DEPTHBOUNDS: 725 case GST_DEPTHRANGE: 726 case GST_POLYGONOFFSET: 727 case GST_MAXANISOTROPY: 728 case GST_MAXMIPLEVEL: 729 default: 730 // todo - error 731 break; 732 } 733 } 734 //--------------------------------------------------------------------- 735 //--------------------------------------------------------------------- 736 //--------------------------------------------------------------------- CgFloat3GlobalStateListener(const GlobalStateType globalStateType)737 CgFxScriptLoader::CgFloat3GlobalStateListener::CgFloat3GlobalStateListener( const GlobalStateType globalStateType ) 738 : CgGlobalStateListener(globalStateType, CG_FLOAT3) 739 { 740 741 } 742 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)743 void CgFxScriptLoader::CgFloat3GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 744 { 745 switch( mGlobalStateType ) 746 { 747 case GST_POINTDISTANCEATTENUATION: 748 default: 749 // todo - error 750 break; 751 } 752 } 753 //--------------------------------------------------------------------- getValue(CGstateassignment cgStateAssignment)754 const CgFxScriptLoader::Vector3f CgFxScriptLoader::CgFloat3GlobalStateListener::getValue( CGstateassignment cgStateAssignment ) 755 { 756 return Vector3f( cgStateAssignment ); 757 } 758 //--------------------------------------------------------------------- 759 //--------------------------------------------------------------------- 760 //--------------------------------------------------------------------- CgFloat4GlobalStateListener(const GlobalStateType globalStateType)761 CgFxScriptLoader::CgFloat4GlobalStateListener::CgFloat4GlobalStateListener( const GlobalStateType globalStateType ) 762 : CgGlobalStateListener(globalStateType, CG_FLOAT4) 763 { 764 765 } 766 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)767 void CgFxScriptLoader::CgFloat4GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 768 { 769 switch( mGlobalStateType ) 770 { 771 case GST_BLENDCOLOR: 772 case GST_CLEARCOLOR: 773 case GST_CLIPPLANE: 774 case GST_FOGCOLOR: 775 case GST_FRAGMENTENVPARAMETER: 776 case GST_FRAGMENTLOCALPARAMETER: 777 case GST_LIGHTMODELAMBIENT: 778 case GST_AMBIENT: 779 case GST_LIGHTAMBIENT: 780 case GST_LIGHTDIFFUSE: 781 case GST_LIGHTPOSITION: 782 case GST_LIGHTSPECULAR: 783 case GST_LIGHTSPOTDIRECTION: 784 case GST_LIGHTDIRECTION: 785 case GST_MATERIALAMBIENT: 786 case GST_MATERIALDIFFUSE: 787 case GST_MATERIALEMISSION: 788 case GST_MATERIALEMISSIVE: 789 case GST_MATERIALSPECULAR: 790 case GST_TEXGENSOBJECTPLANE: 791 case GST_TEXGENSEYEPLANE: 792 case GST_TEXGENTOBJECTPLANE: 793 case GST_TEXGENTEYEPLANE: 794 case GST_TEXGENROBJECTPLANE: 795 case GST_TEXGENREYEPLANE: 796 case GST_TEXGENQOBJECTPLANE: 797 case GST_TEXGENQEYEPLANE: 798 case GST_TEXTUREENVCOLOR: 799 case GST_VERTEXENVPARAMETER: 800 case GST_VERTEXLOCALPARAMETER: 801 case GST_PIXELSHADERCONSTANT1: 802 case GST_VERTEXSHADERCONSTANT1: 803 case GST_PIXELSHADERCONSTANTF: 804 case GST_VERTEXSHADERCONSTANTF: 805 case GST_BORDERCOLOR: 806 default: 807 // todo - error 808 break; 809 } 810 } 811 //--------------------------------------------------------------------- getValue(CGstateassignment cgStateAssignment)812 const CgFxScriptLoader::Vector4f CgFxScriptLoader::CgFloat4GlobalStateListener::getValue( CGstateassignment cgStateAssignment ) 813 { 814 return Vector4f( cgStateAssignment ); 815 } 816 //--------------------------------------------------------------------- 817 //--------------------------------------------------------------------- 818 //--------------------------------------------------------------------- CgFloat4x2GlobalStateListener(const GlobalStateType globalStateType)819 CgFxScriptLoader::CgFloat4x2GlobalStateListener::CgFloat4x2GlobalStateListener( const GlobalStateType globalStateType ) 820 : CgGlobalStateListener(globalStateType, CG_FLOAT4x2) 821 { 822 823 } 824 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)825 void CgFxScriptLoader::CgFloat4x2GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 826 { 827 switch( mGlobalStateType ) 828 { 829 case GST_PIXELSHADERCONSTANT2: 830 case GST_VERTEXSHADERCONSTANT2: 831 default: 832 // todo - error 833 break; 834 } 835 } 836 //--------------------------------------------------------------------- 837 //--------------------------------------------------------------------- 838 //--------------------------------------------------------------------- CgFloat4x3GlobalStateListener(const GlobalStateType globalStateType)839 CgFxScriptLoader::CgFloat4x3GlobalStateListener::CgFloat4x3GlobalStateListener( const GlobalStateType globalStateType ) 840 : CgGlobalStateListener(globalStateType, CG_FLOAT4x3) 841 { 842 843 } 844 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)845 void CgFxScriptLoader::CgFloat4x3GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 846 { 847 switch( mGlobalStateType ) 848 { 849 case GST_PIXELSHADERCONSTANT3: 850 case GST_VERTEXSHADERCONSTANT3: 851 default: 852 // todo - error 853 break; 854 } 855 } 856 //--------------------------------------------------------------------- 857 //--------------------------------------------------------------------- 858 //--------------------------------------------------------------------- CgFloat4x4GlobalStateListener(const GlobalStateType globalStateType)859 CgFxScriptLoader::CgFloat4x4GlobalStateListener::CgFloat4x4GlobalStateListener( const GlobalStateType globalStateType ) 860 : CgGlobalStateListener(globalStateType, CG_FLOAT4x4) 861 { 862 863 } 864 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)865 void CgFxScriptLoader::CgFloat4x4GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 866 { 867 switch( mGlobalStateType ) 868 { 869 case GST_COLORMATRIX: 870 case GST_COLORTRANSFORM: 871 case GST_MODELVIEWMATRIX: 872 case GST_MODELVIEWTRANSFORM: 873 case GST_VIEWTRANSFORM: 874 case GST_WORLDTRANSFORM: 875 case GST_PROJECTIONMATRIX: 876 case GST_PROJECTIONTRANSFORM: 877 case GST_TEXTURETRANSFORM: 878 case GST_TEXTUREMATRIX: 879 case GST_PIXELSHADERCONSTANT: 880 case GST_VERTEXSHADERCONSTANT: 881 case GST_PIXELSHADERCONSTANT4: 882 case GST_VERTEXSHADERCONSTANT4: 883 default: 884 // todo - error 885 break; 886 } 887 } 888 //--------------------------------------------------------------------- 889 //--------------------------------------------------------------------- 890 //--------------------------------------------------------------------- CgIntGlobalStateListener(const GlobalStateType globalStateType)891 CgFxScriptLoader::CgIntGlobalStateListener::CgIntGlobalStateListener( const GlobalStateType globalStateType ) 892 : CgGlobalStateListener(globalStateType, CG_INT) 893 { 894 895 } 896 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)897 void CgFxScriptLoader::CgIntGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 898 { 899 switch( mGlobalStateType ) 900 { 901 case GST_BLENDOP: 902 case GST_CLEARSTENCIL: 903 case GST_CLIPPLANEENABLE: 904 case GST_CULLMODE: 905 case GST_ZFUNC: 906 case GST_FOGTABLEMODE: 907 case GST_FOGVERTEXMODE: 908 case GST_LIGHTTYPE: 909 case GST_MULTISAMPLEMASK: 910 case GST_AMBIENTMATERIALSOURCE: 911 case GST_DIFFUSEMATERIALSOURCE: 912 case GST_EMISSIVEMATERIALSOURCE: 913 case GST_SPECULARMATERIALSOURCE: 914 case GST_VERTEXBLEND: 915 case GST_DESTBLEND: 916 case GST_SRCBLEND: 917 case GST_STENCILMASK: 918 case GST_STENCILPASS: 919 case GST_STENCILREF: 920 case GST_STENCILWRITEMASK: 921 case GST_STENCILZFAIL: 922 case GST_TEXTUREFACTOR: 923 case GST_STENCILFAIL: 924 case GST_WRAP0: 925 case GST_WRAP1: 926 case GST_WRAP2: 927 case GST_WRAP3: 928 case GST_WRAP4: 929 case GST_WRAP5: 930 case GST_WRAP6: 931 case GST_WRAP7: 932 case GST_WRAP8: 933 case GST_WRAP9: 934 case GST_WRAP10: 935 case GST_WRAP11: 936 case GST_WRAP12: 937 case GST_WRAP13: 938 case GST_WRAP14: 939 case GST_WRAP15: 940 case GST_ADDRESSU: 941 case GST_ADDRESSV: 942 case GST_ADDRESSW: 943 case GST_MIPMAPLODBIAS: 944 case GST_BLENDOPALPHA: 945 case GST_SRCBLENDALPHA: 946 case GST_DESTBLENDALPHA: 947 case GST_ALPHAOP: 948 case GST_COLOROP: 949 case GST_ALPHAARG0: 950 case GST_ALPHAARG1: 951 case GST_ALPHAARG2: 952 case GST_COLORARG0: 953 case GST_COLORARG1: 954 case GST_COLORARG2: 955 case GST_RESULTARG: 956 case GST_TEXCOORDINDEX: 957 case GST_TEXTURETRANSFORMFLAGS: 958 case GST_MIPFILTER: // todo 959 default: 960 // todo - error 961 break; 962 } 963 } 964 //--------------------------------------------------------------------- getValue(CGstateassignment cgStateAssignment)965 const CgFxScriptLoader::Vector1i CgFxScriptLoader::CgIntGlobalStateListener::getValue( CGstateassignment cgStateAssignment ) 966 { 967 return Vector1i(cgStateAssignment); 968 } 969 //--------------------------------------------------------------------- 970 //--------------------------------------------------------------------- 971 //--------------------------------------------------------------------- CgInt2GlobalStateListener(const GlobalStateType globalStateType)972 CgFxScriptLoader::CgInt2GlobalStateListener::CgInt2GlobalStateListener( const GlobalStateType globalStateType ) 973 : CgGlobalStateListener(globalStateType, CG_INT2) 974 { 975 976 } 977 //--------------------------------------------------------------------- getValue(CGstateassignment cgStateAssignment)978 const CgFxScriptLoader::Vector2i CgFxScriptLoader::CgInt2GlobalStateListener::getValue( CGstateassignment cgStateAssignment ) 979 { 980 return Vector2i(cgStateAssignment); 981 } 982 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)983 void CgFxScriptLoader::CgInt2GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 984 { 985 switch( mGlobalStateType ) 986 { 987 case GST_LINESTIPPLE: 988 case GST_FILLMODE: 989 default: 990 // todo - error 991 break; 992 } 993 } 994 //--------------------------------------------------------------------- 995 //--------------------------------------------------------------------- 996 //--------------------------------------------------------------------- CgInt3GlobalStateListener(const GlobalStateType globalStateType)997 CgFxScriptLoader::CgInt3GlobalStateListener::CgInt3GlobalStateListener( const GlobalStateType globalStateType ) 998 : CgGlobalStateListener(globalStateType, CG_INT3) 999 { 1000 1001 } 1002 //--------------------------------------------------------------------- getValue(CGstateassignment cgStateAssignment)1003 const CgFxScriptLoader::Vector3i CgFxScriptLoader::CgInt3GlobalStateListener::getValue( CGstateassignment cgStateAssignment ) 1004 { 1005 return Vector3i(cgStateAssignment); 1006 } 1007 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1008 void CgFxScriptLoader::CgInt3GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1009 { 1010 // todo - error 1011 } 1012 //--------------------------------------------------------------------- 1013 //--------------------------------------------------------------------- 1014 //--------------------------------------------------------------------- CgInt4GlobalStateListener(const GlobalStateType globalStateType)1015 CgFxScriptLoader::CgInt4GlobalStateListener::CgInt4GlobalStateListener( const GlobalStateType globalStateType ) 1016 : CgGlobalStateListener(globalStateType, CG_INT4) 1017 { 1018 1019 } 1020 //--------------------------------------------------------------------- getValue(CGstateassignment cgStateAssignment)1021 const CgFxScriptLoader::Vector4i CgFxScriptLoader::CgInt4GlobalStateListener::getValue( CGstateassignment cgStateAssignment ) 1022 { 1023 return Vector4i(cgStateAssignment); 1024 } 1025 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1026 void CgFxScriptLoader::CgInt4GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1027 { 1028 switch( mGlobalStateType ) 1029 { 1030 case GST_SCISSOR: 1031 case GST_PIXELSHADERCONSTANTI: 1032 case GST_VERTEXSHADERCONSTANTI: 1033 default: 1034 // todo - error 1035 break; 1036 } 1037 } 1038 //--------------------------------------------------------------------- 1039 //--------------------------------------------------------------------- 1040 //--------------------------------------------------------------------- CgSamplerGlobalStateListener(const GlobalStateType globalStateType)1041 CgFxScriptLoader::CgSamplerGlobalStateListener::CgSamplerGlobalStateListener( const GlobalStateType globalStateType ) 1042 : CgGlobalStateListener(globalStateType, CG_SAMPLER) 1043 { 1044 1045 } 1046 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1047 void CgFxScriptLoader::CgSamplerGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1048 { 1049 switch( mGlobalStateType ) 1050 { 1051 case GST_SAMPLER: 1052 case GST_TEXTURE1D: 1053 default: 1054 // todo - error 1055 break; 1056 } 1057 } 1058 //--------------------------------------------------------------------- 1059 //--------------------------------------------------------------------- 1060 //--------------------------------------------------------------------- CgSampler2GlobalStateListener(const GlobalStateType globalStateType)1061 CgFxScriptLoader::CgSampler2GlobalStateListener::CgSampler2GlobalStateListener( const GlobalStateType globalStateType ) 1062 : CgGlobalStateListener(globalStateType, CG_SAMPLER2D) 1063 { 1064 1065 } 1066 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1067 void CgFxScriptLoader::CgSampler2GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1068 { 1069 switch( mGlobalStateType ) 1070 { 1071 case GST_TEXTURE2D: 1072 default: 1073 // todo - error 1074 break; 1075 } 1076 } 1077 //--------------------------------------------------------------------- 1078 //--------------------------------------------------------------------- 1079 //--------------------------------------------------------------------- CgSampler3GlobalStateListener(const GlobalStateType globalStateType)1080 CgFxScriptLoader::CgSampler3GlobalStateListener::CgSampler3GlobalStateListener( const GlobalStateType globalStateType ) 1081 : CgGlobalStateListener( globalStateType, CG_SAMPLER3D ) 1082 { 1083 1084 } 1085 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1086 void CgFxScriptLoader::CgSampler3GlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1087 { 1088 switch( mGlobalStateType ) 1089 { 1090 case GST_TEXTURE3D: 1091 default: 1092 // todo - error 1093 break; 1094 } 1095 } 1096 //--------------------------------------------------------------------- 1097 //--------------------------------------------------------------------- 1098 //--------------------------------------------------------------------- CgSamplerCubeGlobalStateListener(const GlobalStateType globalStateType)1099 CgFxScriptLoader::CgSamplerCubeGlobalStateListener::CgSamplerCubeGlobalStateListener( const GlobalStateType globalStateType ) 1100 : CgGlobalStateListener(globalStateType, CG_SAMPLERCUBE) 1101 { 1102 1103 } 1104 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1105 void CgFxScriptLoader::CgSamplerCubeGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1106 { 1107 switch( mGlobalStateType ) 1108 { 1109 case GST_TEXTURECUBEMAP: 1110 default: 1111 // todo - error 1112 break; 1113 } 1114 } 1115 //--------------------------------------------------------------------- 1116 //--------------------------------------------------------------------- 1117 //--------------------------------------------------------------------- CgSamplerRectGlobalStateListener(const GlobalStateType globalStateType)1118 CgFxScriptLoader::CgSamplerRectGlobalStateListener::CgSamplerRectGlobalStateListener( const GlobalStateType globalStateType ) 1119 : CgGlobalStateListener(globalStateType, CG_SAMPLERRECT) 1120 { 1121 1122 } 1123 updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1124 void CgFxScriptLoader::CgSamplerRectGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1125 { 1126 switch( mGlobalStateType ) 1127 { 1128 case GST_TEXTURERECTANGLE: 1129 default: 1130 // todo - error 1131 break; 1132 } 1133 } 1134 //--------------------------------------------------------------------- 1135 //--------------------------------------------------------------------- 1136 //--------------------------------------------------------------------- CgTextureGlobalStateListener(const GlobalStateType globalStateType)1137 CgFxScriptLoader::CgTextureGlobalStateListener::CgTextureGlobalStateListener( const GlobalStateType globalStateType ) 1138 : CgGlobalStateListener(globalStateType, CG_TEXTURE) 1139 { 1140 1141 } 1142 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1143 void CgFxScriptLoader::CgTextureGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1144 { 1145 switch( mGlobalStateType ) 1146 { 1147 case GST_TEXTURE: 1148 default: 1149 // todo - error 1150 break; 1151 } 1152 } 1153 //--------------------------------------------------------------------- 1154 //--------------------------------------------------------------------- 1155 //--------------------------------------------------------------------- CgProgramGlobalStateListener(const GlobalStateType globalStateType)1156 CgFxScriptLoader::CgProgramGlobalStateListener::CgProgramGlobalStateListener( const GlobalStateType globalStateType ) 1157 : CgGlobalStateListener(globalStateType, CG_PROGRAM_TYPE) 1158 { 1159 1160 } 1161 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1162 void CgFxScriptLoader::CgProgramGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1163 { 1164 switch( mGlobalStateType ) 1165 { 1166 case GST_GEOMETRYPROGRAM: 1167 case GST_VERTEXPROGRAM: 1168 case GST_VERTEXSHADER: 1169 case GST_FRAGMENTPROGRAM: 1170 case GST_PIXELSHADER: 1171 default: 1172 // todo - error 1173 break; 1174 } 1175 } 1176 //--------------------------------------------------------------------- 1177 //--------------------------------------------------------------------- 1178 //--------------------------------------------------------------------- CgBlendEquationGlobalStateListener()1179 CgFxScriptLoader::CgBlendEquationGlobalStateListener::CgBlendEquationGlobalStateListener() 1180 : CgIntGlobalStateListener(GST_BLENDEQUATION) 1181 { 1182 1183 } 1184 //--------------------------------------------------------------------- createState()1185 void CgFxScriptLoader::CgBlendEquationGlobalStateListener::createState() 1186 { 1187 CgGlobalStateListener::createState(); 1188 1189 addStateEnumerant((int)BET_FUNCADD , "FuncAdd"); 1190 addStateEnumerant((int)BET_FUNCSUBTRACT , "FuncSubtract"); 1191 addStateEnumerant((int)BET_MIN , "Min"); 1192 addStateEnumerant((int)BET_MAX , "Max"); 1193 addStateEnumerant((int)BET_LOGICOP ,"LogicOp"); 1194 } 1195 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1196 void CgFxScriptLoader::CgBlendEquationGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1197 { 1198 switch( getValue(cgStateAssignment) ) 1199 { 1200 case BET_FUNCADD: // FuncAdd 1201 case BET_FUNCSUBTRACT: // FuncSubtract 1202 case BET_MIN: // Min 1203 case BET_MAX: // Max 1204 case BET_LOGICOP: // LogicOp 1205 default: 1206 // todo - error 1207 break; 1208 } 1209 } 1210 //--------------------------------------------------------------------- 1211 //--------------------------------------------------------------------- 1212 //--------------------------------------------------------------------- CgDepthFuncGlobalStateListener()1213 CgFxScriptLoader::CgDepthFuncGlobalStateListener::CgDepthFuncGlobalStateListener() 1214 : CgIntGlobalStateListener(GST_DEPTHFUNC) 1215 { 1216 1217 } 1218 //--------------------------------------------------------------------- createState()1219 void CgFxScriptLoader::CgDepthFuncGlobalStateListener::createState() 1220 { 1221 CgGlobalStateListener::createState(); 1222 1223 addStateEnumerant((int)DFT_NEVER , "Never"); 1224 addStateEnumerant((int)DFT_LESS , "Less"); 1225 addStateEnumerant((int)DFT_LEQUAL , "LEqual"); 1226 addStateEnumerant((int)DFT_EQUAL , "Equal"); 1227 addStateEnumerant((int)DFT_GREATER , "Greater"); 1228 addStateEnumerant((int)DFT_NOTEQUAL , "NotEqual"); 1229 addStateEnumerant((int)DFT_GEQUAL , "GEqual"); 1230 addStateEnumerant((int)DFT_ALWAYS , "Always"); 1231 } 1232 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1233 void CgFxScriptLoader::CgDepthFuncGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1234 { 1235 switch( getValue(cgStateAssignment) ) 1236 { 1237 case DFT_NEVER: // Never 1238 case DFT_LESS: // Less 1239 case DFT_LEQUAL: // LEqual 1240 case DFT_EQUAL: // Equal 1241 case DFT_GREATER: // Greater 1242 case DFT_NOTEQUAL: // NotEqual 1243 case DFT_GEQUAL: // GEqual 1244 case DFT_ALWAYS : // Always 1245 default: 1246 // todo - error 1247 break; 1248 } 1249 } 1250 //--------------------------------------------------------------------- 1251 //--------------------------------------------------------------------- 1252 //--------------------------------------------------------------------- CgFogDistanceModeGlobalStateListener()1253 CgFxScriptLoader::CgFogDistanceModeGlobalStateListener::CgFogDistanceModeGlobalStateListener() 1254 : CgIntGlobalStateListener(GST_FOGDISTANCEMODE) 1255 { 1256 1257 } 1258 //--------------------------------------------------------------------- createState()1259 void CgFxScriptLoader::CgFogDistanceModeGlobalStateListener::createState() 1260 { 1261 CgGlobalStateListener::createState(); 1262 1263 addStateEnumerant((int)FDMT_EYERADIAL , "EyeRadial"); 1264 addStateEnumerant((int)FDMT_EYEPLANE , "EyePlane"); 1265 addStateEnumerant((int)FDMT_EYEPLANEABSOLUTE , "EyePlaneAbsolute"); 1266 } 1267 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1268 void CgFxScriptLoader::CgFogDistanceModeGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1269 { 1270 switch( getValue(cgStateAssignment) ) 1271 { 1272 case FDMT_EYERADIAL: // EyeRadial 1273 case FDMT_EYEPLANE: // EyePlane 1274 case FDMT_EYEPLANEABSOLUTE: // EyePlaneAbsolute 1275 default: 1276 // todo - error 1277 break; 1278 } 1279 } 1280 //--------------------------------------------------------------------- 1281 //--------------------------------------------------------------------- 1282 //--------------------------------------------------------------------- CgFogModeGlobalStateListener()1283 CgFxScriptLoader::CgFogModeGlobalStateListener::CgFogModeGlobalStateListener() 1284 : CgIntGlobalStateListener(GST_FOGMODE) 1285 { 1286 1287 } 1288 //--------------------------------------------------------------------- createState()1289 void CgFxScriptLoader::CgFogModeGlobalStateListener::createState() 1290 { 1291 CgGlobalStateListener::createState(); 1292 1293 addStateEnumerant((int)FMT_LINEAR , "Linear"); 1294 addStateEnumerant((int)FMT_EXP , "Exp"); 1295 addStateEnumerant((int)FMT_EXP2 , "Exp2"); 1296 1297 } 1298 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1299 void CgFxScriptLoader::CgFogModeGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1300 { 1301 switch( getValue(cgStateAssignment) ) 1302 { 1303 case FMT_LINEAR: // Linear 1304 case FMT_EXP: // Exp 1305 case FMT_EXP2: // Exp2 1306 default: 1307 // todo - error 1308 break; 1309 } 1310 } 1311 //--------------------------------------------------------------------- 1312 //--------------------------------------------------------------------- 1313 //--------------------------------------------------------------------- CgLightModelColorControlGlobalStateListener()1314 CgFxScriptLoader::CgLightModelColorControlGlobalStateListener::CgLightModelColorControlGlobalStateListener() 1315 : CgIntGlobalStateListener(GST_LIGHTMODELCOLORCONTROL) 1316 { 1317 1318 } 1319 //--------------------------------------------------------------------- createState()1320 void CgFxScriptLoader::CgLightModelColorControlGlobalStateListener::createState() 1321 { 1322 CgGlobalStateListener::createState(); 1323 1324 addStateEnumerant((int)LMCCT_SINGLECOLOR , "SingleColor"); 1325 addStateEnumerant((int)LMCCT_SEPARATESPECULAR , "SeparateSpecular"); 1326 1327 } 1328 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1329 void CgFxScriptLoader::CgLightModelColorControlGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1330 { 1331 switch( getValue(cgStateAssignment) ) 1332 { 1333 case LMCCT_SINGLECOLOR: // SingleColor 1334 case LMCCT_SEPARATESPECULAR: // SeparateSpecular 1335 default: 1336 // todo - error 1337 break; 1338 } 1339 } 1340 //--------------------------------------------------------------------- 1341 //--------------------------------------------------------------------- 1342 //--------------------------------------------------------------------- CgLogicOpGlobalStateListener()1343 CgFxScriptLoader::CgLogicOpGlobalStateListener::CgLogicOpGlobalStateListener() 1344 : CgIntGlobalStateListener(GST_LOGICOP) 1345 { 1346 1347 } 1348 //--------------------------------------------------------------------- createState()1349 void CgFxScriptLoader::CgLogicOpGlobalStateListener::createState() 1350 { 1351 CgGlobalStateListener::createState(); 1352 1353 addStateEnumerant((int)LOT_CLEAR , "Clear"); 1354 addStateEnumerant((int)LOT_AND , "And"); 1355 addStateEnumerant((int)LOT_ANDREVERSE , "AndReverse"); 1356 addStateEnumerant((int)LOT_COPY , "Copy"); 1357 addStateEnumerant((int)LOT_ANDINVERTED , "AndInverted"); 1358 addStateEnumerant((int)LOT_NOOP , "Noop"); 1359 addStateEnumerant((int)LOT_XOR , "Xor"); 1360 addStateEnumerant((int)LOT_OR , "Or"); 1361 addStateEnumerant((int)LOT_NOR , "Nor"); 1362 addStateEnumerant((int)LOT_EQUIV , "Equiv"); 1363 addStateEnumerant((int)LOT_INVERT , "Invert"); 1364 addStateEnumerant((int)LOT_ORREVERSE , "OrReverse"); 1365 addStateEnumerant((int)LOT_COPYINVERTED , "CopyInverted"); 1366 addStateEnumerant((int)LOT_NAND , "Nand"); 1367 addStateEnumerant((int)LOT_SET , "Set"); 1368 1369 } 1370 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1371 void CgFxScriptLoader::CgLogicOpGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1372 { 1373 switch( getValue(cgStateAssignment) ) 1374 { 1375 case LOT_CLEAR: // Clear 1376 case LOT_AND: // And 1377 case LOT_ANDREVERSE: // AndReverse 1378 case LOT_COPY: // Copy 1379 case LOT_ANDINVERTED: // AndInverted 1380 case LOT_NOOP: // Noop 1381 case LOT_XOR: // Xor 1382 case LOT_OR: // Or, 1383 case LOT_NOR: // Nor 1384 case LOT_EQUIV: // Equiv 1385 case LOT_INVERT: // Invert 1386 case LOT_ORREVERSE: // OrReverse 1387 case LOT_COPYINVERTED: // CopyInverted 1388 case LOT_NAND: // Nand 1389 case LOT_SET: // Set 1390 default: 1391 // todo - error 1392 break; 1393 } 1394 } 1395 //--------------------------------------------------------------------- 1396 //--------------------------------------------------------------------- 1397 //--------------------------------------------------------------------- CgPointSpriteCoordOriginGlobalStateListener()1398 CgFxScriptLoader::CgPointSpriteCoordOriginGlobalStateListener::CgPointSpriteCoordOriginGlobalStateListener() 1399 : CgIntGlobalStateListener(GST_POINTSPRITECOORDORIGIN) 1400 { 1401 1402 } 1403 //--------------------------------------------------------------------- createState()1404 void CgFxScriptLoader::CgPointSpriteCoordOriginGlobalStateListener::createState() 1405 { 1406 CgGlobalStateListener::createState(); 1407 1408 addStateEnumerant((int)PSCOT_LOWERLEFT , "LowerLeft"); 1409 addStateEnumerant((int)PSCOT_UPPERLEFT , "UpperLeft"); 1410 } 1411 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1412 void CgFxScriptLoader::CgPointSpriteCoordOriginGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1413 { 1414 switch( getValue(cgStateAssignment) ) 1415 { 1416 case PSCOT_LOWERLEFT: // LowerLeft 1417 case PSCOT_UPPERLEFT: // UpperLeft 1418 default: 1419 // todo - error 1420 break; 1421 } 1422 } 1423 //--------------------------------------------------------------------- 1424 //--------------------------------------------------------------------- 1425 //--------------------------------------------------------------------- CgPointSpriteRModeGlobalStateListener()1426 CgFxScriptLoader::CgPointSpriteRModeGlobalStateListener::CgPointSpriteRModeGlobalStateListener() 1427 : CgIntGlobalStateListener(GST_POINTSPRITERMODE) 1428 { 1429 1430 } 1431 //--------------------------------------------------------------------- createState()1432 void CgFxScriptLoader::CgPointSpriteRModeGlobalStateListener::createState() 1433 { 1434 CgGlobalStateListener::createState(); 1435 1436 addStateEnumerant((int)PSRMT_ZERO , "Zero"); 1437 addStateEnumerant((int)PSRMT_R , "R"); 1438 addStateEnumerant((int)PSRMT_S , "S"); 1439 } 1440 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1441 void CgFxScriptLoader::CgPointSpriteRModeGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1442 { 1443 switch( getValue(cgStateAssignment) ) 1444 { 1445 case PSRMT_ZERO: // Zero 1446 case PSRMT_R: // R 1447 case PSRMT_S: // S 1448 default: 1449 // todo - error 1450 break; 1451 } 1452 } 1453 //--------------------------------------------------------------------- 1454 //--------------------------------------------------------------------- 1455 //--------------------------------------------------------------------- 1456 CgShadeModelGlobalStateListener()1457 CgFxScriptLoader::CgShadeModelGlobalStateListener::CgShadeModelGlobalStateListener() 1458 : CgIntGlobalStateListener(GST_SHADEMODEL) 1459 { 1460 1461 } 1462 //--------------------------------------------------------------------- createState()1463 void CgFxScriptLoader::CgShadeModelGlobalStateListener::createState() 1464 { 1465 CgGlobalStateListener::createState(); 1466 1467 addStateEnumerant((int)SMT_FLAT , "Flat"); 1468 addStateEnumerant((int)SMT_SMOOTH , "Smooth"); 1469 1470 } 1471 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1472 void CgFxScriptLoader::CgShadeModelGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1473 { 1474 switch( getValue(cgStateAssignment) ) 1475 { 1476 case SMT_FLAT: // Flat 1477 case SMT_SMOOTH: // Smooth 1478 default: 1479 // todo - error 1480 break; 1481 } 1482 1483 } 1484 //--------------------------------------------------------------------- 1485 //--------------------------------------------------------------------- 1486 //--------------------------------------------------------------------- CgTexGenModeGlobalStateListener(const GlobalStateType globalStateType)1487 CgFxScriptLoader::CgTexGenModeGlobalStateListener::CgTexGenModeGlobalStateListener(const GlobalStateType globalStateType) 1488 : CgIntGlobalStateListener(globalStateType) 1489 { 1490 1491 } 1492 //--------------------------------------------------------------------- createState()1493 void CgFxScriptLoader::CgTexGenModeGlobalStateListener::createState() 1494 { 1495 CgGlobalStateListener::createState(); 1496 1497 addStateEnumerant((int)TGMT_OBJECTLINEAR, "ObjectLinear"); 1498 addStateEnumerant((int)TGMT_EYELINEAR, "EyeLinear"); 1499 addStateEnumerant((int)TGMT_SPHEREMAP, "SphereMap"); 1500 addStateEnumerant((int)TGMT_REFLECTIONMAP, "ReflectionMap"); 1501 addStateEnumerant((int)TGMT_NORMALMAP, "NormalMap"); 1502 1503 } 1504 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1505 void CgFxScriptLoader::CgTexGenModeGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1506 { 1507 switch( getValue(cgStateAssignment) ) 1508 { 1509 case TGMT_OBJECTLINEAR: // ObjectLinear 1510 case TGMT_EYELINEAR: // EyeLinear 1511 case TGMT_SPHEREMAP: // SphereMap 1512 case TGMT_REFLECTIONMAP: // ReflectionMap 1513 case TGMT_NORMALMAP: // NormalMap 1514 default: 1515 // todo - error 1516 break; 1517 } 1518 } 1519 //--------------------------------------------------------------------- 1520 //--------------------------------------------------------------------- 1521 //--------------------------------------------------------------------- CgTextureEnvModeGlobalStateListener()1522 CgFxScriptLoader::CgTextureEnvModeGlobalStateListener::CgTextureEnvModeGlobalStateListener() 1523 : CgIntGlobalStateListener(GST_TEXTUREENVMODE) 1524 { 1525 1526 } 1527 //--------------------------------------------------------------------- createState()1528 void CgFxScriptLoader::CgTextureEnvModeGlobalStateListener::createState() 1529 { 1530 CgGlobalStateListener::createState(); 1531 1532 addStateEnumerant((int)BET_MODULATE, "Modulate"); 1533 addStateEnumerant((int)BET_DECAL, "Decal"); 1534 addStateEnumerant((int)BET_BLEND, "Blend"); 1535 addStateEnumerant((int)BET_REPLACE, "Replace"); 1536 addStateEnumerant((int)BET_ADD, "Add"); 1537 } 1538 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1539 void CgFxScriptLoader::CgTextureEnvModeGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1540 { 1541 switch( getValue(cgStateAssignment) ) 1542 { 1543 case BET_MODULATE: // Modulate 1544 case BET_DECAL: // Decal 1545 case BET_BLEND: // Blend 1546 case BET_REPLACE: // Replace 1547 case BET_ADD: // Add 1548 default: 1549 // todo - error 1550 break; 1551 } 1552 } 1553 //--------------------------------------------------------------------- 1554 //--------------------------------------------------------------------- 1555 //--------------------------------------------------------------------- CgMinFilterGlobalStateListener()1556 CgFxScriptLoader::CgMinFilterGlobalStateListener::CgMinFilterGlobalStateListener() 1557 : CgIntGlobalStateListener(GST_MINFILTER) 1558 { 1559 1560 } 1561 //--------------------------------------------------------------------- createState()1562 void CgFxScriptLoader::CgMinFilterGlobalStateListener::createState() 1563 { 1564 CgGlobalStateListener::createState(); 1565 1566 addStateEnumerant((int)MFT_NEAREST, "Nearest"); 1567 addStateEnumerant((int)MFT_LINEAR, "Linear"); 1568 addStateEnumerant((int)MFT_LINEARMIPMAPNEAREST, "LinearMipMapNearest"); 1569 addStateEnumerant((int)MFT_NEARESTMIPMAPNEAREST, "NearestMipMapNearest"); 1570 addStateEnumerant((int)MFT_NEARESTMIPMAPLINEAR, "NearestMipMapLinear"); 1571 addStateEnumerant((int)MFT_LINEARMIPMAPLINEAR, "LinearMipMapLinear"); 1572 } 1573 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1574 void CgFxScriptLoader::CgMinFilterGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1575 { 1576 switch( getValue(cgStateAssignment) ) 1577 { 1578 case MFT_NEAREST: // Nearest 1579 case MFT_LINEAR: // Linear 1580 case MFT_LINEARMIPMAPNEAREST: // LinearMipMapNearest 1581 case MFT_NEARESTMIPMAPNEAREST: // NearestMipMapNearest 1582 case MFT_NEARESTMIPMAPLINEAR: // NearestMipMapLinear 1583 case MFT_LINEARMIPMAPLINEAR: // LinearMipMapLinear 1584 default: 1585 // todo - error 1586 break; 1587 } 1588 } 1589 //--------------------------------------------------------------------- 1590 //--------------------------------------------------------------------- 1591 //--------------------------------------------------------------------- CgMagFilterGlobalStateListener()1592 CgFxScriptLoader::CgMagFilterGlobalStateListener::CgMagFilterGlobalStateListener() 1593 : CgIntGlobalStateListener(GST_MAGFILTER) 1594 { 1595 1596 } 1597 //--------------------------------------------------------------------- createState()1598 void CgFxScriptLoader::CgMagFilterGlobalStateListener::createState() 1599 { 1600 CgGlobalStateListener::createState(); 1601 1602 addStateEnumerant((int)MFT_NEAREST, "Nearest"); 1603 addStateEnumerant((int)MFT_LINEAR, "Linear"); 1604 } 1605 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1606 void CgFxScriptLoader::CgMagFilterGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1607 { 1608 switch( getValue(cgStateAssignment) ) 1609 { 1610 case MFT_NEAREST: // Nearest 1611 case MFT_LINEAR: // Linear 1612 default: 1613 // todo - error 1614 break; 1615 } 1616 } 1617 //--------------------------------------------------------------------- 1618 //--------------------------------------------------------------------- 1619 //--------------------------------------------------------------------- CgFrontFaceGlobalStateListener()1620 CgFxScriptLoader::CgFrontFaceGlobalStateListener::CgFrontFaceGlobalStateListener() 1621 : CgIntGlobalStateListener(GST_FRONTFACE) 1622 { 1623 1624 } 1625 //--------------------------------------------------------------------- createState()1626 void CgFxScriptLoader::CgFrontFaceGlobalStateListener::createState() 1627 { 1628 CgGlobalStateListener::createState(); 1629 1630 addStateEnumerant((int)FFT_CW, "CW"); 1631 addStateEnumerant((int)FFT_CCW, "CCW"); 1632 } 1633 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1634 void CgFxScriptLoader::CgFrontFaceGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1635 { 1636 switch( getValue(cgStateAssignment) ) 1637 { 1638 case FFT_CW: // CW 1639 case FFT_CCW: // CCW 1640 default: 1641 // todo - error 1642 break; 1643 } 1644 } 1645 //--------------------------------------------------------------------- 1646 //--------------------------------------------------------------------- 1647 //--------------------------------------------------------------------- CgCullFaceGlobalStateListener()1648 CgFxScriptLoader::CgCullFaceGlobalStateListener::CgCullFaceGlobalStateListener() 1649 : CgIntGlobalStateListener(GST_CULLFACE) 1650 { 1651 1652 } 1653 //--------------------------------------------------------------------- createState()1654 void CgFxScriptLoader::CgCullFaceGlobalStateListener::createState() 1655 { 1656 CgGlobalStateListener::createState(); 1657 1658 addStateEnumerant((int)CFT_FRONT, "Front"); 1659 addStateEnumerant((int)CFT_BACK, "Back"); 1660 addStateEnumerant((int)CFT_FRONTANDBACK, "FrontAndBack"); 1661 } 1662 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1663 void CgFxScriptLoader::CgCullFaceGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1664 { 1665 switch( getValue(cgStateAssignment) ) 1666 { 1667 case CFT_FRONT: // Front 1668 case CFT_BACK: // Back 1669 case CFT_FRONTANDBACK: // FrontAndBack 1670 default: 1671 // todo - error 1672 break; 1673 } 1674 } 1675 //--------------------------------------------------------------------- 1676 //--------------------------------------------------------------------- 1677 //--------------------------------------------------------------------- CgFogCoordSrcGlobalStateListener()1678 CgFxScriptLoader::CgFogCoordSrcGlobalStateListener::CgFogCoordSrcGlobalStateListener() 1679 : CgIntGlobalStateListener(GST_FOGCOORDSRC) 1680 { 1681 1682 } 1683 //--------------------------------------------------------------------- createState()1684 void CgFxScriptLoader::CgFogCoordSrcGlobalStateListener::createState() 1685 { 1686 CgGlobalStateListener::createState(); 1687 1688 addStateEnumerant((int)FCST_FRAGMENTDEPTH, "FragmentDepth"); 1689 addStateEnumerant((int)FCST_FOGCOORD, "FogCoord"); 1690 } 1691 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1692 void CgFxScriptLoader::CgFogCoordSrcGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1693 { 1694 switch( getValue(cgStateAssignment) ) 1695 { 1696 case FCST_FRAGMENTDEPTH: // FragmentDepth 1697 case FCST_FOGCOORD: // FogCoord 1698 default: 1699 // todo - error 1700 break; 1701 } 1702 } 1703 //--------------------------------------------------------------------- 1704 //--------------------------------------------------------------------- 1705 //--------------------------------------------------------------------- CgAlphaFuncGlobalStateListener()1706 CgFxScriptLoader::CgAlphaFuncGlobalStateListener::CgAlphaFuncGlobalStateListener() 1707 : CgFloat2GlobalStateListener(GST_ALPHAFUNC) 1708 { 1709 1710 } 1711 //--------------------------------------------------------------------- createState()1712 void CgFxScriptLoader::CgAlphaFuncGlobalStateListener::createState() 1713 { 1714 CgGlobalStateListener::createState(); 1715 1716 addStateEnumerant((int)AFT_NEVER, "Never"); 1717 addStateEnumerant((int)AFT_LESS, "Less"); 1718 addStateEnumerant((int)AFT_LEQUAL, "LEqual"); 1719 addStateEnumerant((int)AFT_EQUAL, "Equal"); 1720 addStateEnumerant((int)AFT_GREATER, "Greater"); 1721 addStateEnumerant((int)AFT_NOTEQUAL, "NotEqual"); 1722 addStateEnumerant((int)AFT_GEQUAL, "GEqual"); 1723 addStateEnumerant((int)AFT_ALWAYS, "Always"); 1724 } 1725 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1726 void CgFxScriptLoader::CgAlphaFuncGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1727 { 1728 switch( static_cast<int>(getValue(cgStateAssignment).x) ) 1729 { 1730 case AFT_NEVER: // Never 1731 case AFT_LESS: // Less 1732 case AFT_LEQUAL: // LEqual 1733 case AFT_EQUAL: // Equal 1734 case AFT_GREATER: // Greater 1735 case AFT_NOTEQUAL: // NotEqual 1736 case AFT_GEQUAL: // GEqual 1737 case AFT_ALWAYS: // Always 1738 default: 1739 // todo - error 1740 break; 1741 } 1742 } 1743 //--------------------------------------------------------------------- 1744 //--------------------------------------------------------------------- 1745 //--------------------------------------------------------------------- CgBlendFuncGlobalStateListener()1746 CgFxScriptLoader::CgBlendFuncGlobalStateListener::CgBlendFuncGlobalStateListener() 1747 : CgInt2GlobalStateListener(GST_BLENDFUNC) 1748 { 1749 1750 } 1751 //--------------------------------------------------------------------- 1752 //--------------------------------------------------------------------- 1753 //--------------------------------------------------------------------- createState()1754 void CgFxScriptLoader::CgBlendFuncGlobalStateListener::createState() 1755 { 1756 CgGlobalStateListener::createState(); 1757 1758 addStateEnumerant((int)BF_ZERO, "Zero"); 1759 addStateEnumerant((int)BF_ONE, "One"); 1760 addStateEnumerant((int)BF_DESTCOLOR, "DestColor"); 1761 addStateEnumerant((int)BF_ONEMINUSDESTCOLOR, "OneMinusDestColor"); 1762 addStateEnumerant((int)BF_SRCALPHA, "SrcAlpha"); 1763 addStateEnumerant((int)BF_ONEMINUSSRCALPHA, "OneMinusSrcAlpha"); 1764 addStateEnumerant((int)BF_DSTALPHA, "DstAlpha"); 1765 addStateEnumerant((int)BF_ONEMINUSDSTALPHA, "OneMinusDstAlpha"); 1766 addStateEnumerant((int)BF_SRCALPHASATURATE, "SrcAlphaSaturate"); 1767 addStateEnumerant((int)BF_SRCCOLOR, "SrcColor"); 1768 addStateEnumerant((int)BF_ONEMINUSSRCCOLOR, "OneMinusSrcColor"); 1769 addStateEnumerant((int)BF_CONSTANTCOLOR, "ConstantColor"); 1770 addStateEnumerant((int)BF_ONEMINUSCONSTANTCOLOR, "OneMinusConstantColor"); 1771 addStateEnumerant((int)BF_CONSTANTALPHA, "ConstantAlpha"); 1772 addStateEnumerant((int)BF_ONEMINUSCONSTANTALPHA, "OneMinusConstantAlpha"); 1773 } 1774 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1775 void CgFxScriptLoader::CgBlendFuncGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1776 { 1777 switch( getValue(cgStateAssignment).x ) 1778 { 1779 case BF_ZERO: // Zero 1780 case BF_ONE: // One 1781 case BF_DESTCOLOR: // DestColor 1782 case BF_ONEMINUSDESTCOLOR: // OneMinusDestColor 1783 case BF_SRCALPHA: // SrcAlpha 1784 case BF_ONEMINUSSRCALPHA: // OneMinusSrcAlpha 1785 case BF_DSTALPHA: // DstAlpha 1786 case BF_ONEMINUSDSTALPHA: // OneMinusDstAlpha 1787 case BF_SRCALPHASATURATE: // SrcAlphaSaturate 1788 case BF_SRCCOLOR: // SrcColor 1789 case BF_ONEMINUSSRCCOLOR: // OneMinusSrcColor 1790 case BF_CONSTANTCOLOR: // ConstantColor 1791 case BF_ONEMINUSCONSTANTCOLOR: // OneMinusConstantColor 1792 case BF_CONSTANTALPHA: // ConstantAlpha 1793 case BF_ONEMINUSCONSTANTALPHA: // OneMinusConstantAlpha 1794 default: 1795 // todo - error 1796 break; 1797 } 1798 } 1799 //--------------------------------------------------------------------- 1800 //--------------------------------------------------------------------- 1801 //--------------------------------------------------------------------- CgBlendFuncSeparateGlobalStateListener()1802 CgFxScriptLoader::CgBlendFuncSeparateGlobalStateListener::CgBlendFuncSeparateGlobalStateListener() 1803 : CgInt4GlobalStateListener(GST_BLENDFUNCSEPARATE) 1804 { 1805 1806 } 1807 //--------------------------------------------------------------------- createState()1808 void CgFxScriptLoader::CgBlendFuncSeparateGlobalStateListener::createState() 1809 { 1810 CgGlobalStateListener::createState(); 1811 1812 addStateEnumerant((int)BFST_ZERO, "Zero"); 1813 addStateEnumerant((int)BFST_ONE, "One"); 1814 addStateEnumerant((int)BFST_DESTCOLOR, "DestColor"); 1815 addStateEnumerant((int)BFST_ONEMINUSDESTCOLOR, "OneMinusDestColor"); 1816 addStateEnumerant((int)BFST_SRCALPHA, "SrcAlpha"); 1817 addStateEnumerant((int)BFST_ONEMINUSSRCALPHA, "OneMinusSrcAlpha"); 1818 addStateEnumerant((int)BFST_DSTALPHA, "DstAlpha"); 1819 addStateEnumerant((int)BFST_ONEMINUSDSTALPHA, "OneMinusDstAlpha"); 1820 addStateEnumerant((int)BFST_SRCALPHASATURATE, "SrcAlphaSaturate"); 1821 addStateEnumerant((int)BFST_SRCCOLOR, "SrcColor"); 1822 addStateEnumerant((int)BFST_ONEMINUSSRCCOLOR, "OneMinusSrcColor"); 1823 addStateEnumerant((int)BFST_CONSTANTCOLOR, "ConstantColor"); 1824 addStateEnumerant((int)BFST_ONEMINUSCONSTANTCOLOR, "OneMinusConstantColor"); 1825 addStateEnumerant((int)BFST_CONSTANTALPHA, "ConstantAlpha"); 1826 addStateEnumerant((int)BFST_ONEMINUSCONSTANTALPHA, "OneMinusConstantAlpha"); 1827 } 1828 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1829 void CgFxScriptLoader::CgBlendFuncSeparateGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1830 { 1831 switch( getValue(cgStateAssignment).x ) 1832 { 1833 case BFST_ZERO: // Zero 1834 case BFST_ONE: // One 1835 case BFST_DESTCOLOR: // DestColor 1836 case BFST_ONEMINUSDESTCOLOR: // OneMinusDestColor 1837 case BFST_SRCALPHA: // SrcAlpha 1838 case BFST_ONEMINUSSRCALPHA: // OneMinusSrcAlpha 1839 case BFST_DSTALPHA: // DstAlpha 1840 case BFST_ONEMINUSDSTALPHA: // OneMinusDstAlpha 1841 case BFST_SRCALPHASATURATE: // SrcAlphaSaturate 1842 case BFST_SRCCOLOR: // SrcColor 1843 case BFST_ONEMINUSSRCCOLOR: // OneMinusSrcColor 1844 case BFST_CONSTANTCOLOR: // ConstantColor 1845 case BFST_ONEMINUSCONSTANTCOLOR: // OneMinusConstantColor 1846 case BFST_CONSTANTALPHA: // ConstantAlpha 1847 case BFST_ONEMINUSCONSTANTALPHA: // OneMinusConstantAlpha 1848 default: 1849 // todo - error 1850 break; 1851 } 1852 } 1853 //--------------------------------------------------------------------- 1854 //--------------------------------------------------------------------- 1855 //--------------------------------------------------------------------- CgBlendEquationSeparateGlobalStateListener()1856 CgFxScriptLoader::CgBlendEquationSeparateGlobalStateListener::CgBlendEquationSeparateGlobalStateListener() 1857 : CgInt2GlobalStateListener(GST_BLENDEQUATIONSEPARATE) 1858 { 1859 1860 } 1861 //--------------------------------------------------------------------- createState()1862 void CgFxScriptLoader::CgBlendEquationSeparateGlobalStateListener::createState() 1863 { 1864 CgGlobalStateListener::createState(); 1865 1866 addStateEnumerant((int)BEST_FUNCADD, "FuncAdd"); 1867 addStateEnumerant((int)BEST_FUNCSUBTRACT, "FuncSubtract"); 1868 addStateEnumerant((int)BEST_MIN, "Min"); 1869 addStateEnumerant((int)BEST_MAX, "Max"); 1870 addStateEnumerant((int)BEST_LOGICOP, "LogicOp"); 1871 } 1872 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1873 void CgFxScriptLoader::CgBlendEquationSeparateGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1874 { 1875 switch( getValue(cgStateAssignment).x ) 1876 { 1877 case BEST_FUNCADD: // FuncAdd 1878 case BEST_FUNCSUBTRACT: // FuncSubtract 1879 case BEST_MIN: // Min 1880 case BEST_MAX: // Max 1881 case BEST_LOGICOP: // LogicOp 1882 default: 1883 // todo - error 1884 break; 1885 } 1886 } 1887 //--------------------------------------------------------------------- 1888 //--------------------------------------------------------------------- 1889 //--------------------------------------------------------------------- CgColorMaterialGlobalStateListener()1890 CgFxScriptLoader::CgColorMaterialGlobalStateListener::CgColorMaterialGlobalStateListener() 1891 : CgInt2GlobalStateListener(GST_COLORMATERIAL) 1892 { 1893 1894 } 1895 //--------------------------------------------------------------------- createState()1896 void CgFxScriptLoader::CgColorMaterialGlobalStateListener::createState() 1897 { 1898 CgGlobalStateListener::createState(); 1899 1900 addStateEnumerant((int)CMT_FRONT, "Front"); 1901 addStateEnumerant((int)CMT_BACK, "Back"); 1902 addStateEnumerant((int)CMT_FRONTANDBACK, "FrontAndBack"); 1903 addStateEnumerant((int)CMT_EMISSION, "Emission"); 1904 addStateEnumerant((int)CMT_AMBIENT, "Ambient"); 1905 addStateEnumerant((int)CMT_DIFFUSE, "Diffuse"); 1906 addStateEnumerant((int)CMT_SPECULAR, "Specular"); 1907 addStateEnumerant((int)CMT_AMBIENTANDDIFFUSE, "AmbientAndDiffuse"); 1908 } 1909 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1910 void CgFxScriptLoader::CgColorMaterialGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1911 { 1912 switch( getValue(cgStateAssignment).x ) 1913 { 1914 case CMT_FRONT: // Front 1915 case CMT_BACK: // Back 1916 case CMT_FRONTANDBACK: // FrontAndBack 1917 case CMT_EMISSION: // Emission 1918 case CMT_AMBIENT: // Ambient 1919 case CMT_DIFFUSE: // Diffuse 1920 case CMT_SPECULAR: // Specular 1921 case CMT_AMBIENTANDDIFFUSE: // AmbientAndDiffuse 1922 default: 1923 // todo - error 1924 break; 1925 } 1926 } 1927 //--------------------------------------------------------------------- 1928 //--------------------------------------------------------------------- 1929 //--------------------------------------------------------------------- CgPolygonModeGlobalStateListener()1930 CgFxScriptLoader::CgPolygonModeGlobalStateListener::CgPolygonModeGlobalStateListener() 1931 : CgInt2GlobalStateListener(GST_POLYGONMODE) 1932 { 1933 1934 } 1935 //--------------------------------------------------------------------- createState()1936 void CgFxScriptLoader::CgPolygonModeGlobalStateListener::createState() 1937 { 1938 CgGlobalStateListener::createState(); 1939 1940 addStateEnumerant((int)PMT_FRONT, "Front"); 1941 addStateEnumerant((int)PMT_BACK, "Back"); 1942 addStateEnumerant((int)PMT_FRONTANDBACK, "FrontAndBack"); 1943 addStateEnumerant((int)PMT_POINT, "Point"); 1944 addStateEnumerant((int)PMT_LINE, "Line"); 1945 addStateEnumerant((int)PMT_FILL, "Fill"); 1946 } 1947 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1948 void CgFxScriptLoader::CgPolygonModeGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1949 { 1950 switch( getValue(cgStateAssignment).x ) 1951 { 1952 case PMT_FRONT: // Front 1953 case PMT_BACK: // Back 1954 case PMT_FRONTANDBACK: // FrontAndBack 1955 case PMT_POINT: // Point 1956 case PMT_LINE: // Line 1957 case PMT_FILL: // Fill 1958 default: 1959 // todo - error 1960 break; 1961 } 1962 } 1963 //--------------------------------------------------------------------- 1964 //--------------------------------------------------------------------- 1965 //--------------------------------------------------------------------- CgStencilFuncGlobalStateListener()1966 CgFxScriptLoader::CgStencilFuncGlobalStateListener::CgStencilFuncGlobalStateListener() 1967 : CgInt3GlobalStateListener(GST_STENCILFUNC) 1968 { 1969 1970 } 1971 //--------------------------------------------------------------------- createState()1972 void CgFxScriptLoader::CgStencilFuncGlobalStateListener::createState() 1973 { 1974 CgGlobalStateListener::createState(); 1975 addStateEnumerant((int)SFT_NEVER, "Never"); 1976 addStateEnumerant((int)SFT_LESS, "Less"); 1977 addStateEnumerant((int)SFT_LEQUAL, "LEqual"); 1978 addStateEnumerant((int)SFT_EQUAL, "Equal"); 1979 addStateEnumerant((int)SFT_GREATER, "Greater"); 1980 addStateEnumerant((int)SFT_NOTEQUAL, "NotEqual"); 1981 addStateEnumerant((int)SFT_GEQUAL, "GEqual"); 1982 addStateEnumerant((int)SFT_ALWAYS, "Always"); 1983 } 1984 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)1985 void CgFxScriptLoader::CgStencilFuncGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 1986 { 1987 switch( getValue(cgStateAssignment).x ) 1988 { 1989 case SFT_NEVER: // Never 1990 case SFT_LESS: // Less 1991 case SFT_LEQUAL: // LEqual 1992 case SFT_EQUAL: // Equal 1993 case SFT_GREATER: // Greater 1994 case SFT_NOTEQUAL: // NotEqual 1995 case SFT_GEQUAL: // GEqual 1996 case SFT_ALWAYS: // Always 1997 default: 1998 // todo - error 1999 break; 2000 } 2001 } 2002 //--------------------------------------------------------------------- 2003 //--------------------------------------------------------------------- 2004 //--------------------------------------------------------------------- CgStencilOpGlobalStateListener()2005 CgFxScriptLoader::CgStencilOpGlobalStateListener::CgStencilOpGlobalStateListener() 2006 : CgInt3GlobalStateListener(GST_STENCILOP) 2007 { 2008 2009 } 2010 //--------------------------------------------------------------------- createState()2011 void CgFxScriptLoader::CgStencilOpGlobalStateListener::createState() 2012 { 2013 CgGlobalStateListener::createState(); 2014 addStateEnumerant((int)SOT_KEEP, "Keep"); 2015 addStateEnumerant((int)SOT_ZERO, "Zero"); 2016 addStateEnumerant((int)SOT_REPLACE, "Replace"); 2017 addStateEnumerant((int)SOT_INCR, "Incr"); 2018 addStateEnumerant((int)SOT_DECR, "Decr"); 2019 addStateEnumerant((int)SOT_INVERT, "Invert"); 2020 addStateEnumerant((int)SOT_INCRWRAP, "IncrWrap"); 2021 addStateEnumerant((int)SOT_DECRWRAP, "DecrWrap"); 2022 } 2023 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)2024 void CgFxScriptLoader::CgStencilOpGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 2025 { 2026 switch( getValue(cgStateAssignment).x ) 2027 { 2028 case SOT_KEEP: // Keep 2029 case SOT_ZERO: // Zero 2030 case SOT_REPLACE: // Replace 2031 case SOT_INCR: // Incr 2032 case SOT_DECR: // Decr 2033 case SOT_INVERT: // Invert 2034 case SOT_INCRWRAP: // IncrWrap 2035 case SOT_DECRWRAP: // DecrWrap 2036 default: 2037 // todo - error 2038 break; 2039 } 2040 } 2041 //--------------------------------------------------------------------- 2042 //--------------------------------------------------------------------- 2043 //--------------------------------------------------------------------- CgStencilFuncSeparateGlobalStateListener()2044 CgFxScriptLoader::CgStencilFuncSeparateGlobalStateListener::CgStencilFuncSeparateGlobalStateListener() 2045 : CgInt4GlobalStateListener(GST_STENCILFUNCSEPARATE) 2046 { 2047 2048 } 2049 //--------------------------------------------------------------------- createState()2050 void CgFxScriptLoader::CgStencilFuncSeparateGlobalStateListener::createState() 2051 { 2052 CgGlobalStateListener::createState(); 2053 addStateEnumerant((int)SFST_FRONT, "Front"); 2054 addStateEnumerant((int)SFST_BACK, "Back"); 2055 addStateEnumerant((int)SFST_FRONTANDBACK, "FrontAndBack"); 2056 addStateEnumerant((int)SFST_NEVER, "Never"); 2057 addStateEnumerant((int)SFST_LESS, "Less"); 2058 addStateEnumerant((int)SFST_LEQUAL, "LEqual"); 2059 addStateEnumerant((int)SFST_EQUAL, "Equal"); 2060 addStateEnumerant((int)SFST_GREATER, "Greater"); 2061 addStateEnumerant((int)SFST_NOTEQUAL, "NotEqual"); 2062 addStateEnumerant((int)SFST_GEQUAL, "GEqual"); 2063 addStateEnumerant((int)SFST_ALWAYS, "Always"); 2064 } 2065 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)2066 void CgFxScriptLoader::CgStencilFuncSeparateGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 2067 { 2068 switch( getValue(cgStateAssignment).x ) 2069 { 2070 case SFST_FRONT: // Front 2071 case SFST_BACK: // Back 2072 case SFST_FRONTANDBACK: // FrontAndBack 2073 case SFST_NEVER: // Never 2074 case SFST_LESS: // Less 2075 case SFST_LEQUAL: // LEqual 2076 case SFST_EQUAL: // Equal 2077 case SFST_GREATER: // Greater 2078 case SFST_NOTEQUAL: // NotEqual 2079 case SFST_GEQUAL: // GEqual 2080 case SFST_ALWAYS: // Always 2081 default: 2082 // todo - error 2083 break; 2084 } 2085 } 2086 //--------------------------------------------------------------------- 2087 //--------------------------------------------------------------------- 2088 //--------------------------------------------------------------------- CgStencilMaskSeparateGlobalStateListener()2089 CgFxScriptLoader::CgStencilMaskSeparateGlobalStateListener::CgStencilMaskSeparateGlobalStateListener() 2090 : CgInt2GlobalStateListener(GST_STENCILMASKSEPARATE) 2091 { 2092 2093 } 2094 //--------------------------------------------------------------------- createState()2095 void CgFxScriptLoader::CgStencilMaskSeparateGlobalStateListener::createState() 2096 { 2097 CgGlobalStateListener::createState(); 2098 addStateEnumerant((int)BET_FRONT, "Front"); 2099 addStateEnumerant((int)BET_BACK, "Back"); 2100 addStateEnumerant((int)BET_FRONTANDBACK, "FrontAndBack"); 2101 } 2102 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)2103 void CgFxScriptLoader::CgStencilMaskSeparateGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 2104 { 2105 switch( getValue(cgStateAssignment).x ) 2106 { 2107 case BET_FRONT: // Front 2108 case BET_BACK: // Back 2109 case BET_FRONTANDBACK: // FrontAndBack 2110 default: 2111 // todo - error 2112 break; 2113 } 2114 } 2115 //--------------------------------------------------------------------- 2116 //--------------------------------------------------------------------- 2117 //--------------------------------------------------------------------- CgStencilOpSeparateGlobalStateListener()2118 CgFxScriptLoader::CgStencilOpSeparateGlobalStateListener::CgStencilOpSeparateGlobalStateListener() 2119 : CgInt4GlobalStateListener(GST_STENCILOPSEPARATE) 2120 { 2121 2122 } 2123 //--------------------------------------------------------------------- createState()2124 void CgFxScriptLoader::CgStencilOpSeparateGlobalStateListener::createState() 2125 { 2126 CgGlobalStateListener::createState(); 2127 addStateEnumerant((int)BET_KEEP, "Keep"); 2128 addStateEnumerant((int)BET_ZERO, "Zero"); 2129 addStateEnumerant((int)BET_REPLACE, "Replace"); 2130 addStateEnumerant((int)BET_INCR, "Incr"); 2131 addStateEnumerant((int)BET_DECR, "Decr"); 2132 addStateEnumerant((int)BET_INVERT, "Invert"); 2133 addStateEnumerant((int)BET_INCRWRAP, "IncrWrap"); 2134 addStateEnumerant((int)BET_DECRWRAP, "DecrWrap"); 2135 } 2136 //--------------------------------------------------------------------- updatePass(Pass * ogrePass,CGstateassignment cgStateAssignment)2137 void CgFxScriptLoader::CgStencilOpSeparateGlobalStateListener::updatePass( Pass * ogrePass, CGstateassignment cgStateAssignment ) 2138 { 2139 switch( getValue(cgStateAssignment).x ) 2140 { 2141 case BET_KEEP: // Keep 2142 case BET_ZERO: // Zero 2143 case BET_REPLACE: // Replace 2144 case BET_INCR: // Incr 2145 case BET_DECR: // Decr 2146 case BET_INVERT: // Invert 2147 case BET_INCRWRAP: // IncrWrap 2148 case BET_DECRWRAP: // DecrWrap 2149 default: 2150 // todo - error 2151 break; 2152 } 2153 } 2154 //--------------------------------------------------------------------- 2155 //--------------------------------------------------------------------- 2156 //--------------------------------------------------------------------- CgSamplerStateListener(SamplerStateType samplerStateType,CGtype cgType)2157 CgFxScriptLoader::CgSamplerStateListener::CgSamplerStateListener( SamplerStateType samplerStateType, CGtype cgType ) 2158 :CgStateListener(cgType), 2159 mSamplerStateType(samplerStateType) 2160 { 2161 2162 } 2163 //--------------------------------------------------------------------- ~CgSamplerStateListener()2164 CgFxScriptLoader::CgSamplerStateListener::~CgSamplerStateListener() 2165 { 2166 2167 } 2168 //--------------------------------------------------------------------- createState()2169 void CgFxScriptLoader::CgSamplerStateListener::createState() 2170 { 2171 const char * typeNameAsString = CgFxScriptLoader::getSingleton().getSamplerStateNameTypeToString(mSamplerStateType); 2172 mCgState = cgCreateSamplerState( mCgContext, typeNameAsString, mCgType ); 2173 } 2174 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2175 void CgFxScriptLoader::CgSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2176 { 2177 2178 } 2179 //--------------------------------------------------------------------- 2180 //--------------------------------------------------------------------- 2181 //--------------------------------------------------------------------- CgIntSamplerStateListener(const SamplerStateType samplerStateType)2182 CgFxScriptLoader::CgIntSamplerStateListener::CgIntSamplerStateListener(const SamplerStateType samplerStateType) 2183 : CgSamplerStateListener(samplerStateType, CG_INT) 2184 { 2185 2186 } 2187 //--------------------------------------------------------------------- getValue(CGstateassignment cgStateAssignment)2188 const CgFxScriptLoader::Vector1i CgFxScriptLoader::CgIntSamplerStateListener::getValue( CGstateassignment cgStateAssignment ) 2189 { 2190 return Vector1i(cgStateAssignment); 2191 2192 } 2193 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2194 void CgFxScriptLoader::CgIntSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2195 { 2196 2197 // todo - error 2198 2199 } 2200 //--------------------------------------------------------------------- 2201 //--------------------------------------------------------------------- 2202 //--------------------------------------------------------------------- CgBoolSamplerStateListener(const SamplerStateType samplerStateType)2203 CgFxScriptLoader::CgBoolSamplerStateListener::CgBoolSamplerStateListener( const SamplerStateType samplerStateType ) 2204 : CgSamplerStateListener(samplerStateType, CG_BOOL) 2205 { 2206 2207 } 2208 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2209 void CgFxScriptLoader::CgBoolSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2210 { 2211 switch( mSamplerStateType ) 2212 { 2213 case SST_GENERATEMIPMAP: 2214 default: 2215 // todo - error 2216 break; 2217 } 2218 } 2219 //--------------------------------------------------------------------- 2220 //--------------------------------------------------------------------- 2221 //--------------------------------------------------------------------- CgFloatSamplerStateListener(const SamplerStateType samplerStateType)2222 CgFxScriptLoader::CgFloatSamplerStateListener::CgFloatSamplerStateListener( const SamplerStateType samplerStateType ) 2223 : CgSamplerStateListener(samplerStateType, CG_FLOAT) 2224 { 2225 2226 } 2227 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2228 void CgFxScriptLoader::CgFloatSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2229 { 2230 switch( mSamplerStateType ) 2231 { 2232 case SST_MIPMAPLODBIAS: 2233 case SST_LODBIAS: 2234 case SST_MAXMIPLEVEL: 2235 case SST_MAXANISOTROPY: 2236 case SST_MINMIPLEVEL: 2237 case SST_SRGBTEXTURE: 2238 default: 2239 // todo - error 2240 break; 2241 } 2242 } 2243 //--------------------------------------------------------------------- 2244 //--------------------------------------------------------------------- 2245 //--------------------------------------------------------------------- CgFloat4SamplerStateListener(const SamplerStateType samplerStateType)2246 CgFxScriptLoader::CgFloat4SamplerStateListener::CgFloat4SamplerStateListener( const SamplerStateType samplerStateType ) 2247 : CgSamplerStateListener(samplerStateType, CG_FLOAT4) 2248 { 2249 2250 } 2251 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2252 void CgFxScriptLoader::CgFloat4SamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2253 { 2254 switch( mSamplerStateType ) 2255 { 2256 case SST_BORDERCOLOR: 2257 default: 2258 // todo - error 2259 break; 2260 } 2261 } 2262 //--------------------------------------------------------------------- 2263 //--------------------------------------------------------------------- 2264 //--------------------------------------------------------------------- CgTextureSamplerStateListener(const SamplerStateType samplerStateType)2265 CgFxScriptLoader::CgTextureSamplerStateListener::CgTextureSamplerStateListener( const SamplerStateType samplerStateType ) 2266 : CgSamplerStateListener(samplerStateType, CG_TEXTURE) 2267 { 2268 2269 } 2270 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2271 void CgFxScriptLoader::CgTextureSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2272 { 2273 parseTextureName(getCgParameter(cgStateAssignment), ogreTextureUnitState); 2274 } 2275 //--------------------------------------------------------------------- parseTextureName(CGparameter cgParameter,TextureUnitState * ogreTextureUnitState)2276 void CgFxScriptLoader::CgTextureSamplerStateListener::parseTextureName( CGparameter cgParameter, TextureUnitState * ogreTextureUnitState ) 2277 { 2278 CGannotation cgAnnotation = cgGetNamedParameterAnnotation(cgParameter, "ResourceName"); 2279 if (cgAnnotation && cgGetAnnotationType(cgAnnotation) == CG_STRING) 2280 { 2281 const char * textureName = cgGetStringAnnotationValue(cgAnnotation); 2282 if (textureName) 2283 { 2284 ogreTextureUnitState->setTextureName(textureName, parseTextureType(cgParameter, ogreTextureUnitState)); 2285 } 2286 } 2287 } 2288 //--------------------------------------------------------------------- parseTextureType(CGparameter cgParameter,TextureUnitState * ogreTextureUnitState)2289 TextureType CgFxScriptLoader::CgTextureSamplerStateListener::parseTextureType( CGparameter cgParameter, TextureUnitState * ogreTextureUnitState ) 2290 { 2291 CGannotation cgAnnotation = cgGetNamedParameterAnnotation(cgParameter, "ResourceType"); 2292 if (cgAnnotation && cgGetAnnotationType(cgAnnotation) == CG_STRING) 2293 { 2294 String textureType = cgGetStringAnnotationValue(cgAnnotation); 2295 StringUtil::toLowerCase(textureType); 2296 if ("1d" == textureType) 2297 { 2298 return TEX_TYPE_1D; 2299 } 2300 if ("2d" == textureType) 2301 { 2302 return TEX_TYPE_2D; 2303 } 2304 if ("3d" == textureType) 2305 { 2306 return TEX_TYPE_3D; 2307 } 2308 if ("cube" == textureType) 2309 { 2310 return TEX_TYPE_CUBE_MAP; 2311 } 2312 } 2313 return TEX_TYPE_2D; 2314 } 2315 //--------------------------------------------------------------------- 2316 //--------------------------------------------------------------------- 2317 //--------------------------------------------------------------------- CgWrapSamplerStateListener(const SamplerStateType samplerStateType)2318 CgFxScriptLoader::CgWrapSamplerStateListener::CgWrapSamplerStateListener( const SamplerStateType samplerStateType ) 2319 : CgIntSamplerStateListener(samplerStateType) 2320 { 2321 2322 } 2323 //--------------------------------------------------------------------- createState()2324 void CgFxScriptLoader::CgWrapSamplerStateListener::createState() 2325 { 2326 CgSamplerStateListener::createState(); 2327 2328 addStateEnumerant((int)WT_REPEAT , "Repeat"); 2329 addStateEnumerant((int)WT_CLAMP , "Clamp"); 2330 addStateEnumerant((int)WT_CLAMPTOEDGE , "ClampToEdge"); 2331 addStateEnumerant((int)WT_CLAMPTOBORDER , "ClampToBorder"); 2332 addStateEnumerant((int)WT_MIRROREDREPEAT , "MirroredRepeat"); 2333 addStateEnumerant((int)WT_MIRRORCLAMP , "MirrorClamp"); 2334 addStateEnumerant((int)WT_MIRRORCLAMPTOEDGE , "MirrorClampToEdge"); 2335 addStateEnumerant((int)WT_MIRRORCLAMPTOBORDER , "MirrorClampToBorder"); 2336 } 2337 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2338 void CgFxScriptLoader::CgWrapSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2339 { 2340 TextureAddressingMode ogreTextureAddressingMode = TextureUnitState::TAM_WRAP; 2341 ogreTextureAddressingMode = getOgreTextureAddressingMode(cgStateAssignment); 2342 2343 Sampler::UVWAddressingMode ogreUVWAddressingMode = ogreTextureUnitState->getTextureAddressingMode(); 2344 2345 switch( mSamplerStateType ) 2346 { 2347 case SST_WRAPS: 2348 ogreUVWAddressingMode.u = ogreTextureAddressingMode; 2349 break; 2350 case SST_WRAPT: 2351 ogreUVWAddressingMode.v = ogreTextureAddressingMode; 2352 break; 2353 case SST_WRAPR: 2354 ogreUVWAddressingMode.w = ogreTextureAddressingMode; 2355 break; 2356 default: 2357 // todo - error 2358 break; 2359 } 2360 ogreTextureUnitState->setTextureAddressingMode( ogreUVWAddressingMode ); 2361 2362 } 2363 //--------------------------------------------------------------------- getOgreTextureAddressingMode(CGstateassignment cgStateAssignment)2364 TextureAddressingMode CgFxScriptLoader::CgWrapSamplerStateListener::getOgreTextureAddressingMode( CGstateassignment cgStateAssignment ) 2365 { 2366 TextureAddressingMode ogreTextureAddressingMode = TextureUnitState::TAM_WRAP; 2367 switch( getValue( cgStateAssignment ) ) 2368 { 2369 case WT_REPEAT: // Repeat 2370 ogreTextureAddressingMode = TextureUnitState::TAM_WRAP; 2371 break; 2372 case WT_CLAMP: // Clamp 2373 ogreTextureAddressingMode = TextureUnitState::TAM_CLAMP; 2374 break; 2375 case WT_CLAMPTOEDGE: // ClampToEdge 2376 ogreTextureAddressingMode = TextureUnitState::TAM_CLAMP; 2377 break; 2378 case WT_CLAMPTOBORDER: // ClampToBorder 2379 ogreTextureAddressingMode = TextureUnitState::TAM_BORDER; 2380 break; 2381 case WT_MIRROREDREPEAT: // MirroredRepeat 2382 ogreTextureAddressingMode = TextureUnitState::TAM_MIRROR; 2383 break; 2384 case WT_MIRRORCLAMP: // MirrorClamp 2385 ogreTextureAddressingMode = TextureUnitState::TAM_MIRROR; 2386 break; 2387 case WT_MIRRORCLAMPTOEDGE: // MirrorClampToEdge 2388 ogreTextureAddressingMode = TextureUnitState::TAM_MIRROR; 2389 break; 2390 case WT_MIRRORCLAMPTOBORDER: // MirrorClampToBorder 2391 ogreTextureAddressingMode = TextureUnitState::TAM_MIRROR; 2392 break; 2393 default: 2394 // todo - error 2395 ogreTextureAddressingMode = TextureUnitState::TAM_WRAP; 2396 break; 2397 } 2398 return ogreTextureAddressingMode; 2399 } 2400 //--------------------------------------------------------------------- 2401 //--------------------------------------------------------------------- 2402 //--------------------------------------------------------------------- CgCompareModeSamplerStateListener()2403 CgFxScriptLoader::CgCompareModeSamplerStateListener::CgCompareModeSamplerStateListener() 2404 : CgIntSamplerStateListener(SST_COMPAREMODE) 2405 { 2406 2407 } 2408 //--------------------------------------------------------------------- createState()2409 void CgFxScriptLoader::CgCompareModeSamplerStateListener::createState() 2410 { 2411 CgSamplerStateListener::createState(); 2412 2413 addStateEnumerant((int)CMT_NONE , "None"); 2414 addStateEnumerant((int)CMT_COMPARERTOTEXTURE , "CompareRToTexture"); 2415 } 2416 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2417 void CgFxScriptLoader::CgCompareModeSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2418 { 2419 switch( getValue(cgStateAssignment) ) 2420 { 2421 case CMT_NONE: // None 2422 case CMT_COMPARERTOTEXTURE: // CompareRToTexture 2423 default: 2424 // todo - error 2425 break; 2426 } 2427 } 2428 //--------------------------------------------------------------------- 2429 //--------------------------------------------------------------------- 2430 //--------------------------------------------------------------------- CgCompareFuncSamplerStateListener()2431 CgFxScriptLoader::CgCompareFuncSamplerStateListener::CgCompareFuncSamplerStateListener( ) 2432 : CgIntSamplerStateListener(SST_COMPAREFUNC) 2433 { 2434 2435 } 2436 //--------------------------------------------------------------------- createState()2437 void CgFxScriptLoader::CgCompareFuncSamplerStateListener::createState() 2438 { 2439 CgSamplerStateListener::createState(); 2440 2441 addStateEnumerant((int)CFT_NEVER , "Never"); 2442 addStateEnumerant((int)CFT_LESS , "Less"); 2443 addStateEnumerant((int)CFT_LEQUAL , "LEqual"); 2444 addStateEnumerant((int)CFT_EQUAL , "Equal"); 2445 addStateEnumerant((int)CFT_GREATER , "Greater"); 2446 addStateEnumerant((int)CFT_NOTEQUAL , "NotEqual"); 2447 } 2448 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2449 void CgFxScriptLoader::CgCompareFuncSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2450 { 2451 switch( getValue(cgStateAssignment) ) 2452 { 2453 case CFT_NEVER: // Never 2454 case CFT_LESS: // Less 2455 case CFT_LEQUAL: // LEqual 2456 case CFT_EQUAL: // Equal 2457 case CFT_GREATER: // Greater 2458 case CFT_NOTEQUAL: // NotEqual 2459 default: 2460 // todo - error 2461 break; 2462 } 2463 } 2464 //--------------------------------------------------------------------- 2465 //--------------------------------------------------------------------- 2466 //--------------------------------------------------------------------- CgDepthModeSamplerStateListener()2467 CgFxScriptLoader::CgDepthModeSamplerStateListener::CgDepthModeSamplerStateListener() 2468 : CgIntSamplerStateListener(SST_DEPTHMODE) 2469 { 2470 2471 } 2472 //--------------------------------------------------------------------- createState()2473 void CgFxScriptLoader::CgDepthModeSamplerStateListener::createState() 2474 { 2475 CgSamplerStateListener::createState(); 2476 2477 addStateEnumerant((int)DMT_ALPHA , "Alpha"); 2478 addStateEnumerant((int)DMT_INTENSITY , "Intensity"); 2479 addStateEnumerant((int)DMT_LUMINANCE , "Luminance"); 2480 } 2481 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2482 void CgFxScriptLoader::CgDepthModeSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2483 { 2484 switch( getValue(cgStateAssignment) ) 2485 { 2486 case DMT_ALPHA: // Alpha 2487 case DMT_INTENSITY: // Intensity 2488 case DMT_LUMINANCE: // Luminance 2489 default: 2490 // todo - error 2491 break; 2492 } 2493 } 2494 //--------------------------------------------------------------------- 2495 //--------------------------------------------------------------------- 2496 //--------------------------------------------------------------------- CgMinFilterSamplerStateListener()2497 CgFxScriptLoader::CgMinFilterSamplerStateListener::CgMinFilterSamplerStateListener() 2498 : CgIntSamplerStateListener(SST_MINFILTER) 2499 { 2500 2501 } 2502 //--------------------------------------------------------------------- createState()2503 void CgFxScriptLoader::CgMinFilterSamplerStateListener::createState() 2504 { 2505 CgSamplerStateListener::createState(); 2506 2507 addStateEnumerant((int)MINFT_NEAREST , "Nearest"); 2508 addStateEnumerant((int)MINFT_LINEAR , "Linear"); 2509 addStateEnumerant((int)MINFT_LINEARMIPMAPNEAREST , "LinearMipMapNearest"); 2510 addStateEnumerant((int)MINFT_NEARESTMIPMAPNEAREST , "NearestMipMapNearest"); 2511 addStateEnumerant((int)MINFT_NEARESTMIPMAPLINEAR , "NearestMipMapLinear"); 2512 addStateEnumerant((int)MINFT_LINEARMIPMAPLINEAR , "LinearMipMapLinear"); 2513 2514 } 2515 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2516 void CgFxScriptLoader::CgMinFilterSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2517 { 2518 switch( getValue(cgStateAssignment) ) 2519 { 2520 case MINFT_NEAREST: // Nearest 2521 case MINFT_LINEAR: // Linear 2522 case MINFT_LINEARMIPMAPNEAREST: // LinearMipMapNearest 2523 case MINFT_NEARESTMIPMAPNEAREST: // NearestMipMapNearest 2524 case MINFT_NEARESTMIPMAPLINEAR: // NearestMipMapLinear 2525 case MINFT_LINEARMIPMAPLINEAR: // LinearMipMapLinear 2526 default: 2527 // todo - error 2528 break; 2529 } 2530 } 2531 //--------------------------------------------------------------------- 2532 //--------------------------------------------------------------------- 2533 //--------------------------------------------------------------------- CgMagFilterSamplerStateListener()2534 CgFxScriptLoader::CgMagFilterSamplerStateListener::CgMagFilterSamplerStateListener() 2535 : CgIntSamplerStateListener(SST_MAGFILTER) 2536 { 2537 CgSamplerStateListener::createState(); 2538 2539 addStateEnumerant((int)MAGFT_NEAREST, "Nearest"); 2540 addStateEnumerant((int)MAGFT_LINEAR , "Linear"); 2541 } 2542 //--------------------------------------------------------------------- createState()2543 void CgFxScriptLoader::CgMagFilterSamplerStateListener::createState() 2544 { 2545 2546 } 2547 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2548 void CgFxScriptLoader::CgMagFilterSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2549 { 2550 switch( getValue(cgStateAssignment) ) 2551 { 2552 case MAGFT_NEAREST: // Nearest 2553 case MAGFT_LINEAR: // Linear 2554 default: 2555 // todo - error 2556 break; 2557 } 2558 } 2559 //--------------------------------------------------------------------- 2560 //--------------------------------------------------------------------- 2561 //--------------------------------------------------------------------- CgMipFilterSamplerStateListener()2562 CgFxScriptLoader::CgMipFilterSamplerStateListener::CgMipFilterSamplerStateListener() 2563 : CgIntSamplerStateListener(SST_MIPFILTER) 2564 { 2565 CgSamplerStateListener::createState(); 2566 2567 addStateEnumerant((int)MIPFT_NONE , "None"); 2568 addStateEnumerant((int)MIPFT_POINT , "Point"); 2569 addStateEnumerant((int)MIPFT_LINEAR , "Linear"); 2570 addStateEnumerant((int)MIPFT_ANISOTROPIC , "Nisotropic"); 2571 addStateEnumerant((int)MIPFT_PYRAMIDALQUAD , "PyramidalQuad"); 2572 addStateEnumerant((int)MIPFT_GAUSSIANQUAD , "GaussianQuad"); 2573 } 2574 //--------------------------------------------------------------------- createState()2575 void CgFxScriptLoader::CgMipFilterSamplerStateListener::createState() 2576 { 2577 2578 } 2579 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2580 void CgFxScriptLoader::CgMipFilterSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2581 { 2582 switch( getValue(cgStateAssignment) ) 2583 { 2584 case MIPFT_NONE: // filtering disabled (valid for mip filter only) 2585 case MIPFT_POINT: // nearest 2586 case MIPFT_LINEAR: // linear interpolation 2587 case MIPFT_ANISOTROPIC: // anisotropic 2588 case MIPFT_PYRAMIDALQUAD: // 4-sample tent 2589 case MIPFT_GAUSSIANQUAD: // 4-sample gaussian 2590 default: 2591 // todo - error 2592 break; 2593 } 2594 } 2595 //--------------------------------------------------------------------- 2596 //--------------------------------------------------------------------- 2597 //--------------------------------------------------------------------- CgTextureAddressSamplerStateListener(const SamplerStateType samplerStateType)2598 CgFxScriptLoader::CgTextureAddressSamplerStateListener::CgTextureAddressSamplerStateListener( const SamplerStateType samplerStateType ) 2599 : CgIntSamplerStateListener(samplerStateType) 2600 { 2601 2602 } 2603 //--------------------------------------------------------------------- createState()2604 void CgFxScriptLoader::CgTextureAddressSamplerStateListener::createState() 2605 { 2606 CgSamplerStateListener::createState(); 2607 2608 addStateEnumerant((int)TAT_WRAP, "Wrap"); 2609 addStateEnumerant((int)TAT_MIRROR, "Mirror"); 2610 addStateEnumerant((int)TAT_CLAMP, "Clamp"); 2611 addStateEnumerant((int)TAT_BORDER, "Border"); 2612 addStateEnumerant((int)TAT_MIRRORONCE, "MirrorOnce"); 2613 } 2614 //--------------------------------------------------------------------- upateTextureUnitState(TextureUnitState * ogreTextureUnitState,CGstateassignment cgStateAssignment)2615 void CgFxScriptLoader::CgTextureAddressSamplerStateListener::upateTextureUnitState( TextureUnitState * ogreTextureUnitState, CGstateassignment cgStateAssignment ) 2616 { 2617 switch( mSamplerStateType ) 2618 { 2619 case SST_ADDRESSU: 2620 case SST_ADDRESSV: 2621 case SST_ADDRESSW: 2622 default: 2623 // todo - error 2624 break; 2625 } 2626 2627 switch( getValue(cgStateAssignment) ) 2628 { 2629 case TAT_WRAP: // Wrap 2630 case TAT_MIRROR: // Mirror 2631 case TAT_CLAMP: // Clamp 2632 case TAT_BORDER: // Border 2633 case TAT_MIRRORONCE: // MirrorOnce 2634 default: 2635 // todo - error 2636 break; 2637 } 2638 2639 } 2640 //--------------------------------------------------------------------- 2641 //--------------------------------------------------------------------- 2642 //--------------------------------------------------------------------- 2643 template<> CgFxScriptLoader *Singleton<CgFxScriptLoader>::msSingleton = 0; getSingletonPtr(void)2644 CgFxScriptLoader* CgFxScriptLoader::getSingletonPtr(void) 2645 { 2646 return msSingleton; 2647 } getSingleton(void)2648 CgFxScriptLoader& CgFxScriptLoader::getSingleton(void) 2649 { 2650 assert( msSingleton ); return ( *msSingleton ); 2651 } 2652 //--------------------------------------------------------------------- CgFxScriptLoader()2653 CgFxScriptLoader::CgFxScriptLoader() 2654 { 2655 mCgContext = cgCreateContext(); 2656 2657 mCgStateListenerVector.resize(GST_COUNT); 2658 for (int i = GST_FIRST ; i < GST_COUNT ; i++) 2659 { 2660 const GlobalStateType type = static_cast<GlobalStateType>(i); 2661 CgGlobalStateListener * newState = createCgGlobalStateListener(type); 2662 mCgStateListenerVector[i] = newState; 2663 mCgStateListenerVector[i]->init(); 2664 mCgGlobalStateToListenerMap[mCgStateListenerVector[i]->getCgState()] = newState; 2665 } 2666 2667 mCgSamplerStateListenerVector.resize(SST_COUNT); 2668 for (int i = SST_FIRST ; i < SST_COUNT ; i++) 2669 { 2670 const SamplerStateType type = static_cast<SamplerStateType>(i); 2671 CgSamplerStateListener * newState = createCgSamplerStateListener(type); 2672 mCgSamplerStateListenerVector[i] = newState; 2673 mCgSamplerStateListenerVector[i]->init(); 2674 mCgSamplerStateToListenerMap[mCgSamplerStateListenerVector[i]->getCgState()] = newState; 2675 2676 } 2677 2678 2679 2680 // Scripting is supported by this manager 2681 mScriptPatterns.push_back("*.cgfx"); 2682 ResourceGroupManager::getSingleton()._registerScriptLoader(this); 2683 2684 } 2685 //--------------------------------------------------------------------- ~CgFxScriptLoader()2686 CgFxScriptLoader::~CgFxScriptLoader() 2687 { 2688 for (size_t i = 0 ; i < mCgStateListenerVector.size() ; i++) 2689 { 2690 OGRE_DELETE mCgStateListenerVector[i]; 2691 } 2692 2693 for (size_t i = 0 ; i < mCgSamplerStateListenerVector.size() ; i++) 2694 { 2695 OGRE_DELETE mCgSamplerStateListenerVector[i]; 2696 } 2697 2698 2699 cgDestroyContext(mCgContext); 2700 2701 // Unregister with resource group manager 2702 ResourceGroupManager::getSingleton()._unregisterScriptLoader(this); 2703 } 2704 //--------------------------------------------------------------------- getCgContext() const2705 CGcontext CgFxScriptLoader::getCgContext() const 2706 { 2707 return mCgContext; 2708 } 2709 //--------------------------------------------------------------------- getScriptPatterns(void) const2710 const StringVector& CgFxScriptLoader::getScriptPatterns(void) const 2711 { 2712 return mScriptPatterns; 2713 } 2714 //--------------------------------------------------------------------- getLoadingOrder(void) const2715 Real CgFxScriptLoader::getLoadingOrder(void) const 2716 { 2717 // before the normal material manager - so a normal material can inherits from a cgfx material 2718 return 99.0f; 2719 2720 } 2721 //--------------------------------------------------------------------- parseScript(DataStreamPtr & stream,const String & groupName)2722 void CgFxScriptLoader::parseScript( DataStreamPtr& stream, const String& groupName ) 2723 { 2724 String streamAsString = stream->getAsString(); 2725 2726 MaterialPtr ogreMaterial = MaterialManager::getSingleton().create(stream->getName(), groupName); 2727 2728 String sourceToUse = HighLevelGpuProgram::_resolveIncludes(streamAsString, ogreMaterial.get(), stream->getName()); 2729 2730 CGeffect cgEffect = cgCreateEffect(mCgContext, sourceToUse.c_str(), NULL); 2731 checkForCgError("CgFxScriptLoader::parseScript", 2732 "Unable to Create cg Effect: ", mCgContext); 2733 2734 ogreMaterial->removeAllTechniques(); 2735 parseCgEffect(cgEffect, ogreMaterial); 2736 2737 cgDestroyEffect(cgEffect); 2738 } 2739 //--------------------------------------------------------------------- parseCgEffect(CGeffect cgEffect,MaterialPtr ogreMaterial)2740 void CgFxScriptLoader::parseCgEffect( CGeffect cgEffect, MaterialPtr ogreMaterial ) 2741 { 2742 parseCgEffectTechniques(cgEffect, ogreMaterial); 2743 } 2744 //--------------------------------------------------------------------- parseCgEffectTechniques(CGeffect cgEffect,MaterialPtr ogreMaterial)2745 void CgFxScriptLoader::parseCgEffectTechniques( CGeffect cgEffect, MaterialPtr ogreMaterial ) 2746 { 2747 CGtechnique cgTechnique = cgGetFirstTechnique(cgEffect); 2748 while (cgTechnique) 2749 { 2750 Technique * ogreTechnique = ogreMaterial->createTechnique(); 2751 2752 const char * cgTechniqueName = cgGetTechniqueName(cgTechnique); 2753 if (cgTechniqueName) 2754 { 2755 ogreTechnique->setName(cgTechniqueName); 2756 } 2757 2758 ogreTechnique->removeAllPasses(); 2759 2760 parseCgTechnique(cgTechnique, ogreTechnique); 2761 2762 cgTechnique = cgGetNextTechnique(cgTechnique); 2763 } 2764 } 2765 //--------------------------------------------------------------------- parseCgTechnique(CGtechnique cgTechnique,Technique * ogreTechnique)2766 void CgFxScriptLoader::parseCgTechnique( CGtechnique cgTechnique, Technique * ogreTechnique ) 2767 { 2768 CGpass cgPass = cgGetFirstPass(cgTechnique); 2769 while (cgPass) 2770 { 2771 2772 Pass * ogrePass = ogreTechnique->createPass(); 2773 const char * cgPassName = cgGetPassName(cgPass); 2774 if (cgPassName) 2775 { 2776 ogrePass->setName(cgPassName); 2777 } 2778 2779 parseCgPass(cgPass, ogrePass); 2780 parseSamplerParameters(cgPass, ogrePass); 2781 2782 cgPass = cgGetNextPass(cgPass); 2783 } 2784 } 2785 //--------------------------------------------------------------------- parseCgPass(CGpass cgPass,Pass * ogrePass)2786 void CgFxScriptLoader::parseCgPass( CGpass cgPass, Pass * ogrePass ) 2787 { 2788 parseCgProgram(cgPass, ogrePass, GPT_VERTEX_PROGRAM); 2789 parseCgProgram(cgPass, ogrePass, GPT_FRAGMENT_PROGRAM); 2790 2791 2792 parsePassStateAssignments(cgPass, ogrePass); 2793 2794 2795 2796 } 2797 //--------------------------------------------------------------------- parseCgProgram(CGpass cgPass,Pass * ogrePass,const GpuProgramType ogreProgramType)2798 void CgFxScriptLoader::parseCgProgram( CGpass cgPass, Pass * ogrePass, const GpuProgramType ogreProgramType ) 2799 { 2800 const char *stateName = NULL; 2801 switch(ogreProgramType) 2802 { 2803 case GPT_VERTEX_PROGRAM: 2804 stateName = "VertexProgram"; 2805 break; 2806 case GPT_FRAGMENT_PROGRAM: 2807 stateName = "FragmentProgram"; 2808 break; 2809 case GPT_GEOMETRY_PROGRAM: 2810 stateName = "GeometryProgram"; 2811 break; 2812 case GPT_COMPUTE_PROGRAM: 2813 case GPT_DOMAIN_PROGRAM: 2814 case GPT_HULL_PROGRAM: 2815 break; 2816 } 2817 CGstateassignment cgStateAssignment = cgGetNamedStateAssignment(cgPass, stateName); 2818 if (!cgStateAssignment) 2819 { 2820 switch(ogreProgramType) 2821 { 2822 case GPT_VERTEX_PROGRAM: 2823 stateName = "VertexShader"; 2824 break; 2825 case GPT_FRAGMENT_PROGRAM: 2826 stateName = "PixelShader"; 2827 break; 2828 case GPT_GEOMETRY_PROGRAM: 2829 stateName = "GeometryShader"; 2830 break; 2831 case GPT_COMPUTE_PROGRAM: 2832 case GPT_DOMAIN_PROGRAM: 2833 case GPT_HULL_PROGRAM: 2834 break; 2835 } 2836 2837 cgStateAssignment = cgGetNamedStateAssignment(cgPass, stateName); 2838 if (!cgStateAssignment) 2839 { 2840 return; 2841 } 2842 } 2843 2844 2845 2846 CGprogram cgProgram = cgGetProgramStateAssignmentValue(cgStateAssignment); 2847 2848 CGparameter cgParameter = cgGetFirstParameter(cgProgram, CG_PROGRAM); 2849 while (cgParameter) 2850 { 2851 String paramName = cgGetParameterName(cgParameter); 2852 cgParameter = cgGetNextParameter(cgParameter); 2853 } 2854 2855 2856 const char * source = cgGetProgramString(cgProgram, CG_PROGRAM_SOURCE); 2857 const char * entry = cgGetProgramString(cgProgram, CG_PROGRAM_ENTRY); 2858 const char * profile = cgGetProgramString(cgProgram, CG_PROGRAM_PROFILE); 2859 2860 // The name is all the path to this shader combined with the entry point and profile so it will be unique. 2861 StringStream programName; 2862 programName << ogrePass->getParent()->getParent()->getName() << "|"; // Material 2863 programName << entry << "|"; // entry 2864 programName << profile << "|"; // profile 2865 programName << (ogrePass->getParent()->getParent()->getNumTechniques() - 1) << "-"; // Technique number 2866 programName << ogrePass->getParent()->getName() << "|"; // Technique 2867 programName << (ogrePass->getParent()->getNumPasses() - 1) << "-"; // Pass number 2868 programName << ogrePass->getName(); // Pass 2869 2870 String ProgramNameAsString = programName.str(); 2871 2872 HighLevelGpuProgramPtr ogreProgram = 2873 HighLevelGpuProgramManager::getSingleton(). 2874 createProgram(ProgramNameAsString, 2875 ogrePass->getParent()->getParent()->getGroup(), 2876 "cg", 2877 ogreProgramType); 2878 2879 ogreProgram->setSource(source); 2880 ogreProgram->setParameter("entry_point", entry); 2881 ogreProgram->setParameter("profiles", profile); 2882 2883 //ogreProgram->load(); 2884 if (ogreProgram->isSupported()) 2885 { 2886 2887 ogreProgram->load(); 2888 ogreProgram->createParameters(); 2889 2890 GpuProgramParametersSharedPtr ogreProgramParameters = ogreProgram->getDefaultParameters(); 2891 parseCgProgramParameters(cgPass, ogreProgramParameters); 2892 2893 switch(ogreProgramType) 2894 { 2895 case GPT_VERTEX_PROGRAM: 2896 ogrePass->setVertexProgram(ogreProgram->getName()); 2897 break; 2898 case GPT_FRAGMENT_PROGRAM: 2899 ogrePass->setFragmentProgram(ogreProgram->getName()); 2900 break; 2901 case GPT_GEOMETRY_PROGRAM: 2902 ogrePass->setGeometryProgram(ogreProgram->getName()); 2903 break; 2904 case GPT_DOMAIN_PROGRAM: 2905 case GPT_COMPUTE_PROGRAM: 2906 case GPT_HULL_PROGRAM: 2907 break; 2908 } 2909 2910 } 2911 2912 } 2913 //--------------------------------------------------------------------- parseCgProgramParameters(CGpass cgPass,GpuProgramParametersSharedPtr ogreProgramParameters)2914 void CgFxScriptLoader::parseCgProgramParameters( CGpass cgPass, GpuProgramParametersSharedPtr ogreProgramParameters ) 2915 { 2916 CGeffect cgEffect = cgGetTechniqueEffect(cgGetPassTechnique(cgPass)); 2917 2918 GpuConstantDefinitionIterator constIt = ogreProgramParameters->getConstantDefinitionIterator(); 2919 while(constIt.hasMoreElements()) 2920 { 2921 // get the constant definition 2922 const String& ogreParamName = constIt.peekNextKey(); 2923 constIt.getNext(); 2924 2925 CGparameter cgParameter = cgGetNamedEffectParameter(cgEffect, ogreParamName.c_str()); 2926 // try to find it without case 2927 if (!cgParameter) 2928 { 2929 CGparameter cgParameterToFind = cgGetFirstEffectParameter(cgEffect); 2930 String ogreParamNameLower = ogreParamName; 2931 Ogre::StringUtil::toLowerCase(ogreParamNameLower); 2932 2933 while (cgParameterToFind) 2934 { 2935 String cgParamNameLower = cgGetParameterName(cgParameterToFind); 2936 Ogre::StringUtil::toLowerCase(cgParamNameLower); 2937 2938 if (cgParamNameLower == ogreParamNameLower) 2939 { 2940 cgParameter = cgParameterToFind; 2941 break; 2942 } 2943 2944 cgParameterToFind = cgGetNextParameter(cgParameterToFind); 2945 } 2946 2947 } 2948 if (cgParameter) 2949 { 2950 parseCgProgramParameter(cgParameter, ogreProgramParameters, ogreParamName); 2951 } 2952 else 2953 { 2954 // todo - some kind of error 2955 } 2956 } 2957 2958 } 2959 //--------------------------------------------------------------------- parseCgProgramParameter(CGparameter cgParameter,GpuProgramParametersSharedPtr ogreProgramParameters,const String & ogreParamName)2960 void CgFxScriptLoader::parseCgProgramParameter( CGparameter cgParameter, GpuProgramParametersSharedPtr ogreProgramParameters, const String& ogreParamName ) 2961 { 2962 2963 bool isAutoConstant = 2964 parseAutoConstantParam(cgParameter, 2965 ogreProgramParameters, 2966 ogreParamName); 2967 2968 if (!isAutoConstant) 2969 { 2970 2971 CGtype cgParamType = cgGetParameterType(cgParameter); 2972 CGtype cgParameterBaseType = cgGetParameterBaseType(cgParameter); 2973 2974 switch(cgParameterBaseType) 2975 { 2976 case CG_FLOAT: 2977 parseFloatCgProgramParameter(cgParamType, cgParameter, ogreProgramParameters, ogreParamName); 2978 break; 2979 case CG_INT: 2980 parseIntCgProgramParameter(cgParamType, cgParameter, ogreProgramParameters, ogreParamName); 2981 break; 2982 case CG_BOOL: 2983 // todo 2984 break; 2985 case CG_FIXED: 2986 // todo 2987 break; 2988 case CG_HALF: 2989 // todo 2990 break; 2991 default: 2992 // todo error 2993 break; 2994 2995 } 2996 } 2997 2998 } 2999 //--------------------------------------------------------------------- cgSemanticStringToType(const char * cgParamSemantic)3000 CgFxScriptLoader::FXSemanticID CgFxScriptLoader::cgSemanticStringToType( const char * cgParamSemantic ) 3001 { 3002 String sem = cgParamSemantic; 3003 Ogre::StringUtil::toLowerCase(sem); 3004 3005 if ("none" == sem) return FXS_NONE; 3006 if ("unknown" == sem) return FXS_UNKNOWN; 3007 if ("position" == sem) return FXS_POSITION; 3008 if ("direction" == sem) return FXS_DIRECTION; 3009 if ("color" == sem) return FXS_COLOR; 3010 if ("diffuse" == sem) return FXS_DIFFUSE; 3011 if ("specular" == sem) return FXS_SPECULAR; 3012 if ("ambient" == sem) return FXS_AMBIENT; 3013 if ("emission" == sem) return FXS_EMISSION; 3014 if ("emissive" == sem) return FXS_EMISSIVE; 3015 if ("specularpower" == sem) return FXS_SPECULARPOWER; 3016 if ("refraction" == sem) return FXS_REFRACTION; 3017 if ("opacity" == sem) return FXS_OPACITY; 3018 if ("environment" == sem) return FXS_ENVIRONMENT; 3019 if ("environmentnormal" == sem) return FXS_ENVIRONMENTNORMAL; 3020 if ("normal" == sem) return FXS_NORMAL; 3021 if ("height" == sem) return FXS_HEIGHT; 3022 if ("attenuation" == sem) return FXS_ATTENUATION; 3023 if ("rendercolortarget" == sem) return FXS_RENDERCOLORTARGET; 3024 if ("renderdepthstenciltarget" == sem) return FXS_RENDERDEPTHSTENCILTARGET; 3025 if ("viewportpixelsize" == sem) return FXS_VIEWPORTPIXELSIZE; 3026 if ("cameraposition" == sem) return FXS_CAMERAPOSITION; 3027 if ("time" == sem) return FXS_TIME; 3028 if ("elapsedtime" == sem) return FXS_ELAPSEDTIME; 3029 if ("animationtime" == sem) return FXS_ANIMATIONTIME; 3030 if ("animationtick" == sem) return FXS_ANIMATIONTICK; 3031 if ("mouseposition" == sem) return FXS_MOUSEPOSITION; 3032 if ("leftmousedown" == sem) return FXS_LEFTMOUSEDOWN; 3033 if ("world" == sem) return FXS_WORLD; 3034 if ("view" == sem) return FXS_VIEW; 3035 if ("projection" == sem) return FXS_PROJECTION; 3036 if ("worldtranspose" == sem) return FXS_WORLDTRANSPOSE; 3037 if ("viewtranspose" == sem) return FXS_VIEWTRANSPOSE; 3038 if ("projectiontranspose" == sem) return FXS_PROJECTIONTRANSPOSE; 3039 if ("worldview" == sem) return FXS_WORLDVIEW; 3040 if ("worldviewprojection" == sem) return FXS_WORLDVIEWPROJECTION; 3041 if ("worldinverse" == sem) return FXS_WORLDINVERSE; 3042 if ("viewinverse" == sem) return FXS_VIEWINVERSE; 3043 if ("projectioninverse" == sem) return FXS_PROJECTIONINVERSE; 3044 if ("worldinversetranspose" == sem) return FXS_WORLDINVERSETRANSPOSE; 3045 if ("viewinversetranspose" == sem) return FXS_VIEWINVERSETRANSPOSE; 3046 if ("projectioninversetranspose" == sem) return FXS_PROJECTIONINVERSETRANSPOSE; 3047 if ("worldviewinverse" == sem) return FXS_WORLDVIEWINVERSE; 3048 if ("worldviewtranspose" == sem) return FXS_WORLDVIEWTRANSPOSE; 3049 if ("worldviewinversetranspose" == sem) return FXS_WORLDVIEWINVERSETRANSPOSE; 3050 if ("worldviewprojectioninverse" == sem) return FXS_WORLDVIEWPROJECTIONINVERSE; 3051 if ("worldviewprojectiontranspose" == sem) return FXS_WORLDVIEWPROJECTIONTRANSPOSE; 3052 if ("worldviewprojectioninversetranspose" == sem) return FXS_WORLDVIEWPROJECTIONINVERSETRANSPOSE; 3053 if ("viewprojection" == sem) return FXS_VIEWPROJECTION; 3054 if ("viewprojectiontranspose" == sem) return FXS_VIEWPROJECTIONTRANSPOSE; 3055 if ("viewprojectioninverse" == sem) return FXS_VIEWPROJECTIONINVERSE; 3056 if ("viewprojectioninversetranspose" == sem) return FXS_VIEWPROJECTIONINVERSETRANSPOSE; 3057 if ("fxcomposer_resetpulse" == sem) return FXS_FXCOMPOSER_RESETPULSE; 3058 if ("standardsglobal" == sem) return FXS_STANDARDSGLOBAL; 3059 if ("unitsscale" == sem) return FXS_UNITSSCALE; 3060 if ("power" == sem) return FXS_POWER; 3061 if ("diffusemap" == sem) return FXS_DIFFUSEMAP; 3062 if ("specularmap" == sem) return FXS_SPECULARMAP; 3063 if ("envmap" == sem) return FXS_ENVMAP; 3064 if ("lightposition" == sem) return FXS_LIGHTPOSITION; 3065 if ("transform" == sem) return FXS_TRANSFORM; 3066 if ("user" == sem) return FXS_USER; 3067 if ("constantattenuation" == sem) return FXS_CONSTANTATTENUATION; 3068 if ("linearattenuation" == sem) return FXS_LINEARATTENUATION; 3069 if ("quadraticattenuation" == sem) return FXS_QUADRATICATTENUATION; 3070 if ("falloffangle" == sem) return FXS_FALLOFFANGLE; 3071 if ("falloffexponent" == sem) return FXS_FALLOFFEXPONENT; 3072 if ("boundingradius" == sem) return FXS_BOUNDINGRADIUS; 3073 3074 return FXS_UNKNOWN; 3075 } 3076 //--------------------------------------------------------------------- getGlobalStateNameTypeToString(const GlobalStateType cgStateName)3077 const char * CgFxScriptLoader::getGlobalStateNameTypeToString( const GlobalStateType cgStateName ) 3078 { 3079 switch(cgStateName) 3080 { 3081 case GST_ALPHABLENDENABLE: return "AlphaBlendEnable"; 3082 case GST_ALPHAFUNC: return "AlphaFunc"; 3083 case GST_ALPHAREF: return "AlphaRef"; 3084 case GST_BLENDOP: return "BlendOp"; 3085 case GST_BLENDEQUATION: return "BlendEquation"; 3086 case GST_BLENDFUNC: return "BlendFunc"; 3087 case GST_BLENDFUNCSEPARATE: return "BlendFuncSeparate"; 3088 case GST_BLENDEQUATIONSEPARATE: return "BlendEquationSeparate"; 3089 case GST_BLENDCOLOR: return "BlendColor"; 3090 case GST_CLEARCOLOR: return "ClearColor"; 3091 case GST_CLEARSTENCIL: return "ClearStencil"; 3092 case GST_CLEARDEPTH: return "ClearDepth"; 3093 case GST_CLIPPLANE: return "ClipPlane"; 3094 case GST_CLIPPLANEENABLE: return "ClipPlaneEnable"; 3095 case GST_COLORWRITEENABLE: return "ColorWriteEnable"; 3096 case GST_COLORMASK: return "ColorMask"; 3097 case GST_COLORVERTEX: return "ColorVertex"; 3098 case GST_COLORMATERIAL: return "ColorMaterial"; 3099 case GST_COLORMATRIX: return "ColorMatrix"; 3100 case GST_COLORTRANSFORM: return "ColorTransform"; 3101 case GST_CULLFACE: return "CullFace"; 3102 case GST_CULLMODE: return "CullMode"; 3103 case GST_DEPTHBOUNDS: return "DepthBounds"; 3104 case GST_DEPTHBIAS: return "DepthBias"; 3105 case GST_DESTBLEND: return "DestBlend"; 3106 case GST_DEPTHFUNC: return "DepthFunc"; 3107 case GST_ZFUNC: return "ZFunc"; 3108 case GST_DEPTHMASK: return "DepthMask"; 3109 case GST_ZWRITEENABLE: return "ZWriteEnable"; 3110 case GST_DEPTHRANGE: return "DepthRange"; 3111 case GST_FOGDISTANCEMODE: return "FogDistanceMode"; 3112 case GST_FOGMODE: return "FogMode"; 3113 case GST_FOGTABLEMODE: return "FogTableMode"; 3114 case GST_INDEXEDVERTEXBLENDENABLE: return "IndexedVertexBlendEnable"; 3115 case GST_FOGDENSITY: return "FogDensity"; 3116 case GST_FOGSTART: return "FogStart"; 3117 case GST_FOGEND: return "FogEnd"; 3118 case GST_FOGCOLOR: return "FogColor"; 3119 case GST_FRAGMENTENVPARAMETER: return "FragmentEnvParameter"; 3120 case GST_FRAGMENTLOCALPARAMETER: return "FragmentLocalParameter"; 3121 case GST_FOGCOORDSRC: return "FogCoordSrc"; 3122 case GST_FOGVERTEXMODE: return "FogVertexMode"; 3123 case GST_FRONTFACE: return "FrontFace"; 3124 case GST_LIGHTMODELAMBIENT: return "LightModelAmbient"; 3125 case GST_AMBIENT: return "Ambient"; 3126 case GST_LIGHTINGENABLE: return "LightingEnable"; 3127 case GST_LIGHTENABLE: return "LightEnable"; 3128 case GST_LIGHTAMBIENT: return "LightAmbient"; 3129 case GST_LIGHTCONSTANTATTENUATION: return "LightConstantAttenuation"; 3130 case GST_LIGHTATTENUATION0: return "LightAttenuation0"; 3131 case GST_LIGHTDIFFUSE: return "LightDiffuse"; 3132 case GST_LIGHTLINEARATTENUATION: return "LightLinearAttenuation"; 3133 case GST_LIGHTATTENUATION1: return "LightAttenuation1"; 3134 case GST_LIGHTPOSITION: return "LightPosition"; 3135 case GST_LIGHTQUADRATICATTENUATION: return "LightQuadraticAttenuation"; 3136 case GST_LIGHTATTENUATION2: return "LightAttenuation2"; 3137 case GST_LIGHTSPECULAR: return "LightSpecular"; 3138 case GST_LIGHTSPOTCUTOFF: return "LightSpotCutoff"; 3139 case GST_LIGHTFALLOFF: return "LightFalloff"; 3140 case GST_LIGHTSPOTDIRECTION: return "LightSpotDirection"; 3141 case GST_LIGHTDIRECTION: return "LightDirection"; 3142 case GST_LIGHTSPOTEXPONENT: return "LightSpotExponent"; 3143 case GST_LIGHTPHI: return "LightPhi"; 3144 case GST_LIGHTRANGE: return "LightRange"; 3145 case GST_LIGHTTHETA: return "LightTheta"; 3146 case GST_LIGHTTYPE: return "LightType"; 3147 case GST_LOCALVIEWER: return "LocalViewer"; 3148 case GST_MULTISAMPLEANTIALIAS: return "MultiSampleAntialias"; 3149 case GST_MULTISAMPLEMASK: return "MultiSampleMask"; 3150 case GST_PATCHSEGMENTS: return "PatchSegments"; 3151 case GST_POINTSCALE_A: return "PointScale_A"; 3152 case GST_POINTSCALE_B: return "PointScale_B"; 3153 case GST_POINTSCALE_C: return "PointScale_C"; 3154 case GST_POINTSCALEENABLE: return "PointScaleEnable"; 3155 case GST_RANGEFOGENABLE: return "RangeFogEnable"; 3156 case GST_SPECULARENABLE: return "SpecularEnable"; 3157 case GST_TWEENFACTOR: return "TweenFactor"; 3158 case GST_VERTEXBLEND: return "VertexBlend"; 3159 case GST_AMBIENTMATERIALSOURCE: return "AmbientMaterialSource"; 3160 case GST_DIFFUSEMATERIALSOURCE: return "DiffuseMaterialSource"; 3161 case GST_EMISSIVEMATERIALSOURCE: return "EmissiveMaterialSource"; 3162 case GST_SPECULARMATERIALSOURCE: return "SpecularMaterialSource"; 3163 case GST_CLIPPING: return "Clipping"; 3164 case GST_LIGHTMODELCOLORCONTROL: return "LightModelColorControl"; 3165 case GST_LINESTIPPLE: return "LineStipple"; 3166 case GST_LINEWIDTH: return "LineWidth"; 3167 case GST_LOGICOP: return "LogicOp"; 3168 case GST_MATERIALAMBIENT: return "MaterialAmbient"; 3169 case GST_MATERIALDIFFUSE: return "MaterialDiffuse"; 3170 case GST_MATERIALEMISSION: return "MaterialEmission"; 3171 case GST_MATERIALEMISSIVE: return "MaterialEmissive"; 3172 case GST_MATERIALSHININESS: return "MaterialShininess"; 3173 case GST_MATERIALPOWER: return "MaterialPower"; 3174 case GST_MATERIALSPECULAR: return "MaterialSpecular"; 3175 case GST_MODELVIEWMATRIX: return "ModelViewMatrix"; 3176 case GST_MODELVIEWTRANSFORM: return "ModelViewTransform"; 3177 case GST_VIEWTRANSFORM: return "ViewTransform"; 3178 case GST_WORLDTRANSFORM: return "WorldTransform"; 3179 case GST_POINTDISTANCEATTENUATION: return "PointDistanceAttenuation"; 3180 case GST_POINTFADETHRESHOLDSIZE: return "PointFadeThresholdSize"; 3181 case GST_POINTSIZE: return "PointSize"; 3182 case GST_POINTSIZEMIN: return "PointSizeMin"; 3183 case GST_POINTSIZEMAX: return "PointSizeMax"; 3184 case GST_POINTSPRITECOORDORIGIN: return "PointSpriteCoordOrigin"; 3185 case GST_POINTSPRITECOORDREPLACE: return "PointSpriteCoordReplace"; 3186 case GST_POINTSPRITERMODE: return "PointSpriteRMode"; 3187 case GST_POLYGONMODE: return "PolygonMode"; 3188 case GST_FILLMODE: return "FillMode"; 3189 case GST_LASTPIXEL: return "LastPixel"; 3190 case GST_POLYGONOFFSET: return "PolygonOffset"; 3191 case GST_PROJECTIONMATRIX: return "ProjectionMatrix"; 3192 case GST_PROJECTIONTRANSFORM: return "ProjectionTransform"; 3193 case GST_SCISSOR: return "Scissor"; 3194 case GST_SHADEMODEL: return "ShadeModel"; 3195 case GST_SHADEMODE: return "ShadeMode"; 3196 case GST_SLOPSCALEDEPTHBIAS: return "SlopScaleDepthBias"; 3197 case GST_SRCBLEND: return "SrcBlend"; 3198 case GST_STENCILFUNC: return "StencilFunc"; 3199 case GST_STENCILMASK: return "StencilMask"; 3200 case GST_STENCILPASS: return "StencilPass"; 3201 case GST_STENCILREF: return "StencilRef"; 3202 case GST_STENCILWRITEMASK: return "StencilWriteMask"; 3203 case GST_STENCILZFAIL: return "StencilZFail"; 3204 case GST_TEXTUREFACTOR: return "TextureFactor"; 3205 case GST_STENCILOP: return "StencilOp"; 3206 case GST_STENCILFUNCSEPARATE: return "StencilFuncSeparate"; 3207 case GST_STENCILMASKSEPARATE: return "StencilMaskSeparate"; 3208 case GST_STENCILOPSEPARATE: return "StencilOpSeparate"; 3209 case GST_TEXGENSMODE: return "TexGenSMode"; 3210 case GST_TEXGENSOBJECTPLANE: return "TexGenSObjectPlane"; 3211 case GST_TEXGENSEYEPLANE: return "TexGenSEyePlane"; 3212 case GST_TEXGENTMODE: return "TexGenTMode"; 3213 case GST_TEXGENTOBJECTPLANE: return "TexGenTObjectPlane"; 3214 case GST_TEXGENTEYEPLANE: return "TexGenTEyePlane"; 3215 case GST_TEXGENRMODE: return "TexGenRMode"; 3216 case GST_TEXGENROBJECTPLANE: return "TexGenRObjectPlane"; 3217 case GST_TEXGENREYEPLANE: return "TexGenREyePlane"; 3218 case GST_TEXGENQMODE: return "TexGenQMode"; 3219 case GST_TEXGENQOBJECTPLANE: return "TexGenQObjectPlane"; 3220 case GST_TEXGENQEYEPLANE: return "TexGenQEyePlane"; 3221 case GST_TEXTUREENVCOLOR: return "TextureEnvColor"; 3222 case GST_TEXTUREENVMODE: return "TextureEnvMode"; 3223 case GST_TEXTURE1D: return "Texture1D"; 3224 case GST_TEXTURE2D: return "Texture2D"; 3225 case GST_TEXTURE3D: return "Texture3D"; 3226 case GST_TEXTURERECTANGLE: return "TextureRectangle"; 3227 case GST_TEXTURECUBEMAP: return "TextureCubeMap"; 3228 case GST_TEXTURE1DENABLE: return "Texture1DEnable"; 3229 case GST_TEXTURE2DENABLE: return "Texture2DEnable"; 3230 case GST_TEXTURE3DENABLE: return "Texture3DEnable"; 3231 case GST_TEXTURERECTANGLEENABLE: return "TextureRectangleEnable"; 3232 case GST_TEXTURECUBEMAPENABLE: return "TextureCubeMapEnable"; 3233 case GST_TEXTURETRANSFORM: return "TextureTransform"; 3234 case GST_TEXTUREMATRIX: return "TextureMatrix"; 3235 case GST_VERTEXENVPARAMETER: return "VertexEnvParameter"; 3236 case GST_VERTEXLOCALPARAMETER: return "VertexLocalParameter"; 3237 case GST_ALPHATESTENABLE: return "AlphaTestEnable"; 3238 case GST_AUTONORMALENABLE: return "AutoNormalEnable"; 3239 case GST_BLENDENABLE: return "BlendEnable"; 3240 case GST_COLORLOGICOPENABLE: return "ColorLogicOpEnable"; 3241 case GST_CULLFACEENABLE: return "CullFaceEnable"; 3242 case GST_DEPTHBOUNDSENABLE: return "DepthBoundsEnable"; 3243 case GST_DEPTHCLAMPENABLE: return "DepthClampEnable"; 3244 case GST_DEPTHTESTENABLE: return "DepthTestEnable"; 3245 case GST_ZENABLE: return "ZEnable"; 3246 case GST_DITHERENABLE: return "DitherEnable"; 3247 case GST_FOGENABLE: return "FogEnable"; 3248 case GST_LIGHTMODELLOCALVIEWERENABLE: return "LightModelLocalViewerEnable"; 3249 case GST_LIGHTMODELTWOSIDEENABLE: return "LightModelTwoSideEnable"; 3250 case GST_LINESMOOTHENABLE: return "LineSmoothEnable"; 3251 case GST_LINESTIPPLEENABLE: return "LineStippleEnable"; 3252 case GST_LOGICOPENABLE: return "LogicOpEnable"; 3253 case GST_MULTISAMPLEENABLE: return "MultisampleEnable"; 3254 case GST_NORMALIZEENABLE: return "NormalizeEnable"; 3255 case GST_POINTSMOOTHENABLE: return "PointSmoothEnable"; 3256 case GST_POINTSPRITEENABLE: return "PointSpriteEnable"; 3257 case GST_POLYGONOFFSETFILLENABLE: return "PolygonOffsetFillEnable"; 3258 case GST_POLYGONOFFSETLINEENABLE: return "PolygonOffsetLineEnable"; 3259 case GST_POLYGONOFFSETPOINTENABLE: return "PolygonOffsetPointEnable"; 3260 case GST_POLYGONSMOOTHENABLE: return "PolygonSmoothEnable"; 3261 case GST_POLYGONSTIPPLEENABLE: return "PolygonStippleEnable"; 3262 case GST_RESCALENORMALENABLE: return "RescaleNormalEnable"; 3263 case GST_SAMPLEALPHATOCOVERAGEENABLE: return "SampleAlphaToCoverageEnable"; 3264 case GST_SAMPLEALPHATOONEENABLE: return "SampleAlphaToOneEnable"; 3265 case GST_SAMPLECOVERAGEENABLE: return "SampleCoverageEnable"; 3266 case GST_SCISSORTESTENABLE: return "ScissorTestEnable"; 3267 case GST_STENCILTESTENABLE: return "StencilTestEnable"; 3268 case GST_STENCILENABLE: return "StencilEnable"; 3269 case GST_STENCILTESTTWOSIDEENABLE: return "StencilTestTwoSideEnable"; 3270 case GST_STENCILFAIL: return "StencilFail"; 3271 case GST_TEXGENSENABLE: return "TexGenSEnable"; 3272 case GST_TEXGENTENABLE: return "TexGenTEnable"; 3273 case GST_TEXGENRENABLE: return "TexGenREnable"; 3274 case GST_TEXGENQENABLE: return "TexGenQEnable"; 3275 case GST_WRAP0: return "Wrap0"; 3276 case GST_WRAP1: return "Wrap1"; 3277 case GST_WRAP2: return "Wrap2"; 3278 case GST_WRAP3: return "Wrap3"; 3279 case GST_WRAP4: return "Wrap4"; 3280 case GST_WRAP5: return "Wrap5"; 3281 case GST_WRAP6: return "Wrap6"; 3282 case GST_WRAP7: return "Wrap7"; 3283 case GST_WRAP8: return "Wrap8"; 3284 case GST_WRAP9: return "Wrap9"; 3285 case GST_WRAP10: return "Wrap10"; 3286 case GST_WRAP11: return "Wrap11"; 3287 case GST_WRAP12: return "Wrap12"; 3288 case GST_WRAP13: return "Wrap13"; 3289 case GST_WRAP14: return "Wrap14"; 3290 case GST_WRAP15: return "Wrap15"; 3291 case GST_VERTEXPROGRAMPOINTSIZEENABLE: return "VertexProgramPointSizeEnable"; 3292 case GST_VERTEXPROGRAMTWOSIDEENABLE: return "VertexProgramTwoSideEnable"; 3293 case GST_GEOMETRYPROGRAM: return "GeometryProgram"; 3294 case GST_VERTEXPROGRAM: return "VertexProgram"; 3295 case GST_FRAGMENTPROGRAM: return "FragmentProgram"; 3296 case GST_VERTEXSHADER: return "VertexShader"; 3297 case GST_PIXELSHADER: return "PixelShader"; 3298 case GST_ALPHAOP: return "AlphaOp"; 3299 case GST_ALPHAARG0: return "AlphaArg0"; 3300 case GST_ALPHAARG1: return "AlphaArg1"; 3301 case GST_ALPHAARG2: return "AlphaArg2"; 3302 case GST_COLORARG0: return "ColorArg0"; 3303 case GST_COLORARG1: return "ColorArg1"; 3304 case GST_COLORARG2: return "ColorArg2"; 3305 case GST_COLOROP: return "ColorOp"; 3306 case GST_BUMPENVLSCALE: return "BumpEnvLScale"; 3307 case GST_BUMPENVLOFFSET: return "BumpEnvLOffset"; 3308 case GST_BUMPENVMAT00: return "BumpEnvMat00"; 3309 case GST_BUMPENVMAT01: return "BumpEnvMat01"; 3310 case GST_BUMPENVMAT10: return "BumpEnvMat10"; 3311 case GST_BUMPENVMAT11: return "BumpEnvMat11"; 3312 case GST_RESULTARG: return "ResultArg"; 3313 case GST_TEXCOORDINDEX: return "TexCoordIndex"; 3314 case GST_TEXTURETRANSFORMFLAGS: return "TextureTransformFlags"; 3315 case GST_TWOSIDEDSTENCILMODE: return "TwoSidedStencilMode"; 3316 case GST_SEPARATEALPHABLENDENABLE: return "SeparateAlphaBlendEnable"; 3317 case GST_NORMALIZENORMALS: return "NormalizeNormals"; 3318 case GST_LIGHTING: return "Lighting"; 3319 case GST_PIXELSHADERCONSTANTB: return "PixelShaderConstantB"; 3320 case GST_VERTEXSHADERCONSTANTB: return "VertexShaderConstantB"; 3321 case GST_COLORWRITEENABLE1: return "ColorWriteEnable1"; 3322 case GST_COLORWRITEENABLE2: return "ColorWriteEnable2"; 3323 case GST_COLORWRITEENABLE3: return "ColorWriteEnable3"; 3324 case GST_PIXELSHADERCONSTANT1: return "PixelShaderConstant1"; 3325 case GST_VERTEXSHADERCONSTANT1: return "VertexShaderConstant1"; 3326 case GST_PIXELSHADERCONSTANTF: return "PixelShaderConstantF"; 3327 case GST_VERTEXSHADERCONSTANTF: return "VertexShaderConstantF"; 3328 case GST_PIXELSHADERCONSTANT2: return "PixelShaderConstant2"; 3329 case GST_VERTEXSHADERCONSTANT2: return "VertexShaderConstant2"; 3330 case GST_PIXELSHADERCONSTANT3: return "PixelShaderConstant3"; 3331 case GST_VERTEXSHADERCONSTANT3: return "VertexShaderConstant3"; 3332 case GST_PIXELSHADERCONSTANT: return "PixelShaderConstant"; 3333 case GST_VERTEXSHADERCONSTANT: return "VertexShaderConstant"; 3334 case GST_PIXELSHADERCONSTANT4: return "PixelShaderConstant4"; 3335 case GST_VERTEXSHADERCONSTANT4: return "VertexShaderConstant4"; 3336 case GST_PIXELSHADERCONSTANTI: return "PixelShaderConstantI"; 3337 case GST_VERTEXSHADERCONSTANTI: return "VertexShaderConstantI"; 3338 case GST_SAMPLER: return "Sampler"; 3339 case GST_TEXTURE: return "Texture"; 3340 case GST_ADDRESSU: return "AddressU"; 3341 case GST_ADDRESSV: return "AddressV"; 3342 case GST_ADDRESSW: return "AddressW"; 3343 case GST_BORDERCOLOR: return "BorderColor"; 3344 case GST_MAXANISOTROPY: return "MaxAnisotropy"; 3345 case GST_MAXMIPLEVEL: return "MaxMipLevel"; 3346 case GST_MINFILTER: return "MinFilter"; 3347 case GST_MAGFILTER: return "MagFilter"; 3348 case GST_MIPFILTER: return "MipFilter"; 3349 case GST_MIPMAPLODBIAS: return "MipMapLodBias"; 3350 case GST_BLENDOPALPHA: return "BlendOpAlpha"; 3351 case GST_SRCBLENDALPHA: return "SrcBlendAlpha"; 3352 case GST_DESTBLENDALPHA: return "DestBlendAlpha"; 3353 3354 case GST_UNKNOWN: 3355 default: 3356 return "unknown"; 3357 } 3358 3359 } 3360 //--------------------------------------------------------------------- getSamplerStateNameTypeToString(const SamplerStateType cgStateName)3361 const char * CgFxScriptLoader::getSamplerStateNameTypeToString( const SamplerStateType cgStateName ) 3362 { 3363 switch(cgStateName) 3364 { 3365 case SST_TEXTURE: return "Texture"; 3366 case SST_ADDRESSU: return "AddressU"; 3367 case SST_ADDRESSV: return "AddressV"; 3368 case SST_ADDRESSW: return "AddressW"; 3369 case SST_WRAPS: return "WrapS"; 3370 case SST_WRAPT: return "WrapT"; 3371 case SST_WRAPR: return "WrapR"; 3372 case SST_MIPFILTER: return "MipFilter"; 3373 case SST_MIPMAPLODBIAS: return "MipMapLodBias"; 3374 case SST_LODBIAS: return "LODBias"; 3375 case SST_SRGBTEXTURE: return "SRGBTexture"; 3376 case SST_MINFILTER: return "MinFilter"; 3377 case SST_MAGFILTER: return "MagFilter"; 3378 case SST_BORDERCOLOR: return "BorderColor"; 3379 case SST_MINMIPLEVEL: return "MinMipLevel"; 3380 case SST_MAXMIPLEVEL: return "MaxMipLevel"; 3381 case SST_MAXANISOTROPY: return "MaxAnisotropy"; 3382 case SST_DEPTHMODE: return "DepthMode"; 3383 case SST_COMPAREMODE: return "CompareMode"; 3384 case SST_COMPAREFUNC: return "CompareFunc"; 3385 case SST_GENERATEMIPMAP: return "GenerateMipmap"; 3386 case SST_UNKNOWN: 3387 default: 3388 return "unknown"; 3389 } 3390 3391 } 3392 //--------------------------------------------------------------------- cgSemanticToOgreAutoConstantType(const char * cgParamSemantic,const char * uiNameValue,GpuProgramParameters::AutoConstantType & ogreAutoConstantType,size_t & extraInfo)3393 bool CgFxScriptLoader::cgSemanticToOgreAutoConstantType( const char * cgParamSemantic, const char * uiNameValue, GpuProgramParameters::AutoConstantType & ogreAutoConstantType, size_t & extraInfo ) 3394 { 3395 extraInfo = 0; 3396 3397 FXSemanticID cgFXSemanticID = cgSemanticStringToType(cgParamSemantic); 3398 switch(cgFXSemanticID) 3399 { 3400 case FXS_NONE: 3401 return false; 3402 case FXS_COLOR: 3403 // todo - add to ogre 3404 return false; 3405 case FXS_DIFFUSE: 3406 ogreAutoConstantType = GpuProgramParameters::ACT_SURFACE_DIFFUSE_COLOUR; 3407 return true; 3408 case FXS_SPECULAR: 3409 ogreAutoConstantType = GpuProgramParameters::ACT_SURFACE_SPECULAR_COLOUR; 3410 return true; 3411 case FXS_AMBIENT: 3412 ogreAutoConstantType = GpuProgramParameters::ACT_SURFACE_AMBIENT_COLOUR; 3413 return true; 3414 case FXS_EMISSION: 3415 // todo - add to ogre 3416 return false; 3417 case FXS_EMISSIVE: 3418 ogreAutoConstantType = GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR; 3419 return true; 3420 case FXS_SPECULARPOWER: 3421 // todo - add to ogre 3422 return false; 3423 case FXS_REFRACTION: 3424 // todo - add to ogre 3425 return false; 3426 case FXS_OPACITY: 3427 // todo - add to ogre 3428 return false; 3429 case FXS_ENVIRONMENT: 3430 // todo - add to ogre 3431 return false; 3432 case FXS_ENVIRONMENTNORMAL: 3433 // todo - add to ogre 3434 return false; 3435 case FXS_NORMAL: 3436 // todo - add to ogre 3437 return false; 3438 case FXS_HEIGHT: 3439 // todo - add to ogre 3440 return false; 3441 case FXS_ATTENUATION: 3442 // todo - in ogre ACT_LIGHT_ATTENUATION is float4 and we need float3 here 3443 return false; 3444 case FXS_RENDERCOLORTARGET: 3445 // todo - add to ogre 3446 return false; 3447 case FXS_RENDERDEPTHSTENCILTARGET: 3448 // todo - add to ogre 3449 return false; 3450 case FXS_VIEWPORTPIXELSIZE: 3451 // todo - add to ogre 3452 return false; 3453 case FXS_CAMERAPOSITION: 3454 ogreAutoConstantType = GpuProgramParameters::ACT_CAMERA_POSITION; 3455 return true; 3456 case FXS_TIME: 3457 // todo - possibly this value is has the wrong units... 3458 ogreAutoConstantType = GpuProgramParameters::ACT_TIME; 3459 return true; 3460 case FXS_ELAPSEDTIME: 3461 // todo - possibly this value is has the wrong units... 3462 ogreAutoConstantType = GpuProgramParameters::ACT_FRAME_TIME; 3463 return true; 3464 case FXS_ANIMATIONTIME: 3465 // todo - add to ogre 3466 return false; 3467 case FXS_ANIMATIONTICK: 3468 // todo - add to ogre 3469 return false; 3470 case FXS_MOUSEPOSITION: 3471 // todo - add to ogre 3472 return false; 3473 case FXS_LEFTMOUSEDOWN: 3474 // todo - add to ogre 3475 return false; 3476 case FXS_WORLD: 3477 ogreAutoConstantType = GpuProgramParameters::ACT_WORLD_MATRIX; 3478 return true; 3479 case FXS_VIEW: 3480 ogreAutoConstantType = GpuProgramParameters::ACT_VIEW_MATRIX; 3481 return true; 3482 case FXS_PROJECTION: 3483 ogreAutoConstantType = GpuProgramParameters::ACT_PROJECTION_MATRIX; 3484 return true; 3485 case FXS_WORLDTRANSPOSE: 3486 ogreAutoConstantType = GpuProgramParameters::ACT_TRANSPOSE_WORLD_MATRIX; 3487 return true; 3488 case FXS_VIEWTRANSPOSE: 3489 ogreAutoConstantType = GpuProgramParameters::ACT_TRANSPOSE_VIEW_MATRIX; 3490 return true; 3491 case FXS_PROJECTIONTRANSPOSE: 3492 ogreAutoConstantType = GpuProgramParameters::ACT_TRANSPOSE_PROJECTION_MATRIX; 3493 return true; 3494 case FXS_WORLDVIEW: 3495 ogreAutoConstantType = GpuProgramParameters::ACT_WORLDVIEW_MATRIX; 3496 return true; 3497 case FXS_WORLDVIEWPROJECTION: 3498 ogreAutoConstantType = GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX; 3499 return true; 3500 case FXS_WORLDINVERSE: 3501 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_WORLD_MATRIX; 3502 return true; 3503 case FXS_VIEWINVERSE: 3504 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_VIEW_MATRIX; 3505 return true; 3506 case FXS_PROJECTIONINVERSE: 3507 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_PROJECTION_MATRIX; 3508 return true; 3509 case FXS_WORLDINVERSETRANSPOSE: 3510 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_TRANSPOSE_WORLD_MATRIX; 3511 return true; 3512 case FXS_VIEWINVERSETRANSPOSE: 3513 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_TRANSPOSE_VIEW_MATRIX; 3514 return true; 3515 case FXS_PROJECTIONINVERSETRANSPOSE: 3516 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_TRANSPOSE_PROJECTION_MATRIX; 3517 return true; 3518 case FXS_WORLDVIEWINVERSE: 3519 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_WORLDVIEW_MATRIX; 3520 return true; 3521 case FXS_WORLDVIEWTRANSPOSE: 3522 ogreAutoConstantType = GpuProgramParameters::ACT_TRANSPOSE_WORLDVIEW_MATRIX; 3523 return true; 3524 case FXS_WORLDVIEWINVERSETRANSPOSE: 3525 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_TRANSPOSE_WORLDVIEW_MATRIX; 3526 return true; 3527 case FXS_WORLDVIEWPROJECTIONINVERSE: 3528 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_WORLDVIEWPROJ_MATRIX; 3529 return true; 3530 case FXS_WORLDVIEWPROJECTIONTRANSPOSE: 3531 ogreAutoConstantType = GpuProgramParameters::ACT_TRANSPOSE_WORLDVIEWPROJ_MATRIX; 3532 return true; 3533 case FXS_WORLDVIEWPROJECTIONINVERSETRANSPOSE: 3534 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_TRANSPOSE_WORLDVIEWPROJ_MATRIX; 3535 return true; 3536 case FXS_VIEWPROJECTION: 3537 ogreAutoConstantType = GpuProgramParameters::ACT_VIEWPROJ_MATRIX; 3538 return true; 3539 case FXS_VIEWPROJECTIONTRANSPOSE: 3540 ogreAutoConstantType = GpuProgramParameters::ACT_TRANSPOSE_VIEWPROJ_MATRIX; 3541 return true; 3542 case FXS_VIEWPROJECTIONINVERSE: 3543 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_VIEWPROJ_MATRIX; 3544 return true; 3545 case FXS_VIEWPROJECTIONINVERSETRANSPOSE: 3546 ogreAutoConstantType = GpuProgramParameters::ACT_INVERSE_TRANSPOSE_VIEWPROJ_MATRIX; 3547 return true; 3548 case FXS_FXCOMPOSER_RESETPULSE: 3549 // todo - add to ogre 3550 return false; 3551 case FXS_STANDARDSGLOBAL: 3552 // todo - add to ogre 3553 return false; 3554 case FXS_UNITSSCALE: 3555 // todo - add to ogre 3556 return false; 3557 case FXS_POWER: 3558 // todo - add to ogre 3559 return false; 3560 case FXS_DIFFUSEMAP: 3561 // todo - add to ogre 3562 return false; 3563 case FXS_SPECULARMAP: 3564 // todo - add to ogre 3565 return false; 3566 case FXS_ENVMAP: 3567 // todo - add to ogre 3568 return false; 3569 case FXS_LIGHTPOSITION: 3570 // todo - ACT_LIGHT_POSITION 3571 return false; 3572 case FXS_TRANSFORM: 3573 // todo - add to ogre 3574 return false; 3575 case FXS_USER: 3576 // todo - add to ogre 3577 return false; 3578 case FXS_CONSTANTATTENUATION: 3579 // todo - add to ogre 3580 return false; 3581 case FXS_LINEARATTENUATION: 3582 // todo - add to ogre 3583 return false; 3584 case FXS_QUADRATICATTENUATION: 3585 // todo - add to ogre 3586 return false; 3587 case FXS_FALLOFFANGLE: 3588 // todo - add to ogre 3589 return false; 3590 case FXS_FALLOFFEXPONENT: 3591 // todo - add to ogre 3592 return false; 3593 case FXS_BOUNDINGRADIUS: 3594 // todo - add to ogre 3595 return false; 3596 case FXS_POSITION: 3597 case FXS_DIRECTION: 3598 case FXS_UNKNOWN: 3599 if (uiNameValue) 3600 { 3601 String uiNameValueAsString(uiNameValue); 3602 String theWordLight = "Light"; 3603 if (StringUtil::startsWith(uiNameValueAsString, theWordLight, false)) 3604 { 3605 size_t firstSpacePos = uiNameValueAsString.find(' '); 3606 if (firstSpacePos > 0) 3607 { 3608 String lightNumberAsString = uiNameValueAsString.substr(theWordLight.size(), firstSpacePos - theWordLight.size()); 3609 3610 size_t lightNumber = StringConverter::parseInt(lightNumberAsString); 3611 extraInfo = lightNumber; 3612 3613 String colorPart = uiNameValueAsString.substr(firstSpacePos + 1); 3614 if ( colorPart == "Color" ) // float4 3615 { 3616 ogreAutoConstantType = GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR; 3617 return true; 3618 } 3619 if ( colorPart == "Intensity" ) // float 3620 { 3621 ogreAutoConstantType = GpuProgramParameters::ACT_LIGHT_POWER_SCALE; 3622 return true; 3623 } 3624 if ( colorPart == "Light_position" ) // float3 3625 { 3626 ogreAutoConstantType = GpuProgramParameters::ACT_LIGHT_POSITION; 3627 return true; 3628 } 3629 if ( colorPart == "Light_direction" ) // float3 3630 { 3631 ogreAutoConstantType = GpuProgramParameters::ACT_LIGHT_DIRECTION; 3632 return true; 3633 } 3634 if ( colorPart == "Distance Falloff Exponent" ) // float 3635 { 3636 //ogreAutoConstantType = todo: add to GpuProgramParameters; 3637 return false; 3638 } 3639 if ( colorPart == "Distance Falloff Start" ) // float 3640 { 3641 //ogreAutoConstantType = todo: add to GpuProgramParameters; 3642 return false; 3643 } 3644 if ( colorPart == "Light1 Distance Falloff Limit" ) // float 3645 { 3646 //ogreAutoConstantType = todo: add to GpuProgramParameters; 3647 return false; 3648 } 3649 if ( colorPart == "Distance Scale" ) // float 3650 { 3651 //ogreAutoConstantType = todo: add to GpuProgramParameters; 3652 return false; 3653 } 3654 if ( colorPart == "Spread Inner" ) // float 3655 { 3656 //ogreAutoConstantType = todo: add to GpuProgramParameters; 3657 return false; 3658 } 3659 if ( colorPart == "Spread Falloff" ) // float 3660 { 3661 //ogreAutoConstantType = todo: add to GpuProgramParameters; 3662 return false; 3663 } 3664 if ( colorPart == "Light_spread_cos" ) // float 3665 { 3666 //ogreAutoConstantType = todo: add to GpuProgramParameters; 3667 return false; 3668 } 3669 } 3670 3671 } 3672 else // some other light params 3673 { 3674 if ( uiNameValueAsString == "Diffuse Scalar" ) // float 3675 { 3676 //ogreAutoConstantType = todo: add to GpuProgramParameters; 3677 return false; 3678 } 3679 if ( uiNameValueAsString == "Specular Color" ) // float4 3680 { 3681 ogreAutoConstantType = GpuProgramParameters::ACT_SURFACE_SPECULAR_COLOUR; 3682 return true; 3683 } 3684 if ( uiNameValueAsString == "Specular Scalar" ) // float 3685 { 3686 //ogreAutoConstantType = todo: add to GpuProgramParameters; 3687 return false; 3688 } 3689 if ( uiNameValueAsString == "Specular Shininess" ) // float 3690 { 3691 //ogreAutoConstantType = todo: add to GpuProgramParameters; 3692 return false; 3693 } 3694 } 3695 } 3696 return false; 3697 default: 3698 return false; 3699 } 3700 3701 } 3702 3703 //--------------------------------------------------------------------- parseAutoConstantParam(CGparameter cgParameter,GpuProgramParametersSharedPtr ogreProgramParameters,const String & ogreParamName)3704 bool CgFxScriptLoader::parseAutoConstantParam( CGparameter cgParameter, GpuProgramParametersSharedPtr ogreProgramParameters, const String& ogreParamName ) 3705 { 3706 const char * cgParamSemantic = cgGetParameterSemantic(cgParameter); 3707 CGannotation parameterAnnotation = cgGetFirstParameterAnnotation(cgParameter); 3708 const char * uiNameValue = 0; 3709 while(parameterAnnotation) 3710 { 3711 const char * annotationName = cgGetAnnotationName(parameterAnnotation); 3712 if( strcmp("UIName", annotationName) == 0 ) 3713 { 3714 uiNameValue = cgGetStringAnnotationValue(parameterAnnotation); 3715 } 3716 parameterAnnotation = cgGetNextAnnotation(parameterAnnotation); 3717 } 3718 3719 bool isAutoConstant = false; 3720 if (cgParamSemantic) 3721 { 3722 GpuProgramParameters::AutoConstantType ogreAutoConstantType; 3723 size_t extraInfo = 0; 3724 bool autoConstantTypeFound = cgSemanticToOgreAutoConstantType(cgParamSemantic, uiNameValue, ogreAutoConstantType, extraInfo); 3725 if (autoConstantTypeFound) 3726 { 3727 isAutoConstant = true; 3728 } 3729 else 3730 { 3731 // todo - an error? 3732 } 3733 if (isAutoConstant) 3734 { 3735 ogreProgramParameters->setNamedAutoConstant(ogreParamName, ogreAutoConstantType, extraInfo); 3736 } 3737 } 3738 return isAutoConstant; 3739 } 3740 //--------------------------------------------------------------------- parseFloatCgProgramParameter(CGtype cgParamType,CGparameter cgParameter,GpuProgramParametersSharedPtr ogreProgramParameters,const String & ogreParamName)3741 void CgFxScriptLoader::parseFloatCgProgramParameter( CGtype cgParamType, CGparameter cgParameter, GpuProgramParametersSharedPtr ogreProgramParameters, const String& ogreParamName ) 3742 { 3743 float cgParamValue[4*4] = { 3744 0.0f, 0.0f, 0.0f, 0.0f, 3745 0.0f, 0.0f, 0.0f, 0.0f, 3746 0.0f, 0.0f, 0.0f, 0.0f, 3747 0.0f, 0.0f, 0.0f, 0.0f 3748 }; 3749 int paramSize = 0; 3750 switch(cgParamType) 3751 { 3752 case CG_FLOAT: 3753 paramSize = 1; 3754 break; 3755 case CG_FLOAT2: 3756 paramSize = 2; 3757 break; 3758 case CG_FLOAT3: 3759 paramSize = 3; 3760 break; 3761 case CG_FLOAT4: 3762 paramSize = 4; 3763 break; 3764 case CG_FLOAT1x1: 3765 paramSize = 1*1; 3766 break; 3767 case CG_FLOAT1x2: 3768 paramSize = 1*2; 3769 break; 3770 case CG_FLOAT1x3: 3771 paramSize = 1*3; 3772 break; 3773 case CG_FLOAT1x4: 3774 paramSize = 1*4; 3775 break; 3776 case CG_FLOAT2x1: 3777 paramSize = 2*1; 3778 break; 3779 case CG_FLOAT2x2: 3780 paramSize = 2*2; 3781 break; 3782 case CG_FLOAT2x3: 3783 paramSize = 2*3; 3784 break; 3785 case CG_FLOAT2x4: 3786 paramSize = 2*4; 3787 break; 3788 case CG_FLOAT3x1: 3789 paramSize = 3*1; 3790 break; 3791 case CG_FLOAT3x2: 3792 paramSize = 3*2; 3793 break; 3794 case CG_FLOAT3x3: 3795 paramSize = 3*3; 3796 break; 3797 case CG_FLOAT3x4: 3798 paramSize = 3*4; 3799 break; 3800 case CG_FLOAT4x1: 3801 paramSize = 4*1; 3802 break; 3803 case CG_FLOAT4x2: 3804 paramSize = 4*2; 3805 break; 3806 case CG_FLOAT4x3: 3807 paramSize = 4*3; 3808 break; 3809 case CG_FLOAT4x4: 3810 paramSize = 4*4; 3811 break; 3812 default: 3813 // todo error 3814 break; 3815 } 3816 cgGetParameterValuefc(cgParameter, paramSize, cgParamValue); 3817 ogreProgramParameters->setNamedConstant(ogreParamName, cgParamValue, 1, paramSize); 3818 } 3819 //--------------------------------------------------------------------- parseIntCgProgramParameter(CGtype cgParamType,CGparameter cgParameter,GpuProgramParametersSharedPtr ogreProgramParameters,const String & ogreParamName)3820 void CgFxScriptLoader::parseIntCgProgramParameter( CGtype cgParamType, CGparameter cgParameter, GpuProgramParametersSharedPtr ogreProgramParameters, const String& ogreParamName ) 3821 { 3822 int cgParamValue[4*4] = { 3823 0, 0, 0, 0, 3824 0, 0, 0, 0, 3825 0, 0, 0, 0, 3826 0, 0, 0, 0 3827 }; 3828 int paramSize = 0; 3829 switch(cgParamType) 3830 { 3831 case CG_INT: 3832 paramSize = 1; 3833 break; 3834 case CG_INT2: 3835 paramSize = 2; 3836 break; 3837 case CG_INT3: 3838 paramSize = 3; 3839 break; 3840 case CG_INT4: 3841 paramSize = 4; 3842 break; 3843 case CG_INT1x1: 3844 paramSize = 1*1; 3845 break; 3846 case CG_INT1x2: 3847 paramSize = 1*2; 3848 break; 3849 case CG_INT1x3: 3850 paramSize = 1*3; 3851 break; 3852 case CG_INT1x4: 3853 paramSize = 1*4; 3854 break; 3855 case CG_INT2x1: 3856 paramSize = 2*1; 3857 break; 3858 case CG_INT2x2: 3859 paramSize = 2*2; 3860 break; 3861 case CG_INT2x3: 3862 paramSize = 2*3; 3863 break; 3864 case CG_INT2x4: 3865 paramSize = 2*4; 3866 break; 3867 case CG_INT3x1: 3868 paramSize = 3*1; 3869 break; 3870 case CG_INT3x2: 3871 paramSize = 3*2; 3872 break; 3873 case CG_INT3x3: 3874 paramSize = 3*3; 3875 break; 3876 case CG_INT3x4: 3877 paramSize = 3*4; 3878 break; 3879 case CG_INT4x1: 3880 paramSize = 4*1; 3881 break; 3882 case CG_INT4x2: 3883 paramSize = 4*2; 3884 break; 3885 case CG_INT4x3: 3886 paramSize = 4*3; 3887 break; 3888 case CG_INT4x4: 3889 paramSize = 4*4; 3890 break; 3891 default: 3892 // todo error 3893 break; 3894 } 3895 cgGetParameterValueic(cgParameter, paramSize, cgParamValue); 3896 ogreProgramParameters->setNamedConstant(ogreParamName, cgParamValue, 1, paramSize); 3897 } 3898 //--------------------------------------------------------------------- createCgSamplerStateListener(const SamplerStateType type)3899 Ogre::CgFxScriptLoader::CgSamplerStateListener * CgFxScriptLoader::createCgSamplerStateListener( const SamplerStateType type ) 3900 { 3901 switch(type) 3902 { 3903 case SST_ADDRESSU: 3904 case SST_ADDRESSV: 3905 case SST_ADDRESSW: 3906 return OGRE_NEW CgTextureAddressSamplerStateListener(type); 3907 case SST_WRAPS: 3908 case SST_WRAPT: 3909 case SST_WRAPR: 3910 return OGRE_NEW CgWrapSamplerStateListener(type); 3911 case SST_BORDERCOLOR: 3912 return OGRE_NEW CgFloat4SamplerStateListener(type); 3913 case SST_COMPAREMODE: 3914 return OGRE_NEW CgCompareModeSamplerStateListener(); 3915 case SST_COMPAREFUNC: 3916 return OGRE_NEW CgCompareFuncSamplerStateListener(); 3917 case SST_DEPTHMODE: 3918 return OGRE_NEW CgDepthModeSamplerStateListener(); 3919 case SST_GENERATEMIPMAP: 3920 return OGRE_NEW CgBoolSamplerStateListener(type); 3921 case SST_MIPMAPLODBIAS: 3922 case SST_LODBIAS: 3923 case SST_MAXMIPLEVEL: 3924 case SST_MAXANISOTROPY: 3925 case SST_MINMIPLEVEL: 3926 case SST_SRGBTEXTURE: 3927 return OGRE_NEW CgFloatSamplerStateListener(type); 3928 case SST_MINFILTER: 3929 return OGRE_NEW CgMinFilterSamplerStateListener(); 3930 case SST_MAGFILTER: 3931 return OGRE_NEW CgMagFilterSamplerStateListener(); 3932 case SST_TEXTURE: 3933 return OGRE_NEW CgTextureSamplerStateListener(type); 3934 case SST_MIPFILTER: 3935 return OGRE_NEW CgMipFilterSamplerStateListener(); 3936 default: 3937 // TODO - this is an error.... 3938 return OGRE_NEW CgSamplerStateListener(type, CG_STRING); 3939 } 3940 } 3941 //--------------------------------------------------------------------- createCgGlobalStateListener(const GlobalStateType type)3942 Ogre::CgFxScriptLoader::CgGlobalStateListener * CgFxScriptLoader::createCgGlobalStateListener( const GlobalStateType type ) 3943 { 3944 switch(type) 3945 { 3946 case GST_ALPHABLENDENABLE: 3947 case GST_COLORVERTEX: 3948 case GST_DEPTHMASK: 3949 case GST_ZWRITEENABLE: 3950 case GST_INDEXEDVERTEXBLENDENABLE: 3951 case GST_LIGHTINGENABLE: 3952 case GST_LIGHTING: 3953 case GST_LIGHTENABLE: 3954 case GST_LOCALVIEWER: 3955 case GST_MULTISAMPLEANTIALIAS: 3956 case GST_POINTSCALEENABLE: 3957 case GST_RANGEFOGENABLE: 3958 case GST_SPECULARENABLE: 3959 case GST_CLIPPING: 3960 case GST_POINTSPRITECOORDREPLACE: 3961 case GST_LASTPIXEL: 3962 case GST_TEXTURE1DENABLE: 3963 case GST_TEXTURE2DENABLE: 3964 case GST_TEXTURE3DENABLE: 3965 case GST_TEXTURERECTANGLEENABLE: 3966 case GST_TEXTURECUBEMAPENABLE: 3967 case GST_ALPHATESTENABLE: 3968 case GST_AUTONORMALENABLE: 3969 case GST_BLENDENABLE: 3970 case GST_COLORLOGICOPENABLE: 3971 case GST_CULLFACEENABLE: 3972 case GST_DEPTHBOUNDSENABLE: 3973 case GST_DEPTHCLAMPENABLE: 3974 case GST_DEPTHTESTENABLE: 3975 case GST_ZENABLE: 3976 case GST_DITHERENABLE: 3977 case GST_FOGENABLE: 3978 case GST_LIGHTMODELLOCALVIEWERENABLE: 3979 case GST_LIGHTMODELTWOSIDEENABLE: 3980 case GST_LINESMOOTHENABLE: 3981 case GST_LINESTIPPLEENABLE: 3982 case GST_LOGICOPENABLE: 3983 case GST_MULTISAMPLEENABLE: 3984 case GST_NORMALIZEENABLE: 3985 case GST_NORMALIZENORMALS: 3986 case GST_POINTSMOOTHENABLE: 3987 case GST_POINTSPRITEENABLE: 3988 case GST_POLYGONOFFSETFILLENABLE: 3989 case GST_POLYGONOFFSETLINEENABLE: 3990 case GST_POLYGONOFFSETPOINTENABLE: 3991 case GST_POLYGONSMOOTHENABLE: 3992 case GST_POLYGONSTIPPLEENABLE: 3993 case GST_RESCALENORMALENABLE: 3994 case GST_SAMPLEALPHATOCOVERAGEENABLE: 3995 case GST_SAMPLEALPHATOONEENABLE: 3996 case GST_SAMPLECOVERAGEENABLE: 3997 case GST_SCISSORTESTENABLE: 3998 case GST_STENCILTESTENABLE: 3999 case GST_STENCILENABLE: 4000 case GST_STENCILTESTTWOSIDEENABLE: 4001 case GST_TEXGENSENABLE: 4002 case GST_TEXGENTENABLE: 4003 case GST_TEXGENRENABLE: 4004 case GST_TEXGENQENABLE: 4005 case GST_TWOSIDEDSTENCILMODE: 4006 case GST_SEPARATEALPHABLENDENABLE: 4007 case GST_VERTEXPROGRAMPOINTSIZEENABLE: 4008 case GST_VERTEXPROGRAMTWOSIDEENABLE: 4009 return OGRE_NEW CgBoolGlobalStateListener(type); 4010 case GST_COLORWRITEENABLE: 4011 case GST_COLORMASK: 4012 case GST_PIXELSHADERCONSTANTB: 4013 case GST_VERTEXSHADERCONSTANTB: 4014 case GST_COLORWRITEENABLE1: 4015 case GST_COLORWRITEENABLE2: 4016 case GST_COLORWRITEENABLE3: 4017 return OGRE_NEW CgBool4GlobalStateListener(type); 4018 case GST_ALPHAREF: 4019 case GST_CLEARDEPTH: 4020 case GST_DEPTHBIAS: 4021 case GST_FOGDENSITY: 4022 case GST_FOGSTART: 4023 case GST_FOGEND: 4024 case GST_LIGHTCONSTANTATTENUATION: 4025 case GST_LIGHTATTENUATION0: 4026 case GST_LIGHTLINEARATTENUATION: 4027 case GST_LIGHTATTENUATION1: 4028 case GST_LIGHTQUADRATICATTENUATION: 4029 case GST_LIGHTATTENUATION2: 4030 case GST_LIGHTSPOTCUTOFF: 4031 case GST_LIGHTFALLOFF: 4032 case GST_LIGHTPHI: 4033 case GST_LIGHTRANGE: 4034 case GST_LIGHTTHETA: 4035 case GST_PATCHSEGMENTS: 4036 case GST_POINTSCALE_A: 4037 case GST_POINTSCALE_B: 4038 case GST_POINTSCALE_C: 4039 case GST_TWEENFACTOR: 4040 case GST_LINEWIDTH: 4041 case GST_MATERIALSHININESS: 4042 case GST_MATERIALPOWER: 4043 case GST_POINTFADETHRESHOLDSIZE: 4044 case GST_POINTSIZE: 4045 case GST_POINTSIZEMIN: 4046 case GST_POINTSIZEMAX: 4047 case GST_SLOPSCALEDEPTHBIAS: 4048 case GST_BUMPENVLSCALE: 4049 case GST_BUMPENVLOFFSET: 4050 case GST_BUMPENVMAT00: 4051 case GST_BUMPENVMAT01: 4052 case GST_BUMPENVMAT10: 4053 case GST_BUMPENVMAT11: 4054 case GST_LIGHTSPOTEXPONENT: 4055 return OGRE_NEW CgFloatGlobalStateListener(type); 4056 case GST_DEPTHBOUNDS: 4057 case GST_DEPTHRANGE: 4058 case GST_POLYGONOFFSET: 4059 case GST_MAXANISOTROPY: 4060 case GST_MAXMIPLEVEL: 4061 return OGRE_NEW CgFloat2GlobalStateListener(type); 4062 case GST_POINTDISTANCEATTENUATION: 4063 return OGRE_NEW CgFloat3GlobalStateListener(type); 4064 case GST_BLENDCOLOR: 4065 case GST_CLEARCOLOR: 4066 case GST_CLIPPLANE: 4067 case GST_FOGCOLOR: 4068 case GST_FRAGMENTENVPARAMETER: 4069 case GST_FRAGMENTLOCALPARAMETER: 4070 case GST_LIGHTMODELAMBIENT: 4071 case GST_AMBIENT: 4072 case GST_LIGHTAMBIENT: 4073 case GST_LIGHTDIFFUSE: 4074 case GST_LIGHTPOSITION: 4075 case GST_LIGHTSPECULAR: 4076 case GST_LIGHTSPOTDIRECTION: 4077 case GST_LIGHTDIRECTION: 4078 case GST_MATERIALAMBIENT: 4079 case GST_MATERIALDIFFUSE: 4080 case GST_MATERIALEMISSION: 4081 case GST_MATERIALEMISSIVE: 4082 case GST_MATERIALSPECULAR: 4083 case GST_TEXGENSOBJECTPLANE: 4084 case GST_TEXGENSEYEPLANE: 4085 case GST_TEXGENTOBJECTPLANE: 4086 case GST_TEXGENTEYEPLANE: 4087 case GST_TEXGENROBJECTPLANE: 4088 case GST_TEXGENREYEPLANE: 4089 case GST_TEXGENQOBJECTPLANE: 4090 case GST_TEXGENQEYEPLANE: 4091 case GST_TEXTUREENVCOLOR: 4092 case GST_VERTEXENVPARAMETER: 4093 case GST_VERTEXLOCALPARAMETER: 4094 case GST_PIXELSHADERCONSTANT1: 4095 case GST_VERTEXSHADERCONSTANT1: 4096 case GST_PIXELSHADERCONSTANTF: 4097 case GST_VERTEXSHADERCONSTANTF: 4098 case GST_BORDERCOLOR: 4099 return OGRE_NEW CgFloat4GlobalStateListener(type); 4100 case GST_PIXELSHADERCONSTANT2: 4101 case GST_VERTEXSHADERCONSTANT2: 4102 return OGRE_NEW CgFloat4x2GlobalStateListener(type); 4103 case GST_PIXELSHADERCONSTANT3: 4104 case GST_VERTEXSHADERCONSTANT3: 4105 return OGRE_NEW CgFloat4x3GlobalStateListener(type); 4106 case GST_COLORMATRIX: 4107 case GST_COLORTRANSFORM: 4108 case GST_MODELVIEWMATRIX: 4109 case GST_MODELVIEWTRANSFORM: 4110 case GST_VIEWTRANSFORM: 4111 case GST_WORLDTRANSFORM: 4112 case GST_PROJECTIONMATRIX: 4113 case GST_PROJECTIONTRANSFORM: 4114 case GST_TEXTURETRANSFORM: 4115 case GST_TEXTUREMATRIX: 4116 case GST_PIXELSHADERCONSTANT: 4117 case GST_VERTEXSHADERCONSTANT: 4118 case GST_PIXELSHADERCONSTANT4: 4119 case GST_VERTEXSHADERCONSTANT4: 4120 return OGRE_NEW CgFloat4x4GlobalStateListener(type); 4121 case GST_LINESTIPPLE: 4122 case GST_FILLMODE: 4123 return OGRE_NEW CgInt2GlobalStateListener(type); 4124 case GST_SCISSOR: 4125 case GST_PIXELSHADERCONSTANTI: 4126 case GST_VERTEXSHADERCONSTANTI: 4127 return OGRE_NEW CgInt4GlobalStateListener(type); 4128 case GST_SAMPLER: 4129 case GST_TEXTURE1D: 4130 return OGRE_NEW CgSamplerGlobalStateListener(type); 4131 case GST_TEXTURE2D: 4132 return OGRE_NEW CgSampler2GlobalStateListener(type); 4133 case GST_TEXTURE3D: 4134 return OGRE_NEW CgSampler3GlobalStateListener(type); 4135 case GST_TEXTURECUBEMAP: 4136 return OGRE_NEW CgSamplerCubeGlobalStateListener(type); 4137 case GST_TEXTURERECTANGLE: 4138 return OGRE_NEW CgSamplerRectGlobalStateListener(type); 4139 case GST_TEXTURE: 4140 return OGRE_NEW CgTextureGlobalStateListener(type); 4141 case GST_GEOMETRYPROGRAM: 4142 case GST_VERTEXPROGRAM: 4143 case GST_FRAGMENTPROGRAM: 4144 case GST_VERTEXSHADER: 4145 case GST_PIXELSHADER: 4146 return OGRE_NEW CgProgramGlobalStateListener(type); 4147 case GST_BLENDOP: 4148 case GST_CLEARSTENCIL: 4149 case GST_CLIPPLANEENABLE: 4150 case GST_CULLMODE: 4151 case GST_ZFUNC: 4152 case GST_FOGTABLEMODE: 4153 case GST_FOGVERTEXMODE: 4154 case GST_LIGHTTYPE: 4155 case GST_MULTISAMPLEMASK: 4156 case GST_AMBIENTMATERIALSOURCE: 4157 case GST_DIFFUSEMATERIALSOURCE: 4158 case GST_EMISSIVEMATERIALSOURCE: 4159 case GST_SPECULARMATERIALSOURCE: 4160 case GST_VERTEXBLEND: 4161 case GST_DESTBLEND: 4162 case GST_SRCBLEND: 4163 case GST_STENCILMASK: 4164 case GST_STENCILPASS: 4165 case GST_STENCILREF: 4166 case GST_STENCILWRITEMASK: 4167 case GST_STENCILZFAIL: 4168 case GST_TEXTUREFACTOR: 4169 case GST_STENCILFAIL: 4170 case GST_WRAP0: 4171 case GST_WRAP1: 4172 case GST_WRAP2: 4173 case GST_WRAP3: 4174 case GST_WRAP4: 4175 case GST_WRAP5: 4176 case GST_WRAP6: 4177 case GST_WRAP7: 4178 case GST_WRAP8: 4179 case GST_WRAP9: 4180 case GST_WRAP10: 4181 case GST_WRAP11: 4182 case GST_WRAP12: 4183 case GST_WRAP13: 4184 case GST_WRAP14: 4185 case GST_WRAP15: 4186 case GST_ADDRESSU: 4187 case GST_ADDRESSV: 4188 case GST_ADDRESSW: 4189 case GST_MIPMAPLODBIAS: 4190 case GST_BLENDOPALPHA: 4191 case GST_SRCBLENDALPHA: 4192 case GST_DESTBLENDALPHA: 4193 case GST_ALPHAOP: 4194 case GST_COLOROP: 4195 case GST_ALPHAARG0: 4196 case GST_ALPHAARG1: 4197 case GST_ALPHAARG2: 4198 case GST_COLORARG0: 4199 case GST_COLORARG1: 4200 case GST_COLORARG2: 4201 case GST_RESULTARG: 4202 case GST_TEXCOORDINDEX: 4203 case GST_TEXTURETRANSFORMFLAGS: 4204 case GST_MIPFILTER: // todo 4205 return OGRE_NEW CgIntGlobalStateListener(type); 4206 case GST_BLENDEQUATION: 4207 return OGRE_NEW CgBlendEquationGlobalStateListener(); 4208 case GST_DEPTHFUNC: 4209 return OGRE_NEW CgDepthFuncGlobalStateListener(); 4210 case GST_FOGDISTANCEMODE: 4211 return OGRE_NEW CgFogDistanceModeGlobalStateListener(); 4212 case GST_FOGMODE: 4213 return OGRE_NEW CgFogModeGlobalStateListener(); 4214 case GST_LIGHTMODELCOLORCONTROL: 4215 return OGRE_NEW CgLightModelColorControlGlobalStateListener(); 4216 case GST_LOGICOP: 4217 return OGRE_NEW CgLogicOpGlobalStateListener(); 4218 case GST_POINTSPRITECOORDORIGIN: 4219 return OGRE_NEW CgPointSpriteCoordOriginGlobalStateListener(); 4220 case GST_POINTSPRITERMODE: 4221 return OGRE_NEW CgPointSpriteRModeGlobalStateListener(); 4222 case GST_SHADEMODEL: 4223 case GST_SHADEMODE: 4224 return OGRE_NEW CgShadeModelGlobalStateListener(); 4225 case GST_TEXGENSMODE: 4226 case GST_TEXGENTMODE: 4227 case GST_TEXGENRMODE: 4228 case GST_TEXGENQMODE: 4229 return OGRE_NEW CgTexGenModeGlobalStateListener(type); 4230 case GST_TEXTUREENVMODE: 4231 return OGRE_NEW CgTextureEnvModeGlobalStateListener(); 4232 case GST_MINFILTER: 4233 return OGRE_NEW CgMinFilterGlobalStateListener(); 4234 case GST_MAGFILTER: 4235 return OGRE_NEW CgMagFilterGlobalStateListener(); 4236 case GST_FRONTFACE: 4237 return OGRE_NEW CgFrontFaceGlobalStateListener(); 4238 case GST_CULLFACE: 4239 return OGRE_NEW CgCullFaceGlobalStateListener(); 4240 case GST_FOGCOORDSRC: 4241 return OGRE_NEW CgFogCoordSrcGlobalStateListener(); 4242 case GST_ALPHAFUNC: 4243 return OGRE_NEW CgAlphaFuncGlobalStateListener(); 4244 case GST_BLENDFUNC: 4245 return OGRE_NEW CgBlendFuncGlobalStateListener(); 4246 case GST_BLENDFUNCSEPARATE: 4247 return OGRE_NEW CgBlendFuncSeparateGlobalStateListener(); 4248 case GST_BLENDEQUATIONSEPARATE: 4249 return OGRE_NEW CgBlendEquationSeparateGlobalStateListener(); 4250 case GST_COLORMATERIAL: 4251 return OGRE_NEW CgColorMaterialGlobalStateListener(); 4252 case GST_POLYGONMODE: 4253 return OGRE_NEW CgPolygonModeGlobalStateListener(); 4254 case GST_STENCILFUNC: 4255 return OGRE_NEW CgStencilFuncGlobalStateListener(); 4256 case GST_STENCILOP: 4257 return OGRE_NEW CgStencilOpGlobalStateListener(); 4258 case GST_STENCILFUNCSEPARATE: 4259 return OGRE_NEW CgStencilFuncSeparateGlobalStateListener(); 4260 case GST_STENCILMASKSEPARATE: 4261 return OGRE_NEW CgStencilMaskSeparateGlobalStateListener(); 4262 case GST_STENCILOPSEPARATE: 4263 return OGRE_NEW CgStencilOpSeparateGlobalStateListener(); 4264 default: 4265 // TODO - this is an error.... 4266 return OGRE_NEW CgGlobalStateListener(type, CG_STRING); 4267 } 4268 } 4269 //--------------------------------------------------------------------- parsePassStateAssignments(CGpass cgPass,Pass * ogrePass)4270 void CgFxScriptLoader::parsePassStateAssignments( CGpass cgPass, Pass * ogrePass ) 4271 { 4272 CGstateassignment cgStateAssignment = cgGetFirstStateAssignment(cgPass); 4273 while (cgStateAssignment) 4274 { 4275 CGstate cgState = cgGetStateAssignmentState(cgStateAssignment); 4276 CgGlobalStateToListenerMap::iterator stateIter = mCgGlobalStateToListenerMap.find(cgState); 4277 if (stateIter != mCgGlobalStateToListenerMap.end()) 4278 { 4279 stateIter->second->updatePass(ogrePass, cgStateAssignment); 4280 } 4281 4282 cgStateAssignment = cgGetNextStateAssignment(cgStateAssignment); 4283 } 4284 } 4285 //--------------------------------------------------------------------- parseTextureUnitState(CGstateassignment cgStateAssignment,TextureUnitState * ogreTextureUnitState)4286 void CgFxScriptLoader::parseTextureUnitState( CGstateassignment cgStateAssignment, TextureUnitState * ogreTextureUnitState ) 4287 { 4288 CGstate cgState = cgGetSamplerStateAssignmentState(cgStateAssignment); 4289 4290 checkForCgError("CgFxScriptLoader::parseTextureUnitState", 4291 "Unable to Get State Assignment State: ", mCgContext); 4292 4293 CgSamplerStateToListenerMap::iterator samplerStateIter = mCgSamplerStateToListenerMap.find(cgState); 4294 if (samplerStateIter != mCgSamplerStateToListenerMap.end()) 4295 { 4296 samplerStateIter->second->upateTextureUnitState(ogreTextureUnitState, cgStateAssignment); 4297 } 4298 } 4299 parseSamplerParameters(CGpass cgPass,Pass * ogrePass)4300 void CgFxScriptLoader::parseSamplerParameters(CGpass cgPass, Pass * ogrePass) 4301 { 4302 CGeffect cgEffect = cgGetTechniqueEffect(cgGetPassTechnique(cgPass)); 4303 CGparameter cgParameter = cgGetFirstEffectParameter(cgEffect); 4304 while (cgParameter) 4305 { 4306 if (cgGetParameterClass(cgParameter) == CG_PARAMETERCLASS_SAMPLER) 4307 { 4308 CGstateassignment cgStateAssignment = cgGetFirstSamplerStateAssignment(cgParameter); 4309 4310 if (cgStateAssignment) 4311 { 4312 TextureUnitState * ogreTextureUnitState = ogrePass->createTextureUnitState(); 4313 4314 while(cgStateAssignment) 4315 { 4316 if(cgIsStateAssignment(cgStateAssignment)) 4317 { 4318 parseTextureUnitState(cgStateAssignment, ogreTextureUnitState); 4319 } 4320 4321 cgStateAssignment = cgGetNextStateAssignment(cgStateAssignment); 4322 } 4323 4324 } 4325 } 4326 4327 cgParameter = cgGetNextParameter(cgParameter); 4328 } 4329 4330 } 4331 } 4332