Example #1
0
    void GLES2Texture::loadImpl()
    {
        if (mUsage & TU_RENDERTARGET)
        {
            createRenderTexture();
            return;
        }

        // Now the only copy is on the stack and will be cleaned in case of
        // exceptions being thrown from _loadImages
        LoadedImages loadedImages = mLoadedImages;
        mLoadedImages.setNull();

        // Call internal _loadImages, not loadImage since that's external and 
        // will determine load status etc again
        ConstImagePtrList imagePtrs;

        for (size_t i = 0; i < loadedImages->size(); ++i)
        {
            imagePtrs.push_back(&(*loadedImages)[i]);
        }

        _loadImages(imagePtrs);

        if((mUsage & TU_AUTOMIPMAP) &&
           mNumRequestedMipmaps && mMipmapsHardwareGenerated)
        {
            OGRE_CHECK_GL_ERROR(glGenerateMipmap(getGLES2TextureTarget()));
        }
    }
Example #2
0
	//--------------------------------------------------------------------------    
	void Texture::loadImage( const Image &img )
	{

        LoadingState old = mLoadingState.get();
        if (old!=LOADSTATE_UNLOADED && old!=LOADSTATE_PREPARED) return;

        if (!mLoadingState.cas(old,LOADSTATE_LOADING)) return;

		// Scope lock for actual loading
		try
		{
			OGRE_LOCK_AUTO_MUTEX
			std::vector<const Image*> imagePtrs;
			imagePtrs.push_back(&img);
			_loadImages( imagePtrs );

		}
		catch (...)
		{
			// Reset loading in-progress flag in case failed for some reason
			mLoadingState.set(old);
			// Re-throw
			throw;
		}

        mLoadingState.set(LOADSTATE_LOADED);

		// Notify manager
		if(mCreator)
			mCreator->_notifyResourceLoaded(this);

		// No deferred loading events since this method is not called in background


	}
Example #3
0
    void GLTexture::loadImpl()
    {
        if( mUsage & TU_RENDERTARGET )
        {
            createRenderTexture();
            return;
        }

        // Now the only copy is on the stack and will be cleaned in case of
        // exceptions being thrown from _loadImages
        LoadedImages loadedImages = mLoadedImages;
        mLoadedImages.setNull();

        // Call internal _loadImages, not loadImage since that's external and 
        // will determine load status etc again
        ConstImagePtrList imagePtrs;
        for (size_t i=0 ; i<loadedImages->size() ; ++i) {
            imagePtrs.push_back(&(*loadedImages)[i]);
        }

        _loadImages(imagePtrs);


        // Generate mipmaps after all texture levels have been loaded
        // This is required for compressed formats such as DXT
        // If we can do automip generation and the user desires this, do so
        if((mUsage & TU_AUTOMIPMAP) &&
            mNumRequestedMipmaps && mMipmapsHardwareGenerated)
        {
            glGenerateMipmapEXT(getGLTextureTarget());
        }
    }
Example #4
0
    void GL3PlusTexture::loadImpl()
    {
        if (mUsage & TU_RENDERTARGET)
        {
            createRenderTexture();
            return;
        }

        // Now the only copy is on the stack and will be cleaned in case of
        // exceptions being thrown from _loadImages
        LoadedImages loadedImages = mLoadedImages;
        mLoadedImages.setNull();

        // Call internal _loadImages, not loadImage since that's external and 
        // will determine load status etc again
        ConstImagePtrList imagePtrs;

        for (size_t i = 0; i < loadedImages->size(); ++i)
        {
            imagePtrs.push_back(&(*loadedImages)[i]);
        }

        _loadImages(imagePtrs);

        // Generate mipmaps after all texture levels have been loaded
        // This is required for compressed formats such as DXT
        if (mUsage & TU_AUTOMIPMAP)
        {
            OGRE_CHECK_GL_ERROR(glGenerateMipmap(getGL3PlusTextureTarget()));
        }
    }
