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


C++ IDirect3DStateBlock9类代码示例

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


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

示例1: DrawShadow

	//
	//	Use stencil buffer as a mask. draw shadows to the scene
	//
	HRESULT DrawShadow(IDirect3DDevice9* pd3dDevice)
	{
		IDirect3DStateBlock9* pStateBlock = NULL;
		pd3dDevice->CreateStateBlock(D3DSBT_ALL, &pStateBlock);

		// Set renderstates (disable z-buffering, enable stencil, disable fog, and
		// turn on alphablending)
		SetRenderStateSafe(pd3dDevice, D3DRS_ZENABLE,			FALSE);
		SetRenderStateSafe(pd3dDevice, D3DRS_STENCILENABLE,		TRUE);
		SetRenderStateSafe(pd3dDevice, D3DRS_FOGENABLE,			FALSE);
		SetRenderStateSafe(pd3dDevice, D3DRS_ALPHABLENDENABLE,	TRUE);
		SetRenderStateSafe(pd3dDevice, D3DRS_SRCBLEND,			D3DBLEND_SRCALPHA);
		SetRenderStateSafe(pd3dDevice, D3DRS_DESTBLEND,			D3DBLEND_INVSRCALPHA);
		SetRenderStateSafe(pd3dDevice, D3DRS_ALPHATESTENABLE,	FALSE);
		
		// Only write where stencil val >= 1 (count indicates # of shadows that
		// overlap that pixel)
		SetRenderStateSafe(pd3dDevice, D3DRS_STENCILREF,		0x1);
		SetRenderStateSafe(pd3dDevice, D3DRS_STENCILFUNC,		D3DCMP_LESSEQUAL);
		SetRenderStateSafe(pd3dDevice, D3DRS_CULLMODE,			D3DCULL_CCW); // counter clock-wise render triangles
		pd3dDevice->EndStateBlock(&pStateBlock);

		// Draw a big, gray square
		pd3dDevice->SetFVF( SHADOWVERTEX::FVF );
		pd3dDevice->SetStreamSource( 0, g_pBigSquareVB, 0, sizeof(SHADOWVERTEX) );
		pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );

		pStateBlock->Apply();
		SAFE_RELEASE(pStateBlock);
		return S_OK;
	}
开发者ID:dima424658,项目名称:Direct3D8to9,代码行数:34,代码来源:ShadowVolumeHandler.cpp

示例2: cullGrass

// renderStage1 - Render grass and shadows over near features, and write depth texture for scene 0
void DistantLand::renderStage1()
{
    DECLARE_MWBRIDGE
    IDirect3DStateBlock9 *stateSaved;
    UINT passes;

    ///LOG::logline("Stage 1 prims: %d", recordMW.size());

    if(!isRenderCached)
    {
        // Save state block manually since we can change FVF/decl
        device->CreateStateBlock(D3DSBT_ALL, &stateSaved);

        // TODO: Locate this properly
        if(isDistantCell())
            cullGrass(&mwView, &mwProj);

        if(isDistantCell())
        {
            // Render over Morrowind domain
            effect->Begin(&passes, D3DXFX_DONOTSAVESTATE);

            // Draw grass with shadows
            if(Configuration.MGEFlags & USE_GRASS)
            {
                effect->BeginPass(PASS_RENDERGRASSINST);
                renderGrassInst();
                effect->EndPass();
            }

            // Overlay shadow onto Morrowind objects
            if((Configuration.MGEFlags & USE_SHADOWS) && mwBridge->CellHasWeather())
            {
                effect->BeginPass(PASS_RENDERSHADOW);
                renderShadow();
                effect->EndPass();

            }

            effect->End();
        }

        // Depth texture from recorded renders and distant land
        effectDepth->Begin(&passes, D3DXFX_DONOTSAVESTATE);
        renderDepth();
        effectDepth->End();

        // Restore render state
        stateSaved->Apply();
        stateSaved->Release();
    }

    recordMW.clear();
}
开发者ID:europop,项目名称:MGE-XE,代码行数:55,代码来源:distantland.cpp

示例3: RenderShadow

	//
	// Render shadow information to stencil buffer
	//
	HRESULT RenderShadow(IDirect3DDevice9* pd3dDevice)
	{
		IDirect3DStateBlock9* pStateBlock = NULL;
		pd3dDevice->CreateStateBlock(D3DSBT_ALL, &pStateBlock);

		// Disable z-buffer writes (note: z-testing still occurs), and enable the
		// stencil-buffer
		SetRenderStateSafe(pd3dDevice, D3DRS_ZWRITEENABLE,	FALSE);
		SetRenderStateSafe(pd3dDevice, D3DRS_STENCILENABLE,	TRUE);

		// If ztest passes, inc/decrement stencil buffer value
		SetRenderStateSafe(pd3dDevice, D3DRS_STENCILREF,	0x1);
		SetRenderStateSafe(pd3dDevice, D3DRS_STENCILPASS,	D3DSTENCILOP_INCR);
	
		// Make sure that no pixels get drawn to the frame buffer
		SetRenderStateSafe(pd3dDevice, D3DRS_ALPHABLENDENABLE,	TRUE);
		SetRenderStateSafe(pd3dDevice, D3DRS_SRCBLEND,			D3DBLEND_ZERO);
		SetRenderStateSafe(pd3dDevice, D3DRS_DESTBLEND,			D3DBLEND_ONE);

		// TODO: Check device caps
		if(true)
		{
			// With 2-sided stencil, we can avoid rendering twice:
			SetRenderStateSafe(pd3dDevice, D3DRS_TWOSIDEDSTENCILMODE,	TRUE);
			SetRenderStateSafe(pd3dDevice, D3DRS_CCW_STENCILPASS,		D3DSTENCILOP_DECR);
			SetRenderStateSafe(pd3dDevice, D3DRS_CULLMODE,				D3DCULL_NONE);

			// Draw both sides of shadow volume in stencil/z only
			g_baseShadow.Render( pd3dDevice );

			SetRenderStateSafe(pd3dDevice, D3DRS_TWOSIDEDSTENCILMODE,	FALSE);
		}
		else
		{
			// Draw front-side of shadow volume in stencil/z only
			SetRenderStateSafe(pd3dDevice, D3DRS_CULLMODE,		D3DCULL_CCW);
			g_baseShadow.Render( pd3dDevice );

			// Now reverse cull order so back sides of shadow volume are written.
			SetRenderStateSafe(pd3dDevice, D3DRS_CULLMODE,		D3DCULL_CW);

			// Decrement stencil buffer value
			SetRenderStateSafe(pd3dDevice, D3DRS_STENCILPASS,	D3DSTENCILOP_DECR);

			// Draw back-side of shadow volume in stencil/z only
			g_baseShadow.Render( pd3dDevice );
		}

		pd3dDevice->EndStateBlock(&pStateBlock);
		pStateBlock->Apply();
		SAFE_RELEASE(pStateBlock);
		return S_OK;
	}
开发者ID:dima424658,项目名称:Direct3D8to9,代码行数:56,代码来源:ShadowVolumeHandler.cpp

示例4: renderStageBlend

