void TexGenChunk::deactivate(DrawEnv *pEnv, UInt32 idx) { glErr("TexGenChunk::deactivate precheck"); #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY) Window *win = pEnv->getWindow(); Real32 ntexcoords; if((ntexcoords = win->getConstantValue(GL_MAX_TEXTURE_COORDS_ARB)) == Window::unknownConstant ) { ntexcoords = win->getConstantValue(GL_MAX_TEXTURE_UNITS_ARB); // sgi doesn't support GL_MAX_TEXTURE_UNITS_ARB! if(ntexcoords == Window::unknownConstant) ntexcoords = 1.0f; } if(idx >= static_cast<UInt32>(ntexcoords)) { #ifdef OSG_DEBUG FWARNING(("TexGenChunk::deactivate: Trying to bind texcoord unit %d," " but Window %p only supports %lf!\n", idx, static_cast<void *>(win), ntexcoords)); #endif return; } TextureBaseChunk::activateTexture(win, idx); if(getGenFuncS() != GL_NONE || getSBeacon() != NULL) glDisable(GL_TEXTURE_GEN_S); if(getGenFuncT() != GL_NONE || getTBeacon() != NULL) glDisable(GL_TEXTURE_GEN_T); if(getGenFuncR() != GL_NONE || getRBeacon() != NULL) glDisable(GL_TEXTURE_GEN_R); if(getGenFuncQ() != GL_NONE || getQBeacon() != NULL) glDisable(GL_TEXTURE_GEN_Q); #else OSG_ASSERT(false); #endif glErr("TexGenChunk::deactivate"); }
bool TexGenChunk::operator == (const StateChunk &other) const { TexGenChunk const *tother = dynamic_cast<TexGenChunk const*>(&other); if(!tother) return false; if(tother == this) return true; return getGenFuncS() == tother->getGenFuncS() && getGenFuncT() == tother->getGenFuncT() && getGenFuncR() == tother->getGenFuncR() && getGenFuncQ() == tother->getGenFuncQ() && // not quite right. needs only to be tested for genfuncs using them getGenFuncSPlane() == tother->getGenFuncSPlane() && getGenFuncTPlane() == tother->getGenFuncTPlane() && getGenFuncRPlane() == tother->getGenFuncRPlane() && getGenFuncQPlane() == tother->getGenFuncQPlane() ; }
void TexGenChunk::changeFrom(DrawEnv *pEnv, StateChunk *old , UInt32 idx) { #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY) // change from me to me? // this assumes I haven't changed in the meantime. // is that a valid assumption? // No, for TexGen it's not, as TexGen depends on the current // toWorld matrix!!! // if(old == this) // return; TexGenChunk *oldp = dynamic_cast<TexGenChunk *>(old); // If the old one is not a texgen chunk, deactivate it and activate // ourselves if(!oldp) { old->deactivate(pEnv, idx); activate(pEnv, idx); return; } glErr("TexGenChunk::changeFrom precheck"); pEnv->incNumChunkChanges(); Window *win = pEnv->getWindow(); Real32 ntexcoords; if((ntexcoords = win->getConstantValue(GL_MAX_TEXTURE_COORDS_ARB)) == Window::unknownConstant ) { ntexcoords = win->getConstantValue(GL_MAX_TEXTURE_UNITS_ARB); // sgi doesn't support GL_MAX_TEXTURE_UNITS_ARB! if(ntexcoords == Window::unknownConstant) ntexcoords = 1.0f; } if(idx >= static_cast<UInt32>(ntexcoords)) { #ifdef OSG_DEBUG FWARNING(("TexGenChunk::changeFrom: Trying to bind texcoord unit " "%d, but Window %p only supports %lf!\n", idx, win, ntexcoords)); #endif return; } Matrix cameraMat = pEnv->getCameraViewing(); #ifdef OLD_DA Viewport *vp = pEnv->getViewport(); if(vp != NULL) { pEnv->getCamera()->getViewing(cameraMat, vp->getPixelWidth(), vp->getPixelHeight()); } #endif TextureBaseChunk::activateTexture(win, idx); changeGenFunc(oldp->getGenFuncS(), oldp->getSBeacon(), GL_S, GL_TEXTURE_GEN_S, getGenFuncS(), getGenFuncSPlane(), getSBeacon(), cameraMat, _sfEyeModelViewMode.getValue(), _sfEyeModelViewMatrix.getValue()); changeGenFunc(oldp->getGenFuncT(), oldp->getTBeacon(), GL_T, GL_TEXTURE_GEN_T, getGenFuncT(), getGenFuncTPlane(), getTBeacon(), cameraMat, _sfEyeModelViewMode.getValue(), _sfEyeModelViewMatrix.getValue()); changeGenFunc(oldp->getGenFuncR(), oldp->getRBeacon(), GL_R, GL_TEXTURE_GEN_R, getGenFuncR(), getGenFuncRPlane(), getRBeacon(), cameraMat, _sfEyeModelViewMode.getValue(), _sfEyeModelViewMatrix.getValue()); changeGenFunc(oldp->getGenFuncQ(), oldp->getQBeacon(), GL_Q, GL_TEXTURE_GEN_Q, getGenFuncQ(), getGenFuncQPlane(), getQBeacon(), cameraMat, _sfEyeModelViewMode.getValue(), _sfEyeModelViewMatrix.getValue()); #else OSG_ASSERT(false); #endif glErr("TexGenChunk::changeFrom"); }
void TexGenChunk::activate(DrawEnv *pEnv, UInt32 idx) { glErr("TexGenChunk::activate precheck"); #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY) pEnv->incNumChunkChanges(); Window *win = pEnv->getWindow(); Real32 ntexcoords; if((ntexcoords = win->getConstantValue(GL_MAX_TEXTURE_COORDS_ARB)) == Window::unknownConstant ) { ntexcoords = win->getConstantValue(GL_MAX_TEXTURE_UNITS_ARB); // sgi doesn't support GL_MAX_TEXTURE_UNITS_ARB! if(ntexcoords == Window::unknownConstant) ntexcoords = 1.0f; } if(idx >= static_cast<UInt32>(ntexcoords)) { #ifdef OSG_DEBUG FWARNING(("TexGenChunk::activate: Trying to bind texcoord unit %d," " but Window %p only supports %lf!\n", idx, win, ntexcoords)); #endif return; } TextureBaseChunk::activateTexture(win, idx); FDEBUG(("TexGenChunk::activate\n")); Matrix cameraMat = pEnv->getCameraViewing(); #if OLD_DA Viewport *vp = pEnv->getViewport(); if(vp != NULL) { pEnv->getCamera()->getViewing(cameraMat, vp->getPixelWidth(), vp->getPixelHeight()); } #endif // genfuncs setGenFunc(GL_S, GL_TEXTURE_GEN_S, getGenFuncS(), getGenFuncSPlane(), getSBeacon(), cameraMat, _sfEyeModelViewMode.getValue(), _sfEyeModelViewMatrix.getValue()); glErr("TexGenChunk::activateS"); setGenFunc(GL_T, GL_TEXTURE_GEN_T, getGenFuncT(), getGenFuncTPlane(), getTBeacon(), cameraMat, _sfEyeModelViewMode.getValue(), _sfEyeModelViewMatrix.getValue()); glErr("TexGenChunk::activateT"); setGenFunc(GL_R, GL_TEXTURE_GEN_R, getGenFuncR(), getGenFuncRPlane(), getRBeacon(), cameraMat, _sfEyeModelViewMode.getValue(), _sfEyeModelViewMatrix.getValue()); glErr("TexGenChunk::activateR"); setGenFunc(GL_Q, GL_TEXTURE_GEN_Q, getGenFuncQ(), getGenFuncQPlane(), getQBeacon(), cameraMat, _sfEyeModelViewMode.getValue(), _sfEyeModelViewMatrix.getValue()); #else OSG_ASSERT(false); #endif glErr("TexGenChunk::activateQ"); }