www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - gl3n - linear algebra and more for D

reply David <admin dav1d.de> writes:
Hello,

I am currently working on gl3n - https://bitbucket.org/dav1d/gl3n - gl3n 
provides all the math you need to work with OpenGL, DirectX or just 
vectors and matrices (it's mainly targeted at graphics - gl3n will never 
be more then a pure math library). What it supports:

  * vectors
  * matrices
  * quaternions
  * interpolation (lerp, slerp, hermite, catmull rom, nearest)
  * nearly all glsl functions (according to spec 4.1)
  * some more cool features, like templated types (vectors, matrices,
    quats), cool ctors, dynamic swizzling

And the best is, it's MIT licensed ;). Unfortunatly there's no 
documentation yet, but it shouldn't be hard to understand how to use it, 
if you run anytime into troubles just take a look into the source, I did 
add to every part of the lib unittests, so you can see how it works when 
looking at the unittests, furthermore I am very often at #D on freenode.
But gl3n isn't finished! My current plans are to add more interpolation 
functions and the rest of the glsl defined functions, but I am new to 
graphics programming (about 4 months I am now into OpenGL), so tell me 
what you're missing, the chances are good that I'll implement and add 
it. So let me know what you think about it.

Before I forget it, a bit of code to show you how to use gl3n:

------------------------------------------------------------------------
vec4 v4 = vec4(1.0f, vec3(2.0f, 3.0f, 4.0f));
vec4 v4 = vec4(1.0f, vec4(1.0f, 2.0f, 3.0f, 4.0f).xyz)); // "dynamic" 
swizzling with opDispatch
vec3 v3 = my_3dvec.rgb;
float[] foo = v4.xyzzzwzyyxw // not useful but possible!
glUniformMatrix4fv(location, 1, GL_TRUE, mat4.translation(-0.5f, -0.54f, 
0.42f).rotatex(PI).rotatez(PI/2).value_ptr); // yes they are row major!
mat3 inv_view = view.rotation;
mat3 inv_view = mat3(view);
mat4 m4 = mat4(vec4(1.0f, 2.0f, 3.0f, 4.0f), 5.0f, 6.0f, 7.0f, 8.0f, 
vec4(...) ...);

struct Camera {
     vec3 position = vec3(0.0f, 0.0f, 0.0f);
     quat orientation = quat.identity;

     Camera rotatex(real alpha) { orientation.rotatex(alpha); return this; }
     Camera rotatey(real alpha) { orientation.rotatey(alpha); return this; }
     Camera rotatez(real alpha) { orientation.rotatez(alpha); return this; }

     Camera move(float x, float y, float z) {
         position += vec3(x, y, z);
         return this;
     }
     Camera move(vec3 s) {
         position += s;
         return this;
     }

      property camera() {
         //writefln("yaw: %s, pitch: %s, roll: %s", 
degrees(orientation.yaw), degrees(orientation.pitch), 
degrees(orientation.roll));
         return mat4.translation(position.x, position.y, position.z) * 
orientation.to_matrix!(4,4);
     }
}

         glUniformMatrix4fv(programs.main.view, 1, GL_TRUE, 
cam.camera.value_ptr);
         glUniformMatrix3fv(programs.main.inv_rot, 1, GL_TRUE, 
cam.orientation.to_matrix!(3,3).inverse.value_ptr);
------------------------------------------------------------------------

I hope this gave you a little introduction of gl3n.

- dav1d
Dec 02 2011
next sibling parent reply Kiith-Sa <42 theanswer.com> writes:
David wrote:

 Hello,
 
 I am currently working on gl3n - https://bitbucket.org/dav1d/gl3n - gl3n
 provides all the math you need to work with OpenGL, DirectX or just
 vectors and matrices (it's mainly targeted at graphics - gl3n will never
 be more then a pure math library). What it supports:
 
   * vectors
   * matrices
   * quaternions
   * interpolation (lerp, slerp, hermite, catmull rom, nearest)
   * nearly all glsl functions (according to spec 4.1)
   * some more cool features, like templated types (vectors, matrices,
     quats), cool ctors, dynamic swizzling
 
 And the best is, it's MIT licensed ;). Unfortunatly there's no
 documentation yet, but it shouldn't be hard to understand how to use it,
 if you run anytime into troubles just take a look into the source, I did
 add to every part of the lib unittests, so you can see how it works when
 looking at the unittests, furthermore I am very often at #D on freenode.
 But gl3n isn't finished! My current plans are to add more interpolation
 functions and the rest of the glsl defined functions, but I am new to
 graphics programming (about 4 months I am now into OpenGL), so tell me
 what you're missing, the chances are good that I'll implement and add
 it. So let me know what you think about it.
 
 Before I forget it, a bit of code to show you how to use gl3n:
 
 ------------------------------------------------------------------------
 vec4 v4 = vec4(1.0f, vec3(2.0f, 3.0f, 4.0f));
 vec4 v4 = vec4(1.0f, vec4(1.0f, 2.0f, 3.0f, 4.0f).xyz)); // "dynamic"
 swizzling with opDispatch
 vec3 v3 = my_3dvec.rgb;
 float[] foo = v4.xyzzzwzyyxw // not useful but possible!
 glUniformMatrix4fv(location, 1, GL_TRUE, mat4.translation(-0.5f, -0.54f,
 0.42f).rotatex(PI).rotatez(PI/2).value_ptr); // yes they are row major!
 mat3 inv_view = view.rotation;
 mat3 inv_view = mat3(view);
 mat4 m4 = mat4(vec4(1.0f, 2.0f, 3.0f, 4.0f), 5.0f, 6.0f, 7.0f, 8.0f,
 vec4(...) ...);
 
 struct Camera {
      vec3 position = vec3(0.0f, 0.0f, 0.0f);
      quat orientation = quat.identity;
 
      Camera rotatex(real alpha) { orientation.rotatex(alpha); return this; }
      Camera rotatey(real alpha) { orientation.rotatey(alpha); return this; }
      Camera rotatez(real alpha) { orientation.rotatez(alpha); return this; }
 
      Camera move(float x, float y, float z) {
          position += vec3(x, y, z);
          return this;
      }
      Camera move(vec3 s) {
          position += s;
          return this;
      }
 
       property camera() {
          //writefln("yaw: %s, pitch: %s, roll: %s",
 degrees(orientation.yaw), degrees(orientation.pitch),
 degrees(orientation.roll));
          return mat4.translation(position.x, position.y, position.z) *
 orientation.to_matrix!(4,4);
      }
 }
 
          glUniformMatrix4fv(programs.main.view, 1, GL_TRUE,
 cam.camera.value_ptr);
          glUniformMatrix3fv(programs.main.inv_rot, 1, GL_TRUE,
 cam.orientation.to_matrix!(3,3).inverse.value_ptr);
 ------------------------------------------------------------------------
 
 I hope this gave you a little introduction of gl3n.
 
 - dav1d
