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


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

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


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

示例1: Render

void Cube::Render(LPDIRECT3DDEVICE9 pd3dDevice, DWORD dwAttribId) {
    // Set texture
    if (!m_pTexture) {
        m_pTexture = LoadTexture(pd3dDevice, "snow.bmp");
    }
    std::map<int, DWORD> mDwRenderState;
    pd3dDevice->SetTransform(D3DTS_WORLD, GetTransform());
    if (m_bBlending) {
        DWORD dwState;
        pd3dDevice->GetRenderState(D3DRS_ALPHABLENDENABLE, &dwState);
        mDwRenderState[D3DRS_SRCBLEND] = dwState;
        pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);

        pd3dDevice->GetRenderState(D3DRS_SRCBLEND, &dwState);
        mDwRenderState[D3DRS_SRCBLEND] = dwState;
        pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);

        pd3dDevice->GetRenderState(D3DRS_DESTBLEND, &dwState);
        mDwRenderState[D3DRS_DESTBLEND] = dwState;
        pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
    } /*else {
        pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
        pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
    }  */  
    pd3dDevice->SetMaterial(&m_d3dMaterial);
    pd3dDevice->SetTexture(0, m_pTexture);
    m_pMesh->DrawSubset(dwAttribId);

    if (m_bBlending) {
        for (auto &it : mDwRenderState) {
            pd3dDevice->SetRenderState((D3DRENDERSTATETYPE)it.first, it.second);
        }
    }
}
开发者ID:H56,项目名称:Snowman,代码行数:34,代码来源:Cube.cpp

示例2: sizeof

void CLcMdl2D::Render()
{
	DWORD dMnLgt;

	LPDIRECT3DDEVICE9 pDev = (LPDIRECT3DDEVICE9)LcDev_GetD3Device();

	pDev->GetRenderState( D3DRS_LIGHTING, &dMnLgt);

	pDev->SetRenderState( D3DRS_LIGHTING, FALSE);

	pDev->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
	pDev->SetRenderState(D3DRS_ALPHAREF, 0x40);
	pDev->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);

	pDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	pDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	pDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
	
	pDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	pDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	pDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
	
	pDev->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
	pDev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	pDev->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
	
	pDev->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE );
	pDev->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
	pDev->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );


	D3DXMATRIX	mtWld;
	D3DXMATRIX	mtViw;
	D3DXMATRIX	mtViwI;

	pDev->GetTransform(D3DTS_VIEW, &mtViw);
	D3DXMatrixInverse(&mtViwI, NULL, &mtViw);

	mtViwI._41 = 0;
	mtViwI._42 = 0;
	mtViwI._43 = 0;

	mtWld = mtViwI * m_mtWld;
	pDev->SetTransform(D3DTS_WORLD, &mtWld);


	PDTX pTex = (PDTX)m_pTex->GetPointer();

	pDev->SetTexture(0, pTex);
	pDev->SetFVF(VtxDUV1::FVF);
	pDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, m_pVtx, sizeof(VtxDUV1));


	pDev->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE);
	pDev->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE);
	pDev->SetRenderState( D3DRS_ZWRITEENABLE, TRUE);
	pDev->SetRenderState( D3DRS_LIGHTING, dMnLgt);

	LcD3D_SetWorldIdentity(pDev);
}
开发者ID:GALICSOFT,项目名称:glc220_src,代码行数:60,代码来源:LnMdl2D.cpp

