opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
cubemap.h
Go to the documentation of this file.
1#pragma once
2
8
9#include <span>
10
11namespace osc
12{
13 // Represents a single texture composed of six images that are tessellated into
14 // a cube shape such that they can be sampled using a direction vector that
15 // originates from the center of the cube (i.e. via a `samplerCube`, in GLSL).
16 //
17 // Note: Each of the six faces of the cube should be provided in the same way
18 // as for a `Texture2D` (i.e. starting in the bottom-left and moving row
19 // by row to the top right), but the direction vector in the GLSL shader
20 // is not in something resembling the texture or world coordinate system.
21 // Instead, it's in a left-handed cube map coordinate system that's used
22 // by shader implementations to figure out which of the six faces to
23 // address with a standard 2D vector in texture coordinate space.
24 //
25 // See the OpenGL specification, section 8.13, "Cube Map Texture Selection"
26 // (e.g. https://registry.khronos.org/OpenGL/specs/gl/glspec46.core.pdf) for
27 // more details, but it usually means that the images either have to be
28 // rotated or the direction vector has to be flipped.
29 class Cubemap final {
30 public:
31 // Constructs a cubemap that is `width` physical pixels wide and high, and
32 // the given `format`.
34
35 int32_t width() const;
37
38 TextureWrapMode wrap_mode() const; // same as `wrap_mode_u`
39 void set_wrap_mode(TextureWrapMode); // sets all axes
46
49
50 // The number of provided bytes must match the provided `width*width` and
51 // `TextureFormat` of this `Cubemap`, or an exception will be thrown.
52 void set_pixel_data(CubemapFace, std::span<const uint8_t>);
53
54 friend bool operator==(const Cubemap&, const Cubemap&) = default;
55
56 class Impl;
57 const Impl& impl() const { return *impl_; }
58 private:
59 friend class GraphicsBackend;
60
62 };
63}
Definition copy_on_upd_shared_value.h:16
Definition cubemap.h:29
TextureWrapMode wrap_mode_w() const
void set_pixel_data(CubemapFace, std::span< const uint8_t >)
Cubemap(int32_t width, TextureFormat format)
friend class GraphicsBackend
Definition cubemap.h:59
TextureFormat texture_format() const
friend bool operator==(const Cubemap &, const Cubemap &)=default
void set_wrap_mode(TextureWrapMode)
void set_wrap_mode_w(TextureWrapMode)
void set_filter_mode(TextureFilterMode)
const Impl & impl() const
Definition cubemap.h:57
void set_wrap_mode_u(TextureWrapMode)
TextureWrapMode wrap_mode_u() const
TextureWrapMode wrap_mode_v() const
TextureFilterMode filter_mode() const
int32_t width() const
void set_wrap_mode_v(TextureWrapMode)
TextureWrapMode wrap_mode() const
Definition custom_decoration_generator.h:5
TextureFilterMode
Definition texture_filter_mode.h:8
TextureWrapMode
Definition texture_wrap_mode.h:9
TextureFormat
Definition texture_format.h:10
constexpr U to(T &&value)
Definition conversion.h:56
CubemapFace
Definition cubemap_face.h:5