Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 07, 2017 Having trouble porting basic GLFW C++ example to D | ||||
---|---|---|---|---|
| ||||
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. Does anyone know why the D version does not work? https://github.com/workhorsy/d_glfw |
October 07, 2017 Re: Having trouble porting basic GLFW C++ example to D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matt Jones | 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. |
October 07, 2017 Re: Having trouble porting basic GLFW C++ example to D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joakim | On Saturday, 7 October 2017 at 03:47:27 UTC, Joakim wrote:
> On Saturday, 7 October 2017 at 03:12:09 UTC, Matt Jones wrote:
>> [...]
>
> Heh, that's the problem.
>
>> [...]
>
> I ran into this myself, took me awhile to track it down. I too took the size of dynamic arrays this way:
>
> [...]
Ah. I should have remembered that problem. Thanks. I'll see if that fixes it.
|
October 07, 2017 Re: Having trouble porting basic GLFW C++ example to D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matt Jones | On Saturday, 7 October 2017 at 04:24:07 UTC, Matt Jones wrote:
> On Saturday, 7 October 2017 at 03:47:27 UTC, Joakim wrote:
>> On Saturday, 7 October 2017 at 03:12:09 UTC, Matt Jones wrote:
>>> [...]
>>
>> Heh, that's the problem.
>>
>>> [...]
>>
>> I ran into this myself, took me awhile to track it down. I too took the size of dynamic arrays this way:
>>
>> [...]
>
> Ah. I should have remembered that problem. Thanks. I'll see if that fixes it.
Nice! That worked. Thanks.
|
Copyright © 1999-2021 by the D Language Foundation