Compare commits
No commits in common. "2c6c2b25922af5a0ed6d705b49451f49819012a5" and "b29fdcd83f1dd02a0092f5382d8df746967aa9ff" have entirely different histories.
2c6c2b2592
...
b29fdcd83f
7 changed files with 1176 additions and 1206 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#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>
|
||||||
|
|
||||||
|
|
@ -11,7 +12,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 = 0, .size = 0, .data = NULL};
|
*arena = (Arena){.capacity = NAN, .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;
|
||||||
char *data;
|
void *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,43 +1 @@
|
||||||
#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
|
|
@ -1,18 +0,0 @@
|
||||||
#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,7 +1 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "vulkan_wrapper.h"
|
|
||||||
|
|
||||||
void window_init(VulkanApp *app);
|
|
||||||
|
|
||||||
void window_deinit(VulkanApp *app);
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue