Skip to content

Graphics library

This page lists all included graphics. The list is divided into:

  • 2D graphics: high-quality antialiased 2D graphical elements,
  • 3D graphics: meshes and volumes,
  • Basic graphics: basic, low-quality, aliased, but fast basic primitives (points, lines, triangles), useful for demo, testing, and when dealing with tens of millions of points

Note

If not specified, the default vertex structure is DvzVertex:

Field Type Description
pos vec3 position
color cvec4 color RGBA (four bytes)

2D graphics

Marker

Vertex structure: DvzGraphicsMarkerVertex

Field Type Description
pos vec3 position
color cvec4 color
size float marker size, in pixels
marker uint8_t marker type enum
angle uint8_t angle, between 0 (0) included and 256 (M_2PI) excluded
transform uint8_t transform enum

Params structure: DvzGraphicsMarkerParams

Field Type Description
edge_color vec4 edge color RGBA
edge_width float line width, in pixels

Segment

Vertex structure: DvzGraphicsSegmentVertex

Field Type Description
P0 vec3 start position
P1 vec3 end position
shift vec4 shift of start (xy) and end (zw) positions, in pixels
color cvec4 color
linewidth float line width, in pixels
cap0 DvzCapType start cap enum
cap1 DvzCapType end cap enum
transform uint8_t transform enum

Path

Vertex structure: DvzGraphicsPathVertex

Field Type Description
p0 vec3 previous position
p1 vec3 current position
p2 vec3 next position
p3 vec3 next next position
color cvec4 point color

Params structure: DvzGraphicsPathParams

Field Type Description
linewidth float line width in pixels
miter_limit float miter limit for joins
cap_type int32_t type of the ends of the path
round_join int32_t whether to use round joins

Text

Vertex structure: DvzGraphicsTextVertex

Field Type Description
pos vec3 position
shift vec2 shift, in pixels
color cvec4 color
glyph_size vec2 glyph size, in pixels
anchor vec2 character anchor, in normalized coordinates
angle float string angle
glyph usvec4 glyph: char code, char index, string length, string index
transform uint8_t transform enum

Params structure: DvzGraphicsTextParams

Field Type Description
grid_size ivec2 font atlas grid size (rows, columns)
tex_size ivec2 font atlas texture size, in pixels

Image

Item structure: DvzGraphicsImageItem

Field Type Description
pos0 vec3 top left corner
pos1 vec3 top right corner
pos2 vec3 bottom right corner
pos3 vec3 bottom left corner
uv0 vec2 tex coords of the top left corner
uv1 vec2 tex coords of the top right corner
uv2 vec2 tex coords of the bottom right corner
uv3 vec2 tex coords of the bottom left corner

Vertex structure: DvzGraphicsImageVertex

Field Type Description
pos vec3 position
uv vec2 tex coordinates

Params structure: DvzGraphicsImageParams

Field Type Description
tex_coefs vec4 blending coefficients for the four images

3D graphics

Mesh

Vertex structure: DvzGraphicsMeshVertex

Field Type Description
pos vec4 position
normal vec4 normal vector
uv vec2 tex coords
alpha uint8_t transparency value

Params structure: DvzGraphicsMeshParams

Field Type Description
lights_pos_0 mat4 positions of each of the maximum four lights
lights_params_0 mat4 ambient, diffuse, specular coefs for each light
tex_coefs vec4 blending coefficients for the four textures
clip_coefs vec4 clip coefficients

The mesh graphics supports the following features:

  • Phong shading
  • Up to four textures
  • Customizable texture blending coefficients
  • Transparency (but does not play well with depth test)
  • Support for arbitrary RGB values (via cvec3 packing into vec2)
  • Customizable plane clipping

Plane clipping: when the clip vector is non-zero, the fragment shader implements the following test. If the dot product of the clip vector with the vertex position (in scene coordinates) is negative, the fragment is discarded. This feature allows to cut the mesh along any arbitrary affine plane.

Basic graphics

Points

Params structure: DvzGraphicsPointParams

Field Type Description
point_size float point size, in pixels

Lines

Line strip

Triangles

Triangle strip

Triangle fan

Warning

Triangle fan graphics is not supported on macOS and should therefore be avoided if macOS compatibility is desirable.