naylib icon indicating copy to clipboard operation
naylib copied to clipboard

Deal with cstring parameters

Open planetis-m opened this issue 3 years ago • 4 comments

planetis-m avatar Mar 06 '22 13:03 planetis-m

Left: initWindow, setWindowTitle, setClipboardText, getShaderLocation, getShaderLocationAttrib, takeScreenshot, traceLog, setGamepadMappings, loadImageAnim, exportImage, exportImageAsCode, genImageText, imageText, imageDrawText, exportFontAsCode, drawText, measureText, exportMesh, exportWave, exportWaveAsCode. Needs to be done automatically else don't do it at all.

planetis-m avatar Jan 30 '23 01:01 planetis-m

What is the idea for cstrings? I just found myself editing the drawTextEx for raylib to pass the size, so that (from nim side) you can use openArray[char], and call the raylib api by converting it to cstring (casting the openArray's [0].addr) and passing as well its .len.

edit: FYI I opened this ticket in raylib PS: thank you so much for naylib :) ευχαριστώ!

actondev avatar May 29 '23 17:05 actondev

Γεια σου φιλε Χρήστο,

I agree that calling TextLength when we are already know the size is not optimal, and it's also problematic for strings that contain \0 before the end. But nim's string type has a (non-retrievable) ending \0 for compatibility reasons with C. If you need to use another string type, then you did good to open a ticket in raylib. But I don't have high hopes that Ray will consider it, although it makes a lot of sense for other languages as well.

planetis-m avatar May 29 '23 17:05 planetis-m

Oh, was assuming I'd have to copy to obtain a null-terminated one. Thanks!

actondev avatar May 30 '23 18:05 actondev