本文整理汇总了C++中LPDIRECT3DDEVICE9::SetDepthStencilSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE9::SetDepthStencilSurface方法的具体用法?C++ LPDIRECT3DDEVICE9::SetDepthStencilSurface怎么用?C++ LPDIRECT3DDEVICE9::SetDepthStencilSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE9
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE9::SetDepthStencilSurface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderFrameDX9
void RenderFrameDX9(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->BeginScene();
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
// normal pass
if ( g_bPosteffect )
{
device->SetRenderTarget(0, g_pFrameSurface[FULLSIZE]);
device->SetDepthStencilSurface(NULL);
}
else
{
device->SetRenderTarget(0, g_pMainSurface);
device->SetDepthStencilSurface(NULL);
}
device->Clear(0, NULL, D3DCLEAR_TARGET, 0x0, 1.0f, 0);
device->SetVertexShader(NULL);
device->SetPixelShader(NULL);
device->SetRenderState(D3DRS_LIGHTING, FALSE);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)&g_proj_matrix);
device->SetTransform(D3DTS_VIEW, (D3DMATRIX*)&view_matrix);
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&world_matrix);
g_Model_DX9.Render();
if ( g_bPosteffect )
{
ConverToLogLuminance(g_pFrameBuffer[FULLSIZE], &g_ImageInfo);
// ExpLuminance(g_pFrameSurface[FULLSIZE], g_pFrameBuffer[DOWNSAMPLED_256x256], &g_Image256x256);
AverageLuminance(g_pFrameBuffer[DOWNSAMPLED_256x256]);
ExpLuminance();
AdaptiveLuminance();
device->SetRenderTarget(0, g_pMainSurface);
device->SetDepthStencilSurface(NULL);
//device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0x0, 1.0f, 0);
AutoExposure();
if ( g_iMode & 0x01 )
{
DrawImage(g_pFrameBuffer[LUMINANCE_TEMP], &g_Image1x1, -1.0f, -1.0f, 0.1f, 0.1f);
DrawImage(g_pFrameBuffer[LUMINANCE_CURRENT], &g_Image1x1, -0.9f, -1.0f, 0.1f, 0.1f);
}
}
device->EndScene();
device->Present( NULL, NULL, NULL, NULL );
}
示例2: Antialiasing_SuperSampling
static void Antialiasing_SuperSampling(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->BeginScene();
Matrix4x4 ident_matrix; ident_matrix.Identity();
device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &ident_matrix);
device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &ident_matrix);
device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
device->SetRenderState(D3DRS_ZENABLE, FALSE);
// `先把畫面畫在4倍大的Framebuffer上`
{
// `設定繪圖結果要畫在動態貼圖上`
device->SetRenderTarget(0, g_pFrameBuffer);
device->SetDepthStencilSurface(g_pDepthStencil);
// `消除畫面`
device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DCOLOR_RGBA(0,0,255,255), 1.0f, 0);
// `設定轉換矩陣`
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &g_world_matrix);
// `畫一片3角形`
device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
device->SetRenderState(D3DRS_TEXTUREFACTOR, 0xffffffff);
device->SetFVF(D3DFVF_XYZ);
device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 1, g_Triangle, sizeof(Vector4));
}
// `再把畫面縮小放到原始大小的畫面上`
{
// `改用原本的Framebuffer`
device->SetRenderTarget(0, g_pMainFrameBuffer);
device->SetDepthStencilSurface(g_pMainDepthBuffer);
// `設定要貼圖的內插`
device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
// `使用動態貼圖`
device->SetTexture(0, g_pTexture);
device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
// `設定轉換矩陣`
device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &ident_matrix);
// `把貼圖套到整個畫面上`
device->SetFVF(D3DFVF_XYZ | D3DFVF_TEX1);
device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_Quad, sizeof(Vertex_VT));
}
// `宣告所有的繪圖指令都下完了`
device->EndScene();
// `把背景backbuffer的畫面呈現出來`
device->Present( NULL, NULL, NULL, NULL );
}
示例3: CopyRenderTargetToBackground
static bool CopyRenderTargetToBackground()
{
bool ret = false;
LPDIRECT3DDEVICE9 device = (LPDIRECT3DDEVICE9)GetUseDirect3DDevice9();
if (device == NULL) return nullptr;
HRESULT hr;
IDirect3DSurface9* tempRender = nullptr;
IDirect3DSurface9* tempDepth = nullptr;
hr = device->GetRenderTarget(0, &tempRender);
if (FAILED(hr))
{
goto Exit;
}
hr = device->GetDepthStencilSurface(&tempDepth);
if (FAILED(hr))
{
goto Exit;
}
device->SetRenderTarget(0, g_dx9_backgroundSurface);
device->SetDepthStencilSurface(nullptr);
D3DSURFACE_DESC desc;
tempRender->GetDesc(&desc);
const bool isSame = (desc.Width == g_backgroundWidth && desc.Height == g_backgroundHeight);
device->StretchRect(
tempRender,
nullptr,
g_dx9_backgroundSurface,
nullptr,
(isSame ? D3DTEXF_POINT : D3DTEXF_LINEAR)
);
device->SetRenderTarget(0, tempRender);
device->SetDepthStencilSurface(tempDepth);
ret = true;
Exit:;
ES_SAFE_RELEASE(tempRender);
ES_SAFE_RELEASE(tempDepth);
return ret;
}
示例4: ConverToLogLuminance
void ConverToLogLuminance(LPDIRECT3DTEXTURE9 pSource, sImageInfo *pInfo)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->SetRenderTarget(0, g_pFrameSurface[DOWNSAMPLED_256x256]);
device->SetDepthStencilSurface(NULL);
D3DXHANDLE shader = g_pExposureEffect->GetTechniqueByName("LogLuminance");
g_pExposureEffect->SetTechnique(shader);
D3DXHANDLE tablevar = g_pExposureEffect->GetParameterByName(NULL, "vLuminanceTable");
D3DXHANDLE imagevar = g_pExposureEffect->GetParameterByName(NULL, "Image");
Vector4 vTable(0.21f, 0.71f, 0.072f);
g_pExposureEffect->SetVector(tablevar, (D3DXVECTOR4*)&vTable);
g_pExposureEffect->SetTexture(imagevar, pSource);
g_pExposureEffect->Begin(NULL, 0);
g_pExposureEffect->BeginPass(0);
DrawFullScreenQuad(pInfo);
g_pExposureEffect->EndPass();
g_pExposureEffect->End();
}
示例5: Draw
void Render::Draw(IDirect3DSurface9* renderTarget, D3DXMATRIX* view, D3DXMATRIX* projection)
{
// Get or create device
LPDIRECT3DDEVICE9 device = GetDevice();
if (device == NULL) return;
// Load shaders if it is required
// if (!EnsureShaders()) return;
// Prepare depth surface
D3DSURFACE_DESC renderTargetDescription;
renderTarget->GetDesc(&renderTargetDescription);
D3DSURFACE_DESC depthSurfaceDescription;
if (depthSurface != NULL) depthSurface->GetDesc(&depthSurfaceDescription);
if (depthSurface == NULL || depthSurfaceDescription.Width != renderTargetDescription.Width || depthSurfaceDescription.Height != renderTargetDescription.Height)
{
if (depthSurface != NULL) depthSurface->Release();
device->CreateDepthStencilSurface(renderTargetDescription.Width, renderTargetDescription.Height, D3DFMT_D24X8, D3DMULTISAMPLE_NONE, 0, FALSE, &depthSurface, NULL);
if (depthSurface == NULL) return;
}
device->SetRenderTarget(0, renderTarget);
device->SetDepthStencilSurface(depthSurface);
device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);
if (lowPolySphere == NULL)
{
// Create spheres
lowPolySphere = CreateSphere(2);
middlePolySphere = CreateSphere(3);
highPolySphere = CreateSphere(5);
// Create cylinders
lowPolyCylinder = CreateCylinder(3);
middlePolyCylinder = CreateCylinder(12);
highPolyCylinder = CreateCylinder(24);
}
// FIXME: light dir must be slightly different!
D3DVECTOR lightDirection;
lightDirection.x = view->_13;
lightDirection.y = view->_23;
lightDirection.z = view->_33;
D3DVECTOR viewDirection;
viewDirection.x = view->_13;
viewDirection.y = view->_23;
viewDirection.z = view->_33;
elementMaterials[0].SetViewLightDirection(&viewDirection, &lightDirection);
// Rendering
device->BeginScene();
DrawAtoms(view, projection);
DrawBonds(view, projection);
DrawResidues(view, projection);
device->EndScene();
}
示例6: WaterSimulation
static void WaterSimulation(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->SetRenderTarget(0, g_pSurfaces[TEX_HEIGHT2]);
device->SetDepthStencilSurface(NULL);
D3DXHANDLE shader = g_pWaterEffect->GetTechniqueByName("WaterSimulation");
D3DXHANDLE heightmap_current_var = g_pWaterEffect->GetParameterByName(NULL, "heightmap_current");
D3DXHANDLE heightmap_prev_var = g_pWaterEffect->GetParameterByName(NULL, "heightmap_prev");
D3DXHANDLE texturesize_var = g_pWaterEffect->GetParameterByName(NULL, "texture_size");
D3DXHANDLE damping_var = g_pWaterEffect->GetParameterByName(NULL, "fDamping");
Vector4 texturesize;
texturesize[0] = 1.0f/(float)g_ImageInfo.m_iWidth;
texturesize[1] = 1.0f/(float)g_ImageInfo.m_iHeight;
texturesize[2] = (float)g_ImageInfo.m_iWidth;
texturesize[3] = (float)g_ImageInfo.m_iHeight;
g_pWaterEffect->SetTechnique(shader);
g_pWaterEffect->SetTexture(heightmap_prev_var, g_pTextures[TEX_HEIGHT0]);
g_pWaterEffect->SetTexture(heightmap_current_var, g_pTextures[TEX_HEIGHT1]);
g_pWaterEffect->SetFloat(damping_var, 0.99f);
g_pWaterEffect->SetVector(texturesize_var, (D3DXVECTOR4*)&texturesize);
g_pWaterEffect->Begin(NULL,0);
g_pWaterEffect->BeginPass(0);
GutDrawFullScreenQuad_DX9(&g_ImageInfo);
g_pWaterEffect->EndPass();
g_pWaterEffect->End();
}
示例7: AddImpulse
static void AddImpulse(void)
{
static Vector4 vPosition(0.0f, 0.0f, 0.0f, 0.0f);
//Vector4 vDiff = vPosition - g_vPosition;
Vector4 vDiff = g_vPosition - vPosition;
Vector4 vLength = vDiff.Length();
if ( vLength[0]<2.0f )
return;
Vector4 vDir = vDiff / vLength;
Vector4 vVec0(vDir[1],-vDir[0], 0.0f, 0.0f);
Vector4 vVec1(vDir[0], vDir[1], 0.0f, 0.0f);
vPosition = g_vPosition;
Vector4 vVec0_old = g_orient_matrix[0];
Vector4 vVec1_old = g_orient_matrix[1];
Vector4 vVec0_new = VectorLerp(vVec0_old, vVec0, 0.2f);
Vector4 vVec1_new = VectorLerp(vVec1_old, vVec1, 0.2f);
vVec0_new.Normalize();
vVec1_new.Normalize();
Vector4 vVec2_new = Vector3CrossProduct(vVec0_new, vVec1_new);
g_orient_matrix.Identity();
g_orient_matrix[0] = vVec0_new;
g_orient_matrix[1] = vVec1_new;
g_orient_matrix[2] = vVec2_new;
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->SetRenderTarget(0, g_pSurfaces[TEX_HEIGHT1]);
device->SetDepthStencilSurface(NULL);
Matrix4x4 view_matrix = g_Control.GetViewMatrix();
Matrix4x4 world_matrix;
world_matrix.Scale_Replace(g_fRippleSize, g_fRippleSize, 1.0f);
world_matrix[3] = g_vPosition;
Matrix4x4 wvp_matrix = g_orient_matrix * world_matrix * view_matrix * g_proj_matrix;
D3DXHANDLE shader = g_pWaterEffect->GetTechniqueByName("AddImpulse");
D3DXHANDLE wvp_matrix_var = g_pWaterEffect->GetParameterByName(NULL, "wvp_matrix");
D3DXHANDLE force_var = g_pWaterEffect->GetParameterByName(NULL, "fForce");
g_pWaterEffect->SetTechnique(shader);
g_pWaterEffect->SetMatrix(wvp_matrix_var, (D3DXMATRIX *)&wvp_matrix);
g_pWaterEffect->SetFloat(force_var, 0.05f);
g_pWaterEffect->Begin(NULL, 0);
g_pWaterEffect->BeginPass(0);
g_Model_DX9.Render(0);
g_pWaterEffect->EndPass();
g_pWaterEffect->End();
vPosition = g_vPosition;
}
示例8: CopyRenderTargetToBackground
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
static bool CopyRenderTargetToBackground()
{
bool ret = false;
HRESULT hr;
IDirect3DSurface9* tempRender = nullptr;
IDirect3DSurface9* tempDepth = nullptr;
hr = g_d3d_device->GetRenderTarget(0, &tempRender);
if (FAILED(hr))
{
goto Exit;
}
hr = g_d3d_device->GetDepthStencilSurface(&tempDepth);
if (FAILED(hr))
{
goto Exit;
}
g_d3d_device->SetRenderTarget(0, g_backgroundSurface);
g_d3d_device->SetDepthStencilSurface(nullptr);
D3DSURFACE_DESC desc;
tempRender->GetDesc(&desc);
g_d3d_device->StretchRect(
tempRender,
nullptr,
g_backgroundSurface,
nullptr,
D3DTEXF_POINT
);
g_d3d_device->SetRenderTarget(0, tempRender);
g_d3d_device->SetDepthStencilSurface(tempDepth);
ret = true;
Exit:;
ES_SAFE_RELEASE(tempRender);
ES_SAFE_RELEASE(tempDepth);
return ret;
}
示例9: RenderFrameDX9
void RenderFrameDX9(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->BeginScene();
AddImpulse();
WaterSimulation();
HeightmapToNormal();
device->SetRenderTarget(0, g_pMainFramebuffer);
device->SetDepthStencilSurface(g_pMainDepthbuffer);
device->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0x0, 1.0f, 0);
RenderWater();
DrawObject();
SwapHeightmaps();
float x = -1.0f;
float y = -1.0f;
float w = 0.4f;
float h = 0.4f;
if ( g_iMode & 0x01 )
{
DrawImage(g_pTextures[TEX_HEIGHT2], x, y, w, h, &g_ImageInfo);
x+=w;
}
if ( g_iMode & 0x02 )
{
D3DXHANDLE shader = g_pWaterEffect->GetTechniqueByName("Heightmap");
D3DXHANDLE heightmap_var = g_pWaterEffect->GetTechniqueByName("heightmap_current");
g_pWaterEffect->SetTechnique(shader);
g_pWaterEffect->SetTexture(heightmap_var, g_pTextures[TEX_HEIGHT2]);
g_pWaterEffect->Begin(NULL, 0);
g_pWaterEffect->BeginPass(0);
GutDrawScreenQuad_DX9(x, y, w, h, &g_ImageInfo);
g_pWaterEffect->EndPass();
g_pWaterEffect->End();
x+=w;
}
if ( g_iMode & 0x04 )
{
DrawImage(g_pTextures[TEX_NORMAL], x, y, w, h, &g_ImageInfo);
x+=w;
}
device->EndScene();
device->Present( NULL, NULL, NULL, NULL );
}
示例10: restoreRenderTarget
void Graphics::restoreRenderTarget() {
if (backBuffer != nullptr) {
device->SetRenderTarget(0, backBuffer);
device->SetRenderTarget(1, nullptr);
backBuffer->Release();
backBuffer = nullptr;
device->SetDepthStencilSurface(depthBuffer);
depthBuffer->Release();
depthBuffer = nullptr;
}
}
示例11: setRenderTarget
void Graphics::setRenderTarget(RenderTarget* target, int num) {
//if (backBuffer != nullptr) backBuffer->Release();
if (num == 0) {
if (backBuffer == nullptr) {
device->GetRenderTarget(0, &backBuffer);
device->GetDepthStencilSurface(&depthBuffer);
}
affirm(device->SetDepthStencilSurface(target->depthSurface));
}
affirm(device->SetRenderTarget(num, target->colorSurface));
}
示例12:
void Graphics4::restoreRenderTarget() {
if (backBuffer != nullptr) {
device->SetRenderTarget(0, backBuffer);
device->SetRenderTarget(1, nullptr);
backBuffer->Release();
backBuffer = nullptr;
device->SetDepthStencilSurface(depthBuffer);
depthBuffer->Release();
depthBuffer = nullptr;
viewport(0, 0, _width, _height);
}
}
示例13: setRenderTarget
void Graphics::setRenderTarget(RenderTarget* target, int num, int additionalTargets) {
// if (backBuffer != nullptr) backBuffer->Release();
System::makeCurrent(target->contextId);
if (num == 0) {
if (backBuffer == nullptr) {
device->GetRenderTarget(0, &backBuffer);
device->GetDepthStencilSurface(&depthBuffer);
}
affirm(device->SetDepthStencilSurface(target->depthSurface));
}
affirm(device->SetRenderTarget(num, target->colorSurface));
}
示例14: RenderParticle
static void RenderParticle(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
int w, h; GutGetWindowSize(w, h);
Matrix4x4 wvp_matrix = g_Control.GetObjectMatrix() * g_Control.GetViewMatrix() * g_proj_matrix;
Vector4 ScreenSize( (float)w, (float)h, 0.0f, 0.0f);
float fTanW = FastMath::Tan( FastMath::DegToRad(g_fFOV) );
device->SetRenderTarget(0, g_pMainFramebuffer);
device->SetDepthStencilSurface(g_pMainDepthbuffer);
device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0x0, 1.0f, 0);
D3DXHANDLE shader = g_pParticleRenderFX->GetTechniqueByName("RenderParticle");
D3DXHANDLE positiontex_var = g_pParticleRenderFX->GetParameterByName(NULL, "PositionTex");
D3DXHANDLE velocitytex_var = g_pParticleRenderFX->GetParameterByName(NULL, "VelocityTex");
D3DXHANDLE wvp_matrix_var = g_pParticleRenderFX->GetParameterByName(NULL, "wvp_matrix");
D3DXHANDLE tan_fov_var = g_pParticleRenderFX->GetParameterByName(NULL, "fTanW");
D3DXHANDLE screensize_var = g_pParticleRenderFX->GetParameterByName(NULL, "ScreenSize");
D3DXHANDLE diffusetex_var = g_pParticleRenderFX->GetParameterByName(NULL, "DiffuseTex");
g_pParticleRenderFX->SetTechnique(shader);
g_pParticleRenderFX->SetTexture(positiontex_var, g_pTextures[TEX_POSITION1]);
g_pParticleRenderFX->SetTexture(velocitytex_var, g_pTextures[TEX_VELOCITY1]);
g_pParticleRenderFX->SetMatrix(wvp_matrix_var, (D3DXMATRIX*)&wvp_matrix);
g_pParticleRenderFX->SetVector(screensize_var, (D3DXVECTOR4*)&ScreenSize);
g_pParticleRenderFX->SetFloat(tan_fov_var, fTanW);
g_pParticleRenderFX->SetTexture(diffusetex_var, g_pParticleTexture);
int num_processed_particles = (g_num_particles / g_texture_width) * g_texture_width;
if ( num_processed_particles )
{
device->SetFVF(D3DFVF_TEX1);
g_pParticleRenderFX->Begin(NULL,0);
g_pParticleRenderFX->BeginPass(0);
//device->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
device->DrawPrimitiveUP(D3DPT_POINTLIST, num_processed_particles, g_pParticleArray, sizeof(sParticle));
//device->SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE);
g_pParticleRenderFX->EndPass();
g_pParticleRenderFX->End();
}
}
示例15: HeightmapToNormal
static void HeightmapToNormal(void)
{
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->SetRenderTarget(0, g_pSurfaces[TEX_NORMAL]);
device->SetDepthStencilSurface(NULL);
D3DXHANDLE shader = g_pWaterEffect->GetTechniqueByName("ConvertNormal");
D3DXHANDLE heightmap_current_var = g_pWaterEffect->GetParameterByName(NULL, "heightmap_current");
D3DXHANDLE normalscale_var = g_pWaterEffect->GetParameterByName(NULL, "fNormalScale");
g_pWaterEffect->SetTechnique(shader);
g_pWaterEffect->SetTexture(heightmap_current_var, g_pTextures[TEX_HEIGHT2]);
g_pWaterEffect->SetFloat(normalscale_var, 1.0f);
g_pWaterEffect->Begin(NULL,0);
g_pWaterEffect->BeginPass(0);
GutDrawFullScreenQuad_DX9(&g_ImageInfo);
g_pWaterEffect->EndPass();
g_pWaterEffect->End();
}