I looked at your project yesterday (found it on derelict forums) and it looks really good. Currently I'm using my own code for vectors/matrices but a dedicated library could be better. My comments: Not sure if DMD will do a good job optimizing your code atm (probably no way around this but to wait - uglifying the code would serve no purpose) In the future, SSE support would be nice (maybe will be easier to do if we ever get SSE intrinsics) Seems like most of the code is in linalg.d - wouldn't it be more maintainable to have it separated for each struct, and then public import it through one module for easy usage? I'm doing a lot of 2D work, and could use at least a rectangle/aabbox struct (if I use your lib, I'll implement rectangles on top of it anyway). Some other structs might also be useful (3D aabbox, circle, sphere?) Although, if you want to be as close to GLSL as possible, this might not be a good idea. Most D projects are under the Boost license. If you want to get this to Phobos, (I'd like something like this in Phobos :P) I recommend using that license (IANAL, but I don't see much difference between MIT and Boost) The GLSL style is good if you want it as close to GLSL as possible, but it'd be good to have more D-style aliases (again hinting at Phobos). (Personally I'd probably use the GLSL style, though)
Dec 03 2011
parent reply David <d dav1d.de> writes:
Am 03.12.2011 22:32, schrieb Kiith-Sa:
 David wrote:

 Hello,

 I am currently working on gl3n - https://bitbucket.org/dav1d/gl3n - gl3n
 provides all the math you need to work with OpenGL, DirectX or just
 vectors and matrices (it's mainly targeted at graphics - gl3n will never
 be more then a pure math library). What it supports:

    * vectors
    * matrices
    * quaternions
    * interpolation (lerp, slerp, hermite, catmull rom, nearest)
    * nearly all glsl functions (according to spec 4.1)
    * some more cool features, like templated types (vectors, matrices,
      quats), cool ctors, dynamic swizzling

 And the best is, it's MIT licensed ;). Unfortunatly there's no
 documentation yet, but it shouldn't be hard to understand how to use it,
 if you run anytime into troubles just take a look into the source, I did
 add to every part of the lib unittests, so you can see how it works when
 looking at the unittests, furthermore I am very often at #D on freenode.
 But gl3n isn't finished! My current plans are to add more interpolation
 functions and the rest of the glsl defined functions, but I am new to
 graphics programming (about 4 months I am now into OpenGL), so tell me
 what you're missing, the chances are good that I'll implement and add
 it. So let me know what you think about it.

 Before I forget it, a bit of code to show you how to use gl3n:

 ------------------------------------------------------------------------
 vec4 v4 = vec4(1.0f, vec3(2.0f, 3.0f, 4.0f));
 vec4 v4 = vec4(1.0f, vec4(1.0f, 2.0f, 3.0f, 4.0f).xyz)); // "dynamic"
 swizzling with opDispatch
 vec3 v3 = my_3dvec.rgb;
 float[] foo = v4.xyzzzwzyyxw // not useful but possible!
 glUniformMatrix4fv(location, 1, GL_TRUE, mat4.translation(-0.5f, -0.54f,
 0.42f).rotatex(PI).rotatez(PI/2).value_ptr); // yes they are row major!
 mat3 inv_view = view.rotation;
 mat3 inv_view = mat3(view);
 mat4 m4 = mat4(vec4(1.0f, 2.0f, 3.0f, 4.0f), 5.0f, 6.0f, 7.0f, 8.0f,
 vec4(...) ...);

 struct Camera {
       vec3 position = vec3(0.0f, 0.0f, 0.0f);
       quat orientation = quat.identity;

       Camera rotatex(real alpha) { orientation.rotatex(alpha); return this; }
       Camera rotatey(real alpha) { orientation.rotatey(alpha); return this; }
       Camera rotatez(real alpha) { orientation.rotatez(alpha); return this; }

       Camera move(float x, float y, float z) {
           position += vec3(x, y, z);
           return this;
       }
       Camera move(vec3 s) {
           position += s;
           return this;
       }

        property camera() {
           //writefln("yaw: %s, pitch: %s, roll: %s",
 degrees(orientation.yaw), degrees(orientation.pitch),
 degrees(orientation.roll));
           return mat4.translation(position.x, position.y, position.z) *
 orientation.to_matrix!(4,4);
       }
 }

           glUniformMatrix4fv(programs.main.view, 1, GL_TRUE,
 cam.camera.value_ptr);
           glUniformMatrix3fv(programs.main.inv_rot, 1, GL_TRUE,
 cam.orientation.to_matrix!(3,3).inverse.value_ptr);
 ------------------------------------------------------------------------

 I hope this gave you a little introduction of gl3n.

 - dav1d
I looked at your project yesterday (found it on derelict forums) and it looks really good. Currently I'm using my own code for vectors/matrices but a dedicated library could be better. My comments: Not sure if DMD will do a good job optimizing your code atm (probably no way around this but to wait - uglifying the code would serve no purpose) In the future, SSE support would be nice (maybe will be easier to do if we ever get SSE intrinsics) Seems like most of the code is in linalg.d - wouldn't it be more maintainable to have it separated for each struct, and then public import it through one module for easy usage? I'm doing a lot of 2D work, and could use at least a rectangle/aabbox struct (if I use your lib, I'll implement rectangles on top of it anyway). Some other structs might also be useful (3D aabbox, circle, sphere?) Although, if you want to be as close to GLSL as possible, this might not be a good idea. Most D projects are under the Boost license. If you want to get this to Phobos, (I'd like something like this in Phobos :P) I recommend using that license (IANAL, but I don't see much difference between MIT and Boost) The GLSL style is good if you want it as close to GLSL as possible, but it'd be good to have more D-style aliases (again hinting at Phobos). (Personally I'd probably use the GLSL style, though)
Hi, Thanks for your feedback. SSE is planed, but it will be the last step, optimization at the end. Well gl3n shouldn't be the bottleneck anyways, because it's normally the GPU. I've already thought about splitting linalg into 3 different files (also it was suggested by some people), but I dont like how D(md) handles imports, something like this would be cool: import gl3n.linalg.matrix; import gl3n.linalg.vector; import gl3n.linalg.quaternion; import gl3n.linalg; // this would import gl3n.linalg.matrix/vector/quaternion publically Like __init__.py in Python, unfortunatly this isn't supported (yet?). It is also planed to add some useful stuff for graphics programming, like as you mentioned spheres or AABB (axis aligned bounding boxes). Well I dont want it to be GLSL conform (then it would be glm), because I dont like all of the GLSL design choices and D is much more poweful! I am glad you like it :) - dav1d
Dec 03 2011
parent reply =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= <xtzgzorex gmail.com> writes:
On 03-12-2011 23:36, David wrote:
 Am 03.12.2011 22:32, schrieb Kiith-Sa:
 David wrote:

 Hello,

 I am currently working on gl3n - https://bitbucket.org/dav1d/gl3n - gl3n
 provides all the math you need to work with OpenGL, DirectX or just
 vectors and matrices (it's mainly targeted at graphics - gl3n will never
 be more then a pure math library). What it supports:

 * vectors
 * matrices
 * quaternions
 * interpolation (lerp, slerp, hermite, catmull rom, nearest)
 * nearly all glsl functions (according to spec 4.1)
 * some more cool features, like templated types (vectors, matrices,
 quats), cool ctors, dynamic swizzling

 And the best is, it's MIT licensed ;). Unfortunatly there's no
 documentation yet, but it shouldn't be hard to understand how to use it,
 if you run anytime into troubles just take a look into the source, I did
 add to every part of the lib unittests, so you can see how it works when
 looking at the unittests, furthermore I am very often at #D on freenode.
 But gl3n isn't finished! My current plans are to add more interpolation
 functions and the rest of the glsl defined functions, but I am new to
 graphics programming (about 4 months I am now into OpenGL), so tell me
 what you're missing, the chances are good that I'll implement and add
 it. So let me know what you think about it.

 Before I forget it, a bit of code to show you how to use gl3n:

 ------------------------------------------------------------------------
 vec4 v4 = vec4(1.0f, vec3(2.0f, 3.0f, 4.0f));
 vec4 v4 = vec4(1.0f, vec4(1.0f, 2.0f, 3.0f, 4.0f).xyz)); // "dynamic"
 swizzling with opDispatch
 vec3 v3 = my_3dvec.rgb;
 float[] foo = v4.xyzzzwzyyxw // not useful but possible!
 glUniformMatrix4fv(location, 1, GL_TRUE, mat4.translation(-0.5f, -0.54f,
 0.42f).rotatex(PI).rotatez(PI/2).value_ptr); // yes they are row major!
 mat3 inv_view = view.rotation;
 mat3 inv_view = mat3(view);
 mat4 m4 = mat4(vec4(1.0f, 2.0f, 3.0f, 4.0f), 5.0f, 6.0f, 7.0f, 8.0f,
 vec4(...) ...);

 struct Camera {
 vec3 position = vec3(0.0f, 0.0f, 0.0f);
 quat orientation = quat.identity;

 Camera rotatex(real alpha) { orientation.rotatex(alpha); return this; }
 Camera rotatey(real alpha) { orientation.rotatey(alpha); return this; }
 Camera rotatez(real alpha) { orientation.rotatez(alpha); return this; }

 Camera move(float x, float y, float z) {
 position += vec3(x, y, z);
 return this;
 }
 Camera move(vec3 s) {
 position += s;
 return this;
 }

  property camera() {
 //writefln("yaw: %s, pitch: %s, roll: %s",
 degrees(orientation.yaw), degrees(orientation.pitch),
 degrees(orientation.roll));
 return mat4.translation(position.x, position.y, position.z) *
 orientation.to_matrix!(4,4);
 }
 }

 glUniformMatrix4fv(programs.main.view, 1, GL_TRUE,
 cam.camera.value_ptr);
 glUniformMatrix3fv(programs.main.inv_rot, 1, GL_TRUE,
 cam.orientation.to_matrix!(3,3).inverse.value_ptr);
 ------------------------------------------------------------------------

 I hope this gave you a little introduction of gl3n.

 - dav1d
I looked at your project yesterday (found it on derelict forums) and it looks really good. Currently I'm using my own code for vectors/matrices but a dedicated library could be better. My comments: Not sure if DMD will do a good job optimizing your code atm (probably no way around this but to wait - uglifying the code would serve no purpose) In the future, SSE support would be nice (maybe will be easier to do if we ever get SSE intrinsics) Seems like most of the code is in linalg.d - wouldn't it be more maintainable to have it separated for each struct, and then public import it through one module for easy usage? I'm doing a lot of 2D work, and could use at least a rectangle/aabbox struct (if I use your lib, I'll implement rectangles on top of it anyway). Some other structs might also be useful (3D aabbox, circle, sphere?) Although, if you want to be as close to GLSL as possible, this might not be a good idea. Most D projects are under the Boost license. If you want to get this to Phobos, (I'd like something like this in Phobos :P) I recommend using that license (IANAL, but I don't see much difference between MIT and Boost) The GLSL style is good if you want it as close to GLSL as possible, but it'd be good to have more D-style aliases (again hinting at Phobos). (Personally I'd probably use the GLSL style, though)
Hi, Thanks for your feedback. SSE is planed, but it will be the last step, optimization at the end. Well gl3n shouldn't be the bottleneck anyways, because it's normally the GPU. I've already thought about splitting linalg into 3 different files (also it was suggested by some people), but I dont like how D(md) handles imports, something like this would be cool: import gl3n.linalg.matrix; import gl3n.linalg.vector; import gl3n.linalg.quaternion; import gl3n.linalg; // this would import gl3n.linalg.matrix/vector/quaternion publically Like __init__.py in Python, unfortunatly this isn't supported (yet?). It is also planed to add some useful stuff for graphics programming, like as you mentioned spheres or AABB (axis aligned bounding boxes). Well I dont want it to be GLSL conform (then it would be glm), because I dont like all of the GLSL design choices and D is much more poweful! I am glad you like it :) - dav1d
You can make a gl3n.linalg.all modules that goes like: public import gl3n.linalg.matrix; public import gl3n.linalg.vector; etc... - Alex
Dec 04 2011
parent reply David <d dav1d.de> writes:
Am 04.12.2011 14:16, schrieb Alex Rønne Petersen:
 On 03-12-2011 23:36, David wrote:
 Am 03.12.2011 22:32, schrieb Kiith-Sa:
 David wrote:

 Hello,

 I am currently working on gl3n - https://bitbucket.org/dav1d/gl3n -
 gl3n
 provides all the math you need to work with OpenGL, DirectX or just
 vectors and matrices (it's mainly targeted at graphics - gl3n will
 never
 be more then a pure math library). What it supports:

 * vectors
 * matrices
 * quaternions
 * interpolation (lerp, slerp, hermite, catmull rom, nearest)
 * nearly all glsl functions (according to spec 4.1)
 * some more cool features, like templated types (vectors, matrices,
 quats), cool ctors, dynamic swizzling

 And the best is, it's MIT licensed ;). Unfortunatly there's no
 documentation yet, but it shouldn't be hard to understand how to use
 it,
 if you run anytime into troubles just take a look into the source, I
 did
 add to every part of the lib unittests, so you can see how it works
 when
 looking at the unittests, furthermore I am very often at #D on
 freenode.
 But gl3n isn't finished! My current plans are to add more interpolation
 functions and the rest of the glsl defined functions, but I am new to
 graphics programming (about 4 months I am now into OpenGL), so tell me
 what you're missing, the chances are good that I'll implement and add
 it. So let me know what you think about it.

 Before I forget it, a bit of code to show you how to use gl3n:

 ------------------------------------------------------------------------

 vec4 v4 = vec4(1.0f, vec3(2.0f, 3.0f, 4.0f));
 vec4 v4 = vec4(1.0f, vec4(1.0f, 2.0f, 3.0f, 4.0f).xyz)); // "dynamic"
 swizzling with opDispatch
 vec3 v3 = my_3dvec.rgb;
 float[] foo = v4.xyzzzwzyyxw // not useful but possible!
 glUniformMatrix4fv(location, 1, GL_TRUE, mat4.translation(-0.5f,
 -0.54f,
 0.42f).rotatex(PI).rotatez(PI/2).value_ptr); // yes they are row major!
 mat3 inv_view = view.rotation;
 mat3 inv_view = mat3(view);
 mat4 m4 = mat4(vec4(1.0f, 2.0f, 3.0f, 4.0f), 5.0f, 6.0f, 7.0f, 8.0f,
 vec4(...) ...);

 struct Camera {
 vec3 position = vec3(0.0f, 0.0f, 0.0f);
 quat orientation = quat.identity;

 Camera rotatex(real alpha) { orientation.rotatex(alpha); return this; }
 Camera rotatey(real alpha) { orientation.rotatey(alpha); return this; }
 Camera rotatez(real alpha) { orientation.rotatez(alpha); return this; }

 Camera move(float x, float y, float z) {
 position += vec3(x, y, z);
 return this;
 }
 Camera move(vec3 s) {
 position += s;
 return this;
 }

  property camera() {
 //writefln("yaw: %s, pitch: %s, roll: %s",
 degrees(orientation.yaw), degrees(orientation.pitch),
 degrees(orientation.roll));
 return mat4.translation(position.x, position.y, position.z) *
 orientation.to_matrix!(4,4);
 }
 }

 glUniformMatrix4fv(programs.main.view, 1, GL_TRUE,
 cam.camera.value_ptr);
 glUniformMatrix3fv(programs.main.inv_rot, 1, GL_TRUE,
 cam.orientation.to_matrix!(3,3).inverse.value_ptr);
 ------------------------------------------------------------------------


 I hope this gave you a little introduction of gl3n.

 - dav1d
I looked at your project yesterday (found it on derelict forums) and it looks really good. Currently I'm using my own code for vectors/matrices but a dedicated library could be better. My comments: Not sure if DMD will do a good job optimizing your code atm (probably no way around this but to wait - uglifying the code would serve no purpose) In the future, SSE support would be nice (maybe will be easier to do if we ever get SSE intrinsics) Seems like most of the code is in linalg.d - wouldn't it be more maintainable to have it separated for each struct, and then public import it through one module for easy usage? I'm doing a lot of 2D work, and could use at least a rectangle/aabbox struct (if I use your lib, I'll implement rectangles on top of it anyway). Some other structs might also be useful (3D aabbox, circle, sphere?) Although, if you want to be as close to GLSL as possible, this might not be a good idea. Most D projects are under the Boost license. If you want to get this to Phobos, (I'd like something like this in Phobos :P) I recommend using that license (IANAL, but I don't see much difference between MIT and Boost) The GLSL style is good if you want it as close to GLSL as possible, but it'd be good to have more D-style aliases (again hinting at Phobos). (Personally I'd probably use the GLSL style, though)
Hi, Thanks for your feedback. SSE is planed, but it will be the last step, optimization at the end. Well gl3n shouldn't be the bottleneck anyways, because it's normally the GPU. I've already thought about splitting linalg into 3 different files (also it was suggested by some people), but I dont like how D(md) handles imports, something like this would be cool: import gl3n.linalg.matrix; import gl3n.linalg.vector; import gl3n.linalg.quaternion; import gl3n.linalg; // this would import gl3n.linalg.matrix/vector/quaternion publically Like __init__.py in Python, unfortunatly this isn't supported (yet?). It is also planed to add some useful stuff for graphics programming, like as you mentioned spheres or AABB (axis aligned bounding boxes). Well I dont want it to be GLSL conform (then it would be glm), because I dont like all of the GLSL design choices and D is much more poweful! I am glad you like it :) - dav1d
You can make a gl3n.linalg.all modules that goes like: public import gl3n.linalg.matrix; public import gl3n.linalg.vector; etc... - Alex
Yeah I know, but that's the reason why I don't do it, I don't like the all part. Maybe it's just a personal dislike.
Dec 04 2011
parent reply =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= <xtzgzorex gmail.com> writes:
On 04-12-2011 14:22, David wrote:
 Am 04.12.2011 14:16, schrieb Alex Rønne Petersen:
 On 03-12-2011 23:36, David wrote:
 Am 03.12.2011 22:32, schrieb Kiith-Sa:
 David wrote:

 Hello,

 I am currently working on gl3n - https://bitbucket.org/dav1d/gl3n -
 gl3n
 provides all the math you need to work with OpenGL, DirectX or just
 vectors and matrices (it's mainly targeted at graphics - gl3n will
 never
 be more then a pure math library). What it supports:

 * vectors
 * matrices
 * quaternions
 * interpolation (lerp, slerp, hermite, catmull rom, nearest)
 * nearly all glsl functions (according to spec 4.1)
 * some more cool features, like templated types (vectors, matrices,
 quats), cool ctors, dynamic swizzling

 And the best is, it's MIT licensed ;). Unfortunatly there's no
 documentation yet, but it shouldn't be hard to understand how to use
 it,
 if you run anytime into troubles just take a look into the source, I
 did
 add to every part of the lib unittests, so you can see how it works
 when
 looking at the unittests, furthermore I am very often at #D on
 freenode.
 But gl3n isn't finished! My current plans are to add more
 interpolation
 functions and the rest of the glsl defined functions, but I am new to
 graphics programming (about 4 months I am now into OpenGL), so tell me
 what you're missing, the chances are good that I'll implement and add
 it. So let me know what you think about it.

 Before I forget it, a bit of code to show you how to use gl3n:

 ------------------------------------------------------------------------


 vec4 v4 = vec4(1.0f, vec3(2.0f, 3.0f, 4.0f));
 vec4 v4 = vec4(1.0f, vec4(1.0f, 2.0f, 3.0f, 4.0f).xyz)); // "dynamic"
 swizzling with opDispatch
 vec3 v3 = my_3dvec.rgb;
 float[] foo = v4.xyzzzwzyyxw // not useful but possible!
 glUniformMatrix4fv(location, 1, GL_TRUE, mat4.translation(-0.5f,
 -0.54f,
 0.42f).rotatex(PI).rotatez(PI/2).value_ptr); // yes they are row
 major!
 mat3 inv_view = view.rotation;
 mat3 inv_view = mat3(view);
 mat4 m4 = mat4(vec4(1.0f, 2.0f, 3.0f, 4.0f), 5.0f, 6.0f, 7.0f, 8.0f,
 vec4(...) ...);

 struct Camera {
 vec3 position = vec3(0.0f, 0.0f, 0.0f);
 quat orientation = quat.identity;

 Camera rotatex(real alpha) { orientation.rotatex(alpha); return
 this; }
 Camera rotatey(real alpha) { orientation.rotatey(alpha); return
 this; }
 Camera rotatez(real alpha) { orientation.rotatez(alpha); return
 this; }

 Camera move(float x, float y, float z) {
 position += vec3(x, y, z);
 return this;
 }
 Camera move(vec3 s) {
 position += s;
 return this;
 }

  property camera() {
 //writefln("yaw: %s, pitch: %s, roll: %s",
 degrees(orientation.yaw), degrees(orientation.pitch),
 degrees(orientation.roll));
 return mat4.translation(position.x, position.y, position.z) *
 orientation.to_matrix!(4,4);
 }
 }

 glUniformMatrix4fv(programs.main.view, 1, GL_TRUE,
 cam.camera.value_ptr);
 glUniformMatrix3fv(programs.main.inv_rot, 1, GL_TRUE,
 cam.orientation.to_matrix!(3,3).inverse.value_ptr);
 ------------------------------------------------------------------------



 I hope this gave you a little introduction of gl3n.

 - dav1d
