slate
- 3 Devlogs
- 21 Total hours
slate engine is an open source, cross-platform, vulkan-focused fully featured 3d game engine built using c++ and vulkan/sdl3
slate engine is an open source, cross-platform, vulkan-focused fully featured 3d game engine built using c++ and vulkan/sdl3
all of the obj loading is done using tinyobjloader, which is a popular header file that im using to get the raw vertex coords of any .obj file
however, all tinyobj does is pass the raw vertex data to my code (technically it can do some basic triangulation, but thats not its main purpose so its not perfect)
this means that any model with n-gons (complex polygons) will not work and will look super weird
technically you can tell blender to explicitly triangulate a file when you export it, but i think that it should be able to take any obj that you can throw at it without needing external setup
so i also added a popular header file called earcut, which at a basic level, just cuts any complex polygons into 3-vertex triangles (which my index pass and renderer accepts).
this now means that it can load any custom obj file
i want to add auto color loading (from the obj data) or texture loading next, or maybe work on the ui or add ambient occlusion 
Camera class (look at me keepin things organized
)vulkan_renderer class has model, projection, view, and transform matrices:
SDL_SetWindowRelativeMouseMode, and can be unlocked with the escape keytinyobj
so now, its a spinning cube in a resizeable window that you can move around with wasd 
so, why did it take me 6 hours to get a window to open?
it kinda just comes down to the fact that vulkan is vulkan
on other apis such as opengl, the graphics driver just does stuff for you. you can say sumn like “open a window and make it pink” and it just does the memory, thread syncing, and goofy platform stuff for you
vulkan on the other hand, wants none of that. if you dont specifically ask for something, it wont happen. this does make it significantly harder (and much easier to create a gpu-ending vram overflow) to code with, but it does have the benifit of being much more powerful, having no overhead, and 100% control. its not gonna do anything that you dont tell it to
os bridge (sdl3): instead of writing a whole abstraction for wayland/x11, win32 and metal, you just have to tell sdl3 that you’re making a vulkan window, and it does some magic stuff
vulkan instance (VkInstance): this is how you get into the vulkan sdk. you kinda just have to tell vulkan everything it needs to know and ask sdl what extensions you need
window surface (VkSurfaceKHR): vulkan is kinda dumb and doesnt know what a window actually is, so this is where sdl tells vulkan where it can actually write pixels
pick a physical device: scan the current hardware, loop through every available device, and then just pick the best one (eventually ill probably add a way to select a custom one)
logical device (VkDevice): the physical device is the actual doohickey in your computer that runs stuff, the logical device is the software’s interface to it.
swapchain (VkSwapchainKHR): vulkan can’t actually write images directly to the screen (and that would look bad anyway), so you make a swapchain. my code does double buffering (basically vsync), which means that the screen displays image a, while the gpu is rendering image b.
render pass and framebuffers: basically just telling vulkan what to do (in this case, clear the screen, then draw the color). the framebuffer just binds the swapchain image views to the render pass
synchronization and command subsystem: believe it or not, your gpu’s clock speed is usually around (or more than) half of your cpu’s clock speed, so you have to make sure that your code waits for the gpu is ready before running the next c++ line. if you don’t, your gpu ram and cache will overflow.
overall, this took a total of 764 lines of code just to get a grey window 
the nice part is that the progress that i’ll make is exponential, since the very beginning stuff takes the longest
i also made a logo (the current project page banner)