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

Information needed to use hardware-accelerated shadows. More...

#include "VK2D/Structs.h"
#include <SDL2/SDL.h>
Include dependency graph for ShadowEnvironment.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

VK2DShadowEnvironment vk2DShadowEnvironmentCreate ()
 Creates a new shadow environment. More...
 
void vk2DShadowEnvironmentFree (VK2DShadowEnvironment shadowEnvironment)
 Frees a shadow environment. More...
 
VK2DShadowObject vk2dShadowEnvironmentAddObject (VK2DShadowEnvironment shadowEnvironment)
 Adds a new object to a shadow environment. More...
 
void vk2dShadowEnvironmentObjectSetPos (VK2DShadowEnvironment shadowEnvironment, VK2DShadowObject object, float x, float y)
 Translates a shadow object. More...
 
void vk2dShadowEnvironmentObjectUpdate (VK2DShadowEnvironment shadowEnvironment, VK2DShadowObject object, float x, float y, float scaleX, float scaleY, float rotation, float originX, float originY)
 Updates a shadow object. More...
 
void vk2dShadowEnvironmentObjectSetStatus (VK2DShadowEnvironment shadowEnvironment, VK2DShadowObject object, bool enabled)
 Updates a shadow object's status. More...
 
bool vk2dShadowEnvironmentObjectGetStatus (VK2DShadowEnvironment shadowEnvironment, VK2DShadowObject object)
 Returns a shadow object's status. More...
 
void vk2DShadowEnvironmentAddEdge (VK2DShadowEnvironment shadowEnvironment, float x1, float y1, float x2, float y2)
 Adds an edge to a shadow environment's current object, use this on wall edges. More...
 
void vk2dShadowEnvironmentResetEdges (VK2DShadowEnvironment shadowEnvironment)
 Removes all edges from the shadow environment's cache in case you want to change the edges. More...
 
void vk2DShadowEnvironmentFlushVBO (VK2DShadowEnvironment shadowEnvironment)
 Flushes the edges present in the environment to a VBO that can be drawn to screen. More...
 

Detailed Description

Information needed to use hardware-accelerated shadows.

Author
Paolo Mazzon

Function Documentation

◆ vk2DShadowEnvironmentAddEdge()

void vk2DShadowEnvironmentAddEdge ( VK2DShadowEnvironment  shadowEnvironment,
float  x1,
float  y1,
float  x2,
float  y2 
)

Adds an edge to a shadow environment's current object, use this on wall edges.

Parameters
shadowEnvironmentShadow environment to add to
x1X of the start of the edge
y1Y of the start of the edge
x2X of the end of the edge
y2Y of the end of the edge

You may call this from another thread so long as you do not call vk2DShadowEnvironmentFlushVBO at the same time (ie, set up all your edges in the other thread and once you know that thread is done adding edges call vk2DShadowEnvironmentFlushVBO).

◆ vk2dShadowEnvironmentAddObject()

VK2DShadowObject vk2dShadowEnvironmentAddObject ( VK2DShadowEnvironment  shadowEnvironment)

Adds a new object to a shadow environment.

Parameters
shadowEnvironmentShadow environment
Returns
Shadow object index, or VK2D_INVALID_SHADOW_OBJECT if this fails

◆ vk2DShadowEnvironmentCreate()

VK2DShadowEnvironment vk2DShadowEnvironmentCreate ( )

Creates a new shadow environment.

Returns
An empty shadow environment.

◆ vk2DShadowEnvironmentFlushVBO()

void vk2DShadowEnvironmentFlushVBO ( VK2DShadowEnvironment  shadowEnvironment)

Flushes the edges present in the environment to a VBO that can be drawn to screen.

Parameters
shadowEnvironmentShadow environment to flush
Warning
This function has heavy overhead and should not be called every frame.

◆ vk2DShadowEnvironmentFree()

void vk2DShadowEnvironmentFree ( VK2DShadowEnvironment  shadowEnvironment)

Frees a shadow environment.

Parameters
shadowEnvironmentShadow environment to free

◆ vk2dShadowEnvironmentObjectGetStatus()

bool vk2dShadowEnvironmentObjectGetStatus ( VK2DShadowEnvironment  shadowEnvironment,
VK2DShadowObject  object 
)

Returns a shadow object's status.

Parameters
shadowEnvironmentShadow environment
objectObject to update
Returns
enabled Whether or not this object will be visible

◆ vk2dShadowEnvironmentObjectSetPos()

void vk2dShadowEnvironmentObjectSetPos ( VK2DShadowEnvironment  shadowEnvironment,
VK2DShadowObject  object,
float  x,
float  y 
)

Translates a shadow object.

Parameters
shadowEnvironmentShadow environment
objectObject to update
xX position of the object
yY position of the object

◆ vk2dShadowEnvironmentObjectSetStatus()

void vk2dShadowEnvironmentObjectSetStatus ( VK2DShadowEnvironment  shadowEnvironment,
VK2DShadowObject  object,
bool  enabled 
)

Updates a shadow object's status.

Parameters
shadowEnvironmentShadow environment
objectObject to update
enabledWhether or not this object will be visible

◆ vk2dShadowEnvironmentObjectUpdate()

void vk2dShadowEnvironmentObjectUpdate ( VK2DShadowEnvironment  shadowEnvironment,
VK2DShadowObject  object,
float  x,
float  y,
float  scaleX,
float  scaleY,
float  rotation,
float  originX,
float  originY 
)

Updates a shadow object.

Parameters
shadowEnvironmentShadow environment
objectObject to update
xX position of the object
yY position of the object
scaleXX scale of the object
scaleYY scale of the object
rotationRotation of the object
originXX origin of the object
originYY origin of the object

◆ vk2dShadowEnvironmentResetEdges()

void vk2dShadowEnvironmentResetEdges ( VK2DShadowEnvironment  shadowEnvironment)

Removes all edges from the shadow environment's cache in case you want to change the edges.

Parameters
shadowEnvironmentShadow environment to reset
Warning
This invalidates all objects previously got from vk2dShadowEnvironmentAddObject