51 void load(
VKWindow *win,
const std::string &model,
const std::string &text,
const std::string &path,
float scale);
93 VkDeviceMemory
memory = VK_NULL_HANDLE;
94 VkImageView
view = VK_NULL_HANDLE;
95 uint32_t
w = 0,
h = 0;
Vulkan mesh loader and GPU resource manager.
Convenience wrapper that owns an MXModel plus its Vulkan textures, UBOs, and descriptor sets.
std::vector< VkDescriptorSet > modelDescriptorSets
Descriptor sets (frames x textures).
std::vector< VkBuffer > modelUniformBuffers
Per-frame uniform buffers.
std::string fragShaderPath_
Fragment shader SPIR-V path.
bool isInstance_
True if geometry/textures are shared from another model.
void createModelPipeline(VKWindow *win)
Create a per-model graphics pipeline from stored shader paths.
void loadModelTexturesFromMTL(VKWindow *win, const std::string &path)
Load textures using map_Kd paths from parsed MTL materials.
void createModelDescriptorSets(VKWindow *win)
Allocate and write descriptor sets binding UBOs and textures.
std::vector< TexEntry > modelTextures
Per-sub-mesh texture entries.
VKAbstractModel(VKAbstractModel &&)=delete
void loadModelTextures(VKWindow *win, const std::string &tex, const std::string &path)
Load texture images listed in a .tex file and upload to GPU.
VKAbstractModel & operator=(const VKAbstractModel &)=delete
std::vector< void * > modelUniformBuffersMapped
Persistently mapped UBO pointers.
void createModelDescriptorPool(VKWindow *win)
Create the Vulkan descriptor pool sized for this model's textures.
glm::vec3 modelCenterOffset
Translation to centre the bounding box at origin.
void resize(VKWindow *win)
Recreate UBOs and descriptor sets after a swapchain resize.
void cleanup(VKWindow *win)
Destroy all Vulkan resources owned by this model.
void load(VKWindow *win, const std::string &model, const std::string &text, const std::string &path, float scale)
Load a model, its textures, and create all GPU resources.
VKAbstractModel & operator=(VKAbstractModel &&)=delete
VkPipeline modelPipelineWireframe
Per-model wireframe pipeline.
void loadInstance(VKWindow *win, VKAbstractModel &source)
Create a lightweight instance sharing geometry & textures from a source model.
std::string vertShaderPath_
Vertex shader SPIR-V path.
bool hasCustomShaders() const
Check whether this model has custom shaders set.
VkPipeline getModelPipelineWireframe() const
Get the per-model wireframe pipeline, or VK_NULL_HANDLE if not available.
void render(int cmd)
Record rendering commands (currently a placeholder).
VkDescriptorPool modelDescriptorPool
Descriptor pool for this model.
VKAbstractModel(const VKAbstractModel &)=delete
bool isInstance() const
Check whether this is a lightweight instance (shared geometry).
std::vector< VkDeviceMemory > modelUniformBufferMemory
Memory for per-frame UBOs.
float modelRenderScale
Scale factor normalising model extent.
VKAbstractModel()=default
Default constructor.
VkPipeline getModelPipeline() const
Get the per-model pipeline, or VK_NULL_HANDLE if using the window default.
void setShaders(VKWindow *win, const std::string &vert, const std::string &frag)
Set custom vertex and fragment shaders and create a per-model pipeline.
void cleanupInstanceResources(VKWindow *win)
Clean up only UBO and descriptor resources (used by instances).
void updateUBO(VKWindow *win, uint32_t imageIndex, const mx::UniformBufferObject &ubo)
Copy a UBO into the mapped buffer for a given frame.
VkPipeline modelPipeline
Per-model graphics pipeline (fill).
Primary Vulkan rendering window and device management class.
Vulkan image, memory, and view for one loaded texture.
VkDeviceMemory memory
Device memory backing the image.
VkImageView view
Image view for shader sampling.
VkImage image
Vulkan image handle.
uint32_t h
Texture dimensions in pixels.
Vulkan application window and supporting structs for libmx.
Vulkan 3-D model loader and GPU buffer manager.