Khaotic Engine Reborn
Loading...
Searching...
No Matches
celshade_class Class Reference

Public Member Functions

 celshade_class (const celshade_class &)
 
bool initialize (ID3D11Device *, HWND)
 
void shutdown ()
 
bool render (ID3D11DeviceContext *device_context, int index_count, XMMATRIX world_matrix, XMMATRIX view_matrix, XMMATRIX projection_matrix, ID3D11ShaderResourceView *texture, XMFLOAT4 diffuse_color, XMFLOAT4 ambient_color, XMFLOAT3 sun_direction, float intensity)
 

Detailed Description

Definition at line 11 of file celshade_class.h.

Constructor & Destructor Documentation

◆ celshade_class() [1/2]

celshade_class::celshade_class ( )

Definition at line 7 of file celshade_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}

◆ celshade_class() [2/2]

celshade_class::celshade_class ( const celshade_class & other)

Definition at line 21 of file celshade_class.cpp.

22{
23}

◆ ~celshade_class()

celshade_class::~celshade_class ( )

Definition at line 26 of file celshade_class.cpp.

27{
28}

Member Function Documentation

◆ initialize()

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

Definition at line 31 of file celshade_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/celshading.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/celshading.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 celshade_class::render ( ID3D11DeviceContext * device_context,
int index_count,
XMMATRIX world_matrix,
XMMATRIX view_matrix,
XMMATRIX projection_matrix,
ID3D11ShaderResourceView * texture,
XMFLOAT4 diffuse_color,
XMFLOAT4 ambient_color,
XMFLOAT3 sun_direction,
float intensity )

Definition at line 77 of file celshade_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, world_matrix, view_matrix, projection_matrix, texture, diffuse_color, ambient_color, sun_direction, 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, index_count);
93
94 return true;
95}

◆ shutdown()

void celshade_class::shutdown ( )

Definition at line 69 of file celshade_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: