当前位置: 首页>>代码示例>>C++>>正文


C++ IDirect3DSurface9::Release方法代码示例

本文整理汇总了C++中IDirect3DSurface9::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DSurface9::Release方法的具体用法?C++ IDirect3DSurface9::Release怎么用?C++ IDirect3DSurface9::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDirect3DSurface9的用法示例。


在下文中一共展示了IDirect3DSurface9::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

    void CCoherentViewListener::DrawFrameDX9SharedTexture( Coherent::UI::CoherentHandle handle, int width, int height )
    {
        if ( gCoherentUISystem == NULL )
        {
            return;
        }

        void* pNativeTexture = gCoherentUISystem->GetNativeTextureFromSharedHandle( handle );

        if ( pNativeTexture == NULL )
        {
            return;
        }

        IDirect3DTexture9* pD3DSrcTex = static_cast<IDirect3DTexture9*>( pNativeTexture );
        IDirect3DSurface9* pSurfaceSource;
        pD3DSrcTex->GetSurfaceLevel( 0, &pSurfaceSource );
        IDirect3DSurface9* pSurfaceDest;

        IDirect3DTexture9* pD3DDestTex = static_cast<IDirect3DTexture9*>( m_pTexture );
        pD3DDestTex->GetSurfaceLevel( 0, &pSurfaceDest );
        static_cast<IDirect3DDevice9*>( gD3DDevice )->StretchRect( pSurfaceSource, nullptr, pSurfaceDest, nullptr, D3DTEXF_NONE );

        pSurfaceSource->Release();
        pSurfaceDest->Release();
    }
开发者ID:iherwig,项目名称:Plugin_CoherentUI,代码行数:26,代码来源:CoherentViewListener.cpp

示例2: copy

bool Blit::copy(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level)
{
    RenderTarget9 *renderTarget = NULL;
    IDirect3DSurface9 *source = NULL;
    gl::Renderbuffer *colorbuffer = framebuffer->getColorbuffer(0);

    if (colorbuffer)
    {
        renderTarget = RenderTarget9::makeRenderTarget9(colorbuffer->getRenderTarget());
    }
    
    if (renderTarget)
    {
        source = renderTarget->getSurface();
    }

    if (!source)
    {
        ERR("Failed to retrieve the render target.");
        return gl::error(GL_OUT_OF_MEMORY, false);
    }

    TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage->getStorageInstance());
    IDirect3DSurface9 *destSurface = storage9->getCubeMapSurface(target, level, true);
    bool result = false;

    if (destSurface)
    {
        result = copy(source, sourceRect, destFormat, xoffset, yoffset, destSurface);
        destSurface->Release();
    }

    source->Release();
    return result;
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:35,代码来源:Blit.cpp

示例3: createTexture

	virtual IDirect3DTexture9* createTexture() {
		IDirect3DTexture9* tex = CFixedTextureCreator::createTexture();

		// create the offscreen surface
		HRESULT hr;
		CD3DDevice& dx = CD3DDevice::getInstance();
		IDirect3DSurface9* srcSurf = 0;
		hr = dx.getDevice().CreateOffscreenPlainSurface( mGameMap->getCellsX(), mGameMap->getCellsY(), D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &srcSurf, NULL );
		assert( SUCCEEDED(hr) );

		D3DLOCKED_RECT lr;
		srcSurf->LockRect( &lr, NULL, D3DLOCK_DISCARD );
		const char* linePtr = (const char*)lr.pBits;
		for( int y = 0; y < mGameMap->getCellsY(); ++y ) {
			D3DCOLOR* p = (D3DCOLOR*)linePtr;
			for( int x = 0; x < mGameMap->getCellsX(); ++x ) {
				const CGameMap::SCell& cell = mGameMap->getCell(x,y);
				*p = gColors.minimap[cell.color][cell.type];
				++p;
			}
			linePtr += lr.Pitch;
		}
		srcSurf->UnlockRect();

		// now, filter this into the texture
		IDirect3DSurface9* dstSurf = 0;
		hr = tex->GetSurfaceLevel( 0, &dstSurf );
		assert( SUCCEEDED(hr) );
		hr = D3DXLoadSurfaceFromSurface( dstSurf, NULL, NULL, srcSurf, NULL, NULL, D3DX_FILTER_BOX, 0 );
		dstSurf->Release();
		srcSurf->Release();

		D3DXFilterTexture( tex, NULL, 0, D3DX_FILTER_BOX );
		return tex;
	}
