Skip to content

Instantly share code, notes, and snippets.

@Darianopolis
Darianopolis / ThreadPool.hpp
Last active April 28, 2024 01:57
Minimalistic C++ thread pool implementation
#include <vector>
#include <queue>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <future>
#include <functional>
class ThreadPool
{
@Darianopolis
Darianopolis / vktinyhellotriangle.cpp
Last active December 11, 2023 07:13
vktinyhellotriangle
int main(){glfwInit();
glfwWindowHint(GLFW_CLIENT_API,GLFW_NO_API);
void*window=glfwCreateWindow(800,600,"Hello Triangle",nullptr,nullptr),*glfwExtensions,*extensionCount=new uint32_t,*queueFamily=new uint32_t,*imageIndex=new uint32_t,*count=new uint32_t,*queueFamilies,*formats,*images,*instance,*surface,*physicalDevice,*device,*queue,*swapchain,*vertexShader,*fragmentShader,*renderPass,*pipelineLayout,*pipeline,*fence,*imageView,*framebuffer,*cmdPool,*cmd;
glfwExtensions=glfwGetRequiredInstanceExtensions((uint32_t*)extensionCount);
vkCreateInstance([](auto&&v){return&v;}(VkInstanceCreateInfo{.sType=VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,.pApplicationInfo=[](auto&&v){return&v;}(VkApplicationInfo{.sType=VK_STRUCTURE_TYPE_APPLICATION_INFO,.apiVersion=VK_API_VERSION_1_0,}),.enabledExtensionCount=*(uint32_t*)extensionCount,.ppEnabledExtensionNames=(const char**)glfwExtensions,}),nullptr,(VkInstance*)&instance);
glfwCreateWindowSurface((VkInstance)instance,(GLFWwindow*)window,nullptr,(VkSurfaceKHR*)&surface);
@Darianopolis
Darianopolis / links.txt
Last active June 29, 2023 19:39
Useful Links
@Darianopolis
Darianopolis / glhellotriangle.cpp
Last active August 10, 2023 09:24
Hello Triangle in OpenGL using GLFW and GLAD 2
#include <GLFW/glfw3.h>
#include <glad/gl.h>
int main()
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
auto window = glfwCreateWindow(800, 600, "Test", nullptr, nullptr);
@Darianopolis
Darianopolis / imguivulkanminimal.cpp
Last active May 9, 2023 15:54
ImGui minimal vulkan + glfw integration
struct ImGuiBackend
{
ImGuiContext* imguiCtx = {};
ImGuiContext* lastImguiCtx = {};
Context* ctx = {};
VkRenderPass renderPass = {};
std::vector<VkFramebuffer> framebuffers;
VkDescriptorPool descriptorPool = {};
VkSwapchainKHR lastSwapchain = {};
@Darianopolis
Darianopolis / vkhellotriangle.cpp
Last active March 19, 2024 16:58
vkhellotriangle
#include <vulkan/vulkan.h>
#include <GLFW/glfw3.h>
#include <glslang/Public/ShaderLang.h>
#include <glslang/Public/ResourceLimits.h>
#include <glslang/SPIRV/GlslangToSpv.h>
#include <array>
#include <iostream>
#include <vector>
template<class T> T* Temp(T&& v) { return &v; }
template<typename Container, typename Fn, typename ... Args>