示例3: VRender

		HRESULT Grid::VRender(Scene * pScene)
		{
			// This is slightly different from the Chapter 7 implementation...

			LPDIRECT3DDEVICE9 pDevice = pScene->m_pDevice;

			DWORD oldLightMode;
			pDevice->GetRenderState( D3DRS_LIGHTING, &oldLightMode );
			pDevice->SetRenderState( D3DRS_LIGHTING, FALSE );

			DWORD oldCullMode;
			pDevice->GetRenderState( D3DRS_CULLMODE, &oldCullMode );
			pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

			// Setup our texture. Using textures introduces the texture stage states,
			// which govern how textures get blended together (in the case of multiple
			// textures) and lighting information. In this case, we are modulating
			// (blending) our texture with the diffuse color of the vertices.

			pDevice->SetTexture( 0, m_pTexture );
			pDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
			pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
			pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

			pDevice->SetStreamSource( 0, m_pVerts, 0, sizeof(COLORED_TEXTURED_VERTEX) );
			pDevice->SetIndices(m_pIndices);
			pDevice->SetFVF( D3DFVF_COLORED_TEXTURED_VERTEX );
			pDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST , 0, 0, m_numVerts, 0, m_numPolys );

			// Notice that the render states are returned to 
			// their original settings.....
			// Could there be a better way???

			pDevice->SetTexture (0, NULL);
			pDevice->SetRenderState( D3DRS_LIGHTING, oldLightMode );
			pDevice->SetRenderState( D3DRS_CULLMODE, oldCullMode );

			return S_OK;
		}
开发者ID:fwengineer,项目名称:GameEngineFramework,代码行数:39,代码来源:Grid.cpp

示例4: RenderMesh

void CLcMdlSM::RenderMesh()
{
	LPDIRECT3DDEVICE9 pDev = (LPDIRECT3DDEVICE9)LcDev_GetD3Device();

	DWORD dMnLgt;

	pDev->GetRenderState( D3DRS_LIGHTING, &dMnLgt);
	pDev->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
	
	pDev->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
	pDev->SetRenderState(D3DRS_ALPHAREF, 0x40);
	pDev->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
	
	pDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	pDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	pDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

	pDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	pDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	pDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);

	pDev->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
	pDev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	pDev->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

	pDev->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE );
	pDev->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
	pDev->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );


	PDTX	pDXTex	= (PDTX)m_pTex->GetPointer();

	pDev->SetTexture(0, pDXTex);
	pDev->SetFVF(VtxNDUV1::FVF);
	pDev->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0
									, m_nVtx
									, m_nIdx
									, m_pIdx
									, D3DFMT_INDEX16
									, m_pVtx
									, sizeof(VtxNDUV1)
									);

	LcD3D_SetWorldIdentity(pDev);
	pDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
	pDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);

	pDev->SetRenderState( D3DRS_LIGHTING, dMnLgt);
}
开发者ID:GALICSOFT,项目名称:glc220_src,代码行数:49,代码来源:LnMdlSM.cpp

示例5:

void RageDisplay_D3D::DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex )
{
	SendCurrentMatrices();

	DWORD bLighting;
	g_pd3dDevice->GetRenderState( D3DRS_LIGHTING, &bLighting );

	if( !bLighting )
	{
		g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TFACTOR );
		g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR );
	}

	p->Draw( iMeshIndex );

	if( !bLighting )
	{
		g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT );
		g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
	}
}
开发者ID:augustg,项目名称:openitg,代码行数:21,代码来源:RageDisplay_D3D.cpp

示例6: sizeof

void RageDisplay_D3D::SetMaterial( 
	const RageColor &emissive,
	const RageColor &ambient,
	const RageColor &diffuse,
	const RageColor &specular,
	float shininess
	)
{
	/* If lighting is off, then the current material will have no effect.
	 * We want to still be able to color models with lighting off,
	 * so shove the material color in texture factor and modify the 
	 * texture stage to use it instead of the vertex color (our models
	 * don't have vertex coloring anyway). 
	 */
	DWORD bLighting;
	g_pd3dDevice->GetRenderState( D3DRS_LIGHTING, &bLighting );

	if( bLighting )
	{
		D3DMATERIAL9 mat;
		memcpy( &mat.Diffuse, diffuse, sizeof(float)*4 );
		memcpy( &mat.Ambient, ambient, sizeof(float)*4 );
		memcpy( &mat.Specular, specular, sizeof(float)*4 );
		memcpy( &mat.Emissive, emissive, sizeof(float)*4 );
		mat.Power = shininess;
		g_pd3dDevice->SetMaterial( &mat );
	}
	else
	{
		RageColor c = diffuse;
		c.r += emissive.r + ambient.r;
		c.g += emissive.g + ambient.g;
		c.b += emissive.b + ambient.b;
		RageVColor c2 = c;
		DWORD c3 = *(DWORD*)&c2;
		g_pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, c3 );
	}
}
开发者ID:augustg,项目名称:openitg,代码行数:38,代码来源:RageDisplay_D3D.cpp

示例7:

HRESULT HookIDirect3DDevice9::GetRenderState(LPVOID _this, D3DRENDERSTATETYPE State,DWORD* pValue)
{
	LOG_API();
	return pD3Dev->GetRenderState(State, pValue);
}
开发者ID:zxmarcos,项目名称:bg4t_monitor,代码行数:5,代码来源:D3DWrapper.cpp

示例8: SaveAllRenderStates

/**
* Saves all Direct3D 9 render states.
* Used for games that do not work with state blocks for some reason.
***/
void StereoView::SaveAllRenderStates(LPDIRECT3DDEVICE9 pDevice)
{
	// save all Direct3D 9 RenderStates 
	DWORD dwCount = 0;
	pDevice->GetRenderState(D3DRS_ZENABLE                     , &renderStates[dwCount++]); 
	pDevice->GetRenderState(D3DRS_FILLMODE                    , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_SHADEMODE                   , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ZWRITEENABLE                , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ALPHATESTENABLE             , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_LASTPIXEL                   , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_SRCBLEND                    , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_DESTBLEND                   , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_CULLMODE                    , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ZFUNC                       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ALPHAREF                    , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ALPHAFUNC                   , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_DITHERENABLE                , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ALPHABLENDENABLE            , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_FOGENABLE                   , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_SPECULARENABLE              , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_FOGCOLOR                    , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_FOGTABLEMODE                , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_FOGSTART                    , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_FOGEND                      , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_FOGDENSITY                  , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_RANGEFOGENABLE              , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_STENCILENABLE               , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_STENCILFAIL                 , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_STENCILZFAIL                , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_STENCILPASS                 , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_STENCILFUNC                 , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_STENCILREF                  , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_STENCILMASK                 , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_STENCILWRITEMASK            , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_TEXTUREFACTOR               , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_WRAP0                       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_WRAP1                       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_WRAP2                       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_WRAP3                       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_WRAP4                       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_WRAP5                       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_WRAP6                       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_WRAP7                       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_CLIPPING                    , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_LIGHTING                    , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_AMBIENT                     , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_FOGVERTEXMODE               , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_COLORVERTEX                 , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_LOCALVIEWER                 , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_NORMALIZENORMALS            , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_DIFFUSEMATERIALSOURCE       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_SPECULARMATERIALSOURCE      , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_AMBIENTMATERIALSOURCE       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_EMISSIVEMATERIALSOURCE      , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_VERTEXBLEND                 , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_CLIPPLANEENABLE             , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_POINTSIZE                   , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_POINTSIZE_MIN               , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_POINTSPRITEENABLE           , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_POINTSCALEENABLE            , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_POINTSCALE_A                , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_POINTSCALE_B                , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_POINTSCALE_C                , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_MULTISAMPLEANTIALIAS        , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_MULTISAMPLEMASK             , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_PATCHEDGESTYLE              , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_DEBUGMONITORTOKEN           , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_POINTSIZE_MAX               , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE    , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_COLORWRITEENABLE            , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_TWEENFACTOR                 , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_BLENDOP                     , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_POSITIONDEGREE              , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_NORMALDEGREE                , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_SCISSORTESTENABLE           , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_SLOPESCALEDEPTHBIAS         , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ANTIALIASEDLINEENABLE       , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_MINTESSELLATIONLEVEL        , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_MAXTESSELLATIONLEVEL        , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ADAPTIVETESS_X              , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ADAPTIVETESS_Y              , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ADAPTIVETESS_Z              , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ADAPTIVETESS_W              , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_ENABLEADAPTIVETESSELLATION  , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_TWOSIDEDSTENCILMODE         , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_CCW_STENCILFAIL             , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_CCW_STENCILZFAIL            , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_CCW_STENCILPASS             , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_CCW_STENCILFUNC             , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_COLORWRITEENABLE1           , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_COLORWRITEENABLE2           , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_COLORWRITEENABLE3           , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_BLENDFACTOR                 , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_SRGBWRITEENABLE             , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_DEPTHBIAS                   , &renderStates[dwCount++]);
	pDevice->GetRenderState(D3DRS_WRAP8                       , &renderStates[dwCount++]);
//.........这里部分代码省略.........
开发者ID:DrBeef,项目名称:Perception,代码行数:101,代码来源:StereoView.cpp

示例9: Draw

//*****************************************************************************
//【描画】
//  引数の位置を中心として、矩形を描画
//  返り値  : なし
//  第1引数 : 描画中心位置のx座標
//  第2引数 : 描画中心位置のy座標
//*****************************************************************************
void SkinMesh::Draw(void){
	//null check
	if(_mesh == NULL){
		return;
	}
	
	D3DXMATRIX scl_mtx, rot_mtx, translate_mtx;
	LPDIRECT3DDEVICE9 device = NULL;		//デバイス取得用
	int i = 0;//loop index

	device = _renderer->GetDevice();

	//頂点形式
	device->SetVertexDeclaration(_decl);

	DWORD def_cull = 0;
	device->GetRenderState(D3DRS_CULLMODE, &def_cull);

	if(_reverse){
		device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);				//D3DCULL_CW
	}
	else{
		device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);			//D3DCULL_CCW
	}

	//行列の指定
	D3DXMATRIX matrix_table[Renderer::BONE_TABLE_MAX] = {};

	for(i=0; i<_bone_count; i++){
		matrix_table[i] = _bone[i].world_mtx;
	}
	_renderer->SetWorldArray(matrix_table, 52);

	for(i=0; i<_mesh_count; i++){
		//null check
		if(_mesh[i].index == NULL || _mesh[i].vertex == NULL){
			continue;
		}

		_renderer->SetTextureToShader(_mesh[i].texture);

		//_renderer->SetMaterialAmbient(debug_mat.Diffuse);
		D3DXVECTOR4 diffuse(_mesh[i].material.Diffuse.r,
							_mesh[i].material.Diffuse.g,
							_mesh[i].material.Diffuse.b,
							_mesh[i].material.Diffuse.a);
		if(_transparent){
			diffuse.w *= 0.5f;
		}
		_renderer->SetMaterialDiffuse(diffuse);

		_renderer->SetCurrentShader();

		device->SetStreamSource(0, _mesh[i].vertex, 0, sizeof(VERTEX_BLEND_3D));
		device->SetIndices(_mesh[i].index);
		device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, _mesh[i].vertex_count, 0, _mesh[i].index_count / 3);					//描画

	}

	//カリング復旧
	device->SetRenderState(D3DRS_CULLMODE, def_cull);
}
开发者ID:MasahiroNakajima1202,项目名称:commander,代码行数:69,代码来源:skin_mesh.cpp

