Re: arsd simpledisplay opengl 3d

2017-12-26 Thread Amorphorious via Digitalmars-d-learn
Thanks. It's working. Seems like either it was the drawing code or the setting one of the setup conditions.

Re: Function hijack on selective import

2017-12-26 Thread rumbu via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 20:21:11 UTC, Adam D. Ruppe wrote: On Tuesday, 26 December 2017 at 19:41:47 UTC, rumbu wrote: "Custom" is a templated struct. I cannot imagine all the instantiations of Custom to write template specialisations for each of them. You can specialize on templated

Re: bitmanip : read does not accept my array slice

2017-12-26 Thread Dennis via Digitalmars-d-learn
Ah, so it's about lvalues an rvalues, not the type of the range. Makes sense now. On Tuesday, 26 December 2017 at 22:33:54 UTC, WebFreak001 wrote: BigEndian is default btw, you don't need to specify that but you can if you want. Dealing with Endianness bugs has been such a pain, I like to be

Re: bitmanip : read does not accept my array slice

2017-12-26 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 21:45:29 UTC, Dennis wrote: I was trying to translate this kind of C code to D: void calc(unsigned char *buf) { (...) res = read_u32_be([i]); } So I tried this: import std.bitmanip : read, Endian; void calc(ubyte[] buf) { (...) res = read!(uint,

bitmanip : read does not accept my array slice

2017-12-26 Thread Dennis via Digitalmars-d-learn
I was trying to translate this kind of C code to D: void calc(unsigned char *buf) { (...) res = read_u32_be([i]); } So I tried this: import std.bitmanip : read, Endian; void calc(ubyte[] buf) { (...) res = read!(uint, Endian.bigEndian)(buf[i..$]); } But then I get this error: template

Re: Function hijack on selective import

2017-12-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 19:41:47 UTC, rumbu wrote: "Custom" is a templated struct. I cannot imagine all the instantiations of Custom to write template specialisations for each of them. You can specialize on templated structs generically. int foo(T : Bar!(X, Y), X, Y) that kind of

Re: Function hijack on selective import

2017-12-26 Thread rumbu via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 16:15:55 UTC, Adam D. Ruppe wrote: The mistake you're making is using a constraint when you should try a specialization: int signbit(T:Custom)(T x) { return 0; } That means to use this specialized function when T is Custom. Now, you just need to merge

Re: copy only reference rather duplicate a string in appender!string

2017-12-26 Thread Neia Neutuladh via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 15:37:12 UTC, Marc wrote: I do build a string by coping large parts of diffrent buffers, all those buffers live after the functional call, so rather than duplicate those string I'd like to copy only references to those parts rather duplicate every string. I

Re: arsd simpledisplay opengl 3d

2017-12-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 07:57:02 UTC, Amorphorious wrote: I've played around with various settings but either I get nothing or 2D. Any idea what I might be missing? so i have barely actually done any 3d stuff myself but the one time I did, the function I used was here actually,

Re: Function hijack on selective import

2017-12-26 Thread Adam D. Ruppe via Digitalmars-d-learn
The mistake you're making is using a constraint when you should try a specialization: int signbit(T:Custom)(T x) { return 0; } That means to use this specialized function when T is Custom. Now, you just need to merge the overload sets: import std.math; alias signbit =

Re: Difference in reduce in std and mir

2017-12-26 Thread Seb via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 15:56:19 UTC, Vino wrote: Hi All, What is the difference between std.algorithm.reduce and mir.ndslice.algorithm.reduce. From, Vino.B Mir's reduce works on Slices whereas Phobos's reduce works on Arrays/Ranges. See also:

Difference in reduce in std and mir

2017-12-26 Thread Vino via Digitalmars-d-learn
Hi All, What is the difference between std.algorithm.reduce and mir.ndslice.algorithm.reduce. From, Vino.B

Function hijack on selective import

2017-12-26 Thread rumbu via Digitalmars-d-learn
Is there anyway to extend an existing function to accept custom data types? Option 1 - global import of std.math import std.math; struct Custom {} int signbit(T)(T x) if (is(T == Custom)) { return 0; } Custom c; assert(signbit(c) == 0); assert(signbit(-1.0) == 1);

copy only reference rather duplicate a string in appender!string

2017-12-26 Thread Marc via Digitalmars-d-learn
I do build a string by coping large parts of diffrent buffers, all those buffers live after the functional call, so rather than duplicate those string I'd like to copy only references to those parts rather duplicate every string. I combined appender!string, assumeUnique() and array slices.

Re: copy only reference rather duplicate a string in appender!string

2017-12-26 Thread Marc via Digitalmars-d-learn
of course a totally different approach to solve this is welcome, I came from C/C++/C# worlds so I'm in the process of slowly converting my thinking to the D way (which is new for me, since I'm even unifamiliar with python and such, which got such friendly syntax)

Re: What is 'scope' in function parameter?

2017-12-26 Thread Sobaya via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 00:17:33 UTC, Mike Franklin wrote: After a few hours trying to figure out why the compiler didn't catch this, I finally figured it out. You have to add `@safe`. import std.stdio; int[] x; void func(scope int[] a) @safe { x = a; } void main() @safe {

Re: Does LDC support profiling at all?

2017-12-26 Thread Prasun Anand via Digitalmars-d-learn
On Friday, 22 December 2017 at 09:52:26 UTC, Chris Katko wrote: DMD can use -profile and -profile=gc. But I tried for HOURS to find the equivalent for LDC and came up with only profile-guided optimization--which I don't believe I want. Yet, if we can get PGO... where's the PROFILE itself it's

Re: partial application for templates

2017-12-26 Thread Mengu via Digitalmars-d-learn
On Monday, 25 December 2017 at 22:58:50 UTC, David Nadlinger wrote: On Monday, 25 December 2017 at 20:39:52 UTC, Mengu wrote: is partially applying templates possible? Check out std.meta.Apply{Left, Right}. — David thanks a lot mr. smith & david.

Re: Can I use memoize with a non-static struct method?

2017-12-26 Thread Mengu via Digitalmars-d-learn
On Tuesday, 26 December 2017 at 00:47:14 UTC, Marc wrote: something like this: struct S { // variables... string doGen(int n) { return ""; } alias gen = memoize!doGen; } The error I got is: Error: need 'this' for 'doGen' of type 'string(int n)' I can't make doGen static because it

arsd simpledisplay opengl 3d

2017-12-26 Thread Amorphorious via Digitalmars-d-learn
Hi Adam, I'm interested in using your simpledisplay for 3D in openGL. I have worked with 2D fine but 3D is problemattic. I cannot get any depth even though i have set up 3D mode by modifying gamehelpers: SimpleWindow create2dWindow(int width = 512, int height = 512, int viewportWidth=512,