I looked at your project yesterday (found it on derelict forums) and it looks really good. Currently I'm using my own code for vectors/matrices but a dedicated library could be better. My comments: Not sure if DMD will do a good job optimizing your code atm (probably no way around this but to wait - uglifying the code would serve no purpose) In the future, SSE support would be nice (maybe will be easier to do if we ever get SSE intrinsics) Seems like most of the code is in linalg.d - wouldn't it be more maintainable to have it separated for each struct, and then public import it through one module for easy usage? I'm doing a lot of 2D work, and could use at least a rectangle/aabbox struct (if I use your lib, I'll implement rectangles on top of it anyway). Some other structs might also be useful (3D aabbox, circle, sphere?) Although, if you want to be as close to GLSL as possible, this might not be a good idea. Most D projects are under the Boost license. If you want to get this to Phobos, (I'd like something like this in Phobos :P) I recommend using that license (IANAL, but I don't see much difference between MIT and Boost) The GLSL style is good if you want it as close to GLSL as possible, but it'd be good to have more D-style aliases (again hinting at Phobos). (Personally I'd probably use the GLSL style, though)
Hi, Thanks for your feedback. SSE is planed, but it will be the last step, optimization at the end. Well gl3n shouldn't be the bottleneck anyways, because it's normally the GPU. I've already thought about splitting linalg into 3 different files (also it was suggested by some people), but I dont like how D(md) handles imports, something like this would be cool: import gl3n.linalg.matrix; import gl3n.linalg.vector; import gl3n.linalg.quaternion; import gl3n.linalg; // this would import gl3n.linalg.matrix/vector/quaternion publically Like __init__.py in Python, unfortunatly this isn't supported (yet?). It is also planed to add some useful stuff for graphics programming, like as you mentioned spheres or AABB (axis aligned bounding boxes). Well I dont want it to be GLSL conform (then it would be glm), because I dont like all of the GLSL design choices and D is much more poweful! I am glad you like it :) - dav1d
You can make a gl3n.linalg.all modules that goes like: public import gl3n.linalg.matrix; public import gl3n.linalg.vector; etc... - Alex
Yeah I know, but that's the reason why I don't do it, I don't like the all part. Maybe it's just a personal dislike.
It's the only way you can do it in D. gl3n.linalg will always conflict because that's the name of the package. - Alex
Dec 04 2011
parent Timon Gehr <timon.gehr gmx.ch> writes:
On 12/04/2011 02:27 PM, Alex Rønne Petersen wrote:
 On 04-12-2011 14:22, David wrote:
 Am 04.12.2011 14:16, schrieb Alex Rønne Petersen:
 On 03-12-2011 23:36, David wrote:
 Am 03.12.2011 22:32, schrieb Kiith-Sa:
 David wrote:

 Hello,

 I am currently working on gl3n - https://bitbucket.org/dav1d/gl3n -
 gl3n
 provides all the math you need to work with OpenGL, DirectX or just
 vectors and matrices (it's mainly targeted at graphics - gl3n will
 never
 be more then a pure math library). What it supports:

 * vectors
 * matrices
 * quaternions
 * interpolation (lerp, slerp, hermite, catmull rom, nearest)
 * nearly all glsl functions (according to spec 4.1)
 * some more cool features, like templated types (vectors, matrices,
 quats), cool ctors, dynamic swizzling

 And the best is, it's MIT licensed ;). Unfortunatly there's no
 documentation yet, but it shouldn't be hard to understand how to use
 it,
 if you run anytime into troubles just take a look into the source, I
 did
 add to every part of the lib unittests, so you can see how it works
 when
 looking at the unittests, furthermore I am very often at #D on
 freenode.
 But gl3n isn't finished! My current plans are to add more
 interpolation
 functions and the rest of the glsl defined functions, but I am new to
 graphics programming (about 4 months I am now into OpenGL), so
 tell me
 what you're missing, the chances are good that I'll implement and add
 it. So let me know what you think about it.

 Before I forget it, a bit of code to show you how to use gl3n:

 ------------------------------------------------------------------------



 vec4 v4 = vec4(1.0f, vec3(2.0f, 3.0f, 4.0f));
 vec4 v4 = vec4(1.0f, vec4(1.0f, 2.0f, 3.0f, 4.0f).xyz)); // "dynamic"
 swizzling with opDispatch
 vec3 v3 = my_3dvec.rgb;
 float[] foo = v4.xyzzzwzyyxw // not useful but possible!
 glUniformMatrix4fv(location, 1, GL_TRUE, mat4.translation(-0.5f,
 -0.54f,
 0.42f).rotatex(PI).rotatez(PI/2).value_ptr); // yes they are row
 major!
 mat3 inv_view = view.rotation;
 mat3 inv_view = mat3(view);
 mat4 m4 = mat4(vec4(1.0f, 2.0f, 3.0f, 4.0f), 5.0f, 6.0f, 7.0f, 8.0f,
 vec4(...) ...);

 struct Camera {
 vec3 position = vec3(0.0f, 0.0f, 0.0f);
 quat orientation = quat.identity;

 Camera rotatex(real alpha) { orientation.rotatex(alpha); return
 this; }
 Camera rotatey(real alpha) { orientation.rotatey(alpha); return
 this; }
 Camera rotatez(real alpha) { orientation.rotatez(alpha); return
 this; }

 Camera move(float x, float y, float z) {
 position += vec3(x, y, z);
 return this;
 }
 Camera move(vec3 s) {
 position += s;
 return this;
 }

  property camera() {
 //writefln("yaw: %s, pitch: %s, roll: %s",
 degrees(orientation.yaw), degrees(orientation.pitch),
 degrees(orientation.roll));
 return mat4.translation(position.x, position.y, position.z) *
 orientation.to_matrix!(4,4);
 }
 }

 glUniformMatrix4fv(programs.main.view, 1, GL_TRUE,
 cam.camera.value_ptr);
 glUniformMatrix3fv(programs.main.inv_rot, 1, GL_TRUE,
 cam.orientation.to_matrix!(3,3).inverse.value_ptr);
 ------------------------------------------------------------------------




 I hope this gave you a little introduction of gl3n.

 - dav1d