示例10: Draw

//-------------------------------------
// Draw()
//-------------------------------------
void Shadow::Draw()
{
//	DWORD zfunc;
	LPDIRECT3DDEVICE9 device = DirectX9Holder::device_;

	D3DXMATRIX world, scaling;
	D3DXMatrixIdentity(&world);
	D3DXMatrixScaling(&scaling, parameter_.scaling_.x_, 1.0f, parameter_.scaling_.z_);
	world *= scaling;
	world._41 += parameter_.position_.x_;
	world._42 += parameter_.position_.y_;
	world._43 += parameter_.position_.z_;

	D3DXMATRIX view, projection, wvp;
	device->GetTransform(D3DTS_VIEW, &view);
	device->GetTransform(D3DTS_PROJECTION, &projection);
	wvp = world * view * projection;

	shader_->vertex_table()->SetMatrix(
		device, "matrix_wvp", &wvp);
	device->SetTexture(
		shader_->pixel_table()->GetSamplerIndex("texture_0"), texture_);

	device->SetVertexShader(shader_->vertex_shader());
	device->SetPixelShader(shader_->pixel_shader());

	device->SetVertexDeclaration(
		DirectX9Holder::vertex_declaration_shadow_);

	device->SetStreamSource(
		0,
		vertex_buffer_,
		0,
		sizeof(Vertex3DShadow));

	// レンダーステート保存
	DWORD blendop, srcblend, destblend;//, zfunc;
	device->GetRenderState(D3DRS_BLENDOP, &blendop);
	device->GetRenderState(D3DRS_SRCBLEND, &srcblend);
	device->GetRenderState(D3DRS_DESTBLEND, &destblend);
//	device->GetRenderState(D3DRS_ZFUNC, &zfunc);

	//影用にレンダーステートを減算合成に変更する
	device->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_REVSUBTRACT);
	device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);

	//Zバッファの設定を完全描画にする。
