コード例 #1
0
void SimpleTexturedMaterial::changed(BitVector whichField, UInt32 origin)
{
    prepareLocalChunks();

    // these two are very expensive, as they need to regenerate the
    // texture object, do only if really needed

    if(whichField & ImageFieldMask)
    {
        beginEditCP(_textureChunk, TextureChunk::ImageFieldMask);

        _textureChunk->setImage(getImage());

        endEditCP(_textureChunk, TextureChunk::ImageFieldMask);
    }
    if(whichField & MinFilterFieldMask || whichField & MagFilterFieldMask)
    {
        beginEditCP(_textureChunk, TextureChunk::MinFilterFieldMask |
                                   TextureChunk::MagFilterFieldMask);

        _textureChunk->setMinFilter(getMinFilter());
        _textureChunk->setMagFilter(getMagFilter());

        endEditCP(_textureChunk, TextureChunk::MinFilterFieldMask |
                                 TextureChunk::MagFilterFieldMask);
    }
    // this is not as expensive, but why do it more often then needed?
    if(whichField & EnvModeFieldMask)
    {
        beginEditCP(_textureChunk, TextureChunk::EnvModeFieldMask);

        _textureChunk->setEnvMode(getEnvMode());

        endEditCP(_textureChunk, TextureChunk::EnvModeFieldMask);
    }
    if(whichField & EnvMapFieldMask)
    {
        beginEditCP(_texGenChunk, TexGenChunk::GenFuncSFieldMask |
                                  TexGenChunk::GenFuncTFieldMask);
        
        if (getEnvMap())
        {
            _texGenChunk->setGenFuncS(GL_SPHERE_MAP);
            _texGenChunk->setGenFuncT(GL_SPHERE_MAP);
        }
        else
        {
            _texGenChunk->setGenFuncS(GL_NONE);
            _texGenChunk->setGenFuncT(GL_NONE);
        }

        endEditCP(_texGenChunk, TexGenChunk::GenFuncSFieldMask |
                                TexGenChunk::GenFuncTFieldMask);
    }

    Inherited::changed(whichField, origin);
}
コード例 #2
0
ファイル: GLTextureStage.cpp プロジェクト: arx/ArxLibertatis
void GLTextureStage::apply() {
	
	if(!tex && !current) {
		return;
	}
	
	if(mStage != 0) {
		glActiveTexture(GL_TEXTURE0 + mStage);
	}
	
	if(tex != current) {
		glBindTexture(GL_TEXTURE_2D, tex ? tex->tex : GL_NONE), current = tex;
	}
	
	if(tex) {
		
		bool apply = true;
		for(size_t i = 0; i < mStage; i++) {
			GLTextureStage * stage = renderer->GetTextureStage(i);
			if(stage->tex == tex && stage->isEnabled()) {
				apply = false;
				#ifdef ARX_DEBUG
				if(stage->getWrapMode() != getWrapMode()
				   || stage->getMinFilter() != getMinFilter() || stage->getMagFilter() != getMagFilter()) {
					static bool warned = false;
					if(!warned) {
						LogWarning << "Same texture used in multiple stages with different attributes.";
						warned = true;
					}
				}
				#else
				break;
				#endif
			}
		}
		
		if(apply) {
			tex->apply(this);
		}
		
	}

	if(mStage != 0) {
		glActiveTexture(GL_TEXTURE0);
	}
}
コード例 #3
0
void SimpleTexturedMaterial::changed(ConstFieldMaskArg whichField, 
                                     UInt32            origin,
                                     BitVector         detail)
{
    prepareLocalChunks();

    // these two are very expensive, as they need to regenerate the
    // texture object, do only if really needed

    if(whichField & ImageFieldMask)
    {
        _textureChunk->setImage(getImage());
    }
    if(whichField & MinFilterFieldMask || whichField & MagFilterFieldMask)
    {
        _textureChunk->setMinFilter(getMinFilter());
        _textureChunk->setMagFilter(getMagFilter());
    }
    // this is not as expensive, but why do it more often then needed?
    if(whichField & EnvModeFieldMask)
    {
        _texEnvChunk->setEnvMode(getEnvMode());
    }
    if(whichField & EnvMapFieldMask)
    {
        if (getEnvMap())
        {
#ifndef OSG_EMBEDDED
            _texGenChunk->setGenFuncS(GL_SPHERE_MAP);
            _texGenChunk->setGenFuncT(GL_SPHERE_MAP);
#endif
        }
        else
        {
            _texGenChunk->setGenFuncS(GL_NONE);
            _texGenChunk->setGenFuncT(GL_NONE);
        }
    }

    Inherited::changed(whichField, origin, detail);
}