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


C++ IDirect3DDevice9::CreateVertexDeclaration方法代码示例

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


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

示例1: InitializeVertexDeclarations

void Graphics::InitializeVertexDeclarations(Graphics* gfx)
{
	IDirect3DDevice9* device = gfx->GetDevice();

	// nitVERTEXCOLOR
	D3DVERTEXELEMENT9 elements_d3dvertexcolor[] =
	{
		{0,  0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
		{0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0},
		D3DDECL_END()
	};
	device->CreateVertexDeclaration(elements_d3dvertexcolor, &nitVERTEXCOLOR::decl);

	// nitVERTEXSCREEN
	D3DVERTEXELEMENT9 elements_d3dvertexscreen[] =
	{
		{0,  0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0},
		{0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
		{0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0},
		D3DDECL_END()
	};
	device->CreateVertexDeclaration(elements_d3dvertexscreen, &nitVERTEXSCREEN::decl);

	// nitVERTEX
	D3DVERTEXELEMENT9 elements_d3dvertex[] =
	{
		{0,  0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
		{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
		{0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
		D3DDECL_END()
	};
	device->CreateVertexDeclaration(elements_d3dvertex, &nitVERTEX::decl);
}
开发者ID:limal,项目名称:nit,代码行数:33,代码来源:graphics.cpp

示例2: Create

void VertexDeclaration::Create(Graphics* graphics, const PODVector<VertexDeclarationElement>& elements)
{
    SharedArrayPtr<D3DVERTEXELEMENT9> elementArray(new D3DVERTEXELEMENT9[elements.Size() + 1]);
    
    D3DVERTEXELEMENT9* dest = elementArray;
    for (Vector<VertexDeclarationElement>::ConstIterator i = elements.Begin(); i != elements.End(); ++i)
    {
        dest->Stream = i->stream_;
        dest->Offset = i->offset_;
        dest->Type = d3dElementType[i->element_];
        dest->Method = D3DDECLMETHOD_DEFAULT;
        dest->Usage = d3dElementUsage[i->element_];
        dest->UsageIndex = d3dElementUsageIndex[i->element_];
        dest++;
    }
    
    dest->Stream = 0xff;
    dest->Offset = 0;
    dest->Type = D3DDECLTYPE_UNUSED;
    dest->Method = 0;
    dest->Usage = 0;
    dest->UsageIndex = 0;
    
    IDirect3DDevice9* device = graphics->GetImpl()->GetDevice();
    if (!device)
        return;
    
    device->CreateVertexDeclaration(elementArray, &declaration_);
}
开发者ID:zhzhxtrrk,项目名称:Urho3D,代码行数:29,代码来源:D3D9VertexDeclaration.cpp

示例3: Create

void VertexDeclaration::Create(Graphics* graphics, const PODVector<VertexDeclarationElement>& elements)
{
    SharedArrayPtr<D3DVERTEXELEMENT9> elementArray(new D3DVERTEXELEMENT9[elements.Size() + 1]);

    D3DVERTEXELEMENT9* dest = elementArray;
    for (Vector<VertexDeclarationElement>::ConstIterator i = elements.Begin(); i != elements.End(); ++i)
    {
        dest->Stream = (WORD)i->streamIndex_;
        dest->Offset = (WORD)i->offset_;
        dest->Type = d3dElementType[i->type_];
        dest->Method = D3DDECLMETHOD_DEFAULT;
        dest->Usage = d3dElementUsage[i->semantic_];
        dest->UsageIndex = i->index_;
        dest++;
    }

    dest->Stream = 0xff;
    dest->Offset = 0;
    dest->Type = D3DDECLTYPE_UNUSED;
    dest->Method = 0;
    dest->Usage = 0;
    dest->UsageIndex = 0;

    IDirect3DDevice9* device = graphics->GetImpl()->GetDevice();
    HRESULT hr = device->CreateVertexDeclaration(elementArray, &declaration_);
    if (FAILED(hr))
    {
        URHO3D_SAFE_RELEASE(declaration_);
        URHO3D_LOGD3DERROR("Failed to create vertex declaration", hr);
    }
}
开发者ID:BlueMagnificent,项目名称:Urho3D,代码行数:31,代码来源:D3D9VertexDeclaration.cpp

示例4: ZeroMemory

  bool GPUContextDX9::initialize()
  {
    _window = DX9Window::create();
    if( _window == NULL )
    {
      DX9WARN << "Could not create offscreen window.";
      return false;
    }

    HWND windowHandle = _window->getWindowHandle();

    _direct3D = Direct3DCreate9( D3D_SDK_VERSION );
    if( _direct3D == NULL )
    {
      DX9WARN << "Could not create Direct3D interface.";
      return false;
    }

    D3DPRESENT_PARAMETERS deviceDesc;
    ZeroMemory( &deviceDesc, sizeof(deviceDesc) );

    deviceDesc.Windowed = TRUE;
    deviceDesc.SwapEffect = D3DSWAPEFFECT_DISCARD;
    deviceDesc.BackBufferFormat = D3DFMT_UNKNOWN;
    deviceDesc.EnableAutoDepthStencil = FALSE;
    deviceDesc.AutoDepthStencilFormat = D3DFMT_D24S8;

    HRESULT result = _direct3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, windowHandle,
      D3DCREATE_HARDWARE_VERTEXPROCESSING, &deviceDesc, &_device );
    if( FAILED(result) )
    {
      DX9WARN << "Could not create Direct3D device.";
      return false;
    }

    // create vertex buffer
    static const int kMaxVertexCount = 64;

    result = _device->CreateVertexBuffer(
      kMaxVertexCount*sizeof(DX9Vertex), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &_vertexBuffer, NULL );
    DX9AssertResult( result, "CreateVertexBuffer failed" );

    result = _device->CreateVertexDeclaration( kDX9VertexElements, &_vertexDecl );
    DX9AssertResult( result, "CreateVertexDeclaration failed" );


    // TIM: set up initial state
    result = _device->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
    GPUAssert( !FAILED(result), "SetRenderState failed" );

    _passthroughVertexShader = createVertexShader( kPassthroughVertexShaderSource );
    _passthroughPixelShader = createPixelShader( kPassthroughPixelShaderSource );

    for( size_t i = 0; i < kMaximumOutputCount; i++ )
      _boundOutputs[i] = NULL;
    for( size_t t = 0; t < kMaximumSamplerCount; t++ )
      _boundTextures[t] = NULL;

    return true;
  }
开发者ID:darwin,项目名称:inferno,代码行数:60,代码来源:dx9runtime.cpp

示例5: Error

gl::Error Blit9::initialize()
{
    if (mGeometryLoaded)
    {
        return gl::Error(GL_NO_ERROR);
    }

    static const float quad[] =
    {
        -1, -1,
        -1,  1,
         1, -1,
         1,  1
    };

    IDirect3DDevice9 *device = mRenderer->getDevice();

    HRESULT result = device->CreateVertexBuffer(sizeof(quad), D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &mQuadVertexBuffer, NULL);

    if (FAILED(result))
    {
        ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
        return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal blit vertex shader, result: 0x%X.", result);
    }

    void *lockPtr = NULL;
    result = mQuadVertexBuffer->Lock(0, 0, &lockPtr, 0);

    if (FAILED(result) || lockPtr == NULL)
    {
        ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
        SafeRelease(mQuadVertexBuffer);
        return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal blit vertex shader, result: 0x%X.", result);
    }

    memcpy(lockPtr, quad, sizeof(quad));
    mQuadVertexBuffer->Unlock();

    static const D3DVERTEXELEMENT9 elements[] =
    {
        { 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
        D3DDECL_END()
    };

    result = device->CreateVertexDeclaration(elements, &mQuadVertexDeclaration);

    if (FAILED(result))
    {
        ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
        SafeRelease(mQuadVertexBuffer);
        return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal blit vertex declaration, result: 0x%X.", result);
    }

    mGeometryLoaded = true;
    return gl::Error(GL_NO_ERROR);
}
开发者ID:AlexSoehn,项目名称:qt-base-deb,代码行数:56,代码来源:Blit9.cpp

示例6: initGeometry

void Blit::initGeometry()
{
    static const float quad[] =
    {
        -1, -1,
        -1,  1,
        1, -1,
        1,  1
    };

    IDirect3DDevice9 *device = getDevice();

    HRESULT result = device->CreateVertexBuffer(sizeof(quad), D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &mQuadVertexBuffer, NULL);

    if (FAILED(result))
    {
        ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
        return error(GL_OUT_OF_MEMORY);
    }

    void *lockPtr = NULL;
    result = mQuadVertexBuffer->Lock(0, 0, &lockPtr, 0);

    if (FAILED(result) || lockPtr == NULL)
    {
        ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
        return error(GL_OUT_OF_MEMORY);
    }

    memcpy(lockPtr, quad, sizeof(quad));
    mQuadVertexBuffer->Unlock();

    static const D3DVERTEXELEMENT9 elements[] =
    {
        { 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
        D3DDECL_END()
    };

    result = device->CreateVertexDeclaration(elements, &mQuadVertexDeclaration);

    if (FAILED(result))
    {
        ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
        return error(GL_OUT_OF_MEMORY);
    }
}
开发者ID:RickEyre,项目名称:mozilla-central,代码行数:46,代码来源:Blit.cpp

示例7:

//----------------------------------------------------------------------------
PdrVertexFormat::PdrVertexFormat (Renderer* renderer,
								  const VertexFormat* vformat)
{
	IDirect3DDevice9* device = renderer->mData->mDevice;

	const int numAttributes = vformat->GetNumAttributes();
	for (int i = 0; i < numAttributes; ++i)
	{
		// 获得与平台无关的顶点属性
		unsigned int streamIndex;
		unsigned int offset;
		VertexFormat::AttributeType type;
		VertexFormat::AttributeUsage usage;
		unsigned int usageIndex;
		vformat->GetAttribute(i, streamIndex, offset, type, usage,
			usageIndex);

		// 设置Dx9属性
		D3DVERTEXELEMENT9 &element = mElements[i];
		element.Stream = (WORD)streamIndex;
		element.Offset = (WORD)offset;
		element.Type = gDX9AttributeType[type];
		element.Method = D3DDECLMETHOD_DEFAULT;
		element.Usage = gDX9AttributeUsage[usage];
		element.UsageIndex = (BYTE)usageIndex;
	}

	// 最后一个DX9 element必须是D3DDECL_END().
	D3DVERTEXELEMENT9 &element = mElements[numAttributes];
	element.Stream = 0xFF;
	element.Offset = 0;
	element.Type = D3DDECLTYPE_UNUSED;
	element.Method = 0;
	element.Usage = 0;
	element.UsageIndex = 0;

	HRESULT hr = device->CreateVertexDeclaration(mElements, &mDeclaration);
	PX2_UNUSED(hr);
	assertion(hr == D3D_OK, "Failed to create vertex declaration: %s\n",
		DXGetErrorString(hr));
}
开发者ID:SylviaTanenbaum,项目名称:3d-simulation-and-game,代码行数:42,代码来源:PX2Dx9VertexFormat.cpp

示例8: HDAPIException

void DX9VertexDecl::endBuild(HDResourceMgr *pMgr)
{
    ASSERT(pMgr);
    ASSERT(m_elementArray.size() > 0);

    // --
    D3DVERTEXELEMENT9 em = D3DDECL_END();
    m_elementArray.push_back(em);

    // --
    DX9ResourceMgr* pDX9Mgr = (DX9ResourceMgr*)pMgr;
    IDirect3DDevice9* pDev = pDX9Mgr->getDX9Device();
    HRESULT hr;


    hr = pDev->CreateVertexDeclaration(&m_elementArray[0], &m_pDecl);
    if(FAILED(hr))
    {
        throw HDAPIException("vertex declaration created failed.");
    }

}
开发者ID:WangShuwei6,项目名称:MagicGearEditor3D,代码行数:22,代码来源:DX9Resource.cpp

示例9: sizeof

void NX::Sphere::CreateTriangles() {
	int nV = (m_iStacks - 1) * (m_iSlices + 1) + 2, r, c;
	int nI = (m_iStacks - 2) * (m_iSlices + 1) * 2 + (m_iSlices + 2) * 2;
	float rr = kfPiOver2, rc, dr = kfPi / m_iStacks, dc = kf2Pi / m_iSlices;
	float sr, cr, sc, cc;
	IDirect3DDevice9 *pDevice = glb_GetD3DDevice();
	m_pVertexs = new Vertex[nV];
	{//calculate vertex data 
		Vertex *pVertex = m_pVertexs;
		*pVertex++ = { 0.f, m_fRadius, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f };
		for (r = 1; r < m_iStacks; ++r) {
			rr -= dr;
			rc = 0.f;
			cr = std::cosf(rr), sr = std::sinf(rr);
			for (c = 0; c <= m_iSlices; ++c) {
				sc = std::sinf(rc);
				cc = std::cosf(rc);
				*pVertex++ = { m_fRadius * cr * cc, m_fRadius * sr, m_fRadius * cr * sc, c * 1.f / m_iSlices, r * 1.f / m_iStacks,  cr * cc, sr, cr * sc };
				rc += dc;
			}
		}
		*pVertex = { 0.f, -m_fRadius, 0.f, 0.f, 1.f, 0.f, -1.f, 0.f };
		pDevice->CreateVertexBuffer(sizeof(Vertex) * nV, D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &m_pVertexBuffer, nullptr);

		void *pBase = nullptr;
		m_pVertexBuffer->Lock(0, 0, &pBase, D3DLOCK_DISCARD);
		memcpy(pBase, m_pVertexs, sizeof(Vertex) * nV);
		m_pVertexBuffer->Unlock();
	}


	{//vertex desc
		D3DVERTEXELEMENT9 VertexDesc[] = {
			{ 0, CLS_MEM_OFFSET(Vertex, x), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
			{ 0, CLS_MEM_OFFSET(Vertex, u), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
			{ 0, CLS_MEM_OFFSET(Vertex,nx), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL,   0 },
			D3DDECL_END(),
		};
		pDevice->CreateVertexDeclaration(VertexDesc, &m_pVertexDesc);
	}

	{//calculate index data
		pDevice->CreateIndexBuffer(nI * sizeof(int), D3DUSAGE_WRITEONLY, D3DFMT_INDEX32, D3DPOOL_DEFAULT, &m_pIndexBuffer, nullptr);
		int *pBase = nullptr;
		m_pIndexBuffer->Lock(0, 0, (void**)&pBase, D3DLOCK_DISCARD);
		for (int i = 0; i <= m_iSlices + 1; ++i) {//first stack, triangle_fan
			*pBase++ = i;
		}
		int a = 1;
		for (int i = 1; i < m_iStacks - 1; ++i) {//inner stacks, triangle_list
			for (int j = 0; j <= m_iSlices; ++j) {
				*pBase++ = a;
				*pBase++ = a + m_iSlices + 1;
				++a;
			}
		}

		*pBase++ = (m_iStacks - 1) * (m_iSlices + 1) + 1;
		for (int i = 0; i <= m_iSlices; ++i) {
			*pBase++ = (m_iStacks - 2) * (m_iSlices + 1) + 1 + i;
		}

		m_pIndexBuffer->Unlock();
	}
}
开发者ID:MandyMo,项目名称:NXEngine,代码行数:65,代码来源:NXSphere.cpp

示例10: if

    //-----------------------------------------------------------------------
    IDirect3DVertexDeclaration9* D3D9VertexDeclaration::getD3DVertexDeclaration(void)
    {
		IDirect3DDevice9* pCurDevice   = D3D9RenderSystem::getActiveD3D9Device();
		DeviceToDeclarationIterator it = mMapDeviceToDeclaration.find(pCurDevice);
		IDirect3DVertexDeclaration9* lpVertDecl = NULL;

		// Case we have to create the declaration for this device.
		if (it == mMapDeviceToDeclaration.end() || it->second == NULL)
		{
			D3DVERTEXELEMENT9* d3delems = new D3DVERTEXELEMENT9[mElementList.size() + 1];

			VertexElementList::const_iterator i, iend;
			unsigned int idx;
			iend = mElementList.end();
			for (idx = 0, i = mElementList.begin(); i != iend; ++i, ++idx)
			{
				d3delems[idx].Method = D3DDECLMETHOD_DEFAULT;
				d3delems[idx].Offset = static_cast<WORD>(i->getOffset());
				d3delems[idx].Stream = i->getSource();
				d3delems[idx].Type = D3D9Mappings::get(i->getType());
				d3delems[idx].Usage = D3D9Mappings::get(i->getSemantic());
				// NB force index if colours since D3D uses the same usage for 
				// diffuse & specular
				if (i->getSemantic() == VES_SPECULAR)
				{
					d3delems[idx].UsageIndex = 1;
				}
				else if (i->getSemantic() == VES_DIFFUSE)
				{
					d3delems[idx].UsageIndex = 0;
				}
				else
				{
					d3delems[idx].UsageIndex = static_cast<BYTE>(i->getIndex());
				}
			}
			// Add terminator
			d3delems[idx].Stream = 0xff;
			d3delems[idx].Offset = 0;
			d3delems[idx].Type = D3DDECLTYPE_UNUSED;
			d3delems[idx].Method = 0;
			d3delems[idx].Usage = 0;
			d3delems[idx].UsageIndex = 0;

			
			HRESULT hr = pCurDevice->CreateVertexDeclaration(d3delems, &lpVertDecl);

			if (FAILED(hr))
			{
				OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
					"Cannot create D3D9 vertex declaration: " + 
					Root::getSingleton().getErrorDescription(hr), 
					"Direct3D9VertexDeclaration::getD3DVertexDeclaration");
			}

			delete [] d3delems;

			mMapDeviceToDeclaration[pCurDevice] = lpVertDecl;
		}

		// Declaration already exits.
		else
		{
			lpVertDecl = mMapDeviceToDeclaration[pCurDevice];
		}
		
        return lpVertDecl;
    }
开发者ID:milram,项目名称:ogre-1.7.4-osx,代码行数:69,代码来源:OgreD3D9VertexDeclaration.cpp

示例11: V

void CShowPoints9::SetMesh(LPD3DXMESH pNewMesh, LPD3DXSKININFO pNewSkin)
{
    HRESULT hr = S_OK;

    NumPoints = 0;
    
    UnskinnedVB.resize(0);
    SAFE_RELEASE(SkinnedVB);
    SAFE_RELEASE(Skin);

    if(pNewMesh == NULL)
        return;

    IDirect3DDevice9* device = DXUTGetD3D9Device();

    {//EFFECT
     V( device->CreateVertexDeclaration( Elements, &Declaration ) );

     ID3DXBuffer* pErrors = NULL;
     V( SASCreateEffectFromResource(
             device, 
             NULL, MAKEINTRESOURCE(IDR_SHOWLINES9FX), MAKEINTRESOURCE(RT_RCDATA),
             NULL, 
             NULL, 
             0,
             NULL, 
             &Effect, 
             &pErrors));
    if(pErrors)
         DXVGetApp().OutputA( (const char*)pErrors->GetBufferPointer() );
    SAFE_RELEASE(pErrors);

    }//EFFECT



    D3DVERTEXELEMENT9 declIn[ MAX_FVF_DECL_SIZE ];
    V( pNewMesh->GetDeclaration(declIn) );

    int iPos= -1;
    int iNorm= -1;
    for( int i = 0 ; 
        declIn[i].Stream != 255 && i < MAX_FVF_DECL_SIZE;
        i++)
    {
        if(declIn[i].Usage == D3DDECLUSAGE_POSITION && declIn[i].UsageIndex == 0)
            iPos = i;
        if(declIn[i].Usage == D3DDECLUSAGE_NORMAL && declIn[i].UsageIndex == 0)
            iNorm = i;
    }

    if(iPos == -1 || iNorm == -1)
        return;

    if( (( declIn[iPos].Type & (D3DDECLTYPE_FLOAT3|D3DDECLTYPE_FLOAT4)) == 0  ) ||
        (( declIn[iNorm].Type & (D3DDECLTYPE_FLOAT3|D3DDECLTYPE_FLOAT4)) == 0  ) )
        return;

    NumPoints = pNewMesh->GetNumVertices();

    int MeshStride = pNewMesh->GetNumBytesPerVertex();


    if(pNewSkin)
    {
        V( pNewSkin->Clone( &Skin ) ); 
        V( Skin->SetDeclaration(Elements) );
    }


    //GET VERTEX DATA

    BYTE* pSrcVB= NULL;
    V(  pNewMesh->LockVertexBuffer( D3DLOCK_READONLY, (LPVOID*)&pSrcVB ) );
    UnskinnedVB.resize(pNewMesh->GetNumVertices());
    for( DWORD iVert = 0; iVert < pNewMesh->GetNumVertices(); iVert++)
    {
        Vertex& v0 = UnskinnedVB[iVert];

        v0.Position = *(D3DXVECTOR3*) (pSrcVB+(MeshStride*iVert)+declIn[iPos].Offset);
    }
    V( pNewMesh->UnlockVertexBuffer() );

    V( device->CreateVertexBuffer( NumPoints*Stride , D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &SkinnedVB, NULL) );
    //Fill in with initial values so unskinned meshes do not have to do this every render.
    pSrcVB=(BYTE*)(void*)&UnskinnedVB.front();
    BYTE* pDstVB=NULL;
    V( SkinnedVB->Lock(0, 0, (void**)&pDstVB, 0 ) );
    {
        memcpy( pDstVB, pSrcVB, Stride*pNewMesh->GetNumVertices() );
    }
    V( SkinnedVB->Unlock() );
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:93,代码来源:ShowPoints9.cpp

示例12: VSMain

    void CFullscreenTriangleDrawer::CreateDX9Resources()
    {
        HRESULT hr = S_OK;

        float VertexData[] =
        {
            -1.0f,  1.0f, 0.0f, 0.0f, 0.0f,
            3.0f,  1.0f, 0.0f, 2.0f, 0.0f,
            -1.0f, -3.0f, 0.0f, 0.0f, 2.0f,
        };

        IDirect3DDevice9* pDevice = static_cast<IDirect3DDevice9*>( gD3DDevice );

        // Vertex buffer
        hr = pDevice->CreateVertexBuffer( sizeof( VertexData ), D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &m_pVertexBuffer, NULL );
        CRY_ASSERT( SUCCEEDED( hr ) );

        float* pVertexBuffer = NULL;
        hr = m_pVertexBuffer->Lock( 0, 0, ( void** )&pVertexBuffer, 0 );
        CRY_ASSERT( SUCCEEDED( hr ) );
        memcpy( pVertexBuffer, VertexData, sizeof( VertexData ) );
        m_pVertexBuffer->Unlock();

        // Vertex declaration
        D3DVERTEXELEMENT9 VertexElements[] =
        {
            {0, 0,  D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
            {0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
            D3DDECL_END()
        };
        hr = pDevice->CreateVertexDeclaration( VertexElements, &m_pVertexDeclaration );
        CRY_ASSERT( SUCCEEDED( hr ) );

        // Vertex shader

        /*
        // FSTriangle.vs
        // fxc /O2 /T vs_2_0 /E VSMain
        float Width : register(c0);
        float Height : register(c1);

        struct VertexPT
        {
            float4 PositionL : POSITION0;
            float2 TexCoord  : TEXCOORD0;
        };

        VertexPT VSMain(VertexPT vsIn)
        {
            vsIn.PositionL += float4(-0.5 / Width, 0.5 / Height, 0, 0);
            return vsIn;
        }
        */

        const char CompiledVS[] =
        {
            0x00, 0x02, 0xfe, 0xff, 0xfe, 0xff, 0x28, 0x00, 0x43, 0x54, 0x41, 0x42,
            0x1c, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0xff,
            0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x00, 0x00,
            0x62, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,
            0x01, 0x00, 0x06, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x5c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
            0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x65, 0x69, 0x67,
            0x68, 0x74, 0x00, 0xab, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, 0x00,
            0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x69, 0x64, 0x74,
            0x68, 0x00, 0x76, 0x73, 0x5f, 0x32, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63,
            0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48,
            0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43,
            0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39,
            0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0xab,
            0x51, 0x00, 0x00, 0x05, 0x02, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x00, 0xbf,
            0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90,
            0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0x90,
            0x06, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0xa0,
            0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x80,
            0x02, 0x00, 0x00, 0xa0, 0x06, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x80,
            0x01, 0x00, 0x00, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x02, 0x80,
            0x01, 0x00, 0x00, 0x80, 0x02, 0x00, 0x55, 0xa0, 0x01, 0x00, 0x00, 0x02,
            0x00, 0x00, 0x0c, 0x80, 0x02, 0x00, 0xaa, 0xa0, 0x02, 0x00, 0x00, 0x03,
            0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x90,
            0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x03, 0xe0, 0x01, 0x00, 0xe4, 0x90,
            0xff, 0xff, 0x00, 0x00,
        };

        hr = pDevice->CreateVertexShader( ( DWORD* )CompiledVS, &m_pVertexShader9 );
        CRY_ASSERT( SUCCEEDED( hr ) );

        // Pixel shader

        /*
        // FSTriangle.ps
        // fxc /O2 /T ps_2_0 /E PSMain
        texture Texture : register(s0);

        sampler PointSampler = sampler_state
        {
            Texture = <Texture>;
            MinFilter = Point;
            MagFilter = Point;
//.........这里部分代码省略.........
开发者ID:CoherentLabs,项目名称:CoherentUI_CryEngine3,代码行数:101,代码来源:FullscreenTriangleDrawer.cpp


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