//	device->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);

	// 描画
	device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

	// 変更したレンダースレート修正
//	device->SetRenderState(D3DRS_ZFUNC, zfunc);
	device->SetRenderState(D3DRS_BLENDOP, blendop);
	device->SetRenderState(D3DRS_SRCBLEND, srcblend);
	device->SetRenderState(D3DRS_DESTBLEND, destblend);

	device->SetVertexShader(NULL);
	device->SetPixelShader(NULL);
}
开发者ID:team-h415,项目名称:project-ms,代码行数:65,代码来源:shadow.cpp

示例11: Render

HRESULT KLightning::Render()
{
	HRESULT hr = 0;

	// Backup the previous render states

	DWORD dwPrevLightEnable = 0;
	g_pd3dDevice->GetRenderState(D3DRS_LIGHTING, &dwPrevLightEnable);
	g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);

	DWORD dwPrevCullMode = 0;
	g_pd3dDevice->GetRenderState(D3DRS_CULLMODE, &dwPrevCullMode);
	g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

	DWORD dwPrevFillMode = 0;
	g_pd3dDevice->GetRenderState(D3DRS_FILLMODE, &dwPrevFillMode);
	g_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);

	DWORD dwPrevTexFactor = 0;
	g_pd3dDevice->GetRenderState(D3DRS_TEXTUREFACTOR, &dwPrevTexFactor);
	g_pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, (0x00000000 | m_Alpha) << 24);

	DWORD dwPrevAlphaBlendEnable = 0;
	g_pd3dDevice->GetRenderState(D3DRS_ALPHABLENDENABLE, &dwPrevAlphaBlendEnable);
	g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);

	DWORD dwPrevBlendOP = 0;
	g_pd3dDevice->GetRenderState(D3DRS_BLENDOP, &dwPrevBlendOP);
	g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);

	DWORD dwPrevSrcBlend = 0;
	g_pd3dDevice->GetRenderState(D3DRS_SRCBLEND, &dwPrevSrcBlend);
	g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);

	DWORD dwPrevDestBlend = 0;
	g_pd3dDevice->GetRenderState(D3DRS_DESTBLEND, &dwPrevDestBlend);
	g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);

	D3DXMATRIX mtxPrevWorld, mtxMine;
	D3DXMatrixIdentity(&mtxMine);
	g_pd3dDevice->GetTransform(D3DTS_WORLD, &mtxPrevWorld);
	g_pd3dDevice->SetTransform(D3DTS_WORLD, &mtxMine);

	// Draw

	g_pd3dDevice->SetStreamSource(0, m_pVB, 0, sizeof(KLightningVertex));
	g_pd3dDevice->SetFVF(LIGHTNING_VERTEX_FVF);
	g_pd3dDevice->SetTexture(0, m_pTexture);
	g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
	g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
	g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
	g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

	unsigned int NumOfPTs = m_CurrentNumOfNodes * 2;
	if(FAILED(hr = g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, NumOfPTs)))
	{
		return hr;
	}

	// Recover all the render states

	g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, dwPrevLightEnable);
	g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, dwPrevCullMode);
	g_pd3dDevice->SetRenderState(D3DRS_FILLMODE, dwPrevFillMode);
	g_pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, dwPrevTexFactor);
	g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, dwPrevAlphaBlendEnable);
	g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, dwPrevBlendOP);
	g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, dwPrevSrcBlend);
	g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, dwPrevDestBlend);
	g_pd3dDevice->SetTransform(D3DTS_WORLD, &mtxPrevWorld);

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

