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


C++ LPDIRECT3DDEVICE9::SetIndices方法代码示例

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


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

示例1: Direct3DUpdate

void Direct3DUpdate(HWND hwnd)
{
    //////////////////////////////////////////////////////////////////////////
    // Five steps of rendering: clear, beginScene, render, EndScene, present  
    //////////////////////////////////////////////////////////////////////////   
	gPD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

	RECT formatRect;
	GetClientRect(hwnd, &formatRect);

	gPD3DDevice->BeginScene();

	gPD3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);

	gPD3DDevice->SetStreamSource(0, gPVertexBuffer, 0, sizeof(CUSTOM_VERTEX));
	gPD3DDevice->SetFVF(D3DFVF_CUSTOM_VERTEX);
	gPD3DDevice->SetIndices(gPIndexBuffer);
	gPD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 17, 0, 16);

	int charCount = swprintf_s(gStrFPS, 20, _T("FPS:%0.3f"), GetFPS());
	gPFont->DrawText(NULL, gStrFPS, charCount, &formatRect, DT_TOP | DT_RIGHT, D3DCOLOR_XRGB(255, 39, 136));


	gPD3DDevice->EndScene();
	gPD3DDevice->Present(nullptr, nullptr, nullptr, nullptr);
}
开发者ID:wakqaz4,项目名称:MyGame,代码行数:26,代码来源:main.cpp

示例2: Render

// Render the model using the given matrix list as a hierarchy (must be one matrix per node)
// and from the given camera
void CMesh::Render(	CMatrix4x4* matrices, CCamera* camera )
{
	if (m_HasGeometry)
	{
		for (TUInt32 subMesh = 0; subMesh < m_NumSubMeshes; ++subMesh)
		{
			// Get a reference to the submesh and its material to reduce code clutter
			SSubMeshDX& sub = m_SubMeshesDX[subMesh];
			SMeshMaterialDX& material = m_Materials[sub.material];

			// Set textures from the material
			for (TUInt32 texture = 0; texture < material.numTextures; ++texture)
			{
				g_pd3dDevice->SetTexture( texture, material.textures[texture] );
			}
			
			// Set material properties
			SetMaterialColour( material.diffuseColour, material.specularColour, material.specularPower );

			// Use the render method from the sub-mesh's material and the matrix from its node
			UseMethod( material.renderMethod, &matrices[sub.node], camera );

			// Tell DirectX the vertex and index buffers to use
			g_pd3dDevice->SetStreamSource( 0, sub.vertexBuffer, 0, sub.vertexSize );
			g_pd3dDevice->SetIndices( sub.indexBuffer );

			// Draw the primitives from the buffer - a triangle list
			g_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, sub.numVertices, 0,
			                                    sub.numIndices / 3 );
		}
	}
}
开发者ID:Nixxus,项目名称:GamesDevelopment2,代码行数:34,代码来源:Mesh.cpp

