Screen Triangle

For post-processing effects, it is necessary to display a primitive filling the screen. Haiku allows you to create a single triangle fulfilling this role.

/* Declarations */
GeoPrimitive m_screen_triangle
/* Screen Triangle Creation */
Primitive::CreateScreenTriangle(&m_screen_triangle);
/* Screen Triangle Rendering */
Primitive::RenderScreenTriangle(m_screen);
/* Screen Triangle destruction */
Primitive::Destroy(&m_unit_cube);

Unit Cube

To display a skybox/environment map, it is necessary to display a simple cube:

/* Declarations */
GeoPrimitive m_unit_cube;
/* Unit cube creation */
Primitive::CreateUnitCube(&m_unit_cube);
/* Unit cube rendering */
Primitive::RenderUnitCube(m_unit_cube);
/* Unit cube destruction */
Primitive::Destroy(&m_unit_cube);

Primitive API Description

The data structure is composed only of two handles used as VBO and VAO for the requested primitive:

struct GeoPrimitive

Simple geometric primitives data structure.

Public Members

uint32_t vao = 0u

Vertex array object Opengl ID

uint32_t vbo = 0u

Vertex buffer object OpenGL ID

Functions can be accessed via the Primitive:: namespace:

namespace Primitive

Functions

void CreateScreenTriangle(GeoPrimitive *p)

Create a VBO and VAO of a screen triangle.

void RenderScreenTriangle(const GeoPrimitive &p)

Render a screen triangle.

void CreateUnitCube(GeoPrimitive *p)

Create a VBO and VAO of a unit cube.

void RenderUnitCube(const GeoPrimitive &p)

Render a unit cube mesh.

void Destroy(GeoPrimitive *p)

Cleanup primitive buffer.