开发者ID:BackupTheBerlios,项目名称:dingus-svn,代码行数:35,代码来源:GameMap.cpp

示例4: color

void ModuleIrisGraphics::snap2Bitmap(IIrisBitmap *bitmap){
	IDirect3DSurface9* EXSurface;
	IDirect3DSurface9* ExchangeSurface;
	ExchangeTexture->GetSurfaceLevel(0, &EXSurface);	
	Device->CreateOffscreenPlainSurface(width, height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &ExchangeSurface, 0);
	Device->GetRenderTargetData(EXSurface, ExchangeSurface);

	D3DLOCKED_RECT rc;
	memset(&rc, 0, sizeof(rc));
	ExchangeSurface->LockRect(&rc, 0, D3DLOCK_NOOVERWRITE);
	PARGBQuad p2 = (PARGBQuad)rc.pBits;
	PARGBQuad c2 = 0;
	IrisColor color(0, 0, 0, 0);
	for (int x = 0; x < width; x++){
		for (int y = 0; y < height; y++){
			c2 = p2 + x + y * rc.Pitch / sizeof(ARGBQuad);
			color.set(c2->Red, c2->Green, c2->Blue, c2->Alpha);
			bitmap->SetPixel(x, y, &color);
		}
	}

	ExchangeSurface->UnlockRect();
	EXSurface->Release();
	ExchangeSurface->Release();
}
开发者ID:HADESAngelia,项目名称:Iris-2D-Project,代码行数:25,代码来源:ModuleIrisGraphics.cpp

示例5: InstallOnDevice

LTRESULT CRenderTarget::InstallOnDevice()
{
	if(m_pRenderTarget == NULL || m_pDepthStencilBuffer == NULL)
	{
		return LT_ERROR;
	}

	IDirect3DSurface9* pRTSurface;
	if(FAILED(m_pRenderTarget->GetSurfaceLevel(0, &pRTSurface)))
	{
		return LT_ERROR;
	}

	if(FAILED(PD3DDEVICE->SetRenderTarget(pRTSurface, m_pDepthStencilBuffer)))
	{
		dsi_ConsolePrint("Failed to set the new render target!");
		pRTSurface->Release();
		return LT_ERROR;
	}

	// We need to clear to make it a valid render target.
	if(FAILED(PD3DDEVICE->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DRGBA_255(0, 0, 0, 0), 1.0f, 0)))
	{
		PD3DDEVICE->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DRGBA_255(0, 0, 0, 0), 1.0f, 0);
	}

	pRTSurface->Release();

	return LT_OK;
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:30,代码来源:rendertarget.cpp

示例6: defined

RageSurface* RageDisplay_D3D::CreateScreenshot()
{
#if defined(XBOX)
	return NULL;
#else
	RageSurface * result = NULL;

	// Get the back buffer.
	IDirect3DSurface9* pSurface;
	if( SUCCEEDED( g_pd3dDevice->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &pSurface ) ) )
	{
		// Get the back buffer description.
		D3DSURFACE_DESC desc;
		pSurface->GetDesc( &desc );

		// Copy the back buffer into a surface of a type we support.
		IDirect3DSurface9* pCopy;
		if( SUCCEEDED( g_pd3dDevice->CreateOffscreenPlainSurface( desc.Width, desc.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pCopy, NULL ) ) )
		{
			if( SUCCEEDED( D3DXLoadSurfaceFromSurface( pCopy, NULL, NULL, pSurface, NULL, NULL, D3DX_FILTER_NONE, 0) ) )
			{
				// Update desc from the copy.
				pCopy->GetDesc( &desc );

				D3DLOCKED_RECT lr;

				{
					RECT rect;
					rect.left = 0;
					rect.top = 0;
					rect.right = desc.Width;
					rect.bottom = desc.Height;

					pCopy->LockRect( &lr, &rect, D3DLOCK_READONLY );
				}

				RageSurface *surface = CreateSurfaceFromPixfmt( FMT_RGBA8, lr.pBits, desc.Width, desc.Height, lr.Pitch);
				ASSERT( surface != NULL );

				// We need to make a copy, since lr.pBits will go away when we call UnlockRect().
				result = 
					CreateSurface( surface->w, surface->h,
						surface->format->BitsPerPixel,
						surface->format->Rmask, surface->format->Gmask,
						surface->format->Bmask, surface->format->Amask );
				RageSurfaceUtils::CopySurface( surface, result );
				delete surface;

				pCopy->UnlockRect();
			}

			pCopy->Release();
		}

		pSurface->Release();
	}

	return result;
#endif
}
开发者ID:augustg,项目名称:openitg,代码行数:60,代码来源:RageDisplay_D3D.cpp

示例7: buildGBuffers

void DS_Basic_MRT::buildGBuffers()
{
	HRESULT hr;
	//-- G-Buffsers
	SetRenderTarget SRT(m_pD3DDevice, m_posRT);

	IDirect3DSurface9 *pSurfaceZ = NULL;
	hr = m_posRT_Z->GetSurfaceLevel(0, &pSurfaceZ );

	IDirect3DSurface9 *pSurfaceNormal = NULL;
	hr = m_normalRT->GetSurfaceLevel(0, &pSurfaceNormal );
	
	IDirect3DSurface9 *pSurfaceDiffuse= NULL;
	hr = m_diffuseRT->GetSurfaceLevel(0, &pSurfaceDiffuse );
	
	hr = m_pD3DDevice->SetRenderTarget(1, pSurfaceZ);
	hr = m_pD3DDevice->SetRenderTarget(2, pSurfaceNormal);
	hr = m_pD3DDevice->SetRenderTarget(3, pSurfaceDiffuse);

	pSurfaceZ->Release();
	pSurfaceDiffuse->Release();
	pSurfaceNormal->Release();

	hr = m_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1, 0);

	hr = m_pEffect->SetTechnique("init_mrt");
	renderScene();

	hr = m_pD3DDevice->SetRenderTarget(1, NULL);
	hr = m_pD3DDevice->SetRenderTarget(2, NULL);
	hr = m_pD3DDevice->SetRenderTarget(3, NULL);

	//hr = D3DXSaveTextureToFile("D:\\test.dds", D3DXIFF_DDS, m_posRT, NULL);
}
开发者ID:neil3d,项目名称:myshaders,代码行数:34,代码来源:DS_Basic_MRT.cpp

示例8:

void D3D9Sprite::RecoverFromBackup()
{
	if (!m_pBackupTexture)
		return;

	m_texture = m_video.lock()->CreateRenderTargetTexture(static_cast<unsigned int>(m_size.x), static_cast<unsigned int>(m_size.y), m_targetFormat);

	IDirect3DTexture9* pBackup = m_pBackupTexture;

	IDirect3DTexture9* pActualTexture;
	try 
	{
		pActualTexture = boost::any_cast<IDirect3DTexture9*>(m_texture->GetTextureObject());
	}
	catch (const boost::bad_any_cast &)
	{
		std::wstringstream ss;
		ss << L"D3D9Sprite::RecoverFromBackup Invalid texture pointer" << std::endl;
		ShowMessage(ss, GSMT_ERROR);
		return;
	}
	IDirect3DSurface9* pActualSurface = NULL;
	IDirect3DSurface9* pBackupSurf = NULL;

	pActualTexture->GetSurfaceLevel(0, &pActualSurface);
	pBackup->GetSurfaceLevel(0, &pBackupSurf);
	m_pDevice->UpdateSurface(pBackupSurf, NULL, pActualSurface, NULL);
	
	pBackupSurf->Release();
	pActualSurface->Release();

	GetInternalData();
}
开发者ID:skaflux,项目名称:ethanon,代码行数:33,代码来源:D3D9Sprite.cpp

示例9: PresentToTexture

HRESULT VMRSurfaceAllocator::PresentToTexture( VMR9PresentationInfo *lpPresInfo )
{
	HRESULT hr;
	IDirect3DTexture9 *lpTexture;
	IDirect3DSurface9 *lpSurface;

	if ( m_alpDirect3DTexture[ 0 ] != NULL )
	{
		clock->Lock();
		lpTexture = m_alpDirect3DTexture[ m_nFilpTexNum ];
		hr = lpTexture->GetSurfaceLevel( 0, &lpSurface );
		if ( hr != S_OK )
		{
			return hr;
		}

		hr = D3DDev->StretchRect( lpPresInfo->lpSurf, NULL, lpSurface, NULL, D3DTEXF_NONE );
		if ( hr != S_OK )
		{
			lpSurface->Release();
			return hr;
		}
		lpSurface->Release();
		texnum = m_nFilpTexNum;
		m_nFilpTexNum = m_nFilpTexNum ^ 0x01;
		clock->Unlock();
	} else
	{
		m_nFilpTexNum = -1;
	}

	return S_OK;
}
开发者ID:HirokiMiyaoka,项目名称:Mikan,代码行数:33,代码来源:VMRSurfaceAllocator.cpp

示例10: DrawToTexture

void COverlayRenderer::DrawToTexture(OSDTexture* pOsdTexture, IDirect3DTexture9* pTexture, uint16_t x, uint16_t y, uint16_t w, uint16_t h)
{
  if (!pOsdTexture || !pTexture || !m_pD3DDevice)
    return;

  RECT sourceRect;
  sourceRect.left = 0;
  sourceRect.top = 0;
  sourceRect.right = w;
  sourceRect.bottom = h;

  RECT dstRect;
  dstRect.left = x;
  dstRect.top = y;
  dstRect.right = x + w;
  dstRect.bottom = y + h;

  IDirect3DSurface9* sourceSurface = NULL;
  IDirect3DSurface9* dstSurface = NULL;

  pTexture->GetSurfaceLevel(0, &sourceSurface);
  pOsdTexture->texture->GetSurfaceLevel(0, &dstSurface);

  m_pD3DDevice->StretchRect(sourceSurface, &sourceRect, dstSurface, &dstRect, D3DTEXF_NONE);

  sourceSurface->Release();
  dstSurface->Release();
  pTexture->Release();
}
开发者ID:Azzuro,项目名称:MediaPortal-1,代码行数:29,代码来源:OverlayRenderer.cpp

示例11: if

//! Regenerates the mip map levels of the texture. Useful after locking and
//! modifying the texture
void CD3D9Texture::regenerateMipMapLevels(void* mipmapData)
{
	if (mipmapData)
	{
		core::dimension2du size = TextureSize;
		u32 level=0;
		do
		{
			if (size.Width>1)
				size.Width /=2;
			if (size.Height>1)
				size.Height /=2;
			++level;
			IDirect3DSurface9* mipSurface = 0;
			HRESULT hr = Texture->GetSurfaceLevel(level, &mipSurface);
			if (FAILED(hr) || !mipSurface)
			{
				os::Printer::log("Could not get mipmap level", ELL_WARNING);
				return;
			}
			D3DSURFACE_DESC mipDesc;
			mipSurface->GetDesc(&mipDesc);
			D3DLOCKED_RECT miplr;

			// lock mipmap surface
			if (FAILED(mipSurface->LockRect(&miplr, NULL, 0)))
			{
				mipSurface->Release();
				os::Printer::log("Could not lock texture", ELL_WARNING);
				return;
			}

			memcpy(miplr.pBits, mipmapData, size.getArea()*getPitch()/TextureSize.Width);
			mipmapData = (u8*)mipmapData+size.getArea()*getPitch()/TextureSize.Width;
			// unlock
			mipSurface->UnlockRect();
			// release
			mipSurface->Release();
		} while (size.Width != 1 || size.Height != 1);
	}
	else if (HasMipMaps)
	{
		// create mip maps.
#ifdef _IRR_USE_D3DXFilterTexture_
		// The D3DXFilterTexture function seems to get linked wrong when
		// compiling with both D3D8 and 9, causing it not to work in the D3D9 device.
		// So mipmapgeneration is replaced with my own bad generation
		HRESULT hr  = D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT, D3DX_DEFAULT);
		if (FAILED(hr))
#endif
		createMipMaps();
	}
}
开发者ID:Lumirion,项目名称:pseuwow,代码行数:55,代码来源:CD3D9Texture.cpp

示例12: getSurfaceLevel

void TextureStorage9_2D::generateMipmap(int level)
{
    IDirect3DSurface9 *upper = getSurfaceLevel(level - 1, false);
    IDirect3DSurface9 *lower = getSurfaceLevel(level, true);

    if (upper != NULL && lower != NULL)
    {
        mRenderer->boxFilter(upper, lower);
    }

    if (upper != NULL) upper->Release();
    if (lower != NULL) lower->Release();
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:13,代码来源:TextureStorage9.cpp

示例13: getCubeMapSurface

void TextureStorage9_Cube::generateMipmap(int face, int level)
{
    IDirect3DSurface9 *upper = getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level - 1, false);
    IDirect3DSurface9 *lower = getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, true);

    if (upper != NULL && lower != NULL)
    {
        mRenderer->boxFilter(upper, lower);
    }

    if (upper != NULL) upper->Release();
    if (lower != NULL) lower->Release();
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:13,代码来源:TextureStorage9.cpp

