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


C++ LPDIRECT3DINDEXBUFFER9::Unlock方法代码示例

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


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

示例1: CreateIndexBuffer

		LPDIRECT3DINDEXBUFFER9 CreateIndexBuffer( LPDIRECT3DDEVICE9 device, OvByte* buffer, OvSize bufsize )
		{
			if ( device && buffer && bufsize )
			{
				LPDIRECT3DINDEXBUFFER9	streamBuffer = NULL;
				HRESULT hr = device->CreateIndexBuffer
					( bufsize
					, 0
					, D3DFMT_INDEX16
					, D3DPOOL_MANAGED
					, &streamBuffer
					, NULL
					);

				if ( SUCCEEDED(hr) && streamBuffer )
				{
					void* copyDest = NULL;
					if ( SUCCEEDED(streamBuffer->Lock( 0, bufsize, &copyDest, 0)) && copyDest)
					{
						memcpy( copyDest, buffer, bufsize );
						streamBuffer->Unlock();
						return streamBuffer;
					}
				}
			}
			return NULL;
		}
开发者ID:ultrano,项目名称:OliveEngine,代码行数:27,代码来源:OvUtility_d3dx9.cpp

示例2: GetDevice

LPDIRECT3DINDEXBUFFER9 OvRenderer::CreateIndexStream( void* buffer, UINT stride, UINT count )
{
	OvDevice device = GetDevice();
	if ( device )
	{
		LPDIRECT3DINDEXBUFFER9	streamBuffer = NULL;
		UINT streamSize = count * stride;
		HRESULT hr = device->CreateIndexBuffer
			( streamSize
			, 0
			, D3DFMT_INDEX16
			, D3DPOOL_MANAGED
			, &streamBuffer
			, NULL
			);

		if ( SUCCEEDED(hr) && streamBuffer )
		{
			void* copyDest = NULL;
			if ( SUCCEEDED(streamBuffer->Lock( 0, streamSize, &copyDest, 0)) && copyDest)
			{
				memcpy( copyDest, buffer, streamSize );
				streamBuffer->Unlock();
				return streamBuffer;
			}
		}
	}
	return NULL;

}
开发者ID:ultrano,项目名称:OliveEngine,代码行数:30,代码来源:OvRenderer.cpp

示例3: InitIB

/**-----------------------------------------------------------------------------
 * 인덱스 버퍼 초기화
 *------------------------------------------------------------------------------
 */
