00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include <OSGConfig.h>
00047
00048 #include <OSGGL.h>
00049 #include <OSGGLU.h>
00050 #include <OSGGLEXT.h>
00051
00052 #include "OSGDrawActionBase.h"
00053
00054 #include "OSGCubeTextureChunk.h"
00055
00056 OSG_USING_NAMESPACE
00057
00058
00059
00060
00061
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 CubeTextureChunk::CubeTextureChunk(void) :
00088 Inherited()
00089 {
00090 }
00091
00092 CubeTextureChunk::CubeTextureChunk(const CubeTextureChunk &source) :
00093 Inherited(source)
00094 {
00095 }
00096
00097 CubeTextureChunk::~CubeTextureChunk(void)
00098 {
00099 if(_sfPosZImage.getValue() != NullFC)
00100 subRefCP(_sfPosZImage.getValue());
00101
00102 if(_sfPosXImage.getValue() != NullFC)
00103 subRefCP(_sfPosXImage.getValue());
00104 if(_sfNegXImage.getValue() != NullFC)
00105 subRefCP(_sfNegXImage.getValue());
00106
00107 if(_sfPosYImage.getValue() != NullFC)
00108 subRefCP(_sfPosYImage.getValue());
00109 if(_sfNegYImage.getValue() != NullFC)
00110 subRefCP(_sfNegYImage.getValue());
00111 }
00112
00113
00114
00115 const StateChunkClass *CubeTextureChunk::getClass(void) const
00116 {
00117 return TextureChunk::getClass();
00118 }
00119
00120
00121
00122 void CubeTextureChunk::changed(BitVector whichField, UInt32 origin)
00123 {
00124 if(whichField & PosZImageFieldMask)
00125 {
00126 if(origin & ChangedOrigin::Abstract)
00127 {
00128 if(origin & ChangedOrigin::AbstrIncRefCount)
00129 {
00130 addRefCP(_sfPosZImage.getValue());
00131 }
00132 else
00133 {
00134 ImagePtr pImage = _sfPosZImage.getValue();
00135
00136 _sfPosZImage.setValue(NullFC);
00137
00138 setPosZImage(pImage);
00139 }
00140 }
00141 }
00142
00143 if(whichField & PosXImageFieldMask)
00144 {
00145 if(origin & ChangedOrigin::Abstract)
00146 {
00147 if(origin & ChangedOrigin::AbstrIncRefCount)
00148 {
00149 addRefCP(_sfPosXImage.getValue());
00150 }
00151 else
00152 {
00153 ImagePtr pImage = _sfPosXImage.getValue();
00154
00155 _sfPosXImage.setValue(NullFC);
00156
00157 setPosXImage(pImage);
00158 }
00159 }
00160 }
00161
00162 if(whichField & NegXImageFieldMask)
00163 {
00164 if(origin & ChangedOrigin::Abstract)
00165 {
00166 if(origin & ChangedOrigin::AbstrIncRefCount)
00167 {
00168 addRefCP(_sfNegXImage.getValue());
00169 }
00170 else
00171 {
00172 ImagePtr pImage = _sfNegXImage.getValue();
00173
00174 _sfNegXImage.setValue(NullFC);
00175
00176 setNegXImage(pImage);
00177 }
00178 }
00179 }
00180
00181 if(whichField & PosYImageFieldMask)
00182 {
00183 if(origin & ChangedOrigin::Abstract)
00184 {
00185 if(origin & ChangedOrigin::AbstrIncRefCount)
00186 {
00187 addRefCP(_sfPosYImage.getValue());
00188 }
00189 else
00190 {
00191 ImagePtr pImage = _sfPosYImage.getValue();
00192
00193 _sfPosYImage.setValue(NullFC);
00194
00195 setPosYImage(pImage);
00196 }
00197 }
00198 }
00199
00200 if(whichField & NegYImageFieldMask)
00201 {
00202 if(origin & ChangedOrigin::Abstract)
00203 {
00204 if(origin & ChangedOrigin::AbstrIncRefCount)
00205 {
00206 addRefCP(_sfNegYImage.getValue());
00207 }
00208 else
00209 {
00210 ImagePtr pImage = _sfNegYImage.getValue();
00211
00212 _sfNegYImage.setValue(NullFC);
00213
00214 setNegYImage(pImage);
00215 }
00216 }
00217 }
00218 Inherited::changed(whichField, origin);
00219 }
00220
00221
00222
00223 void CubeTextureChunk::onCreate(const CubeTextureChunk *)
00224 {
00225 if(GlobalSystemState == Startup)
00226 return;
00227
00228
00229
00230
00231 CubeTextureChunkPtr tmpPtr(*this);
00232
00233 beginEditCP(tmpPtr, CubeTextureChunk::GLIdFieldMask);
00234
00235 setGLId(
00236 Window::registerGLObject(
00237 osgTypedMethodVoidFunctor2ObjCPtrPtr<CubeTextureChunkPtr,
00238 Window ,
00239 UInt32>(
00240 tmpPtr,
00241 &CubeTextureChunk::handleGL),
00242 1));
00243
00244 endEditCP(tmpPtr, CubeTextureChunk::GLIdFieldMask);
00245 }
00246
00247
00248
00249 void CubeTextureChunk::dump( UInt32 ,
00250 const BitVector ) const
00251 {
00252 SLOG << "Dump CubeTextureChunk NI" << std::endl;
00253 }
00254
00255
00256
00257
00258 void CubeTextureChunk::handleGL(Window *win, UInt32 idstatus)
00259 {
00260 Window::GLObjectStatusE mode;
00261 UInt32 id;
00262
00263
00264 if(win->hasExtension(_arbCubeTex) == false)
00265 return;
00266
00267 Window::unpackIdStatus(idstatus, id, mode);
00268
00269 if(mode == Window::destroy)
00270 {
00271 GLuint tex = id;
00272 glDeleteTextures(1, &tex);
00273 }
00274 else if(mode == Window::finaldestroy)
00275 {
00276
00277 }
00278 else if(mode == Window::initialize || mode == Window::reinitialize)
00279 {
00280 handleTexture(win, id,
00281 GL_TEXTURE_CUBE_MAP_ARB,
00282 GL_TEXTURE_CUBE_MAP_ARB,
00283 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
00284 mode, getImage());
00285 handleTexture(win, id,
00286 GL_TEXTURE_CUBE_MAP_ARB,
00287 GL_NONE,
00288 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
00289 Window::initialize, getPosZImage());
00290 handleTexture(win, id,
00291 GL_TEXTURE_CUBE_MAP_ARB,
00292 GL_NONE,
00293 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
00294 Window::initialize, getNegYImage());
00295 handleTexture(win, id,
00296 GL_TEXTURE_CUBE_MAP_ARB,
00297 GL_NONE,
00298 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
00299 Window::initialize, getPosYImage());
00300 handleTexture(win, id,
00301 GL_TEXTURE_CUBE_MAP_ARB,
00302 GL_NONE,
00303 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
00304 Window::initialize, getNegXImage());
00305 handleTexture(win, id,
00306 GL_TEXTURE_CUBE_MAP_ARB,
00307 GL_NONE,
00308 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
00309 Window::initialize, getPosXImage());
00310 }
00311 else if(mode == Window::needrefresh)
00312 {
00313 handleTexture(win, id,
00314 GL_TEXTURE_CUBE_MAP_ARB,
00315 GL_TEXTURE_CUBE_MAP_ARB,
00316 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
00317 mode, getImage());
00318 handleTexture(win, id,
00319 GL_TEXTURE_CUBE_MAP_ARB,
00320 GL_NONE,
00321 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
00322 mode, getPosZImage());
00323 handleTexture(win, id,
00324 GL_TEXTURE_CUBE_MAP_ARB,
00325 GL_NONE,
00326 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
00327 mode, getNegYImage());
00328 handleTexture(win, id,
00329 GL_TEXTURE_CUBE_MAP_ARB,
00330 GL_NONE,
00331 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
00332 mode, getPosYImage());
00333 handleTexture(win, id,
00334 GL_TEXTURE_CUBE_MAP_ARB,
00335 GL_NONE,
00336 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
00337 mode, getNegXImage());
00338 handleTexture(win, id,
00339 GL_TEXTURE_CUBE_MAP_ARB,
00340 GL_NONE,
00341 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
00342 mode, getPosXImage());
00343 }
00344 else
00345 {
00346 SWARNING << "Win:" << win << "TextureChunk(" << this
00347 << "::handleGL: Illegal mode: "
00348 << mode << " for id " << id << std::endl;
00349 }
00350 }
00351
00352
00353
00354
00355 void CubeTextureChunk::activate( DrawActionBase *action, UInt32 idx )
00356 {
00357
00358 if(action->getWindow()->hasExtension(_arbCubeTex) == false)
00359 return;
00360
00361 Window *win = action->getWindow();
00362
00363 Real32 nteximages, ntexcoords;
00364 if((nteximages = win->getConstantValue(GL_MAX_TEXTURE_IMAGE_UNITS_ARB)) ==
00365 Window::unknownConstant
00366 )
00367 {
00368 nteximages = win->getConstantValue(GL_MAX_TEXTURE_UNITS_ARB);
00369
00370 if(nteximages == Window::unknownConstant)
00371 nteximages = 1.0f;
00372 }
00373 if((ntexcoords = win->getConstantValue(GL_MAX_TEXTURE_COORDS_ARB)) ==
00374 Window::unknownConstant
00375 )
00376 {
00377 ntexcoords = win->getConstantValue(GL_MAX_TEXTURE_UNITS_ARB);
00378
00379 if(ntexcoords == Window::unknownConstant)
00380 ntexcoords = 1.0f;
00381 }
00382
00383 if(idx >= static_cast<UInt32>(nteximages))
00384 {
00385 #ifdef OSG_DEBUG
00386 FWARNING(("CubeTextureChunk::activate: Trying to bind image unit %d,"
00387 " but Window %p only supports %d!\n",
00388 idx, win, nteximages));
00389 #endif
00390 return;
00391 }
00392
00393 TextureChunk::activateTexture(win, idx);
00394
00395 win->validateGLObject(getGLId());
00396
00397 glErr("CubeTextureChunk::activate precheck");
00398
00399 FDEBUG(("CubeTextureChunk::activate - %d\n", getGLId()));
00400
00401 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, getGLId());
00402
00403 #ifdef GL_NV_point_sprite
00404 if(idx < static_cast<UInt32>(ntexcoords))
00405 {
00406 if(getPointSprite() &&
00407 win->hasExtension(_nvPointSprite))
00408 {
00409 glTexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV, GL_TRUE);
00410 }
00411 }
00412 #endif
00413
00414 if(idx < static_cast<UInt32>(nteximages))
00415 {
00416 if(getLodBias() != 0.0f &&
00417 win->hasExtension(_extTextureLodBias))
00418 {
00419 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT,
00420 getLodBias());
00421 }
00422 }
00423
00424 Real32 ntexunits = win->getConstantValue(GL_MAX_TEXTURE_UNITS_ARB);
00425
00426
00427 if(ntexunits == Window::unknownConstant)
00428 ntexunits = 1.0f;
00429
00430 if(idx < static_cast<UInt32>(ntexunits))
00431 {
00432
00433 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, getEnvMode());
00434 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR,
00435 (GLfloat*)getEnvColor().getValuesRGBA());
00436
00437 if(getEnvMode() == GL_COMBINE_EXT)
00438 {
00439 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, getEnvCombineRGB ());
00440 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, getEnvScaleRGB ());
00441 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, getEnvSource0RGB ());
00442 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, getEnvSource1RGB ());
00443 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, getEnvSource2RGB ());
00444 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, getEnvOperand0RGB());
00445 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, getEnvOperand1RGB());
00446 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, getEnvOperand2RGB());
00447
00448 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, getEnvCombineAlpha ());
00449 glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, getEnvScaleAlpha ());
00450 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, getEnvSource0Alpha ());
00451 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, getEnvSource1Alpha ());
00452 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, getEnvSource2Alpha ());
00453 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT,getEnvOperand0Alpha());
00454 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT,getEnvOperand1Alpha());
00455 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT,getEnvOperand2Alpha());
00456 }
00457
00458 TextureChunk::handleTextureShader(win, GL_TEXTURE_CUBE_MAP_ARB);
00459
00460 if(getShaderOperation() != GL_NONE &&
00461 win->hasExtension(_nvTextureShader) &&
00462 idx == 0)
00463 {
00464 glEnable(GL_TEXTURE_SHADER_NV);
00465 }
00466 glEnable(GL_TEXTURE_CUBE_MAP_ARB);
00467 }
00468
00469 glErr("CubeTextureChunk::activate");
00470 }
00471
00472 void CubeTextureChunk::changeFrom( DrawActionBase *action,
00473 StateChunk *old ,
00474 UInt32 idx )
00475 {
00476
00477 if(action->getWindow()->hasExtension(_arbCubeTex) == false)
00478 return;
00479
00480
00481
00482
00483 if(old == this)
00484 return;
00485
00486
00487
00488 if(getTypeId() != old->getTypeId())
00489 {
00490 old->deactivate(action, idx);
00491 activate(action, idx);
00492 return;
00493 }
00494
00495 CubeTextureChunk *oldp = dynamic_cast<CubeTextureChunk *>(old);
00496
00497 glErr("CubeTextureChunk::changeFrom precheck");
00498
00499 Window *win = action->getWindow();
00500
00501 if(TextureChunk::activateTexture(win, idx))
00502 return;
00503
00504 UInt32 nteximages, ntexcoords, ntexunits;
00505
00506 Real32 dummy = win->getConstantValue(GL_MAX_TEXTURE_UNITS_ARB);
00507
00508 if(dummy == Window::unknownConstant)
00509 {
00510 ntexunits = 1;
00511 }
00512 else
00513 {
00514 ntexunits = static_cast<UInt32>(dummy);
00515 }
00516
00517 if((dummy = win->getConstantValue(GL_MAX_TEXTURE_IMAGE_UNITS_ARB)) ==
00518 Window::unknownConstant
00519 )
00520 {
00521 nteximages = ntexunits;
00522 }
00523 else
00524 {
00525 nteximages = static_cast<UInt32>(dummy);
00526 }
00527
00528 if((dummy = win->getConstantValue(GL_MAX_TEXTURE_COORDS_ARB)) ==
00529 Window::unknownConstant
00530 )
00531 {
00532 ntexcoords = ntexunits;
00533 }
00534 else
00535 {
00536 ntexcoords = static_cast<UInt32>(dummy);
00537 }
00538
00539 if(idx >= nteximages)
00540 {
00541 #ifdef OSG_DEBUG
00542 FWARNING(("TextureChunk::activate: Trying to bind image unit %d,"
00543 " but Window %p only supports %d!\n",
00544 idx, win, nteximages));
00545 #endif
00546 return;
00547 }
00548
00549 win->validateGLObject(getGLId());
00550
00551 FDEBUG(("CubeTextureChunk::activate - %d\n", getGLId()));
00552
00553 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, getGLId());
00554
00555 #ifdef GL_NV_point_sprite
00556 if(idx < ntexcoords)
00557 {
00558 if(oldp->getPointSprite() != getPointSprite() &&
00559 win->hasExtension(_nvPointSprite)
00560 )
00561 {
00562 glTexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV, getPointSprite());
00563 }
00564 }
00565 #endif
00566
00567 if(idx < nteximages)
00568 {
00569 if(oldp->getLodBias() != getLodBias() &&
00570 win->hasExtension(_extTextureLodBias)
00571 )
00572 {
00573 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT,
00574 getLodBias());
00575 }
00576 }
00577
00578 if(idx < ntexunits)
00579 {
00580 if(oldp->getEnvMode() != getEnvMode())
00581 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, getEnvMode());
00582
00583 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR,
00584 (GLfloat*)getEnvColor().getValuesRGBA());
00585
00586 if(getEnvMode() == GL_COMBINE_EXT)
00587 {
00588 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, getEnvCombineRGB ());
00589 glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, getEnvScaleRGB ());
00590 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, getEnvSource0RGB ());
00591 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, getEnvSource1RGB ());
00592 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, getEnvSource2RGB ());
00593 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, getEnvOperand0RGB());
00594 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, getEnvOperand1RGB());
00595 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, getEnvOperand2RGB());
00596
00597 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, getEnvCombineAlpha ());
00598 glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, getEnvScaleAlpha ());
00599 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, getEnvSource0Alpha ());
00600 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, getEnvSource1Alpha ());
00601 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, getEnvSource2Alpha ());
00602 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT,getEnvOperand0Alpha());
00603 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT,getEnvOperand1Alpha());
00604 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT,getEnvOperand2Alpha());
00605 }
00606
00607 if(win->hasExtension(_nvTextureShader))
00608 {
00609 if( getShaderOperation() != GL_NONE &&
00610 oldp->getShaderOperation() == GL_NONE
00611 )
00612 {
00613 handleTextureShader(win, GL_TEXTURE_CUBE_MAP_ARB);
00614 if(idx == 0)
00615 glEnable(GL_TEXTURE_SHADER_NV);
00616 }
00617 else if( getShaderOperation() == GL_NONE &&
00618 oldp->getShaderOperation() != GL_NONE
00619 )
00620 {
00621 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE);
00622 if(idx == 0)
00623 glDisable(GL_TEXTURE_SHADER_NV);
00624 }
00625 }
00626 }
00627
00628 glErr("CubeTextureChunk::changeFrom");
00629 }
00630
00631 void CubeTextureChunk::deactivate(DrawActionBase *action, UInt32 idx)
00632 {
00633
00634 if(action->getWindow()->hasExtension(_arbCubeTex) == false)
00635 return;
00636
00637 Window *win = action->getWindow();
00638
00639 Real32 nteximages, ntexcoords;
00640 if((nteximages = win->getConstantValue(GL_MAX_TEXTURE_IMAGE_UNITS_ARB)) ==
00641 Window::unknownConstant
00642 )
00643 {
00644 nteximages = win->getConstantValue(GL_MAX_TEXTURE_UNITS_ARB);
00645
00646 if(nteximages == Window::unknownConstant)
00647 nteximages = 1.0f;
00648 }
00649 if((ntexcoords = win->getConstantValue(GL_MAX_TEXTURE_COORDS_ARB)) ==
00650 Window::unknownConstant
00651 )
00652 {
00653 ntexcoords = win->getConstantValue(GL_MAX_TEXTURE_UNITS_ARB);
00654
00655 if(ntexcoords == Window::unknownConstant)
00656 ntexcoords = 1.0f;
00657 }
00658
00659 if(idx >= static_cast<UInt32>(nteximages))
00660 {
00661 #ifdef OSG_DEBUG
00662 FWARNING(("CubeTextureChunk::deactivate: Trying to bind image unit %d,"
00663 " but Window %p only supports %d!\n",
00664 idx, win, nteximages));
00665 #endif
00666 return;
00667 }
00668
00669
00670 bool isActive = false;
00671
00672 #ifdef GL_NV_point_sprite
00673 if(getPointSprite() &&
00674 win->hasExtension(_nvPointSprite) &&
00675 idx < static_cast<UInt32>(ntexcoords)
00676 )
00677 {
00678 if(!isActive)
00679 {
00680 TextureChunk::activateTexture(win, idx);
00681 isActive = true;
00682 }
00683 glTexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV, GL_FALSE);
00684 }
00685 #endif
00686
00687 if(getLodBias() != 0.0f &&
00688 win->hasExtension(_extTextureLodBias))
00689 {
00690 if(!isActive)
00691 TextureChunk::activateTexture(win, idx);
00692 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT,
00693 0.0f);
00694 }
00695
00696 Real32 ntexunits = win->getConstantValue(GL_MAX_TEXTURE_UNITS_ARB);
00697 if(ntexunits == Window::unknownConstant)
00698 ntexunits = 1.0f;
00699
00700 if(idx >= static_cast<UInt32>(ntexunits))
00701 return;
00702
00703 if(!isActive)
00704 TextureChunk::activateTexture(win, idx);
00705
00706 if(getShaderOperation() != GL_NONE &&
00707 win->hasExtension(_nvTextureShader))
00708 {
00709 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE);
00710
00711 if(idx == 0)
00712 glDisable(GL_TEXTURE_SHADER_NV);
00713 }
00714
00715 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
00716
00717 glErr("CubeTextureChunk::deactivate");
00718 }
00719
00720
00721
00722 Real32 CubeTextureChunk::switchCost(StateChunk *OSG_CHECK_ARG(chunk))
00723 {
00724 return 0;
00725 }
00726
00727 bool CubeTextureChunk::operator < (const StateChunk &other) const
00728 {
00729 return this < &other;
00730 }
00731
00732 bool CubeTextureChunk::operator == (const StateChunk &other) const
00733 {
00734 CubeTextureChunk const *tother =
00735 dynamic_cast<CubeTextureChunk const*>(&other);
00736
00737 if(!tother)
00738 return false;
00739
00740 if(tother == this)
00741 return true;
00742
00743 return TextureChunk::operator==(other) &&
00744 getPosZImage() == tother->getPosZImage() &&
00745 getPosYImage() == tother->getPosYImage() &&
00746 getNegYImage() == tother->getNegYImage() &&
00747 getPosXImage() == tother->getPosXImage() &&
00748 getNegXImage() == tother->getNegXImage();
00749 }
00750
00751 bool CubeTextureChunk::operator != (const StateChunk &other) const
00752 {
00753 return ! (*this == other);
00754 }
00755
00756
00757
00758
00759 #ifdef __sgi
00760 #pragma set woff 1174
00761 #endif
00762
00763 #ifdef OSG_LINUX_ICC
00764 #pragma warning( disable : 177 )
00765 #endif
00766
00767 namespace
00768 {
00769 static Char8 cvsid_cpp[] = "@(#)$Id: $";
00770 static Char8 cvsid_hpp[] = OSGCUBETEXTURECHUNK_HEADER_CVSID;
00771 static Char8 cvsid_inl[] = OSGCUBETEXTURECHUNK_INLINE_CVSID;
00772 }