Skip to content

Commit

Permalink
Add documentation comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mogemimi committed Nov 16, 2019
1 parent 5f7867a commit b0a3f08
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 8 deletions.
8 changes: 8 additions & 0 deletions include/Pomdog/Graphics/BufferUsage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@

namespace Pomdog {

/// Identifies the expected usage pattern of graphics buffers during rendering.
enum class BufferUsage : std::uint8_t {
/// A resource that can only be read by the GPU. It cannot be accessed by the CPU.
///
/// A immutable resource must be initialized when it is created, since it cannot be changed after creation.
Immutable,

/// A resource that will be modified repeatedly. It is accessible by both the GPU (read only) and the CPU (write only).
///
/// A dynamic resource is a good choice for a resource that will be updated by the CPU per frame.
Dynamic,
};

Expand Down
6 changes: 6 additions & 0 deletions include/Pomdog/Graphics/ConstantBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,32 @@ class POMDOG_EXPORT ConstantBuffer final {

void GetValue(std::size_t sizeInBytes, void* result) const;

/// Sets constant buffer data.
template <typename T>
void SetValue(const T& value)
{
static_assert(std::is_pod<T>::value, "You can only use plain-old-data types.");
Detail::EffectBinaryParameter::Set(*this, value);
}

/// Sets constant buffer data.
template <typename T>
void SetValue(const T* data, std::size_t count)
{
static_assert(std::is_pod<T>::value, "You can only use plain-old-data types.");
Detail::EffectBinaryParameter::Set(*this, data, count);
}

/// Sets constant buffer data.
void SetValue(const void* data, std::size_t sizeInBytes);

/// Gets the size in bytes of this constant buffer.
std::size_t GetSizeInBytes() const noexcept;

/// Gets the expected usage hint of this constant buffer.
BufferUsage GetBufferUsage() const noexcept;

/// Gets the pointer of the native constant buffer resource.
Detail::NativeBuffer* GetNativeConstantBuffer();

private:
Expand Down
6 changes: 6 additions & 0 deletions include/Pomdog/Graphics/CullMode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@

namespace Pomdog {

/// Indicates whether to cull primitives for hidden surface removal.
enum class CullMode : std::uint8_t {
/// Does not cull any back faces.
None,

/// Culls back faces with clockwise vertices.
ClockwiseFace,

/// Culls back faces with counterclockwise vertices.
CounterClockwiseFace,
};

Expand Down
4 changes: 4 additions & 0 deletions include/Pomdog/Graphics/FillMode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@

namespace Pomdog {

/// Determines the fill mode to use when rendering primitives.
enum class FillMode : std::uint8_t {
/// Draws polygon edges as line segments.
WireFrame,

/// Rasterizes triangle primitives as filled triangles.
Solid,
};

Expand Down
3 changes: 3 additions & 0 deletions include/Pomdog/Graphics/GraphicsDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ class POMDOG_EXPORT GraphicsDevice final {

~GraphicsDevice();

/// Gets the currently supported shader language.
ShaderLanguage GetSupportedLanguage() const noexcept;

/// Gets the presentation parameters.
PresentationParameters GetPresentationParameters() const noexcept;

/// Gets the pointer of the native graphics device.
Detail::NativeGraphicsDevice* GetNativeGraphicsDevice();

private:
Expand Down
7 changes: 7 additions & 0 deletions include/Pomdog/Graphics/IndexBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,28 @@ class POMDOG_EXPORT IndexBuffer final {
IndexBuffer& operator=(const IndexBuffer&) = delete;
IndexBuffer& operator=(IndexBuffer&&) = default;

/// Gets the number of indices.
std::size_t GetIndexCount() const noexcept;

/// Gets the size in bytes of per-index element.
IndexElementSize GetElementSize() const noexcept;

/// Gets the size in bytes of this index buffer.
std::size_t GetSizeInBytes() const noexcept;

/// Gets the expected usage hint of this index buffer.
BufferUsage GetBufferUsage() const noexcept;

/// Sets index buffer data.
void SetData(const void* source, std::size_t elementCount);

/// Sets index buffer data.
void SetData(
std::size_t offsetInBytes,
const void* source,
std::size_t elementCount);

/// Gets the pointer of the native index buffer resource.
Detail::NativeBuffer* GetNativeIndexBuffer();

private:
Expand Down
4 changes: 2 additions & 2 deletions include/Pomdog/Graphics/IndexElementSize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
namespace Pomdog {

enum class IndexElementSize : std::uint8_t {
///@brief 16 bit.
/// A 16-bit unsigned integer used as a the size of a primitive index.
SixteenBits,

///@brief 32 bit.
/// A 32-bit unsigned nteger used as a the size of a primitive index.
ThirtyTwoBits,
};

Expand Down
8 changes: 4 additions & 4 deletions include/Pomdog/Graphics/PrimitiveTopology.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
namespace Pomdog {

enum class PrimitiveTopology : std::uint8_t {
///@brief A triangle list.
/// A triangle list.
TriangleList,

///@brief A triangle strip.
/// A triangle strip.
TriangleStrip,

///@brief A line list.
/// A line list.
LineList,

///@brief A line strip.
/// A line strip.
LineStrip,
};

Expand Down
12 changes: 12 additions & 0 deletions include/Pomdog/Graphics/RasterizerDescription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,22 @@
namespace Pomdog {

struct POMDOG_EXPORT RasterizerDescription final {
/// A constant depth bias applied to a given pixel.
///
/// The depth bias (or z-bias) can be added to each of the polygons that
/// are coplanar in 3D space to make them appear as if they are not coplanar.
std::int32_t DepthBias;

/// A scale on a depth gradient of the primitive.
float SlopeScaledDepthBias;

/// Indicates whether to cull primitives for hidden surface removal.
Pomdog::CullMode CullMode;

/// Determines the fill mode to use when rendering primitives.
Pomdog::FillMode FillMode;

/// Enable multisample antialiasing (MSAA).
bool MultisampleEnable;

static RasterizerDescription CreateDefault()
Expand Down
9 changes: 9 additions & 0 deletions include/Pomdog/Graphics/RenderPass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ namespace Pomdog {
using RenderTargetAndClearColor = std::tuple<std::shared_ptr<RenderTarget2D>, std::optional<Vector4>>;

struct POMDOG_EXPORT RenderPass final {
/// An array of render targets.
std::vector<RenderTargetAndClearColor> RenderTargets;

/// A viewport for projection transformations and clipping.
std::optional<Pomdog::Viewport> Viewport;

/// A scissor rectangle for a scissor test.
std::optional<Rectangle> ScissorRect;

/// The depth value to use when the depth buffer is cleared.
std::optional<float> ClearDepth;

/// The stencil value to use when the stencil buffer is cleared.
std::optional<std::uint8_t> ClearStencil;
};

Expand Down
1 change: 1 addition & 0 deletions include/Pomdog/Graphics/SamplerState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class POMDOG_EXPORT SamplerState final {

~SamplerState();

/// Gets the pointer of the native sampler state object.
Detail::NativeSamplerState* GetNativeSamplerState();

private:
Expand Down
7 changes: 7 additions & 0 deletions include/Pomdog/Graphics/VertexBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,29 @@ class POMDOG_EXPORT VertexBuffer final {
VertexBuffer& operator=(const VertexBuffer&) = delete;
VertexBuffer& operator=(VertexBuffer&&) = default;

/// Gets the number of vertices.
std::size_t GetVertexCount() const noexcept;

/// Gets the size in bytes of per-vertex data.
std::size_t GetStrideBytes() const noexcept;

/// Gets the size in bytes of this vertex buffer.
std::size_t GetSizeInBytes() const noexcept;

/// Gets the expected usage hint of this vertex buffer.
BufferUsage GetBufferUsage() const noexcept;

/// Sets vertex buffer data.
void SetData(const void* source, std::size_t elementCount);

/// Sets vertex buffer data.
void SetData(
std::size_t offsetInBytes,
const void* source,
std::size_t elementCount,
std::size_t strideInBytes);

/// Gets the pointer of the native vertex buffer resource.
Detail::NativeBuffer* GetNativeVertexBuffer();

private:
Expand Down
15 changes: 13 additions & 2 deletions include/Pomdog/Graphics/Viewport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@ namespace Pomdog {

class POMDOG_EXPORT Viewport final {
public:
/// The x coordinate of the upper-left corner of the viewport.
int TopLeftX;

/// The y coordinate of the upper-left corner of the viewport.
int TopLeftY;

/// The width of the viewport, in pixels.
int Width;

/// The height of the viewport, in pixels.
int Height;

// The minimum depth of the viewport. It must be between 0.0 and 1.0.
/// The minimum depth of the clip volume. It must be between 0.0 and 1.0.
float MinDepth;

// The maximum depth of the viewport. It must be between 0.0 and 1.0.
/// The maximum depth of the clip volume. It must be between 0.0 and 1.0.
float MaxDepth;

public:
Expand All @@ -30,16 +37,20 @@ class POMDOG_EXPORT Viewport final {
Viewport(int x, int y, int width, int height,
float minDepth, float maxDepth) noexcept;

/// Projects a position from object space into screen space.
Vector3 Project(
const Vector3& source,
const Matrix4x4& worldViewProjection) const;

/// Projects a position from screen space into world space.
Vector3 Unproject(
const Vector3& source,
const Matrix4x4& worldViewProjection) const;

/// Gets the boundary of this viewport.
[[nodiscard]] Rectangle GetBounds() const noexcept;

/// Gets the aspect ratio used by the viewport, which is width / height.
[[nodiscard]] float GetAspectRatio() const noexcept;
};

Expand Down

0 comments on commit b0a3f08

Please sign in to comment.