On Saturday, 7 October 2017 at 03:12:09 UTC, Matt Jones wrote:
I've been trying to port a basic GLFW C++ example to D. The C++ version shows the textures correctly. But the D version shows nothing. The code is almost identical.

Heh, that's the problem.

Does anyone know why the D version does not work?

https://github.com/workhorsy/d_glfw

I ran into this myself, took me awhile to track it down. I too took the size of dynamic arrays this way:

https://github.com/workhorsy/d_glfw/blob/master/dlang/source/main.d#L158
https://github.com/workhorsy/d_glfw/blob/master/dlang/source/main.d#L161

That will give you 2 words for a slice or dynamic array, the length and pointer. What you want is the length of the array

https://github.com/joakim-noah/android/blob/master/samples/Teapot/jni/TeapotRenderer.d#L192

multiplied by the size of the element

https://github.com/joakim-noah/android/blob/master/samples/Teapot/jni/TeapotRenderer.d#L195

Sizeof works for static arrays, but is different for slices: that's likely your problem.

Reply via email to