示例3: render_submodel

    void render_submodel( LPDIRECT3DDEVICE9 device, SubModel& submodel )
    {
        if( submodel.texture ) {
            device->SetTextureStageState(
                0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
            device->SetTextureStageState(
                0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
            device->SetTextureStageState(
                0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
            device->SetTextureStageState(
                0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
            device->SetTextureStageState(
                1, D3DTSS_COLOROP, D3DTOP_DISABLE );
            device->SetTextureStageState(
                1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
            device->SetTexture( 0, submodel.texture->texture );
        } else {
            device->SetTextureStageState(
                0, D3DTSS_COLOROP, D3DTOP_DISABLE );
            device->SetTextureStageState(
                0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
            device->SetTexture( 0, NULL );
        }

        device->SetIndices( submodel.ib );
        device->SetStreamSource(
            0, submodel.vb, 0, sizeof(model_vertex_type) );
        device->SetFVF( model_vertex_type::format );
        device->DrawIndexedPrimitive(
            D3DPT_TRIANGLELIST, 0, 0, submodel.index_source.size(), 0,
            submodel.index_source.size() / 3 );
    }
开发者ID:jonigata,项目名称:yamadumi,代码行数:32,代码来源:shape.cpp

示例4: DrawMesh

/**-----------------------------------------------------------------------------
 * 메시 그리기
 *------------------------------------------------------------------------------
 */
void DrawMesh( D3DXMATRIXA16* pMat )
{
    g_pd3dDevice->SetTransform( D3DTS_WORLD, pMat );
    g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) );
    g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
    g_pd3dDevice->SetIndices( g_pIB );
    g_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, g_cxHeight*g_czHeight, 0, (g_cxHeight-1)*(g_czHeight-1)*2 );
}
开发者ID:blastingzone,项目名称:ComputerGraphicsAdvenced,代码行数:12,代码来源:HeightMap.cpp

示例5: DrawShadowVolume

//*************************************************************************************************************
void DrawShadowVolume(const ShadowCaster& caster)
{
	extrude->SetMatrix("matWorld", &caster.world);
	extrude->CommitChanges();
	
	device->SetVertexDeclaration(shadowdecl);
	device->SetStreamSource(0, caster.vertices, 0, sizeof(D3DXVECTOR4));
	device->SetIndices(caster.indices);
	device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, caster.numvertices, 0, caster.numfaces);
}
开发者ID:IwishIcanFLighT,项目名称:Asylum_Tutorials,代码行数:11,代码来源:main.cpp

示例6: DrawCube

void DrawCube()
{
	// translate model to origin
	D3DXMATRIX world ;
	D3DXMatrixTranslation(&world, 0.0f, 0.0f, 0.0f) ;
	g_pd3dDevice->SetTransform(D3DTS_WORLD, &world) ;

	// set view
	D3DXVECTOR3 eyePt(5.0f, 5.0f, -5.0f) ;
	D3DXVECTOR3 upVec(0.0f, 1.0f, 0.0f) ;
	D3DXVECTOR3 lookCenter(0.0f, 0.0f, 0.0f) ;

	D3DXMATRIX view ;
	D3DXMatrixLookAtLH(&view, &eyePt, &lookCenter, &upVec) ;
	g_pd3dDevice->SetTransform(D3DTS_VIEW, &view) ;

	// set projection
	D3DXMATRIX proj ;
	D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 4, 1.0f, 1.0f, 1000.0f) ;
	g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &proj) ;

	D3DXMATRIX worldviewproj = world * view * proj;

	// Set matrix
	g_pEffect->SetMatrix(g_hWVP, &worldviewproj);

	// Set technique
	g_pEffect->SetTechnique(g_hTech);

	// Render pass
	UINT numPass = 0;
	g_pEffect->Begin(&numPass, 0);
	g_pEffect->BeginPass(0);


	// Set texture
	D3DXCreateTextureFromFile(g_pd3dDevice, "../Common/Media/crate.jpg", &g_pCubeTexture) ;
	g_pEffect->SetTexture("g_pCubeTexture", g_pCubeTexture);


	/*g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);*/

	// Set stream source, and index buffer
	g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(Vertex) );
	g_pd3dDevice->SetIndices(g_pIB) ;
	g_pd3dDevice->SetFVF(VERTEX_FVF) ;

	// Totally 24 points and 12 triangles
	g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 24, 0, 12) ;

	g_pEffect->EndPass();
	g_pEffect->End();
}
开发者ID:BillyKim,项目名称:directxcode,代码行数:55,代码来源:Texture.cpp

示例7: Render

