# Khaotic Engine Reborn: Skybox Class Reference

Loading...
Searching...
No Matches
Skybox Class Reference

## Public Member Functions

void | Initialize (d_3d_class *d3dClassRef)
object * | ConstructSkybox (application_class *app)

## Public Attributes

std::vector< ID3D11ShaderResourceView * > | textures
std::vector< XMMATRIX > | translations

## Detailed Description

Definition at line 7 of file Skybox.h.

## Constructor & Destructor Documentation

## Skybox()

Skybox::Skybox | ( |  | ) |

Definition at line 3 of file Skybox.cpp.

{
}

## ~Skybox()

Skybox::~Skybox | ( |  | ) |

Definition at line 7 of file Skybox.cpp.

{
for (auto& texture : textures)
{
if (texture)
{
texture->Release();
texture = nullptr;
}
}
textures.clear();
translations.clear();
}

## Member Function Documentation

## ConstructSkybox()

object * Skybox::ConstructSkybox | ( | application_class * | app | ) |

Definition at line 26 of file Skybox.cpp.

{
Logger::Get().Log("Construct skybox", __FILE__, __LINE__, Logger::LogLevel::Initialize);
char modelFilename[128];
strcpy_s(modelFilename, "assets/Model/OBJ/skysphere.obj");
std::vector<std::wstring> skyboxTextures = {
L"assets/Skybox/skybox.png",
};
TextureContainer SkyboxTextures;
// Load the textures
for (const auto& textureFilename : skyboxTextures)
{
ID3D11ShaderResourceView* texture = nullptr;
HRESULT result = DirectX::CreateWICTextureFromFile(m_d3dClassRef->get_device(), m_d3dClassRef->get_device_context(), textureFilename.c_str(), nullptr, &texture);
if (FAILED(result))
{
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
return nullptr;
}
SkyboxTextures.diffuse.push_back(texture);
}
// Create the model object
m_Skybox = new object(*app);
HRESULT result = m_Skybox->Initialize(m_d3dClassRef->get_device(), m_d3dClassRef->get_device_context(), modelFilename, SkyboxTextures);
if (!result)
{
Logger::Get().Log("Could not initialize the skybox model object", __FILE__, __LINE__, Logger::LogLevel::Error);
delete m_Skybox;
return nullptr;
}
m_Skybox->SetTranslateMatrix(XMMatrixTranslation(0.0f, 0.0f, 0.0f)); // Set the initial translation of the skybox
m_Skybox->SetActiveShader(ShaderType::SKYBOX);
return m_Skybox; // Return the constructed skybox object
}
object
Definition object.h:30
TextureContainer
Definition model_class.h:34

## Initialize()

void Skybox::Initialize | ( | d_3d_class * | d3dClassRef | ) |

Definition at line 21 of file Skybox.cpp.

{
m_d3dClassRef = d3dClassRef;
}

## Member Data Documentation

## textures

std::vector<ID3D11ShaderResourceView*> Skybox::textures

Definition at line 21 of file Skybox.h.

## translations

std::vector<XMMATRIX> Skybox::translations

Definition at line 22 of file Skybox.h.

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

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