just realized this is not how the documentation uses properties but i'm
wondering if using them as a constructor type thing is a problem in nim. So far
it seems fine but its not in the manual.
so here's my example...
var cmd_pool: VkCommandPool
type
CommandBufferPool* = ref object
cmd_pool_info : VkCommandPoolCreateInfo
que_type_flags*: seq[VkQueueFlags]
phys_device*: VKDevice
result*: VkResult
proc `=CommandBufferPool`*(self:CommandBufferPool) =
self.cmd_pool_info.sType = VkStructureType.commandPoolCreateInfo
self.cmd_pool_info.pNext = nil
###########
for i in 0 .. <self.que_type_flags.len:
if self.que_type_flags[i] == vkQueueGraphicsBit:
self.cmd_pool_info.queueFamilyIndex = vkQueueGraphicsBit ## <-
temporary short circuit
else: echo "commandbuffer type" & $vkQueueGraphicsBit
###########
self.cmd_pool_info.flags = 0
self.result = vkCreateCommandPool(self.phys_device,addr
self.cmd_pool_info,nil,addr cmd_pool)
and here's the call
let cmd =
CommandBufferPool(index:que.index,phys_device:device.physical_device)
if cmd.result == VkResult.success:
echo("vulkan command_buffer: " & $VkResult.success)
i think so far its pretty good way of doing constructor type behavior but i
did'nt see it in the manual so i'm wondering about it.
and if it ok would'nt it be better to do a python type __init___ constructor.
i'm actually not familiar with python but i think that is how it works.
maybe something like this...
proc `_CommandBufferPool_`*(self:CommandBufferPool) =
or this...
proc <CommandBufferPool>*(self:CommandBufferPool) =
And then the <> brackets would insert a = sign to make it a constructor?