# Khaotic Engine Reborn: shadow_map Class Reference

Loading...
Searching...
No Matches
shadow_map Class Reference

## Public Member Functions

bool | initialize (ID3D11Device *device, int width, int height)
void | shutdown ()
void | set_render_target (ID3D11DeviceContext *context)
void | clear_render_target (ID3D11DeviceContext *context, float depth=1.0f)
ID3D11ShaderResourceView * | get_shader_resource_view ()

## Detailed Description

Definition at line 5 of file shadow_map.h.

## Constructor & Destructor Documentation

## shadow_map()

shadow_map::shadow_map | ( |  | ) |

Definition at line 3 of file shadow_map.cpp.

: depth_texture_(nullptr), depth_stencil_view_(nullptr), shader_resource_view_(nullptr), width_(0), height_(0) {}

## ~shadow_map()

shadow_map::~shadow_map | ( |  | ) |

Definition at line 6 of file shadow_map.cpp.

{
shutdown();
}

## Member Function Documentation

## clear_render_target()

void shadow_map::clear_render_target | ( | ID3D11DeviceContext * | context,
|  | float | depth = 1.0f )

Definition at line 56 of file shadow_map.cpp.

{
context->ClearDepthStencilView(depth_stencil_view_, D3D11_CLEAR_DEPTH, depth, 0);
}

## get_shader_resource_view()

ID3D11ShaderResourceView * shadow_map::get_shader_resource_view | ( |  | ) |

Definition at line 60 of file shadow_map.cpp.

{
return shader_resource_view_;
}

## initialize()

bool shadow_map::initialize | ( | ID3D11Device * | device,
|  | int | width,
|  | int | height )

Definition at line 10 of file shadow_map.cpp.

{
width_ = width;
height_ = height;
D3D11_TEXTURE2D_DESC texDesc = {};
texDesc.Width = width;
texDesc.Height = height;
texDesc.MipLevels = 1;
texDesc.ArraySize = 1;
texDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
texDesc.SampleDesc.Count = 1;
texDesc.Usage = D3D11_USAGE_DEFAULT;
texDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
if (FAILED(device->CreateTexture2D(&texDesc, nullptr, &depth_texture_)))
return false;
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc = {};
dsvDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
dsvDesc.Texture2D.MipSlice = 0;
if (FAILED(device->CreateDepthStencilView(depth_texture_, &dsvDesc, &depth_stencil_view_)))
return false;
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
srvDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
srvDesc.Texture2D.MipLevels = 1;
if (FAILED(device->CreateShaderResourceView(depth_texture_, &srvDesc, &shader_resource_view_)))
return false;
return true;
}

## set_render_target()

void shadow_map::set_render_target | ( | ID3D11DeviceContext * | context | ) |

Definition at line 52 of file shadow_map.cpp.

{
context->OMSetRenderTargets(0, nullptr, depth_stencil_view_);
}

## shutdown()

void shadow_map::shutdown | ( |  | ) |

Definition at line 46 of file shadow_map.cpp.

{
if (shader_resource_view_) { shader_resource_view_->Release(); shader_resource_view_ = nullptr; }
if (depth_stencil_view_) { depth_stencil_view_->Release(); depth_stencil_view_ = nullptr; }
if (depth_texture_) { depth_texture_->Release(); depth_texture_ = nullptr; }
}

The documentation for this class was generated from the following files:

- enginecustom/src/inc/system/shadow_map.h
- enginecustom/src/src/system/shadow_map.cpp