Hello i'm having trouble knowing what to do in this case. It seems the int literal in the vulkan binding code does not work with an if statement since it is an int literal.
so the offending code.
proc create_device(self:Render) =
for index in 0 .. 0:
for i in 0 .. queue_prop[index].queueCount:
if queue_prop[index].queueFlags and vkQueueGraphicsBit == 1: # vkQueueGraphicsBit
echo "index found on: ", queue_index
break
queue_index.inc
err_check(vkCreateDevice(gpu_list[0],addr device_create_info, nil, addr device))
the line here... wont evaluate to a bool
if queue_prop[index].queueFlags and vkQueueGraphicsBit == 1: # vkQueueGraphicsBit
queueFlags is of queue_prop, and is the type "VkQueueFlags". as is the int literal "vkQueueGraphicsBit", which is 0x00000001 int literal in the binding.
So i'm thinking that i need to do operator overloading but, i must admit i don't know how in this case. Any ideas appreciated. and i will keep searching the documentation.
edit:
trying this but it always resolves true and i don't believe it should.
if (queue_prop[index].queueFlags and vkQueueGraphicsBit).bool == 1.bool:
Use () here to override the precedence rules.
if (queue_prop[index].queueFlags and vkQueueGraphicsBit) == 1:
Kerp, you are working on the Vulkan bindings? Great!
For C flags you should strongly consider using Nim's sets! I did that for the high level GTK bindings recently. Have code like
type
RegionFlag* {.size: sizeof(cint), pure.} = enum
even = 1
odd = 2
first = 3
last = 4
only = 5
sorted = 6
RegionFlags* {.size: sizeof(cint).} = set[RegionFlag]
So you can pass procs sets as parameter. The empty set {}, or something like {RegionFlags.sorted, RegionFlags.even}. It is not a very compact notation for pure Enums unfortunately. I hope this will work fine for GTK, have not yet tested. Of course that needs some mangling, flagNone=0 is generally removed, first=8 becomes first=3.
Another solution is using distinc ints. Or enums, but than you have to define some operations.
hi stefan , i'm using this binding.
if there are ways to improve it i will ask, but for now it seems to be ok.
i'm using this binding.
Interesting, please let us know about your results.
I would like to play with Vulkan too.
I think Mr Preussner has invested much time and effort in that bindings -- but I have not seen him since a long time...
I recently saw the nice and very long C tutorial for Vulkan. But about 1000 lines of code to draw a simple rectangle is really a lot, and I think it will need a lot of time to learn Vulkan.