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


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

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


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

示例1: render

/**
 * @brief 敵を描画する
 *
 */
void Enemy::render()
{
    LPDIRECT3DDEVICE9 pDevice = DXUTGetD3D9Device();

    D3DXMATRIXA16 worldMatrix;
    D3DXMatrixTranslation(&worldMatrix, m_position.x, m_position.y, m_position.z);
    pDevice->SetTransform(D3DTS_WORLD, &worldMatrix);

    for (DWORD i = 0; i < s_numberOfMaterials; ++i) {
        if (this->isDead()) {
            if (m_dieOutTime <= 0) {
                return;
            }

            // 死亡時は、消滅するまで徐々に赤から色を黒くしていく
            D3DMATERIAL9 deadMaterial = s_deadMaterial;
            float red = m_dieOutTime / GameConfiguration::s_ENEMY_DIE_OUT_TIME;
            if (red < 0.50f) {
                red = 0.5f;
            }
            deadMaterial.Diffuse.r = deadMaterial.Ambient.r = red;
            pDevice->SetMaterial(&deadMaterial);
        }
        else {
            pDevice->SetMaterial(&s_meshMaterials.at(i));
        }
        pDevice->SetTexture(0, s_meshTexturePointers.at(i));

        s_pMesh->DrawSubset(i);
    }

#ifdef DEBUG
    s_debugCollision.render();
#endif
}
开发者ID:kwmur,项目名称:my-first-game,代码行数:39,代码来源:Enemy.cpp

示例2: render

