Khaotic Engine Reborn
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.

8{
9 vertex_shader_ = 0;
10 pixel_shader_ = 0;
11 layout_ = 0;
12 sample_state_ = 0;
13 matrix_buffer_ = 0;
14 camera_buffer_ = 0;
15 sunlight_buffer_ = 0;
16 sunlight_color_buffer_ = 0;
17 sunlight_position_buffer_ = 0;
18}

◆ 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.

22{
23}

◆ ~sunlight_shader_class()

sunlight_shader_class::~sunlight_shader_class ( )

Definition at line 26 of file sunlight_shader_class.cpp.

27{
28}

Member Function Documentation

◆ initialize()

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

Definition at line 31 of file sunlight_shader_class.cpp.

32{
33 Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
34
35 wchar_t vsFilename[128];
36 wchar_t psFilename[128];
37 int error;
38 bool result;
39
40 // Set the filename of the vertex shader.
41 error = wcscpy_s(vsFilename, 128, L"src/hlsl/sunlight.vs");
42 if (error != 0)
43 {
44 Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
45 return false;
46 }
47
48 // Set the filename of the pixel shader.
49 error = wcscpy_s(psFilename, 128, L"src/hlsl/sunlight.ps");
50 if (error != 0)
51 {
52 Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
53 return false;
54 }
55 // initialize the vertex and pixel shaders.
56 result = initialize_shader(device, hwnd, vsFilename, psFilename);
57 if (!result)
58 {
59 Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
60 return false;
61 }
62
63 Logger::Get().Log("SunLightShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
64
65 return true;
66}
static Logger & Get()
Definition Logger.h:20
void Log(const std::string &message, const std::string &fileName, int lineNumber, LogLevel level=LogLevel::Info)
Definition Logger.h:158

◆ 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.

79{
80 bool result;
81
82
83 // Set the shader parameters that it will use for rendering.
84 result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
85 if (!result)
86 {
87 Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
88 return false;
89 }
90
91 // Now render the prepared buffers with the shader.
92 render_shader(deviceContext, indexCount);
93
94 return true;
95}

◆ shutdown()

void sunlight_shader_class::shutdown ( )

Definition at line 69 of file sunlight_shader_class.cpp.

70{
71 // shutdown the vertex and pixel shaders as well as the related objects.
72 shutdown_shader();
73
74 return;
75}

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