23 ID3D11ShaderResourceView* envmap_;
24 ID3D11ShaderResourceView* clouds_;
26 ID3D11DepthStencilState* dss_disable_depth_test_;
27 ID3D11DepthStencilState* dss_enable_depth_test_;
32 virtual void create(ID3D11Device* device,
const dune::tstring& file)
36 D3D11_DEPTH_STENCIL_DESC dsd;
37 dsd.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
38 dsd.DepthFunc = D3D11_COMPARISON_LESS;
39 dsd.StencilEnable =
true;
40 dsd.StencilReadMask = 0xFF;
41 dsd.StencilWriteMask = 0xFF;
42 dsd.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
43 dsd.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
44 dsd.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
45 dsd.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
46 dsd.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
47 dsd.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
48 dsd.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
49 dsd.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
51 dsd.DepthEnable = FALSE;
52 dune::assert_hr(device->CreateDepthStencilState(&dsd, &dss_disable_depth_test_));
54 dsd.DepthEnable = TRUE;
55 dune::assert_hr(device->CreateDepthStencilState(&dsd, &dss_enable_depth_test_));
66 virtual void render(ID3D11DeviceContext* context)
68 context->OMSetDepthStencilState(dss_disable_depth_test_, 0);
70 context->OMSetDepthStencilState(dss_enable_depth_test_, 0);
74 void set_envmap(ID3D11Device* device,
const dune::tstring& file)
76 dune::load_texture(device, file, &envmap_);
78 for (
auto i = meshes_.begin(); i != meshes_.end(); ++i)
79 i->diffuse_tex = envmap_;
83 void set_clouds(ID3D11Device* device,
const dune::tstring& file)
85 dune::load_texture(device, file, &clouds_);
87 for (
auto i = meshes_.begin(); i != meshes_.end(); ++i)
88 i->specular_tex = clouds_;
virtual void create(ID3D11Device *device, const tstring &file)
Create a mesh from a given filename.
Definition: assimp_mesh.cpp:343
virtual void render(ID3D11DeviceContext *context, DirectX::XMFLOAT4X4 *to_clip=nullptr)
Renders the mesh using the shaders previously set.
Definition: assimp_mesh.cpp:243
A simple skydome mesh.
Definition: skydome.h:20
void set_clouds(ID3D11Device *device, const dune::tstring &file)
Set an optional cloud map (latlong format) to use for the sky.
Definition: skydome.h:83
Default implementation of assimp_mesh (pun intended).
Definition: assimp_mesh.h:113
virtual void destroy()
Destroy a mesh and free all its resources.
Definition: assimp_mesh.cpp:498
virtual void create(ID3D11Device *device, const dune::tstring &file)
Create a mesh from a given filename.
Definition: skydome.h:32
void set_envmap(ID3D11Device *device, const dune::tstring &file)
Set the environment map (latlong format) to use for the sky.
Definition: skydome.h:74
virtual void destroy()
Destroy a mesh and free all its resources.
Definition: skydome.h:58
tstring make_absolute_path(const tstring &relative_filename)
Return an absolute URI to a URI relative to the execution directory. Thus function is used in every l...
Definition: common_tools.cpp:67
void safe_release(T &obj)
Safely release an object of type T, setting it to nullptr afterwards.
Definition: d3d_tools.h:61