VOID render(){
	g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
		D3DCOLOR_XRGB(192, 192, 192), 1.0f, 0);

	if(SUCCEEDED(g_pDevice->BeginScene())){

		setWorldMatrix();
		//First, Render the not transparent part
		for(DWORD i=0; i<g_dwNumMaterials; ++i){
			if(g_pMeshMaterials[i].Diffuse.a == 1.0f){
				g_pDevice->SetMaterial(&g_pMeshMaterials[i]);
				g_pDevice->SetTexture(0, g_pMeshTextures[i]);

				g_pMesh->DrawSubset(i);
			}
		}

		//Second , Render the transparent part
		for(DWORD i=0; i<g_dwNumMaterials; ++i){
			if(g_pMeshMaterials[i].Diffuse.a != 1.0f){
				g_pDevice->SetMaterial(&g_pMeshMaterials[i]);
				g_pDevice->SetTexture(0, g_pMeshTextures[i]);

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

示例3: DrawEnemy

//=============================================================================
// 描画処理
//=============================================================================
void DrawEnemy(void)
{
	LPDIRECT3DDEVICE9 pDevice = GetDevice();
	D3DXMATRIX mtxScl, mtxRot, mtxTranslate;
	D3DXMATERIAL *pD3DXMat;
	D3DMATERIAL9 matDef;

	for(int nCntEnemy = 0; nCntEnemy < MAX_ENEMY; nCntEnemy++)
	{
		if(g_enemy[nCntEnemy].bUse)
		{
			// ワールドマトリックスの初期化
			D3DXMatrixIdentity( &g_enemy[nCntEnemy].mtxWorld);
	
			// スケールを反映
			D3DXMatrixScaling( &mtxScl, g_enemy[nCntEnemy].scl.x, g_enemy[nCntEnemy].scl.y, g_enemy[nCntEnemy].scl.z);
			D3DXMatrixMultiply( &g_enemy[nCntEnemy].mtxWorld, &g_enemy[nCntEnemy].mtxWorld, &mtxScl);
	
			// 回転を反映
			D3DXMatrixRotationYawPitchRoll( &mtxRot, g_enemy[nCntEnemy].rot.y, g_enemy[nCntEnemy].rot.x, g_enemy[nCntEnemy].rot.z);
			D3DXMatrixMultiply( &g_enemy[nCntEnemy].mtxWorld, &g_enemy[nCntEnemy].mtxWorld, &mtxRot);
	
			// 移動を反映
			D3DXMatrixTranslation( &mtxTranslate, g_enemy[nCntEnemy].pos.x, g_enemy[nCntEnemy].pos.y, g_enemy[nCntEnemy].pos.z);
			D3DXMatrixMultiply( &g_enemy[nCntEnemy].mtxWorld, &g_enemy[nCntEnemy].mtxWorld, &mtxTranslate);
	
			// ワールドマトリックスの設定
			pDevice->SetTransform( D3DTS_WORLD, &g_enemy[nCntEnemy].mtxWorld);

			// 現在のマテリアルを取得
			pDevice->GetMaterial(&matDef);
	
			
			ENEMY_TYPE type = g_enemy[nCntEnemy].type;
			// マテリアル情報に対するポインタを取得
			pD3DXMat = (D3DXMATERIAL *)g_modelData[type].pD3DXBuffMat->GetBufferPointer();
			for(int nCntMat = 0; nCntMat < (int)g_modelData[type].nNumMat; nCntMat++)
			{
				// マテリアルの設定
				pDevice->SetMaterial( &pD3DXMat[nCntMat].MatD3D);
				// テクスチャの設定
				pDevice->SetTexture( 0, g_modelData[type].pD3DTexture);
				// 描画
				g_modelData[type].pD3DXMesh->DrawSubset( nCntMat);
			}

			// マテリアルをデフォルトに戻す
			pDevice->SetMaterial( &matDef);		
		}
	}

}
开发者ID:minamiliu,项目名称:Time_To_Shoot,代码行数:55,代码来源:enemy.cpp

示例4: vb

	//	球描画
	void	DrawSphere( LPDIRECT3DDEVICE9 d3dd, CONST D3DXVECTOR3 &p0, FLOAT r, D3DCOLOR c )
	{
		CONST INT N = 36;

		static _VB vb( d3dd, sizeof( D3DXVECTOR3 ) * ( N + 1 ) );
		for ( int n = 0; n < 3; n++ )
		{
			D3DXVECTOR3 *p;
			vb->Lock( 0, 0, ( void ** )&p, 0 );
			for ( int i = 0; i < N; i++ )
			{
				switch (  n )
				{
				case 0: p[i] = r * D3DXVECTOR3( sinf( 360.0f / N * 0.01745f * i ), cosf( 360.0f / N * 0.01745f * i ), 0 ) + p0; break;
				case 1: p[i] = r * D3DXVECTOR3( sinf( 360.0f / N * 0.01745f * i ), 0, cosf( 360.0f / N * 0.01745f * i ) ) + p0; break;
				case 2: p[i] = r * D3DXVECTOR3( 0, sinf( 360.0f / N * 0.01745f * i ), cosf( 360.0f / N * 0.01745f * i ) ) + p0; break;
				}
			}
			p[N] = p[0];
			vb->Unlock();

			D3DMATERIAL9 m = { 0 };
			m.Diffuse = m.Ambient = D3DXCOLOR( c );
			d3dd->SetMaterial( &m );

			d3dd->SetFVF( D3DFVF_XYZ );
			d3dd->SetStreamSource( 0, vb, 0, sizeof( D3DXVECTOR3 ) );
			d3dd->SetTransform( D3DTS_WORLD, &D3DXMATRIX( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ) );
			d3dd->DrawPrimitive( D3DPT_LINESTRIP, 0, N );
		}
	}
开发者ID:NyamLand,项目名称:WonderToyBox,代码行数:32,代码来源:GlobalFunction.cpp

示例5: render_1

//-----------------------------------------------------------------------------
// Name: render_1()
// Desc:
//-----------------------------------------------------------------------------
void render_1( void )
{
    D3DXMATRIX matView;
    D3DXMATRIX matWorld;
    D3DXMATRIX matRotation;
    D3DXMATRIX matTranslation;

    // Now we can clear just view-port's portion of the buffer to green...
    g_pd3dDevice_1->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE( 0.0f, 1.0f, 0.0f, 1.0f ), 1.0f, 0 );

    g_pd3dDevice_1->BeginScene();

    // For the left view-port, leave the view at the origin...
    D3DXMatrixIdentity( &matView );
    g_pd3dDevice_1->SetTransform( D3DTS_VIEW, &matView );

    // ... and use the world matrix to spin and translate the teapot
    // out where we can see it...
    D3DXMatrixRotationYawPitchRoll( &matRotation, D3DXToRadian(g_fSpinX), D3DXToRadian(g_fSpinY), 0.0f );
    D3DXMatrixTranslation( &matTranslation, 0.0f, 0.0f, 5.0f );
    matWorld = matRotation * matTranslation;
    g_pd3dDevice_1->SetTransform( D3DTS_WORLD, &matWorld );


    g_pd3dDevice_1->SetMaterial( &g_teapotMtrl );
    g_pTeapotMesh_1->DrawSubset(0);

    g_pd3dDevice_1->EndScene();

    // We're done! Now, we just call Present()
    g_pd3dDevice_1->Present( NULL, NULL, NULL, NULL );
}
开发者ID:djrobx,项目名称:vpinballx,代码行数:36,代码来源:multipleFullscreen.c

示例6: DrawAlpha

//**関数***************************************************************************
//	概要	:	メッシュ半透明部分のみ描画 (アルファ有効化/無効化なし)
//*********************************************************************************
void CMesh::DrawAlpha(D3DXMATRIX& world , S_HANDLE nShadeHndle)
{
	// ワールド マトリックス設定
    LPDIRECT3DDEVICE9 pDevice = CGraphics::GetDevice();
	CShader* pShade = REGISTER_H_P(nShadeHndle , CShader*);
	
	if(nShadeHndle == 0)
		pDevice->SetTransform(D3DTS_WORLD, &world);
	else
		pShade->SetWorldMatrix(&world);

	for (DWORD i = 0; i < m_dwAttr; i++) 
	{
		DWORD id = m_pAttr[i].AttribId;
        // アルファ値をチェック
        D3DMATERIAL9 mtrl = m_pMaterial[id];
		if (mtrl.Diffuse.a >= 1.0f)
			continue;

		if(nShadeHndle == 0)
		{
			pDevice->SetMaterial(&mtrl);
			pDevice->SetTexture(0, m_ppTexture[id]);	// テクスチャを設定
		}
		else
			pShade->SetMaterial(&mtrl , m_ppTexture[id]);

		m_pD3DMesh->DrawSubset(id);					// 描画を実行
	}
}
开发者ID:FujiokaNaoto,项目名称:DirectX_Base,代码行数:33,代码来源:Mesh.cpp

示例7: DrawBox

//**関数***************************************************************************
//	概要	:	OBBの描画
//*********************************************************************************
void CMesh::DrawBox(D3DXMATRIX& world, D3DCOLORVALUE color)
{
    LPDIRECT3DDEVICE9 pDevice = CGraphics::GetDevice();

	// ワールド マトリックス設定
	D3DXMATRIX m;
	D3DXMatrixTranslation(&m, m_vCenter.x, m_vCenter.y, m_vCenter.z);
	m *= world;
    pDevice->SetTransform(D3DTS_WORLD, &m);

    // アルファ ブレンド有効化
	pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
    pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
    pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

	// メッシュ描画
	D3DMATERIAL9 mtrl = {
		color,//Diffuse
		color,//Ambient
		{1.0f, 1.0f, 1.0f, 1.0f},//Specular
		{0.0f, 0.0f, 0.0f, 1.0f},//Emissive
		1.0f//Power
	};

	pDevice->SetMaterial(&mtrl);
	pDevice->SetTexture(0, NULL);
	pDevice->SetFVF(D3DFVF_XYZ |
		D3DFVF_NORMAL | D3DFVF_TEX1);
	m_pBox->DrawSubset(0);

    // アルファ ブレンド無効化
    pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
开发者ID:FujiokaNaoto,项目名称:DirectX_Base,代码行数:36,代码来源:Mesh.cpp

示例8: Draw

//**関数***************************************************************************
//	概要	:	半透明描画
//*********************************************************************************
void CMesh::Draw(D3DXMATRIX& world, float fAlpha)
{
    // ワールド マトリックス設定
    LPDIRECT3DDEVICE9 pDevice = CGraphics::GetDevice();
    pDevice->SetTransform(D3DTS_WORLD, &world);

    // アルファ ブレンド有効化
    pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
    pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
    pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

    for (DWORD i = 0; i < m_dwAttr; i++) {
        DWORD id = m_pAttr[i].AttribId;

        // アルファ値を変更
        D3DMATERIAL9 mtrl = m_pMaterial[id];
        mtrl.Diffuse.a *= fAlpha;
        pDevice->SetMaterial(&mtrl);

        pDevice->SetTexture(0, m_ppTexture[id]);
        pDevice->SetFVF(FVF_BVERTEX);

		pDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST,
			m_pAttr[i].FaceCount,
			&m_pPieceVtx[m_pAttr[i].FaceStart * 3],
			sizeof(BVERTEX));
    }

    // アルファ ブレンド無効化
    pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
开发者ID:FujiokaNaoto,项目名称:DirectX_Base,代码行数:34,代码来源:Mesh.cpp

示例9: Render

//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render(bool b_AutoRotation, bool b_WireframeMode)
{
    // Clear the backbuffer and the zbuffer
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
                         D3DCOLOR_ARGB( 0, 0, 0, 0 ), 1.0f, 0 );

    // Begin the scene
    if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
    {
        // Setup the world, view, and projection matrices
		// SetupMatrices();
        if (b_AutoRotation) SetupMatrices();
		g_pd3dDevice->SetRenderState(D3DRS_FILLMODE, (b_WireframeMode) ? D3DFILL_WIREFRAME : D3DFILL_SOLID);
		g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, (b_WireframeMode) ? D3DCULL_NONE : D3DCULL_CCW);

        // D3DRenderer are divided into subsets, one for each material. Render them in
        // a loop
        for( DWORD i = 0; i < g_dwNumMaterials; i++ )
        {
            // Set the material and texture for this subset
            g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] );
            g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );

            // Draw the mesh subset
            g_pMesh->DrawSubset( i );
        }

        // End the scene
        g_pd3dDevice->EndScene();
    }

    // Present the backbuffer contents to the display
    // g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
