예제 #1
0
	void GenesisTexture::createManual(int _width, int _height, TextureUsage _usage, PixelFormat _format)
	{
		m_width = _width;
		m_height = _height;
		mOriginalUsage = _usage;
		setFormat(_format);
		RenderBase::PixelFormat::Code wj_format = FormatMyGuiToWj(_format);

		GPtr<RenderBase::Texture> tex = RenderBase::Texture::Create();
		tex->Setup();

		// set type
		RenderBase::Texture::Type texType = RenderBase::Texture::Texture2D;

		tex->SetType( texType );

		tex->SetWidth( _width );
		tex->SetHeight( _height );
		tex->SetDepth( 1);
		tex->SetNumMipLevels( 1 );
		tex->SetPixelFormat( wj_format );

		tex->SetUsage(UsageMyGuiToWj(_usage));
		//tex->SetUsage(RenderBase::RenderResource::UsageDynamic);
		tex->SetAccess(RenderBase::RenderResource::AccessWrite);


		// dummy
		tex->SetSkippedMips( 0 );
		tex->SetUnitIndex( 0 );

		//tex->SetTexturePath();

		if (m_texStream)
		{
			m_texStream = NULL;
		}
		m_texStream = IO::MemoryStream::Create();
		m_texStream->SetAccessMode( IO::Stream::WriteAccess );
		if( m_texStream->Open() )
		{
			m_texStream->SetSize(m_width * m_height * mNumElemBytes);
			tex->SetStream( m_texStream.upcast<IO::Stream>() );
			m_texStream->Close();
			//m_texStream->SetAccessMode( IO::Stream::ReadAccess );
			m_texHandle = Graphic::GraphicSystem::Instance()->CreateTexture(tex);

			GenesisTextureMgr::Instance()->AddManualTexture(this);
			m_bManualCreate = true;
		}
		else
		{
			m_texHandle = NULL;
			m_width = 0;
			m_height = 0;
			mOriginalUsage = TextureUsage::Default;
			mOriginalFormat = PixelFormat::Unknow;
		}
	}
예제 #2
0
	void GenesisTextureMgr::ReLoadManualTextures() const
	{
		SizeT nCount = m_ManualTextures.Size();

		for (IndexT i = 0; i < nCount; ++i)
		{

			GenesisTexture* pTex = m_ManualTextures[i];

			SizeT width  = pTex->getWidth();
			SizeT height = pTex->getHeight();

			RenderBase::PixelFormat::Code wj_format = GenesisTexture::FormatMyGuiToWj(pTex->getFormat());

			GPtr<RenderBase::Texture> tex = RenderBase::Texture::Create();
			tex->Setup();

			// set type
			RenderBase::Texture::Type texType = RenderBase::Texture::Texture2D;

			tex->SetType( texType );

			tex->SetWidth( width );
			tex->SetHeight( height );
			tex->SetDepth( 1);
			tex->SetNumMipLevels( 1 );
			tex->SetPixelFormat( wj_format );

			tex->SetAccess(RenderBase::RenderResource::AccessWrite);

			// dummy
			tex->SetSkippedMips( 0 );
			tex->SetUnitIndex( 0 );

			tex->SetStream( pTex->GetBuffer().upcast<IO::Stream>() );

			Graphic::GraphicSystem::Instance()->UpdateTexture(pTex->GetTextureHandle(), tex);
		}
	}