Vulkan2D
2D renderer written in C using Vulkan and SDL2
Polygon.h File Reference

Abstraction of VK2DBuffer for shapes. More...

#include "VK2D/Structs.h"
Include dependency graph for Polygon.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

VK2DPolygon vk2dPolygonShapeCreateRaw (VK2DVertexColour *vertexData, uint32_t vertexCount)
 Creates a polygon for the shapes pipeline (should be triangulated) More...
 
VK2DPolygon vk2dPolygonCreate (vec2 *vertices, uint32_t vertexCount)
 Creates a polygon with specified vertices for drawing (use vk2dRendererSetColourMod to change colours) More...
 
VK2DPolygon vk2dPolygonCreateOutline (vec2 *vertices, uint32_t vertexCount)
 Creates a polygon made to be rendered as an outline (does not triangulate input) More...
 
void vk2dPolygonFree (VK2DPolygon polygon)
 Frees a polygon from memory. More...
 

Detailed Description

Abstraction of VK2DBuffer for shapes.

Author
Paolo Mazzon

Function Documentation

◆ vk2dPolygonCreate()

VK2DPolygon vk2dPolygonCreate ( vec2 vertices,
uint32_t  vertexCount 
)

Creates a polygon with specified vertices for drawing (use vk2dRendererSetColourMod to change colours)

Parameters
verticesList of x/y positions for the polygon's vertices
vertexCountAmount of vertices
Returns
Returns either the new polygon or NULL if it failed
Warning
Convex polygons only, the triangulation method will likely fail for concave polygons
Must have at least 3 vertices
While you may use polygons created from this function with vk2dDrawPolygonOutline, it may not look like you expect and for that reason you may want vk2dPolygonCreateOutline for polygons you want to draw outlined

◆ vk2dPolygonCreateOutline()

VK2DPolygon vk2dPolygonCreateOutline ( vec2 vertices,
uint32_t  vertexCount 
)

Creates a polygon made to be rendered as an outline (does not triangulate input)

Parameters
verticesList of x/y positions for the polygons vertices
vertexCountNumber of vertices in the list
Returns
Returns either the new polygon or NULL if it failed
Warning
It is not possible to draw a polygon made with this function with vk2dRendererDrawPolygon unless its a triangle
This function will crash on < 1 vertex

◆ vk2dPolygonFree()

void vk2dPolygonFree ( VK2DPolygon  polygon)

Frees a polygon from memory.

Parameters
polygonPolygon to free

◆ vk2dPolygonShapeCreateRaw()

VK2DPolygon vk2dPolygonShapeCreateRaw ( VK2DVertexColour vertexData,
uint32_t  vertexCount 
)

Creates a polygon for the shapes pipeline (should be triangulated)

Parameters
vertexDataVertex data of the polygon (must be triangulated)
vertexCountNumber of vertices
Returns
Returns a new polygon
Warning
This function is for creating fancier effects with the inner vertex data. Use vk2dPolygonCreate for creating simple shapes
Polygon must be triangulated unless it will be drawn as an outline, vk2dPolygonCreate automatically triangulates but this does not.