示例12: render

/// Rendering the particles involves looping through every live particle
/// and writing it's relevant data to a vertex buffer, and then rendering
/// that vertex buffer.
void ParticleEffect::render()
{
    if(m_nLiveParticleCount == 0) // make sure we have something to render
        return;

    if(m_sort)
        sort();

    // save render states before starting
    DWORD lighting;
    DWORD alphablend;
    DWORD zwrite;
    DWORD zenable;
    DWORD srcblend;
    DWORD destblend;

    pD3DDevice->GetRenderState(D3DRS_LIGHTING, &lighting);
    pD3DDevice->GetRenderState(D3DRS_ALPHABLENDENABLE, &alphablend);
    pD3DDevice->GetRenderState(D3DRS_ZWRITEENABLE, &zwrite);
    pD3DDevice->GetRenderState(D3DRS_ZENABLE, &zenable);
    pD3DDevice->GetRenderState(D3DRS_SRCBLEND, &srcblend);
    pD3DDevice->GetRenderState(D3DRS_DESTBLEND, &destblend);

    // set up particle engine states
    pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
    pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
    if(m_sort)
        pD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
    else
        pD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
    pD3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
    pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
    pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
    //pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
    //pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);

    // set texture operations for alpha blending by setting the color
    // to texture color times diffuse color, and alpha taken entirely from
    // texture value
    pD3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
    pD3DDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
    pD3DDevice->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);
    pD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE);
    pD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
    pD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_DIFFUSE);

    // get camera right and up vectors to figure out how to orient the sprites
    D3DXMATRIXA16 view;
    pD3DDevice->GetTransform(D3DTS_VIEW, &view);

    Vector3 vecRight = Vector3(view._11, view._21, view._31);
    Vector3 vecUp = Vector3(view._12, view._22, view._32);
    Vector3 vecForward = Vector3(view._13, view._23, view._33);

    // precalculate corners
    Vector3 ul, ur, bl, br;
    //ul = -vecRight + vecUp; // upper left
    //ur = vecRight + vecUp;  // upper right
    //bl = -vecRight - vecUp; // bottom left
    //br = vecRight - vecUp;  // bottom right

    pD3DDevice->SetTexture(0, m_txtParticleTexture);

    if(!m_vertBuffer->lock())
    {
        return;
    }

    // shorthand to the current vertex
    RenderVertexL *vert = &((*m_vertBuffer)[0]);

    // although these values are the same for all particles (except color.alpha),
    // you could implement some randomness, at which point there would be a
    // reason to assign to them with every iteration of the loop
    unsigned int color;
    float size = m_fPISize/2.0f; // half of m_fPISize in each direction
    float tTop = 0;
    float tBottom = 1.0f;
    float tLeft = 0;
    float tRight = 1.0f;

    // loop through all live particles to assign proper values to the vertices
    for (int i=0; i<m_nLiveParticleCount; i++)
    {
        Vector3 pos = m_Particles[m_drawOrder[i]].position;
        color = m_Particles[m_drawOrder[i]].color;

        Vector3 myUp, myRight;
        Quaternion q;
        q.setToRotateAboutAxis(vecForward, m_Particles[m_drawOrder[i]].rotation);

        RotationMatrix r;
        r.fromObjectToInertialQuaternion(q);

        myUp = r.objectToInertial(vecUp);
        myRight = r.objectToInertial(vecRight);

//.........这里部分代码省略.........
开发者ID:kmh0237,项目名称:GameProgramming2Project,代码行数:101,代码来源:ParticleEffect.cpp

示例13:


//.........这里部分代码省略.........
	static DWORD texblend[] = 
	{
		D3DTOP_MODULATE,
		D3DTOP_MODULATE,
		D3DTOP_ADD
	};

	int tex_stage = 0;

	for ( int t=0; t<MAX_NUM_TEXTURES; t++ )
	{
		LPDIRECT3DBASETEXTURE9 pTex = NULL;

		if ( CGutModel_DX9::s_pTextureOverwrite[t] )
		{
			pTex = CGutModel_DX9::s_pTextureOverwrite[t];
		}
		else
		{
			pTex = m_pTextures[t];
		}

		if ( bSubmitTexture )
		{
			pDevice->SetTexture(tex_stage, pTex);
		}

		if ( pTex==NULL )
		{
			pDevice->SetTextureStageState(t, D3DTSS_COLOROP, D3DTOP_DISABLE);
			continue;
		}

		if ( bSubmitMtl )
		{
			// 沒有使用Pixel Shader時才需要套用multi-texture混色設定.
			if ( NULL==pPixelShader )
			{
				pDevice->SetTextureStageState(tex_stage, D3DTSS_COLORARG1, D3DTA_TEXTURE);
				pDevice->SetTextureStageState(tex_stage, D3DTSS_COLORARG2, D3DTA_CURRENT);
				pDevice->SetTextureStageState(tex_stage, D3DTSS_COLOROP, texblend[t]);
				
				int MapChannel = CGutModel_DX9::s_MapOverwrite[t]==0xff ? m_MapChannel[t] : CGutModel_DX9::s_MapOverwrite[t];

				switch(MapChannel)
				{
				// sphere map
				case MAP_SPHEREMAP:
					pDevice->SetTextureStageState(tex_stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
					pDevice->SetTextureStageState(tex_stage, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_SPHEREMAP);
					break;
				// cube map
				case MAP_CUBEMAP:
					pDevice->SetTextureStageState(tex_stage, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
					//pDevice->SetTextureStageState(tex_stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3);
					break;
				// pass through
				default:
					pDevice->SetTextureStageState(tex_stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
					pDevice->SetTextureStageState(tex_stage,  D3DTSS_TEXCOORDINDEX, MapChannel);
					break;
				}
			}
			else
			{
				pDevice->SetTextureStageState(tex_stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
				pDevice->SetTextureStageState(tex_stage, D3DTSS_TEXCOORDINDEX, tex_stage);
			}
		}

		tex_stage++;
	}

	// no textures
	if ( 0==tex_stage && NULL==pPixelShader && bSubmitMtl )
	{
		DWORD lighting;
		pDevice->GetRenderState(D3DRS_LIGHTING, &lighting);

		if ( lighting )
		{
			pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
			pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
			pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2);
		}
		else
		{
			pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
			pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
			pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG2);

			int r = m_Material.Diffuse.r * 255;
			int g = m_Material.Diffuse.g * 255;
			int b = m_Material.Diffuse.b * 255;
			int a = m_Material.Diffuse.a * 255;

			pDevice->SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_RGBA(r,g,b,a));
		}
	}
}
开发者ID:ToyAuthor,项目名称:GraphExamples,代码行数:101,代码来源:GutModel_DX9.cpp


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