// renderStageBlend - Blend between MGE distant land and Morrowind, rendering caustics first so it blends out
void DistantLand::renderStageBlend()
{
    DECLARE_MWBRIDGE
    IDirect3DStateBlock9 *stateSaved;
    UINT passes;

    if(isRenderCached)
        return;

    // Save state block manually since we can change FVF/decl
    device->CreateStateBlock(D3DSBT_ALL, &stateSaved);
    effect->Begin(&passes, D3DXFX_DONOTSAVESTATE);

    // Render caustics
    if(mwBridge->IsExterior() && Configuration.DL.WaterCaustics > 0)
    {
        D3DXMATRIX m;
        IDirect3DTexture9 *tex = PostShaders::borrowBuffer(0);
        D3DXMatrixTranslation(&m, eyePos.x, eyePos.y, mwBridge->WaterLevel());

        effect->SetTexture(ehTex0, tex);
        effect->SetTexture(ehTex1, texWater);
        effect->SetTexture(ehTex3, texDepthFrame);
        effect->SetMatrix(ehWorld, &m);
        effect->SetFloat(ehAlphaRef, Configuration.DL.WaterCaustics);
        effect->CommitChanges();

        effect->BeginPass(PASS_RENDERCAUSTICS);
        PostShaders::applyBlend();
        effect->EndPass();
    }

    // Blend MW/MGE
    if(isDistantCell() && (~Configuration.MGEFlags & NO_MW_MGE_BLEND))
    {
        effect->SetTexture(ehTex0, texDistantBlend);
        effect->SetTexture(ehTex3, texDepthFrame);
        effect->CommitChanges();

        effect->BeginPass(PASS_BLENDMGE);
        PostShaders::applyBlend();
        effect->EndPass();
    }

    effect->End();
    stateSaved->Apply();
    stateSaved->Release();
}
开发者ID:europop,项目名称:MGE-XE,代码行数:49,代码来源:distantland.cpp

示例5: RenderMeshes

void Overlay::RenderMeshes()
{
    if(g_Globals.UsingOverlay && _Meshes.Length() > 0)
	{
        IDirect3DStateBlock9* pStateBlock = NULL;
        _Device->CreateStateBlock( D3D9Base::D3DSBT_ALL, &pStateBlock );

        const UINT MaxTextureSlots = 8;
        for(UINT TextureIndex = 0; TextureIndex < MaxTextureSlots; TextureIndex++)
        {
            _Device->SetTexture(TextureIndex, NULL);
        }

        D3D9Base::D3DXMATRIXA16 NewTransformWorld, NewTransformView, NewTransformProjection;
        NewTransformWorld = Matrix4ToD3DXMATRIX(Matrix4::Identity());
        NewTransformView = Matrix4ToD3DXMATRIX(Matrix4::Identity());
        NewTransformProjection = Matrix4ToD3DXMATRIX(_MeshTransform);

        _Device->SetTransform(D3DTS_WORLD, &NewTransformWorld);
        _Device->SetTransform(D3D9Base::D3DTS_VIEW, &NewTransformView);
        _Device->SetTransform(D3D9Base::D3DTS_PROJECTION, &NewTransformProjection);

        _Device->SetRenderState(D3D9Base::D3DRS_ALPHABLENDENABLE, FALSE);
        //_Device->SetRenderState(D3D9Base::D3DRS_ZENABLE, D3D9Base::D3DZB_TRUE);
        _Device->SetRenderState(D3D9Base::D3DRS_ZENABLE, D3D9Base::D3DZB_FALSE);
        _Device->SetRenderState(D3D9Base::D3DRS_LIGHTING, FALSE);
        _Device->SetRenderState(D3D9Base::D3DRS_ZFUNC, D3D9Base::D3DCMP_ALWAYS);
        _Device->SetRenderState(D3D9Base::D3DRS_ALPHATESTENABLE, FALSE);
        _Device->SetRenderState(D3D9Base::D3DRS_CULLMODE, D3D9Base::D3DCULL_NONE);

        const DWORD D3DMeshFlags = D3DFVF_DIFFUSE | D3DFVF_NORMAL | D3DFVF_XYZ | D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEX1;
        _Device->SetFVF(D3DMeshFlags);
        
        _Device->SetVertexShader(NULL);
        _Device->SetPixelShader(NULL);
        
        for(UINT MeshIndex = 0; MeshIndex < _Meshes.Length(); MeshIndex++)
        {
            Mesh &CurMesh = *(_Meshes[MeshIndex]);
            _Device->DrawIndexedPrimitiveUP(D3D9Base::D3DPT_TRIANGLELIST, 0, CurMesh.VertexCount(), CurMesh.FaceCount(), CurMesh.Indices(), D3D9Base::D3DFMT_INDEX32, CurMesh.Vertices(), sizeof(MeshVertex));
        }

        pStateBlock->Apply();
        pStateBlock->Release();
    }
}
开发者ID:kbinani,项目名称:dxrip,代码行数:46,代码来源:Overlay.cpp