Example #5
0
	//------------------------------------------------------------------------------//
	void Texture::loadImage(const Image& img)
	{
		if(mLoadState != LS_UNPREPARED)
			return ;

		vector<const Image*>::type imagePtrs;
		imagePtrs.push_back(&img);
		_loadImages( imagePtrs );

		mLoadState = LS_LOADED;
	}
Example #6
0
    void GLTexture::loadImpl()
    {
        if( mUsage & TU_RENDERTARGET )
        {
            createRenderTexture();
            return;
        }

        // Now the only copy is on the stack and will be cleaned in case of
        // exceptions being thrown from _loadImages
        LoadedImages loadedImages = mLoadedImages;
        mLoadedImages.setNull();

        // Call internal _loadImages, not loadImage since that's external and 
        // will determine load status etc again
        ConstImagePtrList imagePtrs;
        for (size_t i=0 ; i<loadedImages->size() ; ++i) {
            imagePtrs.push_back(&(*loadedImages)[i]);
        }

        _loadImages(imagePtrs);

    }
Example #7
0
    void GLTexture::loadImpl()
    {
        if( mUsage & TU_RENDERTARGET )
        {
            createRenderTexture();
        }
        else
        {
			String baseName, ext;
			size_t pos = mName.find_last_of(".");
			if( pos == String::npos )
				OGRE_EXCEPT(
					Exception::ERR_INVALIDPARAMS, 
					"Unable to load image file '"+ mName + "' - invalid extension.",
					"GLTexture::loadImpl" );

			baseName = mName.substr(0, pos);
			ext = mName.substr(pos+1);
    
			if(mTextureType == TEX_TYPE_1D || mTextureType == TEX_TYPE_2D || 
                mTextureType == TEX_TYPE_3D)
            {
                Image img;
	            // find & load resource data intro stream to allow resource
				// group changes if required
				DataStreamPtr dstream = 
					ResourceGroupManager::getSingleton().openResource(
						mName, mGroup, true, this);

                img.load(dstream, ext);

				// If this is a cube map, set the texture type flag accordingly.
                if (img.hasFlag(IF_CUBEMAP))
					mTextureType = TEX_TYPE_CUBE_MAP;
				// If this is a volumetric texture set the texture type flag accordingly.
				if(img.getDepth() > 1)
					mTextureType = TEX_TYPE_3D;

				// Call internal _loadImages, not loadImage since that's external and 
				// will determine load status etc again
				ConstImagePtrList imagePtrs;
				imagePtrs.push_back(&img);
				_loadImages( imagePtrs );
            }
            else if (mTextureType == TEX_TYPE_CUBE_MAP)
            {
				if(StringUtil::endsWith(getName(), ".dds"))
				{
					// XX HACK there should be a better way to specify whether 
					// all faces are in the same file or not
					Image img;
	            	// find & load resource data intro stream to allow resource
					// group changes if required
					DataStreamPtr dstream = 
						ResourceGroupManager::getSingleton().openResource(
							mName, mGroup, true, this);

	                img.load(dstream, ext);
					// Call internal _loadImages, not loadImage since that's external and 
					// will determine load status etc again
					ConstImagePtrList imagePtrs;
					imagePtrs.push_back(&img);
					_loadImages( imagePtrs );
				}
				else
				{
					std::vector<Image> images(6);
					ConstImagePtrList imagePtrs;
					static const String suffixes[6] = {"_rt", "_lf", "_up", "_dn", "_fr", "_bk"};
	
					for(size_t i = 0; i < 6; i++)
					{
						String fullName = baseName + suffixes[i] + "." + ext;
		            	// find & load resource data intro stream to allow resource
						// group changes if required
						DataStreamPtr dstream = 
							ResourceGroupManager::getSingleton().openResource(
								fullName, mGroup, true, this);
	
						images[i].load(dstream, ext);
						imagePtrs.push_back(&images[i]);
					}
	
					_loadImages( imagePtrs );
				}
            }
            else
                OGRE_EXCEPT( Exception::ERR_NOT_IMPLEMENTED, "**** Unknown texture type ****", "GLTexture::load" );
        }
    }