HRESULT InitIB()
{
    if( FAILED( g_pd3dDevice->CreateIndexBuffer( (g_cxHeight-1)*(g_czHeight-1)*2 * sizeof(MYINDEX), 0, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &g_pIB, NULL ) ) )
    {
        return E_FAIL;
    }

    MYINDEX		i;
    MYINDEX*	pI;
    if( FAILED( g_pIB->Lock( 0, (g_cxHeight-1)*(g_czHeight-1)*2 * sizeof(MYINDEX), (void**)&pI, 0 ) ) )
        return E_FAIL;

    for ( DWORD z = 0; z < g_czHeight - 1; z++ )
    {
        for ( DWORD x = 0; x < g_cxHeight - 1; x++ )
        {
            i._0 = static_cast<WORD>( z*g_cxHeight + x );
            i._1 = static_cast<WORD>( z*g_cxHeight + x + 1 );
            i._2 = static_cast<WORD>( ( z + 1 )*g_cxHeight + x );
            *pI++ = i;
            i._0 = static_cast<WORD>( ( z + 1 )*g_cxHeight + x );
            i._1 = static_cast<WORD>( z*g_cxHeight + x + 1 );
            i._2 = static_cast<WORD>( ( z + 1 )*g_cxHeight + x + 1 );
            *pI++ = i;
        }
    }
    g_pIB->Unlock();

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

示例4: ComputeNormalVector

bool CEntity::ComputeNormalVector(
	LPD3DXMESH _pMesh, D3DXVECTOR3& _vNormal, D3DXVECTOR3& _vCol, CEntity* target)
{
	BOOL isHit = false;
	DWORD dwFaceIndex = 0;
	float fDist = 0;
	LPD3DXBUFFER ppAllhit;
	DWORD pCountOfHits;
	
	D3DXVECTOR3 vPos = m_vPos - target->GetPos();
	D3DXVECTOR3 vtar = (-vPos);
	D3DXVec3Normalize( &vtar, &vtar);

	D3DXIntersect( _pMesh, &vPos, &vtar, &isHit, 
		&dwFaceIndex, NULL, NULL, &fDist, &ppAllhit, &pCountOfHits );

	if ( !isHit || fDist > GetSize()  )
		return false;// Ãæµ¹ÀÌ ¾È‰ç°Å³ª °Å¸®°¡ ¸Ö´Ù¸é ¸®ÅÏ;

	LPDIRECT3DVERTEXBUFFER9 pVB; 
	LPDIRECT3DINDEXBUFFER9 pIB; 

	_pMesh->GetVertexBuffer(&pVB); 
	_pMesh->GetIndexBuffer( &pIB ); 

	WORD* pIndices; 
	D3DVERTEX* pVertices; 

	pIB->Lock( 0, 0, (void**)&pIndices, 0 ); 
	pVB->Lock( 0, 0,(void**)&pVertices, 0); 

	D3DXVECTOR3 v0 = pVertices[pIndices[3*dwFaceIndex+0]].vPos; 
	D3DXVECTOR3 v1 = pVertices[pIndices[3*dwFaceIndex+1]].vPos; 
	D3DXVECTOR3 v2 = pVertices[pIndices[3*dwFaceIndex+2]].vPos; 
	
	D3DXPLANE plane;
	
	D3DXPlaneFromPoints( &plane, &v0, &v1, &v2);
	
	_vCol = (v0 + v1 + v2)/3.f;
	_vCol += target->GetPos();

	_vNormal.x = plane.a;
	_vNormal.y = plane.b;
	_vNormal.z = plane.c;
	
#ifdef _DEBUG
	//Ãæµ¹ÁöÁ¡ Ç¥½Ã
	_SINGLE(CDebug)->AddPosMark( _vCol, COLOR_BLACK);
#endif
	
	pVB->Unlock(); 
	pIB->Unlock(); 
	Safe_Release(pVB); 
	Safe_Release(pIB); 

	return true;
}
开发者ID:qiomoip,项目名称:space-express,代码行数:58,代码来源:Entity.cpp

示例5: ComputeNormals

void ComputeNormals(LPDIRECT3DVERTEXBUFFER9 vtxBuff, int vtxSize,  LPDIRECT3DINDEXBUFFER9 idxBuff, int faceSize)
{
	Vertex* vertices;
	vtxBuff->Lock( 0, sizeof(Vertex), (void**)&vertices, 0);
	WORD *indices = NULL;
	idxBuff->Lock(0, 0, (void**)&indices, 0);

	for (int i=0; i < faceSize*3; i+=3)
	{
		Vector3 p1 = vertices[ indices[ i]].p;
		Vector3 p2 = vertices[ indices[ i+1]].p;
		Vector3 p3 = vertices[ indices[ i+2]].p;

		Vector3 v1 = p2 - p1;
		Vector3 v2 = p3 - p1;
		v1.Normalize();
		v2.Normalize();
		Vector3 n = v1.CrossProduct(v2);
		n.Normalize();

		if (vertices[ indices[ i]].n.IsEmpty())
		{
			vertices[ indices[ i]].n = n;
		}
		else
		{
			vertices[ indices[ i]].n += n;
			vertices[ indices[ i]].n /= 2.f;
		}

		if (vertices[ indices[ i+1]].n.IsEmpty())
		{
			vertices[ indices[ i+1]].n = n;
		}
		else
		{
			vertices[ indices[ i+1]].n += n;
			vertices[ indices[ i+1]].n /= 2.f;
		}

		if (vertices[ indices[ i+2]].n.IsEmpty())
		{
			vertices[ indices[ i+2]].n = n;
		}
		else
		{
			vertices[ indices[ i+2]].n += n;
			vertices[ indices[ i+2]].n /= 2.f;
		}
	}

	vtxBuff->Unlock();
	idxBuff->Unlock();
}
开发者ID:butilities,项目名称:3D-Lecture-2,代码行数:54,代码来源:Target.cpp

示例6: CreateOctree

void GdsNode::CreateOctree()
{
	RENDER_OBJECT_CONTAINER::iterator it = m_list_RenderObject.begin();
	for ( ; it != m_list_RenderObject.end() ; ++it )
	{
		VOID* pVB;
		GdsRenderObject* rendertoken = it->first;
		LPDIRECT3DVERTEXBUFFER9 vb = rendertoken->GetVertexBuffer();
		if (  SUCCEEDED( vb->Lock( 0 , rendertoken->GetVertexMaxCount() * sizeof( GDSVERTEX ) , (void**)&pVB , 0 ) ) )
		{
			D3DXVECTOR3 minPos( 0,0,0 );
			D3DXVECTOR3 maxPos( 0,0,0 );
			for ( int i=0 ; i < rendertoken->GetVertexMaxCount() ; i++ )
			{				
				GDSVERTEX* v = (GDSVERTEX*)pVB + i;

				if ( minPos.x > v->p.x )
					minPos.x = v->p.x;

				if ( minPos.y > v->p.y )
					minPos.y = v->p.y;

				if ( minPos.z > v->p.z )
					minPos.z = v->p.z;

				if ( maxPos.x < v->p.x )
					maxPos.x = v->p.x;
				if ( maxPos.y < v->p.y )
					maxPos.y = v->p.y;
				if ( maxPos.z < v->p.z )
					maxPos.z = v->p.z;
			}

			m_pOctreeRootNode = NULL;
			m_pVert = (GDSVERTEX*)pVB;
			if ( m_pOctreeRootNode == NULL )
				m_pOctreeRootNode = new Node( rendertoken->GetIndexMaxCount() , minPos , maxPos );

			VOID* pI;
			LPDIRECT3DINDEXBUFFER9 pIB = rendertoken->GetIndexBuffer();
			pIB->Lock( 0 , rendertoken->GetIndexMaxCount() * sizeof( GDSINDEX ) , (void**)&pI , 0 );
			memcpy( m_pOctreeRootNode->m_pFace , pI , sizeof( GDSINDEX ) * rendertoken->GetIndexMaxCount() );
			pIB->Unlock();
			m_pOctreeRootNode->m_iNumOfChild = 0;	

			build( m_pOctreeRootNode );
			
		}		
		vb->Unlock();
	}

	m_bUseOctree = true;
	m_iCountOfOctreeNode = 0;
}
开发者ID:rodrigobmg,项目名称:choding,代码行数:54,代码来源:GdsNode.cpp

示例7: Draw

void cSubDivSurf::Draw( matrix4& mat )
{
	LPDIRECT3DDEVICE9 lpDevice = Graphics()->GetDevice();
	Graphics()->SetWorldMatrix( mat );

	HRESULT hr;

	// The index buffer
	LPDIRECT3DINDEXBUFFER9 pIndexBuffer = 0;

	// Create the index buffer
	lpDevice->CreateIndexBuffer(
		m_nTris * 3 * sizeof( WORD ),	// Size in bytes of buffer
		D3DUSAGE_WRITEONLY,				// Will only be writing to the buffer
		D3DFMT_INDEX16,					// 16 bit indices
		D3DPOOL_DEFAULT,				// Default memory pooling
		&pIndexBuffer,					// Address of the buffer pointer
		NULL );							// Reserved. set to NULL

	// Pointer to the index buffer data
	WORD* pData = 0;

	// Lock the index buffer
	pIndexBuffer->Lock( 0, 0, (void**)&pData, 0 );

	// Copy the index data into the index buffer
	CopyMemory( pData, m_d3dTriList, m_nTris * 3 * sizeof( WORD ) );

	// Unlock the index buffer
	pIndexBuffer->Unlock();

	// Tell Direct3D to use the index buffer
	lpDevice->SetIndices( pIndexBuffer );
	
	// Attach the vertex buffer to rendering stream 0
	lpDevice->SetStreamSource( 0, m_pVertexBuffer, 0, sizeof( sVertex ) );

	// Draw the primitive
	hr = lpDevice->DrawIndexedPrimitive(
		D3DPT_TRIANGLELIST,
		0,
		0,
		m_nVerts,
		0,
		m_nTris );

	if( FAILED( hr ) )
	{
		DP0("[cSubDivSurf::Draw]: DrawIndexedPrimitive failed!\n");
	}

	pIndexBuffer->Release();
}
开发者ID:amitahire,项目名称:development,代码行数:53,代码来源:SubDivSurf.cpp

示例8: ObjectInit

/************************************************************************
* Objects such as vertex buffer, index buffer, fonts are initialized here
************************************************************************/
bool ObjectInit(HWND hwnd)
{

	PlaySound(_T("阿兰 - 浴火重生.wav"), nullptr, SND_ASYNC | SND_FILENAME | SND_LOOP);
	srand(unsigned(time(NULL)));

	D3DXCreateFont(gPD3DDevice, 40, 0, 0, 0, 0, 0, 0, 0, 0, _T("楷体"), &gPFont);

	//////////////////////////////////////////////////////////////////////////
	// Fill in the vertex struct  
	//////////////////////////////////////////////////////////////////////////
	CUSTOM_VERTEX vertices[17];
	vertices[0].x = 400.0f;
	vertices[0].y = 300.0f;
	vertices[0].z = 0.0f;
	vertices[0].rhw = 1.0f;
	vertices[0].color = D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256);
	for (int i = 1; i < 17; i++)
	{
		vertices[i].x = gRadius*cos(PI*(i - 1)/ 8) + vertices[0].x;
		vertices[i].y = gRadius*sin(PI*(i - 1)/ 8) + vertices[0].y;
		vertices[i].z = 0.0f;
		vertices[i].rhw = 1.0f;
		vertices[i].color = D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256);
	}

	gPD3DDevice->CreateVertexBuffer(17 * sizeof(CUSTOM_VERTEX), 0, D3DFVF_CUSTOM_VERTEX, D3DPOOL_DEFAULT,
		&gPVertexBuffer, nullptr);
	void* pVertices{0};
	gPVertexBuffer->Lock(0, 17 * sizeof(CUSTOM_VERTEX), (void**)&pVertices, 0);
	memcpy(pVertices, vertices, 17 * sizeof(CUSTOM_VERTEX));
	gPVertexBuffer->Unlock();

    //////////////////////////////////////////////////////////////////////////
    // Fill in the index struct  
    //////////////////////////////////////////////////////////////////////////	
	int indexes[48];
	for (int i = 0; i < 16; i++)
	{
		indexes[i * 3] = 0;
		indexes[i * 3 + 1] = i + 1;
		indexes[i * 3 + 2] = i + 2;
	}
	indexes[47] = 1;
	
	gPD3DDevice->CreateIndexBuffer(48 * sizeof(int), 0, D3DFMT_INDEX32, D3DPOOL_DEFAULT, &gPIndexBuffer, nullptr);
	int* pIndexes{0};
	gPIndexBuffer->Lock(0, 0, (void**)&pIndexes, 0);
	memcpy(pIndexes, indexes, 48 * sizeof(int));
	gPIndexBuffer->Unlock();

	return true;
}
开发者ID:wakqaz4,项目名称:MyGame,代码行数:56,代码来源:main.cpp