开发者ID:Narinyir,项目名称:WPF-DirectX,代码行数:38,代码来源:D3DRenderer.cpp

示例10: _render

	type_result HierarchySubReferer::_render( D3DMATERIAL9& material )
	{
		_initializeMesh();
		//	main:
		//		DX9 바인딩:
		DX9& dx9 = getDependent();
		if( ! &dx9)
		{
			ALERT_ERROR(" : 디바이스 바인딩 실패로 중지");
			return RESULT_TYPE_ERROR;
		}
		LPDIRECT3DDEVICE9 device = dx9.getDevice();		
		//		월드좌표 갱신:
		D3DXMATRIX& world = getWorldMatrix();
		D3DXMATRIX origin;
		device->GetTransform(D3DTS_WORLD, &origin);
		device->SetTransform(D3DTS_WORLD, &world);

		device->SetRenderState(D3DRS_AMBIENT, 0xffffffff);

		//device->SetTexture(0, NULL);
		device->SetMaterial(&material);
		device->SetTexture(0, 0);
		if(_ball)
		{			
			_ball->DrawSubset(0);
		}

		//		자식과 선을 잇기:
		device->SetTransform(D3DTS_WORLD, &origin);

		_searchModuleSet(getConnector().getModuleCodeSetKey().getValue(), &ThisClass::_renderLineBetweenChild);			//		월드 좌표 복귀:
		return RESULT_SUCCESS;
	}