I looked at your project yesterday (found it on derelict forums) and it looks really good. Currently I'm using my own code for vectors/matrices but a dedicated library could be better. My comments: Not sure if DMD will do a good job optimizing your code atm (probably no way around this but to wait - uglifying the code would serve no purpose) In the future, SSE support would be nice (maybe will be easier to do if we ever get SSE intrinsics) Seems like most of the code is in linalg.d - wouldn't it be more maintainable to have it separated for each struct, and then public import it through one module for easy usage? I'm doing a lot of 2D work, and could use at least a rectangle/aabbox struct (if I use your lib, I'll implement rectangles on top of it anyway). Some other structs might also be useful (3D aabbox, circle, sphere?) Although, if you want to be as close to GLSL as possible, this might not be a good idea. Most D projects are under the Boost license. If you want to get this to Phobos, (I'd like something like this in Phobos :P) I recommend using that license (IANAL, but I don't see much difference between MIT and Boost) The GLSL style is good if you want it as close to GLSL as possible, but it'd be good to have more D-style aliases (again hinting at Phobos). (Personally I'd probably use the GLSL style, though)
Hi, Thanks for your feedback. SSE is planed, but it will be the last step, optimization at the end. Well gl3n shouldn't be the bottleneck anyways, because it's normally the GPU. I've already thought about splitting linalg into 3 different files (also it was suggested by some people), but I dont like how D(md) handles imports, something like this would be cool: import gl3n.linalg.matrix; import gl3n.linalg.vector; import gl3n.linalg.quaternion; import gl3n.linalg; // this would import gl3n.linalg.matrix/vector/quaternion publically Like __init__.py in Python, unfortunatly this isn't supported (yet?). It is also planed to add some useful stuff for graphics programming, like as you mentioned spheres or AABB (axis aligned bounding boxes). Well I dont want it to be GLSL conform (then it would be glm), because I dont like all of the GLSL design choices and D is much more poweful! I am glad you like it :) - dav1d
You can make a gl3n.linalg.all modules that goes like: public import gl3n.linalg.matrix; public import gl3n.linalg.vector; etc... - Alex
Yeah I know, but that's the reason why I don't do it, I don't like the all part. Maybe it's just a personal dislike.
It's the only way you can do it in D. gl3n.linalg will always conflict because that's the name of the package. - Alex
I usually use "_" instead of "all".
Dec 04 2011
prev sibling next sibling parent reply dsimcha <dsimcha yahoo.com> writes:
I don't know much about computer graphics but I take it that a sane 
design for a matrix/vector library geared towards graphics is completely 
different from one geared towards general numerics/scientific computing? 
  I'm trying to understand whether SciD (which uses BLAS/LAPACK and 
expression templates) overlaps with this at all.

On 12/2/2011 5:36 PM, David wrote:
 Hello,

 I am currently working on gl3n - https://bitbucket.org/dav1d/gl3n - gl3n
 provides all the math you need to work with OpenGL, DirectX or just
 vectors and matrices (it's mainly targeted at graphics - gl3n will never
 be more then a pure math library). What it supports:

   * vectors
   * matrices
   * quaternions
   * interpolation (lerp, slerp, hermite, catmull rom, nearest)
   * nearly all glsl functions (according to spec 4.1)
   * some more cool features, like templated types (vectors, matrices,
     quats), cool ctors, dynamic swizzling

 And the best is, it's MIT licensed ;). Unfortunatly there's no
 documentation yet, but it shouldn't be hard to understand how to use it,
 if you run anytime into troubles just take a look into the source, I did
 add to every part of the lib unittests, so you can see how it works when
 looking at the unittests, furthermore I am very often at #D on freenode.
 But gl3n isn't finished! My current plans are to add more interpolation
 functions and the rest of the glsl defined functions, but I am new to
 graphics programming (about 4 months I am now into OpenGL), so tell me
 what you're missing, the chances are good that I'll implement and add
 it. So let me know what you think about it.

 Before I forget it, a bit of code to show you how to use gl3n:

 ------------------------------------------------------------------------
 vec4 v4 = vec4(1.0f, vec3(2.0f, 3.0f, 4.0f));
 vec4 v4 = vec4(1.0f, vec4(1.0f, 2.0f, 3.0f, 4.0f).xyz)); // "dynamic"
 swizzling with opDispatch
 vec3 v3 = my_3dvec.rgb;
 float[] foo = v4.xyzzzwzyyxw // not useful but possible!
 glUniformMatrix4fv(location, 1, GL_TRUE, mat4.translation(-0.5f, -0.54f,
 0.42f).rotatex(PI).rotatez(PI/2).value_ptr); // yes they are row major!
 mat3 inv_view = view.rotation;
 mat3 inv_view = mat3(view);
 mat4 m4 = mat4(vec4(1.0f, 2.0f, 3.0f, 4.0f), 5.0f, 6.0f, 7.0f, 8.0f,
 vec4(…) …);

 struct Camera {
      vec3 position = vec3(0.0f, 0.0f, 0.0f);
      quat orientation = quat.identity;

      Camera rotatex(real alpha) { orientation.rotatex(alpha); return this; }
      Camera rotatey(real alpha) { orientation.rotatey(alpha); return this; }
      Camera rotatez(real alpha) { orientation.rotatez(alpha); return this; }

      Camera move(float x, float y, float z) {
          position += vec3(x, y, z);
          return this;
      }
      Camera move(vec3 s) {
          position += s;
          return this;
      }

       property camera() {
          //writefln("yaw: %s, pitch: %s, roll: %s",
 degrees(orientation.yaw), degrees(orientation.pitch),
 degrees(orientation.roll));
          return mat4.translation(position.x, position.y, position.z) *
 orientation.to_matrix!(4,4);
      }
 }

          glUniformMatrix4fv(programs.main.view, 1, GL_TRUE,
 cam.camera.value_ptr);
          glUniformMatrix3fv(programs.main.inv_rot, 1, GL_TRUE,
 cam.orientation.to_matrix!(3,3).inverse.value_ptr);
 ------------------------------------------------------------------------

 I hope this gave you a little introduction of gl3n.

 - dav1d
