Skip to content

Vp::Shaper

A utility class for constructing simple shapes. More...

#include "Viewport/Shaper.h"

Public Functions

Name
voidinitDefaultShapes()
voidclear()<br>Clear prepared geometry (vertices and colors).
Core::Mesh *createLineMesh(const std::string & alias ="", Core::Mesh::BufferType bufferType =Core::Mesh::BufferType::STATIC)<br>Create a line mesh from current shaper state.
Core::Mesh *createMesh(const std::string & alias ="", Core::Mesh::BufferType bufferType =Core::Mesh::BufferType::STATIC)<br>Create a triangle mesh from current shaper state.
const std::vector< float > &getColors() const
const std::vector< float > &getVertices() const
voidline(const glm::vec3 a, const glm::vec3 b)<br>Prepare geometry for line from a to b using the single global color currentColor.
voidline(const glm::vec3 a, const glm::vec3 b, const glm::vec3 color)<br>Prepare geometry for line from a to b using the single color color for the whole line (both line ends)
voidline(const glm::vec3 a, const glm::vec3 b, const glm::vec3 color_a, const glm::vec3 color_b)<br>Prepare geometry for line from a to b using the single color color for the whole line (both line ends)
voidlineBox(glm::vec3 from, glm::vec3 to)
voidquad(const glm::vec3 a, const glm::vec3 b, const glm::vec3 c, const glm::vec3 d)<br>Creates a quad with two triangles.
voidquad(const glm::vec3 a, const glm::vec3 b, const glm::vec3 c, const glm::vec3 d, const glm::vec3 color)<br>Creates a quad with two triangles.
voidreserveBuffers(const int newCapacity)
voidsetColor(const glm::vec3 color)<br>Set the current drawing color.
voidupdateLineMesh(Core::Mesh * mesh)
voidupdateMesh(Core::Mesh * mesh)

Public Attributes

Name
std::stringplane
std::stringscreenQuad <br>Screen quad for post processing.
std::stringunitCube <br>Equivalent to standard OpenGL ndc space.
std::stringunitLineCube <br>Equivalent to standard OpenGL ndc space.
std::stringvulkanNdcCube
std::stringvulkanNdcLineCube
std::stringxyzAxes <br>Simple three color line axes.

Detailed Description

cpp
class Vp::Shaper;
class Vp::Shaper;

A utility class for constructing simple shapes.

Used in Viewport for drawing of world axes, axes of models and wireframe objects (such as projection frustum)

Public Functions Documentation

function initDefaultShapes

cpp
static void initDefaultShapes()
static void initDefaultShapes()

function clear

cpp
void clear()
void clear()

Clear prepared geometry (vertices and colors).

function createLineMesh

cpp
Core::Mesh * createLineMesh(
    const std::string & alias ="",
    Core::Mesh::BufferType bufferType =Core::Mesh::BufferType::STATIC
)
Core::Mesh * createLineMesh(
    const std::string & alias ="",
    Core::Mesh::BufferType bufferType =Core::Mesh::BufferType::STATIC
)

Create a line mesh from current shaper state.

Parameters:

  • alias Unique shape identifier, registered with ResourceManager if not empty

Return:

Note: Dynamic meshes should not provide an alias, as they would persist in ResourceManager.

function createMesh

cpp
Core::Mesh * createMesh(
    const std::string & alias ="",
    Core::Mesh::BufferType bufferType =Core::Mesh::BufferType::STATIC
)
Core::Mesh * createMesh(
    const std::string & alias ="",
    Core::Mesh::BufferType bufferType =Core::Mesh::BufferType::STATIC
)

Create a triangle mesh from current shaper state.

Parameters:

  • alias Unique shape identifier, registered with ResourceManager if not empty

Return:

Note: Dynamic meshes should not provide an alias, as they would persist in ResourceManager.

function getColors

cpp
const std::vector< float > & getColors() const
const std::vector< float > & getColors() const

function getVertices

