www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DirectXMath alternative

reply John Burton <john.burton jbmail.com> writes:
There is a directx-d library which seems to work nicely for d3d11 
but it doesn't include anything like DirectXMath.h presumably 
because it's all implemented as inline intrinsics and very visual 
c++ specific.

What is the best alternative for D, assuming there is anything?
(I want vector, matrix math for use in D3, things like inverting 
a matrix, getting perspective matrices etc)
I can program something myself if necessary but I'd prefer notto
Dec 04 2018
parent reply Guillaume Piolat <first.last gmail.com> writes:
On Tuesday, 4 December 2018 at 20:33:07 UTC, John Burton wrote:
 What is the best alternative for D, assuming there is anything?
 (I want vector, matrix math for use in D3, things like 
 inverting a matrix, getting perspective matrices etc)
 I can program something myself if necessary but I'd prefer notto
You have the choice between the following packages: - dlib - gfm:math - gl3n
Dec 04 2018
parent reply evilrat <evilrat666 gmail.com> writes:
On Tuesday, 4 December 2018 at 20:41:54 UTC, Guillaume Piolat 
wrote:
 On Tuesday, 4 December 2018 at 20:33:07 UTC, John Burton wrote:
 What is the best alternative for D, assuming there is anything?
 (I want vector, matrix math for use in D3, things like 
 inverting a matrix, getting perspective matrices etc)
 I can program something myself if necessary but I'd prefer 
 notto
You have the choice between the following packages: - dlib - gfm:math - gl3n
I was using gl3n then switched to gfm math. Try gfm, IIRC it should work without much PITA because it stores matrices row-major way, so you don't have to transpose it like with OpenGL. Can't say anything about dlib though, I tried it a bit with dagon engine, but just didn't stick for long.
Dec 04 2018
next sibling parent John Burton <john.burton jbmail.com> writes:
On Wednesday, 5 December 2018 at 01:57:53 UTC, evilrat wrote:
 On Tuesday, 4 December 2018 at 20:41:54 UTC, Guillaume Piolat 
 wrote:
 On Tuesday, 4 December 2018 at 20:33:07 UTC, John Burton wrote:
 What is the best alternative for D, assuming there is 
 anything?
 (I want vector, matrix math for use in D3, things like 
 inverting a matrix, getting perspective matrices etc)
 I can program something myself if necessary but I'd prefer 
 notto
You have the choice between the following packages: - dlib - gfm:math - gl3n
I was using gl3n then switched to gfm math. Try gfm, IIRC it should work without much PITA because it stores matrices row-major way, so you don't have to transpose it like with OpenGL. Can't say anything about dlib though, I tried it a bit with dagon engine, but just didn't stick for long.
These all look good, thank you. Although the first two bring in additional modules I don't want I guess I can just ignore them
Dec 04 2018
prev sibling parent reply Guillaume Piolat <first.last gmail.com> writes:
On Wednesday, 5 December 2018 at 01:57:53 UTC, evilrat wrote:
 On Tuesday, 4 December 2018 at 20:41:54 UTC, Guillaume Piolat 
 wrote:
 On Tuesday, 4 December 2018 at 20:33:07 UTC, John Burton wrote:
 What is the best alternative for D, assuming there is 
 anything?
 (I want vector, matrix math for use in D3, things like 
 inverting a matrix, getting perspective matrices etc)
 I can program something myself if necessary but I'd prefer 
 notto
You have the choice between the following packages: - dlib - gfm:math - gl3n
I was using gl3n then switched to gfm math. Try gfm, IIRC it should work without much PITA because it stores matrices row-major way, so you don't have to transpose it like with OpenGL. Can't say anything about dlib though, I tried it a bit with dagon engine, but just didn't stick for long.
I think you are mistaken, gfm:math also stores matrices line-major so you _have_ to transpose them. The problem with row-major is it makes matrix literals read transposed vs the math notation.
Dec 05 2018
next sibling parent John Burton <john.burton jbmail.com> writes:
On Wednesday, 5 December 2018 at 10:52:44 UTC, Guillaume Piolat 
wrote:
 On Wednesday, 5 December 2018 at 01:57:53 UTC, evilrat wrote:
 On Tuesday, 4 December 2018 at 20:41:54 UTC, Guillaume Piolat 
 wrote:
 [...]
I was using gl3n then switched to gfm math. Try gfm, IIRC it should work without much PITA because it stores matrices row-major way, so you don't have to transpose it like with OpenGL. Can't say anything about dlib though, I tried it a bit with dagon engine, but just didn't stick for long.
I think you are mistaken, gfm:math also stores matrices line-major so you _have_ to transpose them. The problem with row-major is it makes matrix literals read transposed vs the math notation.
I think in hlsl shader language you can declare your matrices to be either way anyway can't you? It's just the default that is this way around?
Dec 05 2018
prev sibling parent reply evilrat <evilrat666 gmail.com> writes:
On Wednesday, 5 December 2018 at 10:52:44 UTC, Guillaume Piolat 
wrote:
 On Wednesday, 5 December 2018 at 01:57:53 UTC, evilrat wrote:
 On Tuesday, 4 December 2018 at 20:41:54 UTC, Guillaume Piolat 
 wrote:
 On Tuesday, 4 December 2018 at 20:33:07 UTC, John Burton 
 wrote:
 What is the best alternative for D, assuming there is 
 anything?
 (I want vector, matrix math for use in D3, things like 
 inverting a matrix, getting perspective matrices etc)
 I can program something myself if necessary but I'd prefer 
 notto
You have the choice between the following packages: - dlib - gfm:math - gl3n
I was using gl3n then switched to gfm math. Try gfm, IIRC it should work without much PITA because it stores matrices row-major way, so you don't have to transpose it like with OpenGL. Can't say anything about dlib though, I tried it a bit with dagon engine, but just didn't stick for long.
I think you are mistaken, gfm:math also stores matrices line-major so you _have_ to transpose them. The problem with row-major is it makes matrix literals read transposed vs the math notation.
Are you sure you don't confuse lines with columns? Here it says it is row major https://github.com/d-gamedev-team/gfm/blob/master/math/gfm/math/matrix.d#L17
 On Tuesday, 4 December 2018 at 20:41:54 UTC, Guillaume Piolat
I think in hlsl shader language you can declare your matrices to be either way anyway can't you? It's just the default that is this way around?
The only real difference is the order or operations. IIRC however gfm tries to hide this difference and use math notation. Another thing is memory caches - accessing row in succession will have better chance of cached access while accessing columns in most(if not all) cases will fetch more items only to discard them on next value. Though I haven't ever profiled this myself to be 100% sure.
Dec 05 2018
parent Guillaume Piolat <first.last gmail.com> writes:
On Wednesday, 5 December 2018 at 11:43:46 UTC, evilrat wrote:
 Are you sure you don't confuse lines with columns?
 Here it says it is row major
 https://github.com/d-gamedev-team/gfm/blob/master/math/gfm/math/matrix.d#L17
Yes, sorry I made a mistake. It's indeed row-major in gfm:math.
 The only real difference is the order or operations. IIRC 
 however gfm tries to hide this difference and use math notation.
 Another thing is memory caches - accessing row in succession 
 will have better chance of cached access while accessing 
 columns in most(if not all) cases will fetch more items only to 
 discard them on next value.
 Though I haven't ever profiled this myself to be 100% sure.
I don't know if there is a definitive answer as to which is preferable.
Dec 05 2018