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

Makes shaders possible in VK2D. More...

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

Go to the source code of this file.

Functions

VK2DShader vk2dShaderLoad (const char *vertexShader, const char *fragmentShader, uint32_t uniformBufferSize)
 Creates a shader you can use to render textures. More...
 
VK2DShader vk2dShaderFrom (uint8_t *vertexShaderBuffer, int vertexShaderBufferSize, uint8_t *fragmentShaderBuffer, int fragmentShaderBufferSize, uint32_t uniformBufferSize)
 Creates a shader you can use to render textures from an in-memory buffer. More...
 
void vk2dShaderFree (VK2DShader shader)
 Frees a shader from memory. More...
 

Detailed Description

Makes shaders possible in VK2D.

Author
Paolo Mazzon

Function Documentation

◆ vk2dShaderFree()

void vk2dShaderFree ( VK2DShader  shader)

Frees a shader from memory.

Parameters
shaderShader to free

◆ vk2dShaderFrom()

VK2DShader vk2dShaderFrom ( uint8_t *  vertexShaderBuffer,
int  vertexShaderBufferSize,
uint8_t *  fragmentShaderBuffer,
int  fragmentShaderBufferSize,
uint32_t  uniformBufferSize 
)

Creates a shader you can use to render textures from an in-memory buffer.

Parameters
vertexShaderBufferBuffer containing compiled SPIR-V shader code
vertexShaderBufferSizeSize of the vertexShaderBuffer buffer in bytes
fragmentShaderBufferFile containing the compiled SPIR-V fragment shader
fragmentShaderBufferSizeSize of the fragmentShaderBuffer buffer in bytes
uniformBufferSizeSize of the shader's expected uniform buffer (0 is valid)
Returns
Returns a new shader or NULL
Warning
There are strict requirements for how the shader should be constructed
uniformBufferSize must be less than the maxShaderBufferSize field of vk2dRendererGetLimits
uniformBufferSize must be a multiple of 4

Check the shaders shaders/tex.vert and shaders/tex.frag for information on how the shaders should be set up. You may choose to not include a uniform buffer if you specify a uniform buffer size of 0.

◆ vk2dShaderLoad()

VK2DShader vk2dShaderLoad ( const char *  vertexShader,
const char *  fragmentShader,
uint32_t  uniformBufferSize 
)

Creates a shader you can use to render textures.

Parameters
vertexShaderFile containing the compiled SPIR-V vertex shader
fragmentShaderFile containing the compiled SPIR-V fragment shader
uniformBufferSizeSize of the shader's expected uniform buffer (0 is valid)
Returns
Returns a new shader or NULL
Warning
There are strict requirements for how the shader should be constructed
uniformBufferSize must be less than the maxShaderBufferSize field of vk2dRendererGetLimits
uniformBufferSize must be a multiple of 4

Check the shaders shaders/tex.vert and shaders/tex.frag for information on how the shaders should be set up. You may choose to not include a uniform buffer if you specify a uniform buffer size of 0.