Skip to content

Instantly share code, notes, and snippets.

View SeppahBaws's full-sized avatar
💭
Vulkan and stuff...

Seppe Dekeyser SeppahBaws

💭
Vulkan and stuff...
View GitHub Profile
@SeppahBaws
SeppahBaws / imgui_impl_vulkan.cpp
Created June 19, 2022 23:58
DearImGui Vulkan backend adapted to work with VK_KHR_dynamic_rendering
// dear imgui: Renderer Backend for Vulkan
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
// Implemented features:
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [x] Renderer: Multi-viewport / platform windows. With issues (flickering when creating a new viewport).
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
PipelineBuilder builder{};
builder.SetShader(someShader);
builder.SetRasterizer(vk::PolygonMode::eFill, vk::CullingModeFlagBits::eBack); // Specify filled polygons, with backface-culling
// other functions
// Create a pipeline from the builder
VulkanPipeline somePipeline = builder.BuildGraphics();
// Now we can re-use the builder, change some properties and create a new pipeline
builder.SetShader(someOtherShader);
@SeppahBaws
SeppahBaws / main.cpp
Created May 30, 2022 20:58
Creating a scene in my Vulkan renderer
Scene* scene = new Scene();
Entity player = scene->CreateEntity("Player");
player.AddComponent<TransformComponent>(
{ 0.0f, 0.0f, 0.0f, }, // Position
{ 0.0f, 90.0f, 0.0f }, // Rotation
{ 1.0f, 1.0f, 1.0f } // Scale
);
player.AddComponent<ModelComponent>("resources/Models/Player.fbx");
@SeppahBaws
SeppahBaws / AssetReference.h
Last active May 30, 2022 20:59
AssetReference class in my Vulkan renderer
template<class T>
struct AssetReference
{
T* pAsset;
int32_t refCount;
};
@SeppahBaws
SeppahBaws / VulkanRenderer.cpp
Created May 30, 2022 20:57
Reloading a shader in my Vulkan renderer
void VulkanRenderer::ReloadShaders()
{
m_pDevice->WaitIdle();
m_Pipeline.Cleanup(m_pDevice->GetDevice());
m_pDevice->GetDevice().destroyRenderPass(m_RenderPass);
CreateRenderPass();
CreateGraphicsPipeline();
}
@SeppahBaws
SeppahBaws / main.cpp
Created December 15, 2019 02:58
Example for a Scene Manager for my OpenGL Sandbox. Example used for planning my Scene Manager.
class MeshComponent;
class MeshRenderComponent;
class Scene
{
public:
virtual void Init() = 0;
};
class Actor
@SeppahBaws
SeppahBaws / Utils.cs
Created January 13, 2019 13:28
This is a simple function that makes checking variables for null much easier. It can even log a simple message. (in this case to the Unity debug console)
public static class Utils
{
public static bool NullCheck(this object obj, string msg = "")
{
if (obj == null)
{
if (msg != "")
Debug.LogError(msg);
return true;
}
@SeppahBaws
SeppahBaws / EditorStateVisualizer.cs
Last active January 2, 2020 16:59
This is a simple script that creates a Unity Editor Window that shows the current state of the Editor. Useful for when you want to know if the Editor is still compiling your code.
// === EditorStateVisualizer By Seppe Dekeyser. ===
using UnityEngine;
using UnityEditor;
enum EditorState
{
Ready,
Compiling,
Paused,