Compare commits
60 Commits
v1.0.0
..
4a9ec8107d
| Author | SHA1 | Date | |
|---|---|---|---|
|
4a9ec8107d
|
|||
|
d88f5c8188
|
|||
|
311135e8a9
|
|||
|
1146a99c53
|
|||
|
7998ef448e
|
|||
|
d0521c19d9
|
|||
|
4e3c2f9983
|
|||
|
394d2dc358
|
|||
|
e64ba6870b
|
|||
|
3a9592bbd3
|
|||
|
422560a028
|
|||
|
87620b6e0c
|
|||
|
98b845f876
|
|||
|
f633db3070
|
|||
|
e69f907a96
|
|||
| afc4f50a20 | |||
| 39f52a959b | |||
| 22ae3e0351 | |||
| ef6941c47f | |||
| 99647be837 | |||
| f229c15bad | |||
| e73b4f3a14 | |||
| 9d70f19cac | |||
| 61e2da6bc8 | |||
| 228d12085a | |||
| 5c0c63a03b | |||
| 7b26a00ae3 | |||
| 027d066cbf | |||
| c583cbb829 | |||
| a54821aea0 | |||
| f7b4850b56 | |||
| c08c3d6bd1 | |||
| 8654cf72d8 | |||
| 64565bbff4 | |||
| 6333bc667c | |||
| 1a734cd185 | |||
| 156345ca11 | |||
| c55619d14d | |||
| 6feb886b73 | |||
| 19be22ebda | |||
| d273a23618 | |||
| 214e2e1862 | |||
| 6c0ed3f244 | |||
| 1205002094 | |||
| 5a257b7ae3 | |||
| 396ff9cedd | |||
| df70fc67b2 | |||
| 7f106fdd7f | |||
| fb371ac5bf | |||
| 4c3d180799 | |||
| 22012d6d24 | |||
| f109407049 | |||
| 0992e92d38 | |||
| 23a123437b | |||
| e299d56058 | |||
| 63989790d2 | |||
| 3ab869923f | |||
| 4cd1e43950 | |||
| 5920c7b965 | |||
| 1d40d2cd2a |
@@ -2,3 +2,5 @@
|
|||||||
*.swp
|
*.swp
|
||||||
*.swx
|
*.swx
|
||||||
sandbox/test
|
sandbox/test
|
||||||
|
sandbox/build/
|
||||||
|
sandbox/.xmake/
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
KVF (kbz_8 vulkan framework) is a lightweight single-header Vulkan framework written in C99 to simplify the creation of Vulkan applications.
|
KVF (kbz_8 vulkan framework) is a lightweight single-header Vulkan framework written in C99 to simplify the creation of Vulkan applications.
|
||||||
It is designed to be a drop in framework inside any existing Vulkan renderer as it does not use any custom types of structs (except for the graphics pipeline builder).
|
It is designed to be a drop in framework inside any existing Vulkan renderer as it does not use any custom types of structs (except for the graphics pipeline builder).
|
||||||
|
|
||||||
Here's a simple C example of a hello world triangle using KVF and SDL2:
|
Here's a simple C example of a hello world triangle using KVF and SDL2 :
|
||||||
```C
|
```C
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <SDL2/SDL_timer.h>
|
#include <SDL2/SDL_timer.h>
|
||||||
@@ -45,7 +45,7 @@ int main(void)
|
|||||||
// Swapchain creation
|
// Swapchain creation
|
||||||
VkExtent2D extent;
|
VkExtent2D extent;
|
||||||
SDL_Vulkan_GetDrawableSize(win, (int*)&extent.width, (int*)&extent.height);
|
SDL_Vulkan_GetDrawableSize(win, (int*)&extent.width, (int*)&extent.height);
|
||||||
VkSwapchainKHR swapchain = kvfCreateSwapchainKHR(device, ph_device, surface, extent, true);
|
VkSwapchainKHR swapchain = kvfCreateSwapchainKHR(device, ph_device, surface, extent, VK_NULL_HANDLE, true, true);
|
||||||
|
|
||||||
// Swapchain images acquisition
|
// Swapchain images acquisition
|
||||||
uint32_t swapchain_images_count = kvfGetSwapchainImagesCount(swapchain);
|
uint32_t swapchain_images_count = kvfGetSwapchainImagesCount(swapchain);
|
||||||
@@ -55,8 +55,8 @@ int main(void)
|
|||||||
for(uint32_t i = 0; i < swapchain_images_count; i++)
|
for(uint32_t i = 0; i < swapchain_images_count; i++)
|
||||||
{
|
{
|
||||||
VkCommandBuffer cmd = kvfCreateCommandBuffer(device);
|
VkCommandBuffer cmd = kvfCreateCommandBuffer(device);
|
||||||
kvfTransitionImageLayout(device, swapchain_images[i], cmd, kvfGetSwapchainImagesFormat(swapchain), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, true);
|
kvfTransitionImageLayout(device, swapchain_images[i], KVF_IMAGE_COLOR, cmd, kvfGetSwapchainImagesFormat(swapchain), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, true);
|
||||||
swapchain_images_views[i] = kvfCreateImageView(device, swapchain_images[i], kvfGetSwapchainImagesFormat(swapchain), VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT);
|
swapchain_images_views[i] = kvfCreateImageView(device, swapchain_images[i], kvfGetSwapchainImagesFormat(swapchain), VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync objects creation
|
// Sync objects creation
|
||||||
@@ -85,10 +85,11 @@ int main(void)
|
|||||||
kvfGPipelineBuilderSetCullMode(builder, VK_CULL_MODE_NONE, VK_FRONT_FACE_CLOCKWISE);
|
kvfGPipelineBuilderSetCullMode(builder, VK_CULL_MODE_NONE, VK_FRONT_FACE_CLOCKWISE);
|
||||||
kvfGPipelineBuilderAddShaderStage(builder, VK_SHADER_STAGE_VERTEX_BIT, vertex_shader_module, "main");
|
kvfGPipelineBuilderAddShaderStage(builder, VK_SHADER_STAGE_VERTEX_BIT, vertex_shader_module, "main");
|
||||||
kvfGPipelineBuilderAddShaderStage(builder, VK_SHADER_STAGE_FRAGMENT_BIT, fragment_shader_module, "main");
|
kvfGPipelineBuilderAddShaderStage(builder, VK_SHADER_STAGE_FRAGMENT_BIT, fragment_shader_module, "main");
|
||||||
|
kvfGPipelineBuilderSetMultisampling(builder , VK_SAMPLE_COUNT_1_BIT);
|
||||||
kvfGPipelineBuilderDisableDepthTest(builder);
|
kvfGPipelineBuilderDisableDepthTest(builder);
|
||||||
kvfGPipelineBuilderDisableBlending(builder);
|
kvfGPipelineBuilderDisableBlending(builder);
|
||||||
|
|
||||||
VkPipeline pipeline = kvfCreateGraphicsPipeline(device, pipeline_layout, builder, renderpass);
|
VkPipeline pipeline = kvfCreateGraphicsPipeline(device, VK_NULL_HANDLE, pipeline_layout, builder, renderpass);
|
||||||
|
|
||||||
kvfDestroyGPipelineBuilder(builder);
|
kvfDestroyGPipelineBuilder(builder);
|
||||||
kvfDestroyShaderModule(device, vertex_shader_module);
|
kvfDestroyShaderModule(device, vertex_shader_module);
|
||||||
@@ -152,3 +153,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="https://github.com/Kbz-8/KVF/blob/46aa29be4facef398aeab0b7e82bff84aab683ce/sandbox/screenshot.png" alt="drawing" width="500"/>
|
||||||
|
</p>
|
||||||
|
|||||||
+5
-4
@@ -80,7 +80,7 @@ int main(void)
|
|||||||
// Swapchain creation
|
// Swapchain creation
|
||||||
VkExtent2D extent;
|
VkExtent2D extent;
|
||||||
SDL_Vulkan_GetDrawableSize(win, (int*)&extent.width, (int*)&extent.height);
|
SDL_Vulkan_GetDrawableSize(win, (int*)&extent.width, (int*)&extent.height);
|
||||||
VkSwapchainKHR swapchain = kvfCreateSwapchainKHR(device, ph_device, surface, extent, true);
|
VkSwapchainKHR swapchain = kvfCreateSwapchainKHR(device, ph_device, surface, extent, VK_NULL_HANDLE, true, true);
|
||||||
|
|
||||||
// Swapchain images acquisition
|
// Swapchain images acquisition
|
||||||
uint32_t swapchain_images_count = kvfGetSwapchainImagesCount(swapchain);
|
uint32_t swapchain_images_count = kvfGetSwapchainImagesCount(swapchain);
|
||||||
@@ -90,8 +90,8 @@ int main(void)
|
|||||||
for(uint32_t i = 0; i < swapchain_images_count; i++)
|
for(uint32_t i = 0; i < swapchain_images_count; i++)
|
||||||
{
|
{
|
||||||
VkCommandBuffer cmd = kvfCreateCommandBuffer(device);
|
VkCommandBuffer cmd = kvfCreateCommandBuffer(device);
|
||||||
kvfTransitionImageLayout(device, swapchain_images[i], cmd, kvfGetSwapchainImagesFormat(swapchain), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, true);
|
kvfTransitionImageLayout(device, swapchain_images[i], KVF_IMAGE_COLOR, cmd, kvfGetSwapchainImagesFormat(swapchain), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, true);
|
||||||
swapchain_images_views[i] = kvfCreateImageView(device, swapchain_images[i], kvfGetSwapchainImagesFormat(swapchain), VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT);
|
swapchain_images_views[i] = kvfCreateImageView(device, swapchain_images[i], kvfGetSwapchainImagesFormat(swapchain), VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync objects creation
|
// Sync objects creation
|
||||||
@@ -118,12 +118,13 @@ int main(void)
|
|||||||
kvfGPipelineBuilderSetInputTopology(builder, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
|
kvfGPipelineBuilderSetInputTopology(builder, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
|
||||||
kvfGPipelineBuilderSetPolygonMode(builder, VK_POLYGON_MODE_FILL, 1.0f);
|
kvfGPipelineBuilderSetPolygonMode(builder, VK_POLYGON_MODE_FILL, 1.0f);
|
||||||
kvfGPipelineBuilderSetCullMode(builder, VK_CULL_MODE_NONE, VK_FRONT_FACE_CLOCKWISE);
|
kvfGPipelineBuilderSetCullMode(builder, VK_CULL_MODE_NONE, VK_FRONT_FACE_CLOCKWISE);
|
||||||
|
kvfGPipelineBuilderSetMultisampling(builder, VK_SAMPLE_COUNT_1_BIT);
|
||||||
kvfGPipelineBuilderAddShaderStage(builder, VK_SHADER_STAGE_VERTEX_BIT, vertex_shader_module, "main");
|
kvfGPipelineBuilderAddShaderStage(builder, VK_SHADER_STAGE_VERTEX_BIT, vertex_shader_module, "main");
|
||||||
kvfGPipelineBuilderAddShaderStage(builder, VK_SHADER_STAGE_FRAGMENT_BIT, fragment_shader_module, "main");
|
kvfGPipelineBuilderAddShaderStage(builder, VK_SHADER_STAGE_FRAGMENT_BIT, fragment_shader_module, "main");
|
||||||
kvfGPipelineBuilderDisableDepthTest(builder);
|
kvfGPipelineBuilderDisableDepthTest(builder);
|
||||||
kvfGPipelineBuilderDisableBlending(builder);
|
kvfGPipelineBuilderDisableBlending(builder);
|
||||||
|
|
||||||
VkPipeline pipeline = kvfCreateGraphicsPipeline(device, pipeline_layout, builder, renderpass);
|
VkPipeline pipeline = kvfCreateGraphicsPipeline(device, VK_NULL_HANDLE, pipeline_layout, builder, renderpass);
|
||||||
|
|
||||||
kvfDestroyGPipelineBuilder(builder);
|
kvfDestroyGPipelineBuilder(builder);
|
||||||
kvfDestroyShaderModule(device, vertex_shader_module);
|
kvfDestroyShaderModule(device, vertex_shader_module);
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Reference in New Issue
Block a user