dav1d
Joined: 12 Sep 2011 Posts: 40
|
Posted: Tue Nov 29, 2011 9:30 am Post subject: gl3n |
|
|
Hello,
This has nothing to do with derelict directly, more with OpenGL.
I've recently written, well I am still working on it, gl3n, it's a D library which provides all the math you need to work with OpenGL, currently it supports vector, matrices, quats, interpolation (lerp, slerp, hermite, catmull rom, nearest) and nearly all math functions available in GLSL (according to spec 4.1). The reason why I present it here is, I need some help, ideas, things you miss or need, because I am quite new to OpenGL programming (about 3 month). Unfortunatly there is no documentation, but it's on my TODO list , but it shouldn't be hard to understand how it works, if you need some help, take a look inside the source, I did add unittests to each function/method so it shouldn't be hard to get it working. Furthermore I am often at #D on freenode.
Some examples:
Code: | 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
mat4.translation(-0.5f, -0.54f, 0.42f).rotatex(PI).rotatez(PI/2).value_ptr;
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);
|
And the source, which is licensed under MIT: https://bitbucket.org/dav1d/gl3n/overview
Would be cool, if I could get some feedback .
PS: I hope it is ok, when I post this here. |
|