本文整理汇总了C++中IDirect3DStateBlock9::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DStateBlock9::Release方法的具体用法?C++ IDirect3DStateBlock9::Release怎么用?C++ IDirect3DStateBlock9::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirect3DStateBlock9
的用法示例。
在下文中一共展示了IDirect3DStateBlock9::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createCleanState
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();
}
示例2: releaseAll
void DevState::releaseAll() {
ods("D3D9: Release All");
releaseData();
if (pSB)
pSB->Release();
pSB = NULL;
}
示例3: 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();
}
示例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();
}
示例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();
}
}
示例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();
}
示例7: 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);
}
}
示例8: 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;
}
}
示例9: 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();
}
}
示例10: 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();
}
}
示例11: 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);
}
示例12: draw
void MGEhud::draw()
{
std::map<std::string, MGEhud::hud_id>::const_iterator i;
IDirect3DStateBlock9 *stateSaved;
device->CreateStateBlock(D3DSBT_ALL, &stateSaved);
D3DXVECTOR4 *vbase;
HRESULT hr = vbHUD->Lock(0, 0, (void**)&vbase, D3DLOCK_DISCARD);
if(hr != D3D_OK || vbase == 0)
return;
for(i = element_names.begin(); i != element_names.end(); ++i)
{
const Element *e = &elements[i->second];
if(e->enabled)
{
float x0 = e->x, x1 = e->x + e->xscale * e->w;
float y0 = e->y, y1 = e->y + e->yscale * e->h;
// Correct for D3D9 pixel offset
x0 -= 0.5; y0 -= 0.5; x1 -= 0.5; y1 -= 0.5;
D3DXVECTOR4 *v = vbase + 8 * i->second;
v[0] = D3DXVECTOR4(x0, y1, 0, 1);
v[1] = D3DXVECTOR4(0, 1, 0, 0);
v[2] = D3DXVECTOR4(x0, y0, 0, 1);
v[3] = D3DXVECTOR4(0, 0, 0, 0);
v[4] = D3DXVECTOR4(x1, y1, 0, 1);
v[5] = D3DXVECTOR4(1, 1, 0, 0);
v[6] = D3DXVECTOR4(x1, y0, 0, 1);
v[7] = D3DXVECTOR4(1, 0, 0, 0);
}
}
vbHUD->Unlock();
device->SetFVF(fvfHUD);
device->SetStreamSource(0, vbHUD, 0, 32);
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
for(i = element_names.begin(); i != element_names.end(); ++i)
{
const Element *e = &elements[i->second];
if(e->enabled)
{
ID3DXEffect *effect = e->effect ? e->effect : effectStandard;
D3DXHANDLE ehTex = effect->GetParameterByName(0, "tex");
UINT passes;
effect->SetTexture(ehTex, e->texture);
effect->Begin(&passes, D3DXFX_DONOTSAVESTATE);
effect->BeginPass(0);
device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 4 * i->second, 2);
effect->EndPass();
effect->End();
}
}
stateSaved->Apply();
stateSaved->Release();
}
示例13: setView
// renderStage0 - Render distant land at beginning of scene 0, after sky
void DistantLand::renderStage0()
{
DECLARE_MWBRIDGE
IDirect3DStateBlock9 *stateSaved;
UINT passes;
// Get Morrowind camera matrices
device->GetTransform(D3DTS_VIEW, &mwView);
device->GetTransform(D3DTS_PROJECTION, &mwProj);
// Set variables derived from current camera configuration
setView(&mwView);
adjustFog();
setupCommonEffect(&mwView, &mwProj);
// Select distant static set
selectDistantCell();
isRenderCached &= (Configuration.MGEFlags & USE_MENU_CACHING) && mwBridge->IsMenu();
if(!isRenderCached)
{
///LOG::logline("Sky prims: %d", recordSky.size());
if(isDistantCell())
{
// Save state block manually since we can change FVF/decl
device->CreateStateBlock(D3DSBT_ALL, &stateSaved);
effect->BeginPass(PASS_SETUP);
effect->EndPass();
// Shadow map early render
if(Configuration.MGEFlags & USE_SHADOWS)
{
if(mwBridge->CellHasWeather() && !mwBridge->IsMenu())
{
effectShadow->Begin(&passes, D3DXFX_DONOTSAVESTATE);
renderShadowMap();
effectShadow->End();
}
}
// Distant everything; bias the projection matrix such that
// distant land gets drawn behind anything Morrowind would draw
D3DXMATRIX distProj = mwProj;
distProj._33 += kDistantZBias;
effect->SetMatrix(ehProj, &distProj);
effect->Begin(&passes, D3DXFX_DONOTSAVESTATE);
if(!mwBridge->IsUnderwater(eyePos.z))
{
// Draw distant landscape
if(mwBridge->IsExterior())
{
effect->BeginPass(PASS_RENDERLAND);
renderDistantLand(effect, &mwView, &distProj);
effect->EndPass();
}
// Draw distant statics, with alpha dissolve as they pass the near view boundary
DWORD p = mwBridge->CellHasWeather() ? PASS_RENDERSTATICSEXTERIOR : PASS_RENDERSTATICSINTERIOR;
effect->SetFloat(ehDissolveRange, 7168.0);
effect->BeginPass(p);
cullDistantStatics(&mwView, &distProj);
renderDistantStatics();
effect->EndPass();
}
// Sky scattering and sky objects (should be drawn late as possible)
if((Configuration.MGEFlags & USE_ATM_SCATTER) && mwBridge->CellHasWeather())
{
effect->BeginPass(PASS_RENDERSKY);
renderSky();
effect->EndPass();
}
// Update reflection
if(mwBridge->CellHasWater())
renderWaterReflection(&mwView, &distProj);
// Update water simulation
if(Configuration.MGEFlags & DYNAMIC_RIPPLES)
simulateDynamicWaves();
effect->End();
// Reset matrices
effect->SetMatrix(ehView, &mwView);
effect->SetMatrix(ehProj, &mwProj);
// Save distant land only frame to texture
if(~Configuration.MGEFlags & NO_MW_MGE_BLEND)
texDistantBlend = PostShaders::borrowBuffer(1);
// Restore render state
stateSaved->Apply();
stateSaved->Release();
}
else
//.........这里部分代码省略.........
示例14: Provoke
/**
* Render the Oculus Rift View.
***/
void* OculusRenderer::Provoke(void* pThis, int eD3D, int eD3DInterface, int eD3DMethod, DWORD dwNumberConnected, int& nProvokerIndex)
{
// return if wrong call
if ((eD3D >= (int)AQU_DirectXVersion::DirectX_9_0) &&
(eD3D <= (int)AQU_DirectXVersion::DirectX_9_29))
{
if (((eD3DInterface == INTERFACE_IDIRECT3DDEVICE9) &&
(eD3DMethod == METHOD_IDIRECT3DDEVICE9_PRESENT)) ||
((eD3DInterface == INTERFACE_IDIRECT3DDEVICE9) &&
(eD3DMethod == METHOD_IDIRECT3DDEVICE9_ENDSCENE)) ||
((eD3DInterface == INTERFACE_IDIRECT3DSWAPCHAIN9) &&
(eD3DMethod == METHOD_IDIRECT3DSWAPCHAIN9_PRESENT)))
{
(pThis);
}
else return nullptr;
}
else
return nullptr;
// get input data
if (m_paInput[(int)ORN_Decommanders::LeftTexture])
m_pcTextureLeft = *(LPDIRECT3DTEXTURE9*)m_paInput[(int)ORN_Decommanders::LeftTexture];
else
m_pcTextureLeft = nullptr;
if (m_paInput[(int)ORN_Decommanders::RightTexture])
m_pcTextureRight = *(LPDIRECT3DTEXTURE9*)m_paInput[(int)ORN_Decommanders::RightTexture];
else m_pcTextureRight = nullptr;
if (m_paInput[(int)ORN_Decommanders::DistortionVertexBufferLeft])
if (*(LPDIRECT3DVERTEXBUFFER9**)m_paInput[(int)ORN_Decommanders::DistortionVertexBufferLeft])
m_pcDistortionVertexBufferLeft = **(LPDIRECT3DVERTEXBUFFER9**)m_paInput[(int)ORN_Decommanders::DistortionVertexBufferLeft];
else m_pcDistortionVertexBufferLeft = nullptr;
else m_pcDistortionVertexBufferLeft = nullptr;
if (m_paInput[(int)ORN_Decommanders::DistortionVertexBufferRight])
if (*(LPDIRECT3DVERTEXBUFFER9**)m_paInput[(int)ORN_Decommanders::DistortionVertexBufferRight])
m_pcDistortionVertexBufferRight = **(LPDIRECT3DVERTEXBUFFER9**)m_paInput[(int)ORN_Decommanders::DistortionVertexBufferRight];
else m_pcDistortionVertexBufferRight = nullptr;
else m_pcDistortionVertexBufferRight = nullptr;
if (m_paInput[(int)ORN_Decommanders::DistortionIndexBufferLeft])
if (*(LPDIRECT3DINDEXBUFFER9**)m_paInput[(int)ORN_Decommanders::DistortionIndexBufferLeft])
m_pcDistortionIndexBufferLeft = **(LPDIRECT3DINDEXBUFFER9**)m_paInput[(int)ORN_Decommanders::DistortionIndexBufferLeft];
else m_pcDistortionIndexBufferLeft = nullptr;
else m_pcDistortionIndexBufferLeft = nullptr;
if (m_paInput[(int)ORN_Decommanders::DistortionIndexBufferRight])
if (*(LPDIRECT3DINDEXBUFFER9**)m_paInput[(int)ORN_Decommanders::DistortionIndexBufferRight])
m_pcDistortionIndexBufferRight = **(LPDIRECT3DINDEXBUFFER9**)m_paInput[(int)ORN_Decommanders::DistortionIndexBufferRight];
else m_pcDistortionIndexBufferRight = nullptr;
else m_pcDistortionIndexBufferRight = nullptr;
if (m_paInput[(int)ORN_Decommanders::OculusVertexDeclaration])
if (*(LPDIRECT3DVERTEXDECLARATION9**)m_paInput[(int)ORN_Decommanders::OculusVertexDeclaration])
m_pcVertexDecl = **(LPDIRECT3DVERTEXDECLARATION9**)m_paInput[(int)ORN_Decommanders::OculusVertexDeclaration];
else m_pcVertexDecl = nullptr;
else m_pcVertexDecl = nullptr;
if (m_paInput[(int)ORN_Decommanders::DefaultEyeFovLeft])
if (*(ovrFovPort**)m_paInput[(int)ORN_Decommanders::DefaultEyeFovLeft])
m_psFOVPortLeft = *(ovrFovPort**)m_paInput[(int)ORN_Decommanders::DefaultEyeFovLeft];
else m_psFOVPortLeft = nullptr;
else m_psFOVPortLeft = nullptr;
if (m_paInput[(int)ORN_Decommanders::DefaultEyeFovRight])
if (*(ovrFovPort**)m_paInput[(int)ORN_Decommanders::DefaultEyeFovRight])
m_psFOVPortRight = *(ovrFovPort**)m_paInput[(int)ORN_Decommanders::DefaultEyeFovRight];
else m_psFOVPortRight = nullptr;
else m_psFOVPortRight = nullptr;
// get device
LPDIRECT3DDEVICE9 pcDevice = nullptr;
bool bReleaseDevice = false;
if (eD3DInterface == INTERFACE_IDIRECT3DDEVICE9)
{
pcDevice = (LPDIRECT3DDEVICE9)pThis;
}
else if (eD3DInterface == INTERFACE_IDIRECT3DSWAPCHAIN9)
{
LPDIRECT3DSWAPCHAIN9 pSwapChain = (LPDIRECT3DSWAPCHAIN9)pThis;
if (!pSwapChain)
{
OutputDebugString(L"Oculus Renderer Node : No swapchain !");
return nullptr;
}
pSwapChain->GetDevice(&pcDevice);
bReleaseDevice = true;
}
if (!pcDevice)
{
OutputDebugString(L"Oculus Renderer Node : No device !");
return nullptr;
}
// Original code (LibOVR) :
// pShaderCode = ShaderCompile("precompiledVertexShaderSrc",VertexShaderSrc,"vs_2_0");
// pShaderCode = ShaderCompile("precompiledVertexShaderTimewarpSrc",VertexShaderTimewarpSrc,"vs_3_0");
// pShaderCode = ShaderCompile("precompiledPixelShaderSrc",PixelShaderSrc,"ps_3_0");
// pixel shader created ?
if (!m_pcOculusPixelShader)
{
//.........这里部分代码省略.........
示例15: ImageWriter
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;
}