This commit is contained in:
Jorijn van der Graaf 2025-06-14 01:51:35 +02:00
commit c8f1c90f9c
9 changed files with 0 additions and 0 deletions

View file

@ -1,36 +0,0 @@
# HelloWindow Example
## Description
This example showcases how to define a custom shader.
## Expected Result
A RGB triangle.
## Highlighted Code Snippet
```cpp
class CustomShader {
public:
Buffer<Vector<float, 4>> colors;
CustomShader(const std::vector<Vector<float, 4>>& colors) : colors(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, colors.size()) {
memcpy(this->colors.value, colors.data(), colors.size()*sizeof(Vector<float, 4>));
}
void WriteDescriptors(VkDescriptorSet set) {
VkWriteDescriptorSet write[1] = {
vks::initializers::writeDescriptorSet(set, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 0, &colors.descriptor),
};
vkUpdateDescriptorSets(VulkanDevice::device, 1, &write[0], 0, nullptr);
}
};
```
## How to Run
```bash
crafter-build -c example -r
```
## Relevant documentation