cpp
const std::vector< float > & getVertices() const
const std::vector< float > & getVertices() const

function line

cpp
void line(
    const glm::vec3 a,
    const glm::vec3 b
)
void line(
    const glm::vec3 a,
    const glm::vec3 b
)

Prepare geometry for line from a to b using the single global color currentColor.

Parameters:

  • a point from
  • b point to

function line

cpp
void line(
    const glm::vec3 a,
    const glm::vec3 b,
    const glm::vec3 color
)
void line(
    const glm::vec3 a,
    const glm::vec3 b,
    const glm::vec3 color
)

Prepare geometry for line from a to b using the single color color for the whole line (both line ends)

Parameters:

  • a Start point
  • b End point
  • color Line color

function line

cpp
void line(
    const glm::vec3 a,
    const glm::vec3 b,
    const glm::vec3 color_a,
    const glm::vec3 color_b
)
void line(
    const glm::vec3 a,
    const glm::vec3 b,
    const glm::vec3 color_a,
    const glm::vec3 color_b
)

Prepare geometry for line from a to b using the single color color for the whole line (both line ends)

Parameters:

  • a Start point
  • b End point
  • color_a Start-point color
  • color_b End-point color

function lineBox

cpp
void lineBox(
    glm::vec3 from,
    glm::vec3 to
)
void lineBox(
    glm::vec3 from,
    glm::vec3 to
)

function quad

cpp
void quad(
    const glm::vec3 a,
    const glm::vec3 b,
    const glm::vec3 c,
    const glm::vec3 d
)
void quad(
    const glm::vec3 a,
    const glm::vec3 b,
    const glm::vec3 c,
    const glm::vec3 d
)

Creates a quad with two triangles.

Parameters:

  • a Top left corner
  • b Top right corner
  • c Bottom left corner
  • d Bottom right corner

Triangles are CCW acd and adb. a — b | \ | c — d

function quad

cpp
void quad(
    const glm::vec3 a,
    const glm::vec3 b,
    const glm::vec3 c,
    const glm::vec3 d,
    const glm::vec3 color
)
void quad(
    const glm::vec3 a,
    const glm::vec3 b,
    const glm::vec3 c,
    const glm::vec3 d,
    const glm::vec3 color
)

Creates a quad with two triangles.

Parameters:

  • a Top left corner
  • b Top right corner
  • c Bottom left corner
  • d Bottom right corner
  • color Color of the vertices

Triangles are CCW acd and adb. a — b | \ | c — d

function reserveBuffers

cpp
void reserveBuffers(
    const int newCapacity
)
void reserveBuffers(
    const int newCapacity
)

function setColor

cpp
void setColor(
    const glm::vec3 color
)
void setColor(
    const glm::vec3 color
)

Set the current drawing color.

Parameters:

  • color New drawing color "currentColor"

function updateLineMesh

cpp
void updateLineMesh(
    Core::Mesh * mesh
)
void updateLineMesh(
    Core::Mesh * mesh
)

function updateMesh

cpp
void updateMesh(
    Core::Mesh * mesh
)
void updateMesh(
    Core::Mesh * mesh
)

Public Attributes Documentation

variable plane

cpp
static std::string plane;
static std::string plane;

variable screenQuad

cpp
static std::string screenQuad;
static std::string screenQuad;

Screen quad for post processing.

variable unitCube

cpp
static std::string unitCube;
static std::string unitCube;

Equivalent to standard OpenGL ndc space.

variable unitLineCube

cpp
static std::string unitLineCube;
static std::string unitLineCube;

Equivalent to standard OpenGL ndc space.

variable vulkanNdcCube

cpp
static std::string vulkanNdcCube;
static std::string vulkanNdcCube;

variable vulkanNdcLineCube

cpp
static std::string vulkanNdcLineCube;
static std::string vulkanNdcLineCube;

variable xyzAxes

cpp
static std::string xyzAxes;
static std::string xyzAxes;

Simple three color line axes.


Updated on 2025-05-31 at 12:55:31 +0000