CubeTexture
Represents a cube map texture.
A cube texture stores six face images that form a cube map, commonly used for skyboxes and environment mapping. Each face corresponds to a direction along the positive or negative X, Y, or Z axis. Cube textures are typically created using CubeTextureLoader rather than instantiated directly.
cpp
auto MyScene::OnAttached(SharedContextPointer context) -> void {
skybox_handle_ = context->cube_texture_loader->LoadAsync({
.positive_x = "assets/skybox/px.png",
.negative_x = "assets/skybox/nx.png",
.positive_y = "assets/skybox/py.png",
.negative_y = "assets/skybox/ny.png",
.positive_z = "assets/skybox/pz.png",
.negative_z = "assets/skybox/nz.png",
});
}
auto MyScene::OnUpdate(float _) -> void {
if (auto skybox = skybox_handle_.TryTake()) {
this->background = skybox.value();
}
}INFO
Derives from Texture and inherits all public properties and methods.
Construction
Constructors
CubeTexture()
Constructs a cube texture from six face images.
The texture holds shared references to each face image, allowing multiple textures to share the same underlying pixel data.
cpp
CubeTexture::CubeTexture(Images images);| Parameter | Description |
|---|---|
| images | The six face images that make up the cube map. |
Factories preferred
CubeTexture::Create() std::shared_ptr<CubeTexture>
Creates a shared instance of CubeTexture.
cpp
static std::shared_ptr<CubeTexture> CubeTexture::Create(Images images);| Parameter | Description |
|---|---|
| images | The six face images that make up the cube map. |
Types
CubeTexture::Images struct
The six face images that make up the cube map.
| Parameter | Description |
|---|---|
| positive_x std::shared_ptr<Image> | Right face (+X). |
| negative_x std::shared_ptr<Image> | Left face (-X). |
| positive_y std::shared_ptr<Image> | Top face (+Y). |
| negative_y std::shared_ptr<Image> | Bottom face (-Y). |
| positive_z std::shared_ptr<Image> | Front face (+Z). |
| negative_z std::shared_ptr<Image> | Back face (-Z). |
Properties
Functions
GetType() Texture::Type virtual
Identifies this texture as Texture::Type::CubeTexture.
cpp
Type vglx::CubeTexture::GetType() const override;