示例9: init_graphics

// this is the function that puts the 3D models into video RAM
void init_graphics(void)
{   
    // create a vertex buffer interface called v_buffer
    d3ddev->CreateVertexBuffer(g_Sim.numPoints()*sizeof(CUSTOMVERTEX),
                               D3DUSAGE_WRITEONLY,
                               CUSTOMFVF,
                               D3DPOOL_MANAGED,
                               &v_buffer,
                               NULL);
	d3ddev->CreateVertexBuffer(5*sizeof(CUSTOMVERTEX),
		                       D3DUSAGE_WRITEONLY,
							   CUSTOMFVF,
							   D3DPOOL_MANAGED,
							   &v_bordbuffer,
							   NULL);
	d3ddev->CreateIndexBuffer(g_Sim.numConstraints() * 2 * sizeof(short),
							  D3DUSAGE_WRITEONLY,
							  D3DFMT_INDEX16,
							  D3DPOOL_MANAGED,
							  &i_buffer,
							  NULL);


	HRESULT hr = D3DXCreateFont(d3ddev, 17, 0, FW_NORMAL, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Courier New"), &font );

	CUSTOMVERTEX* verts;
	v_bordbuffer->Lock(0, 0, (void**)&verts, 0);
	verts[0].X = MINX;
	verts[0].Y = MINY;
	verts[1].X = MINX;
	verts[1].Y = MAXY;
	verts[2].X = MAXX;
	verts[2].Y = MAXY;
	verts[3].X = MAXX;
	verts[3].Y = MINY;
	verts[4].X = MINX;
	verts[4].Y = MINY;

	verts[0].Z = verts[1].Z = verts[2].Z = verts[3].Z = verts[4].Z = 0.0f;
	verts[0].COLOR = verts[1].COLOR = verts[2].COLOR = verts[3].COLOR = verts[4].COLOR = D3DCOLOR_XRGB(127, 127, 127);
	v_bordbuffer->Unlock();

    short* indices;
    i_buffer->Lock(0, 0, (void**)&indices, 0);
	for (unsigned i = 0; i < g_Sim.numConstraints(); i++) {
		const std::pair<unsigned, unsigned>& p = g_Sim.constraint(i);
		indices[2 * i] = p.first;
		indices[2 * i + 1] = p.second;
	}
    i_buffer->Unlock();

}
开发者ID:m3lawren,项目名称:ClothDemo,代码行数:53,代码来源:main.cpp

示例10: ProcessFrustumCull

/**-----------------------------------------------------------------------------
 * Frustum Culling을 사용해서 그려질 인덱스 생성
 *------------------------------------------------------------------------------
 */
HRESULT ProcessFrustumCull()
{
	DWORD		i[4];	// 임시로 저장할 인덱스 정보
	BOOL		b[4];	// 임시로 저장할 frustum culling결과값
	MYINDEX		idx;
    MYINDEX*	pI;

	if ( FAILED( g_pIB->Lock( 0, ( g_cxHeight - 1 )*( g_czHeight - 1 ) * 2 * sizeof( MYINDEX ), (void**)&pI, 0 ) ) )
	{
		return E_FAIL;
	}

	g_nTriangles = 0;

	for( DWORD z = 0 ; z < g_czHeight-1 ; z++ )
	{
		for( DWORD x = 0 ; x < g_cxHeight-1 ; x++ )
		{
			i[0] = (z*g_cxHeight+x);			// 좌측 상단
			i[1] = (z*g_cxHeight+x+1);			// 우측 상단
			i[2] = ((z+1)*g_cxHeight+x);		// 좌측 하단
			i[3] = ((z+1)*g_cxHeight+x+1);		// 우측 하단

			b[0] = g_pFrustum->IsIn( &g_pvHeightMap[ i[0] ] );	// 좌측상단 정점이 Frustum안에 있는가?
			b[1] = g_pFrustum->IsIn( &g_pvHeightMap[ i[1] ] );	// 우측상단 정점이 Frustum안에 있는가?
			b[2] = g_pFrustum->IsIn( &g_pvHeightMap[ i[2] ] );	// 좌측하단 정점이 Frustum안에 있는가?
			if ( b[0] | b[1] | b[2] )	// 셋중에 하나라도 frustum안에 있으면 렌더링한다.
			{
				idx._0 = static_cast<WORD>( i[0] );
				idx._1 = static_cast<WORD>( i[1] );
				idx._2 = static_cast<WORD>( i[2] );
				*pI++ = idx;
				g_nTriangles++;			// 렌더링할 삼각형 개수 증가
			}

			b[2] = g_pFrustum->IsIn( &g_pvHeightMap[ i[2] ] );	// 좌측하단 정점이 Frustum안에 있는가?
			b[1] = g_pFrustum->IsIn( &g_pvHeightMap[ i[1] ] );	// 우측상단 정점이 Frustum안에 있는가?
			b[3] = g_pFrustum->IsIn( &g_pvHeightMap[ i[3] ] );	// 우측하단 정점이 Frustum안에 있는가?
			if ( b[2] | b[1] | b[3] )	// 셋중에 하나라도 frustum안에 있으면 렌더링한다.
			{
				idx._0 = static_cast<WORD>( i[2] );
				idx._1 = static_cast<WORD>( i[1] );
				idx._2 = static_cast<WORD>( i[3] );
				*pI++ = idx;
				g_nTriangles++;
			}
		}
	}
    g_pIB->Unlock();

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

示例11:

HRESULT	CameraWorkBase::SetIB( LPDIRECT3DINDEXBUFFER9 _pIB, LPVOID _indices, INT _nIndex, INT _Size )
{
	LPVOID pIndices;
	if( FAILED( _pIB->Lock( 0, _nIndex * _Size, (VOID**)&pIndices, 0 ) ) )
	{
		MessageBox( NULL, L"CameraWorkBase::m_pIB->Lock() failed.", NULL, MB_OK );
		return E_FAIL;
	}
	
		memcpy( pIndices, _indices, _nIndex * _Size );

	_pIB->Unlock();

	return S_OK;
}
开发者ID:yoonhada,项目名称:nlinelast,代码行数:15,代码来源:CameraWorkBase.cpp

示例12: ConvertVertex

//===============================================
//頂点情報のコンバート
//===============================================
//[input]
//	pD3DX9:Direct3Dデバイス
//[return]
//	HREULT値
//===============================================
bool CXMesh::ConvertVertex(LPDIRECT3DDEVICE9 pD3DX9)
{
    LPD3DXBUFFER pD3DXMtrlBuffer = NULL;

	/*Vertex Bufferにコピーする*/
	D3DVERTEX* pSrc;
	D3DVERTEX* pDest;
	LPDIRECT3DINDEXBUFFER9 pSrcIndex;
	WORD* pISrc;
	WORD* pIDest;

	/*VertexBuffer情報取得*/
	LPDIRECT3DVERTEXBUFFER9 pVB;
	MeshData.pMesh->GetVertexBuffer(&pVB);

	D3DVERTEXBUFFER_DESC	Desc;
	pVB->GetDesc( &Desc );

	DWORD nMeshVertices	= MeshData.pMesh->GetNumVertices();
	DWORD nMeshFaces	= MeshData.pMesh->GetNumFaces();

	/*頂点バッファを作成*/
	pD3DX9->CreateVertexBuffer( Desc.Size, 0, MeshData.pMesh->GetFVF(), D3DPOOL_MANAGED, &m_pMeshVB, NULL );

	/*インデックスバッファを作成*/
	pD3DX9->CreateIndexBuffer( nMeshFaces * 3 * sizeof(WORD), 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &m_pMeshIndex, NULL );

	/*頂点バッファをコピー*/
	pVB->Lock(0,0,(void**)&pSrc,0);
	m_pMeshVB->Lock(0,0,(void**)&pDest,0);
	CopyMemory( pDest, pSrc, Desc.Size );

	pVB->Unlock();
	pVB->Release();
	m_pMeshVB->Unlock();

	/*インデックスのコピー*/
	MeshData.pMesh->GetIndexBuffer( &pSrcIndex );
	pSrcIndex->Lock( 0, 0, (void**)&pISrc, 0 );
	m_pMeshIndex->Lock( 0, 0, (void**)&pIDest, 0 );
	CopyMemory( pIDest, pISrc, nMeshFaces * 3 * sizeof( WORD ) );

	pSrcIndex->Unlock();
	m_pMeshIndex->Unlock();
	pSrcIndex->Release();

    return true;
}
开发者ID:Taka03,项目名称:Procon2007,代码行数:56,代码来源:CXMesh.cpp

示例13: LoadMesh

    void LoadMesh(const PMDLoader::DATA *_data)
    {
        LPDIRECT3DDEVICE9 device = DirectX9::Instance().Device;
        HRESULT hr;

        // 頂点バッファの作成
        m_MaxVertex = _data->vert_count.u;
        hr = device->CreateVertexBuffer(
            sizeof(Vertex3D::VERTEX) * _data->vert_count.u,
            D3DUSAGE_WRITEONLY,                // 頂点バッファの使用方法
            Vertex3D::FVF,                     // 使用する頂点フォーマット
            D3DPOOL_MANAGED,                   // バッファを保持するメモリクエストを指定
            &m_VertexBuffer,                   // 頂点のバッファの先頭アドレス
            NULL );

        Vertex3D::VERTEX *vtx;
        hr = m_VertexBuffer->Lock(0,0,(void**)&vtx,0);
        for( unsigned int i = 0; i < _data->vert_count.u ; i++)
        {
            vtx[i].pos.x =   _data->vertex[i].pos[0].f;
            vtx[i].pos.y =   _data->vertex[i].pos[1].f;
            vtx[i].pos.z =  -_data->vertex[i].pos[2].f;
            vtx[i].nor.x =  _data->vertex[i].normal_vec[0].f;
            vtx[i].nor.y =  _data->vertex[i].normal_vec[1].f;
            vtx[i].nor.z = -_data->vertex[i].normal_vec[2].f;
            vtx[i].tex.x =  _data->vertex[i].uv[0].f;
            vtx[i].tex.y =  _data->vertex[i].uv[1].f;
        }
        hr = m_VertexBuffer->Unlock();

        // インデックスバッファの作成
        m_MaxIndex = _data->face_vert_count.u;
        hr = device->CreateIndexBuffer(
            sizeof( WORD ) * m_MaxIndex,    // バッファサイズ
            D3DUSAGE_WRITEONLY,             // 頂点バッファの使用方法
            D3DFMT_INDEX16,                 // 使用する頂点フォーマット
            D3DPOOL_MANAGED,                // バッファを保持するメモリクエストを指定
            &m_IndexBuffer,                 // 頂点インデックスのバッファの先頭アドレス
            NULL );

        WORD *idx;
        hr = m_IndexBuffer->Lock(0,0,(void**)&idx,0);
        for( unsigned int i=0; i < _data->face_vert_count.u ; i++)
        {
            idx[i] = _data->face_vert_index[i].u;
        }
        hr = m_IndexBuffer->Unlock();
    }
开发者ID:AyumiYasui,项目名称:Material,代码行数:48,代码来源:PMDNoBoneManagerDx9.cpp

示例14: D3DQuads_OnRecover

void D3DQuads_OnRecover (void)
{
	if (!d3d_QuadBuffer)
	{
		D3DMain_CreateVertexBuffer (D3D_MAX_QUADS * 4 * sizeof (quadvert_t), D3DUSAGE_DYNAMIC, &d3d_QuadBuffer);
		d3d_NumQuads = 0;
	}

	if (!d3d_QuadIndexes)
	{
		unsigned short *ndx = NULL;

		D3DMain_CreateIndexBuffer16 (D3D_MAX_QUADS * 6, 0, &d3d_QuadIndexes);
		d3d_QuadIndexes->Lock (0, 0, (void **) &ndx, d3d_GlobalCaps.DefaultLock);

		// strips?  go hang yer bollocks on them.  with a 4-entry vertex cache this is just fine
		for (int i = 0, v = 0; i < D3D_MAX_QUADS; i++, v += 4, ndx += 6)
		{
			ndx[0] = v + 0;
			ndx[1] = v + 1;
			ndx[2] = v + 2;
			ndx[3] = v + 0;
			ndx[4] = v + 2;
			ndx[5] = v + 3;
		}

		d3d_QuadIndexes->Unlock ();
		d3d_RenderDef.numlock++;
	}

	if (!d3d_QuadDecl)
	{
		D3DVERTEXELEMENT9 d3d_quadlayout[] =
		{
			VDECL (0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0),
			VDECL (0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0),
			VDECL (0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0),
			D3DDECL_END ()
		};

		hr = d3d_Device->CreateVertexDeclaration (d3d_quadlayout, &d3d_QuadDecl);
		if (FAILED (hr)) Sys_Error ("D3DQuads_OnRecover: d3d_Device->CreateVertexDeclaration failed");
	}
}
开发者ID:AAS,项目名称:directq,代码行数:44,代码来源:d3d_Quads.cpp

示例15: ChangeObject

void ChangeObject(void)
{
	//顶点数据  
	CUSTOMVERTEX vertices[] =
	{
		{ -20.0f, 20.0f, -20.0f, D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256) },
		{ -20.0f, 20.0f, 20.0f, D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256) },
		{ 20.0f, 20.0f, 20.0f, D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256) },
		{ 20.0f, 20.0f, -20.0f, D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256) },
		{ -20.0f, -20.0f, -20.0f, D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256) },
		{ -20.0f, -20.0f, 20.0f, D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256) },
		{ 20.0f, -20.0f, 20.0f, D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256) },
		{ 20.0f, -20.0f, -20.0f, D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256) }
	};

	VOID * pVertics = 0;
	g_pVertexBuffer->Lock(0, sizeof(vertices), (void**)&pVertics, 0);
	memcpy(pVertics, vertices, sizeof(vertices));
	g_pVertexBuffer->Unlock();

	// 填充索引数据  
	WORD *pIndices = NULL;
	g_pIndexBuffer->Lock(0, 0, (void**)&pIndices, 0);
	// 顶面  
	pIndices[0] = 0, pIndices[1] = 1, pIndices[2] = 2;
	pIndices[3] = 0, pIndices[4] = 2, pIndices[5] = 3;
	// 正面  
	pIndices[6] = 0, pIndices[7] = 3, pIndices[8] = 7;
	pIndices[9] = 0, pIndices[10] = 7, pIndices[11] = 4;
	// 左侧面  
	pIndices[12] = 0, pIndices[13] = 4, pIndices[14] = 5;
	pIndices[15] = 0, pIndices[16] = 5, pIndices[17] = 1;
	// 右侧面  
	pIndices[18] = 2, pIndices[19] = 6, pIndices[20] = 7;
	pIndices[21] = 2, pIndices[22] = 7, pIndices[23] = 3;
	// 背面  
	pIndices[24] = 2, pIndices[25] = 5, pIndices[26] = 6;
	pIndices[27] = 2, pIndices[28] = 1, pIndices[29] = 5;
	// 底面  
	pIndices[30] = 4, pIndices[31] = 6, pIndices[32] = 5;
	pIndices[33] = 4, pIndices[34] = 7, pIndices[35] = 6;
	g_pIndexBuffer->Unlock();
}
开发者ID:liyongfa,项目名称:DirectX,代码行数:43,代码来源:demo1.cpp


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