コード例 #1
0
    //-----------------------------------------------------------------------
    bool TextureUnitState::applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply)
    {
        bool testResult = false;
        // if TUS has an alias see if its in the alias container
        if (!mTextureNameAlias.empty())
        {
            AliasTextureNamePairList::const_iterator aliasEntry =
                aliasList.find(mTextureNameAlias);

            if (aliasEntry != aliasList.end())
            {
                // match was found so change the texture name in mFrames
                testResult = true;

                if (apply)
                {
                    // currently assumes animated frames are sequentially numbered
                    // cubic, 1d, 2d, and 3d textures are determined from current TUS state
                    
                    // if cubic or 3D
                    if (mCubic)
                    {
                        setCubicTextureName(aliasEntry->second, getTextureType() == TEX_TYPE_CUBE_MAP);
                    }
                    else
                    {
                        // if more than one frame then assume animated frames
                        if (mFramePtrs.size() > 1)
                            setAnimatedTextureName(aliasEntry->second, 
                                static_cast<unsigned int>(mFramePtrs.size()), mAnimDuration);
                        else
                            setTextureName(aliasEntry->second, getTextureType());
                    }
                }
                
            }
        }

        return testResult;
    }
コード例 #2
0
ファイル: OgreTexture.cpp プロジェクト: masonh/marblemax
	//---------------------------------------------------------------------
	String Texture::getSourceFileType() const
	{
		if (mName.empty())
			return StringUtil::BLANK;

		String::size_type pos = mName.find_last_of(".");
		if (pos != String::npos && pos < (mName.length() - 1))
		{
			String ext = mName.substr(pos+1);
			StringUtil::toLowerCase(ext);
			return ext;
		}
		else
		{
			// No extension
			DataStreamPtr dstream;
			try
			{
				dstream = ResourceGroupManager::getSingleton().openResource(
						mName, mGroup, true, 0);
			}
			catch (Exception&)
			{
			}
			if (dstream.isNull() && getTextureType() == TEX_TYPE_CUBE_MAP)
			{
				// try again with one of the faces (non-dds)
				try
				{
					dstream = ResourceGroupManager::getSingleton().openResource(
						mName + "_rt", mGroup, true, 0);
				}
				catch (Exception&)
				{
				}
			}

			if (!dstream.isNull())
			{
				return Image::getFileExtFromMagic(dstream);
			}
		}

		return StringUtil::BLANK;

	}
コード例 #3
0
void Material::loadTexture(TextureType textureType)
{
	const aiTextureType aiType = getTextureType(textureType);
	aiString path;
	aiReturn texFound = mAiMaterial.GetTexture(aiType, 0, &path);
	bool useDefaultTexture = false;
	if (texFound == AI_SUCCESS) {
		const Texture* const pTexture = Texture::load(path.C_Str());
		if (pTexture) {
			addTexture(textureType, pTexture);
		}
		else {
			fprintf(stderr, "Error loading texture: %s\n", path.C_Str());
			useDefaultTexture = true;
		}
	}
	else {
		useDefaultTexture = true;
	}

	if (useDefaultTexture) {
		addTexture(textureType, Texture::sDefaultTexture);
	}
}
コード例 #4
0
ファイル: OgreTexture.cpp プロジェクト: masonh/marblemax
	//--------------------------------------------------------------------------
	size_t Texture::getNumFaces(void) const
	{
		return getTextureType() == TEX_TYPE_CUBE_MAP ? 6 : 1;
	}
コード例 #5
0
ファイル: TextureCubemap.cpp プロジェクト: savant-nz/carbon
bool TextureCubemap::upload()
{
    if (state_ != Texture::UploadPending)
        return false;

    try
    {
        videoMemoryUsed_ = 0;

        auto temporaryImage = Image();
        auto& image = getUploadableImage(temporaryImage);

        // Get the first mipmap level to upload
        auto firstMipmap = calculateFirstMipmapLevel();
        auto mipmapCount = image.getMipmapCount();

        // Upload all frames
        textureObjects_.resize(image.getFrameCount(), nullptr);
        for (auto i = 0U; i < textureObjects_.size(); i++)
        {
            auto uploadData = Vector<GraphicsInterface::TextureData>();

            for (auto j = 0U; j < 6; j++)
            {
                // Construct the upload data for this mipmap chain
                auto size = image.getWidth();
                auto dataOffset = 0U;
                for (auto k = 0U; k < mipmapCount; k++)
                {
                    auto dataSize = Image::getImageDataSize(size, size, 1, image.getPixelFormat());

                    if (k >= firstMipmap)
                    {
                        uploadData.emplace(size, size, 1, &image.getCubemapDataForFrame(i, j)[dataOffset], dataSize);

                        videoMemoryUsed_ += dataSize;
                    }

                    dataOffset += dataSize;
                    size /= 2;
                }
            }

            // Create a new texture object if needed
            if (!textureObjects_[i])
                textureObjects_[i] = graphics().createTexture();

            // Upload this frame's texture data
            if (!graphics().uploadTexture(textureObjects_[i], getTextureType(), image.getPixelFormat(), uploadData))
                throw Exception("Failed uploading texture data");
        }

        setProperties(getProperties());

        state_ = Ready;

        return true;
    }
    catch (const Exception& e)
    {
        state_ = Error;

        LOG_ERROR << "'" << getName() << "' - " << e;

        return false;
    }
}
コード例 #6
0
 //-----------------------------------------------------------------------
 bool TextureUnitState::is3D(void) const
 {
     return getTextureType() == TEX_TYPE_CUBE_MAP;
 }