Struct VertexArray

Inheritance Relationships

Base Type

Struct Documentation

struct VertexArray : public CE::Rendering::Geometry::Buffer2D

Declaration: final

Immutable native vertex upload retaining its VAO and buffers.

2D ranges use vertex counts, not bytes. Indexed 3D construction is supported as native storage but reports Unsupported layout and rejects the 2D draw path. CPU upload views/owners are not retained after construction.

See also

Rendering guide

Public Functions

VertexArray(std::shared_ptr<::CE::Rendering::OpenGL::ResourceLifetime> lifetime, std::span<const ::CE::Rendering::Geometry::Vertex2D> vertices, ::CE::Rendering::Geometry::Topology topology)

Upload position3/UV2 vertices with fixed common attribute locations.

Parameters:
  • lifetime – Required live owner/current-context native domain.

  • vertices – Nonempty contiguous CPU data within GLsizei/GLsizeiptr limits, borrowed until return.

  • topology – Triangles or TriangleStrip; no per-primitive completeness check is made until packet validation. Malformed input/topology throws invalid_args. Native/allocation failures retire completed adopted objects; construction may change native bindings and does not restore their prior values.

VertexArray(std::shared_ptr<::CE::Rendering::OpenGL::ResourceLifetime> lifetime, std::span<const ::CE::Rendering::Geometry::Vertex2DColor> vertices, ::CE::Rendering::Geometry::Topology topology)

Upload position3/UV2/color4 vertices with fixed common attribute locations.

Parameters:
  • lifetime – Required live owner/current-context native domain.

  • vertices – Nonempty contiguous CPU data within GLsizei/GLsizeiptr limits, borrowed until return.

  • topology – Triangles or TriangleStrip; no per-primitive completeness check is made until packet validation. Malformed input/topology throws invalid_args. Native/allocation failures retire completed adopted objects; construction may change native bindings and does not restore their prior values.

VertexArray(std::shared_ptr<::CE::Rendering::OpenGL::ResourceLifetime> lifetime, std::shared_ptr<::CE::Rendering::Geometry::Vertex2D> vertices, uint32_t num_vertices, ::CE::Rendering::Geometry::Topology topology)

Compatibility upload retaining the CPU array only through the span constructor.

Parameters:
  • lifetime – Required live native domain.

  • vertices – Owner of at least num_vertices contiguous vertices.

  • num_vertices – Nonzero count, not bytes.

  • topology – Uploaded triangle/strip interpretation. Null/empty input rejects; remaining size/native/failure behavior matches the position/UV span overload.

VertexArray(std::shared_ptr<::CE::Rendering::OpenGL::ResourceLifetime> lifetime, std::shared_ptr<::CE::Rendering::Geometry::Vertex3D> vertices, uint32_t num_vertices, std::shared_ptr<uint32_t> indices, uint32_t num_indices)

Copy an indexed 3D mesh into native vertex/element buffers.

Parameters:
  • lifetime – Required live owner/current-context native domain.

  • vertices – Contiguous position/normal/UV array borrowed through upload.

  • num_vertices – Positive addressable vertex count.

  • indices – Contiguous unsigned index array borrowed through upload.

  • num_indices – Positive addressable index count. Null/empty/oversized buffers throw invalid_args; index contents are not bounds-validated here. The common 2D draw() path rejects meshes; construction retains no CPU owners and may change native bindings.

virtual void bind() const override

Bind this VAO after requiring its original live owner/current context; no program, image or material is selected.

virtual void draw(std::size_t first_vertex, std::size_t vertex_count) const override

Issue glDrawArrays for this flat upload’s topology after require_draw().

Parameters:
  • first_vertex – First vertex index, not a byte offset.

  • vertex_count – Bounded vertex count representable by the uploaded native limits. Caller must bind this VAO and compatible program/material state first. This primitive does not bind it or enforce nonzero/complete primitives; pipeline playback does.

inline virtual ::CE::Rendering::Geometry::Layout2D vertex_layout() const noexcept override

Declaration: [[nodiscard]]

Returns:

Uploaded flat layout or Unsupported for indexed mesh construction; CPU metadata only.

inline virtual ::CE::Rendering::Geometry::Topology topology() const noexcept override

Declaration: [[nodiscard]]

Returns:

Uploaded topology metadata without native calls.

inline virtual std::size_t vertex_count() const noexcept override

Declaration: [[nodiscard]]

Returns:

Uploaded vertex count, not bytes or mesh index count; CPU inspection only.

inline const ::CE::Rendering::OpenGL::ResourceLifetime *resource_domain() const noexcept

Declaration: [[nodiscard]]

Returns:

Borrowed original native-domain identity while retaining this upload; no current/active validation occurs.

void require_draw(std::size_t first_vertex, std::size_t vertex_count) const

Validate live owner/current context, flat upload kind and bounded range without binding/drawing.

Parameters:
  • first_vertex – First vertex index.

  • vertex_count – Range count; zero/primitive completeness is checked by common pipeline validation, not this low-level check. Mesh/range mismatch throws invalid_args; lifetime failures throw failed_operation.

Protected Types

enum VAOType

Protected upload family; the common 2D draw path accepts flat only.

Values:

enumerator flat

Nonindexed position/UV or position/UV/color geometry.

enumerator mesh

Indexed position/normal/UV storage, outside common 2D playback.

Protected Attributes

enum CE::Rendering::OpenGL::VertexArray::VAOType type

Upload family selected during construction.

::CE::Rendering::Geometry::Topology topology_ = ::CE::Rendering::Geometry::Topology::Triangles

Uploaded primitive interpretation.

::CE::Rendering::Geometry::Layout2D layout_ = ::CE::Rendering::Geometry::Layout2D::Position3UV2

Selected flat vertex layout; mesh reports Unsupported.

std::size_t vertex_count_ = 0

Number of uploaded vertices, independent of mesh index count.

::CE::Rendering::OpenGL::Handle vao_

Retained vertex-array registration in the original native domain.

std::array<::CE::Rendering::OpenGL::Handle, 2> vbo_

Retained native index/vertex buffers; final release queues retirement.