You are browsing as a guest. Sign up (or log in) to start making projects!

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

Open comments for this post

8h 18m 23s logged

custom obj file loading :obj:


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 :think:

0
0
16
Open comments for this post

6h 33m 41s logged

entered the 3rd dimension :wowzers:


wasd movement

made a whole separate Camera class (look at me keepin things organized :yay2: )

  • this means that now the vulkan_renderer class has model, projection, view, and transform matrices:
    • the model matrix tracks the transformations
    • the view matrix essentially tracks where the camera is
    • the projection matrix sets a perspective frustum in order to make things actually have perspective and not just be flat
  • the lerping is also based on deltaTime, which means smooth movement no matter ur fps
  • the mouse tracking is locked via SDL_SetWindowRelativeMouseMode, and can be unlocked with the escape key

vertices and index buffers

  • right now, the vertices are being set manually in my code… however, importing obj (and maybe gltf and stl) files is next on the feature list, i’m planning on using tinyobj
  • all the geometry is indexed, which basically means that instead of wasting a ton of memory repeating data for 36 raw vertices, you can just define the 8 corner vertices, then use an index buffer pass to tell the gpu how to connect those 8 vertices into 12 triangles :thumbup-nobg:

window resizing

  • this was easy, basically just had to tell it to make new image views and framebuffers based on the current aspect ratio (w/h) when the size of the window changes

so now, its a spinning cube in a resizeable window that you can move around with wasd :yip:

7
0
123
Open comments for this post

6h 7m 25s logged

the window opens (!!) :ultrafastswedenparrot:


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


so what do you have to do to open a beautiful grey window with vulkan?

  • 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 :yip:

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)

0
0
13

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…