Compare commits
3 commits
b29fdcd83f
...
2c6c2b2592
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c6c2b2592 | |||
| 5ce5da188a | |||
| 4da333d7f6 |
7 changed files with 1206 additions and 1176 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
#include "arena_allocator.h"
|
#include "arena_allocator.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
@ -12,7 +11,7 @@ Arena arena_init(size_t capacity) {
|
||||||
|
|
||||||
void arena_deinit(Arena *arena) {
|
void arena_deinit(Arena *arena) {
|
||||||
free(arena->data);
|
free(arena->data);
|
||||||
*arena = (Arena){.capacity = NAN, .size = 0, .data = NULL};
|
*arena = (Arena){.capacity = 0, .size = 0, .data = NULL};
|
||||||
}
|
}
|
||||||
|
|
||||||
void *arena_alloc(Arena *arena, size_t size) {
|
void *arena_alloc(Arena *arena, size_t size) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
size_t size;
|
size_t size;
|
||||||
void *data;
|
char *data;
|
||||||
} Arena;
|
} Arena;
|
||||||
|
|
||||||
Arena arena_init(size_t capacity);
|
Arena arena_init(size_t capacity);
|
||||||
|
|
|
||||||
1183
src/main.c
1183
src/main.c
File diff suppressed because it is too large
Load diff
1128
src/vulkan_wrapper.c
1128
src/vulkan_wrapper.c
File diff suppressed because it is too large
Load diff
|
|
@ -1 +1,43 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
|
#define GLFW_INCLUDE_VULKAN
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#define MAX_FRAMES_IN_FLIGHT 2
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GLFWwindow *window;
|
||||||
|
VkInstance instance;
|
||||||
|
VkDebugUtilsMessengerEXT debugMessenger;
|
||||||
|
VkSurfaceKHR surface;
|
||||||
|
VkPhysicalDevice physicalDevice;
|
||||||
|
VkDevice device;
|
||||||
|
VkQueue graphicsQueue;
|
||||||
|
VkQueue presentQueue;
|
||||||
|
VkSwapchainKHR swapChain;
|
||||||
|
VkImage *swapChainImages;
|
||||||
|
uint32_t swapChainImageCount;
|
||||||
|
VkFormat swapChainImageFormat;
|
||||||
|
VkExtent2D swapChainExtent;
|
||||||
|
VkImageView *swapChainImageViews;
|
||||||
|
uint32_t swapChainImageViewCount;
|
||||||
|
VkRenderPass renderPass;
|
||||||
|
VkPipelineLayout pipelineLayout;
|
||||||
|
VkPipeline graphicsPipeline;
|
||||||
|
VkFramebuffer *swapChainFramebuffers;
|
||||||
|
uint32_t swapChainFramebufferCount;
|
||||||
|
VkCommandPool commandPool;
|
||||||
|
VkCommandBuffer commandBuffers[MAX_FRAMES_IN_FLIGHT];
|
||||||
|
VkSemaphore imageAvailableSemaphores[MAX_FRAMES_IN_FLIGHT];
|
||||||
|
VkSemaphore renderFinishedSemaphore[MAX_FRAMES_IN_FLIGHT];
|
||||||
|
VkFence inFlightFences[MAX_FRAMES_IN_FLIGHT];
|
||||||
|
uint32_t currentFrame; // initialised to 0
|
||||||
|
} VulkanApp;
|
||||||
|
|
||||||
|
void vulkan_init(VulkanApp *app);
|
||||||
|
void mainLoop(VulkanApp *app);
|
||||||
|
void vulkan_deinit(VulkanApp *app);
|
||||||
|
|
||||||
|
void framebufferResizeCallback(GLFWwindow *window, int width, int height);
|
||||||
|
|
|
||||||
18
src/window.c
18
src/window.c
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
|
#define GLFW_INCLUDE_VULKAN
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
void window_init(VulkanApp *app) {
|
||||||
|
glfwInit();
|
||||||
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
|
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
||||||
|
app->window = glfwCreateWindow(800, 600, "Vulkan", NULL, NULL);
|
||||||
|
|
||||||
|
glfwSetFramebufferSizeCallback(app->window, framebufferResizeCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
void window_deinit(VulkanApp *app) {
|
||||||
|
glfwDestroyWindow(app->window);
|
||||||
|
glfwTerminate();
|
||||||
|
}
|
||||||
|
|
@ -1 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "vulkan_wrapper.h"
|
||||||
|
|
||||||
|
void window_init(VulkanApp *app);
|
||||||
|
|
||||||
|
void window_deinit(VulkanApp *app);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue