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


C++ LPDIRECT3DTEXTURE9::GetLevelDesc方法代码示例

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


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

示例1: init

	bool AlphaMap::init(bool pAlphaCheck, LPDIRECT3DTEXTURE9 pTexture)
	{
    d_solid = true;

		if (!pAlphaCheck)
			return false;

		D3DSURFACE_DESC surfaceDesc;
		pTexture->GetLevelDesc(0, &surfaceDesc);

		d_width = surfaceDesc.Width;
		d_height = surfaceDesc.Height;
		d_mask.resize(d_width * d_height);

		D3DLOCKED_RECT lockedRect;
		if (SUCCEEDED(pTexture->LockRect(0, &lockedRect, NULL, D3DLOCK_DISCARD)))
		{
			unsigned char* bits = (unsigned char*)lockedRect.pBits;

			for (int y = 0; y < d_height; ++y)
			{
				for (int x = 0; x < d_width; ++x)
				{
					bool solid = (bits[x * 4 + y * lockedRect.Pitch + 3] != 0);
					d_mask[x + y * d_width] = solid;
					if (!solid)
						d_solid = false;
				}
			}
			pTexture->UnlockRect(0);
		}

		return true;
	}
开发者ID:dohxehapo,项目名称:Doh3d,代码行数:34,代码来源:AlphaMap.cpp

示例2: GetSpriteSize

void GetSpriteSize(LPDIRECT3DTEXTURE9 pTex,int& width,int& height)
{
	D3DSURFACE_DESC desc;
	pTex->GetLevelDesc(0,&desc);
	width=desc.Width;
	height=desc.Height;
}
开发者ID:MarcusKhoo,项目名称:Apollo13,代码行数:7,代码来源:SpriteUtils.cpp

示例3:

//-------------------------------------------------------------------------------------------------
sdMemoryTexture::sdMemoryTexture(LPDIRECT3DTEXTURE9 spD3DTexture)
{
	NIASSERT(spD3DTexture);

	// 获取渲染设备
	NiDX9Renderer* spRenderer = NiDX9Renderer::GetRenderer();
	NIASSERT(spRenderer);

	// 提取格式信息
	D3DSURFACE_DESC kLevelDesc;
	spD3DTexture->GetLevelDesc(0, &kLevelDesc);

	m_uiWidth = kLevelDesc.Width;
	m_uiHeight = kLevelDesc.Height;
	m_uiLevel = spD3DTexture->GetLevelCount();
	m_eFormat = kLevelDesc.Format;

	//
	m_spD3DTexture = spD3DTexture;
	m_spD3DTexture->AddRef();

	// 创建GB纹理对象
	m_spTexture = spRenderer->CreateNiTextureFromD3DTexture(m_spD3DTexture);
	NIASSERT(m_spTexture);
}
开发者ID:arundev,项目名称:dev-code,代码行数:26,代码来源:sdMemoryTexture.cpp

示例4: DrawSprite

void CImage::DrawSprite(LPD3DXSPRITE SpriteInterface, LPDIRECT3DTEXTURE9 TextureInterface, int PosX, int PosY, int Rotation, int Align)
{
	if(SpriteInterface == NULL || TextureInterface == NULL)
		return;

	D3DXVECTOR3 Vec;

	Vec.x = (FLOAT)PosX;
	Vec.y = (FLOAT)PosY;
	Vec.z = (FLOAT)0.0f;

	D3DXMATRIX mat;
	D3DXVECTOR2 scaling(1.0f, 1.0f);
	D3DSURFACE_DESC desc;
	TextureInterface->GetLevelDesc(0, &desc);
	D3DXVECTOR2 spriteCentre;
	if(Align == 1)
		spriteCentre = D3DXVECTOR2((FLOAT)desc.Width / 2, (FLOAT)desc.Height / 2);
	else
		spriteCentre = D3DXVECTOR2(0, 0);
	D3DXVECTOR2 trans = D3DXVECTOR2(0, 0);
	D3DXMatrixTransformation2D(&mat, NULL, 0.0, &scaling, &spriteCentre, (FLOAT)Rotation, &trans);

	SpriteInterface->SetTransform(&mat);
	SpriteInterface->Begin(D3DXSPRITE_ALPHABLEND);
	SpriteInterface->Draw(TextureInterface, NULL, NULL, &Vec, 0xFFFFFFFF);
	SpriteInterface->End();
}
开发者ID:JohnnyCrazy,项目名称:DX9-Overlay-API,代码行数:28,代码来源:Image.cpp

示例5: GetFormat

D3DFORMAT CDxtexDoc::GetFormat(LPDIRECT3DBASETEXTURE9 ptex)
{
    LPDIRECT3DTEXTURE9 pmiptex = NULL;
    LPDIRECT3DCUBETEXTURE9 pcubetex = NULL;
    LPDIRECT3DVOLUMETEXTURE9 pvoltex = NULL;
    D3DFORMAT fmt = D3DFMT_UNKNOWN;

    if (IsVolumeMap())
        pvoltex = (LPDIRECT3DVOLUMETEXTURE9)ptex;
    else if (IsCubeMap())
        pcubetex = (LPDIRECT3DCUBETEXTURE9)ptex;
    else
        pmiptex = (LPDIRECT3DTEXTURE9)ptex;

    if (pvoltex != NULL)
    {
        D3DVOLUME_DESC vd;
        pvoltex->GetLevelDesc(0, &vd);
        fmt = vd.Format;
    }
    else if (pcubetex != NULL)
    {
        D3DSURFACE_DESC sd;
        pcubetex->GetLevelDesc(0, &sd);
        fmt = sd.Format;
    }
    else if( pmiptex != NULL )
    {
        D3DSURFACE_DESC sd;
        pmiptex->GetLevelDesc(0, &sd);
        fmt = sd.Format;
    }
    return fmt;
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:34,代码来源:dxtexdoc.cpp

示例6: init

void OpticSprite::init(LPDIRECT3DTEXTURE9 texture) {
	texture->GetLevelDesc(0, &surfaceDesc); 
	transformCentre = D3DXVECTOR2(surfaceDesc.Width * 0.5f, surfaceDesc.Height * 0.5f);
	translateCentre = D3DXVECTOR2(0.0f, 0.0f);
	this->texture = texture;
	this->spritesheet = false;
	this->texture = texture;
	this->lastTime = 0;
}
开发者ID:ChurroV2,项目名称:ElDorito,代码行数:9,代码来源:OpticSprite.cpp

示例7: CalculateResourceUsage

//--------------------------------------------------------------------------------------
//  CalculateResourceUsage( )
//
//      DESC:
//          Based on the known resources this function attempts to make an accurate
//          measurement of how much VRAM is being used by this part of the application.
//
//      NOTES:
//          Whilst the return value should be pretty accurate, it shouldn't be relied
//          on due to the way drivers/hardware can allocate memory.
//
//          Only the first level of the render target is checked as there should, by
//          definition, be no mip levels.
//
//--------------------------------------------------------------------------------------
DWORD CalculateResourceUsage()
{

    DWORD usage = 0;
    D3DSURFACE_DESC d;

    if( SUCCEEDED( g_pBrightPassTex->GetLevelDesc( 0, &d ) ) )
        usage += ( ( d.Width * d.Height ) * ( PostProcess::g_fmtHDR == D3DFMT_A32B32G32R32F ? 16 : 8 ) );

    if( SUCCEEDED( g_pDownSampledTex->GetLevelDesc( 0, &d ) ) )
        usage += ( ( d.Width * d.Height ) * ( PostProcess::g_fmtHDR == D3DFMT_A32B32G32R32F ? 16 : 8 ) );

    if( SUCCEEDED( g_pBloomHorizontal->GetLevelDesc( 0, &d ) ) )
        usage += ( ( d.Width * d.Height ) * ( PostProcess::g_fmtHDR == D3DFMT_A32B32G32R32F ? 16 : 8 ) );

    if( SUCCEEDED( g_pBloomVertical->GetLevelDesc( 0, &d ) ) )
        usage += ( ( d.Width * d.Height ) * ( PostProcess::g_fmtHDR == D3DFMT_A32B32G32R32F ? 16 : 8 ) );

    return usage;

}
开发者ID:KNeal,项目名称:Oculus,代码行数:36,代码来源:PostProcess.cpp

示例8: DXTRACE_ERR

//-------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: 디바이스가 생성된후의 초기화
//       프레임버퍼 포맷과 디바이스 종류가 변한뒤에 호출
//       여기서 확보한 메모리는 DeleteDeviceObjects()에서 해제
//-------------------------------------------------------------
HRESULT CMyD3DApplication::InitDeviceObjects()
{
    HRESULT hr;
    LPDIRECT3DTEXTURE9	pHeightTexture;
    D3DSURFACE_DESC desc;

	// 법선맵 생성
    D3DUtil_CreateTexture( m_pd3dDevice,// 높이맵 읽기
		_T("height.bmp"), &pHeightTexture );
    pHeightTexture->GetLevelDesc(0,&desc);// 텍스처 정보 얻기
    D3DXCreateTexture(m_pd3dDevice, desc.Width, desc.Height, 0, 0, 
        D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &m_pNormalMap);// 텍스처 생성
    D3DXComputeNormalMap(m_pNormalMap,	// 법선맵 생성
        pHeightTexture, NULL, 0, D3DX_CHANNEL_RED, 1.0f);
    SAFE_RELEASE( pHeightTexture );		// 필요없어진 리소스 해제

	// 정점선언 오브젝트 생성
	if( FAILED( hr = m_pd3dDevice->CreateVertexDeclaration(
										decl, &m_pDecl )))
		return DXTRACE_ERR ("CreateVertexDeclaration", hr);
	
	// 주전자 읽기
	if(FAILED(hr=m_pMesh  ->Create( m_pd3dDevice, _T("t-pot.x"))))
        return DXTRACE_ERR( "Load Object", hr );
        
	// 지형 읽기
	if(FAILED(hr=m_pMeshBg->Create( m_pd3dDevice, _T("map.x"))))
        return DXTRACE_ERR( "Load Ground", hr );
        
	// 셰이더 읽기
    LPD3DXBUFFER pErr=NULL;
    if( FAILED( hr = D3DXCreateEffectFromFile(
                m_pd3dDevice, "hlsl.fx", NULL, NULL, 
                0 , NULL, &m_pEffect, &pErr ))){
        // 셰이더 읽기 실패
        MessageBox( NULL, (LPCTSTR)pErr->GetBufferPointer()
                    , "ERROR", MB_OK);
    }else{
		m_hTechnique = m_pEffect->GetTechniqueByName( "TShader" );
		m_hmWVP      = m_pEffect->GetParameterByName( NULL, "mWVP" );
		m_hvLightDir = m_pEffect->GetParameterByName( NULL, "vLightDir" );
		m_hvColor    = m_pEffect->GetParameterByName( NULL, "vColor" );
		m_hvEyePos   = m_pEffect->GetParameterByName( NULL, "vEyePos" );
		m_htDecaleTex= m_pEffect->GetParameterByName( NULL, "DecaleTex" );
		m_htNormalMap= m_pEffect->GetParameterByName( NULL, "NormalMap" );
    }
    SAFE_RELEASE(pErr);

	// 폰트
    m_pFont->InitDeviceObjects( m_pd3dDevice );

    return S_OK;
}
开发者ID:jjuiddong,项目名称:Dx9-Shader,代码行数:59,代码来源:main.cpp

示例9: InitVB

/**-----------------------------------------------------------------------------
 * 정점버퍼를 생성하고 정점값을 채워넣는다.
 * HeightMap정보도 여기서 초기화한다.
 *------------------------------------------------------------------------------
 */
HRESULT InitVB()
{
	D3DSURFACE_DESC		ddsd;
	D3DLOCKED_RECT		d3drc;

	g_pTexHeight->GetLevelDesc( 0, &ddsd );	// 텍스처의 정보
	g_cxHeight = ddsd.Width;				// 텍스처의 가로크기
	g_czHeight = ddsd.Height;				// 텍스처의 세로크기
	g_pLog->Log( "Texture Size:[%d,%d]", g_cxHeight, g_czHeight );
	g_pvHeightMap = new D3DXVECTOR3[g_cxHeight * g_czHeight];	// 높이맵배열 생성

	if ( FAILED( g_pd3dDevice->CreateVertexBuffer( ddsd.Width*ddsd.Height*sizeof( CUSTOMVERTEX ),
		0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
	{
		return E_FAIL;
	}

	// 텍스처 메모리 락!
	g_pTexHeight->LockRect( 0, &d3drc, NULL, D3DLOCK_READONLY );
    VOID* pVertices;
	// 정점버퍼 락!
	if ( FAILED( g_pVB->Lock( 0, g_cxHeight*g_czHeight*sizeof( CUSTOMVERTEX ), (void**)&pVertices, 0 ) ) )
	{
		return E_FAIL;
	}

	CUSTOMVERTEX	v;
	CUSTOMVERTEX*	pV = (CUSTOMVERTEX*)pVertices;
	for ( DWORD z = 0; z < g_czHeight; z++ )
	{
		for ( DWORD x = 0; x < g_cxHeight; x++ )
		{
			v.p.x = (float)x - g_cxHeight / 2.0f;		// 정점의 x좌표(메시를 원점에 정렬)
			v.p.z = -( (float)z - g_czHeight / 2.0f );	// 정점의 z좌표(메시를 원점에 정렬), z축이 모니터안쪽이므로 -를 곱한다.
			v.p.y = ( (float)( *( (LPDWORD)d3drc.pBits + x + z*( d3drc.Pitch / 4 ) ) & 0x000000ff ) ) / 10.0f;	/// DWORD이므로 pitch/4
			v.n.x = v.p.x;
			v.n.y = v.p.y;
			v.n.z = v.p.z;
			D3DXVec3Normalize( &v.n, &v.n );
			v.t.x = (float)x / ( g_cxHeight - 1 );
			v.t.y = (float)z / ( g_czHeight - 1 );
			*pV++ = v;									// 정점버퍼에 정점 저장
			g_pvHeightMap[z * g_cxHeight + x] = v.p;	// 높이맵에 정점 저장
		}
	}

    g_pVB->Unlock();
	g_pTexHeight->UnlockRect( 0 );

    return S_OK;
}
开发者ID:blastingzone,项目名称:ComputerGraphicsAdvenced,代码行数:56,代码来源:HeightMap.cpp

示例10: CreateTextureFromSurface

HRESULT VertexObject::CreateTextureFromSurface(LPDIRECT3DSURFACE9 pSurface, RECT* pSrcRect, RECT* pDestRect, LPDIRECT3DTEXTURE9* ppTexture)
{
	int width, height;
	RECT Src;
	D3DSURFACE_DESC surfDesc;
	pSurface->GetDesc(&surfDesc);

	if( !pSrcRect )
	{
		width = surfDesc.Width;
		height = surfDesc.Height;
		Src.left = Src.top = 0;
		Src.right = width;
		Src.bottom = height;
	}
	else
	{
		width = pSrcRect->right - pSrcRect->left; // + 1;
		height = pSrcRect->bottom - pSrcRect->top; // + 1;
		Src = *pSrcRect;
	}

	D3DXCreateTexture(DDevice, width, height, 
	1, 0, surfDesc.Format, D3DPOOL_DEFAULT, ppTexture) ;

	// Retrieve the surface image of the texture.
	LPDIRECT3DSURFACE9 pTexSurface;
	LPDIRECT3DTEXTURE9 pTexture = *ppTexture;
	pTexture->GetLevelDesc(0, &surfDesc);
	pTexture->GetSurfaceLevel(0, &pTexSurface);

	// Create a clean surface to clear the texture with.
	LPDIRECT3DSURFACE9 pCleanSurface;
	D3DLOCKED_RECT lockRect;
	DDevice->CreateOffscreenPlainSurface(
	surfDesc.Width, surfDesc.Height, surfDesc.Format, D3DPOOL_DEFAULT, &pCleanSurface, NULL);
	pCleanSurface->LockRect(&lockRect, NULL, 0) ;
	memset((BYTE*)lockRect.pBits, 0, surfDesc.Height * lockRect.Pitch);
	pCleanSurface->UnlockRect() ;

	DDevice->UpdateSurface(pCleanSurface, NULL, pTexSurface, NULL);
	pCleanSurface->Release();

	// Copy the image to the texture.
	POINT destPoint = { 0, 0 };
	DDevice->UpdateSurface(pSurface, &Src, pTexSurface, &destPoint);
	pTexSurface->Release();

	return S_OK;
}
开发者ID:vdoom,项目名称:GAM,代码行数:50,代码来源:VertexObject.cpp

示例11: SetTextures

// Set Source texture
HRESULT ScalingEffect::SetTextures(LPDIRECT3DTEXTURE9 lpSource, LPDIRECT3DTEXTURE9 lpWorking1,
			LPDIRECT3DTEXTURE9 lpWorking2, LPDIRECT3DVOLUMETEXTURE9 lpHq2xLookupTexture)
{
    if(!m_SourceTextureEffectHandle) {
	m_strErrors += "Texture with SOURCETEXTURE semantic not found";
	return E_FAIL;
    }

    HRESULT hr = m_pEffect->SetTexture(m_SourceTextureEffectHandle, lpSource);

    if(FAILED(hr)) {
	m_strErrors += "Unable to set SOURCETEXTURE";
	return hr;
    }

    

    D3DXVECTOR4 fDims(256,256,1,1), fTexelSize(1,1,1,1);

    if(lpSource) {
	D3DSURFACE_DESC Desc;
	lpSource->GetLevelDesc(0, &Desc);
	fDims[0] = (FLOAT) Desc.Width;
	fDims[1] = (FLOAT) Desc.Height;
    }

    fTexelSize[0] = 1/fDims[0];
    fTexelSize[1] = 1/fDims[1];

    if(m_SourceDimsEffectHandle) {
	hr = m_pEffect->SetVector(m_SourceDimsEffectHandle, &fDims);

	if(FAILED(hr)) {
	    m_strErrors += "Unable to set SOURCEDIMS";
	    return hr;
	}
    }

    if(m_TexelSizeEffectHandle) {
	hr = m_pEffect->SetVector(m_TexelSizeEffectHandle, &fTexelSize);

	if(FAILED(hr)) {
	    m_strErrors += "Unable to set TEXELSIZE";
	    return hr;
	}
    }

    return hr;
}
开发者ID:magicseb,项目名称:fbanext,代码行数:50,代码来源:ScalingEffect.cpp

示例12:

	virtual const char* lock_framebuffer( void *& buffer, unsigned & pitch )
	{
		if ( retry_count && !restore_objects() ) return "Lock failed";

		lptex->GetLevelDesc(0, &d3dsd);
		if ( lptex->GetSurfaceLevel(0, &lpsurface) != D3D_OK )
			return "Lock failed";

		if ( lpsurface->LockRect(&d3dlr, 0, flags.lock) != D3D_OK )
			return "Lock failed";
		buffer = d3dlr.pBits;
		pitch = d3dlr.Pitch;

		return buffer != 0 ? 0 : "Lock failed";
	}
开发者ID:kode54,项目名称:QuickNES_Windows,代码行数:15,代码来源:display_d3d9.cpp

示例13: AddTexture

// returns the index this texture is in class
int CNumberToSprite::AddTexture(IDirect3DDevice9* pd3dDevice, LPCWSTR numberFileName)
{
    HRESULT hr;
    LPDIRECT3DTEXTURE9 pTex;
    V( D3DXCreateTextureFromFile(pd3dDevice, numberFileName, &pTex) );

    // get length
    D3DSURFACE_DESC desc;
    V( pTex->GetLevelDesc(0, &desc) );

    m_vSpacing.push_back((float)desc.Width / m_nSYMBOLS);
    m_vpTex.push_back(pTex);

    return (int)(m_vpTex.size() - 1);
}
开发者ID:dimroc,项目名称:sunborn_igf,代码行数:16,代码来源:NumberToSprite.cpp

示例14: begin

//----[  begin  ]--------------------------------------------------------------
bool PreviewImageDialog::begin(Evidyon::Tools::CompleteEditor* editor,
                               Evidyon::Image::Tools::Image* image) {
  if (!image->loadD3DTexture(editor->getD3DDevice(), true)) return false;
  LPDIRECT3DTEXTURE9 texture = image->getD3DTexture();
  texture->GetLevelDesc(0, &desc);
  editor_ = editor;
  image_ = image;
  dcx::dcxWin32DialogTemplate dialog;
  dialog.setStyleAsResizeableAppWindow();
  dialog.setTitle("Image Preview");
  BYTE buffer[256];
  LPCDLGTEMPLATE dlg_template = dialog.compile(buffer, sizeof(buffer));
  dialog_handle_ = createDialog(GetModuleHandle(NULL),
                                dlg_template,
                                editor->topWindow());
  dcx::dcxWin32SetWindowClientSize(dialog_handle_, desc.Width, desc.Height);
  return editor->addD3DWindow(this);
}
开发者ID:karlgluck,项目名称:Evidyon,代码行数:19,代码来源:previewimagedialog.cpp

示例15: BlurTexture

//*************************************************************************************************************
void BlurTexture(LPDIRECT3DTEXTURE9 tex)
{
	LPDIRECT3DSURFACE9 surface = NULL;
	LPDIRECT3DSURFACE9 blursurface = NULL;
	LPDIRECT3DTEXTURE9 blurtex = NULL;

	D3DXVECTOR4 texelsize(1.0f / SHADOWMAP_SIZE, 0, 0, 0);
	D3DSURFACE_DESC desc;

	tex->GetLevelDesc(0, &desc);

	if( desc.Format == D3DFMT_A8R8G8B8 )
		blurtex = blurARGB8; // for convolution
	else
		blurtex = blurRGBA32F; // for others

	blurtex->GetSurfaceLevel(0, &blursurface);
	tex->GetSurfaceLevel(0, &surface);

	device->SetRenderTarget(0, blursurface);
	device->SetTexture(0, tex);
	device->SetVertexDeclaration(vertexdecl);

	boxblur5x5->SetVector("texelSize", &texelsize);

	boxblur5x5->Begin(NULL, 0);
	boxblur5x5->BeginPass(0);
	{
		device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, &vertices[0], 6 * sizeof(float));
		std::swap(texelsize.x, texelsize.y);

		boxblur5x5->SetVector("texelSize", &texelsize);
		boxblur5x5->CommitChanges();

		device->SetRenderTarget(0, surface);
		device->SetTexture(0, blurtex);
		device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, &vertices[0], 6 * sizeof(float));
	}
	boxblur5x5->EndPass();
	boxblur5x5->End();

	surface->Release();
	blursurface->Release();
}
开发者ID:IwishIcanFLighT,项目名称:Asylum_Tutorials,代码行数:45,代码来源:main.cpp


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