Dec 03 2011
parent reply David <d dav1d.de> writes:
Am 04.12.2011 01:38, schrieb dsimcha:
 I don't know much about computer graphics but I take it that a sane
 design for a matrix/vector library geared towards graphics is completely
 different from one geared towards general numerics/scientific computing?
 I'm trying to understand whether SciD (which uses BLAS/LAPACK and
 expression templates) overlaps with this at all.

 On 12/2/2011 5:36 PM, David wrote:
 Hello,

 I am currently working on gl3n - https://bitbucket.org/dav1d/gl3n - gl3n
 provides all the math you need to work with OpenGL, DirectX or just
 vectors and matrices (it's mainly targeted at graphics - gl3n will never
 be more then a pure math library). What it supports:

 * vectors
 * matrices
 * quaternions
 * interpolation (lerp, slerp, hermite, catmull rom, nearest)
 * nearly all glsl functions (according to spec 4.1)
 * some more cool features, like templated types (vectors, matrices,
 quats), cool ctors, dynamic swizzling

 And the best is, it's MIT licensed ;). Unfortunatly there's no
 documentation yet, but it shouldn't be hard to understand how to use it,
 if you run anytime into troubles just take a look into the source, I did
 add to every part of the lib unittests, so you can see how it works when
 looking at the unittests, furthermore I am very often at #D on freenode.
 But gl3n isn't finished! My current plans are to add more interpolation
 functions and the rest of the glsl defined functions, but I am new to
 graphics programming (about 4 months I am now into OpenGL), so tell me
 what you're missing, the chances are good that I'll implement and add
 it. So let me know what you think about it.

 Before I forget it, a bit of code to show you how to use gl3n:

 ------------------------------------------------------------------------
 vec4 v4 = vec4(1.0f, vec3(2.0f, 3.0f, 4.0f));
 vec4 v4 = vec4(1.0f, vec4(1.0f, 2.0f, 3.0f, 4.0f).xyz)); // "dynamic"
 swizzling with opDispatch
 vec3 v3 = my_3dvec.rgb;
 float[] foo = v4.xyzzzwzyyxw // not useful but possible!
 glUniformMatrix4fv(location, 1, GL_TRUE, mat4.translation(-0.5f, -0.54f,
 0.42f).rotatex(PI).rotatez(PI/2).value_ptr); // yes they are row major!
 mat3 inv_view = view.rotation;
 mat3 inv_view = mat3(view);
 mat4 m4 = mat4(vec4(1.0f, 2.0f, 3.0f, 4.0f), 5.0f, 6.0f, 7.0f, 8.0f,
 vec4(…) …);

 struct Camera {
 vec3 position = vec3(0.0f, 0.0f, 0.0f);
 quat orientation = quat.identity;

 Camera rotatex(real alpha) { orientation.rotatex(alpha); return this; }
 Camera rotatey(real alpha) { orientation.rotatey(alpha); return this; }
 Camera rotatez(real alpha) { orientation.rotatez(alpha); return this; }

 Camera move(float x, float y, float z) {
 position += vec3(x, y, z);
 return this;
 }
 Camera move(vec3 s) {
 position += s;
 return this;
 }

  property camera() {
 //writefln("yaw: %s, pitch: %s, roll: %s",
 degrees(orientation.yaw), degrees(orientation.pitch),
 degrees(orientation.roll));
 return mat4.translation(position.x, position.y, position.z) *
 orientation.to_matrix!(4,4);
 }
 }

 glUniformMatrix4fv(programs.main.view, 1, GL_TRUE,
 cam.camera.value_ptr);
 glUniformMatrix3fv(programs.main.inv_rot, 1, GL_TRUE,
 cam.orientation.to_matrix!(3,3).inverse.value_ptr);
 ------------------------------------------------------------------------

 I hope this gave you a little introduction of gl3n.

 - dav1d
We talked yesterday about this topic a bit (freenode.#D): klickverbot dav1d: Just to clear up the confusion, scientific linear algebra stuff is a completely different beast than game math. Games is fast 4x4 matrices, numerics is intricate algorithms for 1000x1000 matrices (read: larger than you ever need in gamedev, even when your game uses string theory) klickverbot dav1d: I don't know gl3n specifically, but trust me, no gaming linear algebra lib is ever going to be a viable choice for science-y things and vice versa klickverbot dav1d: I mean, a gaming lib would e.g. never have LU, Cholesky, and all other different kinds of decomposition algorithms Well, I don't know a lot about this topic (scientific linear algebra), but it seems that they have different aims.
Dec 03 2011
parent Peter Alexander <peter.alexander.au gmail.com> writes:
On 4/12/11 12:56 AM, David wrote:
 Am 04.12.2011 01:38, schrieb dsimcha:
 I don't know much about computer graphics but I take it that a sane
 design for a matrix/vector library geared towards graphics is completely
 different from one geared towards general numerics/scientific computing?
 I'm trying to understand whether SciD (which uses BLAS/LAPACK and
 expression templates) overlaps with this at all.
klickverbot dav1d: Just to clear up the confusion, scientific linear algebra stuff is a completely different beast than game math. Games is fast 4x4 matrices, numerics is intricate algorithms for 1000x1000 matrices (read: larger than you ever need in gamedev, even when your game uses string theory) klickverbot dav1d: I don't know gl3n specifically, but trust me, no gaming linear algebra lib is ever going to be a viable choice for science-y things and vice versa klickverbot dav1d: I mean, a gaming lib would e.g. never have LU, Cholesky, and all other different kinds of decomposition algorithms Well, I don't know a lot about this topic (scientific linear algebra), but it seems that they have different aims.
That's right. Game maths revolves around small vectors and matrices, typically never above 4x4.
Dec 04 2011
prev sibling next sibling parent "Eric Poggel (JoeCoder)" <dnewsgroup2 yage3d.net> writes:
On 12/2/2011 5:36 PM, David wrote:
 Hello,

 I am currently working on gl3n - https://bitbucket.org/dav1d/gl3n - gl3n
 provides all the math you need to work with OpenGL, DirectX or just
 vectors and matrices (it's mainly targeted at graphics - gl3n will never
 be more then a pure math library). What it supports:

 - dav1d
I can see myself using this. Thanks for your work.
Dec 04 2011
prev sibling next sibling parent David <d dav1d.de> writes:
Ah finally, I spent today some work on adding and finishing the 
documentation, the result: http://dav1d.bitbucket.org/gl3n/index.html

Thanks for all your suggestions and the positive feedback so far :)

- dav1d
Dec 04 2011
prev sibling next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
David:

 I am currently working on gl3n - https://bitbucket.org/dav1d/gl3n - gl3n 
 provides all the math you need to work with OpenGL, DirectX or just 
 vectors and matrices (it's mainly targeted at graphics - gl3n will never 
 be more then a pure math library). What it supports:
 
   * vectors
   * matrices
   * quaternions
   * interpolation (lerp, slerp, hermite, catmull rom, nearest)
   * nearly all glsl functions (according to spec 4.1)
   * some more cool features, like templated types (vectors, matrices,
     quats), cool ctors, dynamic swizzling
