Re: Trouble with tables
stefan your right that was it, thank you. I'm pretty sure i got it fixed with this code. I realized i needed a continue in the if statements too. proc sort_queue_properties(index:int): TableRef[uint32,string] = result = newTable[uint32,string](queue_properties[index].queueCount.int) for i in 0 ..
Re: Trouble with tables
still having problems, it seems that the table loses its info on length and value when i return it? for instance proc sort_queue_properties(index:int): TableRef[uint32,string] = var queue_table = newTable[uint32,string](queue_properties[index].queueCount.int) for i in 0 ..
Re: Trouble with tables
Interesting enough var queue_table = Table[uint32,string]() actually compiles on my machine. i'm using mingw64-6.3 from this website and x64 nim_0.17.0 too it maybe why i am confused. i haven't used tables before, i don't know what the correct syntax is.
Trouble with tables
Hello again having trouble with any of the tables, i'm not sure how they work it seems, and the manual is kinda skimpy too. so here is my code proc sort_queue_properties(index:int): Table[uint32,string] = var queue_table = Table[uint32,string]() for i in 0 ..
Re: Gource visualization of the Nim repo history
Thats kinda weird looks like a flower in the end!
Re: GetWindowEx() in winlean?
hey thanks dom i will see what i can do.
GetWindowEx() in winlean?
just wondering where it is? I could not find it in "winlean" import. But i need it to create a window in vulkan cause i don't want to use glfw. or if its possible do i just make a binding for it?
Re: Nim on Android
awesome!
casting address of pointer functions to a type
Hi again just need to know what i'm doing wrong on this subject But first here is my code var vkCreateDebugReportCallbackEXT = cast[PFN_vkCreateDebugReportCallbackEXT](vkGetInstanceProcAddr(inst,"vkCreateDebugReportCallbackExt")) i get a message from the compiler about this when i try it, that it cannot convert to a pointer type. i believe its because its pointer function in c and maybe nim does not like casting those, i dunno?
vcc and nim vs mingw with vulkan
hello just wondering what the plans are or potential roadblocks to getting nim to be used by vcc on windows. I don't see any docs on this but there is obviously the mingw-64 download on the site. The reason i'm asking is after getting to to "vkCreateCmdPool" in the vulkan api seemingly cannot go further because it seg-faults in nim. I think it is a problem with the compiler(mingw) not working with the vcc build lib in the sdk. I can't prove that yet so no accusations here. But there are posts on stackoverflow about this. Anybody got any ideas to make it work better? if not i will wait till nim switches to vcc to work on vulkan. But i do have some c++ code working with vulkan right now, it seems there are slight incompatabilities with mingw and vcc so i have to pick one.
Re: Using cstringArray and allocCstringArray
Thanks mashagingan that did the trick
Re: Using cstringArray and allocCstringArray
hmm, still having some trouble, it seems nim won't let you politely cast cstring to string. I tried unsafe cast and it compiles but i get the "out of memory" err. But i have to use cstringArray for the vulkan lib in the end. I will come back later and do some digging in the docs. and maybe somebody will suggest something.
Re: Using cstringArray and allocCstringArray
And while i'm at it, anyone know how to either use the __LINE__ macro from the compiler in nim? Or even the '#' stringify preprocessor symbol? I have a template that checks the proc result calls in vulkan and puts out the error string. Nim makes it easy to do this, but i dunno what the corresponding line is where the error or proc call is.
Re: Using cstringArray and allocCstringArray
Hi stefan it seems your suggestion jogged my memory banks a bit. Here is what i came up with. It seems to work so far. var s : seq[string] = newSeq[string](extension_count) for i in 0 .. s.len: var f = extension_prop[i].extensionName.cstring s[i] = newString(256) s[i] = cast[string](f) extension = alloccstringArray(s) and thank you for your help
Using cstringArray and allocCstringArray
Hello, having trouble using allocCstringArray to to allocate enough space for my extensions in Vulkan. The problem is that the extension member is an array of 256 char so i cannot use it in allocCstringArray. So here is the code to my problem. VkExtensionProperties* = object extensionName*: array[vkMaxExtensionNameSize, char] specVersion*: uint32 i can get the "extensionName" member to a cstring but allocCstringArray wants a openarray of string. so this is far as i got tonight. for i in 0 .. extension_prop.len: var s = (extension_prop[i].extensionName.cstring) extension = allocCStringArray(??) #what to do here? and i have to use cstringArray for the "extension" type. I'm sure there is someway to do this.
Re: int literals and if statement
hi stefan , i'm using this binding. [vulkan binding https://github.com/nimious/vulkan](https://forum.nim-lang.org/postActivity.xml#vulkan-binding-https-github-com-nimious-vulkan) if there are ways to improve it i will ask, but for now it seems to be ok.
Re: int literals and if statement
yes Araq thank you, it has worked i believe after investigating it. it seems my hardware has a "vkQueueGraphicsBit" on every queue since its nvidia.
int literals and if statement
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 0x0001 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:
Re: Anyone tried the "nim secret"?
Yes i i have used it it is useful!
Re: Installation on 64-bit Windows
It seems too that tdm-gcc is the most convienent way in windows to get a compiler but it does not seem to like vulkan libs (trouble linking). And you have to deal with winpthreads licence, but you get a working compiler easier it still works for opengl for instance. but i switched too linux mint to play with vulkan and nim.
Anything wrong with this syntax?
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:CommandBufferPool) = And then the <> brackets would insert a = sign to make it a constructor?
Re: pointer arithmetic example?
this what i came up with for the + operator proc `+`(a:pointer,p:pointer): pointer = result = cast[pointer](cast[int](a) + 1 * sizeof(p)) I believe a person has to times the sizeof p by 1. But i could make it use generics too i guess but i dunno. And thank you filwit for your post it was perfect. i will look into create and resize the unchecked pragma.
pointer arithmetic example?
I am still relatively new to doing this even in c, because i was used to using vector in c++. But since i am learning nim i don't know the way to correctly put a pointer into a pre allocated pointer using cast in nim. So here is what i'm working on. import ../obj_parser, streams type BinWriter* = ref object of RootObj obj: ref obj_data proc readObjFile*(self:BinWriter,name:string) = self.obj = getObjFile(name) proc createBinary*(self:BinWriter,filename:string) = var s = newFileStream(filename,fmwrite); if s != nil: var total : int = 0 total += (self.obj.vert.len * sizeof(float32)) total += (self.obj.face.len * sizeof(uint32)) total += (self.obj.nrml.len * sizeof(float32)) total += (self.obj.tex.len * sizeof(float32)) var all : pointer = nil var vert = alloc(self.obj.vert.len * sizeof(float32)) for i in 0 ..
Re: Version 0.15 released!
Very awesome! I will enjoy my continued learning of nimrod
lulzz..
[Britney spears created this!!](http://forum.nim-lang.org///nim-lang.org/docs/idetools.html) i did'nt know. too funny..
Re: Nim Documentation - a GitBook version
Being a someone who is kinda new to the terminology of computer science i find that in nim the documentation may be perfect for seasoned people who have a clue, but i did not at first. Till i started searching individual topics like, hygenic macros and such. So my suggestion to add to this is that while maybe, documentation that approaches the novice or noob have an appendix of the explanations of the terminology that is used in the documentation on this website. I wish i would have had it, and maybe i still need it? i dunno, i like all the ideas here and would like to help but i am not self confident enough to volunteer yet. i like jlp765's idea of a periodic "lets figure this out together moment". maybe based on problems people from other languages who do not know nim so well like me, need to know. For instance maybe pointer arithmetic... its different in c than in nim to do it. i think without someone like Araq showing how to do it would be a challenge to say the least, for me at least i know! But in the same though maybe a category like "coming from c to nim" or "from python to nim" would be good. i think some stuff is like that on github already.
how to use Natural type?
I checked the documentation, i understand i think, that a natural is a range of a type specifically int in the example. But other than that i have no idea how to use it. I'm trying to use readbytes proc in system module but having a little difficulty understanding what i need to do to use the proc. But my case use is i'm trying too use my .obj parser to write the data from text file to a binary file then read it back from binary file, then later i'll make a text based scene format file. any help appreciated.
Opengl vertices
First let me say if this is not a bug my apologies. But i think in my noobish experience it is. I think i traced my problem to it in nim. The strange behavior i get with my opengl vertices and i'm fairly certain after trying the same sorta thing in c++ and nim is that a vertice of 0,0,0 for x,y,z coords appear in the shader data when sending the vertices to the shader. i'm certain its the first vertices of x,y,z coordinate to sent to the shader so maybe in nim my vector3 object is being initialized with 0,0,0? Here is my Vector3 object. type Vec3* = object x*,y*,z* : GLfloat The more i think of this the more it would to be make sense that when nim does a check for the variables or object maybe the first thing it does is make it static in c?? i don't know for sure but thats the only thing i can think of that would make nim do this. And i base this off some of the posts i've read from araq. but if araq or someone thinks this is a bug i will post it on github.
`-` operator overloading and negative numbers of distinct type
Ok here is my code i get a stack overflow on the overloaded - operator with a distinct type. import math type F_TYPE* = distinct float32 # change to suit your needs type BASE_TYPE = distinct float type Mat4_t* = array[16,F_TYPE] type Mat3_t* = array[16,F_TYPE] type Vec4_t* = ref object of RootObj x*,y*,z*,w* : F_TYPE type Vec3_t* = ref object of RootObj x*,y*,z* : F_TYPE proc `/`*(a,b:F_TYPE): F_TYPE = result = a / b proc `==`(a,b:F_TYPE): bool = if a == b: return true else: return false proc `-`*(a,:F_TYPE): F_TYPE = return -a proc `-`*(a,b:F_TYPE): F_TYPE = result = (a - b) And here is where the compiler stops when running the program. proc mat4_frustum(left,right,bottom,top,near,far:F_TYPE): Mat4_t = var dest : Mat4_t var rl = (right - -left).F_TYPE #code breaks here tb = (top - -bottom).F_TYPE #and here fn = (far - near).F_TYPE dest[0] = (near.float * 2.0.float).F_TYPE / rl.F_TYPE dest[5] = (near.float * 2.0.float).F_TYPE / tb.F_TYPE dest[8] = (right + left).F_TYPE / rl.F_TYPE dest[9] = (top + bottom).F_TYPE / tb.F_TYPE dest[10] = - ((far + near).F_TYPE / fn).F_TYPE dest[11] = - 1.0.F_TYPE dest[14] = - ((far.float * near.float * 2).F_TYPE / fn.F_TYPE).F_TYPE dest[15] = 1.0.F_TYPE return dest Specifically it breaks on the negative distinct type i think? Is this normal? I doubt it could be, because that would be not useful. So any ideas about how to get it to run correctly? or whatever else is needed...