void ZBspTree::Render( LPDIRECT3DDEVICE9 pDev )
{
	pDev->SetFVF( BSPVERTEX::FVF );
//	pDev->SetStreamSource( 0, m_pVB, 0, sizeof(BSPVERTEX) );
	pDev->SetIndices( NULL );

//	pDev->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, m_nVertexCount,
//				m_nFaceCount, m_pTriangleIndex, D3DFMT_INDEX16, m_pPos, sizeof( BSPVERTEX )  );
	
	m_pRootNode->Render( pDev );
}
开发者ID:blastingzone,项目名称:ComputerGraphicsAdvenced,代码行数:11,代码来源:ZBspTree.cpp

示例8: Draw

    void Draw(void) override
    {
        LPDIRECT3DDEVICE9 device;
        m_Data->m_VertexBuffer->GetDevice(&device);
        HRESULT hr;

        hr = device->SetFVF(Vertex3D::FVF);
        hr = device->SetStreamSource(0,m_Data->m_VertexBuffer,0,sizeof(Vertex3D::VERTEX));
        hr = device->SetIndices(m_Data->m_IndexBuffer);
        hr = device->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
    };
开发者ID:AyumiYasui,项目名称:Material,代码行数:11,代码来源:PMDNoBoneManagerDx9.cpp

示例9: 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

示例10: Render

//랜더
void Render(int timeDelta)
{
	//화면 청소
	if (SUCCEEDED(g_pDevice->Clear( 
		0,			//청소할 영역의 D3DRECT 배열 갯수		( 전체 클리어 0 )
		NULL,		//청소할 영역의 D3DRECT 배열 포인터		( 전체 클리어 NULL )
		D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,	//청소될 버퍼 플레그 ( D3DCLEAR_TARGET 컬러버퍼, D3DCLEAR_ZBUFFER 깊이버퍼, D3DCLEAR_STENCIL 스텐실버퍼
		D3DCOLOR_XRGB(255, 255, 255),			//컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
		1.0f,				//깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
		0					//스텐실 버퍼를 채울값
		)))
	{
		//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
		g_pDevice->BeginScene();

		Matrix44 mR;
		if (g_ani)
		{
			g_alpha += timeDelta / 1000.f;
			if (g_alpha > 1)
			{
				g_alpha = 1;
				g_ani = false;
			}
		}

		Vector3 v = g_from.Interpolate(g_to, g_alpha);
		Quaternion quat(Vector3(0,1,0), v);
		mR = quat.GetMatrix();

		Matrix44 tm = mR * g_LocalTm;
		g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&tm);

		g_pDevice->SetTexture(0, g_Texture);
		g_pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
		g_pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
		g_pDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);


		g_pDevice->SetMaterial(&g_Mtrl);
		g_pDevice->SetStreamSource( 0, g_pVB, 0, sizeof(Vertex) );
		g_pDevice->SetIndices(g_pIB);
		g_pDevice->SetFVF( Vertex::FVF );
		g_pDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, g_VtxSize, 0, g_FaceSize);


		//랜더링 끝
		g_pDevice->EndScene();
		//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
		g_pDevice->Present( NULL, NULL, NULL, NULL );
	}
}
开发者ID:kami36,项目名称:Study,代码行数:53,代码来源:RenderQuaternion.cpp

示例11: BeginState

void ZEffectBase::BeginState()
{
	rmatrix id;
	D3DXMatrixIdentity(&id);

	LPDIRECT3DDEVICE9 pDevice = RGetDevice();

	pDevice->SetTransform(D3DTS_WORLD, &id);
	pDevice->SetStreamSource(0,m_pVB,0,sizeof(ZEFFECTCUSTOMVERTEX));
	pDevice->SetIndices(m_pIB);
	pDevice->SetFVF(ZEFFECTBASE_D3DFVF);
	pDevice->SetTexture(0,m_pBaseTexture ? m_pBaseTexture->GetTexture() : NULL );
}
开发者ID:MagistrAVSH,项目名称:node3d,代码行数:13,代码来源:ZEffectBase.cpp

示例12: render

VOID render(){
	g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(192,192,192), 1.0f, 0);
	if(SUCCEEDED(g_pDevice->BeginScene())){
		//Render to the back-buffer
		g_pDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
		g_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
		g_pDevice->SetIndices(g_pIB);
		g_pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0,0,9,0,8);

		g_pDevice->EndScene();
	}
	g_pDevice->Present(NULL, NULL, NULL, NULL);
}
开发者ID:junglek,项目名称:DirectX-Basic,代码行数:13,代码来源:Main.cpp

示例13: Render

//-------------------------------------------------
// Name: Render
// Desc:
//-------------------------------------------------
HRESULT cprimitive::Render(LPDIRECT3DDEVICE9 pd3dDevice)
{
	HRESULT hr;

	W( pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ) );

	W( pd3dDevice->SetIndices(g_pIB) );
	W( pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ) );
	W( pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ) );

	W( pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, m_numVertices, 0, m_numIndices/3) );

	return S_OK;
}
开发者ID:m10914,项目名称:Sphere,代码行数:18,代码来源:cprimitive.cpp

示例14: Render

void ModelMesh::Render( LPDIRECT3DDEVICE9 device )
{
	if( !IsLoaded() )
		return;

	device->SetRenderState( D3DRS_FILLMODE, m_d3d_fillmode);
	device->SetRenderState( D3DRS_CULLMODE, m_d3d_cullmode );

 	device->SetStreamSource( 0, m_vb, 0, sizeof(ModelVertexStruct) );
	device->SetFVF( ModelVertexStruct::FVF );
	device->SetIndices( m_ib );

	device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, m_vertex_size, 0, m_index_size / 3 );
}
开发者ID:YgritteSnow,项目名称:DxLearningDemo,代码行数:14,代码来源:model_mesh.cpp

示例15: Render

//랜더
void Render(int timeDelta)
{
	//화면 청소
	if (SUCCEEDED(g_pDevice->Clear( 
		0,			//청소할 영역의 D3DRECT 배열 갯수		( 전체 클리어 0 )
		NULL,		//청소할 영역의 D3DRECT 배열 포인터		( 전체 클리어 NULL )
		D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,	//청소될 버퍼 플레그 ( D3DCLEAR_TARGET 컬러버퍼, D3DCLEAR_ZBUFFER 깊이버퍼, D3DCLEAR_STENCIL 스텐실버퍼
		D3DCOLOR_XRGB(150, 150, 150),			//컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
		1.0f,				//깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
		0					//스텐실 버퍼를 채울값
		)))
	{
		//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
		g_pDevice->BeginScene();

		g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&global->localTm);

		g_pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
		g_pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
		g_pDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
		g_pDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, global->addressMode) ;
		g_pDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, global->addressMode) ;

		g_pDevice->SetMaterial(&global->mtrl);

		g_pDevice->SetTexture(0, global->texture);
		g_pDevice->SetStreamSource( 0, global->vb, 0, sizeof(Vertex) );
		g_pDevice->SetIndices(global->ib);
		g_pDevice->SetFVF( Vertex::FVF );
		g_pDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, global->vtxSize, 0, global->faceSize);

		switch (global->mode)
		{
		case sGlobal::RENDER_FACE_NORMAL:
			g_pDevice->SetStreamSource( 0, global->fnvb, 0, sizeof(Vertex) );
			g_pDevice->DrawPrimitive( D3DPT_LINELIST, 0, global->faceNormalVtxSize/2);
			break;
		case sGlobal::RENDER_VERTEX_NORMAL:
			g_pDevice->SetStreamSource( 0, global->vnvb, 0, sizeof(Vertex) );
			g_pDevice->DrawPrimitive( D3DPT_LINELIST, 0, global->vertexNormalVtxSize/2);
			break;
		}

		//랜더링 끝
		g_pDevice->EndScene();
		//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
		g_pDevice->Present( NULL, NULL, NULL, NULL );
	}
}
开发者ID:butilities,项目名称:3D-Lecture-2,代码行数:50,代码来源:RenderTextureExporter.cpp


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