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


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

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


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

示例1: initVertexData

void initVertexData()
{
	size_t count = partCount;
	VertexData *vertexData = new VertexData[count];

	for(size_t i = 0; i < count; ++i)
	{
		vertexData[i].x = particlesCoord[i].x;
		vertexData[i].y = particlesCoord[i].y;
		vertexData[i].z = 0.f;
		vertexData[i].u = 0;
		vertexData[i].v = 0;
	}

	void *pRectBuffer = NULL;
	device->CreateVertexBuffer(count*sizeof(VertexData), D3DUSAGE_WRITEONLY,
		D3DFVF_XYZ | D3DFVF_TEX0, D3DPOOL_DEFAULT, &pVertexObject, NULL);

	pVertexObject->Lock(0, count*sizeof(VertexData), &pRectBuffer, 0);

	memcpy(pRectBuffer, vertexData, count*sizeof(VertexData));
	pVertexObject->Unlock();

	delete[] vertexData;
	vertexData = nullptr;

	D3DVERTEXELEMENT9 decl[] =
	{
		{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
		{ 0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
		D3DDECL_END()
	};

	device->CreateVertexDeclaration(decl, &vertexDecl);
}
开发者ID:DrA1ex,项目名称:ParticleSystem,代码行数:35,代码来源:RenderToTexture.cpp

示例2: InitVB

// Prepare quad data, we build up a quad by combine two triangles
HRESULT InitVB()
{
	// Initialize three Vertices for rendering a triangle
	ScreenVertex Vertices[] =
	{
		{ 50.0f, 100.0f, 0.0f, 1.0f, 0xffff0000}, // 0
		{100.0f,  50.0f, 0.0f, 1.0f, 0xffff0000}, // 1
		{150.0f, 100.0f, 0.0f, 1.0f, 0xffff0000}, // 2
		{200.0f,  50.0f, 0.0f, 1.0f, 0xffff0000}, // 3
		{250.0f, 100.0f, 0.0f, 1.0f, 0xffff0000}, // 4
		{300.0f,  50.0f, 0.0f, 1.0f, 0xffff0000}, // 5
	};

	if( FAILED( g_pd3dDevice->CreateVertexBuffer( 8* sizeof( ScreenVertex ),
		0, SCREEN_SPACE_FVF,
		D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
	{
		return E_FAIL;
	}

	VOID* pVertices;
	if( FAILED( g_pVB->Lock( 0, sizeof( Vertices ), ( void** )&pVertices, 0 ) ) )
		return E_FAIL;
	memcpy( pVertices, Vertices, sizeof( Vertices ) );
	g_pVB->Unlock();

	return S_OK;
}
开发者ID:BillyKim,项目名称:directxcode,代码行数:29,代码来源:CullMode.cpp

示例3: InitGeometry

//-----------------------------------------------------------------------------
// Name: InitGeometry()
// Desc: Creates the scene geometry
//-----------------------------------------------------------------------------
HRESULT InitGeometry()
{
	// Initialize three vertices for rendering a triangle
	CUSTOMVERTEX g_Vertices[] =
	{
		{ -1.0f,-1.0f, 0.0f, 0xffff0000, },
		{  1.0f,-1.0f, 0.0f, 0xff0000ff, },
		{  0.0f, 1.0f, 0.0f, 0xffffffff, },
	};

	// Create the vertex buffer.
	if( FAILED( g_pd3dDevice->CreateVertexBuffer( 3*sizeof(CUSTOMVERTEX),
		0, D3DFVF_CUSTOMVERTEX,
		D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
	{
		return E_FAIL;
	}

	// Fill the vertex buffer.
	VOID* pVertices;
	if( FAILED( g_pVB->Lock( 0, sizeof(g_Vertices), (void**)&pVertices, 0 ) ) )
		return E_FAIL;
	memcpy( pVertices, g_Vertices, sizeof(g_Vertices) );
	g_pVB->Unlock();

	return S_OK;
}
开发者ID:rtmpnewbie,项目名称:lai3d,代码行数:31,代码来源:Matrices.cpp

示例4: InitGeometry

//-----------------------------------------------------------------------------
// Desc: 创建场景图形
//-----------------------------------------------------------------------------
HRESULT InitGeometry()
{
	//创顶点缓冲区
	if( FAILED( g_pd3dDevice->CreateVertexBuffer( 50*2*sizeof(CUSTOMVERTEX),
		0, D3DFVF_CUSTOMVERTEX,
		D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
	{
		return E_FAIL;
	}

	//填充顶点缓冲区
	CUSTOMVERTEX* pVertices;
	if( FAILED( g_pVB->Lock( 0, 0, (void**)&pVertices, 0 ) ) )
		return E_FAIL;
	for( DWORD i=0; i<50; i++ )
	{
		FLOAT theta = (2*D3DX_PI*i)/(50-1);
		pVertices[2*i+0].position = D3DXVECTOR3( sinf(theta),-1.0f, cosf(theta) );
		pVertices[2*i+0].normal   = D3DXVECTOR3( sinf(theta), 0.0f, cosf(theta) );
		pVertices[2*i+1].position = D3DXVECTOR3( sinf(theta), 1.0f, cosf(theta) );
		pVertices[2*i+1].normal   = D3DXVECTOR3( sinf(theta), 0.0f, cosf(theta) );
	}
	g_pVB->Unlock();

	return S_OK;
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:29,代码来源:Multilights.cpp

示例5: CalculateShades

//-----------------------------------------------------------------------------
// Name: CalculateShades()
// Desc: Calculates shades of vertices depending on current time and background color
//-----------------------------------------------------------------------------
void CalculateShades()
{
    float cost = (float)cos(timeGetTime()/2000.0f - g_StartTime);

    static BYTE btRed1, btGrn1, btBlu1;
    static BYTE btRed2, btGrn2, btBlu2;

    CUSTOMVERTEX* pVertices = 0;
    if ( SUCCEEDED( g_pVB->Lock( 0, 0, (void**)&pVertices, 0 ) ) )
    {
        {
            btRed1 = (BYTE)(((0xFF-bkRed)*cost + (0xFF+bkRed))/2);
            btGrn1 = (BYTE)(((0xFF-bkGrn)*cost + (0xFF+bkGrn))/2);
            btBlu1 = (BYTE)(((0xFF-bkBlu)*cost + (0xFF+bkBlu))/2);
        }

        {
            btRed2 = (BYTE)(((bkRed-0xFF)*cost + (0xFF+bkRed))/2);
            btGrn2 = (BYTE)(((bkGrn-0xFF)*cost + (0xFF+bkGrn))/2);
            btBlu2 = (BYTE)(((bkBlu-0xFF)*cost + (0xFF+bkBlu))/2);
        }

        for( DWORD i=0; i<nGrid; i++ )
        {
            pVertices[2*i+0].color    = D3DCOLOR_XRGB(btRed1, btGrn1, btBlu1);
            pVertices[2*i+1].color    = D3DCOLOR_XRGB(btRed2, btGrn2, btBlu2);
        }
        g_pVB->Unlock();
    }
}
开发者ID:chinajeffery,项目名称:dx_sdk,代码行数:34,代码来源:Textures.cpp

示例6: InitVB

// Prepare vertex buffer
void InitVB()
{
	Vertex Quad[] = 
	{
		{-2.0f,  2.0f, 0,    0,    0},	
		{ 2.0f,  2.0f, 0, 3.0f,    0},	// repeat 3 times on x and y
		{-2.0f, -2.0f, 0,    0, 3.0f},	
		{ 2.0f, -2.0f, 0, 3.0f, 3.0f},	

		// scale effect
		/*{-2.0f,  2.0f, 0,    0,    0},	
		{ 2.0f,  2.0f, 0, 0.5f,    0},	
		{-2.0f, -2.0f, 0,    0, 0.5f},	
		{ 2.0f, -2.0f, 0, 0.5f, 0.5f},*/
	} ;

	// Create vertex buffer
	HRESULT hr ;
	hr = g_pd3dDevice->CreateVertexBuffer(4 * sizeof(Vertex), D3DUSAGE_WRITEONLY, 
		VertexFVF, D3DPOOL_MANAGED, &g_pVB, NULL) ;
	if (FAILED(hr))
	{
		MessageBoxA(NULL, "Create vertex buffer failed!", "Error", 0) ;
	}

	// Copy data
	Vertex* v ;
	g_pVB->Lock(0, 0, (void**)&v, 0) ;
	memcpy(v, Quad, 4 * sizeof(Vertex)) ;
	g_pVB->Unlock() ;
}
开发者ID:BillyKim,项目名称:directxcode,代码行数:32,代码来源:AddressingMode.cpp

示例7: SetTexturePlaybar

void SetTexturePlaybar(	int nIdx,					//记录当前对应的图组地址
						int nPatternAnim,			//记录当前显示帧
						int numAnimPattern, 		//记录当前对应的组成图组的图片数量
						int texPatternDivideX,		//记录当前图组X轴图片数量
						int texPatternDivideY )		//记录当前图组Y轴图片数量
{
	{//頂点バッファの中身を埋める
		VERTEX_2D *pVtx;
		float fPosXLeft, fPosXRight;
		float fPosYUp, fPosYDown;

		// 頂点データの範囲をロックし、頂点バッファへのポインタを取得
		g_pD3DVtxBuffPlaybar->Lock(0, 0, (void**)&pVtx, 0);

		pVtx += (nIdx * 4);

		// テクスチャ座標の設定 纹理坐标设定
		fPosXLeft = (float)(nPatternAnim % texPatternDivideX) * 1.0f / texPatternDivideX;
		fPosXRight = (float)(nPatternAnim % texPatternDivideX) * 1.0f / texPatternDivideX + 1.0f / texPatternDivideX;
		fPosYUp = (float)(nPatternAnim / (numAnimPattern / texPatternDivideY)) * 1.0f / texPatternDivideY;
		fPosYDown = (float)(nPatternAnim / (numAnimPattern / texPatternDivideY)) * 1.0f / texPatternDivideY + 1.0f / texPatternDivideY;

		pVtx[0].tex = D3DXVECTOR2(fPosXLeft, fPosYUp);
		pVtx[1].tex = D3DXVECTOR2(fPosXRight, fPosYUp);
		pVtx[2].tex = D3DXVECTOR2(fPosXLeft, fPosYDown);
		pVtx[3].tex = D3DXVECTOR2(fPosXRight, fPosYDown);

		// 頂点データをアンロックする
		g_pD3DVtxBuffPlaybar->Unlock();
	}
}
开发者ID:andylam5538,项目名称:sango,代码行数:31,代码来源:playbar.cpp

示例8: memcpy

//-----------------------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InitDeviceObjects()
{
    HRESULT hr;

    m_pFont->InitDeviceObjects( m_pd3dDevice );

	ilInit();
	iluInit();
	ilutInit();
	ilutD3D8TexFromFile(m_pd3dDevice, __argv[1], &m_pTexture);
	//D3DXCreateTextureFromFile(m_pd3dDevice, __argv[1], &m_pTexture);

    // Create a vertex buffer
    {
        if( FAILED( hr = m_pd3dDevice->CreateVertexBuffer( 4*sizeof(VERTEX),
                                           D3DUSAGE_WRITEONLY,
                                           D3DFVF_VERTEX,
                                           D3DPOOL_MANAGED, &m_pVB ) ) )
            return hr;

        VERTEX* pVertices;
        m_pVB->Lock( 0, 4*sizeof(VERTEX), (BYTE**)&pVertices, 0 );
        memcpy( pVertices, g_vVertices, sizeof(VERTEX)*4 );
        m_pVB->Unlock();
    }

    return S_OK;
}
开发者ID:AMDmi3,项目名称:DevIL,代码行数:32,代码来源:d3dtest.cpp

示例9: initializeObj

bool initializeObj() {
	//手动创建数组保存顶点数据
	unsigned INT colorInfo = D3DCOLOR_ARGB(1, 255, 255, 255);
	D3DVertexXYZRHW vertexData[] =
	{
		{ 10.0f, 10.0f, 0.0f, 1.0f, colorInfo },
		{ 200.0f, 10.0f, 0.0f, 1.0f, colorInfo },
		{ 10.0f, 200.0f, 0.0f, 1.0f, D3DCOLOR_ARGB(1, 0, 0, 0) },
		{ 200.0f, 200.0f, 0.0f, 1.0f, colorInfo },
		{ 400.0f, 200.0f, 0.0f, 1.0f, colorInfo },
		{ 200.0f, 400.0f, 0.0f, 1.0f, colorInfo },
	};

	//用D3D设备创建一个用于存放顶点数据的缓存
	if (FAILED(d3dDevice->CreateVertexBuffer(sizeof(vertexData), 0, D3DFVF_XYZRHW | D3DFVF_DIFFUSE,
											 D3DPOOL_DEFAULT, &d3dVertexBuf, NULL)))
		return false;

	//用ptr当媒介,向缓存填入顶点数据
	VOID *ptr;
	if (FAILED(d3dVertexBuf->Lock(0, sizeof(vertexData), (VOID**)&ptr, 0)))
		return false;
	memcpy(ptr, vertexData, sizeof(vertexData));
	d3dVertexBuf->Unlock();

	return true;
}
开发者ID:henianming,项目名称:WayToDirectx,代码行数:27,代码来源:csdn_lesson003.cpp

示例10: init_vertex_buffer

//------------------------------------------------------------------------------
HRESULT init_vertex_buffer()
{
    CUSTOMVERTEX vertices[] = {
		{ -1,  1,  1 , 0xFFFF0000 },		/// v0
		{  1,  1,  1 , 0xFF00FF00 },		/// v1
		{  1,  1, -1 , 0xFF0000FF },		/// v2
		{ -1,  1, -1 , 0xFFFFFF00 },		/// v3

		{ -1, -1,  1 , 0xFF00FFFF },		/// v4
		{  1, -1,  1 , 0xFFFF00FF },		/// v5
		{  1, -1, -1 , 0xFF000000 },		/// v6
		{ -1, -1, -1 , 0xFFFFFFFF },		/// v7
    };

    if (FAILED( g_pd3dDevice->CreateVertexBuffer( 8*sizeof(CUSTOMVERTEX),
                                                  0, D3DFVF_CUSTOMVERTEX,
                                                  D3DPOOL_DEFAULT, &g_pVertexBuff, NULL )))
        return E_FAIL;

    VOID* pVertices;
    if (FAILED( g_pVertexBuff->Lock( 0, sizeof(vertices), (void**)&pVertices, 0 )))
        return E_FAIL;
    memcpy( pVertices, vertices, sizeof(vertices) );
    g_pVertexBuff->Unlock();

    return S_OK;
}
开发者ID:netpyoung,项目名称:bs.3d_game_programming,代码行数:28,代码来源:2-7.cpp

示例11: GetDevice

LPDIRECT3DVERTEXBUFFER9 OvRenderer::CreateVertexStream( void* buffer, UINT stride, UINT count )
{
	OvDevice device = GetDevice();
	if ( device )
	{
		LPDIRECT3DVERTEXBUFFER9 vertexStream = NULL;
		UINT streamSize = count * stride;
		HRESULT hr = device->CreateVertexBuffer
			( streamSize
			, 0
			, 0
			, D3DPOOL_MANAGED
			, &vertexStream
			, NULL
			);
		if ( SUCCEEDED(hr) && vertexStream )
		{
			void* copyDest = NULL;
			if ( SUCCEEDED(vertexStream->Lock( 0, streamSize, &copyDest, 0)) && copyDest)
			{
				memcpy( copyDest, buffer, streamSize );
				vertexStream->Unlock();
				return vertexStream;
			}
		}
	}
	return NULL;
}
开发者ID:ultrano,项目名称:OliveEngine,代码行数:28,代码来源:OvRenderer.cpp

示例12: InitGeometry

//-----------------------------------------------------------------------------
// Name: InitGeometry()
// Desc: Creates the scene geometry
//-----------------------------------------------------------------------------
HRESULT InitGeometry()
{
    // Create the vertex buffer.
    if( FAILED( g_pd3dDevice->CreateVertexBuffer( 50*2*sizeof(CUSTOMVERTEX),
                0, D3DFVF_CUSTOMVERTEX,
                D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
    {
        return E_FAIL;
    }

    // Fill the vertex buffer. We are algorithmically generating a cylinder
    // here, including the normals, which are used for lighting.
    CUSTOMVERTEX* pVertices;
    if( FAILED( g_pVB->Lock( 0, 0, (void**)&pVertices, 0 ) ) )
        return E_FAIL;
    for( DWORD i=0; i<50z; i++ )
    {
        FLOAT theta = (2*D3DX_PI*i)/(50-1);
        pVertices[2*i+0].position = D3DXVECTOR3( sinf(theta),-1.0f, cosf(theta) );
        pVertices[2*i+0].normal   = D3DXVECTOR3( sinf(theta), 0.0f, cosf(theta) );
        pVertices[2*i+1].position = D3DXVECTOR3( sinf(theta), 1.0f, cosf(theta) );
        pVertices[2*i+1].normal   = D3DXVECTOR3( sinf(theta), 0.0f, cosf(theta) );
    }
    g_pVB->Unlock();

    return S_OK;
}
开发者ID:arlukin,项目名称:dev,代码行数:31,代码来源:Lights.cpp

示例13: InitializeVertexBuffer

HRESULT InitializeVertexBuffer()
{
	//Store each point of the triangle together with its color
	CUSTOMVERTEX cvVertices[] =
	{
		{-10.f, 0.f, 0.f, D3DCOLOR_XRGB(255, 0, 0)},
		{0.f, 0.f, 10.f, D3DCOLOR_XRGB(0, 255, 0)},
		{10.f, 0.f, 0.f, D3DCOLOR_XRGB(0, 0, 255)}
	};

	//Create the vertex buffer
	if(FAILED(g_pD3DDevice->CreateVertexBuffer(sizeof(cvVertices), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVertexBuffer, 0)))
		return E_FAIL;

	//Get a pointer to the vertex buffer vertices and lock the vertex buffer
	void* pVertices = 0;
	if(FAILED(g_pVertexBuffer->Lock(0, sizeof(cvVertices), &pVertices, 0)))
		return E_FAIL;

	//Copy our stored vertices value into the vertex buffer
	memcpy(pVertices, cvVertices, sizeof(cvVertices));

	g_pVertexBuffer->Unlock();

	return S_OK;
}
开发者ID:viticm,项目名称:pap2,代码行数:26,代码来源:TestRender.cpp

示例14: initRectangleVertexes

void initRectangleVertexes()
{
	VertexData data[4] = {
		/*   x          y           z       u   v   */
		{ 0, 0, 0, 0, 0 },
		{ Width, 0, 0, 1, 0 },
		{ 0, Height, 0, 0, 1 },
		{ Width, Height, 0, 1, 1 }
	};

	void *pRectBuffer = NULL;
	device->CreateVertexBuffer(4 * sizeof(VertexData), D3DUSAGE_WRITEONLY,
		D3DFVF_XYZ | D3DFVF_TEX0, D3DPOOL_DEFAULT, &pRectObject, NULL);

	pRectObject->Lock(0, 4 * sizeof(VertexData), &pRectBuffer, 0);

	memcpy(pRectBuffer, data, 4 * sizeof(VertexData));
	pRectObject->Unlock();

	D3DVERTEXELEMENT9 decl[] =
	{
		{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
		{ 0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
		D3DDECL_END()
	};

	device->CreateVertexDeclaration(decl, &RectDecl);
}
开发者ID:DrA1ex,项目名称:ParticleSystem,代码行数:28,代码来源:RenderToTexture.cpp

示例15: init_graphics

// this is the function that puts the 3D models into video RAM
void init_graphics(void)
{
    // create the vertices using the CUSTOMVERTEX struct
    CUSTOMVERTEX vertices[] =
    {
        { 3.0f, -3.0f, 0.0f, D3DCOLOR_XRGB(0, 0, 255), },
        { 0.0f, 3.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0), },
        { -3.0f, -3.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0), },
    };

    // create a vertex buffer interface called v_buffer
    d3ddev->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX),
                               0,
                               CUSTOMFVF,
                               D3DPOOL_MANAGED,
                               &v_buffer,
                               NULL);

    VOID* pVoid;    // a void pointer

    // lock v_buffer and load the vertices into it
    v_buffer->Lock(0, 0, (void**)&pVoid, 0);
    memcpy(pVoid, vertices, sizeof(vertices));
    v_buffer->Unlock();
}
开发者ID:smidget,项目名称:AscensionControl,代码行数:26,代码来源:Main.cpp


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