!waoZWxdJJQNrbqLfTI:matrix.org

Nim Game Development

3860 Members
The perfect place to discuss game development in Nim. Let's help each other out and test our games!15 Servers

Load older messages


SenderMessageTime
27 May 2023
@_discord_203695042760671234:t2bot.iokonsumer * I do similar stuff on the js host (even for strings, but also structs), so it's not a big deal, just a bit confused by how it all fit together. Makes perfect sense, now 22:11:32
@elegantbeef:matrix.orgElegantbeefIt's weird that emscripten does it the way it does22:13:59
@elegantbeef:matrix.orgElegantbeef You could always use a type WasmPtr[T] = distinct uint32 might result in proper semantics 22:14:38
@_discord_203695042760671234:t2bot.iokonsumer yeh, it gets really weird too, when you are making wasm in other ecosystems too (like assemblyscript) 22:14:46
@elegantbeef:matrix.orgElegantbeef Wait do they all pass in a ptr T? 22:15:00
@_discord_203695042760671234:t2bot.iokonsumer where would I put that? 22:15:02
@elegantbeef:matrix.orgElegantbeefInside the module22:15:15
@_discord_203695042760671234:t2bot.iokonsumer I think yes, but assemblyscript returns it 22:15:19
@elegantbeef:matrix.orgElegantbeefYou want wasm to treat it as a module22:15:25
@elegantbeef:matrix.orgElegantbeefprimitive*22:15:34
@elegantbeef:matrix.orgElegantbeefBrainfart and a half there22:15:40
@_discord_203695042760671234:t2bot.iokonsumer * I think yes, but assemblyscript returns the pointer (not mangle the function) 22:16:06
@_discord_203695042760671234:t2bot.iokonsumer After I get all the functions demo'd in nim on both sides of the wasm-barrier, I will start making other wasm-side languages do similar. For example, I made an assemblyscript-side adapter for strings, so they look the same in both hosts. Aseemblyscript has automatic struct stuff, but it returns the pointer (instead of adding it as the second parm) so I will probly have to do something else there, but that is a problem for another day. 22:19:16
@_discord_203695042760671234:t2bot.iokonsumer * After I get all the functions demo'd in nim on both sides of the wasm-barrier, I will start making other wasm-side languages do similar. For example, I made an assemblyscript-side adapter for strings, so they look the same in both hosts (js and nim.) Aseemblyscript has automatic struct stuff, but it returns the pointer (instead of adding it as the second parm) so I will probly have to do something else there, but that is a problem for another day. 22:19:43
@elegantbeef:matrix.orgElegantbeefThere might be a flag to disable this behaviour, do not remember22:19:46
@_discord_203695042760671234:t2bot.iokonsumer maybe if I setup (wasm-side) the function to return a pointer, it wouldd do it more how I expect. That could be a good solution (so it all works the same) 22:22:17
@_discord_203695042760671234:t2bot.iokonsumer * maybe if I setup (wasm-side) the function to return a pointer, it would do it more how I expect. That could be a good solution (so it all works the same) 22:22:25
@_discord_203695042760671234:t2bot.iokonsumer I don;t really mind this, though, like if all just put the return var on the end, I can make other labguages do that too 22:23:34
@_discord_203695042760671234:t2bot.iokonsumer * I don;t really mind this, though, like if all just put the return var on the end, I can make other languages do that too. they all will have little wrapper-headers to make it feel normal in whatever the wasm language is, so it's not a huge deal. 22:24:20
@_discord_203695042760671234:t2bot.iokonsumer in nim, I do similar, like
# Draw an image on another image
proc draw_image*(targetID: Image, sourceID:Image, x: int32, y: int32) {.importc, cdecl.}

proc draw_image*(targetID: Image, sourceID:Image, x: int, y: int) =
  draw_image(targetID, sourceID, int32 x, int32 y)

proc draw_image*(sourceID: Image, x: int, y: int) =
  draw_image(screen, sourceID, x, y)

proc draw*(sourceID: Image, x: int, y: int) =
  draw_image(screen, sourceID, x, y)

