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

Public Member Functions

 texture_shader_class (const texture_shader_class &)
 
bool initialize (ID3D11Device *, HWND)
 
void shutdown ()
 
bool render (ID3D11DeviceContext *, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView *)
 

Detailed Description

Definition at line 20 of file texture_shader_class.h.

Constructor & Destructor Documentation

◆ texture_shader_class() [1/2]

texture_shader_class::texture_shader_class ( )

Definition at line 4 of file texture_shader_class.cpp.

5{
6 vertex_shader_ = 0;
7 pixel_shader_ = 0;
8 layout_ = 0;
9 matrix_buffer_ = 0;
10 sample_state_ = 0;
11}

◆ texture_shader_class() [2/2]

texture_shader_class::texture_shader_class ( const texture_shader_class & other)

Definition at line 14 of file texture_shader_class.cpp.

15{
16}

◆ ~texture_shader_class()

texture_shader_class::~texture_shader_class ( )

Definition at line 19 of file texture_shader_class.cpp.

20{
21}

Member Function Documentation

◆ initialize()

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

Definition at line 24 of file texture_shader_class.cpp.

25{
26 Logger::Get().Log("Initializing texture shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
27
28 bool result;
29 wchar_t vsFilename[128];
30 wchar_t psFilename[128];
31 int error;
32 // Set the filename of the vertex shader.
33 error = wcscpy_s(vsFilename, 128, L"src/hlsl/texture.vs");
34 if (error != 0)
35 {
36 Logger::Get().Log("Error copying stirng", __FILE__, __LINE__, Logger::LogLevel::Error);
37 return false;
38 }
39
40 // Set the filename of the pixel shader.
41 error = wcscpy_s(psFilename, 128, L"src/hlsl/texture.ps");
42 if (error != 0)
43 {
44 Logger::Get().Log("Error copying stirng", __FILE__, __LINE__, Logger::LogLevel::Error);
45 return false;
46 }
47
48 // initialize the vertex and pixel shaders.
49 result = initialize_shader(device, hwnd, vsFilename, psFilename);
50 if (!result)
51 {
52 Logger::Get().Log("Error initializing shader", __FILE__, __LINE__, Logger::LogLevel::Error);
53 return false;
54 }
55
56 Logger::Get().Log("Texture shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
57
58 return true;
59}
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 texture_shader_class::render ( ID3D11DeviceContext * deviceContext,
int indexCount,
XMMATRIX worldMatrix,
XMMATRIX viewMatrix,
XMMATRIX projectionMatrix,
ID3D11ShaderResourceView * texture )

Definition at line 69 of file texture_shader_class.cpp.

71{
72 bool result;
73
74
75 // Set the shader parameters that it will use for rendering.
76 result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture);
77 if (!result)
78 {
79 Logger::Get().Log("Error setting shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
80 return false;
81 }
82
83 // Now render the prepared buffers with the shader.
84 render_shader(deviceContext, indexCount);
85
86 return true;
87}

◆ shutdown()

void texture_shader_class::shutdown ( )

Definition at line 61 of file texture_shader_class.cpp.

62{
63 // shutdown the vertex and pixel shaders as well as the related objects.
64 shutdown_shader();
65
66 return;
67}

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