开发者ID:kniz,项目名称:World,代码行数:34,代码来源:HierarchySubReferer.cpp

示例11: SetupLights

//-----------------------------------------------------------------------------
// Name: SetupLights()
// Desc: Sets up the lights and materials for the scene.
//-----------------------------------------------------------------------------
VOID SetupLights()
{
    // Set up a material. The material here just has the diffuse and ambient
    // colors set to yellow. Note that only one material can be used at a time.
    D3DMATERIAL9 mtrl;
    ZeroMemory( &mtrl, sizeof(D3DMATERIAL9) );
    mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
    mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
    mtrl.Diffuse.b = mtrl.Ambient.b = 0.0f;
    mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
    g_pd3dDevice->SetMaterial( &mtrl );

    // Set up a white, directional light, with an oscillating direction.
    // Note that many lights may be active at a time (but each one slows down
    // the rendering of our scene). However, here we are just using one. Also,
    // we need to set the D3DRS_LIGHTING renderstate to enable lighting
    D3DXVECTOR3 vecDir;
    D3DLIGHT9 light;
    ZeroMemory( &light, sizeof(D3DLIGHT9) );
    light.Type       = D3DLIGHT_DIRECTIONAL;
    light.Diffuse.r  = 1.0f;
    light.Diffuse.g  = 1.0f;
    light.Diffuse.b  = 1.0f;
    vecDir = D3DXVECTOR3(cosf(timeGetTime()/350.0f),
                         1.0f,
                         sinf(timeGetTime()/350.0f) );
    D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &vecDir );
    light.Range       = 1000.0f;
    g_pd3dDevice->SetLight( 0, &light );
    g_pd3dDevice->LightEnable( 0, TRUE );
    g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );

    // Finally, turn on some ambient light.
    g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00202020 );
}
开发者ID:arlukin,项目名称:dev,代码行数:39,代码来源:Lights.cpp

示例12: if

