source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/demos/Standalone/PathMap [DirectX]/DepthRenderStrategy.cpp @ 3255

Revision 3255, 1.5 KB checked in by szirmay, 16 years ago (diff)
Line 
1#include "dxstdafx.h"
2#include ".\depthrenderstrategy.h"
3#include "PathMapEffect.h"
4#include "Entity.h"
5#include "SubEntity.h"
6
7DepthRenderStrategy::DepthRenderStrategy(PathMapEffect* pathMapEffect)
8:RenderStrategy(pathMapEffect)
9{
10}
11
12void DepthRenderStrategy::applyTargets() const
13{
14        LPDIRECT3DDEVICE9 device = pathMapEffect->device;
15        device->SetRenderTarget(0, pathMapEffect->fakeSurface);
16        device->SetDepthStencilSurface( pathMapEffect->depthMapDepthStencilBuffer);
17}
18
19void DepthRenderStrategy::applyRenderState() const
20{
21        LPDIRECT3DDEVICE9 device = pathMapEffect->device;
22        device->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
23        // render backfaces to avoid z-fighting
24        device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
25
26        device->Clear( 0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(255, 0, 0, 0), 1.0f, 0 );
27}
28
29void DepthRenderStrategy::applyTechnique() const
30{
31        pathMapEffect->effect->SetTechnique("Depth");
32}
33
34void DepthRenderStrategy::applyTransforms(Entity* entity) const
35{
36        LPD3DXEFFECT effect = pathMapEffect->effect;
37        effect->SetMatrix("modelToProjMatrix",
38                &( entity->modelWorldTransform * *camera.GetViewMatrix() * *camera.GetProjMatrix() ) );
39        effect->CommitChanges();
40}
41
42
43void DepthRenderStrategy::resetRenderState() const
44{
45        LPDIRECT3DDEVICE9 device = pathMapEffect->device;
46        device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
47        device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA);
48}
49
Note: See TracBrowser for help on using the repository browser.