本文整理汇总了C++中LPDIRECT3DDEVICE9::CreateVertexDeclaration方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE9::CreateVertexDeclaration方法的具体用法?C++ LPDIRECT3DDEVICE9::CreateVertexDeclaration怎么用?C++ LPDIRECT3DDEVICE9::CreateVertexDeclaration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE9
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE9::CreateVertexDeclaration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadMethod
// Initialises the given render method (vertex + pixel shader), returns true on success
bool LoadMethod( int method )
{
// If the vertex shader for this method has not already been initialised
if (!renderMethods[method].vertexShader)
{
// Load the vertex shader file specified above, storing resultant DirectX data
if (!LoadVertexShader( renderMethods[method].vertexShaderFile,
&renderMethods[method].vertexShader,
&renderMethods[method].vertexConsts ))
{
return false;
}
}
if (!renderMethods[method].pixelShader)
{
// Load the vertex shader file specified above, storing resultant DirectX data
if (!LoadPixelShader( renderMethods[method].pixelShaderFile,
&renderMethods[method].pixelShader,
&renderMethods[method].pixelConsts ))
{
return false;
}
}
if (!renderMethods[method].vertexDecl)
{
if (FAILED(g_pd3dDevice->CreateVertexDeclaration( renderMethods[method].vertexElts,
&renderMethods[method].vertexDecl )))
{
return false;
}
}
return true;
}
示例2:
HRESULT HookIDirect3DDevice9::CreateVertexDeclaration(LPVOID _this,
CONST D3DVERTEXELEMENT9* pVertexElements,
IDirect3DVertexDeclaration9** ppDecl)
{
LOG_API();
return pD3Dev->CreateVertexDeclaration(pVertexElements, ppDecl);
}
示例3: 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);
}
示例4: 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);
}
示例5: CreateShadowMap
void DXDirectionalLight::CreateShadowMap(LPDIRECT3DDEVICE9 device, DWORD type, DWORD size)
{
HRESULT hr;
DXLight::CreateShadowMap(device, type, size);
hr = device->CreateTexture(size, size, 1, D3DUSAGE_RENDERTARGET, D3DFMT_G32R32F, D3DPOOL_DEFAULT, &shadowmap, NULL);
if( SUCCEEDED(hr) )
hr = device->CreateTexture(size, size, 1, D3DUSAGE_RENDERTARGET, D3DFMT_G32R32F, D3DPOOL_DEFAULT, &blur, NULL);
if( FAILED(hr) )
{
if( shadowmap )
shadowmap->Release();
shadowmap = blur = NULL;
}
if( !blurdeclforpointfordirectional )
{
D3DVERTEXELEMENT9 elem[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0 },
{ 0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
D3DDECL_END()
};
device->CreateVertexDeclaration(elem, &blurdeclforpointfordirectional);
}
else
blurdeclforpointfordirectional->AddRef();
}
示例6: CompileShaders
void CompileShaders() {
std::string errorMsg;
HRESULT hr = -1;
if (!CompileVertexShader(vscode, &pFramebufferVertexShader, NULL, errorMsg)) {
OutputDebugStringA(errorMsg.c_str());
DebugBreak();
}
if (!CompilePixelShader(pscode, &pFramebufferPixelShader, NULL, errorMsg)) {
OutputDebugStringA(errorMsg.c_str());
DebugBreak();
}
pD3Ddevice->CreateVertexDeclaration(VertexElements, &pFramebufferVertexDecl);
pD3Ddevice->SetVertexDeclaration(pFramebufferVertexDecl);
pD3Ddevice->CreateVertexDeclaration(SoftTransVertexElements, &pSoftVertexDecl);
}
示例7: Create
//-----------------------------------------------------------------------------
HRESULT CDXUTMesh::Create( LPDIRECT3DDEVICE9 pd3dDevice, LPCWSTR strFilename )
{
WCHAR strPath[MAX_PATH];
LPD3DXBUFFER pAdjacencyBuffer = NULL;
LPD3DXBUFFER pMtrlBuffer = NULL;
HRESULT hr;
// Cleanup previous mesh if any
Destroy();
// Find the path for the file, and convert it to ANSI (for the D3DX API)
DXUTFindDXSDKMediaFileCch( strPath, sizeof(strPath) / sizeof(WCHAR), strFilename );
// Load the mesh
if( FAILED( hr = D3DXLoadMeshFromX( strPath, D3DXMESH_MANAGED, pd3dDevice,
&pAdjacencyBuffer, &pMtrlBuffer, NULL,
&m_dwNumMaterials, &m_pMesh ) ) )
{
return hr;
}
// Optimize the mesh for performance
if( FAILED( hr = m_pMesh->OptimizeInplace(
D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE,
(DWORD*)pAdjacencyBuffer->GetBufferPointer(), NULL, NULL, NULL ) ) )
{
SAFE_RELEASE( pAdjacencyBuffer );
SAFE_RELEASE( pMtrlBuffer );
return hr;
}
// Set strPath to the path of the mesh file
WCHAR *pLastBSlash = wcsrchr( strPath, L'\\' );
if( pLastBSlash )
*(pLastBSlash + 1) = L'\0';
else
*strPath = L'\0';
D3DXMATERIAL* d3dxMtrls = (D3DXMATERIAL*)pMtrlBuffer->GetBufferPointer();
hr = CreateMaterials( strPath, pd3dDevice, d3dxMtrls, m_dwNumMaterials );
SAFE_RELEASE( pAdjacencyBuffer );
SAFE_RELEASE( pMtrlBuffer );
// Extract data from m_pMesh for easy access
D3DVERTEXELEMENT9 decl[MAX_FVF_DECL_SIZE];
m_dwNumVertices = m_pMesh->GetNumVertices();
m_dwNumFaces = m_pMesh->GetNumFaces();
m_dwBytesPerVertex = m_pMesh->GetNumBytesPerVertex();
m_pMesh->GetIndexBuffer( &m_pIB );
m_pMesh->GetVertexBuffer( &m_pVB );
m_pMesh->GetDeclaration( decl );
pd3dDevice->CreateVertexDeclaration( decl, &m_pDecl );
return hr;
}
示例8: CompileShaders
bool CompileShaders(std::string &errorMsg) {
if (!CompileVertexShader(vscode, &pFramebufferVertexShader, NULL, errorMsg)) {
OutputDebugStringA(errorMsg.c_str());
return false;
}
if (!CompilePixelShader(pscode, &pFramebufferPixelShader, NULL, errorMsg)) {
OutputDebugStringA(errorMsg.c_str());
if (pFramebufferVertexShader) {
pFramebufferVertexShader->Release();
}
return false;
}
pD3Ddevice->CreateVertexDeclaration(VertexElements, &pFramebufferVertexDecl);
pD3Ddevice->SetVertexDeclaration(pFramebufferVertexDecl);
pD3Ddevice->CreateVertexDeclaration(SoftTransVertexElements, &pSoftVertexDecl);
return true;
}
示例9: InitAllVertexDeclarations
void InitAllVertexDeclarations(LPDIRECT3DDEVICE9 pD3DDevice)
{
//===============================================================
// VertexPos
D3DVERTEXELEMENT9 VertexPosElements[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
D3DDECL_END()
};
pD3DDevice->CreateVertexDeclaration(VertexPosElements, &VertexPos::Decl);
}
示例10: CreateVertexDeclaration
LPDIRECT3DVERTEXDECLARATION9 CreateVertexDeclaration( LPDIRECT3DDEVICE9 device, D3DVERTEXELEMENT9* elements )
{
if ( device && elements )
{
LPDIRECT3DVERTEXDECLARATION9 vertDecl = NULL;
HRESULT hr = device->CreateVertexDeclaration( elements, &vertDecl );
if ( SUCCEEDED( hr ) )
{
return vertDecl;
}
}
return NULL;
}
示例11: OnCreateDevice
//-----------------------------------------------------------------------------
HRESULT CSkybox::OnCreateDevice( LPDIRECT3DDEVICE9 pd3dDevice, float fSize, IDirect3DCubeTexture9* pCubeTexture,
WCHAR* strEffectFileName )
{
HRESULT hr;
m_pd3dDevice = pd3dDevice;
m_fSize = fSize;
m_pEnvironmentMap = pCubeTexture;
// Define DEBUG_VS and/or DEBUG_PS to debug vertex and/or pixel shaders with the shader debugger.
// Debugging vertex shaders requires either REF or software vertex processing, and debugging
// pixel shaders requires REF. The D3DXSHADER_FORCE_*_SOFTWARE_NOOPT flag improves the debug
// experience in the shader debugger. It enables source level debugging, prevents instruction
// reordering, prevents dead code elimination, and forces the compiler to compile against the next
// higher available software target, which ensures that the unoptimized shaders do not exceed
// the shader model limitations. Setting these flags will cause slower rendering since the shaders
// will be unoptimized and forced into software. See the DirectX documentation for more information
// about using the shader debugger.
DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE;
#if defined( DEBUG ) || defined( _DEBUG )
// Set the D3DXSHADER_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3DXSHADER_DEBUG;
#endif
#ifdef DEBUG_VS
dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;
#endif
#ifdef DEBUG_PS
dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
#endif
// Read the D3DX effect file
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, strEffectFileName ) );
// If this fails, there should be debug output as to
// they the .fx file failed to compile
V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL,
dwShaderFlags, NULL, &m_pEffect, NULL ) );
// Create vertex declaration
V_RETURN( pd3dDevice->CreateVertexDeclaration( g_aSkyboxDecl, &m_pVertexDecl ) );
return S_OK;
}
示例12: InitFX
HRESULT InitFX()
{
D3DVERTEXELEMENT9 decl[MAX_FVF_DECL_SIZE];
// FVF를 사용해서 정점선언값을 자동으로 채워넣는다
D3DXDeclaratorFromFVF( MYVERTEX::FVF, decl );
// 정점선언값으로 g_pDecl을 생성한다.
g_pd3dDevice->CreateVertexDeclaration( decl, &g_pDecl );
// simple.FX 파일을 읽어와서 ID3DXEffect인터페이스를 생성한다.
if( FAILED( D3DXCreateEffectFromFile( g_pd3dDevice, "shader.fx", NULL, NULL, 0, NULL, &g_pEffect, NULL ) ) )
{
MessageBox( NULL, "Effect Load Failed", "shader.fx", MB_OK );
return E_FAIL;
}
return S_OK;
}
示例13: InitVS
HRESULT InitVS()
{
D3DVERTEXELEMENT9 decl[MAX_FVF_DECL_SIZE];
// FVF를 사용해서 정점선언값을 자동으로 채워넣는다
D3DXDeclaratorFromFVF( MYVERTEX::FVF, decl );
// 정점선언값으로 g_pDecl을 생성한다.
g_pd3dDevice->CreateVertexDeclaration( decl, &g_pDecl );
LPD3DXBUFFER pCode;
// simple.vs 파일을 읽어와서 정점쉐이더 인터페이스를 생성한다.
if( FAILED( D3DXAssembleShaderFromFile( "simple.vs", NULL, NULL, 0, &pCode, NULL ) ) )
return E_FAIL;
g_pd3dDevice->CreateVertexShader( (DWORD*)pCode->GetBufferPointer(), &g_pVS);
S_REL( pCode );
return S_OK;
}
示例14: must
bool CObject3D::InitStaticDeviceObjects(LPDIRECT3DDEVICE9 device)
{
D3DVERTEXELEMENT9 decl[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 },
{ 0, 20, D3DDECLTYPE_SHORT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 },
{ 0, 24, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
{ 0, 36, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
D3DDECL_END()
};
if (FAILED(device->CreateVertexDeclaration(decl, &s_skinVertexDeclaration)))
{
qCritical("Can't create skin vertex declaration. You must (re)install the lastest DirectX9 runtime on http://www.microsoft.com/en-us/download/details.aspx?id=8109");
return false;
}
LPD3DXBUFFER code;
if (FAILED(D3DXAssembleShaderFromResource(NULL, MAKEINTRESOURCE(IDR_SKINVS), NULL, NULL, 0, &code, NULL)))
{
qCritical("Can't assemble skin vertex shader from resource. You must (re)install the lastest DirectX9 runtime on http://www.microsoft.com/en-us/download/details.aspx?id=8109");
return false;
}
if (FAILED(device->CreateVertexShader((DWORD*)code->GetBufferPointer(), &s_skinVS)))
{
qCritical("Can't create skin vertex shader. You must (re)install the lastest DirectX9 runtime on http://www.microsoft.com/en-us/download/details.aspx?id=8109");
Release(code);
return false;
}
Release(code);
s_reflectTexture.SetDevice(device);
if (!s_reflectTexture.Load("Model/Texture/etc_reflect.tga"))
{
qCritical("Can't load Model/Texture/etc_reflect.tga");
return false;
}
return true;
}
示例15: InitScene
HRESULT InitScene()
{
HRESULT hr;
LPD3DXBUFFER errors = NULL;
D3DVERTEXELEMENT9 decl[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0 },
{ 0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
D3DDECL_END()
};
SetWindowText(hwnd, TITLE);
MYVALID(CreateColorTex(device, 0xff77FF70, &texture));
MYVALID(D3DXLoadMeshFromXA("../media/meshes/knot.X", D3DXMESH_MANAGED, device, NULL, NULL, NULL, NULL, &mesh));
MYVALID(D3DXCreateTextureFromFileA(device, "../media/textures/intensity.png", &intensity));
MYVALID(device->CreateTexture(screenwidth, screenheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &colortarget, NULL));
MYVALID(device->CreateTexture(screenwidth, screenheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &normaltarget, NULL));
MYVALID(device->CreateTexture(screenwidth, screenheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &edgetarget, NULL));
MYVALID(device->CreateVertexDeclaration(decl, &vertexdecl));
edgetarget->GetSurfaceLevel(0, &edgesurface);
colortarget->GetSurfaceLevel(0, &colorsurface);
normaltarget->GetSurfaceLevel(0, &normalsurface);
MYVALID(device->CreateTexture(512, 512, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &text, NULL));
MYVALID(DXCreateEffect("../media/shaders/celshading.fx", device, &effect));
DXRenderText(HELP_TEXT, text, 512, 512);
D3DXVECTOR3 eye(0.5f, 0.5f, -1.5f);
D3DXVECTOR3 look(0, 0, 0);
D3DXVECTOR3 up(0, 1, 0);
D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 3, (float)screenwidth / (float)screenheight, 0.1f, 10);
D3DXMatrixLookAtLH(&view, &eye, &look, &up);
D3DXMatrixIdentity(&world);
return S_OK;
}