// ---------- framework : display ----------
bool rtvsD3dApp::display (LPDIRECT3DDEVICE9 pd3dDevice)
{
 	// clear backbuffers
  pd3dDevice->Clear( 0,
	NULL,
	D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
	D3DCOLOR_COLORVALUE(0.0f,0.3f,0.7f,1.0f),
	1.0f,
	0);

  // check if should render
  if (m_antShouldRender) { // ant says render
    if (
      !m_pTracer->m_shouldRender // tracer isn't rendering
      && !m_pTracer->m_isRenderDone // tracer isn't done
    ) { 
      // tell it to render
      m_pTracer->startRender();
    }
    else if (
      !m_pTracer->m_shouldRender // tracer isn't rendering
      && m_pTracer->m_isRenderDone // tracer is done
    ) {
      // reset and tell it to render
      m_pTracer->resetRender(pTexture);
      m_pTracer->startRender();
    }
  }
  else // ant says don't render
  {
    if(m_pTracer->m_shouldRender) // tracer is rendering
      m_pTracer->m_shouldRender = false; // tell it to stop
  }

  // if tracer should be rendering
  if(m_pTracer->m_shouldRender)
  {
    // trace line by line & check if done
    m_antShouldRender = m_pTracer->traceNextLine();

    // try to render
    returnvalue = m_pTracer->render(pTexture);
    if (FAILED(returnvalue))
      return false;
  }

	// display solid textured quad
	pd3dDevice->SetMaterial( &quadMtrl );
	pd3dDevice->SetTexture( 0, pTexture );
	pd3dDevice->SetStreamSource( 0, pQuadVertexBuffer, 0, sizeof(QuadVertex) );
	pd3dDevice->SetFVF( QuadVertex::FVF_Flags );
	pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
	pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, numQuadTriangles );

	TwDraw();  // draw the tweak bar GUI

	// ok
	return true;

}
开发者ID:iqabsent,项目名称:cge-raytracer,代码行数:61,代码来源:rtvsD3dApp.cpp

示例13: InitLight

void InitLight()
{
    D3DMATERIAL9 material;    // create the material struct

	D3DLIGHT9 light;    // create the light struct
	ZeroMemory(&light, sizeof(light));    // clear out the light struct for use
    light.Type = D3DLIGHT_DIRECTIONAL;    // make the light type 'directional light'
    light.Diffuse = D3DXCOLOR(0.7f, 0.7f, 0.7f, 1.0f);    // set the light's color
    light.Position = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	light.Direction = D3DXVECTOR3(0.5f, -1.0f, -1.0f);
    d3ddev->SetLight(0, &light);    // send the light struct properties to light #0
    d3ddev->LightEnable(0, TRUE);    // turn on light #0

	D3DLIGHT9 pointLight;    // create the light struct
	ZeroMemory(&pointLight, sizeof(pointLight));    // clear out the light struct for use
	pointLight.Type = D3DLIGHT_POINT;    // make the light type 'point light'
	pointLight.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);    // set the light's color
	pointLight.Position = D3DXVECTOR3(0.0f, 7.0f, 5.0f);
	//pointLight.Direction = D3DXVECTOR3(0.5f, -1.0f, -1.0f);
	pointLight.Range = 100.0f;
	pointLight.Attenuation0 = 0.0f;    // no constant inverse attenuation
	pointLight.Attenuation1 = 0.125f;    // only .125 inverse attenuation
	pointLight.Attenuation2 = 0.0f;    // no square inverse attenuation
	d3ddev->SetLight(1, &pointLight);    // send the light struct properties to light #0
	d3ddev->LightEnable(1, TRUE);    // turn on light #1

    ZeroMemory(&material, sizeof(D3DMATERIAL9));    // clear out the struct for use
    material.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);    // set diffuse color to white
    material.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);    // set ambient color to white

    d3ddev->SetMaterial(&material);    // set the globably-used material to &material
}
开发者ID:ppeschke,项目名称:hexar,代码行数:32,代码来源:direct3d.cpp

示例14: Render

//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
    // Clear the backbuffer and the zbuffer
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 
                         D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
    
    // Begin the scene
    if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
    {
        // Setup the world, view, and projection matrices
        SetupMatrices();

        // Meshes are divided into subsets, one for each material. Render them in
        // a loop
        for( DWORD i=0; i<g_dwNumMaterials; i++ )
        {
            // Set the material and texture for this subset
            g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] );
            g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );
        
            // Draw the mesh subset
            g_pMesh->DrawSubset( i );
        }

        // End the scene
        g_pd3dDevice->EndScene();
    }

    // Present the backbuffer contents to the display
    g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
开发者ID:arlukin,项目名称:dev,代码行数:35,代码来源:Meshes.cpp

示例15: Render

//-----------------------------------------------------------------------------
// Desc: 渲染场景
//-----------------------------------------------------------------------------
VOID Render()
{
	// 清除缓冲区
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 
		D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );

	//开始渲染场景
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		SetWorldMatrix();  //设置世界矩阵

		//逐块渲染网格模型
		for( DWORD i=0; i<g_dwNumMaterials; i++ )
		{
			//设置材料和纹理
			g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] );
			g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );

			//渲染模型
			g_pMesh->DrawSubset( i );
		}

		//场景渲染结束
		g_pd3dDevice->EndScene();
	}

	//在屏幕上显示场景
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
开发者ID:as2120,项目名称:ZNginx,代码行数:32,代码来源:StateControlUseMatrix.cpp


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