# Khaotic Engine Reborn: sunlight_shader_class Class Reference

Loading...
Searching...
No Matches
sunlight_shader_class Class Reference

## Public Member Functions

| sunlight_shader_class (const sunlight_shader_class &)
bool | initialize (ID3D11Device *, HWND)
void | shutdown ()
bool | render (ID3D11DeviceContext *, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView *, XMFLOAT4, XMFLOAT4, XMFLOAT3, float)

## Detailed Description

Definition at line 11 of file sunlight_shader_class.h.

## Constructor & Destructor Documentation

## sunlight_shader_class() [1/2]

sunlight_shader_class::sunlight_shader_class | ( |  | ) |

Definition at line 7 of file sunlight_shader_class.cpp.

{
vertex_shader_ = 0;
pixel_shader_ = 0;
layout_ = 0;
sample_state_ = 0;
matrix_buffer_ = 0;
camera_buffer_ = 0;
sunlight_buffer_ = 0;
sunlight_color_buffer_ = 0;
sunlight_position_buffer_ = 0;
}

## sunlight_shader_class() [2/2]

sunlight_shader_class::sunlight_shader_class | ( | const sunlight_shader_class & | other | ) |

Definition at line 21 of file sunlight_shader_class.cpp.

{
}

## ~sunlight_shader_class()

sunlight_shader_class::~sunlight_shader_class | ( |  | ) |

Definition at line 26 of file sunlight_shader_class.cpp.

{
}

## Member Function Documentation

## initialize()

bool sunlight_shader_class::initialize | ( | ID3D11Device * | device,
|  | HWND | hwnd )

Definition at line 31 of file sunlight_shader_class.cpp.

{
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
wchar_t vsFilename[128];
wchar_t psFilename[128];
int error;
bool result;
// Set the filename of the vertex shader.
error = wcscpy_s(vsFilename, 128, L"src/hlsl/sunlight.vs");
if (error != 0)
{
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Set the filename of the pixel shader.
error = wcscpy_s(psFilename, 128, L"src/hlsl/sunlight.ps");
if (error != 0)
{
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// initialize the vertex and pixel shaders.
result = initialize_shader(device, hwnd, vsFilename, psFilename);
if (!result)
{
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("SunLightShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}

## render()

bool sunlight_shader_class::render | ( | ID3D11DeviceContext * | deviceContext,
|  | int | indexCount,
|  | XMMATRIX | worldMatrix,
|  | XMMATRIX | viewMatrix,
|  | XMMATRIX | projectionMatrix,
|  | ID3D11ShaderResourceView * | texture,
|  | XMFLOAT4 | diffuseColor,
|  | XMFLOAT4 | ambientColor,
|  | XMFLOAT3 | sunDirection,
|  | float | sunIntensity )

Definition at line 77 of file sunlight_shader_class.cpp.

{
bool result;
// Set the shader parameters that it will use for rendering.
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
if (!result)
{
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Now render the prepared buffers with the shader.
render_shader(deviceContext, indexCount);
return true;
}

## shutdown()

void sunlight_shader_class::shutdown | ( |  | ) |

Definition at line 69 of file sunlight_shader_class.cpp.

{
// shutdown the vertex and pixel shaders as well as the related objects.
shutdown_shader();
return;
}

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

- enginecustom/src/inc/shader/sunlight_shader_class.h
- enginecustom/src/src/shader/sunlight_shader_class.cpp