示例14: onRender

void RootViewPlay::onRender(const ::bootes::lib::framework::GameTime* gt)
{
   HRESULT hr;
   ::bootes::lib::util::Timer timer;
   int dt[10];
   int ti = 0;

   IDirect3DDevice9* pDev = g_pFnd->getD3D9Device();
   if (pDev == NULL) { return; }
   hr = pDev->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1, 0  );

   timer.start();
   _pGameView->onRender(gt);
   timer.get(NULL, &dt[ti++]);

   timer.start();
   do {
      //IDirect3DTexture9* pTex = scene.refTexture(); //test
      Scene scene = _pGameView->getScene(true);
      IDirect3DTexture9* pTex = scene.refTexture();
      if (pTex == NULL) { break; }
      IDirect3DSurface9* pSrc;
      pTex->GetSurfaceLevel(0, &pSrc);
      
      IDirect3DSurface9* pDst;
      hr = pDev->GetRenderTarget(0, &pDst);

      //hr = pDev->StretchRect(pSrc, NULL, pDst, NULL, D3DTEXF_NONE); //D3DPOOL_DEFUALT
      hr = pDev->UpdateSurface(pSrc, NULL, pDst, NULL); //D3DPOOL_SYSTEM
      if (hr == D3DERR_INVALIDCALL) {
         DbgBreak("");
      }
      pDst->Release();
      pSrc->Release();
      pTex->Release();
   } while(0);
   pDev->EndScene();
   /*
   do {
      ID3DXLine* pLine;
      D3DXCreateLine(pDev, &pLine);
      D3DXVECTOR2 points[] = {
         D3DXVECTOR2(0,0), D3DXVECTOR2(100,100), 
      };
      pLine->Begin();
      pLine->Draw(points, 2, D3DCOLOR_ARGB(255,255,255,255));
      pLine->End();
   } while(0);
   */
   timer.reset();
}
开发者ID:dai1975,项目名称:BootesDances,代码行数:51,代码来源:RootViewPlay.cpp

示例15: ms

GBitmap *AtlasTexChunk::loadDDSIntoGBitmap(const U8 *ddsBuffer, U32 ddsBufferSize)
{
    D3DXIMAGE_INFO info;
    D3D9Assert(GFXD3DX.D3DXGetImageInfoFromFileInMemory(ddsBuffer, ddsBufferSize, &info),
               "AtlasTexChunk::loadDDSIntoGBitmap - failed to get image info.");

    IDirect3DSurface9 *surf = NULL;
    D3D9Assert(((GFXD3D9Device*)GFX)->getDevice()->CreateOffscreenPlainSurface(
                   info.Width, info.Height, info.Format, D3DPOOL_SCRATCH, &surf, NULL),
               "AtlasTexChunk::loadDDSIntoGBitmap - failed to allocate scratch surface.");

    // We want JPEGs, let's convert it in a klunky way...
    D3D9Assert(GFXD3DX.D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL,
               ddsBuffer, ddsBufferSize, NULL,
               D3DX_DEFAULT, 0, NULL),
               "AtlasTexChunk::loadDDSIntoGBitmap - D3DX failed to load from buffer.");

    ID3DXBuffer *buff = NULL;
    D3D9Assert(GFXD3DX.D3DXSaveSurfaceToFileInMemory(&buff, D3DXIFF_PNG, surf, NULL, NULL),
               "AtlasTexChunk::loadDDSIntoGBitmap - D3DX failed to save back to buffer.");
    MemStream ms(buff->GetBufferSize(), buff->GetBufferPointer(), true, false);

    GBitmap *bitmap = new GBitmap[1];
    bitmap->readBitmap( "png", ms );

    // Cleanup!
    buff->Release();
    surf->Release();

    return bitmap;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:31,代码来源:atlasTexChunkD3D.win32.cpp


注:本文中的IDirect3DSurface9::Release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。