コード例 #1
0
int TexCache::bind( const QModelIndex & iSource )
{
	const NifModel * nif = qobject_cast<const NifModel *>( iSource.model() );
	if ( nif && iSource.isValid() ) {
		if ( nif->get<quint8>( iSource, "Use External" ) == 0 ){
			QModelIndex iData = nif->getBlock( nif->getLink( iSource, "Pixel Data" ) );
			if (iData.isValid()) {
				Tex * tx = embedTextures.value( iData );
				if (tx == NULL){
					tx = new Tex();
					tx->id = 0;
					tx->reload = false;
					try
					{
						glGenTextures( 1, &tx->id );
						glBindTexture( GL_TEXTURE_2D, tx->id );
						embedTextures.insert( iData, tx );
						texLoad(iData, tx->format, tx->width, tx->height, tx->mipmaps);
					} catch ( QString e ) {
						tx->status = e;
					}
				}
				glBindTexture( GL_TEXTURE_2D, tx->id );
				return tx->mipmaps;
			}
		} else if ( ! nif->get<QString>( iSource, "File Name").isEmpty() ) {
			return bind( nif->get<QString>( iSource, "File Name" ) );
		}
	}
	return 0;
}
コード例 #2
0
ファイル: data.cpp プロジェクト: Rimbok/warzone2100
// Tertiles (terrain tiles) loader.
static bool dataTERTILESLoad(const char *fileName, void **ppData)
{
	bool status;

	status = texLoad(fileName);
	ASSERT_OR_RETURN(false, status, "Error loading tertiles!");
	debug(LOG_TEXTURE, "HW Tiles loaded");

	*ppData = NULL;	// don't bother calling cleanup

	return true;
}