本文整理汇总了C++中IDirect3DStateBlock9类 的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DStateBlock9类的具体用法?C++ IDirect3DStateBlock9怎么用?C++ IDirect3DStateBlock9使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IDirect3DStateBlock9类 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: SAFE_RELEASE
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::FlushNonAARenderTarget
//
// If using AA hacks, change everything back
//
////////////////////////////////////////////////////////////////
void CRenderItemManager::FlushNonAARenderTarget( void )
{
if ( m_pSavedSceneDepthSurface )
{
m_pDevice->SetDepthStencilSurface ( m_pSavedSceneDepthSurface );
SAFE_RELEASE( m_pSavedSceneDepthSurface );
}
if ( m_pSavedSceneRenderTargetAA )
{
// Restore GTA AA render target, and copy our non-AA data to it
m_pDevice->SetRenderTarget( 0, m_pSavedSceneRenderTargetAA );
if ( m_pNonAARenderTarget )
{
if ( !m_bIsSwiftShader )
m_pDevice->StretchRect( m_pNonAARenderTarget, NULL, m_pSavedSceneRenderTargetAA, NULL, D3DTEXF_POINT );
else
{
// Emulate StretchRect using DrawPrimitive
// Save render states
IDirect3DStateBlock9* pSavedStateBlock = NULL;
m_pDevice->CreateStateBlock( D3DSBT_ALL, &pSavedStateBlock );
// Prepare vertex buffer
float fX1 = -0.5f;
float fY1 = -0.5f;
float fX2 = m_uiDefaultViewportSizeX + fX1;
float fY2 = m_uiDefaultViewportSizeY + fY1;
float fU1 = 0;
float fV1 = 0;
float fU2 = 1;
float fV2 = 1;
const SRTVertex vertices[] = { { fX1, fY1, 0, 1, fU1, fV1 },
{ fX2, fY1, 0, 1, fU2, fV1 },
{ fX1, fY2, 0, 1, fU1, fV2 },
{ fX2, fY1, 0, 1, fU2, fV1 },
{ fX2, fY2, 0, 1, fU2, fV2 },
{ fX1, fY2, 0, 1, fU1, fV2 } };
// Set vertex stream
uint PrimitiveCount = NUMELMS( vertices ) / 3;
const void* pVertexStreamZeroData = &vertices[0];
uint VertexStreamZeroStride = sizeof(SRTVertex);
m_pDevice->SetFVF( SRTVertex::FVF );
// Set render states
m_pDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
m_pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
m_pDevice->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE );
m_pDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
m_pDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
m_pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
m_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
m_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
m_pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
m_pDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT );
m_pDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT );
m_pDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT );
// Draw using texture
m_pDevice->SetTexture( 0, m_pNonAARenderTargetTexture );
m_pDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride );
// Restore render states
if ( pSavedStateBlock )
{
pSavedStateBlock->Apply();
SAFE_RELEASE( pSavedStateBlock );
}
}
}
SAFE_RELEASE( m_pSavedSceneRenderTargetAA );
}
}
开发者ID:tousuke, 项目名称:mtasa-blue, 代码行数:88, 代码来源:CRenderItemManager.cpp
示例17: doPresent
/// Present the overlay.
///
/// If called via IDirect3DDevice9::present() or IDirect3DDevice9Ex::present(),
/// idd will be non-NULL and ids ill be NULL.
///
/// If called via IDirect3DSwapChain9::present(), both idd and ids will be
/// non-NULL.
///
/// The doPresent function expects the following assumptions to be valid:
///
/// - Only one swap chain used at the same time.
/// - Windowed? IDirect3D9SwapChain::present() is used. ("Additional swap chain" is used)
/// - Full screen? IDirect3D9Device::present() is used. (Implicit swap chain for IDirect3D9Device is used)
///
/// It's either/or.
///
/// If doPresent is called multiple times per frame (say, for different swap chains),
/// the overlay will break badly when DevState::draw() is called. FPS counting will be off,
/// different render targets with different sizes will cause a size-renegotiation with Mumble
/// every frame, etc.
static void doPresent(IDirect3DDevice9 *idd, IDirect3DSwapChain9 *ids) {
DevMapType::iterator it = devMap.find(idd);
DevState *ds = it != devMap.end() ? it->second : NULL;
HRESULT hres;
if (ds && ds->pSB) {
if (ds->dwMyThread != 0) {
ods("D3D9: doPresent from other thread");
}
Stash<DWORD> stashThread(&(ds->dwMyThread), GetCurrentThreadId());
// Get the back buffer.
// If we're called via IDirect3DSwapChain9, acquire it via the swap chain object.
// Otherwise, acquire it via the device itself.
IDirect3DSurface9 *pTarget = NULL;
if (ids) {
hres = ids->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pTarget);
if (FAILED(hres)) {
if (hres == D3DERR_INVALIDCALL) {
ods("D3D9: IDirect3DSwapChain9::GetBackBuffer failed. BackBuffer index equals or exceeds the total number of back buffers");
} else {
ods("D3D9: IDirect3DSwapChain9::GetBackBuffer failed");
}
}
} else {
hres = idd->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pTarget);
if (FAILED(hres)) {
if (hres == D3DERR_INVALIDCALL) {
ods("D3D9: IDirect3DDevice9::GetBackBuffer failed. BackBuffer index equals or exceeds the total number of back buffers");
} else {
ods("D3D9: IDirect3DDevice9::GetBackBuffer failed");
}
}
}
IDirect3DSurface9 *pRenderTarget = NULL;
hres = idd->GetRenderTarget(0, &pRenderTarget);
if (FAILED(hres)) {
if (hres == D3DERR_NOTFOUND) {
ods("D3D9: IDirect3DDevice9::GetRenderTarget failed. There is no render target with the specified index");
} else if (hres == D3DERR_INVALIDCALL) {
ods("D3D9: IDirect3DDevice9::GetRenderTarget failed. One of the passed arguments was invalid");
} else {
ods("D3D9: IDirect3DDevice9::GetRenderTarget failed");
}
}
// 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) {
hres = idd->SetRenderTarget(0, pTarget);
if (FAILED(hres)) {
ods("D3D9: IDirect3DDevice9::SetRenderTarget failed");
}
}
// If we're called via IDirect3DSwapChain9::present(), we have to
// get the size of the back buffer and manually set the viewport size
// to match it.
//
// Although the call to IDirect3DDevice9::SetRenderTarget() above is
// documented as updating the device's viewport:
//
// "Setting a new render target will cause the viewport (see Viewports
// and Clipping (Direct3D 9)) to be set to the full size of the new
// render target."
//
// (via https://msdn.microsoft.com/en-us/library/windows/desktop/bb174455(v=vs.85).aspx)
//
// ...this doesn't happen. At least for some programs such as Final Fantasy XIV
// and Battle.net Launcher. For these programs, we get a viewport of 1x1.
//.........这里部分代码省略.........
开发者ID:Abextm, 项目名称:mumble, 代码行数:101, 代码来源:d3d9.cpp
示例18: SDLOG
void RSManagerDX9::initResources(bool downsampling, unsigned rw, unsigned rh,
unsigned numBBs, D3DFORMAT bbFormat, D3DMULTISAMPLE_TYPE multiSampleType, unsigned multiSampleQuality,
D3DSWAPEFFECT swapEff, bool autoDepthStencil, D3DFORMAT depthStencilFormat) {
if(inited) releaseResources();
SDLOG(0, "RenderstateManager resource initialization started\n");
this->downsampling = downsampling;
renderWidth = rw;
renderHeight = rh;
numBackBuffers = numBBs;
if(bbFormat != D3DFMT_UNKNOWN) backbufferFormat = bbFormat;
swapEffect = swapEff == D3DSWAPEFFECT_COPY ? SWAP_COPY : (swapEff == D3DSWAPEFFECT_DISCARD ? SWAP_DISCARD : SWAP_FLIP);
if(swapEffect == SWAP_FLIP) numBackBuffers++; // account for the "front buffer" in the swap chain
console.initialize(d3ddev, downsampling ? Settings::get().getPresentWidth() : rw, downsampling ? Settings::get().getPresentHeight() : rh);
Console::setLatest(&console);
imgWriter.reset(new ImageWriter(d3ddev, max(rw, max(Settings::get().getRenderWidth(), Settings::get().getPresentWidth())), max(rh, max(Settings::get().getRenderHeight(), Settings::get().getPresentHeight()))));
// performance measurement
console.add(frameTimeText);
perfMonitor.reset(new D3DPerfMonitor(d3ddev, 60));
console.add(traceText);
// store current state temporarily
IDirect3DStateBlock9 *startState;
d3ddev->CreateStateBlock(D3DSBT_ALL, &startState);
// create and capture default state block
d3ddev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
d3ddev->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
d3ddev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
d3ddev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
d3ddev->SetRenderState(D3DRS_LIGHTING, FALSE);
d3ddev->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
d3ddev->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE);
d3ddev->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
d3ddev->SetRenderState(D3DRS_CLIPPING, FALSE);
d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
d3ddev->SetRenderState(D3DRS_FOGENABLE, FALSE);
d3ddev->CreateStateBlock(D3DSBT_ALL, &initStateBlock);
if(downsampling) {
scaler.reset(new Scaler(d3ddev, rw, rh, Settings::get().getPresentWidth(), Settings::get().getPresentHeight()));
// generate backbuffers
SDLOG(2, "Generating backbuffers:\n")
for(unsigned i = 0; i < numBackBuffers; ++i) {
backBuffers.push_back(rtMan->createTexture(rw, rh, backbufferFormat, multiSampleType, multiSampleQuality));
SDLOG(2, "Backbuffer %u: %p\n", i, backBuffers[i]);
}
// set back buffer 0 as initial rendertarget
d3ddev->SetRenderTarget(0, backBuffers[0]->getSurf());
// generate additional buffer to emulate flip if required
if(swapEffect == SWAP_FLIP && Settings::get().getEmulateFlipBehaviour()) {
extraBuffer = rtMan->createSurface(rw, rh, backbufferFormat);
SDLOG(2, "Extra backbuffer: %p\n", extraBuffer);
}
// if required, determine depth/stencil surf type and create
if(autoDepthStencil) {
d3ddev->CreateDepthStencilSurface(rw, rh, depthStencilFormat, multiSampleType, multiSampleQuality, FALSE, &depthStencilSurf, NULL);
SDLOG(2, "Generated depth stencil surface - format: %s\n", D3DFormatToString(depthStencilFormat));
// set our depth stencil surface
d3ddev->SetDepthStencilSurface(depthStencilSurf);
}
}
plugin = GamePlugin::getPlugin(d3ddev, *this);
plugin->initialize(rw, rh, bbFormat, depthStencilFormat);
// restore initial state
startState->Apply();
startState->Release();
SDLOG(0, "RenderstateManager resource initialization completed\n");
inited = true;
}
开发者ID:Abarbula, 项目名称:gedosato, 代码行数:81, 代码来源:renderstate_manager_dx9.cpp
示例19: V
void D3D9statemanager::setSamplerStateBlock( DWORD stage, Texture::ClampMode clampmode, Texture::FilterMode filtermode )
{
int hash = stage << 24 | clampmode << 16 | filtermode;
HRESULT hr;
Dict<int,IDirect3DStateBlock9*>::const_iterator it = m_states.find(hash);
if (it != m_states.end()) {
if (m_stageSamplerStates[stage] != it->second) {
V(it->second->Apply());
m_stageSamplerStates[stage] = it->second;
}
return;
}
IDirect3DStateBlock9* state = 0;
d3d9Device->BeginStateBlock();
switch (clampmode) {
case Texture::CM_Clamp:
case Texture::CM_ClampToEdge:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP);
break;
case Texture::CM_ClampToBorder:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSW, D3DTADDRESS_BORDER);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_BORDERCOLOR, 0);
break;
case Texture::CM_Repeat:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP);
}
switch (filtermode) {
case Texture::FM_Nearest:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MINFILTER, D3DTEXF_POINT);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
break;
case Texture::FM_Linear:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
break;
case Texture::FM_Bilinear:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
break;
case Texture::FM_Trilinear:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
break;
}
d3d9Device->EndStateBlock(&state);
m_states[hash] = state;
state->Apply();
m_stageSamplerStates[stage] = state;
}
开发者ID:CharlieCraft, 项目名称:axonengine, 代码行数:65, 代码来源:d3d9statemanager.cpp
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:18175| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9641| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8166| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8542| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8444| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9368| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8415| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7852| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8399| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7391| 2022-11-06
请发表评论