示例6: renderShadow

// renderStage2 - Render shadows and depth texture for scenes 1+ (post-stencil redraw/alpha/1st person)
void DistantLand::renderStage2()
{
    DECLARE_MWBRIDGE
    IDirect3DStateBlock9 *stateSaved;
    UINT passes;

    ///LOG::logline("Stage 2 prims: %d", recordMW.size());

    // Early out if nothing is happening
    if(recordMW.empty())
        return;

    if(!isRenderCached)
    {
        // Save state block manually since we can change FVF/decl
        device->CreateStateBlock(D3DSBT_ALL, &stateSaved);

        if(isDistantCell())
        {
            // Shadowing onto recorded renders
            if((Configuration.MGEFlags & USE_SHADOWS) && mwBridge->CellHasWeather())
            {
                effect->Begin(&passes, D3DXFX_DONOTSAVESTATE);

                effect->BeginPass(PASS_RENDERSHADOW);
                renderShadow();
                effect->EndPass();

                effect->End();
            }
        }

        // Depth texture from recorded renders
        effectDepth->Begin(&passes, D3DXFX_DONOTSAVESTATE);
        renderDepthAdditional();
        effectDepth->End();

        // Restore state
        stateSaved->Apply();
        stateSaved->Release();
    }

    recordMW.clear();
}
开发者ID:europop,项目名称:MGE-XE,代码行数:45,代码来源:distantland.cpp

示例7: ods

void DevState::createCleanState() {
	if (dwMyThread != 0) {
		ods("D3D9: CreateCleanState from other thread.");
	}
	Stash<DWORD> stashThread(&dwMyThread, GetCurrentThreadId());

	if (pSB)
		pSB->Release();
	pSB = NULL;

	IDirect3DStateBlock9* pStateBlock = NULL;
	dev->CreateStateBlock(D3DSBT_ALL, &pStateBlock);
	if (! pStateBlock)
		return;

	pStateBlock->Capture();

	dev->CreateStateBlock(D3DSBT_ALL, &pSB);
	if (! pSB) {
		pStateBlock->Release();
		return;
	}

	D3DVIEWPORT9 vp;
	dev->GetViewport(&vp);

	dev->SetVertexShader(NULL);
	dev->SetPixelShader(NULL);
	dev->SetFVF(D3DFVF_TLVERTEX);

	dev->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
	dev->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
	dev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); // 0x16
	dev->SetRenderState(D3DRS_WRAP0, FALSE); // 0x80

	dev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	dev->SetRenderState(D3DRS_SRCBLEND,  D3DBLEND_ONE);
	dev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

	dev->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
	dev->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);

	dev->SetRenderState(D3DRS_ZENABLE, FALSE);
	dev->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
	dev->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
	dev->SetRenderState(D3DRS_COLORVERTEX, FALSE);

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

	dev->SetRenderState(D3DRS_LIGHTING, FALSE);

	pSB->Capture();

	pStateBlock->Apply();
	pStateBlock->Release();
}
开发者ID:Andrew-McLeod,项目名称:mumble,代码行数:58,代码来源:d3d9.cpp

示例8: doPresent