This seems the 15th D implementation of certain things I've seen so far. Also to avoid further duplication I'd like 2D/3D/4D vectors (for game or graphics purposes) in Phobos. Bye, bearophile
Dec 04 2011
parent reply bls <bizprac orange.fr> writes:
On 12/04/2011 03:39 PM, bearophile wrote:
This seems the 15th D implementation of certain things I've seen so far. Also
to avoid further duplication I'd like 2D/3D/4D vectors (for game or graphics
purposes) in Phobos.
Isn't he a nice guy ? Since 5, maybe 6, years bearophile is complaining that D is not Python. And in case that bearophile is not in the mood to complain he fires up some obscure benchmarks or he is telling you why language X Y Z is better than D. Pretty annoying imho. My 2 cents OK, Somehow your announcement implicates that you've implemented a DirectX wrapper. "gl3n provides all the math you need to work with OpenGL, DirectX or just vectors and matrices,,, True ? Avail. ? Bjoern
Dec 04 2011
parent David <d dav1d.de> writes:
Am 05.12.2011 04:00, schrieb bls:
 On 12/04/2011 03:39 PM, bearophile wrote:
 This seems the 15th D implementation of certain things I've seen so
 far. Also to avoid further duplication I'd like 2D/3D/4D vectors (for
 game or graphics purposes) in Phobos.
Isn't he a nice guy ? Since 5, maybe 6, years bearophile is complaining that D is not Python. And in case that bearophile is not in the mood to complain he fires up some obscure benchmarks or he is telling you why language X Y Z is better than D. Pretty annoying imho. My 2 cents OK, Somehow your announcement implicates that you've implemented a DirectX wrapper. "gl3n provides all the math you need to work with OpenGL, DirectX or just vectors and matrices,,, True ? Avail. ? Bjoern
Hehe, I wrote gl3n, because of a lack of alternatives and gl3n isn't intended to be merged into phobos! Oh DirectX, it is "just" "vectors and matrices", I think I'll remove DirectX (also I never used DirectX, so I can't tell a lot about it), thanks for pointing it out. - dav1d
Dec 05 2011
prev sibling parent reply ParticlePeter <ParticlePeter gmx.de> writes:
Hi David,

what a lovely Library, very useful for me right now. I am using Derelict and
have
just right now written my first Shader Projection Matrix ( as Uniform ). As far
as
I can see, there is no code for a Projection Matrix in your Lib ( ignore this
if I
have just missed it ), so the attached method should do it.
( I found the original code here:
http://www.geeks3d.com/20090729/howto-perspective-projection-matrix-in-opengl/ )

Now, a little embarrassing ... :-) I am with D for around 2 Weeks now, so ...
how
can I actually use your modules ?
I am using VisualD, in the prefs I added the Path to the source code, but I am
getting "cannot find symbol blah" when I build my project. Any idea why ? The d
files are found, but what do I have to import ?

Cheers, ParticlePeter


begin 644 linalg_project.d

M=BP 9FQO870 87-P96-T+"!F;&]A="!Z;F5A<BP 9FQO870 >F9A<B`I("![

M="!X>6UA>"`]('IN96%R("H =&%N*"!F;W8 *B!025]/5D527S,V,"`I(#L-
M" EF;&]A="!Y;6EN(#T +7AY;6%X.PT*"69L;V%T('AM:6X /2`M>'EM87 [


M;F5A<CL-" EF;&]A="!Q(#T

M;&]A="!W(#T






M6S-=(#T

',#L-" T*?0``
`
end
Dec 05 2011
parent reply David <d dav1d.de> writes:
Am 05.12.2011 13:30, schrieb ParticlePeter:
 Hi David,

 what a lovely Library, very useful for me right now. I am using Derelict and
have
 just right now written my first Shader Projection Matrix ( as Uniform ). As
far as
 I can see, there is no code for a Projection Matrix in your Lib ( ignore this
if I
 have just missed it ), so the attached method should do it.
 ( I found the original code here:
 http://www.geeks3d.com/20090729/howto-perspective-projection-matrix-in-opengl/
)

 Now, a little embarrassing ... :-) I am with D for around 2 Weeks now, so ...
how
 can I actually use your modules ?
 I am using VisualD, in the prefs I added the Path to the source code, but I am
 getting "cannot find symbol blah" when I build my project. Any idea why ? The d
 files are found, but what do I have to import ?

 Cheers, ParticlePeter


 begin 644 linalg_project.d

 M=BP 9FQO870 87-P96-T+"!F;&]A="!Z;F5A<BP 9FQO870 >F9A<B`I("![

 M="!X>6UA>"`]('IN96%R("H =&%N*"!F;W8 *B!025]/5D527S,V,"`I(#L-
 M" EF;&]A="!Y;6EN(#T +7AY;6%X.PT*"69L;V%T('AM:6X /2`M>'EM87 [


 M;F5A<CL-" EF;&]A="!Q(#T

 M;&]A="!W(#T






 M6S-=(#T

 ',#L-" T*?0``
 `
 end
Hi Great you like gl3n. For a projection-matrix use: mat4.perspective or if you want an orthographic: mat4.orthographic, unfortunatly ddoc ignores this block (I think because of "static if(isFloatingPoint!mt)", it begins here: https://bitbucket.org/dav1d/gl3n/src/affe3816c7a4/gl3n/linalg.d#cl-1080 I don't know VisualD but you've normally to add the path to the files (base dir, it is -Ipath/goes/here for dmd) and also each file, it could look like this: -Igl3n/ gl3n/interpolate.d gl3n/linalg.d gl3n/math.d gl3n/util.d my_prog.d and in my_prog.d you import the parts of gl3n as follows: import gl3n.linalg; // if you want linear algebra, vectors, matrices and quats import gl3n.math; // if you need math, normally you always do! import gl3n.interpolate; // for interpolation functions import gl3n.util; // to check for types Hope this helps - dav1d
Dec 05 2011
parent reply ParticlePeter <ParticlePeter gmx.de> writes:
Hi,

and sorry, I found the perspective method just right now :-)

Unfortunately this does not help, still having issues. I will ask on the VisualD
Forum.
Meanwhile, I just copied the files into my project dir, and there it works fine,
so I can play around :-)

Cheers, ParticlePeter
Dec 05 2011
parent Mike Parker <aldacron gmail.com> writes:
On 12/5/2011 10:49 PM, ParticlePeter wrote:
 Hi,

 and sorry, I found the perspective method just right now :-)

 Unfortunately this does not help, still having issues. I will ask on the
VisualD
 Forum.
 Meanwhile, I just copied the files into my project dir, and there it works
fine,
 so I can play around :-)

 Cheers, ParticlePeter
Your problem comes from misunderstanding what 'import' means. The import statement is important for the compilation stage. When module A imports module B, the compiler can know what types/functions/templates and so on are available for module A to use. But that's only half the story. You also need to make sure that module B is compiled and linked into the final executable. In your case, you could compile gl3n as a library and link to it or, as you have discovered, add them to your project so that they are compiled along with your own source modules. Otherwise, you will get errors aout missing symbols.
Dec 05 2011