Exemplo n.º 1
0
bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind)
{
	stop_glerror();
	if (mIndex < 0) return false;

	gGL.flush();

	if (texture == NULL)
	{
		llwarns << "NULL LLTexUnit::bind texture" << llendl;
		return false;
	}
	
	if (!texture->getTexName()) //if texture does not exist
	{
		//if deleted, will re-generate it immediately
		texture->forceImmediateUpdate() ;

		return texture->bindDefaultImage(mIndex);
	}

#if !LL_RELEASE_FOR_DOWNLOAD
	if(for_rendering)
	{
		int w = texture->getWidth(texture->getDiscardLevel()) ;
		int h = texture->getHeight(texture->getDiscardLevel()) ;

		if(w * h == LLImageGL::sCurTexPickSize)
		{
			texture->updateBindStats();
			return bind(LLImageGL::sDefaultTexturep.get());
		}
	}
#endif

	if ((mCurrTexture != texture->getTexName()) || forceBind)
	{
		activate();
		enable(texture->getTarget());
		mCurrTexture = texture->getTexName();
		glBindTexture(sGLTextureType[texture->getTarget()], mCurrTexture);
		texture->updateBindStats();
		texture->setActive() ;
		mHasMipMaps = texture->mHasMipMaps;
		if (texture->mTexOptionsDirty)
		{
			texture->mTexOptionsDirty = false;
			setTextureAddressMode(texture->mAddressMode);
			setTextureFilteringOption(texture->mFilterOption);
		}
	}
	return true;
}
Exemplo n.º 2
0
bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind)
{
	stop_glerror();
	if (mIndex < 0) return false;

	gGL.flush();

	LLImageGL* gl_tex = NULL ;
	if (texture == NULL || !(gl_tex = texture->getGLTexture()))
	{
		llwarns << "NULL LLTexUnit::bind texture" << llendl;
		return false;
	}

	if (!gl_tex->getTexName()) //if texture does not exist
	{
		//if deleted, will re-generate it immediately
		texture->forceImmediateUpdate() ;

		gl_tex->forceUpdateBindStats() ;
		return texture->bindDefaultImage(mIndex);
	}

	//in audit, replace the selected texture by the default one.
	if(gAuditTexture && for_rendering && LLImageGL::sCurTexPickSize > 0)
	{
		if(texture->getWidth() * texture->getHeight() == LLImageGL::sCurTexPickSize)
		{
			gl_tex->updateBindStats(gl_tex->mTextureMemory);
			return bind(LLImageGL::sHighlightTexturep.get());
		}
	}
	if ((mCurrTexture != gl_tex->getTexName()) || forceBind)
	{
		activate();
		enable(gl_tex->getTarget());
		mCurrTexture = gl_tex->getTexName();
		glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture);
		if(gl_tex->updateBindStats(gl_tex->mTextureMemory))
		{
			texture->setActive() ;
			texture->updateBindStatsForTester() ;
		}
		mHasMipMaps = gl_tex->mHasMipMaps;
		if (gl_tex->mTexOptionsDirty)
		{
			gl_tex->mTexOptionsDirty = false;
			setTextureAddressMode(gl_tex->mAddressMode);
			setTextureFilteringOption(gl_tex->mFilterOption);
		}
	}
	return true;
}
Exemplo n.º 3
0
bool LLTexUnit::bind(LLCubeMap* cubeMap)
{
	if (mIndex < 0) return false;

	gGL.flush();

	if (cubeMap == NULL)
	{
		llwarns << "NULL LLTexUnit::bind cubemap" << llendl;
		return false;
	}

	if (cubeMap->mImages[0].isNull())
	{
		llwarns << "NULL LLTexUnit::bind cubeMap->mImages[0]" << llendl;
		return false;
	}
	if (mCurrTexture != cubeMap->mImages[0]->getTexName())
	{
		if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps)
		{
			activate();
			enable(LLTexUnit::TT_CUBE_MAP);
			mCurrTexture = cubeMap->mImages[0]->getTexName();
			glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCurrTexture);
			mHasMipMaps = cubeMap->mImages[0]->mHasMipMaps;
			cubeMap->mImages[0]->updateBindStats(cubeMap->mImages[0]->mTextureMemory);
			if (cubeMap->mImages[0]->mTexOptionsDirty)
			{
				cubeMap->mImages[0]->mTexOptionsDirty = false;
				setTextureAddressMode(cubeMap->mImages[0]->mAddressMode);
				setTextureFilteringOption(cubeMap->mImages[0]->mFilterOption);
			}
			return true;
		}
		else
		{
			llwarns << "Using cube map without extension!" << llendl;
			return false;
		}
	}
	return true;
}
Exemplo n.º 4
0
bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind)
{
	stop_glerror();
	if (mIndex < 0) return false;

	if(!texture)
	{
		llwarns << "NULL LLTexUnit::bind texture" << llendl;
		return false;
	}

	if(!texture->getTexName())
	{
		if(LLImageGL::sDefaultGLTexture && LLImageGL::sDefaultGLTexture->getTexName())
		{
			return bind(LLImageGL::sDefaultGLTexture) ;
		}
		return false ;
	}

	if ((mCurrTexture != texture->getTexName()) || forceBind)
	{
		gGL.flush();
		activate();
		enable(texture->getTarget());
		mCurrTexture = texture->getTexName();
		glBindTexture(sGLTextureType[texture->getTarget()], mCurrTexture);
		texture->updateBindStats(texture->mTextureMemory);		
		mHasMipMaps = texture->mHasMipMaps;
		if (texture->mTexOptionsDirty)
		{
			texture->mTexOptionsDirty = false;
			setTextureAddressMode(texture->mAddressMode);
			setTextureFilteringOption(texture->mFilterOption);
		}
	}

	return true;
}