static void doPresent(IDirect3DDevice9 *idd) {
	DevMapType::iterator it = devMap.find(idd);
	DevState *ds = it != devMap.end() ? it->second : NULL;

	if (ds && ds->pSB) {
		if (ds->dwMyThread != 0) {
			ods("D3D9: doPresent from other thread");
		}
		Stash<DWORD> stashThread(&(ds->dwMyThread), GetCurrentThreadId());

		IDirect3DSurface9 *pTarget = NULL;
		IDirect3DSurface9 *pRenderTarget = NULL;
		idd->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pTarget);
		idd->GetRenderTarget(0, &pRenderTarget);

		// Present is called for each frame. Thus, we do not want to always log here.
		#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
		ods("D3D9: doPresent BackB %p RenderT %p", pTarget, pRenderTarget);
		#endif

		IDirect3DStateBlock9* pStateBlock = NULL;
		idd->CreateStateBlock(D3DSBT_ALL, &pStateBlock);
		pStateBlock->Capture();

		ds->pSB->Apply();

		if (pTarget != pRenderTarget)
			idd->SetRenderTarget(0, pTarget);

		idd->BeginScene();
		ds->draw();
		idd->EndScene();

		pStateBlock->Apply();
		pStateBlock->Release();

		pRenderTarget->Release();
		pTarget->Release();

//		ods("D3D9: Finished ref is %d %d", ds->myRefCount, ds->refCount);
	}
}
开发者ID:Andrew-McLeod,项目名称:mumble,代码行数:42,代码来源:d3d9.cpp

示例9: doPresent

static void doPresent(IDirect3DDevice9 *idd) {
	DevState *ds = devMap[idd];

	if (ds && ds->pSB) {
		DWORD dwOldThread = ds->dwMyThread;
		if (dwOldThread)
			ods("doPresent from other thread");
		ds->dwMyThread = GetCurrentThreadId();

		IDirect3DSurface9 *pTarget = NULL;
		IDirect3DSurface9 *pRenderTarget = NULL;
		idd->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pTarget);
		idd->GetRenderTarget(0, &pRenderTarget);

		ods("D3D9: doPresent Back %p RenderT %p",pTarget,pRenderTarget);

		IDirect3DStateBlock9* pStateBlock = NULL;
		idd->CreateStateBlock(D3DSBT_ALL, &pStateBlock);
		pStateBlock->Capture();

		ds->pSB->Apply();

		if (pTarget != pRenderTarget)
			idd->SetRenderTarget(0, pTarget);

		idd->BeginScene();
		ds->draw();
		idd->EndScene();

		pStateBlock->Apply();
		pStateBlock->Release();

		pRenderTarget->Release();
		pTarget->Release();

//		ods("Finished ref is %d %d", ds->myRefCount, ds->refCount);
		ds->dwMyThread = dwOldThread;
	}
}
开发者ID:ergrelet,项目名称:mumble_ol,代码行数:39,代码来源:d3d9.cpp

示例10: OnRender

		//--------------------------------------------------------------------------------
		void System::OnRender(IDirect3DDevice9* pDevice)
		{
			//if(clock() - TheGameWorld->GetRendering() < 400)
			{
				IDirect3DStateBlock9* pStateBlock = NULL;
 				pDevice->CreateStateBlock(D3DSBT_ALL, &pStateBlock);
 				pStateBlock->Capture();
				try
				{
					if(mUI && mPlatform)
					{
						Update();
						mPlatform->getRenderManagerPtr()->drawOneFrame();
					}
				}
				catch(...)
				{
				}
				pStateBlock->Apply();
				pStateBlock->Release();
			}
		}
开发者ID:679565,项目名称:SkyrimOnline,代码行数:23,代码来源:System.cpp

示例11: renderStageWater

