void CState::Save() { // viewport m_D3DDev->GetViewport(&m_Vp); // render states m_D3DDev->GetRenderState(D3DRS_ZENABLE, &m_Z); m_D3DDev->GetRenderState(D3DRS_CULLMODE, &m_CullMode); m_D3DDev->GetRenderState(D3DRS_ALPHATESTENABLE, &m_AlphaTest); m_D3DDev->GetRenderState(D3DRS_ALPHABLENDENABLE, &m_AlphaBlend); m_D3DDev->GetRenderState(D3DRS_BLENDOP, &m_BlendOp); m_D3DDev->GetRenderState(D3DRS_SRCBLEND, &m_SrcBlend); m_D3DDev->GetRenderState(D3DRS_DESTBLEND, &m_DstBlend); m_D3DDev->GetRenderState(D3DRS_CLIPPLANEENABLE, &m_ClipPlane); m_D3DDev->GetRenderState(D3DRS_FILLMODE, &m_FillMode); m_D3DDev->GetRenderState(D3DRS_LASTPIXEL, &m_LastPixel); m_D3DDev->GetRenderState(D3DRS_FOGENABLE, &m_Fog); m_D3DDev->GetRenderState(D3DRS_STENCILENABLE, &m_Stencil); m_D3DDev->GetRenderState(D3DRS_COLORWRITEENABLE, &m_ColorWrite); m_D3DDev->GetRenderState(D3DRS_SCISSORTESTENABLE, &m_Scissor); if( m_Caps.PrimitiveMiscCaps & D3DPMISCCAPS_SEPARATEALPHABLEND ) m_D3DDev->GetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, &m_SeparateAlphaBlend); //if( m_Caps.LineCaps & D3DLINECAPS_ANTIALIAS ) m_D3DDev->GetRenderState(D3DRS_ANTIALIASEDLINEENABLE, &m_AntiAliasedLine); // primitive m_D3DDev->GetFVF(&m_FVF); m_D3DDev->GetStreamSource(0, &m_StreamData, &m_StreamOffset, &m_StreamStride); m_D3DDev->GetVertexShader(&m_VertexShader); // texture m_D3DDev->GetTexture(0, &m_Tex); m_D3DDev->GetPixelShader(&m_PixelShader); // texture stage states m_D3DDev->GetTextureStageState(0, D3DTSS_COLOROP, &m_ColorOp); m_D3DDev->GetTextureStageState(0, D3DTSS_COLORARG1, &m_ColorArg1); m_D3DDev->GetTextureStageState(0, D3DTSS_COLORARG2, &m_ColorArg2); m_D3DDev->GetTextureStageState(0, D3DTSS_ALPHAOP, &m_AlphaOp); m_D3DDev->GetTextureStageState(0, D3DTSS_ALPHAARG1, &m_AlphaArg1); m_D3DDev->GetTextureStageState(0, D3DTSS_TEXCOORDINDEX, &m_TexCoordIndex); m_D3DDev->GetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, &m_TexTransfFlags); m_D3DDev->GetSamplerState(0, D3DSAMP_ADDRESSU, &m_AddressU); m_D3DDev->GetSamplerState(0, D3DSAMP_ADDRESSV, &m_AddressV); m_D3DDev->GetSamplerState(0, D3DSAMP_MAGFILTER, &m_MagFilter); m_D3DDev->GetSamplerState(0, D3DSAMP_MINFILTER, &m_MinFilter); m_D3DDev->GetSamplerState(0, D3DSAMP_MIPFILTER, &m_MipFilter); }
void TextureDX9::Disable(const unsigned int texUnit) const { IDirect3DDevice9* device = RendererDX9::GetInstance()->GetDevice(); HRESULT hr; #ifdef _DEBUG IDirect3DBaseTexture9* activeTex = nullptr; hr = device->GetTexture(texUnit, &activeTex); assert(SUCCEEDED(hr)); assert(activeTex == m_pTexture); unsigned int refCount = 1; refCount = activeTex->Release(); assert(refCount == 1); #endif hr = device->SetTexture(texUnit, 0); assert(SUCCEEDED(hr)); }
//---------------------------------------------------------------------------- void PdrTextureCube::Disable (Renderer* renderer, int textureUnit) { IDirect3DDevice9* device = renderer->mData->mDevice; HRESULT hr; PX2_UNUSED(hr); #ifdef PX2_PDR_DEBUG // 检测需要被取消激活的数据,是否匹配。 IDirect3DBaseTexture9 *activeTexture = 0; hr = device->GetTexture(textureUnit, &activeTexture); assertion(hr == D3D_OK, "Failed to get cube texture, unit %d: %s\n", textureUnit, DXGetErrorString(hr)); assertion(activeTexture == mTexture, "Mismatched textures\n"); activeTexture->Release(); #endif hr = device->SetTexture(textureUnit, 0); assertion(hr == D3D_OK, "Failed to disable cube texture, unit %d: %s\n", textureUnit, DXGetErrorString(hr)); }
//---------------------------------------------------------------------------- void PdrTexture3D::Disable (Renderer* renderer, int textureUnit) { IDirect3DDevice9* device = renderer->mData->mDevice; HRESULT hr; WM5_UNUSED(hr); #ifdef WM5_PDR_DEBUG // Verify that the active texture is the one making the disable request. IDirect3DBaseTexture9 *activeTexture = 0; hr = device->GetTexture(textureUnit, &activeTexture); assertion(hr == D3D_OK, "Failed to get 3D texture, unit %d: %s\n", textureUnit, DXGetErrorString(hr)); assertion(activeTexture == mTexture, "Mismatched textures\n"); activeTexture->Release(); #endif // Disable the texture by clearing the state. hr = device->SetTexture(textureUnit, 0); assertion(hr == D3D_OK, "Failed to disable 3D texture, unit %d: %s\n", textureUnit, DXGetErrorString(hr)); }