36 lines
928 B
Markdown
36 lines
928 B
Markdown
# 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
|
|
|
|
|