// renderStageWater - Render distant water without blend, for exceptional cases
void DistantLand::renderStageWater()
{
    DECLARE_MWBRIDGE
    IDirect3DStateBlock9 *stateSaved;
    UINT passes;

    if(isRenderCached)
        return;

    if(mwBridge->CellHasWater())
    {
        // Save state block manually since we can change FVF/decl
        device->CreateStateBlock(D3DSBT_ALL, &stateSaved);
        effect->Begin(&passes, D3DXFX_DONOTSAVESTATE);

        // Draw water plane
        bool u = mwBridge->IsUnderwater(eyePos.z);
        bool i = !mwBridge->IsExterior();

        if(u || i)
        {
            // Set up clip plane at fog end for certain environments to save fillrate
            float clipAt = Configuration.DL.InteriorFogEnd * 8192.0;
            D3DXPLANE clipPlane(0, 0, -clipAt, mwProj._33 * clipAt + mwProj._43);
            device->SetClipPlane(0, clipPlane);
            device->SetRenderState(D3DRS_CLIPPLANEENABLE, 1);
        }

        // Switch to appropriate shader and render
        effect->BeginPass(u ? PASS_RENDERUNDERWATER : PASS_RENDERWATER);
        renderWaterPlane();
        effect->EndPass();

        effect->End();
        stateSaved->Apply();
        stateSaved->Release();
    }
}
开发者ID:europop,项目名称:MGE-XE,代码行数:39,代码来源:distantland.cpp

示例12: sample_EndScene

HRESULT WINAPI sample_EndScene(IDirect3DDevice9* device){

  Vert v[] = {
      {100.0f,100.0f,0.0f,0.0f,0xFF00FF00},
      {200.0f,100.0f,0.0f,0.0f,0xFF00FF00},
      {200.0f,200.0f,0.0f,0.0f,0xFF00FF00},
      {100.0f,200.0f,0.0f,0.0f,0xFF00FF00},
  };

  IDirect3DStateBlock9* stateBlock = NULL;
  device->CreateStateBlock(D3DSBT_ALL, &stateBlock); // Stateblock saves all the rendersettings, as we are going to modify them in order to draw our stuff

  device->SetRenderState(D3DRS_ALPHABLENDENABLE,1);
  device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
  device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
  device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);

  device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,v,sizeof(Vert));

  stateBlock->Apply();
  stateBlock->Release();

  return endscene_og(device);
}
开发者ID:GregLando113,项目名称:dx9hook,代码行数:24,代码来源:sample_gw.cpp

示例13:

STDMETHODIMP CDirect3DDevice8::DeleteStateBlock(THIS_ DWORD Token)
{
	IDirect3DStateBlock9* pBlock = (IDirect3DStateBlock9*)Token;
	pBlock->Release();
	return D3D_OK;
}
开发者ID:RuStAk,项目名称:Direct3D8to9,代码行数:6,代码来源:Direct3DDevice8.cpp

示例14: DbgMsg

/******************************Public*Routine*****************************\
* Render
\**************************************************************************/
STDMETHODIMP
CGameUILayer::Render(
                     IDirect3DDevice9 *pDevice)
{
    HRESULT hr = S_OK;
    IDirect3DStateBlock9 *pState = NULL;
    D3DMATRIX matW;
    D3DXMATRIX matW1;

    if( !pDevice )
    {
        return E_POINTER;
    }

    try
    {
        CHECK_HR(
            hr = pDevice->BeginStateBlock(),
            DbgMsg(""));

        CHECK_HR(
            hr = pDevice->EndStateBlock(&pState),
            DbgMsg(""));

        pDevice->GetTransform( D3DTS_WORLD, &matW);
        D3DXMatrixIdentity( &matW1);
        pDevice->SetTransform( D3DTS_WORLD, &matW1);

        pDevice->SetRenderState( D3DRS_ZENABLE,  D3DZB_FALSE );
        pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
        pDevice->SetRenderState( D3DRS_SRCBLEND,    D3DBLEND_SRCALPHA );
        pDevice->SetRenderState( D3DRS_DESTBLEND,  D3DBLEND_INVSRCALPHA );
        pDevice->SetRenderState( D3DRS_ALPHATESTENABLE,  TRUE );
        pDevice->SetRenderState( D3DRS_ALPHAREF,         0x06 );
        pDevice->SetRenderState( D3DRS_ALPHAFUNC,  D3DCMP_GREATEREQUAL );

        CHECK_HR(
            hr = pDevice->SetRenderState( D3DRS_FILLMODE,   D3DFILL_SOLID ),
            DbgMsg(""));

        CHECK_HR(
            hr = pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ),
            DbgMsg(""));

        CHECK_HR(
            hr = pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ),
            DbgMsg(""));

        CHECK_HR(
            hr = pDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 ),
            DbgMsg(""));

        CHECK_HR(
            hr = pDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE ),
            DbgMsg(""));

        if( m_bViewing )
        {
			if( m_pTextureButtonResume )
			{
				CHECK_HR(
					hr = pDevice->SetTexture(0, m_pTextureButtonResume),
					DbgMsg(""));
			}
        }
        else
        {
			if( m_pTextureButtonView )
			{
				CHECK_HR(
					hr = pDevice->SetTexture(0, m_pTextureButtonView),
					DbgMsg(""));
			}
        }

        CHECK_HR(
            hr = pDevice->SetFVF( m_FVFUILayer ),
            DbgMsg(""));

        CHECK_HR(
            hr = pDevice->DrawPrimitiveUP(  D3DPT_TRIANGLESTRIP,
                                            2,
                                            (LPVOID)(m_V),
                                            sizeof(m_V[0])),
            DbgMsg(""));

        pDevice->SetTransform( D3DTS_WORLD, &matW);

        CHECK_HR(
            hr = pDevice->SetTexture(0, NULL),
            DbgMsg(""));

        CHECK_HR(
            hr = pState->Apply(),
            DbgMsg(""));
    }
    catch( HRESULT hr1 )