# so I can do this:
logo.draw(offset.x, offset.y)
22:25:40
@_discord_203695042760671234:t2bot.iokonsumer * in wasm-side nim, I do similar, like
# Draw an image on another image
proc draw_image*(targetID: Image, sourceID:Image, x: int32, y: int32) {.importc, cdecl.}

proc draw_image*(targetID: Image, sourceID:Image, x: int, y: int) =
  draw_image(targetID, sourceID, int32 x, int32 y)

proc draw_image*(sourceID: Image, x: int, y: int) =
  draw_image(screen, sourceID, x, y)

proc draw*(sourceID: Image, x: int, y: int) =
  draw_image(screen, sourceID, x, y)

# so I can do this:
logo.draw(offset.x, offset.y)
22:25:55
@_discord_203695042760671234:t2bot.iokonsumer The goal is that it's helpful for people learning a language, or if they are just new to programming, so they can work with whatever language they chose in a friendly way. 22:26:39
@_discord_203695042760671234:t2bot.iokonsumer * in wasm-side nim, I do similar, like
# Draw an image on another image
proc draw_image*(targetID: Image, sourceID:Image, x: int32, y: int32) {.importc, cdecl.}

proc draw_image*(targetID: Image, sourceID:Image, x: int, y: int) =
  draw_image(targetID, sourceID, int32 x, int32 y)

proc draw_image*(sourceID: Image, x: int, y: int) =
  draw_image(screen, sourceID, x, y)

proc draw*(sourceID: Image, x: int, y: int) =
  draw_image(screen, sourceID, x, y)

proc draw*(sourceID: Image, x: int, y: int) =
  draw_image(screen, sourceID, x, y)

# so I can do this:
logo.draw(offset.x, offset.y)
22:27:19
@_discord_203695042760671234:t2bot.iokonsumer * in wasm-side nim, I do similar, like
# Draw an image on another image
proc draw_image*(targetID: Image, sourceID:Image, x: int32, y: int32) {.importc, cdecl.}

proc draw_image*(targetID: Image, sourceID:Image, x: int, y: int) =
  draw_image(targetID, sourceID, int32 x, int32 y)

proc draw_image*(sourceID: Image, x: int, y: int) =
  draw_image(screen, sourceID, x, y)

proc draw*(sourceID: Image, x: int, y: int) =
  draw_image(screen, sourceID, x, y)

# so I can do this:
logo.draw(offset.x, offset.y)
22:27:28
@_discord_203695042760671234:t2bot.iokonsumer * The goal is that it's helpful for people learning a language, or if they are just new to programming, so they can work with whatever language they chose in a friendly way. I originally made stuff in C, JS, Rust & Assemblyscript, but I am learning nim, and rewriting everything in that, since I am already loving the language. It's been really nice, and I have added a lot more features than the original stuff. Nim makes it a lot more fun. 22:31:08
@_discord_203695042760671234:t2bot.iokonsumer Another note on struct-return: it appears it puts the ret-pointer in the 1st param: dimension(returnPtr, image) 22:51:32
@_discord_203695042760671234:t2bot.iokonsumer * Another note on struct-return: it appears it puts the ret-pointer in the 1st param: dimension(returnPtr, imageID) 22:51:41
@_discord_203695042760671234:t2bot.iokonsumer * Another note on struct-return: it appears it puts the ret-pointer in the 1st param: dimension(returnPtr, imageID) for this wasm-side:
proc dimensions*(sourceID: Image): Vector2 {.importc, cdecl.}
22:52:19
@_discord_203695042760671234:t2bot.iokonsumer * Another note on struct-return: it appears it puts the ret-pointer in the 1st param: dimensions(returnPtr, imageID) for this wasm-side:
proc dimensions*(sourceID: Image): Vector2 {.importc, cdecl.}
22:52:36
@_discord_203695042760671234:t2bot.iokonsumer * Another note on struct-return: it appears it puts the ret-pointer in the 1st param: dimensions(returnPtr, imageID) for this wasm-side:
proc dimensions*(imageID: Image): Vector2 {.importc, cdecl.}
22:52:47

There are no newer messages yet.


Back to Room ListRoom Version: 6