digitalmars.D.learn - issue porting C++/glm/openGL to D/gl3n/openGL
- WhatMeWorry (26/26) Jan 09 2016 Just translating some simple C++/glm/opengl tutorial code to
- Mike Parker (6/7) Jan 09 2016 From the very top of the gl3n github page:
- WhatMeWorry (9/18) Jan 09 2016 Thanks. Bummer. I really like gl3n, but glm/opengl is used almost
- Dav1d (16/39) Jan 11 2016 gl3n has most features of GLM just the syntax is different and a
- Mike Parker (5/11) Jan 11 2016 AFAIK, glm is a header-only library, so there's nothing to bind
- rsw0x (3/15) Jan 11 2016 the performance would also be terrible because AFAIK nothing
- rsw0x (3/9) Jan 09 2016 iirc, gl3n uses row major and glm uses column major ordering
- WhatMeWorry (4/16) Jan 09 2016 Yup. Have that already. Maybe I'll take snapshots of the
- Luis (11/23) Jan 11 2016 If you like to check an D lib for vector/matrix/quaterntion
- Luis (5/29) Jan 11 2016 I just remember why I never retake this ... Use gl3n, row-major
- Johan Engelen (7/12) Jan 10 2016 (Disclaimer: I know absolutely nothing about gl3n.)
- Johan Engelen (3/4) Jan 10 2016 Didn't see it in the online docs, but in the source there is the
- WhatMeWorry (8/12) Jan 10 2016 That's it! Excellent catch. Thank you.
Just translating some simple C++/glm/opengl tutorial code to D/gl3n/opengl and I'm coming across more friction than I expected. I've got a square centered at my window which is rotated by 45 degrees (counter clockwise) and then moved to the lower right quadrant. // C++ glm opengl code glm::mat4 transform; transform = glm::translate(transform, glm::vec3(0.0f, -0.5f, 0.0f)); transform = glm::rotate(transform, 45.0f, vec3(0.0f, 0.0f, 1.0f)); // degrees // D gl3n opengl code mat4 transform = mat4.identity; transform = transform.translation(vec3(0.5f, -0.5f, 0.0f)); transform = transform.rotate(0.78539, vec3(0.0f, 0.0f, 1.0f)); // radians My D code performs the operations fine, but in the _opposite_ order. I thought just swapping the order would fix things: transform = transform.rotate(0.78539, vec3(0.0f, 0.0f, 1.0f)); transform = transform.translation(vec3(0.5f, -0.5f, 0.0f)); but now the square is moved to the lower right corner but no rotation happened? So am I using gl3n incorrectly? Are there tricks or techniques I' missing? Is gl3n not a direct replacement for glm? Any advice is greatly appreciated. Thanks.
Jan 09 2016
On Sunday, 10 January 2016 at 02:51:57 UTC, WhatMeWorry wrote:Is gl3n not a direct replacement for glm?From the very top of the gl3n github page: "OpenGL Maths for D (not glm for D)." So, no, it is not. You might want to start with the glm documentaion [1]. [1] http://dav1dde.github.io/gl3n/
Jan 09 2016
On Sunday, 10 January 2016 at 04:37:43 UTC, Mike Parker wrote:On Sunday, 10 January 2016 at 02:51:57 UTC, WhatMeWorry wrote:Thanks. Bummer. I really like gl3n, but glm/opengl is used almost exclusively in all the modern opengl code (tutorials) I've seen, so this might be a deal breaker. As the author of Derelict do you have any ideas of how much work is involved with getting glm to work with D? Want to do a DerelictGLM :) I bought your excellent book as a xmas present for myself so looks like I'll be reading chapter 9.Is gl3n not a direct replacement for glm?From the very top of the gl3n github page: "OpenGL Maths for D (not glm for D)." So, no, it is not. You might want to start with the glm documentaion [1]. [1] http://dav1dde.github.io/gl3n/
Jan 09 2016
On Sunday, 10 January 2016 at 05:47:01 UTC, WhatMeWorry wrote:On Sunday, 10 January 2016 at 04:37:43 UTC, Mike Parker wrote:gl3n has most features of GLM just the syntax is different and a few other things. gl3n then operates on row-major matrices only (Extrawurst wanted to work on a column-major version), which isn't a big issue for your usual GL, you just need to tell OpenGL that it is in row-major format when uploading it. iirc GLM is a header only library so you can't simply interface it from D you would need to port every function, that's what I basically did in gl3n only that I started from scratch and made my own API etc. So you can use gl3n as a glm replacement it just has a different syntax and a few semantics are different. --- Regarding some functions not showing up on the website, that's because the ddoc generator doesn't want to go into some static if() or version() blocks. A known bug.On Sunday, 10 January 2016 at 02:51:57 UTC, WhatMeWorry wrote:Thanks. Bummer. I really like gl3n, but glm/opengl is used almost exclusively in all the modern opengl code (tutorials) I've seen, so this might be a deal breaker. As the author of Derelict do you have any ideas of how much work is involved with getting glm to work with D? Want to do a DerelictGLM :) I bought your excellent book as a xmas present for myself so looks like I'll be reading chapter 9.Is gl3n not a direct replacement for glm?From the very top of the gl3n github page: "OpenGL Maths for D (not glm for D)." So, no, it is not. You might want to start with the glm documentaion [1]. [1] http://dav1dde.github.io/gl3n/
Jan 11 2016
On Sunday, 10 January 2016 at 05:47:01 UTC, WhatMeWorry wrote:Thanks. Bummer. I really like gl3n, but glm/opengl is used almost exclusively in all the modern opengl code (tutorials) I've seen, so this might be a deal breaker. As the author of Derelict do you have any ideas of how much work is involved with getting glm to work with D? Want to do a DerelictGLM :)AFAIK, glm is a header-only library, so there's nothing to bind to. And if it did have binaries, I don't think the current state of D's C++ support could handle it. Binding to C is easy, binding to C++ is hit or miss.
Jan 11 2016
On Tuesday, 12 January 2016 at 01:00:30 UTC, Mike Parker wrote:On Sunday, 10 January 2016 at 05:47:01 UTC, WhatMeWorry wrote:the performance would also be terrible because AFAIK nothing could be inlined(outside of LTO, maybe)Thanks. Bummer. I really like gl3n, but glm/opengl is used almost exclusively in all the modern opengl code (tutorials) I've seen, so this might be a deal breaker. As the author of Derelict do you have any ideas of how much work is involved with getting glm to work with D? Want to do a DerelictGLM :)AFAIK, glm is a header-only library, so there's nothing to bind to. And if it did have binaries, I don't think the current state of D's C++ support could handle it. Binding to C is easy, binding to C++ is hit or miss.
Jan 11 2016
On Sunday, 10 January 2016 at 02:51:57 UTC, WhatMeWorry wrote:Just translating some simple C++/glm/opengl tutorial code to D/gl3n/opengl and I'm coming across more friction than I expected. I've got a square centered at my window which is rotated by 45 degrees (counter clockwise) and then moved to the lower right quadrant. [...]iirc, gl3n uses row major and glm uses column major ordering just pass GL_TRUE to the transpose argument in glUniformMatrix4fv
Jan 09 2016
On Sunday, 10 January 2016 at 06:35:34 UTC, rsw0x wrote:On Sunday, 10 January 2016 at 02:51:57 UTC, WhatMeWorry wrote:Yup. Have that already. Maybe I'll take snapshots of the transform matrix of both programs and see how they differ (if any). The vertex shader is identical for both.Just translating some simple C++/glm/opengl tutorial code to D/gl3n/opengl and I'm coming across more friction than I expected. I've got a square centered at my window which is rotated by 45 degrees (counter clockwise) and then moved to the lower right quadrant. [...]iirc, gl3n uses row major and glm uses column major ordering just pass GL_TRUE to the transpose argument in glUniformMatrix4fv
Jan 09 2016
On Sunday, 10 January 2016 at 06:35:34 UTC, rsw0x wrote:On Sunday, 10 January 2016 at 02:51:57 UTC, WhatMeWorry wrote:If you like to check an D lib for vector/matrix/quaterntion operations that uses column major ordering (ie, not need to transpose), see this : https://github.com/Zardoz89/zmath Was just my D2 learning pet project... I never checked if it was math correct, and I don't updated in a lot of time (5 years ago), plus there isn't documentation beyond comments and a few unit-tests, so use at your risk. But at least I know that was working correctly with Derelict2 when I wrote it. Perhaps I should retake this...Just translating some simple C++/glm/opengl tutorial code to D/gl3n/opengl and I'm coming across more friction than I expected. I've got a square centered at my window which is rotated by 45 degrees (counter clockwise) and then moved to the lower right quadrant. [...]iirc, gl3n uses row major and glm uses column major ordering just pass GL_TRUE to the transpose argument in glUniformMatrix4fv
Jan 11 2016
On Monday, 11 January 2016 at 10:04:29 UTC, Luis wrote:On Sunday, 10 January 2016 at 06:35:34 UTC, rsw0x wrote:I just remember why I never retake this ... Use gl3n, row-major math operations outperforms a lot, if you are doing any matrix multiplication on CPU side ( http://eli.thegreenplace.net/2015/memory-layout-of-multi-dimensional-arrays/ )On Sunday, 10 January 2016 at 02:51:57 UTC, WhatMeWorry wrote:If you like to check an D lib for vector/matrix/quaterntion operations that uses column major ordering (ie, not need to transpose), see this : https://github.com/Zardoz89/zmath Was just my D2 learning pet project... I never checked if it was math correct, and I don't updated in a lot of time (5 years ago), plus there isn't documentation beyond comments and a few unit-tests, so use at your risk. But at least I know that was working correctly with Derelict2 when I wrote it. Perhaps I should retake this...Just translating some simple C++/glm/opengl tutorial code to D/gl3n/opengl and I'm coming across more friction than I expected. I've got a square centered at my window which is rotated by 45 degrees (counter clockwise) and then moved to the lower right quadrant. [...]iirc, gl3n uses row major and glm uses column major ordering just pass GL_TRUE to the transpose argument in glUniformMatrix4fv
Jan 11 2016
On Sunday, 10 January 2016 at 02:51:57 UTC, WhatMeWorry wrote:I thought just swapping the order would fix things: transform = transform.rotate(0.78539, vec3(0.0f, 0.0f, 1.0f)); transform = transform.translation(vec3(0.5f, -0.5f, 0.0f)); but now the square is moved to the lower right corner but no rotation happened?(Disclaimer: I know absolutely nothing about gl3n.) Note that you wrote "translatION", instead of "translatE". Reading the documentation, "translation" does not apply but instead it sets the matrix to a certain translation. See the difference between "rotate" and "rotation" methods. It's pretty strange that there is no "translate" method...
Jan 10 2016
On Sunday, 10 January 2016 at 10:35:34 UTC, Johan Engelen wrote:It's pretty strange that there is no "translate" method...Didn't see it in the online docs, but in the source there is the "translate" method that you should use.
Jan 10 2016
On Sunday, 10 January 2016 at 10:38:07 UTC, Johan Engelen wrote:On Sunday, 10 January 2016 at 10:35:34 UTC, Johan Engelen wrote:That's it! Excellent catch. Thank you. gll3n has translate(), rotate(), and scale() and matrix operators. It also has translation(), rotation(), and scaling() which /// Returns a translation matrix (3x3 and 4x4 matrices). /// Returns an identity matrix with an applied rotate_axis around an arbitrary axis (nxn matrices, n >= 3). /// Returns a scaling matrix (3x3 and 4x4 matrices);It's pretty strange that there is no "translate" method...Didn't see it in the online docs, but in the source there is the "translate" method that you should use.
Jan 10 2016