//.........这里部分代码省略.........
开发者ID:hgl888,项目名称:nashtest,代码行数:101,代码来源:CustomUILayer.cpp

示例15: if


//.........这里部分代码省略.........
		// index buffer ?
		if ((!m_pcDistortionIndexBufferLeft) || (!m_pcDistortionIndexBufferRight))
			return nullptr;

		// index buffer description ?
		if (!m_sIndexBufferDescLeft.Size)
		{
			m_pcDistortionIndexBufferLeft->GetDesc(&m_sIndexBufferDescLeft);

			// index buffer length matches vertex buffer size ? TODO !!
			/*if ()
			{
			OutputDebugString(L"OculusRenderer Node : Connected index buffer size mismatch !");
			return nullptr;
			}*/
		}
		if (!m_sIndexBufferDescRight.Size)
		{
			m_pcDistortionIndexBufferRight->GetDesc(&m_sIndexBufferDescRight);

			// index buffer length matches vertex buffer size ? TODO !!
			/*if ()
			{
			OutputDebugString(L"OculusRenderer Node : Connected index buffer size mismatch !");
			return nullptr;
			}*/
		}
	}

	// start to render
	pcDevice->BeginScene();

	// save states
	IDirect3DStateBlock9* pStateBlock = nullptr;
	pcDevice->CreateStateBlock(D3DSBT_ALL, &pStateBlock);

	// set ALL render states to default
	SetAllRenderStatesDefault(pcDevice);

	// set states
	pcDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
	pcDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
	pcDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
	pcDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CONSTANT);
	pcDevice->SetTextureStageState(0, D3DTSS_CONSTANT, 0xffffffff);
	pcDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	pcDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
	pcDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
	pcDevice->SetSamplerState(0, D3DSAMP_SRGBTEXTURE, 0);
	pcDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
	pcDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
	pcDevice->SetSamplerState(0, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP);
	pcDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_ANISOTROPIC);
	pcDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC);
	pcDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

	D3DCOLOR clearColor = D3DCOLOR_RGBA(0, 0, 0, 0);

	pcDevice->Clear(0, NULL, D3DCLEAR_TARGET, clearColor, 0, 0);

	// required fields
	D3DSURFACE_DESC sSurfaceDesc;
	ovrSizei sTextureSize;
	ovrRecti sRenderViewport;
	ovrVector2f UVScaleOffset[2];
开发者ID:Innovative-Ideas,项目名称:Perception,代码行数:66,代码来源:OculusRenderer.cpp


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